* 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
65 lines
1.9 KiB
Go
65 lines
1.9 KiB
Go
package action
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/slack-go/slack"
|
|
"github.com/slack-go/slack/socketmode"
|
|
"go.uber.org/zap"
|
|
"houston/appcontext"
|
|
"houston/internal/processor/action/view"
|
|
"houston/logger"
|
|
"houston/pkg/slackbot"
|
|
rcaService "houston/service/rca/impl"
|
|
)
|
|
|
|
type HoustonCommandAction struct {
|
|
socketModeClient *socketmode.Client
|
|
slackBot *slackbot.Client
|
|
rcaService *rcaService.RcaService
|
|
}
|
|
|
|
func NewHoustonCommandAction(
|
|
socketModeClient *socketmode.Client,
|
|
slackBot *slackbot.Client,
|
|
rcaService *rcaService.RcaService,
|
|
) *HoustonCommandAction {
|
|
return &HoustonCommandAction{
|
|
socketModeClient: socketModeClient,
|
|
slackBot: slackBot,
|
|
rcaService: rcaService,
|
|
}
|
|
}
|
|
|
|
func (action *HoustonCommandAction) 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
|
|
}
|
|
|
|
result, err := appcontext.GetIncidentRepo().FindIncidentByChannelId(cmd.ChannelID)
|
|
if err != nil {
|
|
logger.Error("FindIncidentBySlackChannelId errors",
|
|
zap.String("channel_id", cmd.ChannelID), zap.String("channel", cmd.ChannelName),
|
|
zap.String("user_id", cmd.UserID), zap.Error(err))
|
|
return
|
|
}
|
|
|
|
if result != nil {
|
|
logger.Info("Result", zap.String("result", result.IncidentName))
|
|
payload := view.ExistingIncidentOptionsBlock()
|
|
action.socketModeClient.Ack(*evt.Request, payload)
|
|
}
|
|
_, err = action.slackBot.GetConversationInfo(cmd.ChannelID)
|
|
var payload map[string]interface{}
|
|
if err != nil && err.Error() == "channel_not_found" {
|
|
payload = view.IntegrateHoustonInChannelBlock()
|
|
} else {
|
|
payload = view.NewIncidentBlock()
|
|
}
|
|
action.socketModeClient.Ack(*evt.Request, payload)
|
|
}
|
|
|
|
var genericBackendError = fmt.Errorf("something went wrong. Please retry after sometime or run `/houston` command")
|