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

feat(core): marking notification as read when deleting distributed reliability #887

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/core/agent/services/ipexCommunicationService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ describe("Receive individual ACDC actions", () => {
JSON.stringify(connectionNote),
})
);
markNotificationMock.mockResolvedValueOnce({status: "done"});

await ipexCommunicationService.admitAcdcFromGrant(id);

Expand Down Expand Up @@ -1078,6 +1079,7 @@ describe("Offer ACDC individual actions", () => {
id: "opName",
recordType: OperationPendingRecordType.ExchangeOfferCredential,
});
markNotificationMock.mockResolvedValueOnce({status: "done"});

await ipexCommunicationService.offerAcdcFromApply(id, grantForIssuanceExnMessage.exn.e.acdc);

Expand Down Expand Up @@ -1542,6 +1544,7 @@ describe("Grant ACDC individual actions", () => {
recordType: OperationPendingRecordType.ExchangePresentCredential,
});
ipexGrantMock.mockResolvedValue(["grant", "sigs", "gend"]);
markNotificationMock.mockResolvedValueOnce({status: "done"});

await ipexCommunicationService.grantAcdcFromAgree("agree-note-id");

Expand Down
8 changes: 8 additions & 0 deletions src/core/agent/services/keriaNotificationService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,8 @@ describe("Signify notification service of agent", () => {

test("should call delete keri notification when trigger deleteNotificationRecordById", async () => {
const id = "uuid";
markNotificationMock.mockResolvedValueOnce({status: "done"});

await keriaNotificationService.deleteNotificationRecordById(
id,
NotificationRoute.ExnIpexAgree
Expand All @@ -421,6 +423,8 @@ describe("Signify notification service of agent", () => {
const notificationStorage = new NotificationStorage(
agentServicesProps.signifyClient
);
markNotificationMock.mockResolvedValueOnce({status: "done"});

notificationStorage.deleteById = jest.fn();
await deleteNotificationRecordById(
agentServicesProps.signifyClient,
Expand Down Expand Up @@ -721,6 +725,7 @@ describe("Signify notification service of agent", () => {
updatedAt: new Date(),
};
notificationStorage.findAllByQuery = jest.fn().mockResolvedValue([notification]);
markNotificationMock.mockResolvedValueOnce({status: "done"});

await keriaNotificationService.processNotification(
notificationIpexGrantProp
Expand Down Expand Up @@ -793,6 +798,7 @@ describe("Signify notification service of agent", () => {
.mockResolvedValue({
id: "id",
});
markNotificationMock.mockResolvedValueOnce({status: "done"});

await keriaNotificationService.processNotification(
notificationIpexGrantProp
Expand Down Expand Up @@ -2506,6 +2512,7 @@ describe("Long running operation tracker", () => {
updatedAt: new Date(),
},
]);
markNotificationMock.mockResolvedValueOnce({status: "done"});

await keriaNotificationService.processOperation(operationRecord);

Expand Down Expand Up @@ -2693,6 +2700,7 @@ describe("Long running operation tracker", () => {
updatedAt: new Date(),
},
]);
markNotificationMock.mockResolvedValueOnce({status: "done"});

await keriaNotificationService.processOperation(operationRecord);

Expand Down
5 changes: 4 additions & 1 deletion src/core/agent/services/multiSigService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ describe("Creation of multi-sig", () => {
id: `group.${multisigIdentifier}`,
recordType: OperationPendingRecordType.Group,
});

markNotificationMock.mockResolvedValueOnce({status: "done"});
expect(
await multiSigService.joinMultisig(
"id",
Expand Down Expand Up @@ -647,6 +647,9 @@ describe("Creation of multi-sig", () => {
groupCreated: true,
},
});

markNotificationMock.mockResolvedValueOnce({status: "done"});

await multiSigService.joinMultisig(
"id",
NotificationRoute.MultiSigIcp,
Expand Down
8 changes: 7 additions & 1 deletion src/core/agent/services/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,13 @@ export const deleteNotificationRecordById = async (
route: NotificationRoute
): Promise<void> => {
if (!/^\/local/.test(route)) {
await client.notifications().mark(id);
await client.notifications().mark(id)
.catch((error) => {
const status = error.message.split(" - ")[1];
if (!/404/gi.test(status)) {
throw error;
}
});
}
await notificationStorage.deleteById(id);
};
Expand Down
Loading