From 981ea33b8e10456bc279f36235c814305d01b243 Mon Sep 17 00:00:00 2001 From: Joram Wilander Date: Thu, 24 Nov 2016 09:35:09 -0500 Subject: PLT-4403 Add server-based channel autocomplete, search and paging (#4585) * Add more channel paging API * Add channel paging support to client * Add DB channel search functions * Add API for searching more channels * Add more channel search functionality to client * Add API for autocompleting channels * Add channel autocomplete functionality to the client * Move to be deprecated APIs to their own file * Final clean-up * Fixes related to feedback * Localization changes * Add unit as suffix to timeout constants --- api/command_join.go | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'api/command_join.go') diff --git a/api/command_join.go b/api/command_join.go index 2aba1bbd5..0499d503d 100644 --- a/api/command_join.go +++ b/api/command_join.go @@ -33,25 +33,22 @@ func (me *JoinProvider) GetCommand(c *Context) *model.Command { } func (me *JoinProvider) DoCommand(c *Context, channelId string, message string) *model.CommandResponse { - if result := <-Srv.Store.Channel().GetMoreChannels(c.TeamId, c.Session.UserId); result.Err != nil { + if result := <-Srv.Store.Channel().GetByName(c.TeamId, message); result.Err != nil { return &model.CommandResponse{Text: c.T("api.command_join.list.app_error"), ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL} } else { - channels := result.Data.(*model.ChannelList) + channel := result.Data.(*model.Channel) - for _, v := range *channels { + if channel.Name == message { - if v.Name == message { - - if v.Type != model.CHANNEL_OPEN { - return &model.CommandResponse{Text: c.T("api.command_join.fail.app_error"), ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL} - } - - if err, _ := JoinChannelById(c, c.Session.UserId, v.Id); err != nil { - return &model.CommandResponse{Text: c.T("api.command_join.fail.app_error"), ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL} - } + if channel.Type != model.CHANNEL_OPEN { + return &model.CommandResponse{Text: c.T("api.command_join.fail.app_error"), ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL} + } - return &model.CommandResponse{GotoLocation: c.GetTeamURL() + "/channels/" + v.Name, Text: c.T("api.command_join.success"), ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL} + if err, _ := JoinChannelById(c, c.Session.UserId, channel.Id); err != nil { + return &model.CommandResponse{Text: c.T("api.command_join.fail.app_error"), ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL} } + + return &model.CommandResponse{GotoLocation: c.GetTeamURL() + "/channels/" + channel.Name, Text: c.T("api.command_join.success"), ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL} } } -- cgit v1.2.3-1-g7c22