From a28942aaddf6465dab268007a2ce7e4e8fd4856e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nils=20B=C3=BCchner?= Date: Sun, 15 Sep 2024 00:11:33 +0200 Subject: [PATCH] fixes --- synapse_invite_checker/invite_checker.py | 28 +++++++++++++----------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/synapse_invite_checker/invite_checker.py b/synapse_invite_checker/invite_checker.py index 6c7e7c8..4d3da4e 100644 --- a/synapse_invite_checker/invite_checker.py +++ b/synapse_invite_checker/invite_checker.py @@ -182,26 +182,28 @@ class InviteChecker: inviter_domain = UserID.from_string(inviter).domain logger.debug(f"Blocklist: {blocklist}, Allowlist: {allowlist}, Blocklist Room IDs: {blocklist_room_ids}") + + if self.use_allowlist: + logger.info(f"Allowlist enabled. Checking domain: {inviter_domain}") + if inviter_domain in allowlist: + logger.info(f"Invite allowed: {inviter_domain} is on the allowlist") + returnValue("NOT_SPAM") if room_id in blocklist_room_ids: logger.info(f"Invite blocked: room {room_id} is blocklisted") returnValue(errors.Codes.FORBIDDEN) - if self.use_allowlist: - logger.info(f"Allowlist enabled. Checking domain: {inviter_domain}") - if inviter_domain in allowlist: - logger.info(f"Invite allowed: {inviter_domain} is in the allowlist") - returnValue("NOT_SPAM") - if self.use_blocklist: - logger.info(f"Blocklist enabled. Checking domain: {inviter_domain}") + logger.info(f"Blocklist enabled. Checking {inviter}") if inviter_domain in blocklist: - logger.info(f"Invite blocked: {inviter_domain} is in the blocklist") + logger.info(f"Invite blocked: {inviter_domain} is on the blocklist") returnValue(errors.Codes.FORBIDDEN) - - if self.use_allowlist and inviter_domain not in allowlist: - logger.info(f"Invite blocked: {inviter_domain} is not in the allowlist") + if inviter in blocklist: + logger.info(f"Invite blocked: {inviter} is on the blocklist") + returnValue(errors.Codes.FORBIDDEN) + elif self.use_allowlist and inviter_domain not in allowlist: + logger.info(f"Invite blocked: {inviter_domain} is not on the allowlist") returnValue(errors.Codes.FORBIDDEN) - - logger.info(f"Invite allowed by default: {inviter_domain}") + logger.info(f"Invite allowed by default: {inviter}") + returnValue("NOT_SPAM")