Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Timo Ley
synapse
Commits
25e55d25
Unverified
Commit
25e55d25
authored
4 years ago
by
Patrick Cloke
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Return the previous stream token if a non-member event is a duplicate. (#8093)
parent
8b6c176a
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
changelog.d/8093.bugfix
+1
-0
1 addition, 0 deletions
changelog.d/8093.bugfix
synapse/handlers/message.py
+15
-10
15 additions, 10 deletions
synapse/handlers/message.py
with
16 additions
and
10 deletions
changelog.d/8093.bugfix
0 → 100644
+
1
−
0
View file @
25e55d25
Return the previous stream token if a non-member event is a duplicate.
This diff is collapsed.
Click to expand it.
synapse/handlers/message.py
+
15
−
10
View file @
25e55d25
...
...
@@ -667,14 +667,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_token_for_event
(
prev_event
.
event_id
)
return
await
self
.
handle_new_client_event
(
requester
=
requester
,
event
=
event
,
context
=
context
,
ratelimit
=
ratelimit
...
...
@@ -682,27 +682,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
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment