diff options
author | Andrew Morgan <andrew@amorgan.xyz> | 2021-11-26 17:17:05 +0000 |
---|---|---|
committer | Andrew Morgan <andrew@amorgan.xyz> | 2021-12-08 18:30:52 +0000 |
commit | a19380416239feb35ea0af1c163a09ef3e15f0f3 (patch) | |
tree | 192cbf6a81ea47a348983c5f7d3b882f99a2b456 | |
parent | rename ApplicationServices.is_interested -> is_interested_in_event (diff) | |
download | synapse-a19380416239feb35ea0af1c163a09ef3e15f0f3.tar.xz |
rename ApplicationService.is_interested_in_user -> is_user_in_namespace
-rw-r--r-- | synapse/api/auth.py | 2 | ||||
-rw-r--r-- | synapse/appservice/__init__.py | 10 | ||||
-rw-r--r-- | synapse/appservice/api.py | 2 | ||||
-rw-r--r-- | synapse/handlers/appservice.py | 6 | ||||
-rw-r--r-- | synapse/handlers/message.py | 2 | ||||
-rw-r--r-- | synapse/handlers/register.py | 4 | ||||
-rw-r--r-- | synapse/rest/client/login.py | 2 |
7 files changed, 14 insertions, 14 deletions
diff --git a/synapse/api/auth.py b/synapse/api/auth.py index 44883c6663..2b73c66071 100644 --- a/synapse/api/auth.py +++ b/synapse/api/auth.py @@ -263,7 +263,7 @@ class Auth: if app_service.sender == user_id: pass # Check to make sure the app service is allowed to control the user - elif not app_service.is_interested_in_user(user_id): + elif not app_service.is_user_in_namespace(user_id): raise AuthError( 403, "Application service cannot masquerade as this user (%s)." % user_id, diff --git a/synapse/appservice/__init__.py b/synapse/appservice/__init__.py index c2e2132d59..fbc9d5d1f8 100644 --- a/synapse/appservice/__init__.py +++ b/synapse/appservice/__init__.py @@ -150,10 +150,10 @@ class ApplicationService: if not event: return False - if self.is_interested_in_user(event.sender): + if self.is_user_in_namespace(event.sender): return True # also check m.room.member state key - if event.type == EventTypes.Member and self.is_interested_in_user( + if event.type == EventTypes.Member and self.is_user_in_namespace( event.state_key ): return True @@ -186,7 +186,7 @@ class ApplicationService: # check joined member events for user_id in member_list: - if self.is_interested_in_user(user_id): + if self.is_user_in_namespace(user_id): return True return False @@ -248,7 +248,7 @@ class ApplicationService: True if this service would like to know about presence for this user. """ # Find all the rooms the sender is in - if self.is_interested_in_user(user_id.to_string()): + if self.is_user_in_namespace(user_id.to_string()): return True room_ids = await store.get_rooms_for_user(user_id.to_string()) @@ -258,7 +258,7 @@ class ApplicationService: return True return False - def is_interested_in_user(self, user_id: str) -> bool: + def is_user_in_namespace(self, user_id: str) -> bool: return ( bool(self._matches_regex(user_id, ApplicationService.NS_USERS)) or user_id == self.sender diff --git a/synapse/appservice/api.py b/synapse/appservice/api.py index ca58f92339..63bc07512c 100644 --- a/synapse/appservice/api.py +++ b/synapse/appservice/api.py @@ -293,7 +293,7 @@ class ApplicationServiceApi(SimpleHttpClient): e.membership == Membership.INVITE or e.membership == Membership.KNOCK ) - and service.is_interested_in_user(e.state_key) + and service.is_user_in_namespace(e.state_key) ), ) for e in events diff --git a/synapse/handlers/appservice.py b/synapse/handlers/appservice.py index 122ec4ac1d..affc398158 100644 --- a/synapse/handlers/appservice.py +++ b/synapse/handlers/appservice.py @@ -522,7 +522,7 @@ class ApplicationServicesHandler: if isinstance(user, UserID): user = user.to_string() - if service.is_interested_in_user(user): + if service.is_user_in_namespace(user): users_appservice_is_interested_in.append(user) if not users_appservice_is_interested_in: @@ -579,7 +579,7 @@ class ApplicationServicesHandler: """ users_appservice_is_interested_in = [ - user for user in users if service.is_interested_in_user(user) + user for user in users if service.is_user_in_namespace(user) ] if not users_appservice_is_interested_in: @@ -719,7 +719,7 @@ class ApplicationServicesHandler: def _get_services_for_user(self, user_id: str) -> List[ApplicationService]: services = self.store.get_app_services() - return [s for s in services if (s.is_interested_in_user(user_id))] + return [s for s in services if (s.is_user_in_namespace(user_id))] def _get_services_for_3pn(self, protocol: str) -> List[ApplicationService]: services = self.store.get_app_services() diff --git a/synapse/handlers/message.py b/synapse/handlers/message.py index 87f671708c..c385813493 100644 --- a/synapse/handlers/message.py +++ b/synapse/handlers/message.py @@ -280,7 +280,7 @@ class MessageHandler: # is a user in the room that the AS is "interested in" if requester.app_service and user_id not in users_with_profile: for uid in users_with_profile: - if requester.app_service.is_interested_in_user(uid): + if requester.app_service.is_user_in_namespace(uid): break else: # Loop fell through, AS has no interested users in room diff --git a/synapse/handlers/register.py b/synapse/handlers/register.py index f08a516a75..ab3d5c9456 100644 --- a/synapse/handlers/register.py +++ b/synapse/handlers/register.py @@ -615,7 +615,7 @@ class RegistrationHandler: service = self.store.get_app_service_by_token(as_token) if not service: raise AuthError(403, "Invalid application service token.") - if not service.is_interested_in_user(user_id): + if not service.is_user_in_namespace(user_id): raise SynapseError( 400, "Invalid user localpart for this application service.", @@ -650,7 +650,7 @@ class RegistrationHandler: interested_services = [ s for s in services - if s.is_interested_in_user(user_id) and s != allowed_appservice + if s.is_user_in_namespace(user_id) and s != allowed_appservice ] for service in interested_services: if service.is_exclusive_user(user_id): diff --git a/synapse/rest/client/login.py b/synapse/rest/client/login.py index f9994658c4..abb9d49f9f 100644 --- a/synapse/rest/client/login.py +++ b/synapse/rest/client/login.py @@ -249,7 +249,7 @@ class LoginRestServlet(RestServlet): else: qualified_user_id = UserID(user, self.hs.hostname).to_string() - if not appservice.is_interested_in_user(qualified_user_id): + if not appservice.is_user_in_namespace(qualified_user_id): raise LoginError(403, "Invalid access_token", errcode=Codes.FORBIDDEN) return await self._complete_login( |