summary refs log tree commit diff
path: root/synapse/module_api (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Add a `cached` helper to the module API (#14663)Brendan Abolivier2022-12-281-1/+39
|
* Move `StateFilter` to `synapse.types` (#14668)David Robertson2022-12-121-1/+1
| | | | | * Move `StateFilter` to `synapse.types` * Changelog
* Add a type hint for `get_device_handler()` and fix incorrect types. (#14055)Patrick Cloke2022-11-221-1/+9
| | | | | This was the last untyped handler from the HomeServer object. Since it was being treated as Any (and thus unchecked) it was being used incorrectly in a few places.
* Remove redundant types from comments. (#14412)Patrick Cloke2022-11-161-4/+3
| | | | | | | Remove type hints from comments which have been added as Python type hints. This helps avoid drift between comments and reality, as well as removing redundant information. Also adds some missing type hints which were simple to fill in.
* Save login tokens in database (#13844)Quentin Gliech2022-10-261-40/+1
| | | | | | | | | | | * Save login tokens in database Signed-off-by: Quentin Gliech <quenting@element.io> * Add upgrade notes * Track login token reuse in a Prometheus metric Signed-off-by: Quentin Gliech <quenting@element.io>
* Deprecate the `generate_short_term_login_token` method in favor of an async ↵Quentin Gliech2022-10-061-0/+42
| | | | | | `create_login_token` method in the Module API. (#13842) Signed-off-by: Quentin Gliech <quenting@element.io> Co-authored-by: Brendan Abolivier <babolivier@matrix.org>
* Add missing version information in the ModuleApi (#13947)Brendan Abolivier2022-09-301-0/+4
|
* Add cache invalidation across workers to module API (#13667)Mathieu Velten2022-09-211-1/+32
| | | Signed-off-by: Mathieu Velten <mathieuv@matrix.org>
* Remove the `complete_sso_login` method from the Module API which was ↵Quentin Gliech2022-09-201-25/+0
| | | | | deprecated in Synapse 1.13.0. (#13843) Signed-off-by: Quentin Gliech <quenting@element.io>
* Update module API "update room membership" method to allow for remote joins ↵Matt C2022-08-051-4/+4
| | | | | | (#13441) Co-authored-by: MattC <buffless-matt@users.noreply.github.com> Co-authored-by: Brendan Abolivier <babolivier@matrix.org>
* Add module API method to create a room (#13429)Matt C2022-08-041-0/+51
| | | | Co-authored-by: MattC <buffless-matt@users.noreply.github.com> Co-authored-by: Brendan Abolivier <babolivier@matrix.org>
* Add module API method to resolve a room alias to a room ID (#13428)Matt C2022-08-031-0/+24
| | | | Co-authored-by: MattC <buffless-matt@users.noreply.github.com> Co-authored-by: Brendan Abolivier <babolivier@matrix.org>
* Uniformize spam-checker API, part 5: expand other spam-checker callbacks to ↵David Teller2022-07-111-0/+1
| | | | | | return `Tuple[Codes, dict]` (#13044) Signed-off-by: David Teller <davidt@element.io> Co-authored-by: Brendan Abolivier <babolivier@matrix.org>
* Uniformize spam-checker API, part 4: port other spam-checker callbacks to ↵David Teller2022-06-131-0/+2
| | | | | return `Union[Allow, Codes]`. (#12857) Co-authored-by: Brendan Abolivier <babolivier@matrix.org>
* Consolidate the logic of delete_device/delete_devices. (#12970)Patrick Cloke2022-06-071-1/+1
| | | | | | | | By always using delete_devices and sometimes passing a list with a single device ID. Previously these methods had gotten out of sync with each other and it seems there's little benefit to the single-device variant.
* Wait for lazy join to complete when getting current state (#12872)Erik Johnston2022-06-011-11/+8
|
* Merge branch 'master' into developErik Johnston2022-05-311-5/+3
|\
| * Fix import in module_api module and docs on the new check_event_for_spam ↵Brendan Abolivier2022-05-311-5/+3
| | | | | | | | | | signature (#12918) Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
* | Document the Synapse version of a new module API method (#12917)Brendan Abolivier2022-05-301-1/+6
| |
* | Add storage and module API methods to get monthly active users and their ↵Matt C2022-05-271-0/+20
|/ | | | appservices (#12838)
* Uniformize spam-checker API, part 2: check_event_for_spam (#12808)David Teller2022-05-232-0/+7
| | | Signed-off-by: David Teller <davidt@element.io>
* add SpamChecker callback for silently dropping inbound federated events (#12744)Jess Porter2022-05-231-0/+5
| | | Signed-off-by: jesopo <github@lolnerd.net>
* Use `ParamSpec` in a few places (#12667)David Robertson2022-05-091-7/+10
|
* Add a module API to allow modules to edit push rule actions (#12406)Brendan Abolivier2022-04-272-0/+68
| | | Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
* Remove unused `# type: ignore`s (#12531)David Robertson2022-04-271-1/+3
| | | | | | | | | | | | | | | | | | | | | | Over time we've begun to use newer versions of mypy, typeshed, stub packages---and of course we've improved our own annotations. This makes some type ignore comments no longer necessary. I have removed them. There was one exception: a module that imports `select.epoll`. The ignore is redundant on Linux, but I've kept it ignored for those of us who work on the source tree using not-Linux. (#11771) I'm more interested in the config line which enforces this. I want unused ignores to be reported, because I think it's useful feedback when annotating to know when you've fixed a problem you had to previously ignore. * Installing extras before typechecking Lacking an easy way to install all extras generically, let's bite the bullet and make install the hand-maintained `all` extra before typechecking. Now that https://github.com/matrix-org/backend-meta/pull/6 is merged to the release/v1 branch.
* Add Module API for reading and writing global account data. (#12391)reivilibre2022-04-111-0/+76
|
* Add a module callback to react to account data changes (#12327)Brendan Abolivier2022-04-011-0/+15
| | | | Co-authored-by: Sean Quah <8349537+squahtx@users.noreply.github.com> Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com>
* Add set_user_admin function to the module API (#12341)Amanda Graven2022-04-011-0/+11
|
* Add a callback to react to 3PID associations (#12302)Brendan Abolivier2022-03-311-0/+3
|
* Allow modules to store already existing 3PID associations (#12195)Brendan Abolivier2022-03-281-1/+26
|
* Allow registering admin users using the module API (#12250)Nicolas Werner2022-03-231-0/+4
| | | Signed-off-by: Nicolas Werner <n.werner@famedly.com>
* Correct `check_username_for_spam` annotations and docs (#12246)David Robertson2022-03-181-0/+2
| | | | | | | * Formally type the UserProfile in user searches * export UserProfile in synapse.module_api * Update docs Co-authored-by: Sean Quah <8349537+squahtx@users.noreply.github.com>
* Add third_party module callbacks to check if a user can delete a room and ↵Will Hunt2022-03-091-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | deactivate a user (#12028) * Add check_can_deactivate_user * Add check_can_shutdown_rooms * Documentation * callbacks, not functions * Various suggested tweaks * Add tests for test_check_can_shutdown_room and test_check_can_deactivate_user * Update check_can_deactivate_user to not take a Requester * Fix check_can_shutdown_room docs * Renegade and use `by_admin` instead of `admin_user_id` * fix lint * Update docs/modules/third_party_rules_callbacks.md Co-authored-by: Brendan Abolivier <babolivier@matrix.org> * Update docs/modules/third_party_rules_callbacks.md Co-authored-by: Brendan Abolivier <babolivier@matrix.org> * Update docs/modules/third_party_rules_callbacks.md Co-authored-by: Brendan Abolivier <babolivier@matrix.org> * Update docs/modules/third_party_rules_callbacks.md Co-authored-by: Brendan Abolivier <babolivier@matrix.org> Co-authored-by: Brendan Abolivier <babolivier@matrix.org>
* Correctly register deactivation and profile update module callbacks (#12141)Brendan Abolivier2022-03-031-0/+8
|
* Add module callbacks called for reacting to deactivation status change and ↵Brendan Abolivier2022-03-011-0/+1
| | | | profile update (#12062)
* Remove `HomeServer.get_datastore()` (#12031)Richard van der Hoff2022-02-231-3/+5
| | | | | | | The presence of this method was confusing, and mostly present for backwards compatibility. Let's get rid of it. Part of #11733
* Document why auth providers aren't validated in the admin API. (#12004)Patrick Cloke2022-02-181-1/+5
| | | | Since it is reasonable to give a future or past auth provider, which might not be in the current configuration.
* Allow modules to set a display name on registration (#12009)Brendan Abolivier2022-02-171-0/+5
| | | Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com>
* Require that modules register their callbacks using keyword arguments. (#11975)Patrick Cloke2022-02-141-0/+6
| | | | To allow for easier backwards/forwards compatibility by making it easier to add/remove callbacks.
* Remove deprecated user_may_create_room_with_invites callback (#11950)Brendan Abolivier2022-02-111-5/+0
| | | Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com>
* Add a callback to allow modules to deny 3PID (#11854)Brendan Abolivier2022-02-081-0/+3
| | | | | Part of the Tchap Synapse mainlining. This allows modules to implement extra logic to figure out whether a given 3PID can be added to the local homeserver. In the Tchap use case, this will allow a Synapse module to interface with the custom endpoint /internal_info.
* Allow modules to retrieve server and worker names (#11868)Brendan Abolivier2022-02-011-0/+26
| | | Fixes #10701
* Add a module callback to set username at registration (#11790)Brendan Abolivier2022-01-261-0/+22
| | | | | | This is in the context of mainlining the Tchap fork of Synapse. Currently in Tchap usernames are derived from the user's email address (extracted from the UIA results, more specifically the m.login.email.identity step). This change also exports the check_username method from the registration handler as part of the module API, so that a module can check if the username it's trying to generate is correct and doesn't conflict with an existing one, and fallback gracefully if not. Co-authored-by: David Robertson <davidr@element.io>
* Fix `ModuleApi.looping_background_call` for non-async functions (#11524)Sean Quah2021-12-071-3/+2
| | | | | | After #10847, `looping_background_call` would print an error in the logs every time a non-async function was called. Since the error would be caught and ignored immediately, there were no other side effects.
* Save the OIDC session ID (sid) with the device on login (#11482)Quentin Gliech2021-12-061-0/+2
| | | As a step towards allowing back-channel logout for OIDC.
* Make background updates controllable via a plugin (#11306)Erik Johnston2021-11-291-1/+53
| | | Co-authored-by: Brendan Abolivier <babolivier@matrix.org>
* disallow-untyped-defs for the module_api (#11029)David Robertson2021-11-291-30/+55
|
* Add missing type hints to config base classes (#11377)Patrick Cloke2021-11-231-1/+1
|
* Add/Unerase annotations to Module API (#11341)reivilibre2021-11-181-23/+134
|
* Add missing type hints to `synapse.app`. (#11287)Patrick Cloke2021-11-101-2/+2
|
* Add a module API method to retrieve state from a room (#11204)Brendan Abolivier2021-10-291-0/+49
|
* Add a ModuleApi method to update a user's membership in a room (#11147)Brendan Abolivier2021-10-281-1/+99
| | | Co-authored-by: reivilibre <oliverw@matrix.org>
* Document the version each module API method was added to Synapse (#11183)Brendan Abolivier2021-10-261-11/+88
|
* Fix module API's `get_user_ip_and_agents` function when run on workers (#11112)Sean Quah2021-10-251-1/+5
|
* Port the Password Auth Providers module interface to the new generic ↵Azrenbeth2021-10-131-0/+9
| | | | | | interface (#10548) Co-authored-by: Azrenbeth <7782548+Azrenbeth@users.noreply.github.com> Co-authored-by: Brendan Abolivier <babolivier@matrix.org>
* Mark Module API error imports as re-exported and mark Synapse as containing ↵reivilibre2021-10-131-2/+9
| | | | type annotations (#11054)
* Add type hints to `synapse.storage.databases.main.client_ips` (#10972)Sean Quah2021-10-121-3/+3
|
* Use direct references for some configuration variables (part 3) (#10885)Patrick Cloke2021-09-231-3/+5
| | | | | | | | This avoids the overhead of searching through the various configuration classes by directly referencing the class that the attributes are in. It also improves type hints since mypy can now resolve the types of the configuration variables.
* Extend ModuleApi with the methods we'll need to reject spam based on …IP - ↵David Teller2021-09-221-1/+81
| | | | | | | | resolves #10832 (#10833) Extend ModuleApi with the methods we'll need to reject spam based on IP - resolves #10832 Signed-off-by: David Teller <davidt@element.io>
* Add type hints for event streams. (#10856)Patrick Cloke2021-09-211-1/+1
|
* Use direct references for some configuration variables (#10798)Patrick Cloke2021-09-131-2/+2
| | | | Instead of proxying through the magic getter of the RootConfig object. This should be more performant (and is more explicit).
* Merge branch 'release-v1.41' into developErik Johnston2021-08-181-2/+10
|\
| * Allow modules to run looping call on all instances (#10638)Erik Johnston2021-08-181-1/+8
| | | | | | | | By default the calls only ran on the worker configured to run background tasks.
| * Centralise the custom template directory (#10596)Brendan Abolivier2021-08-171-1/+2
| | | | | | Several configuration sections are using separate settings for custom template directories, which can be confusing. This PR adds a new top-level configuration for a custom template directory which is then used for every module. The only exception is the consent templates, since the consent template directory require a specific hierarchy, so it's probably better that it stays separate from everything else.
* | Port the PresenceRouter module interface to the new generic interface (#10524)Azrenbeth2021-08-171-0/+10
|/ | | Port the PresenceRouter module interface to the new generic interface introduced in v1.37.0
* Allow using several custom template directories (#10587)Brendan Abolivier2021-08-171-1/+4
| | | Allow using several directories in read_templates.
* Add `get_userinfo_by_id` method to `ModuleApi` (#9581)Jason Robinson2021-08-041-1/+11
| | | | | | Makes it easier to fetch user details in for example spam checker modules, without needing to use api._store or figure out database interactions. Signed-off-by: Jason Robinson <jasonr@matrix.org>
* Fix a handful of type annotations. (#10446)Richard van der Hoff2021-07-221-1/+1
| | | | | | | | | | * switch from `types.CoroutineType` to `typing.Coroutine` these should be identical semantically, and since `defer.ensureDeferred` is defined to take a `typing.Coroutine`, will keep mypy happy * Fix some annotations on inlineCallbacks functions * changelog
* Port the ThirdPartyEventRules module interface to the new generic interface ↵Brendan Abolivier2021-07-201-0/+6
| | | | | (#10386) Port the third-party event rules interface to the generic module interface introduced in v1.37.0
* One last inline type hint (for the whole repo) (#10418)Jonathan de Jong2021-07-161-1/+1
|
* Add a module type for account validity (#9884)Brendan Abolivier2021-07-162-11/+214
| | | | | This adds an API for third-party plugin modules to implement account validity, so they can provide this feature instead of Synapse. The module implementing the current behaviour for this feature can be found at https://github.com/matrix-org/synapse-email-account-validity. To allow for a smooth transition between the current feature and the new module, hooks have been added to the existing account validity endpoints to allow their behaviours to be overridden by a module.
* Use inline type hints in various other places (in `synapse/`) (#10380)Jonathan de Jong2021-07-151-1/+1
|
* MSC2918 Refresh tokens implementation (#9450)Quentin Gliech2021-06-241-1/+1
| | | | | | | | | | This implements refresh tokens, as defined by MSC2918 This MSC has been implemented client side in Hydrogen Web: vector-im/hydrogen-web#235 The basics of the MSC works: requesting refresh tokens on login, having the access tokens expire, and using the refresh token to get a new one. Signed-off-by: Quentin Gliech <quentingliech@gmail.com>
* Standardise the module interface (#10062)Brendan Abolivier2021-06-182-1/+30
| | | This PR adds a common configuration section for all modules (see docs). These modules are then loaded at startup by the homeserver. Modules register their hooks and web resources using the new `register_[...]_callbacks` and `register_web_resource` methods of the module API.
* Use a database table to hold the users that should have full presence sent ↵Andrew Morgan2021-05-181-33/+30
| | | | to them, instead of something in-memory (#9823)
* Don't send normal presence updates over federation replication stream (#9828)Erik Johnston2021-04-191-5/+8
|
* Remove redundant "coding: utf-8" lines (#9786)Jonathan de Jong2021-04-142-2/+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-5/+7
| | | | | | | 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>
* Add a Synapse Module for configuring presence update routing (#9491)Andrew Morgan2021-04-061-0/+50
| | | | | | | | | | | | At the moment, if you'd like to share presence between local or remote users, those users must be sharing a room together. This isn't always the most convenient or useful situation though. This PR adds a module to Synapse that will allow deployments to set up extra logic on where presence updates should be routed. The module must implement two methods, `get_users_for_states` and `get_interested_users`. These methods are given presence updates or user IDs and must return information that Synapse will use to grant passing presence updates around. A method is additionally added to `ModuleApi` which allows triggering a set of users to receive the current, online presence information for all users they are considered interested in. This is the equivalent of that user receiving presence information during an initial sync. The goal of this module is to be fairly generic and useful for a variety of applications, with hard requirements being: * Sending state for a specific set or all known users to a defined set of local and remote users. * The ability to trigger an initial sync for specific users, so they receive all current state.
* Record the SSO Auth Provider in the login token (#9510)Richard van der Hoff2021-03-041-4/+27
| | | This great big stack of commits is a a whole load of hoop-jumping to make it easier to store additional values in login tokens, and then to actually store the SSO Identity Provider in the login token. (Making use of that data will follow in a subsequent PR.)
* Fix additional type hints from Twisted upgrade. (#9518)Patrick Cloke2021-03-031-2/+2
|
* Update black, and run auto formatting over the codebase (#9381)Eric Eastwood2021-02-161-2/+7
| | | | | | | - 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
* Improve styling and wording of SSO redirect confirm template (#9272)Richard van der Hoff2021-02-011-2/+8
|
* Add admin API for logging in as a user (#8617)Erik Johnston2020-11-171-1/+4
|
* Allow modules to create and send events into rooms (#8479)Andrew Morgan2020-10-091-1/+29
| | | | | This PR allows Synapse modules making use of the `ModuleApi` to create and send non-membership events into a room. This can useful to have modules send messages, or change power levels in a room etc. Note that they must send event through a user that's already in the room. The non-membership event limitation is currently arbitrary, as it's another chunk of work and not necessary at the moment.
* Combine `SpamCheckerApi` with the more generic `ModuleApi`. (#8464)Richard van der Hoff2020-10-071-1/+28
| | | | | Lots of different module apis is not easy to maintain. Rather than adding yet another ModuleApi(hs, hs.get_auth_handler()) incantation, first add an hs.get_module_api() method and use it where possible.
* Allow ThirdPartyEventRules modules to manipulate public room state (#8292)Andrew Morgan2020-10-051-0/+67
| | | | | This PR allows `ThirdPartyEventRules` modules to view, manipulate and block changes to the state of whether a room is published in the public rooms directory. While the idea of whether a room is in the public rooms list is not kept within an event in the room, `ThirdPartyEventRules` generally deal with controlling which modifications can happen to a room. Public rooms fits within that idea, even if its toggle state isn't controlled through a state event.
* Stop sub-classing object (#8249)Patrick Cloke2020-09-041-1/+1
|
* Do not assume calls to runInteraction return Deferreds. (#8133)Patrick Cloke2020-08-201-3/+7
|
* Convert synapse.api to async/await (#8031)Patrick Cloke2020-08-061-2/+6
|
* Rename database classes to make some sense (#8033)Erik Johnston2020-08-051-1/+1
|
* Wrap register_device coroutine in an ensureDeferred (#7684)Andrew Morgan2020-06-161-5/+7
| | | | | | | Fixes https://github.com/matrix-org/synapse/issues/7683 Broke in: #7649 We had a `yield` acting on a coroutine. To be fair this one is a bit difficult to notice as there's a function in the middle that just passes the coroutine along.
* Convert the registration handler to async/await. (#7649)Patrick Cloke2020-06-081-2/+6
|
* Convert auth handler to async/await (#7261)Patrick Cloke2020-04-151-2/+4
|
* Do not allow a deactivated user to login via SSO. (#7240)Patrick Cloke2020-04-091-1/+21
|
* Factor out complete_sso_login and expose it to the Module APIBrendan Abolivier2020-03-031-0/+19
|
* Cleanups and additions to the module APIRichard van der Hoff2020-01-122-6/+59
| | | | | | | | | | | Add some useful things, such as error types and logcontext handling, to the API. Make `hs` a private member to dissuade people from using it (hopefully they aren't already). Add a couple of new methods (`record_user_external_id` and `generate_short_term_login_token`).
* Move DB pool and helper functions into dedicated Database classErik Johnston2019-12-051-1/+1
|
* Remove unnecessary parentheses around return statements (#5931)Andrew Morgan2019-08-301-1/+1
| | | | | Python will return a tuple whether there are parentheses around the returned values or not. I'm just sick of my editor complaining about this all over the place :)
* Replace returnValue with return (#5736)Amber Brown2019-07-231-1/+1
|
* Remove access-token support from RegistrationHandler.register (#5641)Richard van der Hoff2019-07-081-8/+2
| | | | | | | | Nothing uses this now, so we can remove the dead code, and clean up the API. Since we're changing the shape of the return value anyway, we take the opportunity to give the method a better name.
* Update ModuleApi to avoid register(generate_token=True) (#5640)Richard van der Hoff2019-07-081-8/+56
| | | | | | | | * Update ModuleApi to avoid register(generate_token=True) This is the only place this is still used, so I'm trying to kill it off. * changelog
* Run Black. (#5482)Amber Brown2019-06-201-3/+3
|
* Allow password providers to bind emails (#4947)Andrew Morgan2019-03-281-4/+5
| | | This PR allows password provider modules to bind email addresses when a user is registering and is motivated by matrix-org/matrix-synapse-ldap3#58
* Support 3PID login in password providers (#4931)Andrew Morgan2019-03-261-3/+15
| | | | | Adds a new method, check_3pid_auth, which gives password providers the chance to allow authentication with third-party identifiers such as email or msisdn.
* Fix registration on workers (#4682)Erik Johnston2019-02-201-1/+1
| | | | | | | | | | * Move RegistrationHandler init to HomeServer * Move post registration actions to RegistrationHandler * Add post regisration replication endpoint * Newsfile
* Delete devices in various logout situationsRichard van der Hoff2017-11-291-2/+12
| | | | | | | | | | | | | Make sure that we delete devices whenever a user is logged out due to any of the following situations: * /logout * /logout_all * change password * deactivate account (by the user or by an admin) * invalidate access token from a dynamic module Fixes #2672.
* Add more hooks to ModuleApiRichard van der Hoff2017-11-021-0/+34
| | | | add `get_user_by_req` and `invalidate_access_token`
* Factor _AccountHandler proxy out to ModuleApiRichard van der Hoff2017-11-021-0/+79
We're going to need to use this from places that aren't password auth, so let's move it to a proper class.