forked from mattermost-community/focalboard
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
@mention support (mattermost-community#1147)
- Loading branch information
Showing
23 changed files
with
1,209 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/mattermost/focalboard/server/services/notify" | ||
"github.com/mattermost/focalboard/server/services/notify/notifymentions" | ||
"github.com/mattermost/focalboard/server/services/notify/plugindelivery" | ||
|
||
pluginapi "github.com/mattermost/mattermost-plugin-api" | ||
|
||
"github.com/mattermost/mattermost-server/v6/model" | ||
|
||
"github.com/mattermost/mattermost-server/v6/shared/mlog" | ||
) | ||
|
||
const ( | ||
botUsername = "boards" | ||
botDisplayname = "Boards" | ||
botDescription = "Created by Boards plugin." | ||
) | ||
|
||
func createMentionsNotifyBackend(client *pluginapi.Client, serverRoot string, logger *mlog.Logger) (notify.Backend, error) { | ||
bot := &model.Bot{ | ||
Username: botUsername, | ||
DisplayName: botDisplayname, | ||
Description: botDescription, | ||
} | ||
botID, err := client.Bot.EnsureBot(bot) | ||
if err != nil { | ||
return nil, fmt.Errorf("failed to ensure %s bot: %w", botDisplayname, err) | ||
} | ||
|
||
pluginAPI := &pluginAPIAdapter{client: client} | ||
|
||
delivery := plugindelivery.New(botID, serverRoot, pluginAPI) | ||
|
||
backend := notifymentions.New(delivery, logger) | ||
|
||
return backend, nil | ||
} | ||
|
||
type pluginAPIAdapter struct { | ||
client *pluginapi.Client | ||
} | ||
|
||
func (da *pluginAPIAdapter) GetDirectChannel(userID1, userID2 string) (*model.Channel, error) { | ||
return da.client.Channel.GetDirect(userID1, userID2) | ||
} | ||
|
||
func (da *pluginAPIAdapter) CreatePost(post *model.Post) error { | ||
return da.client.Post.CreatePost(post) | ||
} | ||
|
||
func (da *pluginAPIAdapter) GetUserByID(userID string) (*model.User, error) { | ||
return da.client.User.Get(userID) | ||
} | ||
|
||
func (da *pluginAPIAdapter) GetUserByUsername(name string) (*model.User, error) { | ||
return da.client.User.GetByUsername(name) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.