summary refs log tree commit diff
path: root/synapse/events/__init__.py (follow)
Commit message (Collapse)AuthorAgeFilesLines
* fix: Push notifications for invite over federation (#13719)Kateřina Churanová2022-09-281-0/+4
|
* Rename the `EventFormatVersions` enum values so that they line up with room ↵reivilibre2022-09-071-6/+6
| | | | version numbers. (#13706)
* Consolidate logic for parsing relations. (#12693)Patrick Cloke2022-05-161-0/+45
| | | | | | | | | | | | | Parse the `m.relates_to` event content field (which describes relations) in a single place, this is used during: * Event persistence. * Validation of the Client-Server API. * Fetching bundled aggregations. * Processing of push rules. Each of these separately implement the logic and each made slightly different assumptions about what was valid. Some had minor / potential bugs.
* fix importsRichard van der Hoff2022-05-031-1/+2
| | | broken in 5938928 :-S
* minor wording fix in docstringRichard van der Hoff2022-05-031-3/+2
|
* Exclude OOB memberships from the federation sender (#12570)Richard van der Hoff2022-05-031-4/+11
| | | | | | | As the comment says, there is no need to process such events, and indeed we need to avoid doing so. Fixes #12509.
* Add `FrozenEvent.get_state_key` and use it in a couple of places (#11793)Richard van der Hoff2022-01-211-4/+9
| | | | This is more efficient, since we only have to look up `state_key` in the event dict once, rather than three (!) times.
* Add remaining type hints to `synapse.events`. (#11098)Patrick Cloke2021-11-021-80/+147
|
* Include rejected status when we log events. (#11008)Richard van der Hoff2021-10-191-6/+10
| | | | | | If we find ourselves dealing with rejected events, we proably want to know about it. Let's include it in the stringification of the event so that it gets logged.
* Include outlier status in `str(event)` for V2/V3 events (#10879)Richard van der Hoff2021-09-221-22/+12
| | | | | | | | | | | | | | | | | | | | | I meant to do this before, in #10591, but because I'm stupid I forgot to do it for V2 and V3 events. I've factored the common code out to `EventBase` to save us having two copies of it. This means that for `FrozenEvent` we replace `self.get("event_id", None)` with `self.event_id`, which I think is safe. `get()` is an alias for `self._dict.get()`, whereas `event_id()` is an `@property` method which looks up `self._event_id`, which is populated during construction from the same dict. We don't seem to rely on the fallback, because if the `event_id` key is absent from the dict then construction of the `EventBase` object will fail. Long story short, the only way this could change behaviour is if `event_dict["event_id"]` is changed *after* the `EventBase` object is constructed without updating the `_event_id` field, or vice versa - either of which would be very problematic anyway and the behavior of `str(event)` is the least of our worries.
* Clean up some logging in the federation event handler (#10591)Richard van der Hoff2021-08-161-1/+2
| | | | | | | | | | | | | | | | | | | * Include outlier status in `str(event)` In places where we log event objects, knowing whether or not you're dealing with an outlier is super useful. * Remove duplicated logging in get_missing_events When we process events received from get_missing_events, we log them twice (once in `_get_missing_events_for_pdu`, and once in `on_receive_pdu`). Reduce the duplication by removing the logging in `on_receive_pdu`, and ensuring the call sites do sensible logging. * log in `on_receive_pdu` when we already have the event * Log which prev_events we are missing * changelog
* Do not include signatures/hashes in make_{join,leave,knock} responses. (#10404)Patrick Cloke2021-07-161-0/+14
| | | | These signatures would end up invalid since the joining/leaving/knocking server would modify the response before calling send_{join,leave,knock}.
* Use inline type hints in various other places (in `synapse/`) (#10380)Jonathan de Jong2021-07-151-13/+13
|
* Correct type hints for synapse.event_auth. (#10253)Patrick Cloke2021-06-301-1/+1
|
* Add endpoints for backfilling history (MSC2716) (#9247)Eric Eastwood2021-06-221-0/+9
| | | Work on https://github.com/matrix-org/matrix-doc/pull/2716
* Remove redundant "coding: utf-8" lines (#9786)Jonathan de Jong2021-04-141-1/+0
| | | | | | | Part of #9744 Removes all redundant `# -*- coding: utf-8 -*-` lines from files, as python 3 automatically reads source code as utf-8 now. `Signed-off-by: Jonathan de Jong <jonathan@automatia.nl>`
* Bugbear: Add Mutable Parameter fixes (#9682)Jonathan de Jong2021-04-081-4/+10
| | | | | | | Part of #9366 Adds in fixes for B006 and B008, both relating to mutable parameter lint errors. Signed-off-by: Jonathan de Jong <jonathan@automatia.nl>
* Prep work for removing `outlier` from `internal_metadata` (#9411)Richard van der Hoff2021-03-171-3/+6
| | | | | | | | | | | | * Populate `internal_metadata.outlier` based on `events` table Rather than relying on `outlier` being in the `internal_metadata` column, populate it based on the `events.outlier` column. * Move `outlier` out of InternalMetadata._dict Ultimately, this will allow us to stop writing it to the database. For now, we have to grandfather it back in so as to maintain compatibility with older versions of Synapse.
* Remote dependency on distutils (#9125)Richard van der Hoff2021-01-151-1/+2
| | | | | | | | | `distutils` is pretty much deprecated these days, and replaced with `setuptools`. It's also annoying because it's you can't `pip install` it, and it's hard to figure out which debian package we should depend on to make sure it's there. Since we only use it for a tiny function anyway, let's just vendor said function into our codebase.
* Use `%r` rather than `%s` for stringifying events (#8679)Richard van der Hoff2020-10-291-2/+2
| | | | otherwise non-state events get written as `<FrozenEvent ... state_key='None'>` which is indistinguishable from state events with the actual state_key `None`.
* Fix typos and spelling errors. (#8639)Patrick Cloke2020-10-231-1/+1
|
* guard against accidental modificationRichard van der Hoff2020-10-131-0/+6
|
* Remove stream ordering from Metadata dict (#8452)Richard van der Hoff2020-10-051-2/+4
| | | | | | | | There's no need for it to be in the dict as well as the events table. Instead, we store it in a separate attribute in the EventInternalMetadata object, and populate that on load. This means that we can rely on it being correctly populated for any event which has been persited to the database.
* Various clean ups to room stream tokens. (#8423)Erik Johnston2020-09-291-3/+3
|
* Stop sub-classing object (#8249)Patrick Cloke2020-09-041-1/+1
|
* Add StreamStore to mypy (#8232)Erik Johnston2020-09-021-2/+2
|
* Be more tolerant of membership events in unknown rooms (#8110)Richard van der Hoff2020-08-201-0/+2
| | | | It turns out that not all out-of-band membership events are labelled as such, so we need to be more accepting here.
* Replace iteritems/itervalues/iterkeys with native versions. (#7692)Patrick Cloke2020-06-151-3/+1
|
* Store room_versions in EventBase objects (#6875)Richard van der Hoff2020-03-051-14/+39
| | | | | | | This is a bit fiddly because it all has to be done on one fell swoop: * Wherever we create a new event, pass in the room version (and check it matches the format version) * When we prune an event, use the room version of the unpruned event to create the pruned version. * When we pass an event over the replication protocol, pass the room version over alongside it, and use it when deserialising the event again.
* Rewrite _EventInternalMetadata to back it with a _dictRichard van der Hoff2020-02-141-16/+39
| | | | Mostly, this gives mypy an easier time.
* Replace _event_dict_property with DictPropertyRichard van der Hoff2020-02-141-65/+79
| | | | | this amounts to the same thing, but replaces `_event_dict` with `_dict`, and removes some of the function layers generated by `property`.
* Add a `make_event_from_dict` method (#6858)Richard van der Hoff2020-02-071-2/+14
| | | | | | | ... and use it in places where it's trivial to do so. This will make it easier to pass room versions into the FrozenEvent constructors.
* remove unused room_version_to_event_format (#6857)Richard van der Hoff2020-02-071-23/+1
|
* Add typing to SyncHandler (#6821)Erik Johnston2020-02-031-7/+11
| | | | Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
* Type defintions for use in refactoring for redaction changes (#6803)Richard van der Hoff2020-01-301-2/+3
| | | | | | | | | | * Bump signedjson to 1.1 ... so that we can use the type definitions * Fix breakage caused by upgrade to signedjson 1.1 Thanks, @illicitonion...
* Make 'event.redacts' never raise. (#6771)Erik Johnston2020-01-231-4/+24
| | | | | | There are quite a few places that we assume that a redaction event has a corresponding `redacts` key, which is not always the case. So lets cheekily make it so that event.redacts just returns None instead.
* Remove the ability to query relations when the original event was redacted. ↵Andrew Morgan2019-07-181-0/+11
| | | | | | | (#5629) Fixes #5594 Forbid viewing relations on an event once it has been redacted.
* Run Black. (#5482)Amber Brown2019-06-201-17/+13
|
* Run as background process and fix commentsErik Johnston2019-06-191-1/+1
|
* Add experimental option to reduce extremities.Erik Johnston2019-06-181-0/+12
| | | | | | | Adds new config option `cleanup_extremities_with_dummy_events` which periodically sends dummy events to rooms with more than 10 extremities. THIS IS REALLY EXPERIMENTAL.
* Fix error handling for rooms whose versions are unknown. (#5219)Richard van der Hoff2019-05-211-2/+6
| | | | | | | If we remove support for a particular room version, we should behave more gracefully. This should make client requests fail with a 400 rather than a 500, and will ignore individiual PDUs in a federation transaction, rather than the whole transaction.
* Add a test room version which updates event ID format (#5210)Richard van der Hoff2019-05-201-1/+22
| | | Implements MSC1884
* Collect room-version variations into one place (#4969)Richard van der Hoff2019-04-011-10/+5
| | | | Collect all the things that make room-versions different to one another into one place, so that it's easier to define new room versions.
* Make `prev_state` field optionalErik Johnston2019-03-081-1/+0
| | | | | | | The `prev_state` field on events is not specced and so synapse shouldn't explode if an event is missing the field. Fixes #4787
* Implement soft failErik Johnston2019-03-061-0/+14
|
* Enable room version v3Erik Johnston2019-01-291-0/+2
|
* Fixup commentErik Johnston2019-01-291-2/+2
|
* kill vdh test some moreErik Johnston2019-01-291-2/+1
|
* Merge branch 'develop' of github.com:matrix-org/synapse into ↵Erik Johnston2019-01-291-16/+94
|\ | | | | | | erikj/redactions_eiah
| * Implement event format v2Erik Johnston2019-01-291-16/+94
| |
* | Add docstringErik Johnston2019-01-291-0/+12
| |
* | Implement rechecking of redactionsErik Johnston2019-01-291-0/+3
|/
* Require event format version to parse or create eventsErik Johnston2019-01-251-1/+23
|
* Merge branch 'develop' of github.com:matrix-org/synapse into erikj/msc_1813Erik Johnston2019-01-251-2/+7
|\
| * Merge pull request #4405 from matrix-org/erikj/fixup_rejecting_invitesErik Johnston2019-01-241-2/+7
| |\ | | | | | | Store rejected remote invite events as outliers
| | * Use term 'out of band membership' insteadErik Johnston2019-01-241-4/+5
| | |
| | * Clarify the invite flowsErik Johnston2019-01-231-2/+6
| | |
* | | Review commentsErik Johnston2019-01-241-1/+2
| | |
* | | Implement MSC 1813 - Add room version to make APIsErik Johnston2019-01-231-1/+16
|/ / | | | | | | | | We also implement `make_membership_event` converting the returned room version to an event format version.
* | isortErik Johnston2019-01-231-3/+1
| |
* | Add support for persisting event format versionsErik Johnston2019-01-231-0/+5
|/ | | | | | | | | | | | | | Currently we only have the one event format version defined, but this adds the necessary infrastructure to persist and fetch the format versions alongside the events. We specify the format version rather than the room version as: 1. We don't necessarily know the room version, existing events may be either v1 or v2. 2. We'd need to be careful to prevent/handle correctly if different events in the same room reported to be of different versions, which sounds annoying.
* Add helpers for getting prev and auth events (#4139)Erik Johnston2018-11-061-0/+18
| | | | | | | * Add helpers for getting prev and auth events This is in preparation for allowing the event format to change between room versions.
* Disable frozen dicts by default (#3987)Amber Brown2018-10-021-3/+10
|
* Fix handling of redacted events from federationErik Johnston2018-09-131-0/+5
| | | | | | | | | | If we receive an event that doesn't pass their content hash check (e.g. due to already being redacted) then we hit a bug which causes an exception to be raised, which then promplty stops the event (and request) from being processed. This effects all sorts of federation APIs, including joining rooms with a redacted state event.
* run isortAmber Brown2018-07-091-2/+1
|
* Consistently use six's iteritems and wrap lazy keys/values in list() if ↵Amber Brown2018-05-311-1/+1
| | | | they're not meant to be lazy (#3307)
* add comment explaining attributeerrorAdrian Tschira2018-04-301-0/+3
|
* Make event properties raise AttributeError insteadAdrian Tschira2018-04-151-3/+12
| | | | | | | | | | | | | They raised KeyError before. I'm changing this because the code uses hasattr() to check for the presence of a key. This worked accidentally before, because hasattr() silences all exceptions in python 2. However, in python3, this isn't the case anymore. I had a look around to see if anything depended on this raising a KeyError and I couldn't find anything. Of course, I could have simply missed it. Signed-off-by: Adrian Tschira <nota@notafile.com>
* Optimise state resolutionErik Johnston2017-01-171-3/+5
|
* gah, fix mangled merge of 0.18.7 into developMatthew Hodgson2017-01-071-1/+1
|
* Only send events that originate on this server.Mark Haines2017-01-051-0/+9
| | | | | | Or events that are sent via the federation "send_join" API. This should match the behaviour from before v0.18.5 and #1635 landed.
* Make None optionalErik Johnston2016-08-261-1/+1
|
* Remove the is_new_state argument to persist event.Mark Haines2016-03-311-0/+3
| | | | | | | | | Move the checks for whether an event is new state inside persist event itself. This was harder than expected because there wasn't enough information passed to persist event to correctly handle invites from remote servers for new rooms.
* Use a stream id generator to assign state group idsMark Haines2016-03-301-1/+1
|
* Intern all the thingsErik Johnston2016-03-231-9/+2
|
* Intern sender, event_id and room_id in eventsErik Johnston2016-03-231-0/+5
|
* Intern type and state_key on eventsErik Johnston2016-03-231-0/+7
|
* Don't assume existence of event_id in __str__Erik Johnston2016-03-181-1/+3
|
* Make Event objects behave more like dictsErik Johnston2016-01-181-0/+9
|
* copyrightsMatthew Hodgson2016-01-071-1/+1
|
* Fix bug where we didn't correctly serialize the redacted_because key over ↵Erik Johnston2015-08-211-1/+4
| | | | federation
* Don't copy twiceErik Johnston2015-05-291-1/+1
|
* Add config option to turn off freezing events. Use new encode_json api and ↵Erik Johnston2015-05-291-1/+10
| | | | ujson.loads
* Store the rejected reason in (Frozen)Event structsPaul "LeoNerd" Evans2015-03-251-2/+4
|
* pyflakesErik Johnston2015-02-111-1/+1
|
* Don't unfreeze when using FreezeEvent.get_dict, as we are using a ↵Erik Johnston2015-02-111-4/+0
| | | | JSONEncoder that understands FrozenDict
* Rearrange persist_event so that do all the queries that need to be done ↵Erik Johnston2015-02-041-1/+1
| | | | before returning early if we have already persisted that event.
* Fix bug where we changes in outlier in metadata dict propogated to other eventsErik Johnston2015-01-301-1/+1
|
* Remove unused importErik Johnston2015-01-071-2/+0
|
* Optimize FrozenEvent creationErik Johnston2015-01-061-7/+13
|
* Update copyright noticesMark Haines2015-01-061-1/+1
|
* clean up coding style a bitMark Haines2014-12-161-11/+11
|
* Persist internal_metadataErik Johnston2014-12-161-2/+3
|
* Fix pyflakesErik Johnston2014-12-151-2/+0
|
* Use frozenutilsErik Johnston2014-12-151-32/+4
|
* Finish up upgrade scriptErik Johnston2014-12-151-1/+1
|
* Fix redactions. Fix 'age' keyErik Johnston2014-12-111-0/+1
|
* Actually fix bug when uploading state with empty state_keyErik Johnston2014-12-101-0/+1
|
* Fix bug when uploading state with empty state_keyErik Johnston2014-12-101-2/+8
|
* Fix AttributeErrorErik Johnston2014-12-101-0/+3
|
* Add __str__ to FrozenEventErik Johnston2014-12-101-0/+5
|
* Try and figure out how and why signatures are being changed.Erik Johnston2014-12-101-8/+10
|
* More bug fixesErik Johnston2014-12-081-8/+1
|
* Start making more things use EventContext rather than event.*Erik Johnston2014-12-051-2/+33
|
* Convert rest and handlers to use new event structureErik Johnston2014-12-041-4/+4
|
* Begin converting things to use the new Event structureErik Johnston2014-12-041-0/+3
|
* WIP for new way of managing events.Erik Johnston2014-12-031-64/+77
|
* Begin fleshing out a new Event objectErik Johnston2014-12-021-0/+120