From 7ae1d6511a68ee8e11f17351a559f7dc1f651938 Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 10 May 2023 10:57:27 +0900 Subject: [PATCH] add X-Robots-Tag: noai --- .../src/server/web/ClientServerService.ts | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/packages/backend/src/server/web/ClientServerService.ts b/packages/backend/src/server/web/ClientServerService.ts index 50b23a068..12369c927 100644 --- a/packages/backend/src/server/web/ClientServerService.ts +++ b/packages/backend/src/server/web/ClientServerService.ts @@ -35,8 +35,8 @@ import { RoleService } from '@/core/RoleService.js'; import manifest from './manifest.json' assert { type: 'json' }; import { FeedService } from './FeedService.js'; import { UrlPreviewService } from './UrlPreviewService.js'; -import type { FastifyInstance, FastifyPluginOptions, FastifyReply } from 'fastify'; import { ClientLoggerService } from './ClientLoggerService.js'; +import type { FastifyInstance, FastifyPluginOptions, FastifyReply } from 'fastify'; const _filename = fileURLToPath(import.meta.url); const _dirname = dirname(_filename); @@ -423,6 +423,10 @@ export class ClientServerService { : []; reply.header('Cache-Control', 'public, max-age=15'); + if (profile.preventAiLarning) { + reply.header('X-Robots-Tag', 'noimageai'); + reply.header('X-Robots-Tag', 'noai'); + } return await reply.view('user', { user, profile, me, avatarUrl: user.avatarUrl ?? this.userEntityService.getIdenticonUrl(user), @@ -467,6 +471,10 @@ export class ClientServerService { const profile = await this.userProfilesRepository.findOneByOrFail({ userId: note.userId }); const meta = await this.metaService.fetch(); reply.header('Cache-Control', 'public, max-age=15'); + if (profile.preventAiLarning) { + reply.header('X-Robots-Tag', 'noimageai'); + reply.header('X-Robots-Tag', 'noai'); + } return await reply.view('note', { note: _note, profile, @@ -506,6 +514,10 @@ export class ClientServerService { } else { reply.header('Cache-Control', 'private, max-age=0, must-revalidate'); } + if (profile.preventAiLarning) { + reply.header('X-Robots-Tag', 'noimageai'); + reply.header('X-Robots-Tag', 'noai'); + } return await reply.view('page', { page: _page, profile, @@ -530,6 +542,10 @@ export class ClientServerService { const profile = await this.userProfilesRepository.findOneByOrFail({ userId: flash.userId }); const meta = await this.metaService.fetch(); reply.header('Cache-Control', 'public, max-age=15'); + if (profile.preventAiLarning) { + reply.header('X-Robots-Tag', 'noimageai'); + reply.header('X-Robots-Tag', 'noai'); + } return await reply.view('flash', { flash: _flash, profile, @@ -554,6 +570,10 @@ export class ClientServerService { const profile = await this.userProfilesRepository.findOneByOrFail({ userId: clip.userId }); const meta = await this.metaService.fetch(); reply.header('Cache-Control', 'public, max-age=15'); + if (profile.preventAiLarning) { + reply.header('X-Robots-Tag', 'noimageai'); + reply.header('X-Robots-Tag', 'noai'); + } return await reply.view('clip', { clip: _clip, profile, @@ -576,6 +596,10 @@ export class ClientServerService { const profile = await this.userProfilesRepository.findOneByOrFail({ userId: post.userId }); const meta = await this.metaService.fetch(); reply.header('Cache-Control', 'public, max-age=15'); + if (profile.preventAiLarning) { + reply.header('X-Robots-Tag', 'noimageai'); + reply.header('X-Robots-Tag', 'noai'); + } return await reply.view('gallery-post', { post: _post, profile,