Compare commits
86 Commits
v1.20.1
...
erikj/repl
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
11149c89c7 | ||
|
|
40c4cfbfb1 | ||
|
|
450ec48445 | ||
|
|
4b3a1faa08 | ||
|
|
31acc5c309 | ||
|
|
fec6f9ac17 | ||
|
|
abd04b6af0 | ||
|
|
3e87d79e1c | ||
|
|
c77c4a2fcd | ||
|
|
f112cfe5bb | ||
|
|
11c9e17738 | ||
|
|
6fdf577593 | ||
|
|
ac11fcbbb8 | ||
|
|
13099ae431 | ||
|
|
2983049a77 | ||
|
|
91c60f3042 | ||
|
|
302dc89f6a | ||
|
|
cbabb312e0 | ||
|
|
916bb9d0d1 | ||
|
|
4bb203ea4f | ||
|
|
bbde4038df | ||
|
|
a4e63e5a47 | ||
|
|
48336eeb85 | ||
|
|
4325be1a52 | ||
|
|
8998217540 | ||
|
|
4da01f9c61 | ||
|
|
b29a9bdaa9 | ||
|
|
37ca5924bd | ||
|
|
4f3096d866 | ||
|
|
babc027543 | ||
|
|
00db7786de | ||
|
|
d688b4bafc | ||
|
|
36efbcaf51 | ||
|
|
8a4a4186de | ||
|
|
68c7a6936f | ||
|
|
7c407efdc8 | ||
|
|
5e42e61609 | ||
|
|
efb6b6629c | ||
|
|
837293c314 | ||
|
|
c3c9732c53 | ||
|
|
53284c425e | ||
|
|
a3f124b821 | ||
|
|
44dec6cbc4 | ||
|
|
7c43643037 | ||
|
|
5dd051acae | ||
|
|
576bc37d31 | ||
|
|
aec294ee0d | ||
|
|
d2a3eb04a4 | ||
|
|
b82d68c0bd | ||
|
|
6605470bfb | ||
|
|
04cc249b43 | ||
|
|
a9dbe98ef9 | ||
|
|
fe8ed1b46f | ||
|
|
c312ee3cde | ||
|
|
95d869c357 | ||
|
|
5d3e306d9f | ||
|
|
a3a90ee031 | ||
|
|
e44e9ee518 | ||
|
|
b312769c0e | ||
|
|
2ea1c68249 | ||
|
|
c9dbee50ae | ||
|
|
dc9dcdbd59 | ||
|
|
e7fd336a53 | ||
|
|
453dfe210b | ||
|
|
a5370072b5 | ||
|
|
e45b834119 | ||
|
|
1553adc831 | ||
|
|
560f3b8609 | ||
|
|
63c0e9e195 | ||
|
|
094896a69d | ||
|
|
0f545e6b96 | ||
|
|
703e2b8a96 | ||
|
|
deedb91732 | ||
|
|
cca03dbec8 | ||
|
|
72bec36d50 | ||
|
|
cef00211c8 | ||
|
|
68cdb3708e | ||
|
|
8d6f97f932 | ||
|
|
77794ebc77 | ||
|
|
7586fdf1e8 | ||
|
|
5b452df23b | ||
|
|
765437df54 | ||
|
|
77b4711bc2 | ||
|
|
7513006b09 | ||
|
|
17fa4c7ca7 | ||
|
|
58f61f10f7 |
@@ -17,9 +17,9 @@ https://help.github.com/articles/using-pull-requests/) to ask us to pull your
|
||||
changes into our repo.
|
||||
|
||||
Some other points to follow:
|
||||
|
||||
|
||||
* Please base your changes on the `develop` branch.
|
||||
|
||||
|
||||
* Please follow the [code style requirements](#code-style).
|
||||
|
||||
* Please include a [changelog entry](#changelog) with each PR.
|
||||
@@ -46,7 +46,7 @@ locally. You'll need python 3.6 or later, and to install a number of tools:
|
||||
|
||||
```
|
||||
# Install the dependencies
|
||||
pip install -U black flake8 flake8-comprehensions isort
|
||||
pip install -e ".[lint]"
|
||||
|
||||
# Run the linter script
|
||||
./scripts-dev/lint.sh
|
||||
|
||||
53
UPGRADE.rst
53
UPGRADE.rst
@@ -75,6 +75,59 @@ for example:
|
||||
wget https://packages.matrix.org/debian/pool/main/m/matrix-synapse-py3/matrix-synapse-py3_1.3.0+stretch1_amd64.deb
|
||||
dpkg -i matrix-synapse-py3_1.3.0+stretch1_amd64.deb
|
||||
|
||||
Upgrading to v1.21.0
|
||||
====================
|
||||
|
||||
Forwarding ``/_synapse/client`` through your reverse proxy
|
||||
----------------------------------------------------------
|
||||
|
||||
The `reverse proxy documentation
|
||||
<https://github.com/matrix-org/synapse/blob/develop/docs/reverse_proxy.md>`_ has been updated
|
||||
to include reverse proxy directives for ``/_synapse/client/*`` endpoints. As the user password
|
||||
reset flow now uses endpoints under this prefix, **you must update your reverse proxy
|
||||
configurations for user password reset to work**.
|
||||
|
||||
Additionally, note that the `Synapse worker documentation
|
||||
<https://github.com/matrix-org/synapse/blob/develop/docs/workers.md>`_ has been updated to
|
||||
state that the ``/_synapse/client/password_reset/email/submit_token`` endpoint can be handled
|
||||
by all workers. If you make use of Synapse's worker feature, please update your reverse proxy
|
||||
configuration to reflect this change.
|
||||
|
||||
New HTML templates
|
||||
------------------
|
||||
|
||||
A new HTML template,
|
||||
`password_reset_confirmation.html <https://github.com/matrix-org/synapse/blob/develop/synapse/res/templates/password_reset_confirmation.html>`_,
|
||||
has been added to the ``synapse/res/templates`` directory. If you are using a
|
||||
custom template directory, you may want to copy the template over and modify it.
|
||||
|
||||
Note that as of v1.20.0, templates do not need to be included in custom template
|
||||
directories for Synapse to start. The default templates will be used if a custom
|
||||
template cannot be found.
|
||||
|
||||
This page will appear to the user after clicking a password reset link that has
|
||||
been emailed to them.
|
||||
|
||||
To complete password reset, the page must include a way to make a `POST`
|
||||
request to
|
||||
``/_synapse/client/password_reset/{medium}/submit_token``
|
||||
with the query parameters from the original link, presented as a URL-encoded form. See the file
|
||||
itself for more details.
|
||||
|
||||
Updated Single Sign-on HTML Templates
|
||||
-------------------------------------
|
||||
|
||||
The ``saml_error.html`` template was removed from Synapse and replaced with the
|
||||
``sso_error.html`` template. If your Synapse is configured to use SAML and a
|
||||
custom ``sso_redirect_confirm_template_dir`` configuration then any customisations
|
||||
of the ``saml_error.html`` template will need to be merged into the ``sso_error.html``
|
||||
template. These templates are similar, but the parameters are slightly different:
|
||||
|
||||
* The ``msg`` parameter should be renamed to ``error_description``.
|
||||
* There is no longer a ``code`` parameter for the response code.
|
||||
* A string ``error`` parameter is available that includes a short hint of why a
|
||||
user is seeing the error page.
|
||||
|
||||
Upgrading to v1.18.0
|
||||
====================
|
||||
|
||||
|
||||
1
changelog.d/7124.bugfix
Normal file
1
changelog.d/7124.bugfix
Normal file
@@ -0,0 +1 @@
|
||||
Fix a bug in the media repository where remote thumbnails with the same size but different crop methods would overwrite each other. Contributed by @deepbluev7.
|
||||
1
changelog.d/7796.bugfix
Normal file
1
changelog.d/7796.bugfix
Normal file
@@ -0,0 +1 @@
|
||||
Fix inconsistent handling of non-existent push rules, and stop tracking the `enabled` state of removed push rules.
|
||||
1
changelog.d/8004.feature
Normal file
1
changelog.d/8004.feature
Normal file
@@ -0,0 +1 @@
|
||||
Require the user to confirm that their password should be reset after clicking the email confirmation link.
|
||||
1
changelog.d/8208.misc
Normal file
1
changelog.d/8208.misc
Normal file
@@ -0,0 +1 @@
|
||||
Fix tests on distros which disable TLSv1.0. Contributed by @danc86.
|
||||
1
changelog.d/8216.misc
Normal file
1
changelog.d/8216.misc
Normal file
@@ -0,0 +1 @@
|
||||
Simplify the distributor code to avoid unnecessary work.
|
||||
1
changelog.d/8217.feature
Normal file
1
changelog.d/8217.feature
Normal file
@@ -0,0 +1 @@
|
||||
Add an admin API `GET /_synapse/admin/v1/event_reports` to read entries of table `event_reports`. Contributed by @dklimpel.
|
||||
1
changelog.d/8227.doc
Normal file
1
changelog.d/8227.doc
Normal file
@@ -0,0 +1 @@
|
||||
Add `/_synapse/client` to the reverse proxy documentation.
|
||||
1
changelog.d/8230.bugfix
Normal file
1
changelog.d/8230.bugfix
Normal file
@@ -0,0 +1 @@
|
||||
Fix messages over federation being lost until an event is sent into the same room.
|
||||
1
changelog.d/8236.bugfix
Normal file
1
changelog.d/8236.bugfix
Normal file
@@ -0,0 +1 @@
|
||||
Fix a longstanding bug where files that could not be thumbnailed would result in an Internal Server Error.
|
||||
1
changelog.d/8243.misc
Normal file
1
changelog.d/8243.misc
Normal file
@@ -0,0 +1 @@
|
||||
Remove the 'populate_stats_process_rooms_2' background job and restore functionality to 'populate_stats_process_rooms'.
|
||||
1
changelog.d/8247.bugfix
Normal file
1
changelog.d/8247.bugfix
Normal file
@@ -0,0 +1 @@
|
||||
Fix messages over federation being lost until an event is sent into the same room.
|
||||
1
changelog.d/8248.feature
Normal file
1
changelog.d/8248.feature
Normal file
@@ -0,0 +1 @@
|
||||
Consolidate the SSO error template across all configuration.
|
||||
1
changelog.d/8250.misc
Normal file
1
changelog.d/8250.misc
Normal file
@@ -0,0 +1 @@
|
||||
Clean up type hints for `PaginationConfig`.
|
||||
1
changelog.d/8256.misc
Normal file
1
changelog.d/8256.misc
Normal file
@@ -0,0 +1 @@
|
||||
Track the latest event for every destination and room for catch-up after federation outage.
|
||||
1
changelog.d/8257.misc
Normal file
1
changelog.d/8257.misc
Normal file
@@ -0,0 +1 @@
|
||||
Fix non-user visible bug in implementation of `MultiWriterIdGenerator.get_current_token_for_writer`.
|
||||
1
changelog.d/8258.bugfix
Normal file
1
changelog.d/8258.bugfix
Normal file
@@ -0,0 +1 @@
|
||||
Fix messages over federation being lost until an event is sent into the same room.
|
||||
1
changelog.d/8259.misc
Normal file
1
changelog.d/8259.misc
Normal file
@@ -0,0 +1 @@
|
||||
Switch to the JSON implementation from the standard library.
|
||||
1
changelog.d/8260.misc
Normal file
1
changelog.d/8260.misc
Normal file
@@ -0,0 +1 @@
|
||||
Add type hints to `synapse.util.async_helpers`.
|
||||
1
changelog.d/8261.misc
Normal file
1
changelog.d/8261.misc
Normal file
@@ -0,0 +1 @@
|
||||
Simplify tests that mock asynchronous functions.
|
||||
1
changelog.d/8262.bugfix
Normal file
1
changelog.d/8262.bugfix
Normal file
@@ -0,0 +1 @@
|
||||
Upgrade canonicaljson to version 1.4.0 to fix an unicode encoding issue.
|
||||
1
changelog.d/8265.bugfix
Normal file
1
changelog.d/8265.bugfix
Normal file
@@ -0,0 +1 @@
|
||||
Fix logstanding bug which could lead to incomplete database upgrades on SQLite.
|
||||
1
changelog.d/8268.bugfix
Normal file
1
changelog.d/8268.bugfix
Normal file
@@ -0,0 +1 @@
|
||||
Fix stack overflow when stderr is redirected to the logging system, and the logging system encounters an error.
|
||||
1
changelog.d/8272.bugfix
Normal file
1
changelog.d/8272.bugfix
Normal file
@@ -0,0 +1 @@
|
||||
Fix messages over federation being lost until an event is sent into the same room.
|
||||
1
changelog.d/8275.feature
Normal file
1
changelog.d/8275.feature
Normal file
@@ -0,0 +1 @@
|
||||
Add a config option to specify a whitelist of domains that a user can be redirected to after validating their email or phone number.
|
||||
1
changelog.d/8278.bugfix
Normal file
1
changelog.d/8278.bugfix
Normal file
@@ -0,0 +1 @@
|
||||
Fix a bug which cause the logging system to report errors, if `DEBUG` was enabled and no `context` filter was applied.
|
||||
1
changelog.d/8279.misc
Normal file
1
changelog.d/8279.misc
Normal file
@@ -0,0 +1 @@
|
||||
Add type hints to `StreamToken` and `RoomStreamToken` classes.
|
||||
1
changelog.d/8281.misc
Normal file
1
changelog.d/8281.misc
Normal file
@@ -0,0 +1 @@
|
||||
Change `StreamToken.room_key` to be a `RoomStreamToken` instance.
|
||||
1
changelog.d/8282.misc
Normal file
1
changelog.d/8282.misc
Normal file
@@ -0,0 +1 @@
|
||||
Clean up type hints for `PaginationConfig`.
|
||||
1
changelog.d/8287.bugfix
Normal file
1
changelog.d/8287.bugfix
Normal file
@@ -0,0 +1 @@
|
||||
Fix edge case where push could get delayed for a user until a later event was pushed.
|
||||
1
changelog.d/8288.misc
Normal file
1
changelog.d/8288.misc
Normal file
@@ -0,0 +1 @@
|
||||
Refactor notifier code to correctly use the max event stream position.
|
||||
1
changelog.d/8294.feature
Normal file
1
changelog.d/8294.feature
Normal file
@@ -0,0 +1 @@
|
||||
Add experimental support for sharding event persister.
|
||||
1
changelog.d/8296.misc
Normal file
1
changelog.d/8296.misc
Normal file
@@ -0,0 +1 @@
|
||||
Use slotted classes where possible.
|
||||
1
changelog.d/8305.feature
Normal file
1
changelog.d/8305.feature
Normal file
@@ -0,0 +1 @@
|
||||
Add the room topic and avatar to the room details admin API.
|
||||
1
changelog.d/8306.feature
Normal file
1
changelog.d/8306.feature
Normal file
@@ -0,0 +1 @@
|
||||
Add an admin API for querying rooms where a user is a member. Contributed by @dklimpel.
|
||||
1
changelog.d/8320.feature
Normal file
1
changelog.d/8320.feature
Normal file
@@ -0,0 +1 @@
|
||||
Add `uk.half-shot.msc2778.login.application_service` login type to allow appservices to login.
|
||||
1
changelog.d/8322.bugfix
Normal file
1
changelog.d/8322.bugfix
Normal file
@@ -0,0 +1 @@
|
||||
Fix messages over federation being lost until an event is sent into the same room.
|
||||
1
changelog.d/8324.bugfix
Normal file
1
changelog.d/8324.bugfix
Normal file
@@ -0,0 +1 @@
|
||||
Fix fetching events from remote servers that are malformed.
|
||||
1
changelog.d/8326.misc
Normal file
1
changelog.d/8326.misc
Normal file
@@ -0,0 +1 @@
|
||||
Update outdated usages of `metaclass` to python 3 syntax.
|
||||
1
changelog.d/8329.bugfix
Normal file
1
changelog.d/8329.bugfix
Normal file
@@ -0,0 +1 @@
|
||||
Fix UnboundLocalError from occuring when appservices send malformed register request.
|
||||
1
changelog.d/8330.misc
Normal file
1
changelog.d/8330.misc
Normal file
@@ -0,0 +1 @@
|
||||
Move lint-related dependencies to package-extra field, update CONTRIBUTING.md to utilise this.
|
||||
1
changelog.d/8331.misc
Normal file
1
changelog.d/8331.misc
Normal file
@@ -0,0 +1 @@
|
||||
Use the `admin_patterns` helper in additional locations.
|
||||
1
changelog.d/8335.misc
Normal file
1
changelog.d/8335.misc
Normal file
@@ -0,0 +1 @@
|
||||
Fix test logging to allow braces in log output.
|
||||
1
changelog.d/8337.misc
Normal file
1
changelog.d/8337.misc
Normal file
@@ -0,0 +1 @@
|
||||
Remove `__future__` imports related to Python 2 compatibility.
|
||||
1
changelog.d/8344.misc
Normal file
1
changelog.d/8344.misc
Normal file
@@ -0,0 +1 @@
|
||||
Simplify `super()` calls to Python 3 syntax.
|
||||
1
changelog.d/8345.feature
Normal file
1
changelog.d/8345.feature
Normal file
@@ -0,0 +1 @@
|
||||
Add a configuration option that allows existing users to log in with OpenID Connect. Contributed by @BBBSnowball and @OmmyZhang.
|
||||
1
changelog.d/8353.bugfix
Normal file
1
changelog.d/8353.bugfix
Normal file
@@ -0,0 +1 @@
|
||||
Don't send push notifications to expired user accounts.
|
||||
1
changelog.d/8354.misc
Normal file
1
changelog.d/8354.misc
Normal file
@@ -0,0 +1 @@
|
||||
Fix bad merge from `release-v1.20.0` branch to `develop`.
|
||||
1
changelog.d/8362.bugfix
Normal file
1
changelog.d/8362.bugfix
Normal file
@@ -0,0 +1 @@
|
||||
Fixed a regression in v1.19.0 with reactivating users through the admin API.
|
||||
2
changelog.d/8364.bugfix
Normal file
2
changelog.d/8364.bugfix
Normal file
@@ -0,0 +1,2 @@
|
||||
Fix a bug where during device registration the length of the device name wasn't
|
||||
limited.
|
||||
1
changelog.d/8370.misc
Normal file
1
changelog.d/8370.misc
Normal file
@@ -0,0 +1 @@
|
||||
Factor out a `_send_dummy_event_for_room` method.
|
||||
1
changelog.d/8371.misc
Normal file
1
changelog.d/8371.misc
Normal file
@@ -0,0 +1 @@
|
||||
Improve logging of state resolution.
|
||||
1
changelog.d/8372.misc
Normal file
1
changelog.d/8372.misc
Normal file
@@ -0,0 +1 @@
|
||||
Add type annotations to `SimpleHttpClient`.
|
||||
1
changelog.d/8373.bugfix
Normal file
1
changelog.d/8373.bugfix
Normal file
@@ -0,0 +1 @@
|
||||
Include `guest_access` in the fields that are checked for null bytes when updating `room_stats_state`. Broke in v1.7.2.
|
||||
1
changelog.d/8374.bugfix
Normal file
1
changelog.d/8374.bugfix
Normal file
@@ -0,0 +1 @@
|
||||
Fix theoretical race condition where events are not sent down `/sync` if the synchrotron worker is restarted without restarting other workers.
|
||||
1
changelog.d/8375.doc
Normal file
1
changelog.d/8375.doc
Normal file
@@ -0,0 +1 @@
|
||||
Add note to the reverse proxy settings documentation about disabling Apache's mod_security2. Contributed by Julian Fietkau (@jfietkau).
|
||||
1
changelog.d/8377.misc
Normal file
1
changelog.d/8377.misc
Normal file
@@ -0,0 +1 @@
|
||||
Move lint-related dependencies to package-extra field, update CONTRIBUTING.md to utilise this.
|
||||
1
changelog.d/8383.misc
Normal file
1
changelog.d/8383.misc
Normal file
@@ -0,0 +1 @@
|
||||
Refactor ID generators to use `async with` syntax.
|
||||
1
changelog.d/8385.bugfix
Normal file
1
changelog.d/8385.bugfix
Normal file
@@ -0,0 +1 @@
|
||||
Fix a bug which could cause errors in rooms with malformed membership events, on servers using sqlite.
|
||||
1
changelog.d/8386.bugfix
Normal file
1
changelog.d/8386.bugfix
Normal file
@@ -0,0 +1 @@
|
||||
Fix a bug introduced in v1.20.0 which caused the `synapse_port_db` script to fail.
|
||||
1
changelog.d/8387.feature
Normal file
1
changelog.d/8387.feature
Normal file
@@ -0,0 +1 @@
|
||||
Add experimental support for sharding event persister.
|
||||
1
changelog.d/8388.misc
Normal file
1
changelog.d/8388.misc
Normal file
@@ -0,0 +1 @@
|
||||
Add `EventStreamPosition` type.
|
||||
1
changelog.d/8396.feature
Normal file
1
changelog.d/8396.feature
Normal file
@@ -0,0 +1 @@
|
||||
Add experimental support for sharding event persister.
|
||||
1
changelog.d/8398.bugfix
Normal file
1
changelog.d/8398.bugfix
Normal file
@@ -0,0 +1 @@
|
||||
Fix "Re-starting finished log context" warning when receiving an event we already had over federation.
|
||||
1
changelog.d/8401.misc
Normal file
1
changelog.d/8401.misc
Normal file
@@ -0,0 +1 @@
|
||||
A pair of tiny cleanups in the federation request code.
|
||||
1
changelog.d/8405.feature
Normal file
1
changelog.d/8405.feature
Normal file
@@ -0,0 +1 @@
|
||||
Consolidate the SSO error template across all configuration.
|
||||
1
changelog.d/8412.bugfix
Normal file
1
changelog.d/8412.bugfix
Normal file
@@ -0,0 +1 @@
|
||||
Fix retries of HTTP requests between Synapse workers when the requests time out.
|
||||
@@ -15,8 +15,6 @@
|
||||
# limitations under the License.
|
||||
|
||||
""" Starts a synapse client console. """
|
||||
from __future__ import print_function
|
||||
|
||||
import argparse
|
||||
import cmd
|
||||
import getpass
|
||||
|
||||
@@ -13,8 +13,6 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import json
|
||||
import urllib
|
||||
from pprint import pformat
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
from __future__ import print_function
|
||||
|
||||
import argparse
|
||||
import cgi
|
||||
import datetime
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
from __future__ import print_function
|
||||
|
||||
import argparse
|
||||
import cgi
|
||||
import datetime
|
||||
|
||||
@@ -10,8 +10,6 @@ the bridge.
|
||||
Requires:
|
||||
npm install jquery jsdom
|
||||
"""
|
||||
from __future__ import print_function
|
||||
|
||||
import json
|
||||
import subprocess
|
||||
import time
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
from __future__ import print_function
|
||||
|
||||
import json
|
||||
import sys
|
||||
@@ -8,11 +7,6 @@ from argparse import ArgumentParser
|
||||
|
||||
import requests
|
||||
|
||||
try:
|
||||
raw_input
|
||||
except NameError: # Python 3
|
||||
raw_input = input
|
||||
|
||||
|
||||
def _mkurl(template, kws):
|
||||
for key in kws:
|
||||
@@ -58,7 +52,7 @@ def main(hs, room_id, access_token, user_id_prefix, why):
|
||||
print("The following user IDs will be kicked from %s" % room_name)
|
||||
for uid in kick_list:
|
||||
print(uid)
|
||||
doit = raw_input("Continue? [Y]es\n")
|
||||
doit = input("Continue? [Y]es\n")
|
||||
if len(doit) > 0 and doit.lower() == "y":
|
||||
print("Kicking members...")
|
||||
# encode them all
|
||||
|
||||
129
docs/admin_api/event_reports.rst
Normal file
129
docs/admin_api/event_reports.rst
Normal file
@@ -0,0 +1,129 @@
|
||||
Show reported events
|
||||
====================
|
||||
|
||||
This API returns information about reported events.
|
||||
|
||||
The api is::
|
||||
|
||||
GET /_synapse/admin/v1/event_reports?from=0&limit=10
|
||||
|
||||
To use it, you will need to authenticate by providing an ``access_token`` for a
|
||||
server admin: see `README.rst <README.rst>`_.
|
||||
|
||||
It returns a JSON body like the following:
|
||||
|
||||
.. code:: jsonc
|
||||
|
||||
{
|
||||
"event_reports": [
|
||||
{
|
||||
"content": {
|
||||
"reason": "foo",
|
||||
"score": -100
|
||||
},
|
||||
"event_id": "$bNUFCwGzWca1meCGkjp-zwslF-GfVcXukvRLI1_FaVY",
|
||||
"event_json": {
|
||||
"auth_events": [
|
||||
"$YK4arsKKcc0LRoe700pS8DSjOvUT4NDv0HfInlMFw2M",
|
||||
"$oggsNXxzPFRE3y53SUNd7nsj69-QzKv03a1RucHu-ws"
|
||||
],
|
||||
"content": {
|
||||
"body": "matrix.org: This Week in Matrix",
|
||||
"format": "org.matrix.custom.html",
|
||||
"formatted_body": "<strong>matrix.org</strong>:<br><a href=\"https://matrix.org/blog/\"><strong>This Week in Matrix</strong></a>",
|
||||
"msgtype": "m.notice"
|
||||
},
|
||||
"depth": 546,
|
||||
"hashes": {
|
||||
"sha256": "xK1//xnmvHJIOvbgXlkI8eEqdvoMmihVDJ9J4SNlsAw"
|
||||
},
|
||||
"origin": "matrix.org",
|
||||
"origin_server_ts": 1592291711430,
|
||||
"prev_events": [
|
||||
"$YK4arsKKcc0LRoe700pS8DSjOvUT4NDv0HfInlMFw2M"
|
||||
],
|
||||
"prev_state": [],
|
||||
"room_id": "!ERAgBpSOcCCuTJqQPk:matrix.org",
|
||||
"sender": "@foobar:matrix.org",
|
||||
"signatures": {
|
||||
"matrix.org": {
|
||||
"ed25519:a_JaEG": "cs+OUKW/iHx5pEidbWxh0UiNNHwe46Ai9LwNz+Ah16aWDNszVIe2gaAcVZfvNsBhakQTew51tlKmL2kspXk/Dg"
|
||||
}
|
||||
},
|
||||
"type": "m.room.message",
|
||||
"unsigned": {
|
||||
"age_ts": 1592291711430,
|
||||
}
|
||||
},
|
||||
"id": 2,
|
||||
"reason": "foo",
|
||||
"received_ts": 1570897107409,
|
||||
"room_alias": "#alias1:matrix.org",
|
||||
"room_id": "!ERAgBpSOcCCuTJqQPk:matrix.org",
|
||||
"sender": "@foobar:matrix.org",
|
||||
"user_id": "@foo:matrix.org"
|
||||
},
|
||||
{
|
||||
"content": {
|
||||
"reason": "bar",
|
||||
"score": -100
|
||||
},
|
||||
"event_id": "$3IcdZsDaN_En-S1DF4EMCy3v4gNRKeOJs8W5qTOKj4I",
|
||||
"event_json": {
|
||||
// hidden items
|
||||
// see above
|
||||
},
|
||||
"id": 3,
|
||||
"reason": "bar",
|
||||
"received_ts": 1598889612059,
|
||||
"room_alias": "#alias2:matrix.org",
|
||||
"room_id": "!eGvUQuTCkHGVwNMOjv:matrix.org",
|
||||
"sender": "@foobar:matrix.org",
|
||||
"user_id": "@bar:matrix.org"
|
||||
}
|
||||
],
|
||||
"next_token": 2,
|
||||
"total": 4
|
||||
}
|
||||
|
||||
To paginate, check for ``next_token`` and if present, call the endpoint again
|
||||
with ``from`` set to the value of ``next_token``. This will return a new page.
|
||||
|
||||
If the endpoint does not return a ``next_token`` then there are no more
|
||||
reports to paginate through.
|
||||
|
||||
**URL parameters:**
|
||||
|
||||
- ``limit``: integer - Is optional but is used for pagination,
|
||||
denoting the maximum number of items to return in this call. Defaults to ``100``.
|
||||
- ``from``: integer - Is optional but used for pagination,
|
||||
denoting the offset in the returned results. This should be treated as an opaque value and
|
||||
not explicitly set to anything other than the return value of ``next_token`` from a previous call.
|
||||
Defaults to ``0``.
|
||||
- ``dir``: string - Direction of event report order. Whether to fetch the most recent first (``b``) or the
|
||||
oldest first (``f``). Defaults to ``b``.
|
||||
- ``user_id``: string - Is optional and filters to only return users with user IDs that contain this value.
|
||||
This is the user who reported the event and wrote the reason.
|
||||
- ``room_id``: string - Is optional and filters to only return rooms with room IDs that contain this value.
|
||||
|
||||
**Response**
|
||||
|
||||
The following fields are returned in the JSON response body:
|
||||
|
||||
- ``id``: integer - ID of event report.
|
||||
- ``received_ts``: integer - The timestamp (in milliseconds since the unix epoch) when this report was sent.
|
||||
- ``room_id``: string - The ID of the room in which the event being reported is located.
|
||||
- ``event_id``: string - The ID of the reported event.
|
||||
- ``user_id``: string - This is the user who reported the event and wrote the reason.
|
||||
- ``reason``: string - Comment made by the ``user_id`` in this report. May be blank.
|
||||
- ``content``: object - Content of reported event.
|
||||
|
||||
- ``reason``: string - Comment made by the ``user_id`` in this report. May be blank.
|
||||
- ``score``: integer - Content is reported based upon a negative score, where -100 is "most offensive" and 0 is "inoffensive".
|
||||
|
||||
- ``sender``: string - This is the ID of the user who sent the original message/event that was reported.
|
||||
- ``room_alias``: string - The alias of the room. ``null`` if the room does not have a canonical alias set.
|
||||
- ``event_json``: object - Details of the original event that was reported.
|
||||
- ``next_token``: integer - Indication for pagination. See above.
|
||||
- ``total``: integer - Total number of event reports related to the query (``user_id`` and ``room_id``).
|
||||
|
||||
@@ -275,6 +275,8 @@ The following fields are possible in the JSON response body:
|
||||
|
||||
* `room_id` - The ID of the room.
|
||||
* `name` - The name of the room.
|
||||
* `topic` - The topic of the room.
|
||||
* `avatar` - The `mxc` URI to the avatar of the room.
|
||||
* `canonical_alias` - The canonical (main) alias address of the room.
|
||||
* `joined_members` - How many users are currently in the room.
|
||||
* `joined_local_members` - How many local users are currently in the room.
|
||||
@@ -304,6 +306,8 @@ Response:
|
||||
{
|
||||
"room_id": "!mscvqgqpHYjBGDxNym:matrix.org",
|
||||
"name": "Music Theory",
|
||||
"avatar": "mxc://matrix.org/AQDaVFlbkQoErdOgqWRgiGSV",
|
||||
"topic": "Theory, Composition, Notation, Analysis",
|
||||
"canonical_alias": "#musictheory:matrix.org",
|
||||
"joined_members": 127
|
||||
"joined_local_members": 2,
|
||||
|
||||
@@ -304,6 +304,43 @@ To use it, you will need to authenticate by providing an ``access_token`` for a
|
||||
server admin: see `README.rst <README.rst>`_.
|
||||
|
||||
|
||||
List room memberships of an user
|
||||
================================
|
||||
Gets a list of all ``room_id`` that a specific ``user_id`` is member.
|
||||
|
||||
The API is::
|
||||
|
||||
GET /_synapse/admin/v1/users/<user_id>/joined_rooms
|
||||
|
||||
To use it, you will need to authenticate by providing an ``access_token`` for a
|
||||
server admin: see `README.rst <README.rst>`_.
|
||||
|
||||
A response body like the following is returned:
|
||||
|
||||
.. code:: json
|
||||
|
||||
{
|
||||
"joined_rooms": [
|
||||
"!DuGcnbhHGaSZQoNQR:matrix.org",
|
||||
"!ZtSaPCawyWtxfWiIy:matrix.org"
|
||||
],
|
||||
"total": 2
|
||||
}
|
||||
|
||||
**Parameters**
|
||||
|
||||
The following parameters should be set in the URL:
|
||||
|
||||
- ``user_id`` - fully qualified: for example, ``@user:server.com``.
|
||||
|
||||
**Response**
|
||||
|
||||
The following fields are returned in the JSON response body:
|
||||
|
||||
- ``joined_rooms`` - An array of ``room_id``.
|
||||
- ``total`` - Number of rooms.
|
||||
|
||||
|
||||
User devices
|
||||
============
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ privileges.
|
||||
|
||||
**NOTE**: Your reverse proxy must not `canonicalise` or `normalise`
|
||||
the requested URI in any way (for example, by decoding `%xx` escapes).
|
||||
Beware that Apache *will* canonicalise URIs unless you specifify
|
||||
Beware that Apache *will* canonicalise URIs unless you specify
|
||||
`nocanon`.
|
||||
|
||||
When setting up a reverse proxy, remember that Matrix clients and other
|
||||
@@ -23,6 +23,10 @@ specification](https://matrix.org/docs/spec/server_server/latest#resolving-serve
|
||||
for more details of the algorithm used for federation connections, and
|
||||
[delegate.md](<delegate.md>) for instructions on setting up delegation.
|
||||
|
||||
Endpoints that are part of the standardised Matrix specification are
|
||||
located under `/_matrix`, whereas endpoints specific to Synapse are
|
||||
located under `/_synapse/client`.
|
||||
|
||||
Let's assume that we expect clients to connect to our server at
|
||||
`https://matrix.example.com`, and other servers to connect at
|
||||
`https://example.com:8448`. The following sections detail the configuration of
|
||||
@@ -45,7 +49,7 @@ server {
|
||||
|
||||
server_name matrix.example.com;
|
||||
|
||||
location /_matrix {
|
||||
location ~* ^(\/_matrix|\/_synapse\/client) {
|
||||
proxy_pass http://localhost:8008;
|
||||
proxy_set_header X-Forwarded-For $remote_addr;
|
||||
# Nginx by default only allows file uploads up to 1M in size
|
||||
@@ -65,6 +69,10 @@ matrix.example.com {
|
||||
proxy /_matrix http://localhost:8008 {
|
||||
transparent
|
||||
}
|
||||
|
||||
proxy /_synapse/client http://localhost:8008 {
|
||||
transparent
|
||||
}
|
||||
}
|
||||
|
||||
example.com:8448 {
|
||||
@@ -79,6 +87,7 @@ example.com:8448 {
|
||||
```
|
||||
matrix.example.com {
|
||||
reverse_proxy /_matrix/* http://localhost:8008
|
||||
reverse_proxy /_synapse/client/* http://localhost:8008
|
||||
}
|
||||
|
||||
example.com:8448 {
|
||||
@@ -96,6 +105,8 @@ example.com:8448 {
|
||||
AllowEncodedSlashes NoDecode
|
||||
ProxyPass /_matrix http://127.0.0.1:8008/_matrix nocanon
|
||||
ProxyPassReverse /_matrix http://127.0.0.1:8008/_matrix
|
||||
ProxyPass /_synapse/client http://127.0.0.1:8008/_synapse/client nocanon
|
||||
ProxyPassReverse /_synapse/client http://127.0.0.1:8008/_synapse/client
|
||||
</VirtualHost>
|
||||
|
||||
<VirtualHost *:8448>
|
||||
@@ -110,6 +121,14 @@ example.com:8448 {
|
||||
|
||||
**NOTE**: ensure the `nocanon` options are included.
|
||||
|
||||
**NOTE 2**: It appears that Synapse is currently incompatible with the ModSecurity module for Apache (`mod_security2`). If you need it enabled for other services on your web server, you can disable it for Synapse's two VirtualHosts by including the following lines before each of the two `</VirtualHost>` above:
|
||||
|
||||
```
|
||||
<IfModule security2_module>
|
||||
SecRuleEngine off
|
||||
</IfModule>
|
||||
```
|
||||
|
||||
### HAProxy
|
||||
|
||||
```
|
||||
@@ -119,6 +138,7 @@ frontend https
|
||||
# Matrix client traffic
|
||||
acl matrix-host hdr(host) -i matrix.example.com
|
||||
acl matrix-path path_beg /_matrix
|
||||
acl matrix-path path_beg /_synapse/client
|
||||
|
||||
use_backend matrix if matrix-host matrix-path
|
||||
|
||||
@@ -146,3 +166,10 @@ connecting to Synapse from a client.
|
||||
Synapse exposes a health check endpoint for use by reverse proxies.
|
||||
Each configured HTTP listener has a `/health` endpoint which always returns
|
||||
200 OK (and doesn't get logged).
|
||||
|
||||
## Synapse administration endpoints
|
||||
|
||||
Endpoints for administering your Synapse instance are placed under
|
||||
`/_synapse/admin`. These require authentication through an access token of an
|
||||
admin user. However as access to these endpoints grants the caller a lot of power,
|
||||
we do not recommend exposing them to the public internet without good reason.
|
||||
|
||||
@@ -432,6 +432,24 @@ retention:
|
||||
#
|
||||
#request_token_inhibit_3pid_errors: true
|
||||
|
||||
# A list of domains that the domain portion of 'next_link' parameters
|
||||
# must match.
|
||||
#
|
||||
# This parameter is optionally provided by clients while requesting
|
||||
# validation of an email or phone number, and maps to a link that
|
||||
# users will be automatically redirected to after validation
|
||||
# succeeds. Clients can make use this parameter to aid the validation
|
||||
# process.
|
||||
#
|
||||
# The whitelist is applied whether the homeserver or an
|
||||
# identity server is handling validation.
|
||||
#
|
||||
# The default value is no whitelist functionality; all domains are
|
||||
# allowed. Setting this value to an empty list will instead disallow
|
||||
# all domains.
|
||||
#
|
||||
#next_link_domain_whitelist: ["matrix.org"]
|
||||
|
||||
|
||||
## TLS ##
|
||||
|
||||
@@ -1467,11 +1485,14 @@ trusted_key_servers:
|
||||
# At least one of `sp_config` or `config_path` must be set in this section to
|
||||
# enable SAML login.
|
||||
#
|
||||
# (You will probably also want to set the following options to `false` to
|
||||
# You will probably also want to set the following options to `false` to
|
||||
# disable the regular login/registration flows:
|
||||
# * enable_registration
|
||||
# * password_config.enabled
|
||||
#
|
||||
# You will also want to investigate the settings under the "sso" configuration
|
||||
# section below.
|
||||
#
|
||||
# Once SAML support is enabled, a metadata file will be exposed at
|
||||
# https://<server>:<port>/_matrix/saml2/metadata.xml, which you may be able to
|
||||
# use to configure your SAML IdP with. Alternatively, you can manually configure
|
||||
@@ -1594,31 +1615,6 @@ saml2_config:
|
||||
# - attribute: department
|
||||
# value: "sales"
|
||||
|
||||
# Directory in which Synapse will try to find the template files below.
|
||||
# If not set, default templates from within the Synapse package will be used.
|
||||
#
|
||||
# DO NOT UNCOMMENT THIS SETTING unless you want to customise the templates.
|
||||
# If you *do* uncomment it, you will need to make sure that all the templates
|
||||
# below are in the directory.
|
||||
#
|
||||
# Synapse will look for the following templates in this directory:
|
||||
#
|
||||
# * HTML page to display to users if something goes wrong during the
|
||||
# authentication process: 'saml_error.html'.
|
||||
#
|
||||
# When rendering, this template is given the following variables:
|
||||
# * code: an HTML error code corresponding to the error that is being
|
||||
# returned (typically 400 or 500)
|
||||
#
|
||||
# * msg: a textual message describing the error.
|
||||
#
|
||||
# The variables will automatically be HTML-escaped.
|
||||
#
|
||||
# You can see the default templates at:
|
||||
# https://github.com/matrix-org/synapse/tree/master/synapse/res/templates
|
||||
#
|
||||
#template_dir: "res/templates"
|
||||
|
||||
|
||||
# OpenID Connect integration. The following settings can be used to make Synapse
|
||||
# use an OpenID Connect Provider for authentication, instead of its internal
|
||||
@@ -1693,6 +1689,11 @@ oidc_config:
|
||||
#
|
||||
#skip_verification: true
|
||||
|
||||
# Uncomment to allow a user logging in via OIDC to match a pre-existing account instead
|
||||
# of failing. This could be used if switching from password logins to OIDC. Defaults to false.
|
||||
#
|
||||
#allow_existing_users: true
|
||||
|
||||
# An external module can be provided here as a custom solution to mapping
|
||||
# attributes returned from a OIDC provider onto a matrix user.
|
||||
#
|
||||
@@ -2021,9 +2022,13 @@ email:
|
||||
# * The contents of password reset emails sent by the homeserver:
|
||||
# 'password_reset.html' and 'password_reset.txt'
|
||||
#
|
||||
# * HTML pages for success and failure that a user will see when they follow
|
||||
# the link in the password reset email: 'password_reset_success.html' and
|
||||
# 'password_reset_failure.html'
|
||||
# * An HTML page that a user will see when they follow the link in the password
|
||||
# reset email. The user will be asked to confirm the action before their
|
||||
# password is reset: 'password_reset_confirmation.html'
|
||||
#
|
||||
# * HTML pages for success and failure that a user will see when they confirm
|
||||
# the password reset flow using the page above: 'password_reset_success.html'
|
||||
# and 'password_reset_failure.html'
|
||||
#
|
||||
# * The contents of address verification emails sent during registration:
|
||||
# 'registration.html' and 'registration.txt'
|
||||
|
||||
@@ -217,6 +217,7 @@ expressions:
|
||||
^/_matrix/client/(api/v1|r0|unstable)/joined_groups$
|
||||
^/_matrix/client/(api/v1|r0|unstable)/publicised_groups$
|
||||
^/_matrix/client/(api/v1|r0|unstable)/publicised_groups/
|
||||
^/_synapse/client/password_reset/email/submit_token$
|
||||
|
||||
# Registration/login requests
|
||||
^/_matrix/client/(api/v1|r0|unstable)/login$
|
||||
|
||||
5
mypy.ini
5
mypy.ini
@@ -34,7 +34,7 @@ files =
|
||||
synapse/http/federation/well_known_resolver.py,
|
||||
synapse/http/server.py,
|
||||
synapse/http/site.py,
|
||||
synapse/logging/,
|
||||
synapse/logging,
|
||||
synapse/metrics,
|
||||
synapse/module_api,
|
||||
synapse/notifier.py,
|
||||
@@ -46,14 +46,17 @@ files =
|
||||
synapse/server_notices,
|
||||
synapse/spam_checker_api,
|
||||
synapse/state,
|
||||
synapse/storage/databases/main/events.py,
|
||||
synapse/storage/databases/main/stream.py,
|
||||
synapse/storage/databases/main/ui_auth.py,
|
||||
synapse/storage/database.py,
|
||||
synapse/storage/engines,
|
||||
synapse/storage/persist_events.py,
|
||||
synapse/storage/state.py,
|
||||
synapse/storage/util,
|
||||
synapse/streams,
|
||||
synapse/types.py,
|
||||
synapse/util/async_helpers.py,
|
||||
synapse/util/caches/descriptors.py,
|
||||
synapse/util/caches/stream_change_cache.py,
|
||||
synapse/util/metrics.py,
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
#! /usr/bin/python
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import argparse
|
||||
import ast
|
||||
import os
|
||||
@@ -13,7 +11,7 @@ import yaml
|
||||
|
||||
class DefinitionVisitor(ast.NodeVisitor):
|
||||
def __init__(self):
|
||||
super(DefinitionVisitor, self).__init__()
|
||||
super().__init__()
|
||||
self.functions = {}
|
||||
self.classes = {}
|
||||
self.names = {}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
#!/usr/bin/env python2
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import sys
|
||||
|
||||
import pymacaroons
|
||||
|
||||
@@ -15,8 +15,6 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import argparse
|
||||
import base64
|
||||
import json
|
||||
@@ -323,7 +321,7 @@ class MatrixConnectionAdapter(HTTPAdapter):
|
||||
url = urlparse.urlunparse(
|
||||
("https", netloc, parsed.path, parsed.params, parsed.query, parsed.fragment)
|
||||
)
|
||||
return super(MatrixConnectionAdapter, self).get_connection(url, proxies)
|
||||
return super().get_connection(url, proxies)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
from __future__ import print_function
|
||||
|
||||
import sqlite3
|
||||
import sys
|
||||
|
||||
|
||||
@@ -32,8 +32,6 @@ To use, pipe the above into::
|
||||
PYTHON_PATH=. ./scripts/move_remote_media_to_new_store.py <source repo> <dest repo>
|
||||
"""
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import argparse
|
||||
import logging
|
||||
import os
|
||||
|
||||
@@ -14,8 +14,6 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
from synapse._scripts.register_new_matrix_user import main
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -628,6 +628,7 @@ class Porter(object):
|
||||
self.progress.set_state("Setting up sequence generators")
|
||||
await self._setup_state_group_id_seq()
|
||||
await self._setup_user_id_seq()
|
||||
await self._setup_events_stream_seqs()
|
||||
|
||||
self.progress.done()
|
||||
except Exception as e:
|
||||
@@ -804,6 +805,29 @@ class Porter(object):
|
||||
|
||||
return self.postgres_store.db_pool.runInteraction("setup_user_id_seq", r)
|
||||
|
||||
def _setup_events_stream_seqs(self):
|
||||
def r(txn):
|
||||
txn.execute("SELECT MAX(stream_ordering) FROM events")
|
||||
curr_id = txn.fetchone()[0]
|
||||
if curr_id:
|
||||
next_id = curr_id + 1
|
||||
txn.execute(
|
||||
"ALTER SEQUENCE events_stream_seq RESTART WITH %s", (next_id,)
|
||||
)
|
||||
|
||||
txn.execute("SELECT -MIN(stream_ordering) FROM events")
|
||||
curr_id = txn.fetchone()[0]
|
||||
if curr_id:
|
||||
next_id = curr_id + 1
|
||||
txn.execute(
|
||||
"ALTER SEQUENCE events_backfill_stream_seq RESTART WITH %s",
|
||||
(next_id,),
|
||||
)
|
||||
|
||||
return self.postgres_store.db_pool.runInteraction(
|
||||
"_setup_events_stream_seqs", r
|
||||
)
|
||||
|
||||
|
||||
##############################################
|
||||
# The following is simply UI stuff
|
||||
|
||||
16
setup.py
16
setup.py
@@ -94,6 +94,22 @@ ALL_OPTIONAL_REQUIREMENTS = dependencies["ALL_OPTIONAL_REQUIREMENTS"]
|
||||
# Make `pip install matrix-synapse[all]` install all the optional dependencies.
|
||||
CONDITIONAL_REQUIREMENTS["all"] = list(ALL_OPTIONAL_REQUIREMENTS)
|
||||
|
||||
# Developer dependencies should not get included in "all".
|
||||
#
|
||||
# We pin black so that our tests don't start failing on new releases.
|
||||
CONDITIONAL_REQUIREMENTS["lint"] = [
|
||||
"isort==5.0.3",
|
||||
"black==19.10b0",
|
||||
"flake8-comprehensions",
|
||||
"flake8",
|
||||
]
|
||||
|
||||
# Dependencies which are exclusively required by unit test code. This is
|
||||
# NOT a list of all modules that are necessary to run the unit tests.
|
||||
# Tests assume that all optional dependencies are installed.
|
||||
#
|
||||
# parameterized_class decorator was introduced in parameterized 0.7.0
|
||||
CONDITIONAL_REQUIREMENTS["test"] = ["mock>=2.0", "parameterized>=0.7.0"]
|
||||
|
||||
setup(
|
||||
name="matrix-synapse",
|
||||
|
||||
@@ -14,8 +14,6 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import argparse
|
||||
import getpass
|
||||
import hashlib
|
||||
|
||||
@@ -218,11 +218,7 @@ class Auth:
|
||||
# Deny the request if the user account has expired.
|
||||
if self._account_validity.enabled and not allow_expired:
|
||||
user_id = user.to_string()
|
||||
expiration_ts = await self.store.get_expiration_ts_for_user(user_id)
|
||||
if (
|
||||
expiration_ts is not None
|
||||
and self.clock.time_msec() >= expiration_ts
|
||||
):
|
||||
if await self.store.is_account_expired(user_id, self.clock.time_msec()):
|
||||
raise AuthError(
|
||||
403, "User account has expired", errcode=Codes.EXPIRED_ACCOUNT
|
||||
)
|
||||
|
||||
@@ -87,7 +87,7 @@ class CodeMessageException(RuntimeError):
|
||||
"""
|
||||
|
||||
def __init__(self, code: Union[int, HTTPStatus], msg: str):
|
||||
super(CodeMessageException, self).__init__("%d: %s" % (code, msg))
|
||||
super().__init__("%d: %s" % (code, msg))
|
||||
|
||||
# Some calls to this method pass instances of http.HTTPStatus for `code`.
|
||||
# While HTTPStatus is a subclass of int, it has magic __str__ methods
|
||||
@@ -138,7 +138,7 @@ class SynapseError(CodeMessageException):
|
||||
msg: The human-readable error message.
|
||||
errcode: The matrix error code e.g 'M_FORBIDDEN'
|
||||
"""
|
||||
super(SynapseError, self).__init__(code, msg)
|
||||
super().__init__(code, msg)
|
||||
self.errcode = errcode
|
||||
|
||||
def error_dict(self):
|
||||
@@ -159,7 +159,7 @@ class ProxiedRequestError(SynapseError):
|
||||
errcode: str = Codes.UNKNOWN,
|
||||
additional_fields: Optional[Dict] = None,
|
||||
):
|
||||
super(ProxiedRequestError, self).__init__(code, msg, errcode)
|
||||
super().__init__(code, msg, errcode)
|
||||
if additional_fields is None:
|
||||
self._additional_fields = {} # type: Dict
|
||||
else:
|
||||
@@ -181,7 +181,7 @@ class ConsentNotGivenError(SynapseError):
|
||||
msg: The human-readable error message
|
||||
consent_url: The URL where the user can give their consent
|
||||
"""
|
||||
super(ConsentNotGivenError, self).__init__(
|
||||
super().__init__(
|
||||
code=HTTPStatus.FORBIDDEN, msg=msg, errcode=Codes.CONSENT_NOT_GIVEN
|
||||
)
|
||||
self._consent_uri = consent_uri
|
||||
@@ -201,7 +201,7 @@ class UserDeactivatedError(SynapseError):
|
||||
Args:
|
||||
msg: The human-readable error message
|
||||
"""
|
||||
super(UserDeactivatedError, self).__init__(
|
||||
super().__init__(
|
||||
code=HTTPStatus.FORBIDDEN, msg=msg, errcode=Codes.USER_DEACTIVATED
|
||||
)
|
||||
|
||||
@@ -225,7 +225,7 @@ class FederationDeniedError(SynapseError):
|
||||
|
||||
self.destination = destination
|
||||
|
||||
super(FederationDeniedError, self).__init__(
|
||||
super().__init__(
|
||||
code=403,
|
||||
msg="Federation denied with %s." % (self.destination,),
|
||||
errcode=Codes.FORBIDDEN,
|
||||
@@ -244,9 +244,7 @@ class InteractiveAuthIncompleteError(Exception):
|
||||
"""
|
||||
|
||||
def __init__(self, session_id: str, result: "JsonDict"):
|
||||
super(InteractiveAuthIncompleteError, self).__init__(
|
||||
"Interactive auth not yet complete"
|
||||
)
|
||||
super().__init__("Interactive auth not yet complete")
|
||||
self.session_id = session_id
|
||||
self.result = result
|
||||
|
||||
@@ -261,14 +259,14 @@ class UnrecognizedRequestError(SynapseError):
|
||||
message = "Unrecognized request"
|
||||
else:
|
||||
message = args[0]
|
||||
super(UnrecognizedRequestError, self).__init__(400, message, **kwargs)
|
||||
super().__init__(400, message, **kwargs)
|
||||
|
||||
|
||||
class NotFoundError(SynapseError):
|
||||
"""An error indicating we can't find the thing you asked for"""
|
||||
|
||||
def __init__(self, msg: str = "Not found", errcode: str = Codes.NOT_FOUND):
|
||||
super(NotFoundError, self).__init__(404, msg, errcode=errcode)
|
||||
super().__init__(404, msg, errcode=errcode)
|
||||
|
||||
|
||||
class AuthError(SynapseError):
|
||||
@@ -279,7 +277,7 @@ class AuthError(SynapseError):
|
||||
def __init__(self, *args, **kwargs):
|
||||
if "errcode" not in kwargs:
|
||||
kwargs["errcode"] = Codes.FORBIDDEN
|
||||
super(AuthError, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
|
||||
class InvalidClientCredentialsError(SynapseError):
|
||||
@@ -335,7 +333,7 @@ class ResourceLimitError(SynapseError):
|
||||
):
|
||||
self.admin_contact = admin_contact
|
||||
self.limit_type = limit_type
|
||||
super(ResourceLimitError, self).__init__(code, msg, errcode=errcode)
|
||||
super().__init__(code, msg, errcode=errcode)
|
||||
|
||||
def error_dict(self):
|
||||
return cs_error(
|
||||
@@ -352,7 +350,7 @@ class EventSizeError(SynapseError):
|
||||
def __init__(self, *args, **kwargs):
|
||||
if "errcode" not in kwargs:
|
||||
kwargs["errcode"] = Codes.TOO_LARGE
|
||||
super(EventSizeError, self).__init__(413, *args, **kwargs)
|
||||
super().__init__(413, *args, **kwargs)
|
||||
|
||||
|
||||
class EventStreamError(SynapseError):
|
||||
@@ -361,7 +359,7 @@ class EventStreamError(SynapseError):
|
||||
def __init__(self, *args, **kwargs):
|
||||
if "errcode" not in kwargs:
|
||||
kwargs["errcode"] = Codes.BAD_PAGINATION
|
||||
super(EventStreamError, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
|
||||
class LoginError(SynapseError):
|
||||
@@ -384,7 +382,7 @@ class InvalidCaptchaError(SynapseError):
|
||||
error_url: Optional[str] = None,
|
||||
errcode: str = Codes.CAPTCHA_INVALID,
|
||||
):
|
||||
super(InvalidCaptchaError, self).__init__(code, msg, errcode)
|
||||
super().__init__(code, msg, errcode)
|
||||
self.error_url = error_url
|
||||
|
||||
def error_dict(self):
|
||||
@@ -402,7 +400,7 @@ class LimitExceededError(SynapseError):
|
||||
retry_after_ms: Optional[int] = None,
|
||||
errcode: str = Codes.LIMIT_EXCEEDED,
|
||||
):
|
||||
super(LimitExceededError, self).__init__(code, msg, errcode)
|
||||
super().__init__(code, msg, errcode)
|
||||
self.retry_after_ms = retry_after_ms
|
||||
|
||||
def error_dict(self):
|
||||
@@ -418,9 +416,7 @@ class RoomKeysVersionError(SynapseError):
|
||||
Args:
|
||||
current_version: the current version of the store they should have used
|
||||
"""
|
||||
super(RoomKeysVersionError, self).__init__(
|
||||
403, "Wrong room_keys version", Codes.WRONG_ROOM_KEYS_VERSION
|
||||
)
|
||||
super().__init__(403, "Wrong room_keys version", Codes.WRONG_ROOM_KEYS_VERSION)
|
||||
self.current_version = current_version
|
||||
|
||||
|
||||
@@ -429,7 +425,7 @@ class UnsupportedRoomVersionError(SynapseError):
|
||||
not support."""
|
||||
|
||||
def __init__(self, msg: str = "Homeserver does not support this room version"):
|
||||
super(UnsupportedRoomVersionError, self).__init__(
|
||||
super().__init__(
|
||||
code=400, msg=msg, errcode=Codes.UNSUPPORTED_ROOM_VERSION,
|
||||
)
|
||||
|
||||
@@ -440,7 +436,7 @@ class ThreepidValidationError(SynapseError):
|
||||
def __init__(self, *args, **kwargs):
|
||||
if "errcode" not in kwargs:
|
||||
kwargs["errcode"] = Codes.FORBIDDEN
|
||||
super(ThreepidValidationError, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
|
||||
class IncompatibleRoomVersionError(SynapseError):
|
||||
@@ -451,7 +447,7 @@ class IncompatibleRoomVersionError(SynapseError):
|
||||
"""
|
||||
|
||||
def __init__(self, room_version: str):
|
||||
super(IncompatibleRoomVersionError, self).__init__(
|
||||
super().__init__(
|
||||
code=400,
|
||||
msg="Your homeserver does not support the features required to "
|
||||
"join this room",
|
||||
@@ -473,7 +469,7 @@ class PasswordRefusedError(SynapseError):
|
||||
msg: str = "This password doesn't comply with the server's policy",
|
||||
errcode: str = Codes.WEAK_PASSWORD,
|
||||
):
|
||||
super(PasswordRefusedError, self).__init__(
|
||||
super().__init__(
|
||||
code=400, msg=msg, errcode=errcode,
|
||||
)
|
||||
|
||||
@@ -488,7 +484,7 @@ class RequestSendFailed(RuntimeError):
|
||||
"""
|
||||
|
||||
def __init__(self, inner_exception, can_retry):
|
||||
super(RequestSendFailed, self).__init__(
|
||||
super().__init__(
|
||||
"Failed to send request: %s: %s"
|
||||
% (type(inner_exception).__name__, inner_exception)
|
||||
)
|
||||
@@ -542,7 +538,7 @@ class FederationError(RuntimeError):
|
||||
self.source = source
|
||||
|
||||
msg = "%s %s: %s" % (level, code, reason)
|
||||
super(FederationError, self).__init__(msg)
|
||||
super().__init__(msg)
|
||||
|
||||
def get_dict(self):
|
||||
return {
|
||||
@@ -570,7 +566,7 @@ class HttpResponseException(CodeMessageException):
|
||||
msg: reason phrase from HTTP response status line
|
||||
response: body of response
|
||||
"""
|
||||
super(HttpResponseException, self).__init__(code, msg)
|
||||
super().__init__(code, msg)
|
||||
self.response = response
|
||||
|
||||
def to_synapse_error(self):
|
||||
|
||||
@@ -15,10 +15,10 @@
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
import json
|
||||
from typing import List
|
||||
|
||||
import jsonschema
|
||||
from canonicaljson import json
|
||||
from jsonschema import FormatChecker
|
||||
|
||||
from synapse.api.constants import EventContentFields
|
||||
@@ -132,7 +132,7 @@ def matrix_user_id_validator(user_id_str):
|
||||
|
||||
class Filtering:
|
||||
def __init__(self, hs):
|
||||
super(Filtering, self).__init__()
|
||||
super().__init__()
|
||||
self.store = hs.get_datastore()
|
||||
|
||||
async def get_user_filter(self, user_localpart, filter_id):
|
||||
|
||||
@@ -21,6 +21,7 @@ from urllib.parse import urlencode
|
||||
|
||||
from synapse.config import ConfigError
|
||||
|
||||
SYNAPSE_CLIENT_API_PREFIX = "/_synapse/client"
|
||||
CLIENT_API_PREFIX = "/_matrix/client"
|
||||
FEDERATION_PREFIX = "/_matrix/federation"
|
||||
FEDERATION_V1_PREFIX = FEDERATION_PREFIX + "/v1"
|
||||
|
||||
@@ -14,13 +14,12 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
import argparse
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
from canonicaljson import json
|
||||
|
||||
from twisted.internet import defer, task
|
||||
|
||||
import synapse
|
||||
|
||||
@@ -152,7 +152,7 @@ class PresenceStatusStubServlet(RestServlet):
|
||||
PATTERNS = client_patterns("/presence/(?P<user_id>[^/]*)/status")
|
||||
|
||||
def __init__(self, hs):
|
||||
super(PresenceStatusStubServlet, self).__init__()
|
||||
super().__init__()
|
||||
self.auth = hs.get_auth()
|
||||
|
||||
async def on_GET(self, request, user_id):
|
||||
@@ -176,7 +176,7 @@ class KeyUploadServlet(RestServlet):
|
||||
Args:
|
||||
hs (synapse.server.HomeServer): server
|
||||
"""
|
||||
super(KeyUploadServlet, self).__init__()
|
||||
super().__init__()
|
||||
self.auth = hs.get_auth()
|
||||
self.store = hs.get_datastore()
|
||||
self.http_client = hs.get_simple_http_client()
|
||||
@@ -646,7 +646,7 @@ class GenericWorkerServer(HomeServer):
|
||||
|
||||
class GenericWorkerReplicationHandler(ReplicationDataHandler):
|
||||
def __init__(self, hs):
|
||||
super(GenericWorkerReplicationHandler, self).__init__(hs)
|
||||
super().__init__(hs)
|
||||
|
||||
self.store = hs.get_datastore()
|
||||
self.presence_handler = hs.get_presence_handler() # type: GenericWorkerPresence
|
||||
|
||||
@@ -15,8 +15,6 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import gc
|
||||
import logging
|
||||
import math
|
||||
@@ -48,6 +46,7 @@ from synapse.api.urls import (
|
||||
from synapse.app import _base
|
||||
from synapse.app._base import listen_ssl, listen_tcp, quit_with_error
|
||||
from synapse.config._base import ConfigError
|
||||
from synapse.config.emailconfig import ThreepidBehaviour
|
||||
from synapse.config.homeserver import HomeServerConfig
|
||||
from synapse.config.server import ListenerConfig
|
||||
from synapse.federation.transport.server import TransportLayerServer
|
||||
@@ -209,6 +208,15 @@ class SynapseHomeServer(HomeServer):
|
||||
|
||||
resources["/_matrix/saml2"] = SAML2Resource(self)
|
||||
|
||||
if self.get_config().threepid_behaviour_email == ThreepidBehaviour.LOCAL:
|
||||
from synapse.rest.synapse.client.password_reset import (
|
||||
PasswordResetSubmitTokenResource,
|
||||
)
|
||||
|
||||
resources[
|
||||
"/_synapse/client/password_reset/email/submit_token"
|
||||
] = PasswordResetSubmitTokenResource(self)
|
||||
|
||||
if name == "consent":
|
||||
from synapse.rest.consent.consent_resource import ConsentResource
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ class ApplicationServiceApi(SimpleHttpClient):
|
||||
"""
|
||||
|
||||
def __init__(self, hs):
|
||||
super(ApplicationServiceApi, self).__init__(hs)
|
||||
super().__init__(hs)
|
||||
self.clock = hs.get_clock()
|
||||
|
||||
self.protocol_meta_cache = ResponseCache(
|
||||
@@ -178,7 +178,7 @@ class ApplicationServiceApi(SimpleHttpClient):
|
||||
urllib.parse.quote(protocol),
|
||||
)
|
||||
try:
|
||||
info = await self.get_json(uri, {})
|
||||
info = await self.get_json(uri)
|
||||
|
||||
if not _is_valid_3pe_metadata(info):
|
||||
logger.warning(
|
||||
|
||||
@@ -838,11 +838,26 @@ class ShardedWorkerHandlingConfig:
|
||||
def should_handle(self, instance_name: str, key: str) -> bool:
|
||||
"""Whether this instance is responsible for handling the given key.
|
||||
"""
|
||||
|
||||
# If multiple instances are not defined we always return true.
|
||||
# If multiple instances are not defined we always return true
|
||||
if not self.instances or len(self.instances) == 1:
|
||||
return True
|
||||
|
||||
return self.get_instance(key) == instance_name
|
||||
|
||||
def get_instance(self, key: str) -> str:
|
||||
"""Get the instance responsible for handling the given key.
|
||||
|
||||
Note: For things like federation sending the config for which instance
|
||||
is sending is known only to the sender instance if there is only one.
|
||||
Therefore `should_handle` should be used where possible.
|
||||
"""
|
||||
|
||||
if not self.instances:
|
||||
return "master"
|
||||
|
||||
if len(self.instances) == 1:
|
||||
return self.instances[0]
|
||||
|
||||
# We shard by taking the hash, modulo it by the number of instances and
|
||||
# then checking whether this instance matches the instance at that
|
||||
# index.
|
||||
@@ -852,7 +867,7 @@ class ShardedWorkerHandlingConfig:
|
||||
dest_hash = sha256(key.encode("utf8")).digest()
|
||||
dest_int = int.from_bytes(dest_hash, byteorder="little")
|
||||
remainder = dest_int % (len(self.instances))
|
||||
return self.instances[remainder] == instance_name
|
||||
return self.instances[remainder]
|
||||
|
||||
|
||||
__all__ = ["Config", "RootConfig", "ShardedWorkerHandlingConfig"]
|
||||
|
||||
@@ -35,6 +35,7 @@ from synapse.config import (
|
||||
workers,
|
||||
)
|
||||
|
||||
|
||||
class ConfigError(Exception): ...
|
||||
|
||||
MISSING_REPORT_STATS_CONFIG_INSTRUCTIONS: str
|
||||
@@ -142,3 +143,4 @@ class ShardedWorkerHandlingConfig:
|
||||
instances: List[str]
|
||||
def __init__(self, instances: List[str]) -> None: ...
|
||||
def should_handle(self, instance_name: str, key: str) -> bool: ...
|
||||
def get_instance(self, key: str) -> str: ...
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user