diff options
author | Joram Wilander <jwawilander@gmail.com> | 2017-03-31 09:55:37 -0400 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2017-03-31 09:55:37 -0400 |
commit | 4e224c299697e570e98c388bf23a42ffa1e6af0d (patch) | |
tree | 5bc192c008347cce8d9b1f34888f2dbb694c8d51 /api4/channel.go | |
parent | ea17e8d004ca6a9501cb540c0009bb531eb9d0f2 (diff) | |
download | chat-4e224c299697e570e98c388bf23a42ffa1e6af0d.tar.gz chat-4e224c299697e570e98c388bf23a42ffa1e6af0d.tar.bz2 chat-4e224c299697e570e98c388bf23a42ffa1e6af0d.zip |
Implement PUT /channels/{channel_id}/members/{user_id}/notify_props for APIv4 (#5901)
Diffstat (limited to 'api4/channel.go')
-rw-r--r-- | api4/channel.go | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/api4/channel.go b/api4/channel.go index ea4f2783a..b7f9508d6 100644 --- a/api4/channel.go +++ b/api4/channel.go @@ -43,6 +43,7 @@ func InitChannel() { BaseRoutes.ChannelMember.Handle("", ApiSessionRequired(getChannelMember)).Methods("GET") BaseRoutes.ChannelMember.Handle("", ApiSessionRequired(removeChannelMember)).Methods("DELETE") BaseRoutes.ChannelMember.Handle("/roles", ApiSessionRequired(updateChannelMemberRoles)).Methods("PUT") + BaseRoutes.ChannelMember.Handle("/notify_props", ApiSessionRequired(updateChannelMemberNotifyProps)).Methods("PUT") } func createChannel(c *Context, w http.ResponseWriter, r *http.Request) { @@ -660,6 +661,32 @@ func updateChannelMemberRoles(c *Context, w http.ResponseWriter, r *http.Request ReturnStatusOK(w) } +func updateChannelMemberNotifyProps(c *Context, w http.ResponseWriter, r *http.Request) { + c.RequireChannelId().RequireUserId() + if c.Err != nil { + return + } + + props := model.MapFromJson(r.Body) + if props == nil { + c.SetInvalidParam("notify_props") + return + } + + if !app.SessionHasPermissionToUser(c.Session, c.Params.UserId) { + c.SetPermissionError(model.PERMISSION_EDIT_OTHER_USERS) + return + } + + _, err := app.UpdateChannelMemberNotifyProps(props, c.Params.ChannelId, c.Params.UserId) + if err != nil { + c.Err = err + return + } + + ReturnStatusOK(w) +} + func addChannelMember(c *Context, w http.ResponseWriter, r *http.Request) { c.RequireChannelId() if c.Err != nil { |