mirror of
https://github.com/SecurityBrewery/catalyst.git
synced 2025-12-26 00:43:10 +01:00
@@ -7,6 +7,7 @@ import (
|
||||
"github.com/arangodb/go-driver"
|
||||
"github.com/google/uuid"
|
||||
|
||||
"github.com/SecurityBrewery/catalyst/bus"
|
||||
"github.com/SecurityBrewery/catalyst/database"
|
||||
"github.com/SecurityBrewery/catalyst/generated/model"
|
||||
)
|
||||
@@ -32,7 +33,15 @@ func (s *Service) RunJob(ctx context.Context, form *model.JobForm) (doc *model.J
|
||||
newJobID := uuid.NewString()
|
||||
|
||||
defer s.publishRequest(ctx, err, "RunJob", jobID(newJobID))
|
||||
err = s.bus.PublishJob(newJobID, form.Automation, form.Payload, msgContext, form.Origin)
|
||||
s.bus.JobChannel.Publish(&bus.JobMsg{
|
||||
ID: newJobID,
|
||||
Automation: form.Automation,
|
||||
Origin: form.Origin,
|
||||
Message: &model.Message{
|
||||
Context: msgContext,
|
||||
Payload: form.Payload,
|
||||
},
|
||||
})
|
||||
|
||||
return &model.JobResponse{
|
||||
Automation: form.Automation,
|
||||
@@ -40,7 +49,7 @@ func (s *Service) RunJob(ctx context.Context, form *model.JobForm) (doc *model.J
|
||||
Origin: form.Origin,
|
||||
Payload: form.Payload,
|
||||
Status: "published",
|
||||
}, err
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *Service) GetJob(ctx context.Context, id string) (*model.JobResponse, error) {
|
||||
|
||||
@@ -2,7 +2,6 @@ package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log"
|
||||
|
||||
"github.com/arangodb/go-driver"
|
||||
|
||||
@@ -34,10 +33,10 @@ func (s *Service) publishRequest(ctx context.Context, err error, function string
|
||||
userID = user.ID
|
||||
}
|
||||
|
||||
go func() {
|
||||
if err := s.bus.PublishRequest(userID, function, ids); err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
}()
|
||||
s.bus.RequestChannel.Publish(&bus.RequestMsg{
|
||||
User: userID,
|
||||
Function: function,
|
||||
IDs: ids,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"github.com/arangodb/go-driver"
|
||||
"github.com/google/uuid"
|
||||
|
||||
"github.com/SecurityBrewery/catalyst/bus"
|
||||
"github.com/SecurityBrewery/catalyst/database"
|
||||
"github.com/SecurityBrewery/catalyst/generated/api"
|
||||
"github.com/SecurityBrewery/catalyst/generated/model"
|
||||
@@ -135,7 +136,17 @@ func (s *Service) RunArtifact(ctx context.Context, id int64, name string, automa
|
||||
jobID := uuid.NewString()
|
||||
origin := &model.Origin{ArtifactOrigin: &model.ArtifactOrigin{TicketId: id, Artifact: name}}
|
||||
|
||||
return s.bus.PublishJob(jobID, automation, map[string]string{"default": name}, &model.Context{Artifact: artifact}, origin)
|
||||
s.bus.JobChannel.Publish(&bus.JobMsg{
|
||||
ID: jobID,
|
||||
Automation: automation,
|
||||
Origin: origin,
|
||||
Message: &model.Message{
|
||||
Context: &model.Context{Artifact: artifact},
|
||||
Payload: map[string]string{"default": name},
|
||||
},
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *Service) AddComment(ctx context.Context, i int64, form *model.CommentForm) (doc *model.TicketWithTickets, err error) {
|
||||
|
||||
Reference in New Issue
Block a user