TP-12355 | Slack topic (#58)
This commit is contained in:
committed by
GitHub Enterprise
parent
4c33d459de
commit
fd77db4b8a
@@ -15,30 +15,14 @@ func IncidentSummarySection(incident *incident.IncidentEntity, team *team.TeamEn
|
||||
BlockSet: []slack.Block{
|
||||
buildSummaryHeader(incident.Title),
|
||||
buildDescriptionBlock(incident.Description),
|
||||
buildTypeAndChannelSectionBlock(incident, team.Name, severity.Name, incidentStatus.Name)},
|
||||
buildTypeAndChannelSectionBlock(incident, team.Name),
|
||||
buildSeverityAndTicketSectionBlock(severity.Name),
|
||||
buildStatusAndMeetLinkSectionBlock(incidentStatus.Name),
|
||||
buildCreatedByAndCreatedAtSectionBlock(incident),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func buildTypeAndChannelSectionBlock(incident *incident.IncidentEntity, teamName, severityName, incidentStatus string) *slack.SectionBlock {
|
||||
fields := []*slack.TextBlockObject{}
|
||||
|
||||
fields = append(fields,
|
||||
|
||||
slack.NewTextBlockObject("mrkdwn", fmt.Sprintf("*Type*\n%s", teamName), false, false),
|
||||
slack.NewTextBlockObject("mrkdwn", fmt.Sprintf("*Channel*\n<#%s>", incident.SlackChannel), false, false),
|
||||
slack.NewTextBlockObject("mrkdwn", fmt.Sprintf("*Severity*\n%s", severityName), false, false),
|
||||
slack.NewTextBlockObject("mrkdwn", fmt.Sprintf("*Ticket*\n%s", "Integration Disabled"), false, false),
|
||||
slack.NewTextBlockObject("mrkdwn", fmt.Sprintf("*Status*\n%s", incidentStatus), false, false),
|
||||
slack.NewTextBlockObject("mrkdwn", fmt.Sprintf("*Meeting*\n%s", "Integration Disabled"), false, false),
|
||||
slack.NewTextBlockObject("mrkdwn", fmt.Sprintf("*Created by*\n%s", fmt.Sprintf("*<@%s>*", incident.CreatedBy)), false, false),
|
||||
slack.NewTextBlockObject("mrkdwn", fmt.Sprintf("*Created at*\n%s", fmt.Sprintf("%s %d", incident.CreatedAt.Month(), incident.CreatedAt.Day())), false, false),
|
||||
)
|
||||
|
||||
block := slack.NewSectionBlock(nil, fields, nil)
|
||||
|
||||
return block
|
||||
}
|
||||
|
||||
func IncidentEphemeralMessage(incident *incident.IncidentEntity, blocks slack.Blocks) slack.MsgOption {
|
||||
color := util.GetColorBySeverity(incident.SeverityId)
|
||||
return slack.MsgOptionAttachments(slack.Attachment{Blocks: blocks, Color: color})
|
||||
@@ -57,3 +41,43 @@ func buildDescriptionBlock(incidentDescription string) *slack.SectionBlock {
|
||||
|
||||
return headerSection
|
||||
}
|
||||
|
||||
func buildTypeAndChannelSectionBlock(incident *incident.IncidentEntity, teamName string) *slack.SectionBlock {
|
||||
fields := []*slack.TextBlockObject{
|
||||
slack.NewTextBlockObject("mrkdwn", fmt.Sprintf("*Type*\n%s", teamName), false, false),
|
||||
slack.NewTextBlockObject("mrkdwn", fmt.Sprintf("*Channel*\n%s", incident.SlackChannel), false, false),
|
||||
}
|
||||
block := slack.NewSectionBlock(nil, fields, nil)
|
||||
|
||||
return block
|
||||
}
|
||||
|
||||
func buildSeverityAndTicketSectionBlock(severityName string) *slack.SectionBlock {
|
||||
fields := []*slack.TextBlockObject{
|
||||
slack.NewTextBlockObject("mrkdwn", fmt.Sprintf("*Severity*\n%s", severityName), false, false),
|
||||
slack.NewTextBlockObject("mrkdwn", fmt.Sprintf("*Ticket*\n%s", "Integration Disabled"), false, false),
|
||||
}
|
||||
block := slack.NewSectionBlock(nil, fields, nil)
|
||||
|
||||
return block
|
||||
}
|
||||
|
||||
func buildStatusAndMeetLinkSectionBlock(incidentStatus string) *slack.SectionBlock {
|
||||
fields := []*slack.TextBlockObject{
|
||||
slack.NewTextBlockObject("mrkdwn", fmt.Sprintf("*Status*\n%s", incidentStatus), false, false),
|
||||
slack.NewTextBlockObject("mrkdwn", fmt.Sprintf("*Meeting*\n%s", "Integration Disabled"), false, false),
|
||||
}
|
||||
block := slack.NewSectionBlock(nil, fields, nil)
|
||||
|
||||
return block
|
||||
}
|
||||
|
||||
func buildCreatedByAndCreatedAtSectionBlock(incident *incident.IncidentEntity) *slack.SectionBlock {
|
||||
fields := []*slack.TextBlockObject{
|
||||
slack.NewTextBlockObject("mrkdwn", fmt.Sprintf("*Created by*\n%s", fmt.Sprintf("*<@%s>*", incident.CreatedBy)), false, false),
|
||||
slack.NewTextBlockObject("mrkdwn", fmt.Sprintf("*Created at*\n%s", fmt.Sprintf("%s %d", incident.CreatedAt.Month(), incident.CreatedAt.Day())), false, false),
|
||||
}
|
||||
block := slack.NewSectionBlock(nil, fields, nil)
|
||||
|
||||
return block
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user