fix: Run to boolean conversion in mastoAPI public and hashtag timelines

The `only_media` query parameter in `/api/v1/timelines/public` and
`/api/v1/timelines/tag/:hashtag` was previously passed directly as-is to
the Misskey API, which made it pretty upset because it was receiving a
string named 'true' instead of the value 'true'.

Needed for pleromaFE to display a timeline.
This commit is contained in:
fruye 2023-03-15 21:38:12 +01:00
parent 0e2a5b3093
commit fcbee6d3f5

View file

@ -92,8 +92,8 @@ export function apiTimelineMastodon(router: Router): void {
try { try {
const query: any = ctx.query; const query: any = ctx.query;
const data = query.local const data = query.local
? await client.getLocalTimeline(limitToInt(query)) ? await client.getLocalTimeline(argsToBools(limitToInt(query)))
: await client.getPublicTimeline(limitToInt(query)); : await client.getPublicTimeline(argsToBools(limitToInt(query)));
ctx.body = toTextWithReaction(data.data, ctx.hostname); ctx.body = toTextWithReaction(data.data, ctx.hostname);
} catch (e: any) { } catch (e: any) {
console.error(e); console.error(e);
@ -111,7 +111,7 @@ export function apiTimelineMastodon(router: Router): void {
try { try {
const data = await client.getTagTimeline( const data = await client.getTagTimeline(
ctx.params.hashtag, ctx.params.hashtag,
limitToInt(ctx.query), argsToBools(limitToInt(ctx.query)),
); );
ctx.body = toTextWithReaction(data.data, ctx.hostname); ctx.body = toTextWithReaction(data.data, ctx.hostname);
} catch (e: any) { } catch (e: any) {