Permalink
Newer
100644
67 lines (55 sloc)
1.9 KB
2
import { jsonError } from "../common.js";
3
4
export async function onRequestPost(context: RequestContext) {
5
const { searchParams } = new URL(context.request.url);
9
if (!attachment || !token)
10
return jsonError("Invalid report id or token", 400);
23
const aws = new AwsClient({
24
accessKeyId: context.env.R2_ACCESS_KEY,
25
secretAccessKey: context.env.R2_SECRET_KEY,
26
});
27
29
30
if (event === "job.failed") {
31
await fetch(context.env.REPORTS_WEBHOOK, {
32
body: JSON.stringify({
33
embeds: [
34
{
35
title: "Transcoding Failed",
36
color: 16711680,
37
description: `Attachment ${attachment} could not be transcoded, please log in to Coconut to see what went wrong.`,
38
},
39
],
40
}),
41
headers: {
42
"content-type": "application/json",
43
},
44
method: "POST",
45
});
46
} else {
47
const R2_URL = `https://car-crushers.${context.env.R2_ZONE}.r2.cloudflarestorage.com`;
57
58
if (!copyResp.ok)
59
console.log(
60
`Copy status: ${copyResp.status}\n\nCopy response body: ${await copyResp.text()}`,
61
);