feat: Add validation check for user account before starting task
All checks were successful
Gitea Build Check / Build (push) Successful in 43s
Gitea Build Check / Build (pull_request) Successful in 45s

This commit is contained in:
SoXX 2024-08-27 14:17:31 +02:00
parent 19b96e64e1
commit caef31f48f

View File

@ -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,