summaryrefslogtreecommitdiffstats
path: root/api4/channel.go
diff options
context:
space:
mode:
authorGeorge Goldberg <george@gberg.me>2018-06-05 12:41:03 +0100
committerMartin Kraft <mkraft@users.noreply.github.com>2018-06-05 07:41:03 -0400
commit0c4078b6b05b4b436c459c4f58faa5302ace8e12 (patch)
tree031c363a10b730afcb33b36023f925f8993ced02 /api4/channel.go
parent2c75247c97d0277944975deb9595b5f82a80e91e (diff)
downloadchat-0c4078b6b05b4b436c459c4f58faa5302ace8e12.tar.gz
chat-0c4078b6b05b4b436c459c4f58faa5302ace8e12.tar.bz2
chat-0c4078b6b05b4b436c459c4f58faa5302ace8e12.zip
MM-9730 & MM-9729: Missing Server PRs (#8908)
* MM-9730: API endpoint to update scheme-derived roles of TeamMembers. * MM-9729: API to update scheme-derived roles of ChannelMembers.
Diffstat (limited to 'api4/channel.go')
-rw-r--r--api4/channel.go26
1 files changed, 26 insertions, 0 deletions
diff --git a/api4/channel.go b/api4/channel.go
index e5101ada8..b2c920ddb 100644
--- a/api4/channel.go
+++ b/api4/channel.go
@@ -45,6 +45,7 @@ func (api *API) InitChannel() {
api.BaseRoutes.ChannelMember.Handle("", api.ApiSessionRequired(getChannelMember)).Methods("GET")
api.BaseRoutes.ChannelMember.Handle("", api.ApiSessionRequired(removeChannelMember)).Methods("DELETE")
api.BaseRoutes.ChannelMember.Handle("/roles", api.ApiSessionRequired(updateChannelMemberRoles)).Methods("PUT")
+ api.BaseRoutes.ChannelMember.Handle("/schemeRoles", api.ApiSessionRequired(updateChannelMemberSchemeRoles)).Methods("PUT")
api.BaseRoutes.ChannelMember.Handle("/notify_props", api.ApiSessionRequired(updateChannelMemberNotifyProps)).Methods("PUT")
}
@@ -811,6 +812,31 @@ func updateChannelMemberRoles(c *Context, w http.ResponseWriter, r *http.Request
ReturnStatusOK(w)
}
+func updateChannelMemberSchemeRoles(c *Context, w http.ResponseWriter, r *http.Request) {
+ c.RequireChannelId().RequireUserId()
+ if c.Err != nil {
+ return
+ }
+
+ schemeRoles := model.SchemeRolesFromJson(r.Body)
+ if schemeRoles == nil {
+ c.SetInvalidParam("scheme_roles")
+ return
+ }
+
+ if !c.App.SessionHasPermissionToChannel(c.Session, c.Params.ChannelId, model.PERMISSION_MANAGE_CHANNEL_ROLES) {
+ c.SetPermissionError(model.PERMISSION_MANAGE_CHANNEL_ROLES)
+ return
+ }
+
+ if _, err := c.App.UpdateChannelMemberSchemeRoles(c.Params.ChannelId, c.Params.UserId, schemeRoles.SchemeUser, schemeRoles.SchemeAdmin); err != nil {
+ c.Err = err
+ return
+ }
+
+ ReturnStatusOK(w)
+}
+
func updateChannelMemberNotifyProps(c *Context, w http.ResponseWriter, r *http.Request) {
c.RequireChannelId().RequireUserId()
if c.Err != nil {