chore: rename 'FeedType' to 'FeedFormat'
This commit is contained in:
parent
61ebb3772a
commit
108e547fb6
|
|
@ -37,7 +37,7 @@ import { deepClone } from '@/misc/clone.js';
|
|||
import { bindThis } from '@/decorators.js';
|
||||
import { FlashEntityService } from '@/core/entities/FlashEntityService.js';
|
||||
import { RoleService } from '@/core/RoleService.js';
|
||||
import { FeedService, FeedType } from './FeedService.js';
|
||||
import { FeedService, FeedFormat } from './FeedService.js';
|
||||
import { UrlPreviewService } from './UrlPreviewService.js';
|
||||
import { ClientLoggerService } from './ClientLoggerService.js';
|
||||
import type { FastifyInstance, FastifyPluginOptions, FastifyReply } from 'fastify';
|
||||
|
|
@ -417,11 +417,11 @@ export class ClientServerService {
|
|||
fastify.get<{ Querystring: { url: string; lang: string; } }>('/url', (request, reply) => this.urlPreviewService.handle(request, reply));
|
||||
|
||||
// Feed
|
||||
const feedTypes: FeedType[] = ['atom', 'rss', 'json'];
|
||||
for (const feedType of feedTypes) {
|
||||
fastify.get<{ Params: { user: string; } }>(`/@:user.${feedType}`, this.feedService.handle(feedType));
|
||||
fastify.get<{ Params: { user: string; } }>(`/@:user.with_replies.${feedType}`, this.feedService.handle(feedType, { withReplies: true }));
|
||||
fastify.get<{ Params: { user: string; } }>(`/@:user.with_files.${feedType}`, this.feedService.handle(feedType, { withFiles: true }));
|
||||
const feedFormats: FeedFormat[] = ['atom', 'rss', 'json'];
|
||||
for (const feedFormat of feedFormats) {
|
||||
fastify.get<{ Params: { user: string; } }>(`/@:user.${feedFormat}`, this.feedService.handle(feedFormat));
|
||||
fastify.get<{ Params: { user: string; } }>(`/@:user.with_replies.${feedFormat}`, this.feedService.handle(feedFormat, { withReplies: true }));
|
||||
fastify.get<{ Params: { user: string; } }>(`/@:user.with_files.${feedFormat}`, this.feedService.handle(feedFormat, { withFiles: true }));
|
||||
}
|
||||
|
||||
//#region SSR (for crawlers)
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ import { IdService } from '@/core/IdService.js';
|
|||
import { FunoutTimelineService } from '@/core/FunoutTimelineService.js';
|
||||
import type { FastifyReply, FastifyRequest } from 'fastify';
|
||||
|
||||
export type FeedType = 'atom' | 'rss' | 'json';
|
||||
export type FeedFormat = 'atom' | 'rss' | 'json';
|
||||
|
||||
@Injectable()
|
||||
export class FeedService {
|
||||
|
|
@ -125,7 +125,7 @@ export class FeedService {
|
|||
|
||||
@bindThis
|
||||
public handle(
|
||||
feedType: FeedType,
|
||||
feedFormat: FeedFormat,
|
||||
options?: {
|
||||
withReplies?: boolean;
|
||||
withFiles?: boolean;
|
||||
|
|
@ -145,14 +145,14 @@ export class FeedService {
|
|||
const feed = user && await this.packFeed(user, options);
|
||||
|
||||
if (feed) {
|
||||
const subtype = feedType === 'atom' || feedType === 'rss'
|
||||
? `${feedType}+xml`
|
||||
: feedType;
|
||||
const subtype = feedFormat === 'atom' || feedFormat === 'rss'
|
||||
? `${feedFormat}+xml`
|
||||
: feedFormat;
|
||||
|
||||
reply.header('Content-Type', `application/${subtype}; charset=utf-8`);
|
||||
|
||||
if (feedType === 'atom') return feed.atom1();
|
||||
else if (feedType === 'rss') return feed.rss2();
|
||||
if (feedFormat === 'atom') return feed.atom1();
|
||||
else if (feedFormat === 'rss') return feed.rss2();
|
||||
else return feed.json1();
|
||||
} else {
|
||||
reply.code(404);
|
||||
|
|
|
|||
Loading…
Reference in New Issue