Split receipt events up into one per room
This commit is contained in:
parent
87311d1b8c
commit
d85ce8d89b
|
@ -144,9 +144,8 @@ class ReceiptsHandler(BaseHandler):
|
||||||
|
|
||||||
event = {
|
event = {
|
||||||
"type": "m.receipt",
|
"type": "m.receipt",
|
||||||
"content": {
|
"room_id": room_id,
|
||||||
room_id: result,
|
"content": result,
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
defer.returnValue([event])
|
defer.returnValue([event])
|
||||||
|
@ -163,23 +162,19 @@ class ReceiptEventSource(object):
|
||||||
|
|
||||||
rooms = yield self.store.get_rooms_for_user(user.to_string())
|
rooms = yield self.store.get_rooms_for_user(user.to_string())
|
||||||
rooms = [room.room_id for room in rooms]
|
rooms = [room.room_id for room in rooms]
|
||||||
content = {}
|
events = []
|
||||||
for room_id in rooms:
|
for room_id in rooms:
|
||||||
result = yield self.store.get_linearized_receipts_for_room(
|
content = yield self.store.get_linearized_receipts_for_room(
|
||||||
room_id, from_key, to_key
|
room_id, from_key, to_key
|
||||||
)
|
)
|
||||||
if result:
|
if content:
|
||||||
content[room_id] = result
|
events.append({
|
||||||
|
|
||||||
if not content:
|
|
||||||
defer.returnValue(([], to_key))
|
|
||||||
|
|
||||||
event = {
|
|
||||||
"type": "m.receipt",
|
"type": "m.receipt",
|
||||||
|
"room_id": room_id,
|
||||||
"content": content,
|
"content": content,
|
||||||
}
|
})
|
||||||
|
|
||||||
defer.returnValue(([event], to_key))
|
defer.returnValue((events, to_key))
|
||||||
|
|
||||||
def get_current_key(self, direction='f'):
|
def get_current_key(self, direction='f'):
|
||||||
return self.store.get_max_receipt_stream_id()
|
return self.store.get_max_receipt_stream_id()
|
||||||
|
@ -195,20 +190,16 @@ class ReceiptEventSource(object):
|
||||||
|
|
||||||
rooms = yield self.store.get_rooms_for_user(user.to_string())
|
rooms = yield self.store.get_rooms_for_user(user.to_string())
|
||||||
rooms = [room.room_id for room in rooms]
|
rooms = [room.room_id for room in rooms]
|
||||||
content = {}
|
events = []
|
||||||
for room_id in rooms:
|
for room_id in rooms:
|
||||||
result = yield self.store.get_linearized_receipts_for_room(
|
content = yield self.store.get_linearized_receipts_for_room(
|
||||||
room_id, from_key, to_key
|
room_id, from_key, to_key
|
||||||
)
|
)
|
||||||
if result:
|
if content:
|
||||||
content[room_id] = result
|
events.append({
|
||||||
|
|
||||||
if not content:
|
|
||||||
defer.returnValue(([], to_key))
|
|
||||||
|
|
||||||
event = {
|
|
||||||
"type": "m.receipt",
|
"type": "m.receipt",
|
||||||
|
"room_id": room_id,
|
||||||
"content": content,
|
"content": content,
|
||||||
}
|
})
|
||||||
|
|
||||||
defer.returnValue(([event], to_key))
|
defer.returnValue((events, to_key))
|
||||||
|
|
Loading…
Reference in New Issue