|
|
|
|
@@ -26,50 +26,49 @@ 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) {
|
|
|
|
|
return s.srv.getDirectChannel(request.EmptyContext(s.srv.Log()), userID1, userID2)
|
|
|
|
|
return s.app.getDirectChannel(request.EmptyContext(s.app.Log()), userID1, userID2)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// GetChannelByID gets a Channel by its ID.
|
|
|
|
|
func (s *channelsWrapper) GetChannelByID(channelID string) (*model.Channel, *model.AppError) {
|
|
|
|
|
return s.srv.getChannel(request.EmptyContext(s.srv.Log()), channelID)
|
|
|
|
|
return s.app.GetChannel(request.EmptyContext(s.app.Log()), channelID)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// GetChannelMember gets a channel member by userID.
|
|
|
|
|
func (s *channelsWrapper) GetChannelMember(channelID string, userID string) (*model.ChannelMember, *model.AppError) {
|
|
|
|
|
return s.srv.getChannelMember(request.EmptyContext(s.srv.Log()), channelID, userID)
|
|
|
|
|
return s.app.GetChannelMember(request.EmptyContext(s.app.Log()), channelID, userID)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *channelsWrapper) GetChannelsForTeamForUser(teamID string, userID string, opts *model.ChannelSearchOpts) (model.ChannelList, *model.AppError) {
|
|
|
|
|
return s.srv.getChannelsForTeamForUser(request.EmptyContext(s.srv.Log()), teamID, userID, opts)
|
|
|
|
|
return s.app.GetChannelsForTeamForUser(request.EmptyContext(s.app.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)
|
|
|
|
|
return s.app.GetSidebarCategoriesForTeamForUser(request.EmptyContext(s.app.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)
|
|
|
|
|
return s.app.GetChannelMembersPage(request.EmptyContext(s.app.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)
|
|
|
|
|
return s.app.CreateSidebarCategory(request.EmptyContext(s.app.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)
|
|
|
|
|
return s.app.UpdateSidebarCategories(request.EmptyContext(s.app.Log()), userID, teamID, categories)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *channelsWrapper) CreateChannel(channel *model.Channel) (*model.Channel, *model.AppError) {
|
|
|
|
|
return s.app.CreateChannel(request.EmptyContext(s.srv.Log()), channel, false)
|
|
|
|
|
return s.app.CreateChannel(request.EmptyContext(s.app.Log()), channel, false)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *channelsWrapper) AddUserToChannel(channelID, userID, asUserID string) (*model.ChannelMember, *model.AppError) {
|
|
|
|
|
ctx := request.EmptyContext(s.srv.Log())
|
|
|
|
|
ctx := request.EmptyContext(s.app.Log())
|
|
|
|
|
channel, err := s.app.GetChannel(ctx, channelID)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
@@ -81,11 +80,11 @@ func (s *channelsWrapper) AddUserToChannel(channelID, userID, asUserID string) (
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *channelsWrapper) UpdateChannelMemberRoles(channelID, userID, newRoles string) (*model.ChannelMember, *model.AppError) {
|
|
|
|
|
return s.app.UpdateChannelMemberRoles(request.EmptyContext(s.srv.Log()), channelID, userID, newRoles)
|
|
|
|
|
return s.app.UpdateChannelMemberRoles(request.EmptyContext(s.app.Log()), channelID, userID, newRoles)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *channelsWrapper) DeleteChannelMember(channelID, userID string) *model.AppError {
|
|
|
|
|
return s.app.LeaveChannel(request.EmptyContext(s.srv.Log()), channelID, userID)
|
|
|
|
|
return s.app.LeaveChannel(request.EmptyContext(s.app.Log()), channelID, userID)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *channelsWrapper) AddChannelMember(channelID, userID string) (*model.ChannelMember, *model.AppError) {
|
|
|
|
|
@@ -94,7 +93,7 @@ func (s *channelsWrapper) AddChannelMember(channelID, userID string) (*model.Cha
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return s.app.AddChannelMember(request.EmptyContext(s.srv.Log()), userID, channel, ChannelMemberOpts{
|
|
|
|
|
return s.app.AddChannelMember(request.EmptyContext(s.app.Log()), userID, channel, ChannelMemberOpts{
|
|
|
|
|
// For now, don't allow overriding these via the plugin API.
|
|
|
|
|
UserRequestorID: "",
|
|
|
|
|
PostRootID: "",
|
|
|
|
|
@@ -102,7 +101,7 @@ 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)
|
|
|
|
|
return s.app.GetOrCreateDirectChannel(request.EmptyContext(s.app.Log()), userID1, userID2)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Ensure the wrapper implements the product service.
|
|
|
|
|
|