Add new functions to channel service and kv store service interfaces

Этот коммит содержится в:
Giorgi Bochorishvili
2022-12-13 17:11:57 +04:00
родитель 496fe73f10
Коммит 9668733615
4 изменённых файлов: 26 добавлений и 2 удалений

Просмотреть файл

@@ -200,7 +200,7 @@ endif
# Playbooks
BUILD_PLAYBOOKS_DIR ?= ../mattermost-plugin-playbooks
BUILD_PLAYBOOKS ?= false
BUILD_PLAYBOOKS ?= true
ifeq ($(BUILD_PLAYBOOKS),true)
IGNORE:=$(shell cp $(BUILD_PLAYBOOKS_DIR)/product/imports/playbooks_imports.go imports/)

Просмотреть файл

@@ -27,6 +27,7 @@ import (
// channelsWrapper provides an implementation of `product.ChannelService` to be used by products.
type channelsWrapper struct {
srv *Server
app *App
}
func (s *channelsWrapper) GetDirectChannel(userID1, userID2 string) (*model.Channel, *model.AppError) {
@@ -47,6 +48,22 @@ func (s *channelsWrapper) GetChannelsForTeamForUser(teamID string, userID string
return s.srv.getChannelsForTeamForUser(request.EmptyContext(s.srv.Log()), teamID, userID, opts)
}
func (s *channelsWrapper) GetChannelSidebarCategories(userID, teamID string) (*model.OrderedSidebarCategories, *model.AppError) {
return s.app.GetSidebarCategoriesForTeamForUser(request.EmptyContext(s.srv.Log()), userID, teamID)
}
func (s *channelsWrapper) GetChannelMembers(channelID string, page, perPage int) (model.ChannelMembers, *model.AppError) {
return s.app.GetChannelMembersPage(request.EmptyContext(s.srv.Log()), channelID, page, perPage)
}
func (s *channelsWrapper) CreateChannelSidebarCategory(userID, teamID string, newCategory *model.SidebarCategoryWithChannels) (*model.SidebarCategoryWithChannels, *model.AppError) {
return s.app.CreateSidebarCategory(request.EmptyContext(s.srv.Log()), userID, teamID, newCategory)
}
func (s *channelsWrapper) UpdateChannelSidebarCategories(userID, teamID string, categories []*model.SidebarCategoryWithChannels) ([]*model.SidebarCategoryWithChannels, *model.AppError) {
return s.app.UpdateSidebarCategories(request.EmptyContext(s.srv.Log()), userID, teamID, categories)
}
// Ensure the wrapper implements the product service.
var _ product.ChannelService = (*channelsWrapper)(nil)

Просмотреть файл

@@ -262,8 +262,9 @@ func NewServer(options ...Option) (*Server, error) {
// ensure app implements `product.UserService`
var _ product.UserService = (*App)(nil)
app := New(ServerConnector(s.Channels()))
serviceMap := map[ServiceKey]any{
ChannelKey: &channelsWrapper{srv: s},
ChannelKey: &channelsWrapper{srv: s, app: app},
ConfigKey: s.platform,
LicenseKey: s.licenseWrapper,
FilestoreKey: s.platform.FileBackend(),

Просмотреть файл

@@ -65,6 +65,10 @@ type ChannelService interface {
GetChannelByID(channelID string) (*model.Channel, *model.AppError)
GetChannelMember(channelID string, userID string) (*model.ChannelMember, *model.AppError)
GetChannelsForTeamForUser(teamID string, userID string, opts *model.ChannelSearchOpts) (model.ChannelList, *model.AppError)
GetChannelSidebarCategories(userID, teamID string) (*model.OrderedSidebarCategories, *model.AppError)
GetChannelMembers(channelID string, page, perPage int) (model.ChannelMembers, *model.AppError)
CreateChannelSidebarCategory(userID, teamID string, newCategory *model.SidebarCategoryWithChannels) (*model.SidebarCategoryWithChannels, *model.AppError)
UpdateChannelSidebarCategories(userID, teamID string, categories []*model.SidebarCategoryWithChannels) ([]*model.SidebarCategoryWithChannels, *model.AppError)
}
// LicenseService provides license related utilities.
@@ -161,6 +165,8 @@ type CloudService interface {
type KVStoreService interface {
SetPluginKeyWithOptions(pluginID string, key string, value []byte, options model.PluginKVSetOptions) (bool, *model.AppError)
KVGet(productID, key string) ([]byte, *model.AppError)
KVDelete(productID, key string) *model.AppError
KVList(productID string, page, perPage int) ([]string, *model.AppError)
}
// LogService is the API for accessing the log service APIs.