mirror of
https://github.com/wukko/cobalt.git
synced 2024-11-15 12:50:01 +00:00
api: merge two picker types into one
This commit is contained in:
parent
ac6d68ec45
commit
95f5fd978f
2 changed files with 11 additions and 15 deletions
|
@ -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"
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue