Skip to content
Snippets Groups Projects
Commit 195b46b3 authored by Martin Lees's avatar Martin Lees Committed by Howo
Browse files

fix assert error message and add assert for setUserTitle

parent 4744e59c
No related branches found
No related tags found
1 merge request!539Update SetRole/SetUserTitle so that you have to be subscribed to get it, also...
This commit is part of merge request !539. Comments created here will be created in the context of that merge request.
...@@ -578,15 +578,18 @@ class CommunityOp: ...@@ -578,15 +578,18 @@ class CommunityOp:
assert account_role < actor_role, 'cant modify higher-role user' assert account_role < actor_role, 'cant modify higher-role user'
assert account_role != new_role, 'role would not change' 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( subscribed = DB.query_one(
f"""SELECT * FROM {SCHEMA_NAME}.validate_community_set_role(:community_id, :actor_id, :role_id)""", 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, 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': elif action == 'updateProps':
assert actor_role >= Role.admin, 'only admins can update props' assert actor_role >= Role.admin, 'only admins can update props'
elif action == 'setUserTitle': 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? # TODO: assert title changed?
assert actor_role >= Role.mod, 'only mods can set user titles' assert actor_role >= Role.mod, 'only mods can set user titles'
elif action == 'mutePost': elif action == 'mutePost':
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment