forked from FoundKeyGang/FoundKey
ドライブ容量の設定をDBに保存するようにしたりリファクタリングしたり
This commit is contained in:
parent
06bb2a1c7c
commit
8f714b5b12
18 changed files with 133 additions and 54 deletions
|
@ -57,12 +57,6 @@ mongodb:
|
||||||
user: example-misskey-user
|
user: example-misskey-user
|
||||||
pass: example-misskey-pass
|
pass: example-misskey-pass
|
||||||
|
|
||||||
# Drive capacity of a local user (MB)
|
|
||||||
localDriveCapacityMb: 256
|
|
||||||
|
|
||||||
# Drive capacity of a remote user (MB)
|
|
||||||
remoteDriveCapacityMb: 8
|
|
||||||
|
|
||||||
# If enabled:
|
# If enabled:
|
||||||
# Server will not cache remote files (Using direct link instead).
|
# Server will not cache remote files (Using direct link instead).
|
||||||
# You can save your storage.
|
# You can save your storage.
|
||||||
|
|
|
@ -1078,6 +1078,9 @@ admin/views/instance.vue:
|
||||||
instance-name: "インスタンス名"
|
instance-name: "インスタンス名"
|
||||||
instance-description: "インスタンスの紹介"
|
instance-description: "インスタンスの紹介"
|
||||||
banner-url: "バナー画像URL"
|
banner-url: "バナー画像URL"
|
||||||
|
local-drive-capacity-mb: "ローカルユーザーひとりあたりのドライブ容量"
|
||||||
|
remote-drive-capacity-mb: "リモートユーザーひとりあたりのドライブ容量"
|
||||||
|
mb: "メガバイト単位"
|
||||||
max-note-text-length: "投稿の最大文字数"
|
max-note-text-length: "投稿の最大文字数"
|
||||||
disable-registration: "ユーザー登録の受付を停止する"
|
disable-registration: "ユーザー登録の受付を停止する"
|
||||||
disable-local-timeline: "ローカルタイムラインを無効にする"
|
disable-local-timeline: "ローカルタイムラインを無効にする"
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
<ui-input v-model="name">%i18n:@instance-name%</ui-input>
|
<ui-input v-model="name">%i18n:@instance-name%</ui-input>
|
||||||
<ui-textarea v-model="description">%i18n:@instance-description%</ui-textarea>
|
<ui-textarea v-model="description">%i18n:@instance-description%</ui-textarea>
|
||||||
<ui-input v-model="bannerUrl">%i18n:@banner-url%</ui-input>
|
<ui-input v-model="bannerUrl">%i18n:@banner-url%</ui-input>
|
||||||
|
<ui-input v-model="localDriveCapacityMb">%i18n:@local-drive-capacity-mb%<span slot="text">%i18n:@mb%</span></ui-input>
|
||||||
|
<ui-input v-model="remoteDriveCapacityMb">%i18n:@remote-drive-capacity-mb%<span slot="text">%i18n:@mb%</span></ui-input>
|
||||||
<ui-input v-model="maxNoteTextLength">%i18n:@max-note-text-length%</ui-input>
|
<ui-input v-model="maxNoteTextLength">%i18n:@max-note-text-length%</ui-input>
|
||||||
<ui-button @click="updateMeta">%i18n:@save%</ui-button>
|
<ui-button @click="updateMeta">%i18n:@save%</ui-button>
|
||||||
</section>
|
</section>
|
||||||
|
@ -40,6 +42,8 @@ export default Vue.extend({
|
||||||
bannerUrl: null,
|
bannerUrl: null,
|
||||||
name: null,
|
name: null,
|
||||||
description: null,
|
description: null,
|
||||||
|
localDriveCapacityMb: null,
|
||||||
|
remoteDriveCapacityMb: null,
|
||||||
maxNoteTextLength: null,
|
maxNoteTextLength: null,
|
||||||
inviteCode: null,
|
inviteCode: null,
|
||||||
};
|
};
|
||||||
|
@ -50,6 +54,8 @@ export default Vue.extend({
|
||||||
this.bannerUrl = meta.bannerUrl;
|
this.bannerUrl = meta.bannerUrl;
|
||||||
this.name = meta.name;
|
this.name = meta.name;
|
||||||
this.description = meta.description;
|
this.description = meta.description;
|
||||||
|
this.localDriveCapacityMb = meta.driveCapacityPerLocalUserMb;
|
||||||
|
this.remoteDriveCapacityMb = meta.driveCapacityPerRemoteUserMb;
|
||||||
this.maxNoteTextLength = meta.maxNoteTextLength;
|
this.maxNoteTextLength = meta.maxNoteTextLength;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -73,6 +79,8 @@ export default Vue.extend({
|
||||||
bannerUrl: this.bannerUrl,
|
bannerUrl: this.bannerUrl,
|
||||||
name: this.name,
|
name: this.name,
|
||||||
description: this.description,
|
description: this.description,
|
||||||
|
localDriveCapacityMb: parseInt(this.localDriveCapacityMb, 10),
|
||||||
|
remoteDriveCapacityMb: parseInt(this.remoteDriveCapacityMb, 10),
|
||||||
maxNoteTextLength: parseInt(this.maxNoteTextLength, 10)
|
maxNoteTextLength: parseInt(this.maxNoteTextLength, 10)
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
this.$swal({
|
this.$swal({
|
||||||
|
|
|
@ -46,9 +46,6 @@ export default function load() {
|
||||||
mixin.drive_url = `${mixin.scheme}://${mixin.host}/files`;
|
mixin.drive_url = `${mixin.scheme}://${mixin.host}/files`;
|
||||||
mixin.user_agent = `Misskey/${pkg.version} (${config.url})`;
|
mixin.user_agent = `Misskey/${pkg.version} (${config.url})`;
|
||||||
|
|
||||||
if (config.localDriveCapacityMb == null) config.localDriveCapacityMb = 256;
|
|
||||||
if (config.remoteDriveCapacityMb == null) config.remoteDriveCapacityMb = 8;
|
|
||||||
|
|
||||||
if (config.autoAdmin == null) config.autoAdmin = false;
|
if (config.autoAdmin == null) config.autoAdmin = false;
|
||||||
|
|
||||||
return Object.assign(config, mixin);
|
return Object.assign(config, mixin);
|
||||||
|
|
|
@ -46,8 +46,6 @@ export type Source = {
|
||||||
secret_key: string;
|
secret_key: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
localDriveCapacityMb: number;
|
|
||||||
remoteDriveCapacityMb: number;
|
|
||||||
preventCacheRemoteFiles: boolean;
|
preventCacheRemoteFiles: boolean;
|
||||||
|
|
||||||
drive?: {
|
drive?: {
|
||||||
|
|
19
src/misc/fetch-meta.ts
Normal file
19
src/misc/fetch-meta.ts
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
import Meta, { IMeta } from '../models/meta';
|
||||||
|
|
||||||
|
const defaultMeta: any = {
|
||||||
|
name: 'Misskey',
|
||||||
|
localDriveCapacityMb: 256,
|
||||||
|
remoteDriveCapacityMb: 8,
|
||||||
|
hidedTags: [],
|
||||||
|
stats: {
|
||||||
|
originalNotesCount: 0,
|
||||||
|
originalUsersCount: 0
|
||||||
|
},
|
||||||
|
maxNoteTextLength: 1000
|
||||||
|
};
|
||||||
|
|
||||||
|
export default async function(): Promise<IMeta> {
|
||||||
|
const meta = await Meta.findOne({});
|
||||||
|
|
||||||
|
return Object.assign({}, defaultMeta, meta);
|
||||||
|
}
|
|
@ -28,6 +28,28 @@ if ((config as any).description) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
if ((config as any).localDriveCapacityMb) {
|
||||||
|
Meta.findOne({}).then(m => {
|
||||||
|
if (m != null && m.localDriveCapacityMb == null) {
|
||||||
|
Meta.update({}, {
|
||||||
|
$set: {
|
||||||
|
localDriveCapacityMb: (config as any).localDriveCapacityMb
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if ((config as any).remoteDriveCapacityMb) {
|
||||||
|
Meta.findOne({}).then(m => {
|
||||||
|
if (m != null && m.remoteDriveCapacityMb == null) {
|
||||||
|
Meta.update({}, {
|
||||||
|
$set: {
|
||||||
|
remoteDriveCapacityMb: (config as any).remoteDriveCapacityMb
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
export type IMeta = {
|
export type IMeta = {
|
||||||
name?: string;
|
name?: string;
|
||||||
|
@ -44,6 +66,16 @@ export type IMeta = {
|
||||||
hidedTags?: string[];
|
hidedTags?: string[];
|
||||||
bannerUrl?: string;
|
bannerUrl?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Drive capacity of a local user (MB)
|
||||||
|
*/
|
||||||
|
localDriveCapacityMb?: number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Drive capacity of a remote user (MB)
|
||||||
|
*/
|
||||||
|
remoteDriveCapacityMb?: number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Max allowed note text length in charactors
|
* Max allowed note text length in charactors
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -65,7 +65,23 @@ export const meta = {
|
||||||
desc: {
|
desc: {
|
||||||
'ja-JP': '投稿の最大文字数'
|
'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;
|
set.maxNoteTextLength = ps.maxNoteTextLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ps.localDriveCapacityMb !== undefined) {
|
||||||
|
set.localDriveCapacityMb = ps.localDriveCapacityMb;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ps.remoteDriveCapacityMb !== undefined) {
|
||||||
|
set.remoteDriveCapacityMb = ps.remoteDriveCapacityMb;
|
||||||
|
}
|
||||||
|
|
||||||
await Meta.update({}, {
|
await Meta.update({}, {
|
||||||
$set: set
|
$set: set
|
||||||
}, { upsert: true });
|
}, { upsert: true });
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
import Note from '../../../../models/note';
|
import Note from '../../../../models/note';
|
||||||
import Meta from '../../../../models/meta';
|
|
||||||
import define from '../../define';
|
import define from '../../define';
|
||||||
|
import fetchMeta from '../../../../misc/fetch-meta';
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
requireCredential: false,
|
requireCredential: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default define(meta, (ps) => new Promise(async (res, rej) => {
|
export default define(meta, (ps) => new Promise(async (res, rej) => {
|
||||||
const meta = await Meta.findOne({});
|
const instance = await fetchMeta();
|
||||||
const hidedTags = meta ? (meta.hidedTags || []).map(t => t.toLowerCase()) : [];
|
const hidedTags = instance.hidedTags.map(t => t.toLowerCase());
|
||||||
|
|
||||||
const span = 1000 * 60 * 60 * 24 * 7; // 1週間
|
const span = 1000 * 60 * 60 * 24 * 7; // 1週間
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import DriveFile from '../../../models/drive-file';
|
import DriveFile from '../../../models/drive-file';
|
||||||
import config from '../../../config';
|
|
||||||
import define from '../define';
|
import define from '../define';
|
||||||
|
import fetchMeta from '../../../misc/fetch-meta';
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
desc: {
|
desc: {
|
||||||
|
@ -14,6 +14,8 @@ export const meta = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export default define(meta, (ps, user) => new Promise(async (res, rej) => {
|
export default define(meta, (ps, user) => new Promise(async (res, rej) => {
|
||||||
|
const instance = await fetchMeta();
|
||||||
|
|
||||||
// Calculate drive usage
|
// Calculate drive usage
|
||||||
const usage = await DriveFile
|
const usage = await DriveFile
|
||||||
.aggregate([{
|
.aggregate([{
|
||||||
|
@ -39,7 +41,7 @@ export default define(meta, (ps, user) => new Promise(async (res, rej) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
res({
|
res({
|
||||||
capacity: 1024 * 1024 * config.localDriveCapacityMb,
|
capacity: 1024 * 1024 * instance.localDriveCapacityMb,
|
||||||
usage: usage
|
usage: usage
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import Note from '../../../../models/note';
|
import Note from '../../../../models/note';
|
||||||
import { erase } from '../../../../prelude/array';
|
import { erase } from '../../../../prelude/array';
|
||||||
import Meta from '../../../../models/meta';
|
|
||||||
import define from '../../define';
|
import define from '../../define';
|
||||||
|
import fetchMeta from '../../../../misc/fetch-meta';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
トレンドに載るためには「『直近a分間のユニーク投稿数が今からa分前~今からb分前の間のユニーク投稿数のn倍以上』のハッシュタグの上位5位以内に入る」ことが必要
|
トレンドに載るためには「『直近a分間のユニーク投稿数が今からa分前~今からb分前の間のユニーク投稿数のn倍以上』のハッシュタグの上位5位以内に入る」ことが必要
|
||||||
|
@ -20,8 +20,8 @@ export const meta = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export default define(meta, () => new Promise(async (res, rej) => {
|
export default define(meta, () => new Promise(async (res, rej) => {
|
||||||
const meta = await Meta.findOne({});
|
const instance = await fetchMeta();
|
||||||
const hidedTags = meta ? (meta.hidedTags || []).map(t => t.toLowerCase()) : [];
|
const hidedTags = instance.hidedTags.map(t => t.toLowerCase());
|
||||||
|
|
||||||
//#region 1. 直近Aの内に投稿されたハッシュタグ(とユーザーのペア)を集計
|
//#region 1. 直近Aの内に投稿されたハッシュタグ(とユーザーのペア)を集計
|
||||||
const data = await Note.aggregate([{
|
const data = await Note.aggregate([{
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import $ from 'cafy';
|
import $ from 'cafy';
|
||||||
import * as os from 'os';
|
import * as os from 'os';
|
||||||
import config from '../../../config';
|
import config from '../../../config';
|
||||||
import Meta from '../../../models/meta';
|
|
||||||
import Emoji from '../../../models/emoji';
|
import Emoji from '../../../models/emoji';
|
||||||
import define from '../define';
|
import define from '../define';
|
||||||
|
import fetchMeta from '../../../misc/fetch-meta';
|
||||||
|
|
||||||
const pkg = require('../../../../package.json');
|
const pkg = require('../../../../package.json');
|
||||||
const client = require('../../../../built/client/meta.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) => {
|
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 }, {
|
const emojis = await Emoji.find({ host: null }, {
|
||||||
fields: {
|
fields: {
|
||||||
|
@ -41,8 +41,8 @@ export default define(meta, (ps, me) => new Promise(async (res, rej) => {
|
||||||
version: pkg.version,
|
version: pkg.version,
|
||||||
clientVersion: client.version,
|
clientVersion: client.version,
|
||||||
|
|
||||||
name: met.name || 'Misskey',
|
name: instance.name,
|
||||||
description: met.description,
|
description: instance.description,
|
||||||
|
|
||||||
secure: config.https != null,
|
secure: config.https != null,
|
||||||
machine: os.hostname(),
|
machine: os.hostname(),
|
||||||
|
@ -54,21 +54,22 @@ export default define(meta, (ps, me) => new Promise(async (res, rej) => {
|
||||||
cores: os.cpus().length
|
cores: os.cpus().length
|
||||||
},
|
},
|
||||||
|
|
||||||
broadcasts: met.broadcasts || [],
|
broadcasts: instance.broadcasts || [],
|
||||||
disableRegistration: met.disableRegistration,
|
disableRegistration: instance.disableRegistration,
|
||||||
disableLocalTimeline: met.disableLocalTimeline,
|
disableLocalTimeline: instance.disableLocalTimeline,
|
||||||
driveCapacityPerLocalUserMb: config.localDriveCapacityMb,
|
driveCapacityPerLocalUserMb: instance.localDriveCapacityMb,
|
||||||
|
driveCapacityPerRemoteUserMb: instance.remoteDriveCapacityMb,
|
||||||
recaptchaSitekey: config.recaptcha ? config.recaptcha.site_key : null,
|
recaptchaSitekey: config.recaptcha ? config.recaptcha.site_key : null,
|
||||||
swPublickey: config.sw ? config.sw.public_key : null,
|
swPublickey: config.sw ? config.sw.public_key : null,
|
||||||
hidedTags: (me && me.isAdmin) ? met.hidedTags : undefined,
|
hidedTags: (me && me.isAdmin) ? instance.hidedTags : undefined,
|
||||||
bannerUrl: met.bannerUrl,
|
bannerUrl: instance.bannerUrl,
|
||||||
maxNoteTextLength: met.maxNoteTextLength || 1000,
|
maxNoteTextLength: instance.maxNoteTextLength,
|
||||||
|
|
||||||
emojis: emojis,
|
emojis: emojis,
|
||||||
|
|
||||||
features: ps.detail ? {
|
features: ps.detail ? {
|
||||||
registration: !met.disableRegistration,
|
registration: !instance.disableRegistration,
|
||||||
localTimeLine: !met.disableLocalTimeline,
|
localTimeLine: !instance.disableLocalTimeline,
|
||||||
elasticsearch: config.elasticsearch ? true : false,
|
elasticsearch: config.elasticsearch ? true : false,
|
||||||
recaptcha: config.recaptcha ? true : false,
|
recaptcha: config.recaptcha ? true : false,
|
||||||
objectStorage: config.drive && config.drive.storage === 'minio',
|
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 DriveFile, { IDriveFile } from '../../../../models/drive-file';
|
||||||
import create from '../../../../services/note/create';
|
import create from '../../../../services/note/create';
|
||||||
import define from '../../define';
|
import define from '../../define';
|
||||||
import Meta from '../../../../models/meta';
|
import fetchMeta from '../../../../misc/fetch-meta';
|
||||||
|
|
||||||
let maxNoteTextLength = 1000;
|
let maxNoteTextLength = 1000;
|
||||||
|
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
Meta.findOne({}).then(m => {
|
fetchMeta().then(m => {
|
||||||
if (m.maxNoteTextLength) maxNoteTextLength = m.maxNoteTextLength;
|
maxNoteTextLength = m.maxNoteTextLength;
|
||||||
});
|
});
|
||||||
}, 3000);
|
}, 3000);
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import Meta from '../../../models/meta';
|
|
||||||
import define from '../define';
|
import define from '../define';
|
||||||
import driveChart from '../../../chart/drive';
|
import driveChart from '../../../chart/drive';
|
||||||
import federationChart from '../../../chart/federation';
|
import federationChart from '../../../chart/federation';
|
||||||
|
import fetchMeta from '../../../misc/fetch-meta';
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
requireCredential: false,
|
requireCredential: false,
|
||||||
|
@ -15,9 +15,9 @@ export const meta = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export default define(meta, () => new Promise(async (res, rej) => {
|
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);
|
const driveStats = await driveChart.getChart('hour', 1);
|
||||||
stats.driveUsageLocal = driveStats.local.totalSize[0];
|
stats.driveUsageLocal = driveStats.local.totalSize[0];
|
||||||
|
|
|
@ -2,10 +2,10 @@ import * as Router from 'koa-router';
|
||||||
import User from '../../../models/user';
|
import User from '../../../models/user';
|
||||||
import { toASCII } from 'punycode';
|
import { toASCII } from 'punycode';
|
||||||
import config from '../../../config';
|
import config from '../../../config';
|
||||||
import Meta from '../../../models/meta';
|
|
||||||
import { ObjectID } from 'bson';
|
import { ObjectID } from 'bson';
|
||||||
import Emoji from '../../../models/emoji';
|
import Emoji from '../../../models/emoji';
|
||||||
import { toMastodonEmojis } from './emoji';
|
import { toMastodonEmojis } from './emoji';
|
||||||
|
import fetchMeta from '../../../misc/fetch-meta';
|
||||||
const pkg = require('../../../../package.json');
|
const pkg = require('../../../../package.json');
|
||||||
|
|
||||||
// Init router
|
// Init router
|
||||||
|
@ -19,11 +19,8 @@ router.get('/v1/custom_emojis', async ctx => ctx.body =
|
||||||
})).map(x => toMastodonEmojis(x)));
|
})).map(x => toMastodonEmojis(x)));
|
||||||
|
|
||||||
router.get('/v1/instance', async ctx => { // TODO: This is a temporary implementation. Consider creating helper methods!
|
router.get('/v1/instance', async ctx => { // TODO: This is a temporary implementation. Consider creating helper methods!
|
||||||
const meta = await Meta.findOne() || {};
|
const meta = await fetchMeta();
|
||||||
const { originalNotesCount, originalUsersCount } = meta.stats || {
|
const { originalNotesCount, originalUsersCount } = meta.stats;
|
||||||
originalNotesCount: 0,
|
|
||||||
originalUsersCount: 0
|
|
||||||
};
|
|
||||||
const domains = await User.distinct('host', { host: { $ne: null } }) as any as [] || [];
|
const domains = await User.distinct('host', { host: { $ne: null } }) as any as [] || [];
|
||||||
const maintainer = await User.findOne({ isAdmin: true }) || {
|
const maintainer = await User.findOne({ isAdmin: true }) || {
|
||||||
_id: ObjectID.createFromTime(0),
|
_id: ObjectID.createFromTime(0),
|
||||||
|
|
|
@ -8,6 +8,7 @@ import config from '../../../config';
|
||||||
import Meta from '../../../models/meta';
|
import Meta from '../../../models/meta';
|
||||||
import RegistrationTicket from '../../../models/registration-tickets';
|
import RegistrationTicket from '../../../models/registration-tickets';
|
||||||
import usersChart from '../../../chart/users';
|
import usersChart from '../../../chart/users';
|
||||||
|
import fetchMeta from '../../../misc/fetch-meta';
|
||||||
|
|
||||||
if (config.recaptcha) {
|
if (config.recaptcha) {
|
||||||
recaptcha.init({
|
recaptcha.init({
|
||||||
|
@ -33,9 +34,9 @@ export default async (ctx: Koa.Context) => {
|
||||||
const password = body['password'];
|
const password = body['password'];
|
||||||
const invitationCode = body['invitationCode'];
|
const invitationCode = body['invitationCode'];
|
||||||
|
|
||||||
const meta = await Meta.findOne({});
|
const instance = await fetchMeta();
|
||||||
|
|
||||||
if (meta && meta.disableRegistration) {
|
if (instance && instance.disableRegistration) {
|
||||||
if (invitationCode == null || typeof invitationCode != 'string') {
|
if (invitationCode == null || typeof invitationCode != 'string') {
|
||||||
ctx.status = 400;
|
ctx.status = 400;
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -19,6 +19,7 @@ import config from '../../config';
|
||||||
import { getDriveFileThumbnailBucket } from '../../models/drive-file-thumbnail';
|
import { getDriveFileThumbnailBucket } from '../../models/drive-file-thumbnail';
|
||||||
import driveChart from '../../chart/drive';
|
import driveChart from '../../chart/drive';
|
||||||
import perUserDriveChart from '../../chart/per-user-drive';
|
import perUserDriveChart from '../../chart/per-user-drive';
|
||||||
|
import fetchMeta from '../../misc/fetch-meta';
|
||||||
|
|
||||||
const log = debug('misskey:drive:add-file');
|
const log = debug('misskey:drive:add-file');
|
||||||
|
|
||||||
|
@ -255,7 +256,8 @@ export default async function(
|
||||||
|
|
||||||
log(`drive usage is ${usage}`);
|
log(`drive usage is ${usage}`);
|
||||||
|
|
||||||
const driveCapacity = 1024 * 1024 * (isLocalUser(user) ? config.localDriveCapacityMb : config.remoteDriveCapacityMb);
|
const instance = await fetchMeta();
|
||||||
|
const driveCapacity = 1024 * 1024 * (isLocalUser(user) ? instance.localDriveCapacityMb : instance.remoteDriveCapacityMb);
|
||||||
|
|
||||||
// If usage limit exceeded
|
// If usage limit exceeded
|
||||||
if (usage + size > driveCapacity) {
|
if (usage + size > driveCapacity) {
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
import * as mongo from 'mongodb';
|
import * as mongo from 'mongodb';
|
||||||
import redis from './db/redis';
|
import redis from './db/redis';
|
||||||
import Xev from 'xev';
|
import Xev from 'xev';
|
||||||
import Meta, { IMeta } from './models/meta';
|
import { IMeta } from './models/meta';
|
||||||
|
import fetchMeta from './misc/fetch-meta';
|
||||||
|
|
||||||
type ID = string | mongo.ObjectID;
|
type ID = string | mongo.ObjectID;
|
||||||
|
|
||||||
|
@ -16,14 +17,14 @@ class Publisher {
|
||||||
}
|
}
|
||||||
|
|
||||||
setInterval(async () => {
|
setInterval(async () => {
|
||||||
this.meta = await Meta.findOne({});
|
this.meta = await fetchMeta();
|
||||||
}, 5000);
|
}, 5000);
|
||||||
}
|
}
|
||||||
|
|
||||||
public getMeta = async () => {
|
public fetchMeta = async () => {
|
||||||
if (this.meta != null) return this.meta;
|
if (this.meta != null) return this.meta;
|
||||||
|
|
||||||
this.meta = await Meta.findOne({});
|
this.meta = await fetchMeta();
|
||||||
return this.meta;
|
return this.meta;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,13 +83,13 @@ class Publisher {
|
||||||
}
|
}
|
||||||
|
|
||||||
public publishLocalTimelineStream = async (note: any): Promise<void> => {
|
public publishLocalTimelineStream = async (note: any): Promise<void> => {
|
||||||
const meta = await this.getMeta();
|
const meta = await this.fetchMeta();
|
||||||
if (meta.disableLocalTimeline) return;
|
if (meta.disableLocalTimeline) return;
|
||||||
this.publish('localTimeline', null, note);
|
this.publish('localTimeline', null, note);
|
||||||
}
|
}
|
||||||
|
|
||||||
public publishHybridTimelineStream = async (userId: ID, note: any): Promise<void> => {
|
public publishHybridTimelineStream = async (userId: ID, note: any): Promise<void> => {
|
||||||
const meta = await this.getMeta();
|
const meta = await this.fetchMeta();
|
||||||
if (meta.disableLocalTimeline) return;
|
if (meta.disableLocalTimeline) return;
|
||||||
this.publish(userId ? `hybridTimeline:${userId}` : 'hybridTimeline', null, note);
|
this.publish(userId ? `hybridTimeline:${userId}` : 'hybridTimeline', null, note);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue