Files
houston-be/internal/processor/action/resolve_incident_command_action.go
Vijay Joshi ad96361d68 TP-49979 , TP-52174 : API to get resolution tags + resolve incident API + incident resolve entire flow refactor (#347)
* TP-49979 : Added API to get tags for resolving incident

* TP-49979 : Set up basic structure for resolve incident from UI

* TP-49979 : Complete till post rca flow

* TP-49979 : Complete till rca gen flow

* TP-52174 : rebase changes

* TP-52174 : Integrate with slack

* TP-52174 : fix error in flows

* TP-52174 : Segregate interface and impl

* TP-52174 : Fix ut failures

* TP-52174 : Fix resolve tag api error

* TP-52174 : Fix jira link bug

* TP-52174 : Remove nil

* TP-52174 : Rebase changes

* TP-52174 : Jira links table fix

* TP-52174 : Line length fix

* TP-52174 : Makefile changes

* TP-52174 : Basic bug fixes

* TP-52174 : Minor fixes

* TP-52174 : Add UT's for initial flows

* TP-52174 : Added all UT's

* TP-52174 : More PR review changes

* TP-52174 : Add UT's for incident jira and tag service

* TP-52174 : Fix jira link bug and batched create incident tags db call

* TP-52174 : Make auto archival severities configurable

* TP-52174 : Fix jira link in incident table issue
2024-02-01 15:23:15 +05:30

58 lines
2.0 KiB
Go

package action
import (
"fmt"
"github.com/slack-go/slack"
"github.com/slack-go/slack/socketmode"
"go.uber.org/zap"
"houston/appcontext"
"houston/common/util"
"houston/logger"
"houston/pkg/slackbot"
rcaService "houston/service/rca/impl"
)
const resolveIncidentActionLogTag = "[slash_command_action]"
type ResolveIncidentCommandAction struct {
socketModeClient *socketmode.Client
slackBot *slackbot.Client
rcaService *rcaService.RcaService
}
func NewResolveIncidentCommandAction(
socketModeClient *socketmode.Client,
slackBot *slackbot.Client,
rcaService *rcaService.RcaService,
) *ResolveIncidentCommandAction {
return &ResolveIncidentCommandAction{
socketModeClient: socketModeClient,
slackBot: slackBot,
rcaService: rcaService,
}
}
func (action *ResolveIncidentCommandAction) PerformAction(evt *socketmode.Event) {
cmd, ok := evt.Data.(slack.SlashCommand)
logger.Info("processing houston command", zap.Any("payload", cmd))
if !ok {
logger.Error("event data to slash command conversion failed", zap.Any("data", evt))
return
}
tagsAction := NewIncidentTagsAction(appcontext.GetIncidentRepo(), appcontext.GetTagRepo())
rcaSummaryAction := NewIncidentRCASummaryAction(appcontext.GetIncidentRepo())
jiraLinksAction := NewIncidentJiraLinksAction(appcontext.GetIncidentService(), appcontext.GetSlackService())
rcaSectionAction := NewIncidentRCASectionAction(
action.socketModeClient, appcontext.GetIncidentRepo(), appcontext.GetTeamRepo(),
appcontext.GetTagRepo(), appcontext.GetSeverityRepo(), tagsAction, rcaSummaryAction,
jiraLinksAction, action.rcaService, appcontext.GetIncidentService(),
)
err := rcaSectionAction.ProcessIncidentRCAActionRequestForSlashCommand(cmd.ChannelID, cmd.TriggerID, evt.Request, util.IncidentResolveSubmit)
if err != nil {
err := appcontext.GetSlackService().PostEphemeralByChannelID(err.Error(), cmd.UserID, false, cmd.ChannelID)
if err != nil {
logger.Error(fmt.Sprintf("%s failed to post ephemeral for create incident error. %+v", resolveIncidentActionLogTag, err))
}
}
}