From: Marcel Werk Date: Tue, 27 Aug 2024 10:03:58 +0000 (+0200) Subject: Add exceptions for spam checking X-Git-Tag: 6.1.0_Beta_1~5^2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=b7e0dbf9ee73302b346afe2ef5269cf088a29205;p=GitHub%2FWoltLab%2FWCF.git Add exceptions for spam checking The spam check repeatedly matched even for trusted users because their IP address was listed in the SFS database. --- 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; + } }