CDNキャッシュのオン・オフを切り替えられるように

This commit is contained in:
kakkokari-gtyih 2024-12-28 18:27:54 +09:00
parent 5ad0fe70a1
commit 677e980a1c
12 changed files with 1418 additions and 1 deletions

8
locales/index.d.ts vendored
View File

@ -5222,6 +5222,14 @@ export interface Locale extends ILocale {
*
*/
"acknowledgeNotesAndEnable": string;
/**
* CDNキャッシュを併用する
*/
"enableStreamNotesCdnCache": string;
/**
* CDNを使用している場合はCDNの設定を適切に調整するとサーバーへの負荷を軽減できますWebSocket通信ではリアルタイム性のある情報のみを送信しCDNキャッシュから取得して突合します
*/
"enableStreamNotesCdnCacheDescription": string;
"_accountSettings": {
/**
*

View File

@ -1301,6 +1301,8 @@ lockdown: "ロックダウン"
pleaseSelectAccount: "アカウントを選択してください"
availableRoles: "利用可能なロール"
acknowledgeNotesAndEnable: "注意事項を理解した上でオンにします。"
enableStreamNotesCdnCache: "リアルタイム更新時のート取得にCDNキャッシュを併用する"
enableStreamNotesCdnCacheDescription: "サーバーでCDNを使用している場合は、この設定をオンにしたうえでCDNの設定を適切に調整するとサーバーへの負荷を軽減できます上級者向け。WebSocket通信ではリアルタイム性のある情報のみを送信し、残りの情報はCDNキャッシュから取得して突合します。このため、クライアント側の負荷やデータ通信量に影響が出る可能性があります。"
_accountSettings:
requireSigninToViewContents: "コンテンツの表示にログインを必須にする"

View File

@ -0,0 +1,16 @@
/*
* SPDX-FileCopyrightText: syuilo and misskey-project
* SPDX-License-Identifier: AGPL-3.0-only
*/
export class StreamNotesCdnCache1735377503979 {
name = 'StreamNotesCdnCache1735377503979'
async up(queryRunner) {
await queryRunner.query(`ALTER TABLE "meta" ADD "enableStreamNotesCdnCache" boolean NOT NULL DEFAULT false`);
}
async down(queryRunner) {
await queryRunner.query(`ALTER TABLE "meta" DROP COLUMN "enableStreamNotesCdnCache"`);
}
}

View File

@ -609,6 +609,11 @@ export class MiMeta {
})
public enableReactionsBuffering: boolean;
@Column('boolean', {
default: false,
})
public enableStreamNotesCdnCache: boolean;
@Column('integer', {
default: 0,
})

View File

@ -215,6 +215,10 @@ export const packedMetaLiteSchema = {
type: 'boolean',
optional: false, nullable: false,
},
enableStreamNotesCdnCache: {
type: 'boolean',
optional: false, nullable: false,
},
backgroundImageUrl: {
type: 'string',
optional: false, nullable: true,

View File

@ -396,6 +396,10 @@ export const meta = {
type: 'boolean',
optional: false, nullable: false,
},
enableStreamNotesCdnCache: {
type: 'boolean',
optional: false, nullable: false,
},
notesPerOneAd: {
type: 'number',
optional: false, nullable: false,
@ -652,6 +656,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
perUserHomeTimelineCacheMax: instance.perUserHomeTimelineCacheMax,
perUserListTimelineCacheMax: instance.perUserListTimelineCacheMax,
enableReactionsBuffering: instance.enableReactionsBuffering,
enableStreamNotesCdnCache: instance.enableStreamNotesCdnCache,
notesPerOneAd: instance.notesPerOneAd,
summalyProxy: instance.urlPreviewSummaryProxyUrl,
urlPreviewEnabled: instance.urlPreviewEnabled,

View File

@ -150,6 +150,7 @@ export const paramDef = {
perUserHomeTimelineCacheMax: { type: 'integer' },
perUserListTimelineCacheMax: { type: 'integer' },
enableReactionsBuffering: { type: 'boolean' },
enableStreamNotesCdnCache: { type: 'boolean' },
notesPerOneAd: { type: 'integer' },
silencedHosts: {
type: 'array',
@ -631,6 +632,10 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
set.enableReactionsBuffering = ps.enableReactionsBuffering;
}
if (ps.enableStreamNotesCdnCache !== undefined) {
set.enableStreamNotesCdnCache = ps.enableStreamNotesCdnCache;
}
if (ps.notesPerOneAd !== undefined) {
set.notesPerOneAd = ps.notesPerOneAd;
}

View File

@ -661,6 +661,12 @@ export class ClientServerService {
});
fastify.get<{ Params: { note: string; } }>('/notes/:note.json', async (request, reply) => {
// 内部用途なのでCORSを無効化
reply.removeHeader('Access-Control-Allow-Origin');
// this.meta.enableStreamNotesCdnCacheにかかわらずレスポンスは返す
// このプロパティを見ずにminimizeでChannelに繋いだ場合用
const note = await this.notesRepository.findOneBy({
id: request.params.note,
});

View File

@ -122,7 +122,7 @@ async function prepend(data: Misskey.entities.Note | Misskey.entities.StreamNote
let connection: Misskey.ChannelConnection | null = null;
let connection2: Misskey.ChannelConnection | null = null;
let paginationQuery: Paging | null = null;
const minimize = !iAmModerator;
const minimize = !iAmModerator && instance.enableStreamNotesCdnCache;
const stream = useStream();

View File

@ -43,6 +43,13 @@ SPDX-License-Identifier: AGPL-3.0-only
</MkSwitch>
</div>
<div class="_panel" style="padding: 16px;">
<MkSwitch v-model="enableStreamNotesCdnCache" @change="onChange_enableStreamNotesCdnCache">
<template #label>{{ i18n.ts.enableStreamNotesCdnCache }}<span class="_beta">{{ i18n.ts.beta }}</span></template>
<template #caption>{{ i18n.ts.enableStreamNotesCdnCacheDescription }}</template>
</MkSwitch>
</div>
<MkFolder :defaultOpen="true">
<template #icon><i class="ti ti-bolt"></i></template>
<template #label>Misskey® Fan-out Timeline Technology (FTT)</template>
@ -129,6 +136,7 @@ const enableIdenticonGeneration = ref(meta.enableIdenticonGeneration);
const enableChartsForRemoteUser = ref(meta.enableChartsForRemoteUser);
const enableStatsForFederatedInstances = ref(meta.enableStatsForFederatedInstances);
const enableChartsForFederatedInstances = ref(meta.enableChartsForFederatedInstances);
const enableStreamNotesCdnCache = ref(meta.enableStreamNotesCdnCache);
function onChange_enableServerMachineStats(value: boolean) {
os.apiWithDialog('admin/update-meta', {
@ -170,6 +178,14 @@ function onChange_enableChartsForFederatedInstances(value: boolean) {
});
}
function onChange_enableStreamNotesCdnCache(value: boolean) {
os.apiWithDialog('admin/update-meta', {
enableStreamNotesCdnCache: value,
}).then(() => {
fetchInstance(true);
});
}
const fttForm = useForm({
enableFanoutTimeline: meta.enableFanoutTimeline,
enableFanoutTimelineDbFallback: meta.enableFanoutTimelineDbFallback,

File diff suppressed because it is too large Load Diff

View File

@ -5015,6 +5015,7 @@ export type components = {
translatorAvailable: boolean;
mediaProxy: string;
enableUrlPreview: boolean;
enableStreamNotesCdnCache: boolean;
backgroundImageUrl: string | null;
impressumUrl: string | null;
logoImageUrl: string | null;
@ -5189,6 +5190,7 @@ export type operations = {
perUserHomeTimelineCacheMax: number;
perUserListTimelineCacheMax: number;
enableReactionsBuffering: boolean;
enableStreamNotesCdnCache: boolean;
notesPerOneAd: number;
backgroundImageUrl: string | null;
deeplAuthKey: string | null;
@ -9587,6 +9589,7 @@ export type operations = {
perUserHomeTimelineCacheMax?: number;
perUserListTimelineCacheMax?: number;
enableReactionsBuffering?: boolean;
enableStreamNotesCdnCache?: boolean;
notesPerOneAd?: number;
silencedHosts?: string[] | null;
mediaSilencedHosts?: string[] | null;