@@ -16,7 +16,7 @@ limitations under the License.
16
16
17
17
import { MatrixEvent , MatrixEventEvent } from "../../../src/models/event" ;
18
18
import { emitPromise } from "../../test-utils/test-utils" ;
19
- import { Crypto } from "../../../src/crypto" ;
19
+ import { Crypto , IEventDecryptionResult } from "../../../src/crypto" ;
20
20
21
21
describe ( "MatrixEvent" , ( ) => {
22
22
it ( "should create copies of itself" , ( ) => {
@@ -182,4 +182,38 @@ describe("MatrixEvent", () => {
182
182
expect ( encryptedEvent . getType ( ) ) . toEqual ( "m.room.message" ) ;
183
183
} ) ;
184
184
} ) ;
185
+
186
+ describe ( "replyEventId" , ( ) => {
187
+ it ( "should ignore 'm.relates_to' from encrypted content even if cleartext lacks one" , async ( ) => {
188
+ const eventId = "test_encrypted_event" ;
189
+ const encryptedEvent = new MatrixEvent ( {
190
+ event_id : eventId ,
191
+ type : "m.room.encrypted" ,
192
+ content : {
193
+ ciphertext : "secrets" ,
194
+ } ,
195
+ } ) ;
196
+
197
+ const crypto = {
198
+ decryptEvent : jest . fn ( ) . mockImplementationOnce ( ( ) => {
199
+ return Promise . resolve < IEventDecryptionResult > ( {
200
+ clearEvent : {
201
+ type : "m.room.message" ,
202
+ content : {
203
+ "m.relates_to" : {
204
+ "m.in_reply_to" : {
205
+ event_id : "!anotherEvent" ,
206
+ } ,
207
+ } ,
208
+ } ,
209
+ } ,
210
+ } ) ;
211
+ } ) ,
212
+ } as unknown as Crypto ;
213
+
214
+ await encryptedEvent . attemptDecryption ( crypto ) ;
215
+ expect ( encryptedEvent . getType ( ) ) . toEqual ( "m.room.message" ) ;
216
+ expect ( encryptedEvent . replyEventId ) . toBeUndefined ( ) ;
217
+ } ) ;
218
+ } ) ;
185
219
} ) ;
0 commit comments