Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: check duplicate event and death messages #584

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 39 additions & 7 deletions assets/chat/js/chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -1373,11 +1373,17 @@ class Chat {
}

onBROADCAST(data) {
MessageBuilder.broadcast(
const msg = MessageBuilder.broadcast(
data.data,
new ChatUser(data.user),
data.timestamp,
).into(this);
);

if (this.mainwindow.containsMessage(msg)) {
return;
}

msg.into(this);
}

onRELOAD() {
Expand All @@ -1394,7 +1400,12 @@ class Chat {
}

onSUBSCRIPTION(data) {
MessageBuilder.subscription(data).into(this);
const msg = MessageBuilder.subscription(data);
if (this.mainwindow.containsMessage(msg)) {
return;
}

msg.into(this);

// Don't add events when loading messages from history because the
// `PAIDEVENTS` payload will contain those events
Expand All @@ -1412,7 +1423,12 @@ class Chat {
}

onGIFTSUB(data) {
MessageBuilder.gift(data).into(this);
const msg = MessageBuilder.gift(data);
if (this.mainwindow.containsMessage(msg)) {
return;
}

msg.into(this);

if (!this.backlogloading) {
const eventBarEvent = new EventBarEvent(this, MessageTypes.GIFTSUB, data);
Expand All @@ -1424,7 +1440,12 @@ class Chat {
}

onMASSGIFT(data) {
MessageBuilder.massgift(data).into(this);
const msg = MessageBuilder.massgift(data);
if (this.mainwindow.containsMessage(msg)) {
return;
}

msg.into(this);

if (!this.backlogloading) {
const eventBarEvent = new EventBarEvent(
Expand All @@ -1440,7 +1461,12 @@ class Chat {
}

onDONATION(data) {
MessageBuilder.donation(data).into(this);
const msg = MessageBuilder.donation(data);
if (this.mainwindow.containsMessage(msg)) {
return;
}

msg.into(this);

if (!this.backlogloading) {
const eventBarEvent = new EventBarEvent(
Expand Down Expand Up @@ -1647,7 +1673,13 @@ class Chat {
}
}
this.censor(data.nick);
MessageBuilder.death(data.data, user, data.timestamp).into(this);

const msg = MessageBuilder.death(data.data, user, data.timestamp);
if (this.mainwindow.containsMessage(msg)) {
return;
}

msg.into(this);
}

onEVENTSELECTED() {
Expand Down
2 changes: 2 additions & 0 deletions assets/chat/js/messages/ChatEventMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ export default class ChatEventMessage extends ChatMessage {
this.isown = false;
this.mentioned = [];
this.uuid = uuid;

this.generateMessageHash();
}

html(chat = null) {
Expand Down