summaryrefslogtreecommitdiffstats
path: root/api4/channel.go
diff options
context:
space:
mode:
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 {