@@ -44,24 +44,26 @@ async def get_group(self, group_id: str) -> Optional[Dict[str, Any]]:
4444 desc = "get_group" ,
4545 )
4646
47- def get_users_in_group (self , group_id , include_private = False ):
47+ async def get_users_in_group (
48+ self , group_id : str , include_private : bool = False
49+ ) -> List [Dict [str , Any ]]:
4850 # TODO: Pagination
4951
5052 keyvalues = {"group_id" : group_id }
5153 if not include_private :
5254 keyvalues ["is_public" ] = True
5355
54- return self .db_pool .simple_select_list (
56+ return await self .db_pool .simple_select_list (
5557 table = "group_users" ,
5658 keyvalues = keyvalues ,
5759 retcols = ("user_id" , "is_public" , "is_admin" ),
5860 desc = "get_users_in_group" ,
5961 )
6062
61- def get_invited_users_in_group (self , group_id ) :
63+ async def get_invited_users_in_group (self , group_id : str ) -> List [ str ] :
6264 # TODO: Pagination
6365
64- return self .db_pool .simple_select_onecol (
66+ return await self .db_pool .simple_select_onecol (
6567 table = "group_invites" ,
6668 keyvalues = {"group_id" : group_id },
6769 retcol = "user_id" ,
@@ -265,15 +267,14 @@ async def get_group_role(self, group_id, role_id):
265267
266268 return role
267269
268- def get_local_groups_for_room (self , room_id ) :
270+ async def get_local_groups_for_room (self , room_id : str ) -> List [ str ] :
269271 """Get all of the local group that contain a given room
270272 Args:
271- room_id (str) : The ID of a room
273+ room_id: The ID of a room
272274 Returns:
273- Deferred[list[str]]: A twisted.Deferred containing a list of group ids
274- containing this room
275+ A list of group ids containing this room
275276 """
276- return self .db_pool .simple_select_onecol (
277+ return await self .db_pool .simple_select_onecol (
277278 table = "group_rooms" ,
278279 keyvalues = {"room_id" : room_id },
279280 retcol = "group_id" ,
@@ -422,10 +423,10 @@ def _get_users_membership_in_group_txn(txn):
422423 "get_users_membership_info_in_group" , _get_users_membership_in_group_txn
423424 )
424425
425- def get_publicised_groups_for_user (self , user_id ) :
426+ async def get_publicised_groups_for_user (self , user_id : str ) -> List [ str ] :
426427 """Get all groups a user is publicising
427428 """
428- return self .db_pool .simple_select_onecol (
429+ return await self .db_pool .simple_select_onecol (
429430 table = "local_group_membership" ,
430431 keyvalues = {"user_id" : user_id , "membership" : "join" , "is_publicised" : True },
431432 retcol = "group_id" ,
@@ -466,8 +467,8 @@ async def get_remote_attestation(self, group_id, user_id):
466467
467468 return None
468469
469- def get_joined_groups (self , user_id ) :
470- return self .db_pool .simple_select_onecol (
470+ async def get_joined_groups (self , user_id : str ) -> List [ str ] :
471+ return await self .db_pool .simple_select_onecol (
471472 table = "local_group_membership" ,
472473 keyvalues = {"user_id" : user_id , "membership" : "join" },
473474 retcol = "group_id" ,
@@ -585,14 +586,14 @@ def _get_all_groups_changes_txn(txn):
585586
586587
587588class GroupServerStore (GroupServerWorkerStore ):
588- def set_group_join_policy (self , group_id , join_policy ) :
589+ async def set_group_join_policy (self , group_id : str , join_policy : str ) -> None :
589590 """Set the join policy of a group.
590591
591592 join_policy can be one of:
592593 * "invite"
593594 * "open"
594595 """
595- return self .db_pool .simple_update_one (
596+ await self .db_pool .simple_update_one (
596597 table = "groups" ,
597598 keyvalues = {"group_id" : group_id },
598599 updatevalues = {"join_policy" : join_policy },
@@ -1050,8 +1051,10 @@ def add_room_to_group(self, group_id, room_id, is_public):
10501051 desc = "add_room_to_group" ,
10511052 )
10521053
1053- def update_room_in_group_visibility (self , group_id , room_id , is_public ):
1054- return self .db_pool .simple_update (
1054+ async def update_room_in_group_visibility (
1055+ self , group_id : str , room_id : str , is_public : bool
1056+ ) -> int :
1057+ return await self .db_pool .simple_update (
10551058 table = "group_rooms" ,
10561059 keyvalues = {"group_id" : group_id , "room_id" : room_id },
10571060 updatevalues = {"is_public" : is_public },
@@ -1076,10 +1079,12 @@ def _remove_room_from_group_txn(txn):
10761079 "remove_room_from_group" , _remove_room_from_group_txn
10771080 )
10781081
1079- def update_group_publicity (self , group_id , user_id , publicise ):
1082+ async def update_group_publicity (
1083+ self , group_id : str , user_id : str , publicise : bool
1084+ ) -> None :
10801085 """Update whether the user is publicising their membership of the group
10811086 """
1082- return self .db_pool .simple_update_one (
1087+ await self .db_pool .simple_update_one (
10831088 table = "local_group_membership" ,
10841089 keyvalues = {"group_id" : group_id , "user_id" : user_id },
10851090 updatevalues = {"is_publicised" : publicise },
@@ -1218,20 +1223,24 @@ async def update_group_profile(self, group_id, profile):
12181223 desc = "update_group_profile" ,
12191224 )
12201225
1221- def update_attestation_renewal (self , group_id , user_id , attestation ):
1226+ async def update_attestation_renewal (
1227+ self , group_id : str , user_id : str , attestation : dict
1228+ ) -> None :
12221229 """Update an attestation that we have renewed
12231230 """
1224- return self .db_pool .simple_update_one (
1231+ await self .db_pool .simple_update_one (
12251232 table = "group_attestations_renewals" ,
12261233 keyvalues = {"group_id" : group_id , "user_id" : user_id },
12271234 updatevalues = {"valid_until_ms" : attestation ["valid_until_ms" ]},
12281235 desc = "update_attestation_renewal" ,
12291236 )
12301237
1231- def update_remote_attestion (self , group_id , user_id , attestation ):
1238+ async def update_remote_attestion (
1239+ self , group_id : str , user_id : str , attestation : dict
1240+ ) -> None :
12321241 """Update an attestation that a remote has renewed
12331242 """
1234- return self .db_pool .simple_update_one (
1243+ await self .db_pool .simple_update_one (
12351244 table = "group_attestations_remote" ,
12361245 keyvalues = {"group_id" : group_id , "user_id" : user_id },
12371246 updatevalues = {
0 commit comments