-
Notifications
You must be signed in to change notification settings - Fork 11.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FIX] Message_AllowedMaxSize fails for emoji sequences (#10431)
Closes #10422 This pr ensures emojis are treated as single characters when determining if message size exceeds allowed limit, for better experience. Taking same example as mentioned in issue, if max allowed size is 10  now works and has effective size 10.
- Loading branch information
Showing
6 changed files
with
54 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import GraphemeSplitter from 'grapheme-splitter'; | ||
|
||
const splitter = new GraphemeSplitter(); | ||
|
||
export const messageProperties = { | ||
|
||
length: (message => { | ||
return splitter.countGraphemes(message); | ||
}), | ||
|
||
messageWithoutEmojiShortnames: (message => { | ||
return message.replace(/:\w+:/gm, (match) => { | ||
if (RocketChat.emoji.list[match] !== undefined) { | ||
return ' '; | ||
} | ||
return match; | ||
}); | ||
}) | ||
}; | ||
|
||
// check for tests | ||
if (typeof RocketChat !== 'undefined') { | ||
RocketChat.messageProperties = messageProperties; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters