focalboard/server/services/notify/plugindelivery/plugin_delivery.go

53 lines
1.7 KiB
Go
Raw Normal View History

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 (
mm_model "github.com/mattermost/mattermost-server/v6/model"
2021-09-13 21:36:36 +02:00
)
type servicesAPI interface {
2021-09-13 21:36:36 +02:00
// GetDirectChannel gets a direct message channel.
// If the channel does not exist it will create it.
GetDirectChannel(userID1, userID2 string) (*mm_model.Channel, error)
2021-09-13 21:36:36 +02:00
// CreatePost creates a post.
CreatePost(post *mm_model.Post) (*mm_model.Post, error)
2021-09-13 21:36:36 +02:00
// GetUserByID gets a user by their ID.
GetUserByID(userID string) (*mm_model.User, error)
2021-09-13 21:36:36 +02:00
// GetUserByUsername gets a user by their username.
GetUserByUsername(name string) (*mm_model.User, error)
// GetTeamMember gets a team member by their user id.
GetTeamMember(teamID string, userID string) (*mm_model.TeamMember, error)
// GetChannelByID gets a Channel by its ID.
GetChannelByID(channelID string) (*mm_model.Channel, error)
// GetChannelMember gets a channel member by userID.
GetChannelMember(channelID string, userID string) (*mm_model.ChannelMember, error)
// CreateMember adds a user to the specified team. Safe to call if the user is
// already a member of the team.
CreateMember(teamID string, userID string) (*mm_model.TeamMember, error)
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 {
botID string
serverRoot string
api servicesAPI
2021-09-13 21:36:36 +02:00
}
// New creates a PluginDelivery instance.
func New(botID string, serverRoot string, api servicesAPI) *PluginDelivery {
2021-09-13 21:36:36 +02:00
return &PluginDelivery{
botID: botID,
serverRoot: serverRoot,
api: api,
}
}