Skip to content

Commit

Permalink
Merge pull request #148 from destinygg/link-spam-bug
Browse files Browse the repository at this point in the history
Fix triggering spam if mention twice and then don't mention.
  • Loading branch information
11k authored Feb 9, 2024
2 parents 14d92e9 + 4541f53 commit 88a5181
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
1 change: 1 addition & 0 deletions lib/message-routing/message-router.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ class MessageRouter {
this.spamDetection.checkListOfRecentUrlsForSpam(
messageContent,
this.chatCache.getViewerUrlList(user),
this.chatCache.messageUrlSpamUser,
),
];

Expand Down
7 changes: 1 addition & 6 deletions lib/services/dgg-rolling-chat-cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,7 @@ class ChatCache {
}

addMessageToViewerUrlMap(user, message) {
if (
this.messageUrlSpamUser &&
!this.messageMatching.mentionsUser(message, this.messageUrlSpamUser)
) {
return;
}
if (!this.messageMatching.mentionsUser(message, this.messageUrlSpamUser)) return;
this.messageMatching.getLinks(message).forEach((link) => {
this.logger.info(
{ user, url: link.hostname + link.pathname, msg: message },
Expand Down
3 changes: 2 additions & 1 deletion lib/services/spam-detection.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ class SpamDetection {
return this.isSimilarityAboveThreshold(matchPercents);
}

checkListOfRecentUrlsForSpam(message, urlList) {
checkListOfRecentUrlsForSpam(message, urlList, mentionUser = null) {
if (!this.messageMatching.mentionsUser(message, mentionUser)) return false;
return this.messageMatching.getLinks(message).some((link) => {
return (
urlList.filter((url) => url === link.hostname + link.pathname).length >=
Expand Down

0 comments on commit 88a5181

Please sign in to comment.