Skip to content
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
29 changes: 29 additions & 0 deletions plugins/acpPlugin/src/acpPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,13 @@ class AcpPlugin {
try {
const state = await this.getAcpState();

if (state.jobs.cancelled.find(c => c.jobId === +args.jobId!)) {
return new ExecutableGameFunctionResponse(
ExecutableGameFunctionStatus.Failed,
"Cannot respond - this job has been cancelled"
);
}

const job = state.jobs.active.asASeller.find(
(c) => c.jobId === +args.jobId!
);
Expand Down Expand Up @@ -654,6 +661,13 @@ class AcpPlugin {
try {
const state = await this.getAcpState();

if (state.jobs.cancelled.find(c => c.jobId === +args.jobId!)) {
return new ExecutableGameFunctionResponse(
ExecutableGameFunctionStatus.Failed,
"Cannot pay - this job has been cancelled"
);
}

const job = state.jobs.active.asABuyer.find(
(c) => c.jobId === +args.jobId!
);
Expand Down Expand Up @@ -779,6 +793,13 @@ class AcpPlugin {
try {
const state = await this.getAcpState();

if (state.jobs.cancelled.find(c => c.jobId === +args.jobId!)) {
return new ExecutableGameFunctionResponse(
ExecutableGameFunctionStatus.Failed,
"Cannot deliver - this job has been cancelled"
);
}

const job = state.jobs.active.asASeller.find(
(c) => c.jobId === +args.jobId!
);
Expand All @@ -790,6 +811,14 @@ class AcpPlugin {
);
}

if (job.expiredAt && new Date(job.expiredAt) < new Date()) {
const expiredDate = new Date(job.expiredAt);
return new ExecutableGameFunctionResponse(
ExecutableGameFunctionStatus.Failed,
`Cannot deliver - this job has expired on ${expiredDate.toISOString()} (UTC). The buyer may need to create a new job request.`
);
}

if (job.phase !== AcpJobPhasesDesc.TRANSACTION) {
return new ExecutableGameFunctionResponse(
ExecutableGameFunctionStatus.Failed,
Expand Down
1 change: 1 addition & 0 deletions plugins/acpPlugin/src/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export interface AcpJob {
memo: AcpRequestMemo[];
tweetHistory: ITweet[];
lastUpdated: number;
expiredAt?: string;
}

export interface IDeliverable {
Expand Down