[mastodon-client] fix search type param
This commit is contained in:
parent
8323a33f97
commit
7ffe30dcdb
1 changed files with 19 additions and 15 deletions
|
@ -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 a new issue