mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2024-10-01 11:49:51 -04:00
Comments
This commit is contained in:
parent
ed88720952
commit
e5991af629
@ -41,10 +41,9 @@ class ReceiptsHandler(BaseHandler):
|
|||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def received_client_receipt(self, room_id, receipt_type, user_id,
|
def received_client_receipt(self, room_id, receipt_type, user_id,
|
||||||
event_id):
|
event_id):
|
||||||
# 1. Persist.
|
"""Called when a client tells us a local user has read up to the given
|
||||||
# 2. Notify local clients
|
event_id in the room.
|
||||||
# 3. Notify remote servers
|
"""
|
||||||
|
|
||||||
receipt = {
|
receipt = {
|
||||||
"room_id": room_id,
|
"room_id": room_id,
|
||||||
"receipt_type": receipt_type,
|
"receipt_type": receipt_type,
|
||||||
@ -62,6 +61,8 @@ class ReceiptsHandler(BaseHandler):
|
|||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def _received_remote_receipt(self, origin, content):
|
def _received_remote_receipt(self, origin, content):
|
||||||
|
"""Called when we receive an EDU of type m.receipt from a remote HS.
|
||||||
|
"""
|
||||||
receipts = [
|
receipts = [
|
||||||
{
|
{
|
||||||
"room_id": room_id,
|
"room_id": room_id,
|
||||||
@ -79,6 +80,8 @@ class ReceiptsHandler(BaseHandler):
|
|||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def _handle_new_receipts(self, receipts):
|
def _handle_new_receipts(self, receipts):
|
||||||
|
"""Takes a list of receipts, stores them and informs the notifier.
|
||||||
|
"""
|
||||||
for receipt in receipts:
|
for receipt in receipts:
|
||||||
room_id = receipt["room_id"]
|
room_id = receipt["room_id"]
|
||||||
receipt_type = receipt["receipt_type"]
|
receipt_type = receipt["receipt_type"]
|
||||||
@ -105,6 +108,9 @@ class ReceiptsHandler(BaseHandler):
|
|||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def _push_remotes(self, receipts):
|
def _push_remotes(self, receipts):
|
||||||
|
"""Given a list of receipts, works out which remote servers should be
|
||||||
|
poked and pokes them.
|
||||||
|
"""
|
||||||
# TODO: Some of this stuff should be coallesced.
|
# TODO: Some of this stuff should be coallesced.
|
||||||
for receipt in receipts:
|
for receipt in receipts:
|
||||||
room_id = receipt["room_id"]
|
room_id = receipt["room_id"]
|
||||||
@ -140,6 +146,8 @@ class ReceiptsHandler(BaseHandler):
|
|||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def get_receipts_for_room(self, room_id, to_key):
|
def get_receipts_for_room(self, room_id, to_key):
|
||||||
|
"""Gets all receipts for a room, upto the given key.
|
||||||
|
"""
|
||||||
result = yield self.store.get_linearized_receipts_for_room(
|
result = yield self.store.get_linearized_receipts_for_room(
|
||||||
room_id, None, to_key
|
room_id, None, to_key
|
||||||
)
|
)
|
||||||
|
@ -35,6 +35,8 @@ class ReceiptsStore(SQLBaseStore):
|
|||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def get_linearized_receipts_for_rooms(self, room_ids, from_key, to_key):
|
def get_linearized_receipts_for_rooms(self, room_ids, from_key, to_key):
|
||||||
|
"""Get receipts for multiple rooms for sending to clients.
|
||||||
|
"""
|
||||||
room_ids = set(room_ids)
|
room_ids = set(room_ids)
|
||||||
|
|
||||||
if from_key:
|
if from_key:
|
||||||
@ -54,6 +56,8 @@ class ReceiptsStore(SQLBaseStore):
|
|||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def get_linearized_receipts_for_room(self, room_id, from_key, to_key):
|
def get_linearized_receipts_for_room(self, room_id, from_key, to_key):
|
||||||
|
"""Get receipts for a single room for sending to clients.
|
||||||
|
"""
|
||||||
def f(txn):
|
def f(txn):
|
||||||
if from_key:
|
if from_key:
|
||||||
sql = (
|
sql = (
|
||||||
@ -107,6 +111,8 @@ class ReceiptsStore(SQLBaseStore):
|
|||||||
@cached
|
@cached
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def get_graph_receipts_for_room(self, room_id):
|
def get_graph_receipts_for_room(self, room_id):
|
||||||
|
"""Get receipts for sending to remote servers.
|
||||||
|
"""
|
||||||
rows = yield self._simple_select_list(
|
rows = yield self._simple_select_list(
|
||||||
table="receipts_graph",
|
table="receipts_graph",
|
||||||
keyvalues={"room_id": room_id},
|
keyvalues={"room_id": room_id},
|
||||||
@ -181,6 +187,11 @@ class ReceiptsStore(SQLBaseStore):
|
|||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def insert_receipt(self, room_id, receipt_type, user_id, event_ids, data):
|
def insert_receipt(self, room_id, receipt_type, user_id, event_ids, data):
|
||||||
|
"""Insert a receipt, either from local client or remote server.
|
||||||
|
|
||||||
|
Automatically does conversion between linearized and graph
|
||||||
|
representations.
|
||||||
|
"""
|
||||||
if not event_ids:
|
if not event_ids:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user