mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
Temporary fix for slack attachment fields being clobbered by plugins (#9935)
This commit is contained in:
committed by
Carlos Tadeu Panato Junior
parent
2611606e13
commit
2d8cb45ff3
14
app/post.go
14
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{}
|
||||
|
||||
Reference in New Issue
Block a user