diff options
Diffstat (limited to 'api4/channel.go')
-rw-r--r-- | api4/channel.go | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/api4/channel.go b/api4/channel.go index 02a7c34b5..e3a5bf703 100644 --- a/api4/channel.go +++ b/api4/channel.go @@ -33,7 +33,7 @@ func (api *API) InitChannel() { api.BaseRoutes.Channel.Handle("", api.ApiSessionRequired(deleteChannel)).Methods("DELETE") api.BaseRoutes.Channel.Handle("/stats", api.ApiSessionRequired(getChannelStats)).Methods("GET") api.BaseRoutes.Channel.Handle("/pinned", api.ApiSessionRequired(getPinnedPosts)).Methods("GET") - + api.BaseRoutes.Channel.Handle("/timezones", api.ApiSessionRequired(getChannelMembersTimezones)).Methods("GET") api.BaseRoutes.ChannelForUser.Handle("/unread", api.ApiSessionRequired(getChannelUnread)).Methods("GET") api.BaseRoutes.ChannelByName.Handle("", api.ApiSessionRequired(getChannelByName)).Methods("GET") @@ -821,6 +821,26 @@ func getChannelMembers(c *Context, w http.ResponseWriter, r *http.Request) { w.Write([]byte(members.ToJson())) } +func getChannelMembersTimezones(c *Context, w http.ResponseWriter, r *http.Request) { + c.RequireChannelId() + if c.Err != nil { + return + } + + if !c.App.SessionHasPermissionToChannel(c.Session, c.Params.ChannelId, model.PERMISSION_READ_CHANNEL) { + c.SetPermissionError(model.PERMISSION_READ_CHANNEL) + return + } + + membersTimezones, err := c.App.GetChannelMembersTimezones(c.Params.ChannelId) + if err != nil { + c.Err = err + return + } + + w.Write([]byte(model.ArrayToJson(membersTimezones))) +} + func getChannelMembersByIds(c *Context, w http.ResponseWriter, r *http.Request) { c.RequireChannelId() if c.Err != nil { |