summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris <ccbrown112@gmail.com>2017-09-19 16:05:20 -0500
committerHarrison Healey <harrisonmhealey@gmail.com>2017-09-19 17:05:20 -0400
commite7e10d36a9bfd2c4b1ef98aabe013f97c01baa9e (patch)
tree45c894db2d181bd2cd3dadb935f5b989060cded7
parent99b7d65504ce729db4255f2d31def0859d36e87f (diff)
downloadchat-e7e10d36a9bfd2c4b1ef98aabe013f97c01baa9e.tar.gz
chat-e7e10d36a9bfd2c4b1ef98aabe013f97c01baa9e.tar.bz2
chat-e7e10d36a9bfd2c4b1ef98aabe013f97c01baa9e.zip
interactive post update fix (#7477)
-rw-r--r--model/post.go30
-rw-r--r--store/sql_post_store.go2
2 files changed, 22 insertions, 10 deletions
diff --git a/model/post.go b/model/post.go
index 2554c4f2e..d4fff7ef9 100644
--- a/model/post.go
+++ b/model/post.go
@@ -198,21 +198,14 @@ func (o *Post) PreSave() {
}
o.UpdateAt = o.CreateAt
+ o.PreCommit()
+}
+func (o *Post) PreCommit() {
if o.Props == nil {
o.Props = make(map[string]interface{})
}
- if attachments, ok := o.Props["attachments"].([]*SlackAttachment); ok {
- for _, attachment := range attachments {
- for _, action := range attachment.Actions {
- if action.Id == "" {
- action.Id = NewId()
- }
- }
- }
- }
-
if o.Filenames == nil {
o.Filenames = []string{}
}
@@ -220,6 +213,8 @@ func (o *Post) PreSave() {
if o.FileIds == nil {
o.FileIds = []string{}
}
+
+ o.GenerateActionIds()
}
func (o *Post) MakeNonNil() {
@@ -330,3 +325,18 @@ func (o *Post) GetAction(id string) *PostAction {
}
return nil
}
+
+func (o *Post) GenerateActionIds() {
+ if o.Props["attachments"] != nil {
+ o.Props["attachments"] = o.Attachments()
+ }
+ if attachments, ok := o.Props["attachments"].([]*SlackAttachment); ok {
+ for _, attachment := range attachments {
+ for _, action := range attachment.Actions {
+ if action.Id == "" {
+ action.Id = NewId()
+ }
+ }
+ }
+ }
+}
diff --git a/store/sql_post_store.go b/store/sql_post_store.go
index a7d47f4a9..3a57f32e8 100644
--- a/store/sql_post_store.go
+++ b/store/sql_post_store.go
@@ -129,11 +129,13 @@ func (s SqlPostStore) Update(newPost *model.Post, oldPost *model.Post) StoreChan
result := StoreResult{}
newPost.UpdateAt = model.GetMillis()
+ newPost.PreCommit()
oldPost.DeleteAt = newPost.UpdateAt
oldPost.UpdateAt = newPost.UpdateAt
oldPost.OriginalId = oldPost.Id
oldPost.Id = model.NewId()
+ oldPost.PreCommit()
if result.Err = newPost.IsValid(); result.Err != nil {
storeChannel <- result