APIv4 put /posts/{post_id}/patch (#5883)
* APIv4 put /posts/{post_id}/patch
* Add props and edit permission
Этот коммит содержится в:
коммит произвёл
Corey Hulen
родитель
31830ffc7b
Коммит
2f15523fe8
28
api4/post.go
28
api4/post.go
@@ -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 {
|
||||
|
||||
Ссылка в новой задаче
Block a user