From 8f352436049776b5bd7c006bb03992d8fe2f029f Mon Sep 17 00:00:00 2001 From: Kyriakos Z <3829551+koox00@users.noreply.github.com> Date: Thu, 27 Jan 2022 14:47:41 +0200 Subject: [PATCH] Fixes editing and pinning a post (#19425) PR https://github.com/mattermost/mattermost-server/pull/19404 fixed the replies on posts by casting StringArray to a string. This PR fixes editing and pinning a post by casting StringArray, and StringInterface to a string as well. Co-authored-by: Mattermod --- model/utils.go | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/model/utils.go b/model/utils.go index 92b6c35846..c88d9100b6 100644 --- a/model/utils.go +++ b/model/utils.go @@ -80,7 +80,7 @@ func (sa StringArray) Value() (driver.Value, error) { if err != nil { return nil, err } - // non utf8 characters are not supported + // non utf8 characters are not supported https://mattermost.atlassian.net/browse/MM-41066 return string(j), err } @@ -124,7 +124,12 @@ func (m *StringMap) Scan(value interface{}) error { // Value converts StringMap to database value func (m StringMap) Value() (driver.Value, error) { - return json.Marshal(m) + j, err := json.Marshal(m) + if err != nil { + return nil, err + } + // non utf8 characters are not supported https://mattermost.atlassian.net/browse/MM-41066 + return string(j), err } func (si *StringInterface) Scan(value interface{}) error { @@ -147,7 +152,12 @@ func (si *StringInterface) Scan(value interface{}) error { // Value converts StringInterface to database value func (si StringInterface) Value() (driver.Value, error) { - return json.Marshal(si) + j, err := json.Marshal(si) + if err != nil { + return nil, err + } + // non utf8 characters are not supported https://mattermost.atlassian.net/browse/MM-41066 + return string(j), err } var translateFunc i18n.TranslateFunc