summaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
Diffstat (limited to 'api')
-rw-r--r--api/post.go6
-rw-r--r--api/post_test.go11
2 files changed, 17 insertions, 0 deletions
diff --git a/api/post.go b/api/post.go
index 734cb7148..6be3ec7eb 100644
--- a/api/post.go
+++ b/api/post.go
@@ -919,6 +919,12 @@ func updatePost(c *Context, w http.ResponseWriter, r *http.Request) {
c.Err.StatusCode = http.StatusForbidden
return
}
+
+ if oldPost.IsSystemMessage() {
+ c.Err = model.NewLocAppError("updatePost", "api.post.update_post.system_message.app_error", nil, "id="+post.Id)
+ c.Err.StatusCode = http.StatusForbidden
+ return
+ }
}
hashtags, _ := model.ParseHashtags(post.Message)
diff --git a/api/post_test.go b/api/post_test.go
index bb11a5439..b4c23ff06 100644
--- a/api/post_test.go
+++ b/api/post_test.go
@@ -155,6 +155,17 @@ func TestUpdatePost(t *testing.T) {
t.Fatal("failed to updates")
}
}
+
+ post3 := &model.Post{ChannelId: channel1.Id, Message: "a" + model.NewId() + "a", Type: model.POST_JOIN_LEAVE}
+ rpost3, err := Client.CreatePost(post3)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ up3 := &model.Post{Id: rpost3.Data.(*model.Post).Id, ChannelId: channel1.Id, Message: "a" + model.NewId() + " update post 3"}
+ if _, err := Client.UpdatePost(up3); err == nil {
+ t.Fatal("shouldn't have been able to update system message")
+ }
}
func TestGetPosts(t *testing.T) {