From d403292ef674943d7fc3953e9cdbda85402d7c1c Mon Sep 17 00:00:00 2001 From: Dragory <2606411+Dragory@users.noreply.github.com> Date: Mon, 2 Dec 2019 01:13:53 +0200 Subject: [PATCH] starboard: prevent self-votes --- backend/src/plugins/Starboard.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/backend/src/plugins/Starboard.ts b/backend/src/plugins/Starboard.ts index e51e637b..46868206 100644 --- a/backend/src/plugins/Starboard.ts +++ b/backend/src/plugins/Starboard.ts @@ -183,6 +183,9 @@ export class StarboardPlugin extends ZeppelinPlugin { } } + // No self-votes! + if (msg.author.id === userId) return; + const user = await this.resolveUser(userId); if (user instanceof UnknownUser) return; if (user.bot) return; @@ -212,7 +215,7 @@ export class StarboardPlugin extends ZeppelinPlugin { for (const starboard of applicableStarboards) { // Save reaction into the database - await this.starboardReactions.createStarboardReaction(msg.id, userId).catch(); + await this.starboardReactions.createStarboardReaction(msg.id, userId).catch(noop); // If the message has already been posted to this starboard, we don't need to do anything else const starboardMessages = await this.starboardMessages.getMatchingStarboardMessages(starboard.channel_id, msg.id);