2021-09-13 21:36:36 +02:00
|
|
|
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
|
|
// See LICENSE.txt for license information.
|
|
|
|
|
|
|
|
package plugindelivery
|
|
|
|
|
|
|
|
import (
|
2022-04-07 17:42:32 +02:00
|
|
|
"github.com/mattermost/focalboard/server/services/permissions"
|
2021-09-13 21:36:36 +02:00
|
|
|
|
2021-12-10 16:46:37 +01:00
|
|
|
mm_model "github.com/mattermost/mattermost-server/v6/model"
|
2021-09-13 21:36:36 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
type PluginAPI interface {
|
|
|
|
// GetDirectChannel gets a direct message channel.
|
|
|
|
// If the channel does not exist it will create it.
|
2021-12-10 16:46:37 +01:00
|
|
|
GetDirectChannel(userID1, userID2 string) (*mm_model.Channel, error)
|
2021-09-13 21:36:36 +02:00
|
|
|
|
|
|
|
// CreatePost creates a post.
|
2021-12-10 16:46:37 +01:00
|
|
|
CreatePost(post *mm_model.Post) error
|
2021-09-13 21:36:36 +02:00
|
|
|
|
2021-09-20 23:32:47 +02:00
|
|
|
// GetUserByID gets a user by their ID.
|
2021-12-10 16:46:37 +01:00
|
|
|
GetUserByID(userID string) (*mm_model.User, error)
|
2021-09-13 21:36:36 +02:00
|
|
|
|
|
|
|
// GetUserByUsername gets a user by their username.
|
2021-12-10 16:46:37 +01:00
|
|
|
GetUserByUsername(name string) (*mm_model.User, error)
|
2021-09-20 23:32:47 +02:00
|
|
|
|
|
|
|
// GetTeamMember gets a team member by their user id.
|
2021-12-10 16:46:37 +01:00
|
|
|
GetTeamMember(teamID string, userID string) (*mm_model.TeamMember, error)
|
2021-09-20 23:32:47 +02:00
|
|
|
|
|
|
|
// GetChannelByID gets a Channel by its ID.
|
2021-12-10 16:46:37 +01:00
|
|
|
GetChannelByID(channelID string) (*mm_model.Channel, error)
|
2021-12-03 19:33:59 +01:00
|
|
|
|
|
|
|
// GetChannelMember gets a channel member by userID.
|
2021-12-10 16:46:37 +01:00
|
|
|
GetChannelMember(channelID string, userID string) (*mm_model.ChannelMember, error)
|
2021-12-03 19:33:59 +01:00
|
|
|
|
|
|
|
// IsErrNotFound returns true if `err` or one of its wrapped children are the `ErrNotFound`
|
|
|
|
// as defined in the plugin API.
|
|
|
|
IsErrNotFound(err error) bool
|
2021-09-13 21:36:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// PluginDelivery provides ability to send notifications to direct message channels via Mattermost plugin API.
|
|
|
|
type PluginDelivery struct {
|
2022-04-07 17:42:32 +02:00
|
|
|
botID string
|
|
|
|
serverRoot string
|
|
|
|
api PluginAPI
|
|
|
|
permissions permissions.PermissionsService
|
2021-09-13 21:36:36 +02:00
|
|
|
}
|
|
|
|
|
2022-04-07 17:42:32 +02:00
|
|
|
func New(botID string, serverRoot string, api PluginAPI, permissions permissions.PermissionsService) *PluginDelivery {
|
2021-09-13 21:36:36 +02:00
|
|
|
return &PluginDelivery{
|
2022-04-07 17:42:32 +02:00
|
|
|
botID: botID,
|
|
|
|
serverRoot: serverRoot,
|
|
|
|
api: api,
|
|
|
|
permissions: permissions,
|
2021-09-20 23:32:47 +02:00
|
|
|
}
|
|
|
|
}
|