Codebase list matrix-synapse / 3ed5aa7
Imported Upstream version 0.33.1 Erik Johnston 5 years ago
9 changed file(s) with 91 addition(s) and 27 deletion(s). Raw diff Collapse all Expand all
0 Synapse 0.33.1 (2018-08-02)
1 ===========================
2
3 SECURITY FIXES
4 --------------
5
6 - Fix a potential issue where servers could request events for rooms they have not joined. (`#3641 <https://github.com/matrix-org/synapse/issues/3641>`_)
7 - Fix a potential issue where users could see events in private rooms before they joined. (`#3642 <https://github.com/matrix-org/synapse/issues/3642>`_)
8
9
010 Synapse 0.33.0 (2018-07-19)
111 ===========================
212
13 Bugfixes
14 --------
15
16 - Disable a noisy warning about logcontexts. (`#3561 <https://github.com/matrix-org/synapse/issues/3561>`_)
17
18
19 Synapse 0.33.0rc1 (2018-07-18)
20 ==============================
21
322 Features
423 --------
524
6 - Enforce the specified API for report_event (`#3316 <https://github.com/matrix-org/synapse/issues/3316>`_)
25 - Enforce the specified API for report_event. (`#3316 <https://github.com/matrix-org/synapse/issues/3316>`_)
726 - Include CPU time from database threads in request/block metrics. (`#3496 <https://github.com/matrix-org/synapse/issues/3496>`_, `#3501 <https://github.com/matrix-org/synapse/issues/3501>`_)
8 - Add CPU metrics for _fetch_event_list (`#3497 <https://github.com/matrix-org/synapse/issues/3497>`_)
9 - optimisation for /sync (`#3505 <https://github.com/matrix-org/synapse/issues/3505>`_, `#3521 <https://github.com/matrix-org/synapse/issues/3521>`_)
27 - Add CPU metrics for _fetch_event_list. (`#3497 <https://github.com/matrix-org/synapse/issues/3497>`_)
1028 - Optimisation to make handling incoming federation requests more efficient. (`#3541 <https://github.com/matrix-org/synapse/issues/3541>`_)
1129
1230
1331 Bugfixes
1432 --------
1533
16 - Use more portable syntax in our use of the attrs package, widening the supported versions (`#3498 <https://github.com/matrix-org/synapse/issues/3498>`_)
17 - Fix queued federation requests being processed in the wrong order (`#3533 <https://github.com/matrix-org/synapse/issues/3533>`_)
34 - Fix a significant performance regression in /sync. (`#3505 <https://github.com/matrix-org/synapse/issues/3505>`_, `#3521 <https://github.com/matrix-org/synapse/issues/3521>`_, `#3530 <https://github.com/matrix-org/synapse/issues/3530>`_, `#3544 <https://github.com/matrix-org/synapse/issues/3544>`_)
35 - Use more portable syntax in our use of the attrs package, widening the supported versions. (`#3498 <https://github.com/matrix-org/synapse/issues/3498>`_)
36 - Fix queued federation requests being processed in the wrong order. (`#3533 <https://github.com/matrix-org/synapse/issues/3533>`_)
1837 - Ensure that erasure requests are correctly honoured for publicly accessible rooms when accessed over federation. (`#3546 <https://github.com/matrix-org/synapse/issues/3546>`_)
19 - Disable a noisy warning about logcontexts (`#3561 <https://github.com/matrix-org/synapse/issues/3561>`_)
2038
2139
2240 Misc
2341 ----
2442
25 - `#3351 <https://github.com/matrix-org/synapse/issues/3351>`_, `#3463 <https://github.com/matrix-org/synapse/issues/3463>`_, `#3464 <https://github.com/matrix-org/synapse/issues/3464>`_, `#3499 <https://github.com/matrix-org/synapse/issues/3499>`_, `#3530 <https://github.com/matrix-org/synapse/issues/3530>`_, `#3534 <https://github.com/matrix-org/synapse/issues/3534>`_, `#3535 <https://github.com/matrix-org/synapse/issues/3535>`_, `#3540 <https://github.com/matrix-org/synapse/issues/3540>`_, `#3544 <https://github.com/matrix-org/synapse/issues/3544>`_
43 - Refactoring to improve testability. (`#3351 <https://github.com/matrix-org/synapse/issues/3351>`_, `#3499 <https://github.com/matrix-org/synapse/issues/3499>`_)
44 - Use ``isort`` to sort imports. (`#3463 <https://github.com/matrix-org/synapse/issues/3463>`_, `#3464 <https://github.com/matrix-org/synapse/issues/3464>`_, `#3540 <https://github.com/matrix-org/synapse/issues/3540>`_)
45 - Use parse and asserts from http.servlet. (`#3534 <https://github.com/matrix-org/synapse/issues/3534>`_, `#3535 <https://github.com/matrix-org/synapse/issues/3535>`_).
2646
2747
2848 Synapse 0.32.2 (2018-07-07)
1616 """ This is a reference implementation of a Matrix home server.
1717 """
1818
19 __version__ = "0.33.0"
19 __version__ = "0.33.1"
424424 ret = yield self.handler.on_query_auth(
425425 origin,
426426 event_id,
427 room_id,
427428 signed_auth,
428429 content.get("rejects", []),
429430 content.get("missing", []),
1818 from twisted.internet import defer
1919
2020 from synapse.api.constants import EventTypes, Membership
21 from synapse.api.errors import AuthError
2122 from synapse.events import EventBase
2223 from synapse.events.utils import serialize_event
2324 from synapse.types import UserID
2425 from synapse.util.logutils import log_function
26 from synapse.visibility import filter_events_for_client
2527
2628 from ._base import BaseHandler
2729
128130 class EventHandler(BaseHandler):
129131
130132 @defer.inlineCallbacks
131 def get_event(self, user, event_id):
133 def get_event(self, user, room_id, event_id):
132134 """Retrieve a single specified event.
133135
134136 Args:
135137 user (synapse.types.UserID): The user requesting the event
138 room_id (str|None): The expected room id. We'll return None if the
139 event's room does not match.
136140 event_id (str): The event ID to obtain.
137141 Returns:
138142 dict: An event, or None if there is no event matching this ID.
141145 AuthError if the user does not have the rights to inspect this
142146 event.
143147 """
144 event = yield self.store.get_event(event_id)
148 event = yield self.store.get_event(event_id, check_room_id=room_id)
145149
146150 if not event:
147151 defer.returnValue(None)
148152 return
149153
150 if hasattr(event, "room_id"):
151 yield self.auth.check_joined_room(event.room_id, user.to_string())
154 users = yield self.store.get_users_in_room(event.room_id)
155 is_peeking = user.to_string() not in users
156
157 filtered = yield filter_events_for_client(
158 self.store,
159 user.to_string(),
160 [event],
161 is_peeking=is_peeking
162 )
163
164 if not filtered:
165 raise AuthError(
166 403,
167 "You don't have permission to access that event."
168 )
152169
153170 defer.returnValue(event)
13481348 def get_state_for_pdu(self, room_id, event_id):
13491349 """Returns the state at the event. i.e. not including said event.
13501350 """
1351
1352 event = yield self.store.get_event(
1353 event_id, allow_none=False, check_room_id=room_id,
1354 )
1355
13511356 state_groups = yield self.store.get_state_groups(
13521357 room_id, [event_id]
13531358 )
13581363 (e.type, e.state_key): e for e in state
13591364 }
13601365
1361 event = yield self.store.get_event(event_id)
1362 if event and event.is_state():
1366 if event.is_state():
13631367 # Get previous state
13641368 if "replaces_state" in event.unsigned:
13651369 prev_id = event.unsigned["replaces_state"]
13901394 def get_state_ids_for_pdu(self, room_id, event_id):
13911395 """Returns the state at the event. i.e. not including said event.
13921396 """
1397 event = yield self.store.get_event(
1398 event_id, allow_none=False, check_room_id=room_id,
1399 )
1400
13931401 state_groups = yield self.store.get_state_groups_ids(
13941402 room_id, [event_id]
13951403 )
13981406 _, state = state_groups.items().pop()
13991407 results = state
14001408
1401 event = yield self.store.get_event(event_id)
1402 if event and event.is_state():
1409 if event.is_state():
14031410 # Get previous state
14041411 if "replaces_state" in event.unsigned:
14051412 prev_id = event.unsigned["replaces_state"]
17051712 defer.returnValue(context)
17061713
17071714 @defer.inlineCallbacks
1708 def on_query_auth(self, origin, event_id, remote_auth_chain, rejects,
1715 def on_query_auth(self, origin, event_id, room_id, remote_auth_chain, rejects,
17091716 missing):
1717 in_room = yield self.auth.check_host_in_room(
1718 room_id,
1719 origin
1720 )
1721 if not in_room:
1722 raise AuthError(403, "Host not in room.")
1723
1724 event = yield self.store.get_event(
1725 event_id, allow_none=False, check_room_id=room_id
1726 )
1727
17101728 # Just go through and process each event in `remote_auth_chain`. We
17111729 # don't want to fall into the trap of `missing` being wrong.
17121730 for e in remote_auth_chain:
17161734 pass
17171735
17181736 # Now get the current auth_chain for the event.
1719 event = yield self.store.get_event(event_id)
17201737 local_auth_chain = yield self.store.get_auth_chain(
17211738 [auth_id for auth_id, _ in event.auth_events],
17221739 include_given=True
8787 @defer.inlineCallbacks
8888 def on_GET(self, request, event_id):
8989 requester = yield self.auth.get_user_by_req(request)
90 event = yield self.event_handler.get_event(requester.user, event_id)
90 event = yield self.event_handler.get_event(requester.user, None, event_id)
9191
9292 time_now = self.clock.time_msec()
9393 if event:
507507 @defer.inlineCallbacks
508508 def on_GET(self, request, room_id, event_id):
509509 requester = yield self.auth.get_user_by_req(request)
510 event = yield self.event_handler.get_event(requester.user, event_id)
510 event = yield self.event_handler.get_event(requester.user, room_id, event_id)
511511
512512 time_now = self.clock.time_msec()
513513 if event:
342342 table="events",
343343 keyvalues={
344344 "event_id": event_id,
345 "room_id": room_id,
345346 },
346347 retcol="depth",
347348 allow_none=True,
1818
1919 from twisted.internet import defer
2020
21 from synapse.api.errors import SynapseError
21 from synapse.api.errors import NotFoundError
2222 # these are only included to make the type annotations work
2323 from synapse.events import EventBase # noqa: F401
2424 from synapse.events import FrozenEvent
7575 @defer.inlineCallbacks
7676 def get_event(self, event_id, check_redacted=True,
7777 get_prev_content=False, allow_rejected=False,
78 allow_none=False):
78 allow_none=False, check_room_id=None):
7979 """Get an event from the database by event_id.
8080
8181 Args:
8686 include the previous states content in the unsigned field.
8787 allow_rejected (bool): If True return rejected events.
8888 allow_none (bool): If True, return None if no event found, if
89 False throw an exception.
89 False throw a NotFoundError
90 check_room_id (str|None): if not None, check the room of the found event.
91 If there is a mismatch, behave as per allow_none.
9092
9193 Returns:
9294 Deferred : A FrozenEvent.
98100 allow_rejected=allow_rejected,
99101 )
100102
101 if not events and not allow_none:
102 raise SynapseError(404, "Could not find event %s" % (event_id,))
103
104 defer.returnValue(events[0] if events else None)
103 event = events[0] if events else None
104
105 if event is not None and check_room_id is not None:
106 if event.room_id != check_room_id:
107 event = None
108
109 if event is None and not allow_none:
110 raise NotFoundError("Could not find event %s" % (event_id,))
111
112 defer.returnValue(event)
105113
106114 @defer.inlineCallbacks
107115 def get_events(self, event_ids, check_redacted=True,