UNPKG

rsshub

Version:
53 lines (51 loc) 1.98 kB
import "./esm-shims-CzJ_djXG.mjs"; import { t as config } from "./config-C37vj7VH.mjs"; import { t as ViewType } from "./types-D84BRIt4.mjs"; import "./dist-BInvbO1W.mjs"; import "./logger-Czu8UMNd.mjs"; import "./ofetch-BIyrKU3Y.mjs"; import "./parse-date-BrP7mxXf.mjs"; import "./cache-Bo__VnGm.mjs"; import "./helpers-DxBp0Pty.mjs"; import { t as got_default } from "./got-KxxWdaxq.mjs"; import { t as config_not_found_default } from "./config-not-found-Dyp3RlZZ.mjs"; import { t as utils_default } from "./utils-C0JQJOC9.mjs"; //#region lib/routes/mastodon/tag.ts const route = { path: "/tag/:site/:hashtag/:only_media?", categories: ["social-media"], view: ViewType.SocialMedia, example: "/mastodon/tag/mastodon.social/gochisou/true", parameters: { site: "instance address, only domain, no `http://` or `https://` protocol header", hashtag: "Hashtag you want to subscribe to (without the # symbol)", only_media: { description: "whether only display media content, default to false, any value to true", options: [{ value: "true", label: "true" }, { value: "false", label: "false" }], default: "false" } }, name: "Hashtag timeline", maintainers: ["yuikisaito"], handler }; async function handler(ctx) { const { site, hashtag } = ctx.req.param(); const only_media = ctx.req.param("only_media") === "true" ? "true" : "false"; if (!config.feature.allow_user_supply_unsafe_domain && !utils_default.allowSiteList.includes(site)) throw new config_not_found_default(`This RSS is disabled unless 'ALLOW_USER_SUPPLY_UNSAFE_DOMAIN' is set to 'true'.`); const url = `http://${site}/api/v1/timelines/tag/${hashtag}?only_media=${only_media}`; const list = (await got_default.get(url, { headers: utils_default.apiHeaders(site) })).data; return { title: `#${hashtag} ${only_media === "true" ? " Media" : ""} Timeline on ${site}`, link: `https://${site}`, item: utils_default.parseStatuses(list) }; } //#endregion export { route };