|
|
|
|
@@ -71,7 +71,7 @@ func NewIncidentServiceV2(db *gorm.DB) *IncidentServiceV2 {
|
|
|
|
|
|
|
|
|
|
const logTag = "[create-incident-v2]"
|
|
|
|
|
const updateLogTag = "[update-incident-v2]"
|
|
|
|
|
const updateSeveritySlackActionCount = 5
|
|
|
|
|
const updateSeveritySlackActionCount = 6
|
|
|
|
|
const updateStatusSlackActionCount = 2
|
|
|
|
|
const updateTeamSlackActionCount = 5
|
|
|
|
|
|
|
|
|
|
@@ -425,25 +425,7 @@ func createIncidentWorkflow(
|
|
|
|
|
logger.Error(fmt.Sprintf("%s [%s] Failed to post SLA information to the slack channel", logTag, incidentName), zap.Error(err))
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if viper.GetBool("ENABLE_CONFERENCE") {
|
|
|
|
|
calendarActions := conference2.GetCalendarActions()
|
|
|
|
|
calendarService := service2.NewCalendarService(calendarActions)
|
|
|
|
|
calendarEvent, err := calendarService.CreateEvent(channel.Name)
|
|
|
|
|
conferenceLink := calendarEvent.ConferenceLink
|
|
|
|
|
if err != nil {
|
|
|
|
|
logger.Error(fmt.Sprintf("%s [%s] Error while creating conference", logTag, incidentName), zap.Error(err))
|
|
|
|
|
} else {
|
|
|
|
|
util.UpdateIncidentWithConferenceDetails(incidentEntity, calendarEvent, i.incidentRepository)
|
|
|
|
|
//ToDo Update the summary in slack channel with Conference link. To be done post update incident refactoring
|
|
|
|
|
i.slackService.AddBookmark(conferenceLink, channel, calendarService.GetConferenceTitle())
|
|
|
|
|
_, err := i.slackService.PostMessage(fmt.Sprintf(util.ConferenceMessage, conferenceLink), false, channel)
|
|
|
|
|
if err != nil {
|
|
|
|
|
logger.Error(fmt.Sprintf("%s [%s] Failed to post Conference link: %s", logTag, incidentName, conferenceLink))
|
|
|
|
|
}
|
|
|
|
|
logger.Info(fmt.Sprintf("%s [%s] Conference link posted to the channel %s", logTag, incidentName, conferenceLink))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
i.createConferenceAndPostMessageInSlack(incidentEntity)
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -1242,7 +1224,9 @@ func (i *IncidentServiceV2) UpdateSeverityWorkflow(
|
|
|
|
|
slackErrors = append(slackErrors, err)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
go util.ExecuteConcurrentAction(&waitGroup, func() {
|
|
|
|
|
i.createConferenceAndPostMessageInSlack(incidentEntity)
|
|
|
|
|
})
|
|
|
|
|
waitGroup.Wait()
|
|
|
|
|
if slackErrors != nil && len(slackErrors) != 0 {
|
|
|
|
|
return slackErrors[0]
|
|
|
|
|
@@ -1624,3 +1608,47 @@ func (i *IncidentServiceV2) addDefaultUsersToIncident(
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (i *IncidentServiceV2) createConferenceAndPostMessageInSlack(incidentEntity *incident.IncidentEntity) {
|
|
|
|
|
incidentName := incidentEntity.IncidentName
|
|
|
|
|
if viper.GetBool("ENABLE_CONFERENCE") {
|
|
|
|
|
if incidentEntity.SeverityId != incident.Sev3Id && incidentEntity.ConferenceId == "" {
|
|
|
|
|
calendarEvent, err := createConferenceEvent(incidentName)
|
|
|
|
|
conferenceLink := calendarEvent.ConferenceLink
|
|
|
|
|
if err != nil {
|
|
|
|
|
logger.Error(fmt.Sprintf("%s [%s] Error while creating conference", logTag, incidentName), zap.Error(err))
|
|
|
|
|
} else {
|
|
|
|
|
{
|
|
|
|
|
util.UpdateIncidentWithConferenceDetails(incidentEntity, calendarEvent, i.incidentRepository)
|
|
|
|
|
teamEntity, severityEntity, incidentStatusEntity, incidentChannels, err :=
|
|
|
|
|
i.FetchAllEntitiesForIncident(incidentEntity)
|
|
|
|
|
if err != nil {
|
|
|
|
|
logger.Error(fmt.Sprintf("%s Failed to fetch entities for inident: %s", logTag, incidentName))
|
|
|
|
|
}
|
|
|
|
|
processUpdateMessage(incidentEntity, teamEntity, severityEntity, incidentStatusEntity, incidentChannels, i)
|
|
|
|
|
i.addBookMarkAndPostMessageInSlack(incidentName, conferenceLink, incidentEntity.SlackChannel)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
logger.Info(fmt.Sprintf("%s Condition required to create conference has not been satisfied for the incident %s", logTag, incidentEntity.IncidentName))
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
logger.Info(fmt.Sprintf("%s Unable to create conference as conference flag is false %s", logTag, incidentEntity.IncidentName))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func createConferenceEvent(incidentName string) (conference2.EventData, error) {
|
|
|
|
|
calendarActions := conference2.GetCalendarActions()
|
|
|
|
|
calendarService := service2.NewCalendarService(calendarActions)
|
|
|
|
|
calendarEvent, err := calendarService.CreateEvent(incidentName)
|
|
|
|
|
return calendarEvent, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (i *IncidentServiceV2) addBookMarkAndPostMessageInSlack(incidentName string, conferenceLink string, slackChannel string) {
|
|
|
|
|
i.slackService.AddBookmark(conferenceLink, slackChannel, "Google Meet")
|
|
|
|
|
_, err := i.slackService.PostMessageByChannelID(fmt.Sprintf(util.ConferenceMessage, conferenceLink), false, slackChannel)
|
|
|
|
|
if err != nil {
|
|
|
|
|
logger.Error(fmt.Sprintf("%s [%s] Failed to post Conference link: %s", logTag, incidentName, conferenceLink))
|
|
|
|
|
}
|
|
|
|
|
logger.Info(fmt.Sprintf("%s [%s] Conference link posted to the incidentChannel %s", logTag, incidentName, conferenceLink))
|
|
|
|
|
}
|
|
|
|
|
|