summary refs log tree commit diff
path: root/tests/handlers/test_presence.py (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Return an immutable value from get_latest_event_ids_in_room. (#16326)Patrick Cloke2023-09-181-1/+1
|
* Time out busy presence status & test multi-device busy (#16174)Patrick Cloke2023-09-051-3/+101
| | | | | | | Add a (long) timeout to when a "busy" device is considered not online. This does *not* match MSC3026, but is a reasonable thing for an implementation to do. Expands tests for the (unstable) busy presence with multiple devices.
* Track presence state per-device and combine to a user state. (#16066)Patrick Cloke2023-09-051-10/+490
| | | | | | | | | | | Tracks presence on an individual per-device basis and combine the per-device state into a per-user state. This should help in situations where a user has multiple devices with conflicting status (e.g. one is syncing with unavailable and one is syncing with online). The tie-breaking is done by priority: BUSY > ONLINE > UNAVAILABLE > OFFLINE
* Don't wake up destination transaction queue if they're not due for retry. ↵Erik Johnston2023-09-041-12/+48
| | | | (#16223)
* Pass the device ID around in the presence handler (#16171)Patrick Cloke2023-08-281-11/+27
| | | | | | Refactoring to pass the device ID (in addition to the user ID) through the presence handler (specifically the `user_syncing`, `set_state`, and `bump_presence_active_time` methods and their replication versions).
* Combine logic about not overriding BUSY presence. (#16170)Patrick Cloke2023-08-281-7/+30
| | | | | | | | | | | | | Simplify some of the presence code by reducing duplicated code between worker & non-worker modes. The main change is to push some of the logic from `user_syncing` into `set_state`. This is done by passing whether the user is setting the presence via a `/sync` with a new `is_sync` flag to `set_state`. If this is `true` some additional logic is performed: * Don't override `busy` presence. * Update the `last_user_sync_ts`. * Never update the status message.
* Add tests for restoring the presence state after a restart. (#16151)Patrick Cloke2023-08-231-0/+116
|
* Clean-up presence tests (#16158)Patrick Cloke2023-08-221-92/+37
| | | Reduce duplicated code & remove unused variables.
* Re-introduce the outbound federation proxy (#15913)Eric Eastwood2023-07-181-1/+0
| | | | | Allow configuring the set of workers to proxy outbound federation traffic through (`outbound_federation_restricted_to`). This is useful when you have a worker setup with `federation_sender` instances responsible for sending outbound federation requests and want to make sure *all* outbound federation traffic goes through those instances. Before this change, the generic workers would still contact federation themselves for things like profile lookups, backfill, etc. This PR allows you to set more strict access controls/firewall for all workers and only allow the `federation_sender`'s to contact the outside world.
* Revert "Federation outbound proxy" (#15910)Eric Eastwood2023-07-101-0/+1
| | | | | | Revert "Federation outbound proxy (#15773)" This reverts commit b07b14b494ae1dd564b4c44f844c9a9545b3d08a.
* Federation outbound proxy (#15773)Eric Eastwood2023-07-051-1/+0
| | | | | | | Allow configuring the set of workers to proxy outbound federation traffic through (`outbound_federation_restricted_to`). This is useful when you have a worker setup with `federation_sender` instances responsible for sending outbound federation requests and want to make sure *all* outbound federation traffic goes through those instances. Before this change, the generic workers would still contact federation themselves for things like profile lookups, backfill, etc. This PR allows you to set more strict access controls/firewall for all workers and only allow the `federation_sender`'s to contact the outside world. The original code is from @erikjohnston's branches which I've gotten in-shape to merge.
* Add missing type hints to tests.handlers. (#14680)Patrick Cloke2022-12-161-46/+54
| | | And do not allow untyped defs in tests.handlers.
* Modernize unit tests configuration settings for workers. (#14568)realtyem2022-12-011-1/+2
| | | | Use the newer foo_instances configuration instead of the deprecated flags to enable specific features (e.g. start_pushers).
* Fix an invalid comparison of `UserPresenceState` to `str` (#14393)Andrew Morgan2022-11-161-6/+35
|
* Prevent a sync request from removing a user's busy presence status (#12213)David Baker2022-04-131-0/+79
| | | | | | | | | | In trying to use the MSC3026 busy presence status, the user's status would be set back to 'online' next time they synced. This change makes it so that syncing does not affect a user's presence status if it is currently set to 'busy': it must be removed through the presence API. The MSC defers to implementations on the behaviour of busy presence, so this ought to remain compatible with the MSC.
* Add type hints to more tests files. (#12240)Dirk Klimpel2022-03-171-4/+9
|
* Replace assertEquals and friends with non-deprecated versions. (#12092)Patrick Cloke2022-02-281-39/+39
|
* Remove `HomeServer.get_datastore()` (#12031)Richard van der Hoff2022-02-231-2/+2
| | | | | | | The presence of this method was confusing, and mostly present for backwards compatibility. Let's get rid of it. Part of #11733
* Split `FederationHandler` in half (#10692)Richard van der Hoff2021-08-261-2/+2
| | | The idea here is to take anything to do with incoming events and move it out to a separate handler, as a way of making FederationHandler smaller.
* Flatten the synapse.rest.client package (#10600)reivilibre2021-08-171-1/+1
|
* Do not remove `status_msg` when user going offline (#10550)Dirk Klimpel2021-08-091-2/+161
| | | Signed-off-by: Dirk Klimpel dirk@klimpel.org
* Move methods involving event authentication to EventAuthHandler. (#10268)Patrick Cloke2021-07-011-2/+2
| | | Instead of mixing them with user authentication methods.
* Add endpoints for backfilling history (MSC2716) (#9247)Eric Eastwood2021-06-221-1/+3
| | | Work on https://github.com/matrix-org/matrix-doc/pull/2716
* Add a test for update_presence (#10033)Andrew Morgan2021-05-211-1/+46
| | | | | | | https://github.com/matrix-org/synapse/issues/9962 uncovered that we accidentally removed all but one of the presence updates that we store in the database when persisting multiple updates. This could cause users' presence state to be stale. The bug was fixed in #10014, and this PR just adds a test that failed on the old code, and was used to initially verify the bug. The test attempts to insert some presence into the database in a batch using `PresenceStore.update_presence`, and then simply pulls it out again.
* Increase perf of handling presence when joining large rooms. (#9916)Erik Johnston2021-05-051-10/+4
|
* Fix tight loop handling presence replication. (#9900)Erik Johnston2021-04-281-0/+22
| | | | | Only affects workers. Introduced in #9819. Fixes #9899.
* Add presence federation stream (#9819)Erik Johnston2021-04-201-8/+171
|
* 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>`
* Use mock from the stdlib. (#9772)Patrick Cloke2021-04-091-1/+1
|
* Implement MSC3026: busy presence stateBrendan Abolivier2021-03-181-0/+20
|
* Be smarter about which hosts to send presence to when processing room joins ↵Andrew Morgan2021-02-191-4/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | (#9402) This PR attempts to eliminate unnecessary presence sending work when your local server joins a room, or when a remote server joins a room your server is participating in by processing state deltas in chunks rather than individually. --- When your server joins a room for the first time, it requests the historical state as well. This chunk of new state is passed to the presence handler which, after filtering that state down to only membership joins, will send presence updates to homeservers for each join processed. It turns out that we were being a bit naive and processing each event individually, and sending out presence updates for every one of those joins. Even if many different joins were users on the same server (hello IRC bridges), we'd send presence to that same homeserver for every remote user join we saw. This PR attempts to deduplicate all of that by processing the entire batch of state deltas at once, instead of only doing each join individually. We process the joins and note down which servers need which presence: * If it was a local user join, send that user's latest presence to all servers in the room * If it was a remote user join, send the presence for all local users in the room to that homeserver We deduplicate by inserting all of those pending updates into a dictionary of the form: ``` { server_name1: {presence_update1, ...}, server_name2: {presence_update1, presence_update2, ...} } ``` Only after building this dict do we then start sending out presence updates.
* Update black, and run auto formatting over the codebase (#9381)Eric Eastwood2021-02-161-2/+1
| | | | | | | - Update black version to the latest - Run black auto formatting over the codebase - Run autoformatting according to [`docs/code_style.md `](https://github.com/matrix-org/synapse/blob/80d6dc9783aa80886a133756028984dbf8920168/docs/code_style.md) - Update `code_style.md` docs around installing black to use the correct version
* Apply an IP range blacklist to push and key revocation requests. (#8821)Patrick Cloke2020-12-021-1/+1
| | | | | | | | | | | | Replaces the `federation_ip_range_blacklist` configuration setting with an `ip_range_blacklist` setting with wider scope. It now applies to: * Federation * Identity servers * Push notifications * Checking key validitity for third-party invite events The old `federation_ip_range_blacklist` setting is still honored if present, but with reduced scope (it only applies to federation and identity servers).
* Simplify `_locally_reject_invite`Richard van der Hoff2020-10-131-1/+1
| | | | | Update `EventCreationHandler.create_event` to accept an auth_events param, and use it in `_locally_reject_invite` instead of reinventing the wheel.
* Remove the deprecated Handlers object (#8494)Patrick Cloke2020-10-091-1/+1
| | | All handlers now available via get_*_handler() methods on the HomeServer.
* Convert stream database to async/await. (#8074)Patrick Cloke2020-08-171-1/+1
|
* Port PresenceHandler to async/await (#6991)Erik Johnston2020-02-261-6/+12
|
* Clarify list/set/dict/tuple comprehensions and enforce via flake8 (#6957)Patrick Cloke2020-02-211-2/+2
| | | | Ensure good comprehension hygiene using flake8-comprehensions.
* Merge pull request #6806 from matrix-org/rav/redact_changes/3Richard van der Hoff2020-01-311-2/+2
|\ | | | | Pass room_version into add_hashes_and_signatures
| * Store the room version in EventBuilderRichard van der Hoff2020-01-301-2/+2
| |
* | s/get_room_version/get_room_version_id/Richard van der Hoff2020-01-311-1/+1
|/ | | | | ... to make way for a forthcoming get_room_version which returns a RoomVersion object.
* Fix presence timeouts when synchrotron restarts. (#6212)Erik Johnston2019-10-181-0/+39
| | | | | | | | | * Fix presence timeouts when synchrotron restarts. Handling timeouts would fail if there was an external process that had timed out, e.g. a synchrotron restarting. This was due to a couple of variable name typoes. Fixes #3715.
* Run Black on the tests again (#5170)Amber Brown2019-05-101-8/+6
|
* Review commentsErik Johnston2019-03-281-5/+9
|
* Add unit testsErik Johnston2019-03-271-1/+171
|
* Run black.black2018-08-101-121/+95
|
* run isortAmber Brown2018-07-091-4/+8
|
* Modify test_user_sync so it doesn't look at last_active_ts over ↵Will Hunt2017-03-151-1/+1
| | | | last_user_sync_ts
* Don't notify for online -> online transitions.Erik Johnston2016-08-301-0/+47
| | | | | Specifically, if currently_active remains true then we should not notify if only the last active time changes.
* Allow external processes to mark a user as syncing. (#812)Mark Haines2016-06-021-9/+7
| | | | | | | | | | | | * Add infrastructure to the presence handler to track sync requests in external processes * Expire stale entries for dead external processes * Add an http endpoint for making users as syncing Add some docstrings and comments. * Fixes
* Don't set currently_active for remote presenceErik Johnston2016-02-191-4/+15
|
* Add unit testErik Johnston2016-02-181-0/+373
|
* Remove old tests.Erik Johnston2016-02-181-1340/+0
|
* Delete the table objects from TransactionStoreMark Haines2016-01-131-1/+0
|
* copyrightsMatthew Hodgson2016-01-071-1/+1
|
* rename the method in the tests as wellMark Haines2015-12-011-3/+3
|
* Update testsErik Johnston2015-11-171-0/+13
|
* Open up /events to anonymous users for room events onlyDaniel Wagner-Hall2015-11-051-18/+53
| | | | Squash-merge of PR #345 from daniel/anonymousevents
* Fix the presence testsMark Haines2015-05-221-6/+10
|
* Fix the presence testsMark Haines2015-05-201-10/+3
|
* Remove unused arguments and doc PresenceHandler.push_update_to_clientsMark Haines2015-05-141-17/+5
|
* Merge branch 'develop' of github.com:matrix-org/synapse into postgresErik Johnston2015-04-271-0/+65
|\
| * Remove users from the remote_offline_serials list (and clean up empty ↵Paul "LeoNerd" Evans2015-04-231-0/+27
| | | | | | | | elements) when they go online again
| * Store a list of the presence serial number at which remote users went ↵Paul "LeoNerd" Evans2015-04-231-0/+38
| | | | | | | | offline, so that when we delete them from the cachemap, we can still synthesize OFFLINE events for them (SYN-261)
* | Make work in both Maria and SQLite. Fix testsErik Johnston2015-04-011-1/+6
|/
* Fix testsErik Johnston2015-03-091-2/+2
|
* Fix presence testsErik Johnston2015-02-231-15/+28
|
* Factor out some of the common homeserver setup code into aMark Haines2015-02-111-14/+2
| | | | setup_test_homeserver function in utils.
* Replace hs.parse_userid with UserID.from_stringMark Haines2015-01-231-14/+15
|
* Rename MockedDatastoreTestCase to MockedDatastorePresenceTestCase since it ↵Paul "LeoNerd" Evans2015-01-221-3/+3
| | | | is still presence-specific
* Much merging of test case setUp() methods to make them much morePaul "LeoNerd" Evans2015-01-221-273/+193
| | | | shareable
* Abstract out the room ID from presence tests, so it's stored in selfPaul "LeoNerd" Evans2015-01-211-8/+10
|
* Use common base class for two Presence unit-tests, avoiding boilerplate ↵Paul "LeoNerd" Evans2015-01-211-54/+25
| | | | copypasta
* fix UTs by telling all the mock stores about the new methods for tracking ↵Matthew Hodgson2014-12-091-1/+9
| | | | retries
* Initialise UserPresenceCache instances to always contain a 'presence' keyPaul "LeoNerd" Evans2014-11-191-2/+8
|
* SYN-103: Remove "origin" and "destination" keys from edusMark Haines2014-11-131-3/+0
|
* Fix presence testErik Johnston2014-11-051-0/+1
|
* Fix an off-by-one bug in presence event stream pagination; this might be ↵Paul "LeoNerd" Evans2014-10-291-0/+16
| | | | responsible for any number of bug reports
* SPEC-7: Rename 'ts' to 'origin_server_ts'Mark Haines2014-10-171-1/+1
|
* SYN-103: Ignore the 'origin' key in received EDUs. Instead take the origin ↵Mark Haines2014-10-141-0/+1
| | | | from the transaction itself
* SYN-75 sign at the request level rather than the transaction levelMark Haines2014-10-131-13/+13
|
* SYN-75 Verify signatures on server to server transactionsMark Haines2014-09-301-3/+6
|
* Sign federation transactionsMark Haines2014-09-241-2/+19
|
* Merge branch 'develop' into test-sqlite-memoryPaul "LeoNerd" Evans2014-09-171-5/+18
|\
| * Fix unit tests after adding extra argument on put_jsonErik Johnston2014-09-151-5/+18
| |
* | Merge remote-tracking branch 'origin/develop' into test-sqlite-memoryPaul "LeoNerd" Evans2014-09-151-6/+1
|\|
| * Have all unit tests import from our own subclass of trial's unittest ↵Paul "LeoNerd" Evans2014-09-121-6/+1
| | | | | | | | TestCase; set up logging in ONE PLACE ONLY
* | Perform PresenceInvitesTestCase against real SQLiteMemoryDbPoolPaul "LeoNerd" Evans2014-09-111-78/+98
| |
* | Need to prepare() the SQLiteMemoryDbPool before passing it to HomeServer ↵Paul "LeoNerd" Evans2014-09-111-3/+4
| | | | | | | | constructor, as DataStore's constructor will want it ready
* | Start of converting PresenceHandler unit tests to use SQLiteMemoryDbPool - ↵Paul "LeoNerd" Evans2014-09-111-46/+27
|/ | | | just the 'State' test case for now
* fix the copyright holder from matrix.org to OpenMarket Ltd, as matrix.org ↵Matthew Hodgson2014-09-031-1/+1
| | | | hasn't been incorporated in time for launch.
* Kill the statePaul "LeoNerd" Evans2014-09-031-33/+17
| | | | ... key from all the Presence messages
* Implement presence state visibilty limiting when polling eventsource for streamPaul "LeoNerd" Evans2014-09-031-1/+67
|
* Don't eat federation transmit errors during unit tests; fix remote presence ↵Paul "LeoNerd" Evans2014-09-031-0/+16
| | | | EDU-sending test because of this
* Rename the 'do_users_share_a_room' to something slightly less verb-soundingPaul "LeoNerd" Evans2014-09-031-2/+2
|
* Ensure that event source unit tests could cope with ↵Paul "LeoNerd" Evans2014-09-021-14/+20
| | | | get_new_events_for_user() returning a Deferred
* Reënable presence visibility permission checking now it's not used on ↵Paul "LeoNerd" Evans2014-09-011-2/+0
| | | | redundant code paths
* Rename API-visible 'mtime' presence field to 'last_active'; slightly ↵Paul "LeoNerd" Evans2014-09-011-11/+18
| | | | different semantics
* Rename 'state' presence key to the much more obvious 'presence'; maintain a ↵Paul "LeoNerd" Evans2014-09-011-43/+79
| | | | legacy 'state' copy for now
* change the world: make the default matrix API URL prefix /_matrix rather ↵Matthew Hodgson2014-08-311-12/+12
| | | | | | than /matrix to make it easier for existing websites to mount a HS in their namespace without collisions. perl -pi -e 's#/matrix#/_matrix#g' ./cmdclient/console.py ./docs/client-server/howto.rst ./docs/client-server/specification.rst ./docs/client-server/swagger_matrix/directory ./docs/client-server/swagger_matrix/events ./docs/client-server/swagger_matrix/login ./docs/client-server/swagger_matrix/presence ./docs/client-server/swagger_matrix/profile ./docs/client-server/swagger_matrix/registration ./docs/client-server/swagger_matrix/rooms ./docs/server-server/specification.rst ./graph/graph.py ./jsfiddles/create_room_send_msg/demo.js ./jsfiddles/event_stream/demo.js ./jsfiddles/example_app/demo.js ./jsfiddles/register_login/demo.js ./jsfiddles/room_memberships/demo.js ./synapse/api/urls.py ./tests/federation/test_federation.py ./tests/handlers/test_presence.py ./tests/handlers/test_typing.py ./tests/rest/test_events.py ./tests/rest/test_presence.py ./tests/rest/test_profile.py ./tests/rest/test_rooms.py ./webclient/components/fileUpload/file-upload-service.js ./webclient/components/matrix/matrix-service.js
* Bugfixes on presence pushes on user joining:Paul "LeoNerd" Evans2014-08-291-57/+71
| | | | | | | | | * No need to inform clients of status of remote users; as that will arrive in due course anyway. We don't -have- the state currently, so we'd only send an unknown message * Remember to bump the presence serial for the event source, so the notifiers will wake up and report it
* Fix a couple of bugs in presence handler related to pushing updatesto the ↵Erik Johnston2014-08-291-51/+87
| | | | correct user. Fix presence tests.
* Only send presence "poll"/"unpoll" EDUs when changing from/to zero remotesPaul "LeoNerd" Evans2014-08-281-6/+33
|
* Re-enable presence, un-skip presence testsPaul "LeoNerd" Evans2014-08-281-6/+0
|
* Fix up the various presence-related tests so that if they're not skipped, ↵Paul "LeoNerd" Evans2014-08-271-4/+6
| | | | they still PASS
* skip presence tests which broke when presence polling was disabledMark Haines2014-08-221-0/+7
|
* Rewrite of PresenceHandler test to ensure it covers the interaction with ↵Paul "LeoNerd" Evans2014-08-191-149/+279
| | | | Federation as well
* Implement and test presence dropping of remote usersPaul "LeoNerd" Evans2014-08-191-0/+8
|
* Allow room presence visibility between users who share a roomPaul "LeoNerd" Evans2014-08-181-5/+40
|
* Removed http_server from HomeServer. Updated unit tests to use either ↵Kegan Dougal2014-08-141-4/+4
| | | | resource_for_federation or resource_for_client depending on what is being tested.
* An initial hack at storing presence state-change mtimes in database and ↵Paul "LeoNerd" Evans2014-08-131-8/+28
| | | | presenting age durations to clients/federation events
* Use strings instead of opaque magic-number constants for presence states; ↵Paul "LeoNerd" Evans2014-08-131-12/+12
| | | | rename AWAY to UNAVAILABLE
* add in copyrights to everything, not just the synapse subdir, and add a ↵Matthew Hodgson2014-08-131-0/+14
| | | | copyrighter.pl whilst we're at it
* Reference Matrix Home Servermatrix.org2014-08-121-0/+884