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): long running operation recovery #882

Open
wants to merge 13 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
8 changes: 4 additions & 4 deletions src/core/agent/records/notificationRecord.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BaseRecord, Tags } from "../../storage/storage.types";
import { NotificationRoute } from "../agent.types";
import { LinkedGroupRequest } from "./notificationRecord.types";
import { LinkedRequest } from "./notificationRecord.types";
import { randomSalt } from "../services/utils";

interface NotificationRecordStorageProps {
Expand All @@ -13,7 +13,7 @@ interface NotificationRecordStorageProps {
multisigId?: string;
connectionId: string;
credentialId?: string;
linkedGroupRequest?: LinkedGroupRequest;
linkedRequest?: LinkedRequest;
groupReplied?: boolean,
initiatorAid?: string,
groupInitiator?: boolean,
Expand All @@ -25,7 +25,7 @@ class NotificationRecord extends BaseRecord {
read!: boolean;
multisigId?: string;
connectionId!: string;
linkedGroupRequest!: LinkedGroupRequest;
linkedRequest!: LinkedRequest;
credentialId?: string;
groupReplied?: boolean;
initiatorAid?: string;
Expand All @@ -45,7 +45,7 @@ class NotificationRecord extends BaseRecord {
this.multisigId = props.multisigId;
this.connectionId = props.connectionId;
this._tags = props.tags ?? {};
this.linkedGroupRequest = props.linkedGroupRequest ?? { accepted: false };
this.linkedRequest = props.linkedRequest ?? { accepted: false };
this.credentialId = props.credentialId;
this.groupReplied = props.groupReplied;
this.initiatorAid = props.initiatorAid;
Expand Down
4 changes: 2 additions & 2 deletions src/core/agent/records/notificationRecord.types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Notification } from "../services/credentialService.types";

interface LinkedGroupRequest {
interface LinkedRequest {
accepted: boolean;
current?: string;
previous?: string;
Expand All @@ -12,4 +12,4 @@ interface NotificationAttempts {
notification: Notification;
}

export type { LinkedGroupRequest, NotificationAttempts };
export type { LinkedRequest, NotificationAttempts };
1 change: 1 addition & 0 deletions src/core/agent/records/operationPendingRecord.type.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export enum OperationPendingRecordType {
Witness = "witness",
Group = "group",
Done = "done",
Oobi = "oobi",
ExchangeReceiveCredential = "exchange.receivecredential",
ExchangeOfferCredential = "exchange.offercredential",
Expand Down
8 changes: 7 additions & 1 deletion src/core/agent/services/identifierService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -498,24 +498,30 @@ class IdentifierService extends AgentService {
continue;
}

let recordType = OperationPendingRecordType.Witness;

const op: Operation = await this.props.signifyClient
.operations()
.get(`witness.${identifier.prefix}`)
.catch(async (error) => {
const status = error.message.split(" - ")[1];

if (/404/gi.test(status)) {
recordType = OperationPendingRecordType.Done
return await this.props.signifyClient
.operations()
.get(`done.${identifier.prefix}`);
}

throw error;
});

const isPending = !op.done;

if (isPending) {
const pendingOperation = await this.operationPendingStorage.save({
id: op.name,
recordType: OperationPendingRecordType.Witness,
recordType,
});
this.props.eventEmitter.emit<OperationAddedEvent>({
type: EventTypes.OperationAdded,
Expand Down
Loading
Loading