From f279a43dc8057e2f996455a60ee5d2df85afa932 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Wed, 6 Jan 2021 14:44:28 +0200 Subject: [PATCH] Add option to allow anyone to use timestamp massaging --- README.md | 7 ++++++- synapse/config/meow.py | 4 ++++ synapse/rest/client/v1/room.py | 7 +++++-- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index c19795320..73fe52c24 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,9 @@ use the specific release tags. * Config option to allow specific users to send events without unnecessary validation. * Config option to allow specific users to receive events that are usually - filtered away (e.g. `org.matrix.dummy_event` and `m.room.aliases`) + filtered away (e.g. `org.matrix.dummy_event` and `m.room.aliases`). +* Config option to allow specific users to use timestamp massaging without + being appservice users. ## Configuration Generating a new config will include the `meow` section, but this is here for @@ -42,4 +44,7 @@ meow: - "@you:example.com" # Whether or not the admin API should be able to register invalid user IDs. admin_api_register_invalid: true + # List of users who can use timestamp massaging without being appservices + timestamp_override: + - "@you:example.com" ``` diff --git a/synapse/config/meow.py b/synapse/config/meow.py index ccd368b1d..8c2cba47e 100644 --- a/synapse/config/meow.py +++ b/synapse/config/meow.py @@ -27,6 +27,7 @@ class MeowConfig(Config): meow_config = config.get("meow", {}) self.validation_override = set(meow_config.get("validation_override", [])) self.filter_override = set(meow_config.get("filter_override", [])) + self.timestamp_override = set(meow_config.get("timestamp_override", [])) self.admin_api_register_invalid = meow_config.get("admin_api_register_invalid", True) def generate_config_section(self, config_dir_path, server_name, **kwargs): @@ -40,6 +41,9 @@ class MeowConfig(Config): # # List of users who will get org.matrix.dummy_event and m.room.aliases events down /sync # filter_override: # - "@you:example.com" + # # List of users who can use timestamp massaging without being appservices + # timestamp_override: + # - "@you:example.com" # # Whether or not the admin API should be able to register invalid user IDs. # admin_api_register_invalid: true """ diff --git a/synapse/rest/client/v1/room.py b/synapse/rest/client/v1/room.py index 93c06afe2..21bdb4281 100644 --- a/synapse/rest/client/v1/room.py +++ b/synapse/rest/client/v1/room.py @@ -213,6 +213,7 @@ class RoomSendEventRestServlet(TransactionRestServlet): super().__init__(hs) self.event_creation_handler = hs.get_event_creation_handler() self.auth = hs.get_auth() + self.hs = hs def register(self, http_server): # /rooms/$roomid/send/$event_type[/$txn_id] @@ -230,8 +231,10 @@ class RoomSendEventRestServlet(TransactionRestServlet): "sender": requester.user.to_string(), } - if b"ts" in request.args and requester.app_service: - event_dict["origin_server_ts"] = parse_integer(request, "ts", 0) + if b"ts" in request.args: + if (requester.app_service + or requester.user.to_string() in self.hs.config.meow.timestamp_override): + event_dict["origin_server_ts"] = parse_integer(request, "ts", 0) try: (