Add changelog, some cleaning

This commit is contained in:
Valere 2022-11-16 10:56:10 +01:00
parent 891709ef41
commit e66a0541be
5 changed files with 9 additions and 6 deletions

1
changelog.d/7594.misc Normal file
View File

@ -0,0 +1 @@
Better validation of edits

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 New Vector Ltd
* Copyright (c) 2022 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -33,13 +33,15 @@ internal class EventEditValidator @Inject constructor(val cryptoStore: IMXCrypto
}
/**
*There are a number of requirements on replacement events, which must be satisfied for the replacement to be considered valid:
* There are a number of requirements on replacement events, which must be satisfied for the replacement
* to be considered valid:
* As with all event relationships, the original event and replacement event must have the same room_id
* (i.e. you cannot send an event in one room and then an edited version in a different room).
* The original event and replacement event must have the same sender (i.e. you cannot edit someone elses messages).
* The replacement and original events must have the same type (i.e. you cannot change the original events type).
* The replacement and original events must not have a state_key property (i.e. you cannot edit state events at all).
* The original event must not, itself, have a rel_type of m.replace (i.e. you cannot edit an edit though you can send multiple edits for a single original event).
* The original event must not, itself, have a rel_type of m.replace
* (i.e. you cannot edit an edit though you can send multiple edits for a single original event).
* The replacement event (once decrypted, if appropriate) must have an m.new_content property.
*
* If the original event was encrypted, the replacement should be too.

View File

@ -213,7 +213,7 @@ internal class EventRelationsAggregationProcessor @Inject constructor(
if (content?.relatesTo?.type == RelationType.REPLACE) {
Timber.v("###REPLACE in room $roomId for event ${event.eventId}")
// A replace!
handleReplace(realm, event, roomId, isLocalEcho, content?.relatesTo.eventId)
handleReplace(realm, event, roomId, isLocalEcho, content.relatesTo.eventId)
}
}
in EventType.POLL_RESPONSE -> {
@ -474,7 +474,7 @@ internal class EventRelationsAggregationProcessor @Inject constructor(
}
val sourceToDiscard = eventSummary.editSummary?.editions?.firstOrNull { it.eventId == redacted.eventId }
if (sourceToDiscard == null) {
Timber.w("Redaction of a replace that was not known in aggregation $sourceToDiscard")
Timber.w("Redaction of a replace that was not known in aggregation")
return
}
// Need to remove this event from the edition list

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 New Vector Ltd
* Copyright (c) 2022 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.