interactive post update fix (#7477)

This commit is contained in:
Chris
2017-09-19 17:05:20 -04:00
committed by Harrison Healey
parent 99b7d65504
commit e7e10d36a9
2 changed files with 22 additions and 10 deletions
+20 -10
View File
@@ -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()
}
}
}
}
}
+2
View File
@@ -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