main

mattermost/focalboard

Last updated at: 29/12/2023 09:40

message.go

TLDR

This file contains a package called plugindelivery that includes a single function called formatMessage. The function is used to format a message with specific templates based on the type of block provided.

Methods

formatMessage

This method takes in several parameters: author (string), extract (string), card (string), link (string), block (*model.Block), boardLink (string), and board (string). It formats a message using predefined templates (defCommentTemplate or defDescriptionTemplate) based on the type of block provided. The formatted message contains information about the author, card, link, board, and extract.

Classes

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.

package plugindelivery

import (
	"fmt"

	"github.com/mattermost/focalboard/server/model"
)

const (
	// TODO: localize these when i18n is available.
	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, boardLink string, board string) string {
	template := defDescriptionTemplate
	if block.Type == model.TypeComment {
		template = defCommentTemplate
	}
	return fmt.Sprintf(template, author, card, link, board, boardLink, extract)
}