Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Allow job retries to successfully send notifications
  • Loading branch information
regalijan committed Feb 6, 2025
1 parent c47812c commit 0c0655a
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions functions/api/coconut.ts
Expand Up @@ -18,14 +18,12 @@ export async function onRequestPost(context: RequestContext) {

if (coconutToken !== token) return jsonError("Forbidden", 403);

await context.env.DATA.delete(`coconutjob_${attachment}`);

const aws = new AwsClient({
accessKeyId: context.env.R2_ACCESS_KEY,
secretAccessKey: context.env.R2_SECRET_KEY,
});

const { event } = await context.request.json() as { event: string };
const { event } = (await context.request.json()) as { event: string };

if (event === "job.failed") {
await fetch(context.env.REPORTS_WEBHOOK, {
Expand Down Expand Up @@ -53,6 +51,7 @@ export async function onRequestPost(context: RequestContext) {
method: "PUT",
});

await context.env.DATA.delete(`coconutjob_${attachment}`);
await context.env.R2.delete(`${attachment}.mp4`);

if (!copyResp.ok)
Expand Down

0 comments on commit 0c0655a

Please sign in to comment.