summary refs log tree commit diff
path: root/synapse/api/auth.py
diff options
context:
space:
mode:
authorWill Hunt <will@half-shot.uk>2022-07-27 13:44:40 +0100
committerGitHub <noreply@github.com>2022-07-27 13:44:40 +0100
commit502f075e96b458a183952ae2be402f00b28af299 (patch)
tree63e1bca88c782aef6b9510cb126206816aabca55 /synapse/api/auth.py
parentMake minor clarifications to the error messages given when we fail to join a ... (diff)
downloadsynapse-502f075e96b458a183952ae2be402f00b28af299.tar.xz
Implement MSC3848: Introduce errcodes for specific event sending failures (#13343)
Implements MSC3848
Diffstat (limited to 'synapse/api/auth.py')
-rw-r--r--synapse/api/auth.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/synapse/api/auth.py b/synapse/api/auth.py
index 6e6eaf3805..82e6475ef5 100644
--- a/synapse/api/auth.py
+++ b/synapse/api/auth.py
@@ -26,6 +26,7 @@ from synapse.api.errors import (
     Codes,
     InvalidClientTokenError,
     MissingClientTokenError,
+    UnstableSpecAuthError,
 )
 from synapse.appservice import ApplicationService
 from synapse.http import get_request_user_agent
@@ -106,8 +107,11 @@ class Auth:
                 forgot = await self.store.did_forget(user_id, room_id)
                 if not forgot:
                     return membership, member_event_id
-
-        raise AuthError(403, "User %s not in room %s" % (user_id, room_id))
+        raise UnstableSpecAuthError(
+            403,
+            "User %s not in room %s" % (user_id, room_id),
+            errcode=Codes.NOT_JOINED,
+        )
 
     async def get_user_by_req(
         self,
@@ -600,8 +604,9 @@ class Auth:
                 == HistoryVisibility.WORLD_READABLE
             ):
                 return Membership.JOIN, None
-            raise AuthError(
+            raise UnstableSpecAuthError(
                 403,
                 "User %s not in room %s, and room previews are disabled"
                 % (user_id, room_id),
+                errcode=Codes.NOT_JOINED,
             )