mirror of
https://mau.dev/maunium/synapse.git
synced 2024-11-16 06:51:46 +01:00
Delete old pushers
This commit is contained in:
parent
351b50a887
commit
183f23f10d
2 changed files with 29 additions and 9 deletions
|
@ -201,6 +201,18 @@ class EventPushActionsStore(SQLBaseStore):
|
||||||
(room_id, event_id)
|
(room_id, event_id)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def _remove_push_actions_before_txn(self, txn, room_id, user_id,
|
||||||
|
topological_ordering):
|
||||||
|
txn.call_after(
|
||||||
|
self.get_unread_event_push_actions_by_room_for_user.invalidate_many,
|
||||||
|
(room_id, user_id, )
|
||||||
|
)
|
||||||
|
txn.execute(
|
||||||
|
"DELETE FROM event_push_actions"
|
||||||
|
" WHERE room_id = ? AND user_id = ? AND topological_ordering < ?",
|
||||||
|
(room_id, user_id, topological_ordering,)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def _action_has_highlight(actions):
|
def _action_has_highlight(actions):
|
||||||
for action in actions:
|
for action in actions:
|
||||||
|
|
|
@ -244,6 +244,15 @@ class ReceiptsStore(SQLBaseStore):
|
||||||
(user_id, room_id, receipt_type)
|
(user_id, room_id, receipt_type)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
res = self._simple_select_one_txn(
|
||||||
|
txn,
|
||||||
|
table="events",
|
||||||
|
retcols=["topological_ordering", "stream_ordering"],
|
||||||
|
keyvalues={"event_id": event_id},
|
||||||
|
)
|
||||||
|
topological_ordering = int(res["topological_ordering"])
|
||||||
|
stream_ordering = int(res["stream_ordering"])
|
||||||
|
|
||||||
# We don't want to clobber receipts for more recent events, so we
|
# We don't want to clobber receipts for more recent events, so we
|
||||||
# have to compare orderings of existing receipts
|
# have to compare orderings of existing receipts
|
||||||
sql = (
|
sql = (
|
||||||
|
@ -256,15 +265,6 @@ class ReceiptsStore(SQLBaseStore):
|
||||||
results = txn.fetchall()
|
results = txn.fetchall()
|
||||||
|
|
||||||
if results:
|
if results:
|
||||||
res = self._simple_select_one_txn(
|
|
||||||
txn,
|
|
||||||
table="events",
|
|
||||||
retcols=["topological_ordering", "stream_ordering"],
|
|
||||||
keyvalues={"event_id": event_id},
|
|
||||||
)
|
|
||||||
topological_ordering = int(res["topological_ordering"])
|
|
||||||
stream_ordering = int(res["stream_ordering"])
|
|
||||||
|
|
||||||
for to, so, _ in results:
|
for to, so, _ in results:
|
||||||
if int(to) > topological_ordering:
|
if int(to) > topological_ordering:
|
||||||
return False
|
return False
|
||||||
|
@ -294,6 +294,14 @@ class ReceiptsStore(SQLBaseStore):
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if receipt_type == "m.read":
|
||||||
|
self._remove_push_actions_before_txn(
|
||||||
|
txn,
|
||||||
|
room_id=room_id,
|
||||||
|
user_id=user_id,
|
||||||
|
topological_ordering=topological_ordering,
|
||||||
|
)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
|
|
Loading…
Reference in a new issue