diff --git a/.config/docker_example.yml b/.config/docker_example.yml index c6c83a98bf..6d82fdcc79 100644 --- a/.config/docker_example.yml +++ b/.config/docker_example.yml @@ -106,7 +106,7 @@ redis: # ┌───────────────────────────┐ #───┘ MeiliSearch configuration └───────────────────────────── -# You can set scope to local (default value) or global +# You can set scope to local (default value) or global # (include notes from remote). #meilisearch: @@ -198,13 +198,18 @@ proxyRemoteFiles: true # https://example.com/thumbnail.webp?thumbnail=1&url=https%3A%2F%2Fstorage.example.com%2Fpath%2Fto%2Fvideo.mp4 #videoThumbnailGenerator: https://example.com +# Enables the built-in thumbnail generator for remote videos. (default: false) +# Only useful if "Cache remote files" is disabled, and "videoThumbnailGenerator" is unset. +# Without it, remote video files that are not cached will not have any thumbnails. +#enableBuiltinVideoThumbnailGenerator: false + # Sign to ActivityPub GET request (default: true) signToActivityPubGet: true # check that inbound ActivityPub GET requests are signed ("authorized fetch") checkActivityPubGetSignature: false # For security reasons, uploading attachments from the intranet is prohibited, -# but exceptions can be made from the following settings. Default value is "undefined". +# but exceptions can be made from the following settings. Default value is "undefined". # Read changelog to learn more (Improvements of 12.90.0 (2021/09/04)). #allowedPrivateNetworks: [ # '127.0.0.1/32' diff --git a/.config/example.yml b/.config/example.yml index 4aa7757c61..183331ef63 100644 --- a/.config/example.yml +++ b/.config/example.yml @@ -118,7 +118,7 @@ redis: # ┌───────────────────────────┐ #───┘ MeiliSearch configuration └───────────────────────────── -# You can set scope to local (default value) or global +# You can set scope to local (default value) or global # (include notes from remote). #meilisearch: @@ -213,13 +213,18 @@ proxyRemoteFiles: true # https://example.com/thumbnail.webp?thumbnail=1&url=https%3A%2F%2Fstorage.example.com%2Fpath%2Fto%2Fvideo.mp4 #videoThumbnailGenerator: https://example.com +# Enables the built-in thumbnail generator for remote videos. (default: false) +# Only useful if "Cache remote files" is disabled, and "videoThumbnailGenerator" is unset. +# Without it, remote video files that are not cached will not have any thumbnails. +#enableBuiltinVideoThumbnailGenerator: false + # Sign to ActivityPub GET request (default: true) signToActivityPubGet: true # check that inbound ActivityPub GET requests are signed ("authorized fetch") checkActivityPubGetSignature: false # For security reasons, uploading attachments from the intranet is prohibited, -# but exceptions can be made from the following settings. Default value is "undefined". +# but exceptions can be made from the following settings. Default value is "undefined". # Read changelog to learn more (Improvements of 12.90.0 (2021/09/04)). #allowedPrivateNetworks: [ # '127.0.0.1/32' diff --git a/packages/backend/src/config.ts b/packages/backend/src/config.ts index a550fdc364..137506bb64 100644 --- a/packages/backend/src/config.ts +++ b/packages/backend/src/config.ts @@ -86,6 +86,7 @@ type Source = { mediaProxy?: string; proxyRemoteFiles?: boolean; videoThumbnailGenerator?: string; + enableBuiltinVideoThumbnailGenerator?: boolean; customMOTD?: string[]; @@ -167,6 +168,7 @@ export type Config = { mediaProxy: string; externalMediaProxyEnabled: boolean; videoThumbnailGenerator: string | null; + enableBuiltinVideoThumbnailGenerator: boolean; redis: RedisOptions & RedisOptionsSource; redisForPubsub: RedisOptions & RedisOptionsSource; redisForJobQueue: RedisOptions & RedisOptionsSource; @@ -272,6 +274,7 @@ export function loadConfig(): Config { videoThumbnailGenerator: config.videoThumbnailGenerator ? config.videoThumbnailGenerator.endsWith('/') ? config.videoThumbnailGenerator.substring(0, config.videoThumbnailGenerator.length - 1) : config.videoThumbnailGenerator : null, + enableBuiltinVideoThumbnailGenerator: config.enableBuiltinVideoThumbnailGenerator ?? false, userAgent: `Misskey/${version} (${config.url})`, clientEntry: clientManifest['src/_boot_.ts'], clientManifestExists: clientManifestExists, diff --git a/packages/backend/src/core/VideoProcessingService.ts b/packages/backend/src/core/VideoProcessingService.ts index e157160b45..c9f706e5c8 100644 --- a/packages/backend/src/core/VideoProcessingService.ts +++ b/packages/backend/src/core/VideoProcessingService.ts @@ -51,12 +51,14 @@ export class VideoProcessingService { @bindThis public getExternalVideoThumbnailUrl(url: string): string | null { if (this.config.videoThumbnailGenerator == null) { - return appendQuery( - `${this.config.url}/proxy/thumbnail.webp`, - query({ - url, - }), - ); + if (this.config.enableBuiltinVideoThumbnailGenerator) { + return appendQuery( + `${this.config.url}/proxy/thumbnail.webp`, + query({ url }), + ); + } + + return null; } return appendQuery( diff --git a/packages/backend/src/server/FileServerService.ts b/packages/backend/src/server/FileServerService.ts index 6659932ed1..3614ea21b6 100644 --- a/packages/backend/src/server/FileServerService.ts +++ b/packages/backend/src/server/FileServerService.ts @@ -83,12 +83,14 @@ export class FileServerService { .catch(err => this.errorHandler(request, reply, err)); }); - fastify.get<{ - Querystring: { url: string; }; - }>('/proxy/thumbnail.webp', async (request, reply) => { - return await this.videoThumbnailHandler(request, reply) - .catch(err => this.errorHandler(request, reply, err)); - }); + if (this.config.enableBuiltinVideoThumbnailGenerator) { + fastify.get<{ + Querystring: { url: string; }; + }>('/proxy/thumbnail.webp', async (request, reply) => { + return await this.videoThumbnailHandler(request, reply) + .catch(err => this.errorHandler(request, reply, err)); + }); + } fastify.get<{ Params: { url: string; }; @@ -395,7 +397,7 @@ export class FileServerService { if (file === '404') { reply.code(404); reply.header('Cache-Control', 'max-age=86400'); - return reply.sendFile('/dummy.png', assets); // TODO: return webp + return reply.sendFile('/dummy.png', assets); } if (file === '204') {