diff options
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 { |