Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decrypting Messages fails when Relationship is not active anymore #279

Merged
merged 11 commits into from
Sep 23, 2024
4 changes: 2 additions & 2 deletions packages/transport/src/modules/messages/MessageController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -507,10 +507,10 @@ export class MessageController extends TransportController {
);
}
} else {
relationship = await this.relationships.getActiveRelationshipToIdentity(envelope.createdBy);
relationship = await this.relationships.getRelationshipToIdentity(envelope.createdBy);

if (!relationship) {
throw TransportCoreErrors.messages.missingOrInactiveRelationship(envelope.createdBy.toString());
throw TransportCoreErrors.general.recordNotFound(Relationship, envelope.createdBy.toString());
}

const [peerMessage, peerKey] = await this.decryptPeerEnvelope(envelope, relationship);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,12 +219,20 @@ describe("MessageController", function () {
});

describe("Relationship Termination", function () {
let messageId: CoreId;

beforeAll(async function () {
messageId = (await TestUtil.sendMessage(sender, recipient)).id;
await TestUtil.terminateRelationship(sender, recipient);
});

test("should not send a message on a terminated relationship", async function () {
await expect(TestUtil.sendMessage(sender, recipient)).rejects.toThrow("error.transport.messages.missingOrInactiveRelationship");
});

test("should still decrypt the message", async function () {
await expect(sender.messages.fetchCaches([messageId])).resolves.not.toThrow();
await expect(recipient.messages.fetchCaches([messageId])).resolves.not.toThrow();
});
});
});