mirror of
https://github.com/mattermost/focalboard.git
synced 2024-12-24 13:43:12 +02:00
4b0fb92fba
- provides support for compiling Boards directly into the Mattermost suite server - a ServicesAPI interface replaces the PluginAPI to allow for implementations coming from pluginAPI and suite server. - a new product package provides a place to register Boards as a suite product and handles life-cycle events - a new boards package replaces much of the mattermost-plugin logic, allowing this to be shared between plugin and product - Boards now uses module workspaces; run make setup-go-work
41 lines
1.3 KiB
Go
41 lines
1.3 KiB
Go
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
package plugindelivery
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/mattermost/focalboard/server/services/notify"
|
|
"github.com/mattermost/focalboard/server/utils"
|
|
|
|
mm_model "github.com/mattermost/mattermost-server/v6/model"
|
|
)
|
|
|
|
// MentionDeliver notifies a user they have been mentioned in a blockv ia the plugin API.
|
|
func (pd *PluginDelivery) MentionDeliver(mentionedUser *mm_model.User, extract string, evt notify.BlockChangeEvent) (string, error) {
|
|
author, err := pd.api.GetUserByID(evt.ModifiedBy.UserID)
|
|
if err != nil {
|
|
return "", fmt.Errorf("cannot find user: %w", err)
|
|
}
|
|
|
|
channel, err := pd.getDirectChannel(evt.TeamID, mentionedUser.Id, pd.botID)
|
|
if err != nil {
|
|
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, boardLink, evt.Board.Title),
|
|
}
|
|
|
|
if _, err := pd.api.CreatePost(post); err != nil {
|
|
return "", err
|
|
}
|
|
|
|
return mentionedUser.Id, nil
|
|
}
|