mirror of
https://github.com/mattermost/mattermost.git
synced 2026-02-18 18:18:23 -05:00
fix(MM-60645): missing emoji on mobile (#30001)
* fix(MM-60645): missing emoji on mobile * removing the `:` completely from being stored or being sent to the server. * proper formatting?
This commit is contained in:
parent
3698808625
commit
55c2d57f70
2 changed files with 54 additions and 1 deletions
|
|
@ -5,6 +5,7 @@ package model
|
|||
|
||||
import (
|
||||
"net/http"
|
||||
"strings"
|
||||
"unicode/utf8"
|
||||
)
|
||||
|
||||
|
|
@ -142,6 +143,7 @@ func (o *ChannelBookmark) PreSave() {
|
|||
}
|
||||
|
||||
o.DisplayName = SanitizeUnicode(o.DisplayName)
|
||||
o.Emoji = strings.Trim(o.Emoji, ":")
|
||||
if o.CreateAt == 0 {
|
||||
o.CreateAt = GetMillis()
|
||||
}
|
||||
|
|
@ -151,6 +153,7 @@ func (o *ChannelBookmark) PreSave() {
|
|||
func (o *ChannelBookmark) PreUpdate() {
|
||||
o.UpdateAt = GetMillis()
|
||||
o.DisplayName = SanitizeUnicode(o.DisplayName)
|
||||
o.Emoji = strings.Trim(o.Emoji, ":")
|
||||
}
|
||||
|
||||
func (o *ChannelBookmark) ToBookmarkWithFileInfo(f *FileInfo) *ChannelBookmarkWithFileInfo {
|
||||
|
|
@ -167,7 +170,7 @@ func (o *ChannelBookmark) ToBookmarkWithFileInfo(f *FileInfo) *ChannelBookmarkWi
|
|||
SortOrder: o.SortOrder,
|
||||
LinkUrl: o.LinkUrl,
|
||||
ImageUrl: o.ImageUrl,
|
||||
Emoji: o.Emoji,
|
||||
Emoji: strings.Trim(o.Emoji, ":"),
|
||||
Type: o.Type,
|
||||
OriginalId: o.OriginalId,
|
||||
ParentId: o.ParentId,
|
||||
|
|
|
|||
|
|
@ -599,6 +599,56 @@ func TestChannelBookmarkPreUpdate(t *testing.T) {
|
|||
assert.Greater(t, bookmark.UpdateAt, originalBookmark.UpdateAt)
|
||||
}
|
||||
|
||||
func TestToBookmarkWithFileInfo(t *testing.T) {
|
||||
testCases := []struct {
|
||||
name string
|
||||
bookmark *ChannelBookmark
|
||||
fileInfo *FileInfo
|
||||
expectedEmoji string
|
||||
}{
|
||||
{
|
||||
name: "emoji with colons",
|
||||
bookmark: &ChannelBookmark{
|
||||
Id: NewId(),
|
||||
DisplayName: "test bookmark",
|
||||
Emoji: ":smile:",
|
||||
Type: ChannelBookmarkLink,
|
||||
},
|
||||
fileInfo: nil,
|
||||
expectedEmoji: "smile",
|
||||
},
|
||||
{
|
||||
name: "emoji without colons",
|
||||
bookmark: &ChannelBookmark{
|
||||
Id: NewId(),
|
||||
DisplayName: "test bookmark",
|
||||
Emoji: "smile",
|
||||
Type: ChannelBookmarkLink,
|
||||
},
|
||||
fileInfo: nil,
|
||||
expectedEmoji: "smile",
|
||||
},
|
||||
{
|
||||
name: "empty emoji",
|
||||
bookmark: &ChannelBookmark{
|
||||
Id: NewId(),
|
||||
DisplayName: "test bookmark",
|
||||
Emoji: "",
|
||||
Type: ChannelBookmarkLink,
|
||||
},
|
||||
fileInfo: nil,
|
||||
expectedEmoji: "",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
result := tc.bookmark.ToBookmarkWithFileInfo(tc.fileInfo)
|
||||
assert.Equal(t, tc.expectedEmoji, result.Emoji)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestChannelBookmarkPatch(t *testing.T) {
|
||||
p := &ChannelBookmarkPatch{
|
||||
DisplayName: NewPointer(NewId()),
|
||||
|
|
|
|||
Loading…
Reference in a new issue