Team admin can now delete any post

Этот коммит содержится в:
nickago
2015-07-14 13:09:14 -07:00
родитель b31327f072
Коммит cb2bff28ee
3 изменённых файлов: 29 добавлений и 9 удалений

Просмотреть файл

@@ -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