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:
@@ -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{}).
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user