Skip to content

Commit

Permalink
bugfix Discord: regular emoji should not have empty IDs
Browse files Browse the repository at this point in the history
  • Loading branch information
mlomb committed Mar 3, 2023
1 parent 525c9de commit 87ab3f8
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 8 deletions.
4 changes: 4 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# v1.0.1 [IN DEVELOPMENT]

- Bugfix Discord: regular emoji were not being rendered correctly in MessageLabel because the ID was being set (due to DCE now including an empty ID)

# v1.0.0

After a lot of work in [#39](https://github.com/mlomb/chat-analytics/pull/39), [#53](https://github.com/mlomb/chat-analytics/pull/53), [#55](https://github.com/mlomb/chat-analytics/pull/55) and [#58](https://github.com/mlomb/chat-analytics/pull/58) (more than 200 commits of refactors and improvements) I can say I'm happy to call this the first release of Chat Analytics!
Expand Down
17 changes: 10 additions & 7 deletions pipeline/parse/parsers/DiscordParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,16 @@ export class DiscordParser extends Parser {
attachments: message.attachments
.map((a) => getAttachmentTypeFromFileName(a.fileName))
.concat(stickers.map((_) => AttachmentType.Sticker)),
reactions: message.reactions.map((r) => [
{
id: r.emoji.id === null ? undefined : r.emoji.id,
text: r.emoji.name || r.emoji.id || "unknown",
},
r.count,
]),
reactions: message.reactions.map((r) => {
const emojiId = r.emoji.id === null || r.emoji.id === "" ? undefined : r.emoji.id;
return [
{
id: emojiId,
text: r.emoji.name || emojiId || "unknown",
},
r.count,
];
}),
};
this.emit("message", pmessage, this.lastMessageTimestampInFile);
}
Expand Down
12 changes: 11 additions & 1 deletion tests/samples/discord/DM_2A_2M.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,17 @@
},
"attachments": [],
"embeds": [],
"reactions": [],
"reactions": [
{
"emoji": {
"id": "",
"name": "\uD83D\uDC46",
"isAnimated": false,
"imageUrl": "https://cdn.jsdelivr.net/gh/twitter/twemoji@latest/assets/svg/1f446.svg"
},
"count": 42
}
],
"mentions": []
},
{
Expand Down
1 change: 1 addition & 0 deletions tests/samples/discord/DM_2A_2M.json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export const expectedParse: ExpectedPartialParseResult = {
channelId: "530805775262679064",
textContent: "blah",
timestamp: Date.parse("2019-01-04T17:52:39.762+00:00"),
reactions: [[{ text: "👆" }, 42]],
},
{
id: "538148765782114306",
Expand Down

0 comments on commit 87ab3f8

Please sign in to comment.