From 95f5fd978fbe545887b59586b7d0e3218c7f847c Mon Sep 17 00:00:00 2001 From: wukko Date: Tue, 6 Aug 2024 21:30:18 +0600 Subject: [PATCH] api: merge two picker types into one --- api/src/processing/request.js | 21 +++++++-------------- api/src/processing/services/tiktok.js | 5 ++++- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/api/src/processing/request.js b/api/src/processing/request.js index 22e34969..c503788c 100644 --- a/api/src/processing/request.js +++ b/api/src/processing/request.js @@ -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" } diff --git a/api/src/processing/services/tiktok.js b/api/src/processing/services/tiktok.js index 33e7aef3..45f61e2e 100644 --- a/api/src/processing/services/tiktok.js +++ b/api/src/processing/services/tiktok.js @@ -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,