ドライブ容量の設定をDBに保存するようにしたりリファクタリングしたり
This commit is contained in:
@ -65,7 +65,23 @@ export const meta = {
|
||||
desc: {
|
||||
'ja-JP': '投稿の最大文字数'
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
localDriveCapacityMb: {
|
||||
validator: $.num.optional.min(0),
|
||||
desc: {
|
||||
'ja-JP': 'ローカルユーザーひとりあたりのドライブ容量 (メガバイト単位)',
|
||||
'en-US': 'Drive capacity of a local user (MB)'
|
||||
}
|
||||
},
|
||||
|
||||
remoteDriveCapacityMb: {
|
||||
validator: $.num.optional.min(0),
|
||||
desc: {
|
||||
'ja-JP': 'リモートユーザーひとりあたりのドライブ容量 (メガバイト単位)',
|
||||
'en-US': 'Drive capacity of a remote user (MB)'
|
||||
}
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
@ -104,6 +120,14 @@ export default define(meta, (ps) => new Promise(async (res, rej) => {
|
||||
set.maxNoteTextLength = ps.maxNoteTextLength;
|
||||
}
|
||||
|
||||
if (ps.localDriveCapacityMb !== undefined) {
|
||||
set.localDriveCapacityMb = ps.localDriveCapacityMb;
|
||||
}
|
||||
|
||||
if (ps.remoteDriveCapacityMb !== undefined) {
|
||||
set.remoteDriveCapacityMb = ps.remoteDriveCapacityMb;
|
||||
}
|
||||
|
||||
await Meta.update({}, {
|
||||
$set: set
|
||||
}, { upsert: true });
|
||||
|
@ -1,14 +1,14 @@
|
||||
import Note from '../../../../models/note';
|
||||
import Meta from '../../../../models/meta';
|
||||
import define from '../../define';
|
||||
import fetchMeta from '../../../../misc/fetch-meta';
|
||||
|
||||
export const meta = {
|
||||
requireCredential: false,
|
||||
};
|
||||
|
||||
export default define(meta, (ps) => new Promise(async (res, rej) => {
|
||||
const meta = await Meta.findOne({});
|
||||
const hidedTags = meta ? (meta.hidedTags || []).map(t => t.toLowerCase()) : [];
|
||||
const instance = await fetchMeta();
|
||||
const hidedTags = instance.hidedTags.map(t => t.toLowerCase());
|
||||
|
||||
const span = 1000 * 60 * 60 * 24 * 7; // 1週間
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
import DriveFile from '../../../models/drive-file';
|
||||
import config from '../../../config';
|
||||
import define from '../define';
|
||||
import fetchMeta from '../../../misc/fetch-meta';
|
||||
|
||||
export const meta = {
|
||||
desc: {
|
||||
@ -14,6 +14,8 @@ export const meta = {
|
||||
};
|
||||
|
||||
export default define(meta, (ps, user) => new Promise(async (res, rej) => {
|
||||
const instance = await fetchMeta();
|
||||
|
||||
// Calculate drive usage
|
||||
const usage = await DriveFile
|
||||
.aggregate([{
|
||||
@ -39,7 +41,7 @@ export default define(meta, (ps, user) => new Promise(async (res, rej) => {
|
||||
});
|
||||
|
||||
res({
|
||||
capacity: 1024 * 1024 * config.localDriveCapacityMb,
|
||||
capacity: 1024 * 1024 * instance.localDriveCapacityMb,
|
||||
usage: usage
|
||||
});
|
||||
}));
|
||||
|
@ -1,7 +1,7 @@
|
||||
import Note from '../../../../models/note';
|
||||
import { erase } from '../../../../prelude/array';
|
||||
import Meta from '../../../../models/meta';
|
||||
import define from '../../define';
|
||||
import fetchMeta from '../../../../misc/fetch-meta';
|
||||
|
||||
/*
|
||||
トレンドに載るためには「『直近a分間のユニーク投稿数が今からa分前~今からb分前の間のユニーク投稿数のn倍以上』のハッシュタグの上位5位以内に入る」ことが必要
|
||||
@ -20,8 +20,8 @@ export const meta = {
|
||||
};
|
||||
|
||||
export default define(meta, () => new Promise(async (res, rej) => {
|
||||
const meta = await Meta.findOne({});
|
||||
const hidedTags = meta ? (meta.hidedTags || []).map(t => t.toLowerCase()) : [];
|
||||
const instance = await fetchMeta();
|
||||
const hidedTags = instance.hidedTags.map(t => t.toLowerCase());
|
||||
|
||||
//#region 1. 直近Aの内に投稿されたハッシュタグ(とユーザーのペア)を集計
|
||||
const data = await Note.aggregate([{
|
||||
|
@ -1,9 +1,9 @@
|
||||
import $ from 'cafy';
|
||||
import * as os from 'os';
|
||||
import config from '../../../config';
|
||||
import Meta from '../../../models/meta';
|
||||
import Emoji from '../../../models/emoji';
|
||||
import define from '../define';
|
||||
import fetchMeta from '../../../misc/fetch-meta';
|
||||
|
||||
const pkg = require('../../../../package.json');
|
||||
const client = require('../../../../built/client/meta.json');
|
||||
@ -27,7 +27,7 @@ export const meta = {
|
||||
};
|
||||
|
||||
export default define(meta, (ps, me) => new Promise(async (res, rej) => {
|
||||
const met: any = (await Meta.findOne()) || {};
|
||||
const instance = await fetchMeta();
|
||||
|
||||
const emojis = await Emoji.find({ host: null }, {
|
||||
fields: {
|
||||
@ -41,8 +41,8 @@ export default define(meta, (ps, me) => new Promise(async (res, rej) => {
|
||||
version: pkg.version,
|
||||
clientVersion: client.version,
|
||||
|
||||
name: met.name || 'Misskey',
|
||||
description: met.description,
|
||||
name: instance.name,
|
||||
description: instance.description,
|
||||
|
||||
secure: config.https != null,
|
||||
machine: os.hostname(),
|
||||
@ -54,21 +54,22 @@ export default define(meta, (ps, me) => new Promise(async (res, rej) => {
|
||||
cores: os.cpus().length
|
||||
},
|
||||
|
||||
broadcasts: met.broadcasts || [],
|
||||
disableRegistration: met.disableRegistration,
|
||||
disableLocalTimeline: met.disableLocalTimeline,
|
||||
driveCapacityPerLocalUserMb: config.localDriveCapacityMb,
|
||||
broadcasts: instance.broadcasts || [],
|
||||
disableRegistration: instance.disableRegistration,
|
||||
disableLocalTimeline: instance.disableLocalTimeline,
|
||||
driveCapacityPerLocalUserMb: instance.localDriveCapacityMb,
|
||||
driveCapacityPerRemoteUserMb: instance.remoteDriveCapacityMb,
|
||||
recaptchaSitekey: config.recaptcha ? config.recaptcha.site_key : null,
|
||||
swPublickey: config.sw ? config.sw.public_key : null,
|
||||
hidedTags: (me && me.isAdmin) ? met.hidedTags : undefined,
|
||||
bannerUrl: met.bannerUrl,
|
||||
maxNoteTextLength: met.maxNoteTextLength || 1000,
|
||||
hidedTags: (me && me.isAdmin) ? instance.hidedTags : undefined,
|
||||
bannerUrl: instance.bannerUrl,
|
||||
maxNoteTextLength: instance.maxNoteTextLength,
|
||||
|
||||
emojis: emojis,
|
||||
|
||||
features: ps.detail ? {
|
||||
registration: !met.disableRegistration,
|
||||
localTimeLine: !met.disableLocalTimeline,
|
||||
registration: !instance.disableRegistration,
|
||||
localTimeLine: !instance.disableLocalTimeline,
|
||||
elasticsearch: config.elasticsearch ? true : false,
|
||||
recaptcha: config.recaptcha ? true : false,
|
||||
objectStorage: config.drive && config.drive.storage === 'minio',
|
||||
|
@ -6,13 +6,13 @@ import User, { IUser } from '../../../../models/user';
|
||||
import DriveFile, { IDriveFile } from '../../../../models/drive-file';
|
||||
import create from '../../../../services/note/create';
|
||||
import define from '../../define';
|
||||
import Meta from '../../../../models/meta';
|
||||
import fetchMeta from '../../../../misc/fetch-meta';
|
||||
|
||||
let maxNoteTextLength = 1000;
|
||||
|
||||
setInterval(() => {
|
||||
Meta.findOne({}).then(m => {
|
||||
if (m.maxNoteTextLength) maxNoteTextLength = m.maxNoteTextLength;
|
||||
fetchMeta().then(m => {
|
||||
maxNoteTextLength = m.maxNoteTextLength;
|
||||
});
|
||||
}, 3000);
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
import Meta from '../../../models/meta';
|
||||
import define from '../define';
|
||||
import driveChart from '../../../chart/drive';
|
||||
import federationChart from '../../../chart/federation';
|
||||
import fetchMeta from '../../../misc/fetch-meta';
|
||||
|
||||
export const meta = {
|
||||
requireCredential: false,
|
||||
@ -15,9 +15,9 @@ export const meta = {
|
||||
};
|
||||
|
||||
export default define(meta, () => new Promise(async (res, rej) => {
|
||||
const meta = await Meta.findOne();
|
||||
const instance = await fetchMeta();
|
||||
|
||||
const stats: any = meta ? meta.stats : {};
|
||||
const stats: any = instance.stats;
|
||||
|
||||
const driveStats = await driveChart.getChart('hour', 1);
|
||||
stats.driveUsageLocal = driveStats.local.totalSize[0];
|
||||
|
Reference in New Issue
Block a user