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":
|
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"
|
||||||
}
|
}
|
||||||
|
|
|
@ -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,
|
||||||
|
|
Loading…
Reference in a new issue