* INFRA-3151 : Add unarchival listener to add houston bot to incident slack channel * INFRA-3151 : review comments * INFRA-3151 : format fix
34 lines
931 B
Go
34 lines
931 B
Go
package processor
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/slack-go/slack/slackevents"
|
|
"github.com/slack-go/slack/socketmode"
|
|
"houston/appcontext"
|
|
"houston/common/metrics"
|
|
"houston/logger"
|
|
"houston/service/incident"
|
|
)
|
|
|
|
type ChannelUnarchivalEventProcessor struct {
|
|
incidentService incident.IIncidentService
|
|
}
|
|
|
|
func NewChannelUnarchivalEventProcessor() *ChannelUnarchivalEventProcessor {
|
|
return &ChannelUnarchivalEventProcessor{
|
|
incidentService: appcontext.GetIncidentService(),
|
|
}
|
|
}
|
|
|
|
func (processor *ChannelUnarchivalEventProcessor) ProcessCommand(
|
|
event *slackevents.ChannelUnarchiveEvent, request socketmode.Request, client *socketmode.Client,
|
|
) {
|
|
err := processor.incidentService.AddBotUponChannelUnarchival(event.Channel)
|
|
if err != nil {
|
|
logger.Error(fmt.Sprint("Error in processing channel unarchival: ", err))
|
|
metrics.PublishHoustonFlowFailureMetrics("CHANNEL_UNARCHIVAL_EVENT", err.Error())
|
|
}
|
|
|
|
client.Ack(request)
|
|
}
|