mirror of
https://iceshrimp.dev/crimekillz/trashposs
synced 2024-11-22 17:03:49 +01:00
[mastodon-client] fix search type param
This commit is contained in:
parent
4cf8c70bf5
commit
22825ae76a
@ -30,21 +30,25 @@ export function apiSearchMastodon(router: Router): void {
|
|||||||
try {
|
try {
|
||||||
const query: any = convertTimelinesArgsId(limitToInt(ctx.query));
|
const query: any = convertTimelinesArgsId(limitToInt(ctx.query));
|
||||||
const type = query.type;
|
const type = query.type;
|
||||||
if (type) {
|
const acct =
|
||||||
const data = await client.search(query.q, type, query);
|
!type || type === "accounts"
|
||||||
ctx.body = data.data.accounts.map((account) => convertAccount(account));
|
? await client.search(query.q, "accounts", query)
|
||||||
} else {
|
: null;
|
||||||
const acct = await client.search(query.q, "accounts", query);
|
const stat =
|
||||||
const stat = await client.search(query.q, "statuses", query);
|
!type || type === "statuses"
|
||||||
const tags = await client.search(query.q, "hashtags", query);
|
? await client.search(query.q, "statuses", query)
|
||||||
|
: null;
|
||||||
|
const tags =
|
||||||
|
!type || type === "hashtags"
|
||||||
|
? await client.search(query.q, "hashtags", query)
|
||||||
|
: null;
|
||||||
ctx.body = {
|
ctx.body = {
|
||||||
accounts: acct.data.accounts.map((account) =>
|
accounts:
|
||||||
convertAccount(account),
|
acct?.data?.accounts.map((account) => convertAccount(account)) ?? [],
|
||||||
),
|
statuses:
|
||||||
statuses: stat.data.statuses.map((status) => convertStatus(status)),
|
stat?.data?.statuses.map((status) => convertStatus(status)) ?? [],
|
||||||
hashtags: tags.data.hashtags,
|
hashtags: tags?.data?.hashtags ?? [],
|
||||||
};
|
};
|
||||||
}
|
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
ctx.status = 401;
|
ctx.status = 401;
|
||||||
|
Loading…
Reference in New Issue
Block a user