diff --git a/app/channel.go b/app/channel.go index 3825a90a58..59b1aa05b4 100644 --- a/app/channel.go +++ b/app/channel.go @@ -40,6 +40,10 @@ func (s *channelsWrapper) GetChannelMember(channelID string, userID string) (*mo return s.srv.getChannelMember(context.Background(), channelID, userID) } +func (s *channelsWrapper) GetChannelsForTeamForUser(teamID string, userID string, opts *model.ChannelSearchOpts) (model.ChannelList, *model.AppError) { + return s.srv.getChannelsForTeamForUser(teamID, userID, opts) +} + // DefaultChannelNames returns the list of system-wide default channel names. // // By default the list will be (not necessarily in this order): @@ -1818,8 +1822,8 @@ func (a *App) GetChannelByNameForTeamName(channelName, teamName string, includeD return result, nil } -func (a *App) GetChannelsForTeamForUser(teamID string, userID string, opts *model.ChannelSearchOpts) (model.ChannelList, *model.AppError) { - list, err := a.Srv().Store.Channel().GetChannels(teamID, userID, opts) +func (s *Server) getChannelsForTeamForUser(teamID string, userID string, opts *model.ChannelSearchOpts) (model.ChannelList, *model.AppError) { + list, err := s.Store.Channel().GetChannels(teamID, userID, opts) if err != nil { var nfErr *store.ErrNotFound switch { @@ -1833,6 +1837,10 @@ func (a *App) GetChannelsForTeamForUser(teamID string, userID string, opts *mode return list, nil } +func (a *App) GetChannelsForTeamForUser(teamID string, userID string, opts *model.ChannelSearchOpts) (model.ChannelList, *model.AppError) { + return a.Srv().getChannelsForTeamForUser(teamID, userID, opts) +} + func (a *App) GetChannelsForTeamForUserWithCursor(teamID string, userID string, opts *model.ChannelSearchOpts, afterChannelID string) (model.ChannelList, *model.AppError) { list, err := a.Srv().Store.Channel().GetChannelsWithCursor(teamID, userID, opts, afterChannelID) if err != nil { diff --git a/app/permissions.go b/app/permissions.go index 6d875849cc..8d3bf69e5f 100644 --- a/app/permissions.go +++ b/app/permissions.go @@ -27,6 +27,10 @@ func (s *permissionsServiceWrapper) HasPermissionToTeam(userID string, teamID st return s.app.HasPermissionToTeam(userID, teamID, permission) } +func (s *permissionsServiceWrapper) HasPermissionToChannel(askingUserID string, channelID string, permission *model.Permission) bool { + return s.app.HasPermissionToChannel(askingUserID, channelID, permission) +} + func (a *App) ResetPermissionsSystem() *model.AppError { // Reset all Teams to not have a scheme. if err := a.Srv().Store.Team().ResetAllTeamSchemes(); err != nil { diff --git a/product/api.go b/product/api.go index d1bad1f3f2..fe4f635335 100644 --- a/product/api.go +++ b/product/api.go @@ -41,6 +41,7 @@ type PostService interface { // The service shall be registered via app.PermissionKey service key. type PermissionService interface { HasPermissionToTeam(userID, teamID string, permission *model.Permission) bool + HasPermissionToChannel(askingUserID string, channelID string, permission *model.Permission) bool } // ClusterService enables to publish cluster events. In addition to that, It's being used for @@ -61,6 +62,7 @@ type ChannelService interface { GetDirectChannel(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) } // LicenseService provides license related utilities.