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

View file

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