summaryrefslogtreecommitdiffstats
path: root/api/channel.go
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2016-06-01 16:04:06 -0400
committerCorey Hulen <corey@hulen.com>2016-06-01 13:04:06 -0700
commit3ce6dfc71eb8f1bf2e9f2d860cf086424cf1c46d (patch)
treecbc22fe5f26a13f9904211b278b959c519c50e2c /api/channel.go
parentbd48d304c34bbf999dc8c458630397718eed5d6a (diff)
downloadchat-3ce6dfc71eb8f1bf2e9f2d860cf086424cf1c46d.tar.gz
chat-3ce6dfc71eb8f1bf2e9f2d860cf086424cf1c46d.tar.bz2
chat-3ce6dfc71eb8f1bf2e9f2d860cf086424cf1c46d.zip
Allow system admins to update and delete channels (#3161)
Diffstat (limited to 'api/channel.go')
-rw-r--r--api/channel.go14
1 files changed, 2 insertions, 12 deletions
diff --git a/api/channel.go b/api/channel.go
index 7b12849e3..ba6de1a48 100644
--- a/api/channel.go
+++ b/api/channel.go
@@ -189,7 +189,6 @@ func updateChannel(c *Context, w http.ResponseWriter, r *http.Request) {
sc := Srv.Store.Channel().Get(channel.Id)
cmc := Srv.Store.Channel().GetMember(channel.Id, c.Session.UserId)
- tmc := Srv.Store.Team().GetMember(c.TeamId, c.Session.UserId)
if cresult := <-sc; cresult.Err != nil {
c.Err = cresult.Err
@@ -197,19 +196,15 @@ func updateChannel(c *Context, w http.ResponseWriter, r *http.Request) {
} else if cmcresult := <-cmc; cmcresult.Err != nil {
c.Err = cmcresult.Err
return
- } else if tmcresult := <-tmc; cmcresult.Err != nil {
- c.Err = tmcresult.Err
- return
} else {
oldChannel := cresult.Data.(*model.Channel)
channelMember := cmcresult.Data.(model.ChannelMember)
- teamMember := tmcresult.Data.(model.TeamMember)
if !c.HasPermissionsToTeam(oldChannel.TeamId, "updateChannel") {
return
}
- if !strings.Contains(channelMember.Roles, model.CHANNEL_ROLE_ADMIN) && !strings.Contains(teamMember.Roles, model.ROLE_TEAM_ADMIN) {
+ if !strings.Contains(channelMember.Roles, model.CHANNEL_ROLE_ADMIN) && !c.IsTeamAdmin() {
c.Err = model.NewLocAppError("updateChannel", "api.channel.update_channel.permission.app_error", nil, "")
c.Err.StatusCode = http.StatusForbidden
return
@@ -639,7 +634,6 @@ func deleteChannel(c *Context, w http.ResponseWriter, r *http.Request) {
sc := Srv.Store.Channel().Get(id)
scm := Srv.Store.Channel().GetMember(id, c.Session.UserId)
- tmc := Srv.Store.Team().GetMember(c.TeamId, c.Session.UserId)
uc := Srv.Store.User().Get(c.Session.UserId)
ihc := Srv.Store.Webhook().GetIncomingByChannel(id)
ohc := Srv.Store.Webhook().GetOutgoingByChannel(id)
@@ -653,9 +647,6 @@ func deleteChannel(c *Context, w http.ResponseWriter, r *http.Request) {
} else if scmresult := <-scm; scmresult.Err != nil {
c.Err = scmresult.Err
return
- } else if tmcresult := <-tmc; tmcresult.Err != nil {
- c.Err = tmcresult.Err
- return
} else if ihcresult := <-ihc; ihcresult.Err != nil {
c.Err = ihcresult.Err
return
@@ -666,7 +657,6 @@ func deleteChannel(c *Context, w http.ResponseWriter, r *http.Request) {
channel := cresult.Data.(*model.Channel)
user := uresult.Data.(*model.User)
channelMember := scmresult.Data.(model.ChannelMember)
- teamMember := tmcresult.Data.(model.TeamMember)
incomingHooks := ihcresult.Data.([]*model.IncomingWebhook)
outgoingHooks := ohcresult.Data.([]*model.OutgoingWebhook)
@@ -674,7 +664,7 @@ func deleteChannel(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
- if !strings.Contains(channelMember.Roles, model.CHANNEL_ROLE_ADMIN) && !strings.Contains(teamMember.Roles, model.ROLE_TEAM_ADMIN) {
+ if !strings.Contains(channelMember.Roles, model.CHANNEL_ROLE_ADMIN) && !c.IsTeamAdmin() {
c.Err = model.NewLocAppError("deleteChannel", "api.channel.delete_channel.permissions.app_error", nil, "")
c.Err.StatusCode = http.StatusForbidden
return