Skip to content

Commit 88a5181

Browse files
authored
Merge pull request #148 from destinygg/link-spam-bug
Fix triggering spam if mention twice and then don't mention.
2 parents 14d92e9 + 4541f53 commit 88a5181

File tree

3 files changed

+4
-7
lines changed

3 files changed

+4
-7
lines changed

lib/message-routing/message-router.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ class MessageRouter {
109109
this.spamDetection.checkListOfRecentUrlsForSpam(
110110
messageContent,
111111
this.chatCache.getViewerUrlList(user),
112+
this.chatCache.messageUrlSpamUser,
112113
),
113114
];
114115

lib/services/dgg-rolling-chat-cache.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,7 @@ class ChatCache {
7979
}
8080

8181
addMessageToViewerUrlMap(user, message) {
82-
if (
83-
this.messageUrlSpamUser &&
84-
!this.messageMatching.mentionsUser(message, this.messageUrlSpamUser)
85-
) {
86-
return;
87-
}
82+
if (!this.messageMatching.mentionsUser(message, this.messageUrlSpamUser)) return;
8883
this.messageMatching.getLinks(message).forEach((link) => {
8984
this.logger.info(
9085
{ user, url: link.hostname + link.pathname, msg: message },

lib/services/spam-detection.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ class SpamDetection {
118118
return this.isSimilarityAboveThreshold(matchPercents);
119119
}
120120

121-
checkListOfRecentUrlsForSpam(message, urlList) {
121+
checkListOfRecentUrlsForSpam(message, urlList, mentionUser = null) {
122+
if (!this.messageMatching.mentionsUser(message, mentionUser)) return false;
122123
return this.messageMatching.getLinks(message).some((link) => {
123124
return (
124125
urlList.filter((url) => url === link.hostname + link.pathname).length >=

0 commit comments

Comments
 (0)