2525from twisted .internet .defer import succeed
2626
2727from synapse .api .constants import MAX_DEPTH , EventTypes , Membership
28- from synapse .api .errors import AuthError , Codes , ConsentNotGivenError , SynapseError
28+ from synapse .api .errors import (
29+ AuthError ,
30+ Codes ,
31+ ConsentNotGivenError ,
32+ NotFoundError ,
33+ SynapseError ,
34+ )
2935from synapse .api .urls import ConsentURIBuilder
3036from synapse .crypto .event_signing import add_hashes_and_signatures
3137from synapse .events .utils import serialize_event
@@ -111,7 +117,7 @@ def get_state_events(
111117 Returns:
112118 A list of dicts representing state events. [{}, {}, {}]
113119 Raises:
114- SynapseError (404) if the at token does not yield an event
120+ NotFoundError (404) if the at token does not yield an event
115121
116122 AuthError (403) if the user doesn't have permission to view
117123 members of this room.
@@ -126,14 +132,10 @@ def get_state_events(
126132 )
127133
128134 if not last_events :
129- raise SynapseError (
130- 404 ,
131- "Can't find event for token %s" % at_token ,
132- Codes .NOT_FOUND
133- )
135+ raise NotFoundError ("Can't find event for token %s" % (at_token , ))
134136
135137 visible_events = yield filter_events_for_client (
136- self .store , user_id , last_events
138+ self .store , user_id , last_events ,
137139 )
138140
139141 event = last_events [0 ]
@@ -144,14 +146,15 @@ def get_state_events(
144146 room_state = room_state [event .event_id ]
145147 else :
146148 raise AuthError (
147- 403 , "User %s not allowed to view events in room %s at token %s" % (
148- user_id , room_id , at_token
149+ 403 ,
150+ "User %s not allowed to view events in room %s at token %s" % (
151+ user_id , room_id , at_token ,
149152 )
150153 )
151154 else :
152155 membership , membership_event_id = (
153156 yield self .auth .check_in_room_or_world_readable (
154- room_id , user_id
157+ room_id , user_id ,
155158 )
156159 )
157160
0 commit comments