api: merge two picker types into one

This commit is contained in:
wukko 2024-08-06 21:30:18 +06:00
parent ac6d68ec45
commit 95f5fd978f
No known key found for this signature in database
GPG key ID: 3E30B3F26C7B4AA2
2 changed files with 11 additions and 15 deletions

View file

@ -48,14 +48,14 @@ export function createResponse(responseType, responseData) {
case "error":
response = {
error: {
code: responseData.code,
code: responseData?.code,
context: responseData?.context,
}
}
break;
case "redirect":
response = {
url: responseData.u,
url: responseData?.u,
}
break;
@ -66,22 +66,15 @@ export function createResponse(responseType, responseData) {
break;
case "picker":
let pickerType = "various",
audio = false;
if (responseData.service === "tiktok") {
audio = responseData.u;
pickerType = "images";
}
response = {
pickerType: pickerType,
picker: responseData.picker,
audio: audio,
picker: responseData?.picker,
audio: responseData?.u
}
break;
case "critical":
return internalError(responseData.code);
return internalError(responseData?.code);
default:
throw "unreachable"
}

View file

@ -96,7 +96,10 @@ export default async function(obj) {
if (images) {
let imageLinks = images
.map(i => i.imageURL.urlList.find(p => p.includes(".jpeg?")))
.map(url => ({ url }));
.map(url => ({
type: "photo",
url
}));
return {
picker: imageLinks,