diff --git a/CALCKEY.md b/CALCKEY.md index 9ded35c8a..dde53a888 100644 --- a/CALCKEY.md +++ b/CALCKEY.md @@ -36,6 +36,7 @@ - Star as default reaction - Rosé Pine by default (+ non-themable elements made Rosé Pine) - Better sidebar/navbar +- MOTD (customizable by admins!) - [Profile background as banner](https://codeberg.org/Freeplay/Misskey-Tweaks/src/branch/main/snippets/profile-background.styl) - Better timeline top bar - Mark as read from notifications widget @@ -45,7 +46,6 @@ - Spinner instead of "Loading..." - SearchX instead of Google - Spacing on group items -- MOTD - Reply limit bug fixed (somewhat) - Custom assets - [OAuth bearer token authentication](https://github.com/misskey-dev/misskey/pull/9021) diff --git a/locales/en-US.yml b/locales/en-US.yml index 0088af46d..53cb9185f 100644 --- a/locales/en-US.yml +++ b/locales/en-US.yml @@ -901,6 +901,9 @@ move: "Move" showAds: "Show ads" enterSendsMessage: "Press Return in Messaging to send message (off is Ctrl + Return)" adminCustomCssWarn: "This setting should only be used if you know what it does. Entering improper values may cause EVERYONE'S clients to stop functioning normally. Please ensure your CSS works properly by testing it in your user settings." +customMOTD: "Custom MOTD (splash screen messages)" +customMOTDDescription: "Custom messages for the MOTD (splash screen) separated by line breaks to be shown randomly every time a user loads/reloads the page." + _sensitiveMediaDetection: description: "Reduces the effort of server moderation through automatically recognizing NSFW media via Machine Learning. This will slightly increase the load on the server." diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index 1c832e1f7..3ce268ddd 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -901,6 +901,8 @@ shuffle: "シャッフル" account: "アカウント" move: "移動" adminCustomCssWarn: "この設定は、それが何をするものであるかを知っている場合のみ使用してください。不適切な値を入力すると、クライアントが正常に動作しなくなる可能性があります。ユーザー設定でCSSをテストし、正しく動作することを確認してください。" +customMOTD: "カスタムMOTD(スプラッシュスクリーンメッセージ)" +customMOTDDescription: "ユーザがページをロード/リロードするたびにランダムに表示される、改行で区切られたMOTD(スプラッシュスクリーン)用のカスタムメッセージ" _sensitiveMediaDetection: description: "機械学習を使って自動でセンシティブなメディアを検出し、モデレーションに役立てることができます。サーバーの負荷が少し増えます。" diff --git a/package.json b/package.json index 96c286e50..5cc0201de 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "misskey", - "version": "12.118.0-calc.8.b4", + "version": "12.118.0-calc.9.b4", "codename": "indigo", "repository": { "type": "git", diff --git a/packages/backend/migration/1658939464003CustomMOTD.js b/packages/backend/migration/1658939464003CustomMOTD.js new file mode 100644 index 000000000..eac03451d --- /dev/null +++ b/packages/backend/migration/1658939464003CustomMOTD.js @@ -0,0 +1,8 @@ +export class CustomMOTD1658939464003 { + async up(queryRunner) { + await queryRunner.query(`ALTER TABLE "meta" ADD "customMOTD" character varying(256) array NOT NULL DEFAULT '{}'::varchar[]`); + } + async down(queryRunner) { + await queryRunner.query(`ALTER TABLE "meta" DROP COLUMN "customMOTD"`); + } +} diff --git a/packages/backend/src/models/entities/meta.ts b/packages/backend/src/models/entities/meta.ts index 02f5e3ecc..cb47307f9 100644 --- a/packages/backend/src/models/entities/meta.ts +++ b/packages/backend/src/models/entities/meta.ts @@ -67,6 +67,11 @@ export class Meta { }) public pinnedUsers: string[]; + @Column('varchar', { + length: 256, array: true, default: '{}', + }) + public customMOTD: string[]; + @Column('varchar', { length: 256, array: true, default: '{}', }) diff --git a/packages/backend/src/server/api/endpoints.ts b/packages/backend/src/server/api/endpoints.ts index d7fcc32d3..0c29e16fc 100644 --- a/packages/backend/src/server/api/endpoints.ts +++ b/packages/backend/src/server/api/endpoints.ts @@ -268,6 +268,7 @@ import * as ep___pages_unlike from './endpoints/pages/unlike.js'; import * as ep___pages_update from './endpoints/pages/update.js'; import * as ep___ping from './endpoints/ping.js'; import * as ep___pinnedUsers from './endpoints/pinned-users.js'; +import * as ep___customMOTD from './endpoints/custom-motd.js'; import * as ep___promo_read from './endpoints/promo/read.js'; import * as ep___requestResetPassword from './endpoints/request-reset-password.js'; import * as ep___resetDb from './endpoints/reset-db.js'; @@ -585,6 +586,7 @@ const eps = [ ['pages/update', ep___pages_update], ['ping', ep___ping], ['pinned-users', ep___pinnedUsers], + ['custom-motd', ep___customMOTD], ['promo/read', ep___promo_read], ['request-reset-password', ep___requestResetPassword], ['reset-db', ep___resetDb], diff --git a/packages/backend/src/server/api/endpoints/admin/meta.ts b/packages/backend/src/server/api/endpoints/admin/meta.ts index 8a11baf90..b5201ea9f 100644 --- a/packages/backend/src/server/api/endpoints/admin/meta.ts +++ b/packages/backend/src/server/api/endpoints/admin/meta.ts @@ -171,6 +171,14 @@ export const meta = { optional: false, nullable: false, }, }, + customMOTD: { + type: 'array', + optional: true, nullable: false, + items: { + type: 'string', + optional: false, nullable: false, + }, + }, hiddenTags: { type: 'array', optional: true, nullable: false, @@ -402,6 +410,7 @@ export default define(meta, paramDef, async (ps, me) => { cacheRemoteFiles: instance.cacheRemoteFiles, useStarForReactionFallback: instance.useStarForReactionFallback, pinnedUsers: instance.pinnedUsers, + customMOTD: instance.customMOTD, hiddenTags: instance.hiddenTags, blockedHosts: instance.blockedHosts, allowedHosts: instance.allowedHosts, diff --git a/packages/backend/src/server/api/endpoints/admin/update-meta.ts b/packages/backend/src/server/api/endpoints/admin/update-meta.ts index 1fe68f261..60d388d68 100644 --- a/packages/backend/src/server/api/endpoints/admin/update-meta.ts +++ b/packages/backend/src/server/api/endpoints/admin/update-meta.ts @@ -21,6 +21,9 @@ export const paramDef = { pinnedUsers: { type: 'array', nullable: true, items: { type: 'string', } }, + customMOTD: { type: 'array', nullable: true, items: { + type: 'string', + } }, hiddenTags: { type: 'array', nullable: true, items: { type: 'string', } }, @@ -135,6 +138,10 @@ export default define(meta, paramDef, async (ps, me) => { set.pinnedUsers = ps.pinnedUsers.filter(Boolean); } + if (Array.isArray(ps.customMOTD)) { + set.customMOTD = ps.customMOTD.filter(Boolean); + } + if (Array.isArray(ps.hiddenTags)) { set.hiddenTags = ps.hiddenTags.filter(Boolean); } diff --git a/packages/backend/src/server/web/index.ts b/packages/backend/src/server/web/index.ts index 1d201d712..58d141041 100644 --- a/packages/backend/src/server/web/index.ts +++ b/packages/backend/src/server/web/index.ts @@ -268,22 +268,6 @@ router.get('/@:user.json', async ctx => { } }); -// MOTD -const motd = [ - 'If you\'re on mobile, you can tap install/add to homescreen to get the app!', - 'You can click the time a note was posted to get a full view of the note.', - 'Wanna find people to follow? Head over to the Explore tab!', - 'Want more ways to post? You can make blogs in Pages and galleries in Gallery tab.', - 'You can add cool stuff to notes like CWs, polls, multiple videos/gifs, and audio!', - 'Use #hashtags to tag notes and reach more people, especially for #art.', - 'If your note gets popular, it might show up on the Featured tap for up to 3 days!', - 'Use the 4 buttons at the top (or the top drop-down on mobile) to switch timelines.', - 'The Fediverse is made up of more than just Calckey.', - 'Avatars and banners can be GIFs.', - 'When writing a note, type $ to see a list of cool text effects (mfm).', - 'Be gay, do crime.', -]; - //#region SSR (for crawlers) // User router.get(['/@:user', '/@:user/:sub'], async (ctx, next) => { @@ -311,9 +295,8 @@ router.get(['/@:user', '/@:user/:sub'], async (ctx, next) => { icon: meta.iconUrl, themeColor: meta.themeColor, privateMode: meta.privateMode, - randomMOTD: motd[Math.floor(Math.random() * motd.length)], }); - ctx.set('Cache-Control', 'public, max-age=3'); + ctx.set('Cache-Control', 'public, max-age=15'); } else { // リモートユーザーなので // モデレータがAPI経由で参照可能にするために404にはしない @@ -543,6 +526,11 @@ router.get('/streaming', async ctx => { // Render base html for all requests router.get('(.*)', async ctx => { const meta = await fetchMeta(); + let motd = ['Loading...']; + // Check if meta.MOTD exists and is at least 1 in length + if (meta.customMOTD && meta.customMOTD.length > 0) { + motd = meta.customMOTD; + } await ctx.render('base', { img: meta.bannerUrl, title: meta.name || 'Calckey', @@ -551,8 +539,9 @@ router.get('(.*)', async ctx => { icon: meta.iconUrl, themeColor: meta.themeColor, privateMode: meta.privateMode, + randomMOTD: motd[Math.floor(Math.random() * motd.length)], }); - ctx.set('Cache-Control', 'public, max-age=15'); + ctx.set('Cache-Control', 'public, max-age=3'); }); // Register router diff --git a/packages/client/src/pages/admin/settings.vue b/packages/client/src/pages/admin/settings.vue index 496eb46ea..995c8e805 100644 --- a/packages/client/src/pages/admin/settings.vue +++ b/packages/client/src/pages/admin/settings.vue @@ -34,6 +34,11 @@ + + + + + @@ -176,6 +181,7 @@ let defaultDarkTheme: any = $ref(null); let enableLocalTimeline: boolean = $ref(false); let enableGlobalTimeline: boolean = $ref(false); let pinnedUsers: string = $ref(''); +let customMOTD: string = $ref(''); let cacheRemoteFiles: boolean = $ref(false); let localDriveCapacityMb: any = $ref(0); let remoteDriveCapacityMb: any = $ref(0); @@ -203,6 +209,7 @@ async function init() { enableLocalTimeline = !meta.disableLocalTimeline; enableGlobalTimeline = !meta.disableGlobalTimeline; pinnedUsers = meta.pinnedUsers.join('\n'); + customMOTD = meta.customMOTD.join('\n'); cacheRemoteFiles = meta.cacheRemoteFiles; localDriveCapacityMb = meta.driveCapacityPerLocalUserMb; remoteDriveCapacityMb = meta.driveCapacityPerRemoteUserMb; @@ -231,6 +238,7 @@ function save() { disableLocalTimeline: !enableLocalTimeline, disableGlobalTimeline: !enableGlobalTimeline, pinnedUsers: pinnedUsers.split('\n'), + customMOTD: customMOTD.split('\n'), cacheRemoteFiles, localDriveCapacityMb: parseInt(localDriveCapacityMb, 10), remoteDriveCapacityMb: parseInt(remoteDriveCapacityMb, 10),