From 195b46b34e47587a8d40185dd82e265bd7f58ad3 Mon Sep 17 00:00:00 2001 From: Martin Lees <drov0@users.noreply.github.com> Date: Fri, 7 Jul 2023 23:01:56 -0400 Subject: [PATCH] fix assert error message and add assert for setUserTitle --- hive/indexer/community.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hive/indexer/community.py b/hive/indexer/community.py index f58f44448..34c6b16b5 100644 --- a/hive/indexer/community.py +++ b/hive/indexer/community.py @@ -578,15 +578,18 @@ class CommunityOp: assert account_role < actor_role, 'cant modify higher-role user' assert account_role != new_role, 'role would not change' + # prevent setting a role if the user is not subscribed to the community. + # the role "muted" is still settable regardless of subscription status subscribed = DB.query_one( f"""SELECT * FROM {SCHEMA_NAME}.validate_community_set_role(:community_id, :actor_id, :role_id)""", community_id=self.community_id, actor_id=self.actor_id, role_id=new_role, ) - assert subscribed, f"account {self.account} must be subscribed to the community to execute setRole" + assert subscribed, f"{self.actor} must be subscribed to the community to change its role" elif action == 'updateProps': assert actor_role >= Role.admin, 'only admins can update props' elif action == 'setUserTitle': + assert self._subscribed(self.actor_id), f"{self.actor} must be subscribed to the community to change its title" # TODO: assert title changed? assert actor_role >= Role.mod, 'only mods can set user titles' elif action == 'mutePost': -- GitLab