Team admin can now delete any post
Этот коммит содержится в:
21
api/post.go
21
api/post.go
@@ -619,16 +619,23 @@ func deletePost(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
cchan := Srv.Store.Channel().CheckPermissionsTo(c.Session.TeamId, channelId, c.Session.UserId)
|
||||
pchan := Srv.Store.Post().Get(postId)
|
||||
uchan := Srv.Store.User().Get(c.Session.UserId)
|
||||
|
||||
if !c.HasPermissionsToChannel(cchan, "deletePost") {
|
||||
if uresult := <-uchan; uresult.Err != nil {
|
||||
c.Err = uresult.Err
|
||||
return
|
||||
}
|
||||
|
||||
if result := <-pchan; result.Err != nil {
|
||||
c.Err = result.Err
|
||||
} else if presult := <-pchan; presult.Err != nil {
|
||||
c.Err = presult.Err
|
||||
return
|
||||
} else {
|
||||
post := result.Data.(*model.PostList).Posts[postId]
|
||||
|
||||
user := uresult.Data.(*model.User)
|
||||
|
||||
if !c.HasPermissionsToChannel(cchan, "deletePost") && !strings.Contains(user.Roles,"admin"){
|
||||
return
|
||||
}
|
||||
|
||||
post := presult.Data.(*model.PostList).Posts[postId]
|
||||
|
||||
if post == nil {
|
||||
c.SetInvalidParam("deletePost", "postId")
|
||||
@@ -641,7 +648,7 @@ func deletePost(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if post.UserId != c.Session.UserId {
|
||||
if post.UserId != c.Session.UserId && !strings.Contains(user.Roles,"admin") {
|
||||
c.Err = model.NewAppError("deletePost", "You do not have the appropriate permissions", "")
|
||||
c.Err.StatusCode = http.StatusForbidden
|
||||
return
|
||||
|
||||
Ссылка в новой задаче
Block a user