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
This commit is contained in:
Vijay Joshi
2024-04-12 18:53:06 +05:30
committed by GitHub
parent 602db7741c
commit 0ed941abc3
12 changed files with 158 additions and 8 deletions

View File

@@ -61,6 +61,24 @@ func (r *Repository) GetUnArchivedChannelsForTerminalIncidents() ([]IncidentChan
return incidentChannels, nil
}
func (r *Repository) GetIncidentChannelBySlackChannelId(channelId string) (*IncidentChannelEntity, error) {
var incidentChannel *IncidentChannelEntity
query := r.gormClient.
Table("incident_channel").
Where("incident_channel.slack_channel = ?", channelId).
Joins("JOIN incident ON incident_channel.slack_channel = incident.slack_channel")
if err := query.First(&incidentChannel).Error; err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
return nil, nil
}
return nil, err
}
return incidentChannel, nil
}
func (r *Repository) UpdateIncidentChannelArchivalStatuses(incidentChannelIds []uint, archivalStatus bool) error {
err := r.gormClient.
Model(&IncidentChannelEntity{}).

View File

@@ -3,5 +3,6 @@ package incident_channel
type IncidentChannelRepositoryInterface interface {
GetIncidentChannels(incidentID uint) ([]IncidentChannelEntity, error)
GetUnArchivedChannelsForTerminalIncidents() ([]IncidentChannelEntity, error)
GetIncidentChannelBySlackChannelId(channelId string) (*IncidentChannelEntity, error)
UpdateIncidentChannelArchivalStatuses(incidentChannelIds []uint, archivalStatus bool) error
}