Skip to content
Snippets Groups Projects

Update SetRole/SetUserTitle so that you have to be subscribed to get it, also...

Merged Howo requested to merge feature/role-only-if-subscribed into develop
1 file
+ 4
1
Compare changes
  • Side-by-side
  • Inline
+ 4
1
@@ -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':
Loading