APIv4 put /posts/{post_id}/patch (#5883)

* APIv4 put /posts/{post_id}/patch

* Add props and edit permission
Этот коммит содержится в:
Saturnino Abril
2017-03-30 00:06:51 +09:00
коммит произвёл Corey Hulen
родитель 31830ffc7b
Коммит 2f15523fe8
5 изменённых файлов: 221 добавлений и 4 удалений

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

@@ -25,6 +25,7 @@ func InitPost() {
BaseRoutes.Team.Handle("/posts/search", ApiSessionRequired(searchPosts)).Methods("POST")
BaseRoutes.Post.Handle("", ApiSessionRequired(updatePost)).Methods("PUT")
BaseRoutes.Post.Handle("/patch", ApiSessionRequired(patchPost)).Methods("PUT")
}
func createPost(c *Context, w http.ResponseWriter, r *http.Request) {
@@ -245,6 +246,33 @@ func updatePost(c *Context, w http.ResponseWriter, r *http.Request) {
w.Write([]byte(rpost.ToJson()))
}
func patchPost(c *Context, w http.ResponseWriter, r *http.Request) {
c.RequirePostId()
if c.Err != nil {
return
}
post := model.PostPatchFromJson(r.Body)
if post == nil {
c.SetInvalidParam("post")
return
}
if !app.SessionHasPermissionToPost(c.Session, c.Params.PostId, model.PERMISSION_EDIT_OTHERS_POSTS) {
c.SetPermissionError(model.PERMISSION_EDIT_OTHERS_POSTS)
return
}
patchedPost, err := app.PatchPost(c.Params.PostId, post)
if err != nil {
c.Err = err
return
}
w.Write([]byte(patchedPost.ToJson()))
}
func getFileInfosForPost(c *Context, w http.ResponseWriter, r *http.Request) {
c.RequirePostId()
if c.Err != nil {