Files
houston-be/internal/processor/channel_unarchive_event_processor.go
Vijay Joshi 0ed941abc3 INFRA-3151 : Add unarchival listener to add houston bot to incident slack channel (#416)
* INFRA-3151 : Add unarchival listener to add houston bot to incident slack channel

* INFRA-3151 : review comments

* INFRA-3151 : format fix
2024-04-12 18:53:06 +05:30

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