Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d5d4ff5d75 | |||
| 8848b3e197 |
@@ -72,3 +72,8 @@ book/
|
|||||||
|
|
||||||
# Don't include users' poetry configs
|
# Don't include users' poetry configs
|
||||||
/poetry.toml
|
/poetry.toml
|
||||||
|
|
||||||
|
# Devenv
|
||||||
|
.devenv*
|
||||||
|
devenv.local.nix
|
||||||
|
|
||||||
|
|||||||
+177
@@ -0,0 +1,177 @@
|
|||||||
|
{
|
||||||
|
"nodes": {
|
||||||
|
"devenv": {
|
||||||
|
"locked": {
|
||||||
|
"dir": "src/modules",
|
||||||
|
"lastModified": 1673960114,
|
||||||
|
"narHash": "sha256-YNCok1a8cy71nP0idJds2Dwn2B1T6zGw9+2H1A0lNa0=",
|
||||||
|
"owner": "cachix",
|
||||||
|
"repo": "devenv",
|
||||||
|
"rev": "0960585a7221e6ede718cc9a2c2eade7ce75c229",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"dir": "src/modules",
|
||||||
|
"owner": "cachix",
|
||||||
|
"repo": "devenv",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"fenix": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
],
|
||||||
|
"rust-analyzer-src": "rust-analyzer-src"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1674023045,
|
||||||
|
"narHash": "sha256-btQC+gTeVLmX9cYl/6Kig7BuDltVWJEh7TrITAc6QjA=",
|
||||||
|
"owner": "nix-community",
|
||||||
|
"repo": "fenix",
|
||||||
|
"rev": "75dbe699bc57323cdef636b82bcfef6028bd1530",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nix-community",
|
||||||
|
"repo": "fenix",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"flake-compat": {
|
||||||
|
"flake": false,
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1668681692,
|
||||||
|
"narHash": "sha256-Ht91NGdewz8IQLtWZ9LCeNXMSXHUss+9COoqu6JLmXU=",
|
||||||
|
"owner": "edolstra",
|
||||||
|
"repo": "flake-compat",
|
||||||
|
"rev": "009399224d5e398d03b22badca40a37ac85412a1",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "edolstra",
|
||||||
|
"repo": "flake-compat",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"flake-utils": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1667395993,
|
||||||
|
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"gitignore": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": [
|
||||||
|
"pre-commit-hooks",
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1660459072,
|
||||||
|
"narHash": "sha256-8DFJjXG8zqoONA1vXtgeKXy68KdJL5UaXR8NtVMUbx8=",
|
||||||
|
"owner": "hercules-ci",
|
||||||
|
"repo": "gitignore.nix",
|
||||||
|
"rev": "a20de23b925fd8264fd7fad6454652e142fd7f73",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "hercules-ci",
|
||||||
|
"repo": "gitignore.nix",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1673947312,
|
||||||
|
"narHash": "sha256-xx/2nRwRy3bXrtry6TtydKpJpqHahjuDB5sFkQ/XNDE=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "2d38b664b4400335086a713a0036aafaa002c003",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "NixOS",
|
||||||
|
"ref": "nixpkgs-unstable",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs-stable": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1671271954,
|
||||||
|
"narHash": "sha256-cSvu+bnvN08sOlTBWbBrKaBHQZq8mvk8bgpt0ZJ2Snc=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "d513b448cc2a6da2c8803e3c197c9fc7e67b19e3",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "NixOS",
|
||||||
|
"ref": "nixos-22.05",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"pre-commit-hooks": {
|
||||||
|
"inputs": {
|
||||||
|
"flake-compat": "flake-compat",
|
||||||
|
"flake-utils": "flake-utils",
|
||||||
|
"gitignore": "gitignore",
|
||||||
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
],
|
||||||
|
"nixpkgs-stable": "nixpkgs-stable"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1674046351,
|
||||||
|
"narHash": "sha256-vNErPj4gfO/G1vHuOh5/IbjLaydwePcRlD0fXlnUbmI=",
|
||||||
|
"owner": "cachix",
|
||||||
|
"repo": "pre-commit-hooks.nix",
|
||||||
|
"rev": "756cc26afb75b0f8bfec48bbc54a8836a04953fb",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "cachix",
|
||||||
|
"repo": "pre-commit-hooks.nix",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
"inputs": {
|
||||||
|
"devenv": "devenv",
|
||||||
|
"fenix": "fenix",
|
||||||
|
"nixpkgs": "nixpkgs",
|
||||||
|
"pre-commit-hooks": "pre-commit-hooks"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"rust-analyzer-src": {
|
||||||
|
"flake": false,
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1673979364,
|
||||||
|
"narHash": "sha256-ecgQENol9XhhcYF+M9B8FMrsWYQ/ZvRsvgEWi8HI6D0=",
|
||||||
|
"owner": "rust-lang",
|
||||||
|
"repo": "rust-analyzer",
|
||||||
|
"rev": "3a7271336536f2cd558498755254ae8c0e73baa7",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "rust-lang",
|
||||||
|
"ref": "nightly",
|
||||||
|
"repo": "rust-analyzer",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": "root",
|
||||||
|
"version": 7
|
||||||
|
}
|
||||||
+122
@@ -0,0 +1,122 @@
|
|||||||
|
{ inputs, pkgs, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
# Configure packages to install.
|
||||||
|
# Search for package names at https://search.nixos.org/packages?channel=unstable
|
||||||
|
packages = with pkgs; [
|
||||||
|
# Native dependencies for running Synapse.
|
||||||
|
icu
|
||||||
|
libffi
|
||||||
|
libjpeg
|
||||||
|
libpqxx
|
||||||
|
libwebp
|
||||||
|
libxml2
|
||||||
|
libxslt
|
||||||
|
sqlite
|
||||||
|
|
||||||
|
# Native dependencies for unit tests (SyTest also requires OpenSSL).
|
||||||
|
openssl
|
||||||
|
|
||||||
|
# Native dependencies for running Complement.
|
||||||
|
olm
|
||||||
|
|
||||||
|
# Development tools.
|
||||||
|
poetry
|
||||||
|
];
|
||||||
|
|
||||||
|
# Activate (and create if necessary) a poetry virtualenv on startup.
|
||||||
|
enterShell = ''
|
||||||
|
. "$(dirname $(poetry run which python))/activate"
|
||||||
|
'';
|
||||||
|
|
||||||
|
# Install dependencies for the additional programming languages
|
||||||
|
# involved with Synapse development. Python is already available
|
||||||
|
# from poetry's virtual environment.
|
||||||
|
#
|
||||||
|
# * Rust is used for developing and running Synapse.
|
||||||
|
# * Golang is needed to run the Complement test suite.
|
||||||
|
# * Perl is needed to run the SyTest test suite.
|
||||||
|
languages.go.enable = true;
|
||||||
|
languages.rust.enable = true;
|
||||||
|
languages.rust.version = "latest";
|
||||||
|
languages.perl.enable = true;
|
||||||
|
|
||||||
|
# Postgres is needed to run Synapse with postgres support and
|
||||||
|
# to run certain unit tests that require postgres.
|
||||||
|
services.postgres.enable = true;
|
||||||
|
|
||||||
|
# On the first invocation of `devenv up`, create a database for
|
||||||
|
# Syanpse to store data in.
|
||||||
|
services.postgres.initdbArgs = ["--locale=C" "--encoding=UTF8"];
|
||||||
|
services.postgres.initialDatabases = [
|
||||||
|
{ name = "synapse"; }
|
||||||
|
];
|
||||||
|
|
||||||
|
# Redis is needed in order to run Synapse in worker mode.
|
||||||
|
services.redis.enable = true;
|
||||||
|
|
||||||
|
# We wrap `poetry` with a bash script that disables the download
|
||||||
|
# of binary wheels for certain packages if the user is running
|
||||||
|
# NixOS. NixOS is special in that you can have multiple versions
|
||||||
|
# of packages installed at once, including your libc linker!
|
||||||
|
#
|
||||||
|
# Some binaries built for Linux expect those to be in a certain
|
||||||
|
# filepath, but that is not the case on NixOS. In that case, we
|
||||||
|
# force compiling those binaries locally instead.
|
||||||
|
scripts.poetry.exec = ''
|
||||||
|
if [ -z "$__NIXOS_SET_ENVIRONMENT_DONE" ]; then
|
||||||
|
# We are running on NixOS.
|
||||||
|
#
|
||||||
|
# Prevent poetry from downloading known problematic,
|
||||||
|
# dynamically-linked binaries for python dependencies.
|
||||||
|
POETRY_INSTALLER_NO_BINARY=ruff ${pkgs.poetry}/bin/poetry $@
|
||||||
|
else
|
||||||
|
${pkgs.poetry}/bin/poetry $@
|
||||||
|
fi
|
||||||
|
'';
|
||||||
|
|
||||||
|
# Define the perl modules we require to run SyTest.
|
||||||
|
#
|
||||||
|
# This list was compiled by cross-referencing https://metacpan.org/
|
||||||
|
# with the modules defined in './cpanfile' and then finding the
|
||||||
|
# corresponding nix packages on https://search.nixos.org/packages.
|
||||||
|
#
|
||||||
|
# This was done until `./install-deps.pl --dryrun` produced no output.
|
||||||
|
env.PERL5LIB = "${with pkgs.perl536Packages; makePerlPath [
|
||||||
|
DBI
|
||||||
|
ClassMethodModifiers
|
||||||
|
CryptEd25519
|
||||||
|
DataDump
|
||||||
|
DBDPg
|
||||||
|
DigestHMAC
|
||||||
|
DigestSHA1
|
||||||
|
EmailAddressXS
|
||||||
|
EmailMIME
|
||||||
|
EmailSimple # required by Email::Mime
|
||||||
|
EmailMessageID # required by Email::Mime
|
||||||
|
EmailMIMEContentType # required by Email::Mime
|
||||||
|
TextUnidecode # required by Email::Mime
|
||||||
|
ModuleRuntime # required by Email::Mime
|
||||||
|
EmailMIMEEncodings # required by Email::Mime
|
||||||
|
FilePath
|
||||||
|
FileSlurper
|
||||||
|
Future
|
||||||
|
GetoptLong
|
||||||
|
HTTPMessage
|
||||||
|
IOAsync
|
||||||
|
IOAsyncSSL
|
||||||
|
IOSocketSSL
|
||||||
|
NetSSLeay
|
||||||
|
JSON
|
||||||
|
ListUtilsBy
|
||||||
|
ScalarListUtils
|
||||||
|
ModulePluggable
|
||||||
|
NetAsyncHTTP
|
||||||
|
MetricsAny # required by Net::Async::HTTP
|
||||||
|
NetAsyncHTTPServer
|
||||||
|
StructDumb
|
||||||
|
URI
|
||||||
|
YAMLLibYAML
|
||||||
|
]}";
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
inputs:
|
||||||
|
nixpkgs:
|
||||||
|
url: github:NixOS/nixpkgs/nixpkgs-unstable
|
||||||
|
fenix:
|
||||||
|
url: github:nix-community/fenix
|
||||||
|
inputs:
|
||||||
|
nixpkgs:
|
||||||
|
follows: nixpkgs
|
||||||
@@ -45,6 +45,7 @@ CHECK_CAN_DEACTIVATE_USER_CALLBACK = Callable[[str, bool], Awaitable[bool]]
|
|||||||
ON_PROFILE_UPDATE_CALLBACK = Callable[[str, ProfileInfo, bool, bool], Awaitable]
|
ON_PROFILE_UPDATE_CALLBACK = Callable[[str, ProfileInfo, bool, bool], Awaitable]
|
||||||
ON_USER_DEACTIVATION_STATUS_CHANGED_CALLBACK = Callable[[str, bool, bool], Awaitable]
|
ON_USER_DEACTIVATION_STATUS_CHANGED_CALLBACK = Callable[[str, bool, bool], Awaitable]
|
||||||
ON_THREEPID_BIND_CALLBACK = Callable[[str, str, str], Awaitable]
|
ON_THREEPID_BIND_CALLBACK = Callable[[str, str, str], Awaitable]
|
||||||
|
ON_UPDATE_IDENTITY_SERVER_BINDING_CALLBACK = Callable[[str, str, str, Optional[str]], Awaitable[bool]]
|
||||||
|
|
||||||
|
|
||||||
def load_legacy_third_party_event_rules(hs: "HomeServer") -> None:
|
def load_legacy_third_party_event_rules(hs: "HomeServer") -> None:
|
||||||
@@ -174,6 +175,7 @@ class ThirdPartyEventRules:
|
|||||||
ON_USER_DEACTIVATION_STATUS_CHANGED_CALLBACK
|
ON_USER_DEACTIVATION_STATUS_CHANGED_CALLBACK
|
||||||
] = []
|
] = []
|
||||||
self._on_threepid_bind_callbacks: List[ON_THREEPID_BIND_CALLBACK] = []
|
self._on_threepid_bind_callbacks: List[ON_THREEPID_BIND_CALLBACK] = []
|
||||||
|
self._on_update_identity_server_binding: List[ON_UPDATE_IDENTITY_SERVER_BINDING_CALLBACK] = []
|
||||||
|
|
||||||
def register_third_party_rules_callbacks(
|
def register_third_party_rules_callbacks(
|
||||||
self,
|
self,
|
||||||
@@ -193,6 +195,7 @@ class ThirdPartyEventRules:
|
|||||||
ON_USER_DEACTIVATION_STATUS_CHANGED_CALLBACK
|
ON_USER_DEACTIVATION_STATUS_CHANGED_CALLBACK
|
||||||
] = None,
|
] = None,
|
||||||
on_threepid_bind: Optional[ON_THREEPID_BIND_CALLBACK] = None,
|
on_threepid_bind: Optional[ON_THREEPID_BIND_CALLBACK] = None,
|
||||||
|
on_update_identity_server_binding: Optional[ON_UPDATE_IDENTITY_SERVER_BINDING_CALLBACK] = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Register callbacks from modules for each hook."""
|
"""Register callbacks from modules for each hook."""
|
||||||
if check_event_allowed is not None:
|
if check_event_allowed is not None:
|
||||||
@@ -230,6 +233,9 @@ class ThirdPartyEventRules:
|
|||||||
if on_threepid_bind is not None:
|
if on_threepid_bind is not None:
|
||||||
self._on_threepid_bind_callbacks.append(on_threepid_bind)
|
self._on_threepid_bind_callbacks.append(on_threepid_bind)
|
||||||
|
|
||||||
|
if on_update_identity_server_binding is not None:
|
||||||
|
self._on_update_identity_server_binding.append(on_update_identity_server_binding)
|
||||||
|
|
||||||
async def check_event_allowed(
|
async def check_event_allowed(
|
||||||
self, event: EventBase, context: EventContext
|
self, event: EventBase, context: EventContext
|
||||||
) -> Tuple[bool, Optional[dict]]:
|
) -> Tuple[bool, Optional[dict]]:
|
||||||
@@ -523,3 +529,24 @@ class ThirdPartyEventRules:
|
|||||||
logger.exception(
|
logger.exception(
|
||||||
"Failed to run module API callback %s: %s", callback, e
|
"Failed to run module API callback %s: %s", callback, e
|
||||||
)
|
)
|
||||||
|
async def on_update_identity_server_binding(self, user_id: str, medium: str, address: str, id_server: Optional[str]) -> bool:
|
||||||
|
"""Called before a binding between a third-party ID and a Matrix ID is made
|
||||||
|
against an identity server.
|
||||||
|
|
||||||
|
Note that this callback is not called if a user only requests for an association
|
||||||
|
to be made between a third-party ID and their Matrix on their local homeserver.
|
||||||
|
It is only called if an identity server is to receive the binding as well.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
user_id: the ID of the user to include in the association.
|
||||||
|
medium: the medium of the third-party ID (email, msisdn).
|
||||||
|
address: the address of the third-party ID (i.e. an email address).
|
||||||
|
id_server:
|
||||||
|
"""
|
||||||
|
for callback in self._on_threepid_bind_callbacks:
|
||||||
|
try:
|
||||||
|
await callback(user_id, medium, address)
|
||||||
|
except Exception as e:
|
||||||
|
logger.exception(
|
||||||
|
"Failed to run module API callback %s: %s", callback, e
|
||||||
|
)
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ from synapse.events.third_party_rules import (
|
|||||||
ON_NEW_EVENT_CALLBACK,
|
ON_NEW_EVENT_CALLBACK,
|
||||||
ON_PROFILE_UPDATE_CALLBACK,
|
ON_PROFILE_UPDATE_CALLBACK,
|
||||||
ON_THREEPID_BIND_CALLBACK,
|
ON_THREEPID_BIND_CALLBACK,
|
||||||
|
ON_UPDATE_IDENTITY_SERVER_BINDING_CALLBACK,
|
||||||
ON_USER_DEACTIVATION_STATUS_CHANGED_CALLBACK,
|
ON_USER_DEACTIVATION_STATUS_CHANGED_CALLBACK,
|
||||||
)
|
)
|
||||||
from synapse.handlers.account_data import ON_ACCOUNT_DATA_UPDATED_CALLBACK
|
from synapse.handlers.account_data import ON_ACCOUNT_DATA_UPDATED_CALLBACK
|
||||||
@@ -357,6 +358,7 @@ class ModuleApi:
|
|||||||
ON_USER_DEACTIVATION_STATUS_CHANGED_CALLBACK
|
ON_USER_DEACTIVATION_STATUS_CHANGED_CALLBACK
|
||||||
] = None,
|
] = None,
|
||||||
on_threepid_bind: Optional[ON_THREEPID_BIND_CALLBACK] = None,
|
on_threepid_bind: Optional[ON_THREEPID_BIND_CALLBACK] = None,
|
||||||
|
on_update_identity_server_binding: Optional[ON_UPDATE_IDENTITY_SERVER_BINDING_CALLBACK] = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Registers callbacks for third party event rules capabilities.
|
"""Registers callbacks for third party event rules capabilities.
|
||||||
|
|
||||||
@@ -373,6 +375,7 @@ class ModuleApi:
|
|||||||
on_profile_update=on_profile_update,
|
on_profile_update=on_profile_update,
|
||||||
on_user_deactivation_status_changed=on_user_deactivation_status_changed,
|
on_user_deactivation_status_changed=on_user_deactivation_status_changed,
|
||||||
on_threepid_bind=on_threepid_bind,
|
on_threepid_bind=on_threepid_bind,
|
||||||
|
on_update_identity_server_binding=on_update_identity_server_binding,
|
||||||
)
|
)
|
||||||
|
|
||||||
def register_presence_router_callbacks(
|
def register_presence_router_callbacks(
|
||||||
|
|||||||
Reference in New Issue
Block a user