TP-47107| added restriction to not update incident to same status (#318)
This commit is contained in:
committed by
GitHub
parent
bcb352b5b6
commit
14b360d0e5
@@ -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))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user