Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Matrix
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Model registry
Operate
Environments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
Matrix
Commits
9f797a24
Commit
9f797a24
authored
6 years ago
by
Richard van der Hoff
Browse files
Options
Downloads
Patches
Plain Diff
Handle RRs which arrive before their events
parent
857e6fd8
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
synapse/storage/receipts.py
+19
-25
19 additions, 25 deletions
synapse/storage/receipts.py
with
19 additions
and
25 deletions
synapse/storage/receipts.py
+
19
−
25
View file @
9f797a24
...
...
@@ -13,7 +13,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from
synapse.api.errors
import
NotFoundError
from
._base
import
SQLBaseStore
from
.util.id_generators
import
StreamIdGenerator
from
synapse.util.caches.descriptors
import
cachedInlineCallbacks
,
cachedList
,
cached
...
...
@@ -340,32 +340,26 @@ class ReceiptsStore(ReceiptsWorkerStore):
allow_none
=
True
)
if
not
res
:
raise
NotFoundError
(
"
Cannot set read receipt on unknown event %s
"
%
(
event_id
,
),
)
stream_ordering
=
int
(
res
[
"
stream_ordering
"
])
stream_ordering
=
int
(
res
[
"
stream_ordering
"
])
if
res
else
None
# We don't want to clobber receipts for more recent events, so we
# have to compare orderings of existing receipts
sql
=
(
"
SELECT stream_ordering, event_id FROM events
"
"
INNER JOIN receipts_linearized as r USING (event_id, room_id)
"
"
WHERE r.room_id = ? AND r.receipt_type = ? AND r.user_id = ?
"
)
txn
.
execute
(
sql
,
(
room_id
,
receipt_type
,
user_id
))
for
so
,
eid
in
txn
:
if
int
(
so
)
>=
stream_ordering
:
logger
.
debug
(
"
Ignoring new receipt for %s in favour of existing
"
"
one for later event %s
"
,
event_id
,
eid
,
)
return
False
if
stream_ordering
is
not
None
:
sql
=
(
"
SELECT stream_ordering, event_id FROM events
"
"
INNER JOIN receipts_linearized as r USING (event_id, room_id)
"
"
WHERE r.room_id = ? AND r.receipt_type = ? AND r.user_id = ?
"
)
txn
.
execute
(
sql
,
(
room_id
,
receipt_type
,
user_id
))
for
so
,
eid
in
txn
:
if
int
(
so
)
>=
stream_ordering
:
logger
.
debug
(
"
Ignoring new receipt for %s in favour of existing
"
"
one for later event %s
"
,
event_id
,
eid
,
)
return
False
txn
.
call_after
(
self
.
get_receipts_for_room
.
invalidate
,
(
room_id
,
receipt_type
)
...
...
@@ -413,7 +407,7 @@ class ReceiptsStore(ReceiptsWorkerStore):
}
)
if
receipt_type
==
"
m.read
"
:
if
receipt_type
==
"
m.read
"
and
stream_ordering
is
not
None
:
self
.
_remove_old_push_actions_before_txn
(
txn
,
room_id
=
room_id
,
...
...
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