From 787cb1c76ae17d5ca23f0de5233dc9a24e61a5de Mon Sep 17 00:00:00 2001 From: Jeff Wen Date: Mon, 11 Nov 2024 13:23:20 +0800 Subject: [PATCH] fix(route/mastodon): Correct the only_media param (#17531) --- lib/routes/mastodon/account-id.ts | 2 +- lib/routes/mastodon/acct.ts | 2 +- lib/routes/mastodon/timeline-local.ts | 4 ++-- lib/routes/mastodon/timeline-remote.ts | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/routes/mastodon/account-id.ts b/lib/routes/mastodon/account-id.ts index f1fb49110e228f..1d9ddf90a24d1d 100644 --- a/lib/routes/mastodon/account-id.ts +++ b/lib/routes/mastodon/account-id.ts @@ -36,7 +36,7 @@ export const route: Route = { async function handler(ctx) { const site = ctx.req.param('site'); const account_id = ctx.req.param('account_id'); - const only_media = ctx.req.param('only_media') ? 'true' : 'false'; + const only_media = ctx.req.param('only_media') === 'true' ? 'true' : 'false'; if (!config.feature.allow_user_supply_unsafe_domain && !utils.allowSiteList.includes(site)) { throw new ConfigNotFoundError(`This RSS is disabled unless 'ALLOW_USER_SUPPLY_UNSAFE_DOMAIN' is set to 'true'.`); } diff --git a/lib/routes/mastodon/acct.ts b/lib/routes/mastodon/acct.ts index ae5f5b919ef6d7..6ee925dcb2bd67 100644 --- a/lib/routes/mastodon/acct.ts +++ b/lib/routes/mastodon/acct.ts @@ -35,7 +35,7 @@ However, you can still specify these route-specific configurations if you need t async function handler(ctx) { const acct = ctx.req.param('acct'); - const only_media = ctx.req.param('only_media') ? 'true' : 'false'; + const only_media = ctx.req.param('only_media') === 'true' ? 'true' : 'false'; const { site, account_id } = await utils.getAccountIdByAcct(acct); diff --git a/lib/routes/mastodon/timeline-local.ts b/lib/routes/mastodon/timeline-local.ts index 1713c9e8fba5bb..ad1b34e19b45c3 100644 --- a/lib/routes/mastodon/timeline-local.ts +++ b/lib/routes/mastodon/timeline-local.ts @@ -36,7 +36,7 @@ export const route: Route = { async function handler(ctx) { const site = ctx.req.param('site'); - const only_media = ctx.req.param('only_media') ? 'true' : 'false'; + const only_media = ctx.req.param('only_media') === 'true' ? 'true' : 'false'; if (!config.feature.allow_user_supply_unsafe_domain && !utils.allowSiteList.includes(site)) { throw new ConfigNotFoundError(`This RSS is disabled unless 'ALLOW_USER_SUPPLY_UNSAFE_DOMAIN' is set to 'true'.`); } @@ -47,7 +47,7 @@ async function handler(ctx) { const list = response.data; return { - title: `Local Public${ctx.req.param('only_media') ? ' Media' : ''} Timeline on ${site}`, + title: `Local Public${ctx.req.param('only_media') === 'true' ? ' Media' : ''} Timeline on ${site}`, link: `https://${site}`, item: utils.parseStatuses(list), }; diff --git a/lib/routes/mastodon/timeline-remote.ts b/lib/routes/mastodon/timeline-remote.ts index 5e962735371731..bc441b9ece8415 100644 --- a/lib/routes/mastodon/timeline-remote.ts +++ b/lib/routes/mastodon/timeline-remote.ts @@ -36,7 +36,7 @@ export const route: Route = { async function handler(ctx) { const site = ctx.req.param('site'); - const only_media = ctx.req.param('only_media') ? 'true' : 'false'; + const only_media = ctx.req.param('only_media') === 'true' ? 'true' : 'false'; if (!config.feature.allow_user_supply_unsafe_domain && !utils.allowSiteList.includes(site)) { throw new ConfigNotFoundError(`This RSS is disabled unless 'ALLOW_USER_SUPPLY_UNSAFE_DOMAIN' is set to 'true'.`); } @@ -47,7 +47,7 @@ async function handler(ctx) { const list = response.data; return { - title: `Federated Public${ctx.req.param('only_media') ? ' Media' : ''} Timeline on ${site}`, + title: `Federated Public${ctx.req.param('only_media') === 'true' ? ' Media' : ''} Timeline on ${site}`, link: `https://${site}`, item: utils.parseStatuses(list), };