From 2d4f28915eebb7109e8ac444d8f2d0d303d65013 Mon Sep 17 00:00:00 2001 From: qashlan <ahmedelqashlan@gmail.com> Date: Tue, 18 Feb 2025 12:20:30 +0200 Subject: [PATCH] Add method to get current server time in milliseconds in ModuleApi (#18144) - Add `get_current_time_msec()` method to the [module API](https://matrix-org.github.io/synapse/latest/modules/writing_a_module.html) for sound time comparisons with Synapse. - Fixes #18104 Signed-off-by: Ahmed Qashlan <ahmedelqashlan@gmail.com> Co-authored-by: Eric Eastwood <madlittlemods@gmail.com> Co-authored-by: Erik Johnston <erikj@jki.re> --- changelog.d/18144.feature | 1 + synapse/module_api/__init__.py | 4 ++++ 2 files changed, 5 insertions(+) create mode 100644 changelog.d/18144.feature diff --git a/changelog.d/18144.feature b/changelog.d/18144.feature new file mode 100644 index 0000000000..74a28e5a4e --- /dev/null +++ b/changelog.d/18144.feature @@ -0,0 +1 @@ +Add `get_current_time_msec()` method to the [module API](https://matrix-org.github.io/synapse/latest/modules/writing_a_module.html) for sound time comparisons with Synapse. \ No newline at end of file diff --git a/synapse/module_api/__init__.py b/synapse/module_api/__init__.py index 2a2f821427..bf9532e891 100644 --- a/synapse/module_api/__init__.py +++ b/synapse/module_api/__init__.py @@ -1846,6 +1846,10 @@ class ModuleApi: deactivation=deactivation, ) + def get_current_time_msec(self) -> int: + """Returns the current server time in milliseconds.""" + return self._clock.time_msec() + class PublicRoomListManager: """Contains methods for adding to, removing from and querying whether a room -- GitLab