Fix decrypted events replaced by encrypted ones

This commit is contained in:
miruka 2019-07-08 13:29:05 -04:00
parent 861347ce64
commit faccc7ba90
2 changed files with 8 additions and 7 deletions

View File

@ -258,9 +258,6 @@ class MatrixClient(nio.AsyncClient):
# pylint: disable=unused-argument
async def onRoomMessageText(self, room, ev, from_past=False) -> None:
if ev.event_id == "$1562605869886420ieZBa:matrix.org":
print("GOT DECRYPTED")
co = HTML_FILTER.filter(
ev.formatted_body
if ev.format == "org.matrix.custom.html" else html.escape(ev.body)
@ -405,8 +402,6 @@ class MatrixClient(nio.AsyncClient):
async def onOlmEvent(self, room, ev, from_past=False) -> None:
if ev.event_id == "$1562605869886420ieZBa:matrix.org":
print(json.dumps( ev.__dict__ , indent=4))
co = f"%S hasn't sent your device the keys to decrypt this message."
TimelineEventReceived.from_nio(room, ev, content=co)

View File

@ -127,8 +127,14 @@ function onTimelineEventReceived(
if (found.length > 0) {
timelines.set(found[0], item)
} else {
// Multiple clients will emit duplicate events with the same eventId
}
// Multiple clients will emit duplicate events with the same eventId
else if (item.eventType == "OlmEvent" || item.eventType == "MegolmEvent") {
// Don't replace if an item with the same eventId is found in these
// cases, because it would be the ecrypted version of the event.
timelines.upsert({"eventId": event_id}, item, false, 250)
}
else {
timelines.upsert({"eventId": event_id}, item, true, 250)
}
}