Skip to content

Commit 85db57a

Browse files
Magnus-Kuhnjkoenig134mergify[bot]
authored
Decrypting Messages fails when Relationship is not active anymore (#279)
* fix: validate messages, challenges for once active relationship * test: remove test * Revert "test: remove test" This reverts commit 469c9bd. * feat: revert create challenge validation * test: add tests * feat: message controller wording Co-authored-by: Julian König <[email protected]> * refactor: newline * chore: remove challenge changes * refactor: remove unused code --------- Co-authored-by: Julian König <[email protected]> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
1 parent 3ad1fa5 commit 85db57a

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

packages/transport/src/modules/messages/MessageController.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -507,10 +507,10 @@ export class MessageController extends TransportController {
507507
);
508508
}
509509
} else {
510-
relationship = await this.relationships.getActiveRelationshipToIdentity(envelope.createdBy);
510+
relationship = await this.relationships.getRelationshipToIdentity(envelope.createdBy);
511511

512512
if (!relationship) {
513-
throw TransportCoreErrors.messages.missingOrInactiveRelationship(envelope.createdBy.toString());
513+
throw TransportCoreErrors.general.recordNotFound(Relationship, envelope.createdBy.toString());
514514
}
515515

516516
const [peerMessage, peerKey] = await this.decryptPeerEnvelope(envelope, relationship);

packages/transport/test/modules/messages/MessageController.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,12 +219,20 @@ describe("MessageController", function () {
219219
});
220220

221221
describe("Relationship Termination", function () {
222+
let messageId: CoreId;
223+
222224
beforeAll(async function () {
225+
messageId = (await TestUtil.sendMessage(sender, recipient)).id;
223226
await TestUtil.terminateRelationship(sender, recipient);
224227
});
225228

226229
test("should not send a message on a terminated relationship", async function () {
227230
await expect(TestUtil.sendMessage(sender, recipient)).rejects.toThrow("error.transport.messages.missingOrInactiveRelationship");
228231
});
232+
233+
test("should still decrypt the message", async function () {
234+
await expect(sender.messages.fetchCaches([messageId])).resolves.not.toThrow();
235+
await expect(recipient.messages.fetchCaches([messageId])).resolves.not.toThrow();
236+
});
229237
});
230238
});

0 commit comments

Comments
 (0)