diff options
Diffstat (limited to 'synapse/handlers')
-rw-r--r-- | synapse/handlers/directory.py | 2 | ||||
-rw-r--r-- | synapse/handlers/message.py | 11 | ||||
-rw-r--r-- | synapse/handlers/room.py | 9 |
3 files changed, 18 insertions, 4 deletions
diff --git a/synapse/handlers/directory.py b/synapse/handlers/directory.py index 66d3b533d9..a907a66e12 100644 --- a/synapse/handlers/directory.py +++ b/synapse/handlers/directory.py @@ -155,4 +155,4 @@ class DirectoryHandler(BaseHandler): "room_id": room_id, "sender": user_id, "content": {"aliases": aliases}, - }) + }, ratelimit=False) diff --git a/synapse/handlers/message.py b/synapse/handlers/message.py index 49c0e98113..854b2c73c6 100644 --- a/synapse/handlers/message.py +++ b/synapse/handlers/message.py @@ -19,6 +19,7 @@ from synapse.api.constants import EventTypes, Membership from synapse.api.errors import RoomError from synapse.streams.config import PaginationConfig from synapse.events.validator import EventValidator +from synapse.util.logcontext import PreserveLoggingContext from ._base import BaseHandler @@ -106,7 +107,7 @@ class MessageHandler(BaseHandler): defer.returnValue(chunk) @defer.inlineCallbacks - def create_and_send_event(self, event_dict): + def create_and_send_event(self, event_dict, ratelimit=True): """ Given a dict from a client, create and handle a new event. Creates an FrozenEvent object, filling out auth_events, prev_events, @@ -123,7 +124,8 @@ class MessageHandler(BaseHandler): self.validator.validate_new(builder) - self.ratelimit(builder.user_id) + if ratelimit: + self.ratelimit(builder.user_id) # TODO(paul): Why does 'event' not have a 'user' object? user = self.hs.parse_userid(builder.user_id) assert self.hs.is_mine(user), "User must be our own: %s" % (user,) @@ -152,6 +154,11 @@ class MessageHandler(BaseHandler): context=context, ) + if event.type == EventTypes.Message: + presence = self.hs.get_handlers().presence_handler + with PreserveLoggingContext(): + presence.bump_presence_active_time(user) + defer.returnValue(event) @defer.inlineCallbacks diff --git a/synapse/handlers/room.py b/synapse/handlers/room.py index 8567d7409d..deefc3c11e 100644 --- a/synapse/handlers/room.py +++ b/synapse/handlers/room.py @@ -130,6 +130,7 @@ class RoomCreationHandler(BaseHandler): "type": EventTypes.Name, "room_id": room_id, "sender": user_id, + "state_key": "", "content": {"name": name}, }) @@ -139,6 +140,7 @@ class RoomCreationHandler(BaseHandler): "type": EventTypes.Topic, "room_id": room_id, "sender": user_id, + "state_key": "", "content": {"topic": topic}, }) @@ -147,7 +149,7 @@ class RoomCreationHandler(BaseHandler): "type": EventTypes.Member, "state_key": invitee, "room_id": room_id, - "user_id": user_id, + "sender": user_id, "content": {"membership": Membership.INVITE}, }) @@ -390,6 +392,11 @@ class RoomMemberHandler(BaseHandler): host = hosts[0] + # If event doesn't include a display name, add one. + yield self.distributor.fire( + "collect_presencelike_data", joinee, content + ) + content.update({"membership": Membership.JOIN}) builder = self.event_builder_factory.new({ "type": EventTypes.Member, |