git-subtree-dir: services/core git-subtree-mainline:6f5e3a119fgit-subtree-split:6fdbc73753
36 lines
798 B
Go
36 lines
798 B
Go
package notification
|
|
|
|
import (
|
|
"context"
|
|
"log/slog"
|
|
|
|
"github.com/nomadcode/nomadcode-core/internal/adapters/mattermost"
|
|
)
|
|
|
|
type Service struct {
|
|
mattermost *mattermost.Client
|
|
logger *slog.Logger
|
|
}
|
|
|
|
func NewService(mattermostClient *mattermost.Client, logger *slog.Logger) *Service {
|
|
return &Service{
|
|
mattermost: mattermostClient,
|
|
logger: logger,
|
|
}
|
|
}
|
|
|
|
func (s *Service) NotifyTaskCompleted(ctx context.Context, input TaskNotification) error {
|
|
if s.logger != nil {
|
|
s.logger.Info("task completed notification requested", "task_id", input.TaskID)
|
|
}
|
|
if s.mattermost == nil {
|
|
return nil
|
|
}
|
|
|
|
return s.mattermost.SendTaskNotification(ctx, mattermost.TaskNotificationInput{
|
|
TaskID: input.TaskID,
|
|
Title: input.Title,
|
|
Status: input.Status,
|
|
Message: input.Message,
|
|
})
|
|
}
|