[Connection] Clean up receipts
This commit is contained in:
parent
fb0750b69a
commit
88b9cdd345
|
@ -461,15 +461,13 @@ class Connection {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (userTimestampMap[mxid].containsKey("ts")) {
|
if (userTimestampMap[mxid].containsKey("ts")) {
|
||||||
if (receiptStateContent[eventID] == null)
|
receiptStateContent[mxid] = {
|
||||||
receiptStateContent[eventID] = {"m.read": {}};
|
"event_id": eventID,
|
||||||
else if (receiptStateContent[eventID]["m.read"] == null)
|
|
||||||
receiptStateContent[eventID]["m.read"] = {};
|
|
||||||
receiptStateContent[eventID]["m.read"][mxid] = {
|
|
||||||
"ts": userTimestampMap[mxid]["ts"],
|
"ts": userTimestampMap[mxid]["ts"],
|
||||||
};
|
};
|
||||||
|
print(
|
||||||
|
"$mxid hat $eventID um ${userTimestampMap[mxid]["ts"]} gelesen!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,12 +101,10 @@ class Event extends RoomState {
|
||||||
|
|
||||||
/// Returns a list of [Receipt] instances for this event.
|
/// Returns a list of [Receipt] instances for this event.
|
||||||
List<Receipt> get receipts {
|
List<Receipt> get receipts {
|
||||||
if (!(room.roomAccountData.containsKey("m.receipt") &&
|
if (!(room.roomAccountData.containsKey("m.receipt"))) return [];
|
||||||
room.roomAccountData["m.receipt"].content.containsKey(eventId)))
|
|
||||||
return [];
|
|
||||||
List<Receipt> receiptsList = [];
|
List<Receipt> receiptsList = [];
|
||||||
for (var entry in room
|
for (var entry in room.roomAccountData["m.receipt"].content.entries) {
|
||||||
.roomAccountData["m.receipt"].content[eventId]["m.read"].entries) {
|
if (entry.value["event_id"] == eventId)
|
||||||
receiptsList.add(Receipt(
|
receiptsList.add(Receipt(
|
||||||
room.states[entry.key]?.asUser ?? User(entry.key),
|
room.states[entry.key]?.asUser ?? User(entry.key),
|
||||||
ChatTime(entry.value["ts"])));
|
ChatTime(entry.value["ts"])));
|
||||||
|
|
|
@ -130,9 +130,12 @@ void main() {
|
||||||
expect(matrix.roomList.rooms[1].roomAccountData.length, 3);
|
expect(matrix.roomList.rooms[1].roomAccountData.length, 3);
|
||||||
expect(
|
expect(
|
||||||
matrix.roomList.rooms[1].roomAccountData["m.receipt"]
|
matrix.roomList.rooms[1].roomAccountData["m.receipt"]
|
||||||
.content["7365636s6r6432:example.com"]["m.read"]
|
.content["@alice:example.com"]["ts"],
|
||||||
["@alice:example.com"]["ts"],
|
|
||||||
1436451550453);
|
1436451550453);
|
||||||
|
expect(
|
||||||
|
matrix.roomList.rooms[1].roomAccountData["m.receipt"]
|
||||||
|
.content["@alice:example.com"]["event_id"],
|
||||||
|
"7365636s6r6432:example.com");
|
||||||
expect(matrix.roomList.rooms.length, 2);
|
expect(matrix.roomList.rooms.length, 2);
|
||||||
expect(matrix.roomList.rooms[1].canonicalAlias,
|
expect(matrix.roomList.rooms[1].canonicalAlias,
|
||||||
"#famedlyContactDiscovery:${matrix.userID.split(":")[1]}");
|
"#famedlyContactDiscovery:${matrix.userID.split(":")[1]}");
|
||||||
|
|
|
@ -103,10 +103,9 @@ void main() {
|
||||||
room.roomAccountData["m.receipt"] = RoomAccountData.fromJson({
|
room.roomAccountData["m.receipt"] = RoomAccountData.fromJson({
|
||||||
"type": "m.receipt",
|
"type": "m.receipt",
|
||||||
"content": {
|
"content": {
|
||||||
"1": {
|
"@alice:example.com": {
|
||||||
"m.read": {
|
"event_id": "1",
|
||||||
"@alice:example.com": {"ts": 1436451550453}
|
"ts": 1436451550453,
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"room_id": roomID,
|
"room_id": roomID,
|
||||||
|
|
Loading…
Reference in a new issue