UNPKG

rsshub

Version:
78 lines (74 loc) 3.32 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 "./render-BQo6B4tL.mjs"; import "./got-KxxWdaxq.mjs"; import { t as invalid_parameter_default } from "./invalid-parameter-rr4AgGpp.mjs"; import { t as config_not_found_default } from "./config-not-found-Dyp3RlZZ.mjs"; import { n as queryToBoolean, t as fallback } from "./readable-social-DoIL4WB3.mjs"; import { t as utils_default } from "./utils-GeEoF2-w.mjs"; import querystring from "node:querystring"; //#region lib/routes/misskey/user-timeline.ts const route = { path: "/users/notes/:username/:routeParams?", categories: ["social-media"], view: ViewType.SocialMedia, example: "/misskey/users/notes/support@misskey.io", parameters: { username: "Misskey username in the format of username@instance.domain", routeParams: ` | Key | Description | Accepted Values | Default | | ----------------- | --------------------------------------- | --------------- | ------- | | withRenotes | Include renotes in the timeline | 0/1/true/false | false | | mediaOnly | Only return posts containing media | 0/1/true/false | false | | simplifyAuthor | Simplify author field in feed items | 0/1/true/false | false | Note: \`withRenotes\` and \`mediaOnly\` are mutually exclusive and cannot both be set to true. Examples: - /misskey/users/notes/mttb2ccp@misskey.io/withRenotes=true - /misskey/users/notes/mttb2ccp@misskey.io/mediaOnly=true` }, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false }, name: "User timeline", maintainers: [ "siygle", "SnowAgar25", "HanaokaYuzu" ], handler }; async function handler(ctx) { const username = ctx.req.param("username"); const [, pureUsername, site] = username.match(/@?(\w+)@(\w+\.\w+)/) || []; if (!pureUsername || !site) throw new invalid_parameter_default("Provide a valid Misskey username"); 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 routeParams = querystring.parse(ctx.req.param("routeParams")); const withRenotes = fallback(void 0, queryToBoolean(routeParams.withRenotes), false); const mediaOnly = fallback(void 0, queryToBoolean(routeParams.mediaOnly), false); const simplifyAuthor = fallback(void 0, queryToBoolean(routeParams.simplifyAuthor), false); if (withRenotes && mediaOnly) throw new invalid_parameter_default("withRenotes and mediaOnly cannot both be true."); const { accountData, avatarUrl } = await utils_default.getUserTimelineByUsername(pureUsername, site, { withRenotes, mediaOnly }); return { title: `User timeline for ${username} on ${site}`, link: `https://${site}/@${pureUsername}`, image: avatarUrl ?? "", item: utils_default.parseNotes(accountData, site, simplifyAuthor) }; } //#endregion export { route };