mirror of
https://iceshrimp.dev/limepotato/jormungandr-bite.git
synced 2024-11-13 13:37:31 -07:00
[mastodon-client] fix search type param
This commit is contained in:
parent
4cf8c70bf5
commit
22825ae76a
1 changed files with 19 additions and 15 deletions
|
@ -30,21 +30,25 @@ export function apiSearchMastodon(router: Router): void {
|
|||
try {
|
||||
const query: any = convertTimelinesArgsId(limitToInt(ctx.query));
|
||||
const type = query.type;
|
||||
if (type) {
|
||||
const data = await client.search(query.q, type, query);
|
||||
ctx.body = data.data.accounts.map((account) => convertAccount(account));
|
||||
} else {
|
||||
const acct = await client.search(query.q, "accounts", query);
|
||||
const stat = await client.search(query.q, "statuses", query);
|
||||
const tags = await client.search(query.q, "hashtags", query);
|
||||
ctx.body = {
|
||||
accounts: acct.data.accounts.map((account) =>
|
||||
convertAccount(account),
|
||||
),
|
||||
statuses: stat.data.statuses.map((status) => convertStatus(status)),
|
||||
hashtags: tags.data.hashtags,
|
||||
};
|
||||
}
|
||||
const acct =
|
||||
!type || type === "accounts"
|
||||
? await client.search(query.q, "accounts", query)
|
||||
: null;
|
||||
const stat =
|
||||
!type || type === "statuses"
|
||||
? await client.search(query.q, "statuses", query)
|
||||
: null;
|
||||
const tags =
|
||||
!type || type === "hashtags"
|
||||
? await client.search(query.q, "hashtags", query)
|
||||
: null;
|
||||
ctx.body = {
|
||||
accounts:
|
||||
acct?.data?.accounts.map((account) => convertAccount(account)) ?? [],
|
||||
statuses:
|
||||
stat?.data?.statuses.map((status) => convertStatus(status)) ?? [],
|
||||
hashtags: tags?.data?.hashtags ?? [],
|
||||
};
|
||||
} catch (e: any) {
|
||||
console.error(e);
|
||||
ctx.status = 401;
|
||||
|
|
Loading…
Reference in a new issue