Skip to content
Snippets Groups Projects
Verified Commit 81bdaa12 authored by Jonathan Weth's avatar Jonathan Weth :keyboard:
Browse files

Drop semantically wrong properties and use getters

parent 2f4bea19
No related branches found
No related tags found
1 merge request!2Resolve "Review tasks"
Pipeline #56070 canceled
......@@ -136,8 +136,7 @@ class MatrixRoom(ExtensiblePolymorphicModel):
return r
@property
def power_levels(self) -> dict[str, int]:
def get_power_levels(self) -> dict[str, int]:
"""Return the power levels for this room."""
r = do_matrix_request("GET", f"rooms/{self.room_id}/state")
......@@ -146,8 +145,7 @@ class MatrixRoom(ExtensiblePolymorphicModel):
return user_levels
@property
def members(self) -> list[str]:
def get_members(self) -> list[str]:
r = do_matrix_request(
"GET", f"rooms/{self.room_id}/members", body={"membership": ["join", "invite"]}
)
......@@ -202,7 +200,7 @@ class MatrixRoom(ExtensiblePolymorphicModel):
def sync_profiles(self):
"""Sync profiles for this room."""
all_profiles = self.get_profiles()
members = self.members
members = self.get_members()
# Invite all users who are not in the room yet
for profile in all_profiles:
......@@ -211,7 +209,7 @@ class MatrixRoom(ExtensiblePolymorphicModel):
self._invite(profile)
# Set power levels for all users
user_levels = self.power_levels
user_levels = self.get_power_levels()
for profile in all_profiles:
if profile.person in self.group.owners.all():
power_level = get_site_preferences()["matrix__power_level_for_owners"]
......@@ -272,9 +270,8 @@ class MatrixSpace(MatrixRoom):
creation_content["type"] = "m.space"
return super()._create_room(name, alias, invite, creation_content)
@property
def child_spaces(self) -> list[str]:
"""Get all child spaces of this space."""
def get_children(self) -> list[str]:
"""Get all children (rooms/spaces) of this space."""
r = do_matrix_request("GET", f"rooms/{self.room_id}/state")
return [c["state_key"] for c in r if c["type"] == "m.space.child"]
......@@ -289,7 +286,7 @@ class MatrixSpace(MatrixRoom):
def sync_children(self):
"""Sync membership of child spaces and rooms."""
current_children = self.child_spaces
current_children = self.get_children()
child_spaces = MatrixSpace.get_queryset().filter(
group__in=self.group.child_groups.filter(child_groups__isnull=False)
)
......
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