TP-47107| added restriction to not update incident to same status (#318)

This commit is contained in:
Gullipalli Chetan Kumar
2023-12-12 13:41:24 +05:30
committed by GitHub
parent bcb352b5b6
commit 14b360d0e5
3 changed files with 20 additions and 4 deletions

View File

@@ -93,3 +93,11 @@ func PostArchivingTimeToIncidentChannel(channelId string, incidentStatus string,
_, _, errMessage := client.PostMessage(channelId, msgOption)
return errMessage
}
func PostIncidentStatusErrorMessage(status, channelId, userId string, client *socketmode.Client) {
message := fmt.Sprintf("current incident status is already `%s`", status)
_, errMessage := client.PostEphemeral(channelId, userId, slack.MsgOptionText(message, false))
if errMessage != nil {
logger.Error(fmt.Sprintf("post response failed for channel id %s", channelId), zap.String("message", message), zap.Error(errMessage))
}
}

View File

@@ -45,7 +45,10 @@ func (irp *ResolveIncidentAction) IncidentResolveProcess(callback slack.Interact
zap.String("channel", channelId),
zap.String("user_id", callback.User.ID), zap.Error(err))
}
if incidentEntity.Status == incident.ResolvedId {
util.PostIncidentStatusErrorMessage(incident.Resolved, channelId, callback.User.ID, irp.client)
return
}
incidentStatusEntity, _ := irp.incidentService.FindIncidentStatusByName(incident.Resolved)
//check if active tags are set or else throw error
var flag = true

View File

@@ -82,6 +82,14 @@ func (isp *UpdateIncidentAction) IncidentUpdateStatus(callback slack.Interaction
zap.String("user_id", user.ID), zap.Error(err))
return
}
var payload interface{}
isp.client.Ack(*request, payload)
channelId := callback.View.PrivateMetadata
if incidentEntity.Status == result.ID {
util.PostIncidentStatusErrorMessage(result.Name, channelId, callback.User.ID, isp.client)
return
}
tags, err := isp.tagService.FindTagsByTeamId(incidentEntity.TeamId)
if err != nil || tags == nil {
@@ -115,7 +123,6 @@ func (isp *UpdateIncidentAction) IncidentUpdateStatus(callback slack.Interaction
}
}
incidentEntity.Status = result.ID
incidentEntity.UpdatedBy = user.ID
@@ -154,8 +161,6 @@ func (isp *UpdateIncidentAction) IncidentUpdateStatus(callback slack.Interaction
msgUpdate.ProcessAction(incidentEntity.SlackChannel)
}()
var payload interface{}
isp.client.Ack(*request, payload)
}
func buildUpdateIncidentStatusRequest(blockActions map[string]map[string]slack.BlockAction) uint {