mirror of
https://github.com/element-hq/synapse.git
synced 2026-05-11 21:54:46 +00:00
Reinstate removed EventBase methods (#19712)
Both `__getitem__` and `.user_id` were removed in #19680 to simplify the event class. However, `EventBase` is exposed to modules who might also make use of those methods, so let's reinstate them (but otherwise not reinstate the usage of them in the code).
This commit is contained in:
@@ -828,6 +828,24 @@ class ModuleApiTestCase(BaseModuleApiTestCase):
|
||||
# Ensure the pushers were deleted after the callback.
|
||||
self.assertEqual(len(self.hs.get_pusherpool().pushers[user_id].values()), 0)
|
||||
|
||||
def test_event_deprecated_methods(self) -> None:
|
||||
"""Test that deprecated methods on events are still functional."""
|
||||
user_id = self.register_user("user", "password")
|
||||
tok = self.login("user", "password")
|
||||
|
||||
room_id = self.helper.create_room_as(tok=tok)
|
||||
|
||||
state = self.get_success(
|
||||
self.hs.get_storage_controllers().state.get_current_state(room_id)
|
||||
)
|
||||
create_event = state[(EventTypes.Create, "")]
|
||||
|
||||
# `.user_id` is a deprecated alias for `.sender`.
|
||||
self.assertEqual(create_event.user_id, user_id)
|
||||
|
||||
# The event supports looking up keys via `__getitem__` although deprecated
|
||||
self.assertEqual(create_event["room_id"], room_id)
|
||||
|
||||
|
||||
class ModuleApiWorkerTestCase(BaseModuleApiTestCase, BaseMultiWorkerStreamTestCase):
|
||||
"""For testing ModuleApi functionality in a multi-worker setup"""
|
||||
|
||||
Reference in New Issue
Block a user