commit 796a152f753611710922c4147cc86707ec024906
parent 65a604c74db8ad36d9a78f69f347c12f4ccb84ca
Author: n0tr1v <n0tr1v@protonmail.com>
Date: Thu, 19 Jan 2023 19:23:58 -0800
change error order
Diffstat:
1 file changed, 9 insertions(+), 10 deletions(-)
diff --git a/pkg/web/handlers/api/v1/slashInterceptor.go b/pkg/web/handlers/api/v1/slashInterceptor.go
@@ -840,22 +840,12 @@ func canUserPmOther(user, other database.User, roomIsPrivate bool) (skipInbox bo
return false, nil
}
- // Other doesn't want PM from new users
- if !user.AccountOldEnough() && other.BlockNewUsersPm {
- return false, errPMDenied
- }
-
switch other.PmMode {
case database.PmModeWhitelist:
// We are in whitelist mode, and user is not whitelisted
return false, errPMDenied
case database.PmModeStandard:
- // User on blacklist cannot PM/Inbox
- if database.IsUserPmBlacklisted(user.ID, other.ID) {
- return false, errPMDenied
- }
-
if !user.CanSendPM() {
// In private rooms, can send PM but inboxes will be skipped if not enough public messages
if roomIsPrivate {
@@ -865,6 +855,15 @@ func canUserPmOther(user, other database.User, roomIsPrivate bool) (skipInbox bo
return false, Err20Msgs
}
+ // User on blacklist cannot PM/Inbox
+ if database.IsUserPmBlacklisted(user.ID, other.ID) {
+ return false, errPMDenied
+ }
+ // Other doesn't want PM from new users
+ if !user.AccountOldEnough() && other.BlockNewUsersPm {
+ return false, errPMDenied
+ }
+
return false, nil
}