Custom MOTD!

This commit is contained in:
ThatOneCalculator 2022-07-27 09:46:35 -07:00
parent dc66eea6ac
commit 4d22797624
11 changed files with 54 additions and 21 deletions

View File

@ -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)

View File

@ -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."

View File

@ -901,6 +901,8 @@ shuffle: "シャッフル"
account: "アカウント"
move: "移動"
adminCustomCssWarn: "この設定は、それが何をするものであるかを知っている場合のみ使用してください。不適切な値を入力すると、クライアントが正常に動作しなくなる可能性があります。ユーザー設定でCSSをテストし、正しく動作することを確認してください。"
customMOTD: "カスタムMOTDスプラッシュスクリーンメッセージ"
customMOTDDescription: "ユーザがページをロード/リロードするたびにランダムに表示される、改行で区切られたMOTDスプラッシュスクリーン用のカスタムメッセージ"
_sensitiveMediaDetection:
description: "機械学習を使って自動でセンシティブなメディアを検出し、モデレーションに役立てることができます。サーバーの負荷が少し増えます。"

View File

@ -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",

View File

@ -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"`);
}
}

View File

@ -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: '{}',
})

View File

@ -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],

View File

@ -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,

View File

@ -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);
}

View File

@ -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

View File

@ -34,6 +34,11 @@
<template #caption>{{ i18n.ts.pinnedUsersDescription }}</template>
</FormTextarea>
<FormTextarea v-model="customMOTD" class="_formBlock">
<template #label>{{ i18n.ts.customMOTD }}</template>
<template #caption>{{ i18n.ts.customMOTDDescription }}</template>
</FormTextarea>
<FormSection>
<FormSwitch v-model="enableRegistration" class="_formBlock">
<template #label>{{ i18n.ts.enableRegistration }}</template>
@ -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),