Add new method to channel service

Fix channel service App.ch nil bug
Этот коммит содержится в:
Giorgi Bochorishvili
2023-01-05 12:22:52 +04:00
родитель c76a571067
Коммит 084c30bbc1
4 изменённых файлов: 11 добавлений и 1 удалений

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

@@ -101,6 +101,10 @@ func (s *channelsWrapper) AddChannelMember(channelID, userID string) (*model.Cha
})
}
func (s *channelsWrapper) GetDirectChannelOrCreate(userID1, userID2 string) (*model.Channel, *model.AppError) {
return s.app.GetOrCreateDirectChannel(request.EmptyContext(s.srv.Log()), userID1, userID2)
}
// Ensure the wrapper implements the product service.
var _ product.ChannelService = (*channelsWrapper)(nil)

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

@@ -213,6 +213,11 @@ func NewChannels(services map[product.ServiceKey]any) (*Channels, error) {
pluginsRoute.HandleFunc("/public/{public_file:.*}", ch.ServePluginPublicRequest)
pluginsRoute.HandleFunc("/{anything:.*}", ch.ServePluginRequest)
services[product.ChannelKey] = &channelsWrapper{
srv: s,
app: &App{ch: ch},
}
services[product.PostKey] = &postServiceWrapper{
app: &App{ch: ch},
}

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

@@ -247,7 +247,7 @@ func NewServer(options ...Option) (*Server, error) {
product.FilestoreKey: s.platform.FileBackend(),
product.FileInfoStoreKey: &fileInfoWrapper{srv: s},
product.ClusterKey: s.platform,
product.UserKey: New(ServerConnector(s.Channels())),
product.UserKey: app,
product.LogKey: s.platform.Log(),
product.CloudKey: &cloudWrapper{cloud: s.Cloud},
product.KVStoreKey: s.platform,

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

@@ -68,6 +68,7 @@ type ClusterService interface {
// The service shall be registered via app.ChannelKey service key.
type ChannelService interface {
GetDirectChannel(userID1, userID2 string) (*model.Channel, *model.AppError)
GetDirectChannelOrCreate(userID1, userID2 string) (*model.Channel, *model.AppError)
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)