diff --git a/app/post.go b/app/post.go index e33e564f6b..74096d5a1b 100644 --- a/app/post.go +++ b/app/post.go @@ -7,6 +7,7 @@ import ( "crypto/hmac" "crypto/sha1" "encoding/hex" + "encoding/json" "fmt" "net/http" "strings" @@ -139,6 +140,19 @@ func (a *App) CreatePost(post *model.Post, channel *model.Channel, triggerWebhoo return nil, err } + // Temporary fix so old plugins don't clobber new fields in SlackAttachment struct, see MM-13088 + if attachments, ok := post.Props["attachments"].([]*model.SlackAttachment); ok { + jsonAttachments, err := json.Marshal(attachments) + if err == nil { + attachmentsInterface := []interface{}{} + err = json.Unmarshal(jsonAttachments, &attachmentsInterface) + post.Props["attachments"] = attachmentsInterface + } + if err != nil { + mlog.Error("Could not convert post attachments to map interface, err=%s" + err.Error()) + } + } + if pluginsEnvironment := a.GetPluginsEnvironment(); pluginsEnvironment != nil { var rejectionError *model.AppError pluginContext := &plugin.Context{}