summaryrefslogtreecommitdiffstats
path: root/store/sql_channel_store.go
diff options
context:
space:
mode:
authorSaturnino Abril <saturnino.abril@gmail.com>2017-03-27 20:41:40 +0900
committerenahum <nahumhbl@gmail.com>2017-03-27 08:41:40 -0300
commit01aaccb34080ede234602d1ca9acee8373b8560f (patch)
treeaac605bdc35f8a2f1a2761c7f753d5e9f66a33ec /store/sql_channel_store.go
parent720ee81113ac7a7dd062271c3d6cdf58ce8e044a (diff)
downloadchat-01aaccb34080ede234602d1ca9acee8373b8560f.tar.gz
chat-01aaccb34080ede234602d1ca9acee8373b8560f.tar.bz2
chat-01aaccb34080ede234602d1ca9acee8373b8560f.zip
APIv4 post /channels/ids (#5845)
* APIv4 post /channels/ids * updated enpoint as /teams/{team_id}/channels/ids
Diffstat (limited to 'store/sql_channel_store.go')
-rw-r--r--store/sql_channel_store.go50
1 files changed, 50 insertions, 0 deletions
diff --git a/store/sql_channel_store.go b/store/sql_channel_store.go
index d72722f7c..309337e50 100644
--- a/store/sql_channel_store.go
+++ b/store/sql_channel_store.go
@@ -619,6 +619,56 @@ func (s SqlChannelStore) GetPublicChannelsForTeam(teamId string, offset int, lim
return storeChannel
}
+func (s SqlChannelStore) GetPublicChannelsByIdsForTeam(teamId string, channelIds []string) StoreChannel {
+ storeChannel := make(StoreChannel, 1)
+
+ go func() {
+ result := StoreResult{}
+
+ props := make(map[string]interface{})
+ props["teamId"] = teamId
+
+ idQuery := ""
+
+ for index, channelId := range channelIds {
+ if len(idQuery) > 0 {
+ idQuery += ", "
+ }
+
+ props["channelId"+strconv.Itoa(index)] = channelId
+ idQuery += ":channelId" + strconv.Itoa(index)
+ }
+
+ data := &model.ChannelList{}
+ _, err := s.GetReplica().Select(data,
+ `SELECT
+ *
+ FROM
+ Channels
+ WHERE
+ TeamId = :teamId
+ AND Type = 'O'
+ AND DeleteAt = 0
+ AND Id IN (`+idQuery+`)
+ ORDER BY DisplayName`,
+ props)
+
+ if err != nil {
+ result.Err = model.NewLocAppError("SqlChannelStore.GetPublicChannelsByIdsForTeam", "store.sql_channel.get_channels_by_ids.get.app_error", nil, err.Error())
+ }
+
+ if len(*data) == 0 {
+ result.Err = model.NewAppError("SqlChannelStore.GetPublicChannelsByIdsForTeam", "store.sql_channel.get_channels_by_ids.not_found.app_error", nil, "", http.StatusNotFound)
+ }
+
+ result.Data = data
+ storeChannel <- result
+ close(storeChannel)
+ }()
+
+ return storeChannel
+}
+
type channelIdWithCountAndUpdateAt struct {
Id string
TotalMsgCount int64