diff --git a/server/services/notify/notifysubscriptions/diff2slackattachments.go b/server/services/notify/notifysubscriptions/diff2slackattachments.go index 98c8f64d2..a62564b41 100644 --- a/server/services/notify/notifysubscriptions/diff2slackattachments.go +++ b/server/services/notify/notifysubscriptions/diff2slackattachments.go @@ -21,7 +21,7 @@ import ( const ( // card change notifications. defAddCardNotify = "{{.Authors | printAuthors \"unknown_user\" }} has added the card {{. | makeLink}}\n" - defModifyCardNotify = "###### {{.Authors | printAuthors \"unknown_user\" }} has modified the card {{. | makeLink}}\n" + defModifyCardNotify = "###### {{.Authors | printAuthors \"unknown_user\" }} has modified the card {{. | makeLink}} on the board {{. | makeBoardLink}}\n" defDeleteCardNotify = "{{.Authors | printAuthors \"unknown_user\" }} has deleted the card {{. | makeLink}}\n" ) @@ -33,9 +33,10 @@ var ( // DiffConvOpts provides options when converting diffs to slack attachments. type DiffConvOpts struct { - Language string - MakeCardLink func(block *model.Block, board *model.Board, card *model.Block) string - Logger *mlog.Logger + Language string + MakeCardLink func(block *model.Block, board *model.Board, card *model.Block) string + MakeBoardLink func(board *model.Board) string + Logger *mlog.Logger } // getTemplate returns a new or cached named template based on the language specified. @@ -53,11 +54,20 @@ func getTemplate(name string, opts DiffConvOpts, def string) (*template.Template return fmt.Sprintf("`%s`", block.Title) } } + + if opts.MakeBoardLink == nil { + opts.MakeBoardLink = func(board *model.Board) string { + return fmt.Sprintf("`%s`", board.Title) + } + } myFuncs := template.FuncMap{ "getBoardDescription": getBoardDescription, "makeLink": func(diff *Diff) string { return opts.MakeCardLink(diff.NewBlock, diff.Board, diff.Card) }, + "makeBoardLink": func(diff *Diff) string { + return opts.MakeBoardLink(diff.Board) + }, "stripNewlines": func(s string) string { return strings.TrimSpace(strings.ReplaceAll(s, "\n", "ΒΆ ")) }, diff --git a/server/services/notify/notifysubscriptions/notifier.go b/server/services/notify/notifysubscriptions/notifier.go index 929babe83..5138579fc 100644 --- a/server/services/notify/notifysubscriptions/notifier.go +++ b/server/services/notify/notifysubscriptions/notifier.go @@ -204,6 +204,9 @@ func (n *notifier) notifySubscribers(hint *model.NotificationHint) error { MakeCardLink: func(block *model.Block, board *model.Board, card *model.Block) string { return fmt.Sprintf("[%s](%s)", block.Title, utils.MakeCardLink(n.serverRoot, board.TeamID, board.ID, card.ID)) }, + MakeBoardLink: func(board *model.Board) string { + return fmt.Sprintf("[%s](%s)", board.Title, utils.MakeBoardLink(n.serverRoot, board.TeamID, board.ID)) + }, Logger: n.logger, } diff --git a/server/services/notify/plugindelivery/mention_deliver.go b/server/services/notify/plugindelivery/mention_deliver.go index 4cb48a619..744331310 100644 --- a/server/services/notify/plugindelivery/mention_deliver.go +++ b/server/services/notify/plugindelivery/mention_deliver.go @@ -24,11 +24,12 @@ func (pd *PluginDelivery) MentionDeliver(mentionedUser *mm_model.User, extract s return "", fmt.Errorf("cannot get direct channel: %w", err) } link := utils.MakeCardLink(pd.serverRoot, evt.Board.TeamID, evt.Board.ID, evt.Card.ID) + boardLink := utils.MakeBoardLink(pd.serverRoot, evt.Board.TeamID, evt.Board.ID) post := &mm_model.Post{ UserId: pd.botID, ChannelId: channel.Id, - Message: formatMessage(author.Username, extract, evt.Card.Title, link, evt.BlockChanged), + Message: formatMessage(author.Username, extract, evt.Card.Title, link, evt.BlockChanged, boardLink, evt.Board.Title), } return mentionedUser.Id, pd.api.CreatePost(post) } diff --git a/server/services/notify/plugindelivery/message.go b/server/services/notify/plugindelivery/message.go index f627bf3b7..78476f32f 100644 --- a/server/services/notify/plugindelivery/message.go +++ b/server/services/notify/plugindelivery/message.go @@ -11,14 +11,14 @@ import ( const ( // TODO: localize these when i18n is available. - defCommentTemplate = "@%s mentioned you in a comment on the card [%s](%s)\n> %s" - defDescriptionTemplate = "@%s mentioned you in the card [%s](%s)\n> %s" + defCommentTemplate = "@%s mentioned you in a comment on the card [%s](%s) in board [%s](%s)\n> %s" + defDescriptionTemplate = "@%s mentioned you in the card [%s](%s) in board [%s](%s)\n> %s" ) -func formatMessage(author string, extract string, card string, link string, block *model.Block) string { +func formatMessage(author string, extract string, card string, link string, block *model.Block, boardLink string, board string) string { template := defDescriptionTemplate if block.Type == model.TypeComment { template = defCommentTemplate } - return fmt.Sprintf(template, author, card, link, extract) + return fmt.Sprintf(template, author, card, link, board, boardLink, extract) } diff --git a/server/utils/links.go b/server/utils/links.go index f4adb0103..06c8b6c4f 100644 --- a/server/utils/links.go +++ b/server/utils/links.go @@ -9,3 +9,7 @@ import "fmt" func MakeCardLink(serverRoot string, teamID string, boardID string, cardID string) string { return fmt.Sprintf("%s/team/%s/%s/0/%s", serverRoot, teamID, boardID, cardID) } + +func MakeBoardLink(serverRoot string, teamID string, board string) string { + return fmt.Sprintf("%s/team/%s/%s", serverRoot, teamID, board) +}