Make data transfer creation endpoint actually work
This commit is contained in:
@ -1,12 +1,12 @@
|
||||
import { jsonError } from "../../common.js";
|
||||
|
||||
export async function onRequestPost(context: RequestContext) {
|
||||
const { cookie, has_access } = context.data.body;
|
||||
const { cookie, is_banned } = context.data.body;
|
||||
|
||||
if (
|
||||
typeof has_access !== "boolean" ||
|
||||
(!has_access && typeof cookie !== "string") ||
|
||||
(!has_access &&
|
||||
typeof is_banned !== "boolean" ||
|
||||
(is_banned && typeof cookie !== "string") ||
|
||||
(is_banned &&
|
||||
!cookie.match(
|
||||
/_\|WARNING:-DO-NOT-SHARE-THIS\.--Sharing-this-will-allow-someone-to-log-in-as-you-and-to-steal-your-ROBUX-and-items\.\|_[A-F\d]+/,
|
||||
))
|
||||
@ -18,7 +18,7 @@ export async function onRequestPost(context: RequestContext) {
|
||||
Date.now().toString() +
|
||||
crypto.randomUUID().replaceAll("-", "");
|
||||
|
||||
if (has_access) {
|
||||
if (!is_banned) {
|
||||
await context.env.DATA.put(`datatransfer_${id}`, "{}", {
|
||||
expirationTtl: 3600,
|
||||
});
|
||||
@ -54,30 +54,9 @@ export async function onRequestPost(context: RequestContext) {
|
||||
|
||||
const authedUser: { id: number; name: string } = await authedUserReq.json();
|
||||
|
||||
const createCardReq = await fetch(
|
||||
`https://api.trello.com/1/cards?key=${context.env.TRELLO_API_KEY}&token=${context.env.TRELLO_API_TOKEN}`,
|
||||
{
|
||||
body: JSON.stringify({
|
||||
desc: `Old account: ${authedUser.name} (${authedUser.id})`,
|
||||
idList: "5fbd440cd30b6377f959e244",
|
||||
name: `${authedUser.name} | Data Transfer`,
|
||||
}),
|
||||
headers: {
|
||||
accept: "application/json",
|
||||
"content-type": "application/json",
|
||||
},
|
||||
method: "POST",
|
||||
},
|
||||
);
|
||||
|
||||
if (!createCardReq.ok) return jsonError("Failed to create entry", 500);
|
||||
|
||||
const { id: cardId }: { id: string } = await createCardReq.json();
|
||||
|
||||
await context.env.DATA.put(
|
||||
`datatransfer_${id}`,
|
||||
JSON.stringify({
|
||||
cardId,
|
||||
oldUser: authedUser,
|
||||
}),
|
||||
{
|
||||
@ -87,7 +66,7 @@ export async function onRequestPost(context: RequestContext) {
|
||||
|
||||
return new Response(null, {
|
||||
headers: {
|
||||
location: `/data-transfer/${id}`,
|
||||
location: "/data-transfer/destination-account",
|
||||
},
|
||||
status: 201,
|
||||
});
|
||||
|
Reference in New Issue
Block a user