feat: Add validation check for user account before starting task
This commit is contained in:
parent
19b96e64e1
commit
caef31f48f
@ -2,6 +2,7 @@ package plug
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"git.anthrove.art/Anthrove/otter-space-sdk/v3/pkg/database"
|
||||
"git.anthrove.art/Anthrove/otter-space-sdk/v3/pkg/models"
|
||||
@ -65,6 +66,18 @@ func (s *server) TaskStart(ctx context.Context, creation *gRPC.PlugTaskCreation)
|
||||
s.ctx[id] = cancel
|
||||
span.AddEvent("Created new context for task", trace.WithAttributes(attribute.String("task_id", id)))
|
||||
|
||||
if !userSource.AccountValidate {
|
||||
err = errors.New("user is not validated")
|
||||
|
||||
log.WithContext(taskCtx).WithError(err).WithField("task_id", id).Error("Task execution failed")
|
||||
span.RecordError(err)
|
||||
span.SetStatus(codes.Error, err.Error())
|
||||
|
||||
plugTaskState.TaskState = gRPC.PlugTaskState_STOPPED
|
||||
|
||||
return &plugTaskState, err
|
||||
}
|
||||
|
||||
log.WithContext(taskCtx).WithFields(log.Fields{
|
||||
"task_id": id,
|
||||
"user_source_id": creation.UserSourceId,
|
||||
|
Loading…
Reference in New Issue
Block a user