nomadcode/services/core/internal/notification/service.go
toki 11490df648 chore: import nomadcode-core into services/core
git-subtree-dir: services/core
git-subtree-mainline: 6f5e3a119f
git-subtree-split: 6fdbc73753
2026-05-21 13:35:20 +09:00

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,
})
}