From f17c9837c572095a27f6ea9a83e1aadab15b6bb7 Mon Sep 17 00:00:00 2001 From: Syuilo Date: Sun, 2 Jul 2023 16:20:40 -0700 Subject: [PATCH] =?UTF-8?q?refactor:=20=E2=9A=A1=20make=20identicons=20and?= =?UTF-8?q?=20server=20metrics=20optional?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Kainoa Kanter --- locales/en-US.yml | 2 ++ locales/ja-JP.yml | 2 ++ packages/backend/assets/avatar.png | Bin 0 -> 14059 bytes .../1688280713783-add-meta-options.js | 21 ++++++++++++++++++ packages/backend/src/daemons/server-stats.ts | 4 ++++ packages/backend/src/models/entities/meta.ts | 10 +++++++++ .../src/server/api/endpoints/admin/meta.ts | 12 ++++++++++ .../src/server/api/endpoints/server-info.ts | 21 +++++++++++++++++- packages/backend/src/server/index.ts | 15 +++++++++---- packages/client/src/pages/admin/settings.vue | 17 ++++++++++++++ .../src/widgets/server-metric/index.vue | 2 +- 11 files changed, 100 insertions(+), 6 deletions(-) create mode 100644 packages/backend/assets/avatar.png create mode 100644 packages/backend/migration/1688280713783-add-meta-options.js diff --git a/locales/en-US.yml b/locales/en-US.yml index d493f332f..c6c442df7 100644 --- a/locales/en-US.yml +++ b/locales/en-US.yml @@ -1112,6 +1112,8 @@ isModerator: "Moderator" isAdmin: "Administrator" isPatron: "Calckey Patron" reactionPickerSkinTone: "Preferred emoji skin tone" +enableServerMachineStats: "Enable server hardware statistics" +enableIdenticonGeneration: "Enable Identicon generation" _sensitiveMediaDetection: description: "Reduces the effort of server moderation through automatically recognizing diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index fa3c3f1cc..9f2f825e5 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -978,6 +978,8 @@ enableCustomKaTeXMacro: "カスタムKaTeXマクロを有効にする" preventAiLearning: "AIによる学習を防止" preventAiLearningDescription: "投稿したノート、添付した画像などのコンテンツを学習の対象にしないようAIに要求します。これはnoaiフラグをHTMLレスポンスに含めることによって実現されます。" noGraze: "ブラウザの拡張機能「Graze for Mastodon」は、Calckeyの動作を妨げるため、無効にしてください。" +enableServerMachineStats: "サーバーのマシン情報を公開する" +enableIdenticonGeneration: "ユーザーごとのIdenticon生成を有効にする" _sensitiveMediaDetection: description: "機械学習を使って自動でセンシティブなメディアを検出し、モデレーションに役立てられます。サーバーの負荷が少し増えます。" diff --git a/packages/backend/assets/avatar.png b/packages/backend/assets/avatar.png new file mode 100644 index 0000000000000000000000000000000000000000..ee22bdb3c8e56d6e44c1a8eb3dec0d62bb427657 GIT binary patch literal 14059 zcmW+-Wk6J26W(2xuBDMq=}@|t?v!qj5J9@TK@>r{1p!GZMH-fr6r`kCy1Vy+iBb$#a! zg3t|22F4E_@Q(ucUK4%n7Ebi|#ITj)@d?7r1XGd;W2ze<4{%EO&F9f^vT#MTENSLi zrNC+pFZ;J!%sixso_JX`r)Q@3P(52#FJ@7f8J|0{jPL#E6LPm4c(O6NXW{cHcxU}B z1`Mf*N38)Wadh?%3RrWjAq0i|n_ukc>2P-0(=?`1%K>%rgdHmy{cAVWUz(uBc;34B z&^K+-gJryWvE&}HG_=#hocKg&Y2MB!VAr)A%ktq2y}5TSb;IMwiu>X{=E98e)4PAS z==@345>67)AMTEvf_oX;qWHpy5VYy;&XggHkK>t`*d}(rIL{e8LbC^(xW-;fd)2gp z{7owH8Ath)j^TT4=oDFv!I<@R&9c{Pa`r z)oRyXEG+Q)GvWD3J>)97*uw-GvPI}p-|7k(XsCa@pm#uEBKaUQbG}HE245UK_}}pE zA=i}cUDQGj#f7UQQT=O_vkBA~NG#73+V1ZjKWbG7&%52QHgr8oulI>!* zUrEAxC-Tkbdr_yt_=+DvA1nclqv+Y947F!=>pF4>UqDY?F6N=pOjU+{dt; zDXzR>HQ_%~;>75jdz%SY1h{J)5&Pfd9&^dvy(=OR`DD?eI8^MyAVL zgC2B;ERFm$=k?lkq_1~;Xt0v|(ORh}g0YmX`qTMY%s1|=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yYvvkch77_M@zhc#JZC2eY0UTlj NDa&ifRmoU}{|~xPiZcKJ literal 0 HcmV?d00001 diff --git a/packages/backend/migration/1688280713783-add-meta-options.js b/packages/backend/migration/1688280713783-add-meta-options.js new file mode 100644 index 000000000..e97a95c42 --- /dev/null +++ b/packages/backend/migration/1688280713783-add-meta-options.js @@ -0,0 +1,21 @@ +export class AddMetaOptions1688280713783 { + name = "AddMetaOptions1688280713783"; + + async up(queryRunner) { + await queryRunner.query( + `ALTER TABLE "meta" ADD "enableServerMachineStats" boolean NOT NULL DEFAULT false`, + ); + await queryRunner.query( + `ALTER TABLE "meta" ADD "enableIdenticonGeneration" boolean NOT NULL DEFAULT true`, + ); + } + + async down(queryRunner) { + await queryRunner.query( + `ALTER TABLE "meta" DROP COLUMN "enableIdenticonGeneration"`, + ); + await queryRunner.query( + `ALTER TABLE "meta" DROP COLUMN "enableServerMachineStats"`, + ); + } +} diff --git a/packages/backend/src/daemons/server-stats.ts b/packages/backend/src/daemons/server-stats.ts index c936d619a..ba7427876 100644 --- a/packages/backend/src/daemons/server-stats.ts +++ b/packages/backend/src/daemons/server-stats.ts @@ -1,6 +1,7 @@ import si from "systeminformation"; import Xev from "xev"; import * as osUtils from "os-utils"; +import { fetchMeta } from "@/misc/fetch-meta.js"; import meilisearch from "../db/meilisearch.js"; const ev = new Xev(); @@ -20,6 +21,9 @@ export default function () { ev.emit(`serverStatsLog:${x.id}`, log.slice(0, x.length || 50)); }); + const meta = fetchMeta(); + if (!meta.enableServerMachineStats) return; + async function tick() { const cpu = await cpuUsage(); const memStats = await mem(); diff --git a/packages/backend/src/models/entities/meta.ts b/packages/backend/src/models/entities/meta.ts index dd3c5b3b7..200ef5055 100644 --- a/packages/backend/src/models/entities/meta.ts +++ b/packages/backend/src/models/entities/meta.ts @@ -546,4 +546,14 @@ export class Meta { default: {}, }) public experimentalFeatures: Record; + + @Column("boolean", { + default: false, + }) + public enableServerMachineStats: boolean; + + @Column("boolean", { + default: true, + }) + public enableIdenticonGeneration: boolean; } diff --git a/packages/backend/src/server/api/endpoints/admin/meta.ts b/packages/backend/src/server/api/endpoints/admin/meta.ts index 319330127..50317d4a8 100644 --- a/packages/backend/src/server/api/endpoints/admin/meta.ts +++ b/packages/backend/src/server/api/endpoints/admin/meta.ts @@ -481,6 +481,16 @@ export const meta = { }, }, }, + enableServerMachineStats: { + type: "boolean", + optional: false, + nullable: false, + }, + enableIdenticonGeneration: { + type: "boolean", + optional: false, + nullable: false, + }, }, }, } as const; @@ -592,5 +602,7 @@ export default define(meta, paramDef, async (ps, me) => { enableIpLogging: instance.enableIpLogging, enableActiveEmailValidation: instance.enableActiveEmailValidation, experimentalFeatures: instance.experimentalFeatures, + enableServerMachineStats: instance.enableServerMachineStats, + enableIdenticonGeneration: instance.enableIdenticonGeneration, }; }); diff --git a/packages/backend/src/server/api/endpoints/server-info.ts b/packages/backend/src/server/api/endpoints/server-info.ts index 81bb053db..746eae662 100644 --- a/packages/backend/src/server/api/endpoints/server-info.ts +++ b/packages/backend/src/server/api/endpoints/server-info.ts @@ -2,11 +2,13 @@ import * as os from "node:os"; import si from "systeminformation"; import define from "../define.js"; import meilisearch from "@/db/meilisearch.js"; +import { fetchMeta } from "@/misc/fetch-meta.js"; export const meta = { requireCredential: false, requireCredentialPrivateMode: true, - + allowGet: true, + cacheSec: 30, tags: ["meta"], } as const; @@ -29,6 +31,23 @@ export default define(meta, paramDef, async () => { } } + const instanceMeta = await fetchMeta(); + if (!instanceMeta.enableServerMachineStats) { + return { + machine: 'Not specified', + cpu: { + model: 'Not specified', + cores: 0, + }, + mem: { + total: 0, + }, + fs: { + total: 0, + used: 0, + }, + }; + } return { machine: os.hostname(), cpu: { diff --git a/packages/backend/src/server/index.ts b/packages/backend/src/server/index.ts index 95d570eb3..7f8d0ed71 100644 --- a/packages/backend/src/server/index.ts +++ b/packages/backend/src/server/index.ts @@ -16,6 +16,7 @@ import { IsNull } from "typeorm"; import config from "@/config/index.js"; import Logger from "@/services/logger.js"; import { UserProfiles, Users } from "@/models/index.js"; +import { fetchMeta } from "@/misc/fetch-meta.js"; import { genIdenticon } from "@/misc/gen-identicon.js"; import { createTemp } from "@/misc/create-temp.js"; import { publishMainStream } from "@/services/stream.js"; @@ -125,10 +126,16 @@ router.get("/avatar/@:acct", async (ctx) => { }); router.get("/identicon/:x", async (ctx) => { - const [temp, cleanup] = await createTemp(); - await genIdenticon(ctx.params.x, fs.createWriteStream(temp)); - ctx.set("Content-Type", "image/png"); - ctx.body = fs.createReadStream(temp).on("close", () => cleanup()); + const meta = await fetchMeta(); + if (meta.enableIdenticonGeneration) { + const [temp, cleanup] = await createTemp(); + await genIdenticon(ctx.params.x, fs.createWriteStream(temp)); + ctx.set("Content-Type", "image/png"); + ctx.body = fs.createReadStream(temp).on("close", () => cleanup()); + } + else { + ctx.redirect("/static-assets/avatar.png") + } }); mastoRouter.get("/oauth/authorize", async (ctx) => { diff --git a/packages/client/src/pages/admin/settings.vue b/packages/client/src/pages/admin/settings.vue index e67c44b0a..0e83250ba 100644 --- a/packages/client/src/pages/admin/settings.vue +++ b/packages/client/src/pages/admin/settings.vue @@ -343,6 +343,17 @@ + + + + + + + + + + + @@ -442,6 +453,8 @@ let libreTranslateApiUrl: string = $ref(""); let libreTranslateApiKey: string = $ref(""); let defaultReaction: string = $ref(""); let defaultReactionCustom: string = $ref(""); +let enableServerMachineStats: boolean = $ref(false); +let enableIdenticonGeneration: boolean = $ref(false); async function init() { const meta = await os.api("admin/meta"); @@ -482,6 +495,8 @@ async function init() { defaultReactionCustom = ["⭐", "👍", "❤️"].includes(meta.defaultReaction) ? "" : meta.defaultReaction; + enableServerMachineStats = meta.enableServerMachineStats; + enableIdenticonGeneration = meta.enableIdenticonGeneration; } function save() { @@ -521,6 +536,8 @@ function save() { libreTranslateApiUrl, libreTranslateApiKey, defaultReaction, + enableServerMachineStats, + enableIdenticonGeneration, }).then(() => { fetchInstance(); }); diff --git a/packages/client/src/widgets/server-metric/index.vue b/packages/client/src/widgets/server-metric/index.vue index cf84212b1..49dc59ea2 100644 --- a/packages/client/src/widgets/server-metric/index.vue +++ b/packages/client/src/widgets/server-metric/index.vue @@ -106,7 +106,7 @@ const { widgetProps, configure, save } = useWidgetPropsManager( const meta = ref(null); -os.api("server-info", {}).then((res) => { +os.apiGet("server-info", {}).then((res) => { meta.value = res; });