From b87fae646a624507f5b2c1270cae1d3585f589ac Mon Sep 17 00:00:00 2001 From: Chris Date: Tue, 28 Nov 2017 15:02:56 -0600 Subject: PLT-5458: If someone posts a channel link to channel_A that you don't belong to, it doesn't render properly (#7833) * add channel link hints to post props * optimization * update regex, add unit test * fix rebase issue --- app/channel.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'app/channel.go') diff --git a/app/channel.go b/app/channel.go index 50067d42d..16c5dd084 100644 --- a/app/channel.go +++ b/app/channel.go @@ -757,6 +757,18 @@ func (a *App) GetChannelByName(channelName, teamId string) (*model.Channel, *mod } } +func (a *App) GetChannelsByNames(channelNames []string, teamId string) ([]*model.Channel, *model.AppError) { + if result := <-a.Srv.Store.Channel().GetByNames(teamId, channelNames, true); result.Err != nil && result.Err.Id == "store.sql_channel.get_by_name.missing.app_error" { + result.Err.StatusCode = http.StatusNotFound + return nil, result.Err + } else if result.Err != nil { + result.Err.StatusCode = http.StatusBadRequest + return nil, result.Err + } else { + return result.Data.([]*model.Channel), nil + } +} + func (a *App) GetChannelByNameForTeamName(channelName, teamName string) (*model.Channel, *model.AppError) { var team *model.Team -- cgit v1.2.3-1-g7c22