Files
houston-be/internal/processor/start_incident_command_processor.go

44 lines
1.4 KiB
Go
Raw Normal View History

package processor
import (
"fmt"
"github.com/slack-go/slack/socketmode"
"houston/internal/processor/action"
"houston/logger"
"houston/pkg/slackbot"
"houston/service/orchestration"
"houston/service/products"
)
type StartIncidentCommandProcessor struct {
productsService products.ProductService
incidentOrchestrator orchestration.IncidentOrchestrator
socketModeClient *socketmode.Client
startIncidentCommandAction *action.StartIncidentCommandAction
}
const StartIncidentCommandProcessorLogTag = "[start_incident_command_processor]"
func NewStartIncidentCommandProcessor(
productsService products.ProductService,
incidentOrchestrator orchestration.IncidentOrchestrator,
socketModeClient *socketmode.Client,
slackBot *slackbot.Client,
) *StartIncidentCommandProcessor {
return &StartIncidentCommandProcessor{
productsService: productsService,
socketModeClient: socketModeClient,
startIncidentCommandAction: action.NewStartIncidentCommandAction(productsService, incidentOrchestrator, socketModeClient, slackBot),
}
}
func (processor *StartIncidentCommandProcessor) ProcessSlashCommand(event *socketmode.Event) {
defer func() {
if r := recover(); r != nil {
logger.Error(fmt.Sprintf("%s Exception occurred: %+v", StartIncidentCommandProcessorLogTag, r.(error)))
}
}()
processor.startIncidentCommandAction.PerformAction(event)
}