rss json atomを隠した

This commit is contained in:
hijiki 2024-11-01 18:07:22 +09:00
parent b3fc2b484a
commit 1bfcdc45e8
3 changed files with 72 additions and 71 deletions

View File

@ -485,7 +485,7 @@ export class ClientServerService {
// URL preview endpoint // URL preview endpoint
fastify.get<{ Querystring: { url: string; lang: string; } }>('/url', (request, reply) => this.urlPreviewService.handle(request, reply)); fastify.get<{ Querystring: { url: string; lang: string; } }>('/url', (request, reply) => this.urlPreviewService.handle(request, reply));
const getFeed = async (acct: string) => { /* const getFeed = async (acct: string) => {
const { username, host } = Acct.parse(acct); const { username, host } = Acct.parse(acct);
const user = await this.usersRepository.findOneBy({ const user = await this.usersRepository.findOneBy({
usernameLower: username.toLowerCase(), usernameLower: username.toLowerCase(),
@ -496,7 +496,7 @@ export class ClientServerService {
return user && await this.feedService.packFeed(user); return user && await this.feedService.packFeed(user);
}; };
// Atom /* // Atom
fastify.get<{ Params: { user?: string; } }>('/@:user.atom', async (request, reply) => { fastify.get<{ Params: { user?: string; } }>('/@:user.atom', async (request, reply) => {
if (request.params.user == null) return await renderBase(reply); if (request.params.user == null) return await renderBase(reply);
@ -540,7 +540,7 @@ export class ClientServerService {
return; return;
} }
}); });
*/
//#region SSR (for crawlers) //#region SSR (for crawlers)
// User // User
fastify.get<{ Params: { user: string; sub?: string; } }>('/@:user/:sub?', async (request, reply) => { fastify.get<{ Params: { user: string; sub?: string; } }>('/@:user/:sub?', async (request, reply) => {

View File

@ -41,11 +41,11 @@ export class FeedService {
@bindThis @bindThis
public async packFeed(user: MiUser) { public async packFeed(user: MiUser) {
const author = { // フィード生成を無効化
link: `${this.config.url}/@${user.username}`, throw new Error("フィード生成は無効化されています");
name: user.name ?? user.username,
};
// フィード生成のロジックはここでコメントアウトまたは削除します
/*
const profile = await this.userProfilesRepository.findOneByOrFail({ userId: user.id }); const profile = await this.userProfilesRepository.findOneByOrFail({ userId: user.id });
const notes = await this.notesRepository.find({ const notes = await this.notesRepository.find({
@ -92,5 +92,6 @@ export class FeedService {
} }
return feed; return feed;
*/
} }
} }

View File

@ -133,13 +133,13 @@ describe('Webリソース', () => {
}); });
describe.each([ describe.each([
{ ext: 'rss', type: 'application/rss+xml; charset=utf-8' }, /* { ext: 'rss', type: 'application/rss+xml; charset=utf-8' },
{ ext: 'atom', type: 'application/atom+xml; charset=utf-8' }, { ext: 'atom', type: 'application/atom+xml; charset=utf-8' },
{ ext: 'json', type: 'application/json; charset=utf-8' }, { ext: 'json', type: 'application/json; charset=utf-8' },*/
])('/@:username.$ext', ({ ext, type }) => { ])('/@:username.$ext', ({ ext, type }) => {
const path = (username: string): string => `/@${username}.${ext}`; const path = (username: string): string => `/@${username}.${ext}`;
test('がGETできる。', async () => await ok({ /* test('GET', async () => await ok({
path: path(alice.username), path: path(alice.username),
type, type,
})); }));
@ -161,7 +161,7 @@ describe('Webリソース', () => {
test('MFMを含まない。', async () => { test('MFMを含まない。', async () => {
const content = await simpleGet(path(alice.username), "*/*", undefined, res => res.text()); const content = await simpleGet(path(alice.username), "*/*", undefined, res => res.text());
const _body: unknown = content.body; /* const _body: unknown = content.body;
// JSONフィードのときは改めて文字列化する // JSONフィードのときは改めて文字列化する
const body: string = typeof (_body) === "object" ? JSON.stringify(_body) : _body as string; const body: string = typeof (_body) === "object" ? JSON.stringify(_body) : _body as string;
@ -169,7 +169,7 @@ describe('Webリソース', () => {
throw new Error("MFM shouldn't be included"); throw new Error("MFM shouldn't be included");
} }
}); });
}) })*/
}); });
describe.each([{ path: '/api/foo' }])('$path', ({ path }) => { describe.each([{ path: '/api/foo' }])('$path', ({ path }) => {