diff options
author | Andrew Morgan <andrew@amorgan.xyz> | 2020-10-19 18:35:07 +0100 |
---|---|---|
committer | Andrew Morgan <andrew@amorgan.xyz> | 2020-10-19 18:35:07 +0100 |
commit | 1e9ec2afff8197f8da833bb0c218aa31747471c0 (patch) | |
tree | 6e06996ab0f5fc06ab1e159fe938350455d3e0a0 /synapse/handlers | |
parent | Merge commit '8b6c176ae' into anoa/dinsic_release_1_21_x (diff) | |
parent | Fix the return type of send_nonmember_events. (#8112) (diff) | |
download | synapse-1e9ec2afff8197f8da833bb0c218aa31747471c0.tar.xz |
Merge commit '3c01724b3' into anoa/dinsic_release_1_21_x
* commit '3c01724b3': Fix the return type of send_nonmember_events. (#8112) Remove : from allowed client_secret chars (#8101) Rename changelog from bugfix to misc. Iteratively encode JSON responses to avoid blocking the reactor. (#8013) Return the previous stream token if a non-member event is a duplicate. (#8093)
Diffstat (limited to 'synapse/handlers')
-rw-r--r-- | synapse/handlers/message.py | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/synapse/handlers/message.py b/synapse/handlers/message.py index e7a07967d8..465b2a19bc 100644 --- a/synapse/handlers/message.py +++ b/synapse/handlers/message.py @@ -670,14 +670,14 @@ class EventCreationHandler(object): assert self.hs.is_mine(user), "User must be our own: %s" % (user,) if event.is_state(): - prev_state = await self.deduplicate_state_event(event, context) - if prev_state is not None: + prev_event = await self.deduplicate_state_event(event, context) + if prev_event is not None: logger.info( "Not bothering to persist state event %s duplicated by %s", event.event_id, - prev_state.event_id, + prev_event.event_id, ) - return prev_state + return await self.store.get_stream_id_for_event(prev_event.event_id) return await self.handle_new_client_event( requester=requester, event=event, context=context, ratelimit=ratelimit @@ -685,27 +685,32 @@ class EventCreationHandler(object): async def deduplicate_state_event( self, event: EventBase, context: EventContext - ) -> None: + ) -> Optional[EventBase]: """ Checks whether event is in the latest resolved state in context. - If so, returns the version of the event in context. - Otherwise, returns None. + Args: + event: The event to check for duplication. + context: The event context. + + Returns: + The previous verion of the event is returned, if it is found in the + event context. Otherwise, None is returned. """ prev_state_ids = await context.get_prev_state_ids() prev_event_id = prev_state_ids.get((event.type, event.state_key)) if not prev_event_id: - return + return None prev_event = await self.store.get_event(prev_event_id, allow_none=True) if not prev_event: - return + return None if prev_event and event.user_id == prev_event.user_id: prev_content = encode_canonical_json(prev_event.content) next_content = encode_canonical_json(event.content) if prev_content == next_content: return prev_event - return + return None async def create_and_send_nonmember_event( self, |