From b7e0dbf9ee73302b346afe2ef5269cf088a29205 Mon Sep 17 00:00:00 2001 From: Marcel Werk Date: Tue, 27 Aug 2024 12:03:58 +0200 Subject: [PATCH] Add exceptions for spam checking The spam check repeatedly matched even for trusted users because their IP address was listed in the SFS database. --- .../MessageSpamCheckingSfsListener.class.php | 38 ++++++++++++++++--- 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/wcfsetup/install/files/lib/system/event/listener/MessageSpamCheckingSfsListener.class.php b/wcfsetup/install/files/lib/system/event/listener/MessageSpamCheckingSfsListener.class.php index 3b51d828e6..14605cc618 100644 --- a/wcfsetup/install/files/lib/system/event/listener/MessageSpamCheckingSfsListener.class.php +++ b/wcfsetup/install/files/lib/system/event/listener/MessageSpamCheckingSfsListener.class.php @@ -22,13 +22,13 @@ final class MessageSpamCheckingSfsListener return; } + // Skip spam check for team members and trusted users. if ($event->user !== null) { - // Skip spam check for admins and moderators - $userProfile = UserProfileRuntimeCache::getInstance()->getObject($event->user->userID); - if ( - $userProfile->getPermission('admin.general.canUseAcp') - || $userProfile->getPermission('mod.general.canUseModeration') - ) { + if ($this->isTeamMember($event->user->userID)) { + return; + } + + if ($this->isTrustedUser($event->user->userID)) { return; } } @@ -41,4 +41,30 @@ final class MessageSpamCheckingSfsListener $event->preventDefault(); } } + + private function isTeamMember(int $userID): bool + { + $userProfile = UserProfileRuntimeCache::getInstance()->getObject($userID); + if ( + $userProfile->getPermission('admin.general.canUseAcp') + || $userProfile->getPermission('mod.general.canUseModeration') + ) { + return true; + } + + return false; + } + + private function isTrustedUser(int $userID): bool + { + $userProfile = UserProfileRuntimeCache::getInstance()->getObject($userID); + if ( + $userProfile->activityPoints >= 100 || + $userProfile->registrationDate < \TIME_NOW - 86_400 * 180 + ) { + return true; + } + + return false; + } } -- 2.20.1