mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-02 18:04:49 -04:00
Add support for extracting matching room_ids and room_aliases for a given AS.
This commit is contained in:
parent
2d20466f9a
commit
2b8ca84296
3 changed files with 82 additions and 2 deletions
|
@ -153,6 +153,19 @@ class ApplicationServiceStore(SQLBaseStore):
|
|||
|
||||
@defer.inlineCallbacks
|
||||
def get_app_service_by_user_id(self, user_id):
|
||||
"""Retrieve an application service from their user ID.
|
||||
|
||||
All application services have associated with them a particular user ID.
|
||||
There is no distinguishing feature on the user ID which indicates it
|
||||
represents an application service. This function allows you to map from
|
||||
a user ID to an application service.
|
||||
|
||||
Args:
|
||||
user_id(str): The user ID to see if it is an application service.
|
||||
Returns:
|
||||
synapse.appservice.ApplicationService or None.
|
||||
"""
|
||||
|
||||
yield self.cache_defer # make sure the cache is ready
|
||||
|
||||
for service in self.services_cache:
|
||||
|
@ -163,7 +176,7 @@ class ApplicationServiceStore(SQLBaseStore):
|
|||
|
||||
@defer.inlineCallbacks
|
||||
def get_app_service_by_token(self, token, from_cache=True):
|
||||
"""Get the application service with the given token.
|
||||
"""Get the application service with the given appservice token.
|
||||
|
||||
Args:
|
||||
token (str): The application service token.
|
||||
|
@ -186,10 +199,43 @@ class ApplicationServiceStore(SQLBaseStore):
|
|||
|
||||
@defer.inlineCallbacks
|
||||
def get_app_service_rooms(self, service):
|
||||
logger.info("get_app_service_rooms -> %s", service)
|
||||
"""Get a list of RoomsForUser for this application service.
|
||||
|
||||
Application services may be "interested" in lots of rooms depending on
|
||||
the room ID, the room aliases, or the members in the room. This function
|
||||
takes all of these into account and returns a list of RoomsForUser which
|
||||
represent the entire list of room IDs that this application service
|
||||
wants to know about.
|
||||
|
||||
Args:
|
||||
service: The application service to get a room list for.
|
||||
Returns:
|
||||
A list of RoomsForUser.
|
||||
"""
|
||||
# FIXME: This is assuming that this store has methods from
|
||||
# RoomStore, DirectoryStore, which is a bad assumption to
|
||||
# make as it makes testing trickier and coupling less obvious.
|
||||
|
||||
# get all rooms matching the room ID regex.
|
||||
room_entries = yield self.get_all_rooms() # RoomEntry list
|
||||
matching_room_id_list = [
|
||||
r.room_id for r in room_entries if
|
||||
service.is_interested_in_room(r.room_id)
|
||||
]
|
||||
|
||||
# resolve room IDs for matching room alias regex.
|
||||
room_alias_mappings = yield self.get_all_associations()
|
||||
matching_alias_list = [
|
||||
r.room_id for r in room_alias_mappings if
|
||||
service.is_interested_in_alias(r.room_alias)
|
||||
]
|
||||
|
||||
# get all rooms for every user for this AS.
|
||||
|
||||
# TODO stub
|
||||
yield self.cache_defer
|
||||
|
||||
|
||||
defer.returnValue([RoomsForUser("!foo:bar", service.sender, "join")])
|
||||
|
||||
@defer.inlineCallbacks
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue