forked from FoundKeyGang/FoundKey
Merge branch 'master' into l10n_master
This commit is contained in:
commit
0e45d0d47f
59 changed files with 2935 additions and 869 deletions
|
@ -5,6 +5,15 @@ ChangeLog
|
|||
|
||||
This document describes breaking changes only.
|
||||
|
||||
7.0.0
|
||||
-----
|
||||
|
||||
### Migration
|
||||
|
||||
起動する前に、`node cli/migration/7.0.0`してください。
|
||||
|
||||
Please run `node cli/migration/7.0.0` before launch.
|
||||
|
||||
6.0.0
|
||||
-----
|
||||
|
||||
|
|
12
README.md
12
README.md
|
@ -7,10 +7,12 @@
|
|||
[![][dependencies-badge]][dependencies-link]
|
||||
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com) [![Greenkeeper badge](https://badges.greenkeeper.io/syuilo/misskey.svg)](https://greenkeeper.io/)
|
||||
|
||||
**Microblogging. Redefined.**
|
||||
Sophisticated microblogging platform, evolving forever.
|
||||
|
||||
**[Misskey](https://misskey.xyz)** is a completely open source,
|
||||
ultimately sophisticated professional microblogging software.
|
||||
[Misskey](https://misskey.xyz) is a decentralized microblogging platform born on Earth.
|
||||
Since it exists within the Fediverse (a universe where various social media platforms are organized),
|
||||
it is mutually linked with other social media platforms.
|
||||
Why don't you take a short break from the hustle and bustle of the city, and dive into a new Internet?
|
||||
|
||||
<a href="https://www.patreon.com/syuilo"><img src="https://c5.patreon.com/external/logo/become_a_patron_button@2x.png" alt="Become a Patron!" width="160" /></a>
|
||||
|
||||
|
@ -28,7 +30,7 @@ ultimately sophisticated professional microblogging software.
|
|||
|
||||
and more! You can see it with your own eyes at [misskey.xyz](https://misskey.xyz).
|
||||
|
||||
:package: Create your instance
|
||||
:package: Create your own instance
|
||||
----------------------------------------------------------------
|
||||
If you want to run your own instance of Misskey,
|
||||
please see [Setup and installation guide](./docs/setup.en.md).
|
||||
|
@ -43,6 +45,7 @@ If you want to...
|
|||
|
||||
:heart: Backers & Sponsors
|
||||
----------------------------------------------------------------
|
||||
<!-- PATREON_START -->
|
||||
<table>
|
||||
<tr>
|
||||
<td><img src="https://c10.patreonusercontent.com/3/eyJoIjoxMDAsInciOjEwMH0%3D/patreon-media/p/user/619786/32cf01444db24e578cd1982c197f6fc6/1?token-time=2145916800&token-hash=tB1e_r8RlZ5sFL0KV_e8dugapxatNBRK1Z3h67TO1g8%3D"></td>
|
||||
|
@ -71,6 +74,7 @@ If you want to...
|
|||
<td><a href="https://www.patreon.com/gutfuckllc">gutfuckllc</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
<!-- PATREON_END -->
|
||||
|
||||
:four_leaf_clover: Copyright
|
||||
----------------------------------------------------------------
|
||||
|
|
|
@ -1,101 +0,0 @@
|
|||
const chalk = require('chalk');
|
||||
const log = require('single-line-log').stdout;
|
||||
const sequential = require('promise-sequential');
|
||||
const { default: DriveFile, DriveFileChunk } = require('../built/models/drive-file');
|
||||
const { default: DriveFileThumbnail, DriveFileThumbnailChunk } = require('../built/models/drive-file-thumbnail');
|
||||
const { default: User } = require('../built/models/user');
|
||||
|
||||
const q = {
|
||||
'metadata._user.host': {
|
||||
$ne: null
|
||||
},
|
||||
'metadata.withoutChunks': false
|
||||
};
|
||||
|
||||
async function main() {
|
||||
const promiseGens = [];
|
||||
|
||||
const count = await DriveFile.count(q);
|
||||
|
||||
let prev;
|
||||
|
||||
for (let i = 0; i < count; i++) {
|
||||
promiseGens.push(() => {
|
||||
const promise = new Promise(async (res, rej) => {
|
||||
const file = await DriveFile.findOne(prev ? Object.assign({
|
||||
_id: { $lt: prev._id }
|
||||
}, q) : q, {
|
||||
sort: {
|
||||
_id: -1
|
||||
}
|
||||
});
|
||||
|
||||
prev = file;
|
||||
|
||||
function skip() {
|
||||
res([i, file, false]);
|
||||
}
|
||||
|
||||
if (file == null) return skip();
|
||||
|
||||
log(chalk`{gray ${i}} scanning {bold ${file._id}} ${file.filename} ...`);
|
||||
|
||||
const attachingUsersCount = await User.count({
|
||||
$or: [{
|
||||
avatarId: file._id
|
||||
}, {
|
||||
bannerId: file._id
|
||||
}]
|
||||
}, { limit: 1 });
|
||||
if (attachingUsersCount !== 0) return skip();
|
||||
|
||||
Promise.all([
|
||||
// チャンクをすべて削除
|
||||
DriveFileChunk.remove({
|
||||
files_id: file._id
|
||||
}),
|
||||
|
||||
DriveFile.update({ _id: file._id }, {
|
||||
$set: {
|
||||
'metadata.withoutChunks': true
|
||||
}
|
||||
})
|
||||
]).then(async () => {
|
||||
res([i, file, true]);
|
||||
|
||||
//#region サムネイルもあれば削除
|
||||
const thumbnail = await DriveFileThumbnail.findOne({
|
||||
'metadata.originalId': file._id
|
||||
});
|
||||
|
||||
if (thumbnail) {
|
||||
DriveFileThumbnailChunk.remove({
|
||||
files_id: thumbnail._id
|
||||
});
|
||||
|
||||
DriveFileThumbnail.remove({ _id: thumbnail._id });
|
||||
}
|
||||
//#endregion
|
||||
});
|
||||
});
|
||||
|
||||
promise.then(([i, file, deleted]) => {
|
||||
if (deleted) {
|
||||
log(chalk`{gray ${i}} {red deleted: {bold ${file._id}} ${file.filename}}`);
|
||||
} else {
|
||||
log(chalk`{gray ${i}} {green skipped: {bold ${file._id}} ${file.filename}}`);
|
||||
}
|
||||
log.clear();
|
||||
console.log();
|
||||
});
|
||||
|
||||
return promise;
|
||||
});
|
||||
}
|
||||
|
||||
return await sequential(promiseGens);
|
||||
}
|
||||
|
||||
main().then(() => {
|
||||
console.log('ALL DONE');
|
||||
}).catch(console.error);
|
|
@ -1,80 +0,0 @@
|
|||
const chalk = require('chalk');
|
||||
const log = require('single-line-log').stdout;
|
||||
const sequential = require('promise-sequential');
|
||||
const { default: DriveFile, deleteDriveFile } = require('../built/models/drive-file');
|
||||
const { default: Note } = require('../built/models/note');
|
||||
const { default: MessagingMessage } = require('../built/models/messaging-message');
|
||||
const { default: User } = require('../built/models/user');
|
||||
|
||||
async function main() {
|
||||
const promiseGens = [];
|
||||
|
||||
const count = await DriveFile.count({});
|
||||
|
||||
let prev;
|
||||
|
||||
for (let i = 0; i < count; i++) {
|
||||
promiseGens.push(() => {
|
||||
const promise = new Promise(async (res, rej) => {
|
||||
const file = await DriveFile.findOne(prev ? {
|
||||
_id: { $lt: prev._id }
|
||||
} : {}, {
|
||||
sort: {
|
||||
_id: -1
|
||||
}
|
||||
});
|
||||
|
||||
prev = file;
|
||||
|
||||
function skip() {
|
||||
res([i, file, false]);
|
||||
}
|
||||
|
||||
if (file == null) return skip();
|
||||
|
||||
log(chalk`{gray ${i}} scanning {bold ${file._id}} ${file.filename} ...`);
|
||||
|
||||
const attachingUsersCount = await User.count({
|
||||
$or: [{
|
||||
avatarId: file._id
|
||||
}, {
|
||||
bannerId: file._id
|
||||
}]
|
||||
}, { limit: 1 });
|
||||
if (attachingUsersCount !== 0) return skip();
|
||||
|
||||
const attachingNotesCount = await Note.count({
|
||||
mediaIds: file._id
|
||||
}, { limit: 1 });
|
||||
if (attachingNotesCount !== 0) return skip();
|
||||
|
||||
const attachingMessagesCount = await MessagingMessage.count({
|
||||
fileId: file._id
|
||||
}, { limit: 1 });
|
||||
if (attachingMessagesCount !== 0) return skip();
|
||||
|
||||
deleteDriveFile(file).then(() => {
|
||||
res([i, file, true]);
|
||||
}).catch(rej);
|
||||
});
|
||||
|
||||
promise.then(([i, file, deleted]) => {
|
||||
if (deleted) {
|
||||
log(chalk`{gray ${i}} {red deleted: {bold ${file._id}} ${file.filename}}`);
|
||||
} else {
|
||||
log(chalk`{gray ${i}} {green skipped: {bold ${file._id}} ${file.filename}}`);
|
||||
}
|
||||
log.clear();
|
||||
console.log();
|
||||
});
|
||||
|
||||
return promise;
|
||||
});
|
||||
}
|
||||
|
||||
return await sequential(promiseGens);
|
||||
}
|
||||
|
||||
main().then(() => {
|
||||
console.log('done');
|
||||
}).catch(console.error);
|
134
cli/migration/7.0.0.js
Normal file
134
cli/migration/7.0.0.js
Normal file
|
@ -0,0 +1,134 @@
|
|||
const { default: Stats } = require('../../built/models/stats');
|
||||
const { default: User } = require('../../built/models/user');
|
||||
const { default: Note } = require('../../built/models/note');
|
||||
const { default: DriveFile } = require('../../built/models/drive-file');
|
||||
|
||||
const now = new Date();
|
||||
const y = now.getFullYear();
|
||||
const m = now.getMonth();
|
||||
const d = now.getDate();
|
||||
const today = new Date(y, m, d);
|
||||
|
||||
async function main() {
|
||||
const localUsersCount = await User.count({
|
||||
host: null
|
||||
});
|
||||
|
||||
const remoteUsersCount = await User.count({
|
||||
host: { $ne: null }
|
||||
});
|
||||
|
||||
const localNotesCount = await Note.count({
|
||||
'_user.host': null
|
||||
});
|
||||
|
||||
const remoteNotesCount = await Note.count({
|
||||
'_user.host': { $ne: null }
|
||||
});
|
||||
|
||||
const localDriveFilesCount = await DriveFile.count({
|
||||
'metadata._user.host': null
|
||||
});
|
||||
|
||||
const remoteDriveFilesCount = await DriveFile.count({
|
||||
'metadata._user.host': { $ne: null }
|
||||
});
|
||||
|
||||
const localDriveFilesSize = await DriveFile
|
||||
.aggregate([{
|
||||
$match: {
|
||||
'metadata._user.host': null,
|
||||
'metadata.deletedAt': { $exists: false }
|
||||
}
|
||||
}, {
|
||||
$project: {
|
||||
length: true
|
||||
}
|
||||
}, {
|
||||
$group: {
|
||||
_id: null,
|
||||
usage: { $sum: '$length' }
|
||||
}
|
||||
}])
|
||||
.then(aggregates => {
|
||||
if (aggregates.length > 0) {
|
||||
return aggregates[0].usage;
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
|
||||
const remoteDriveFilesSize = await DriveFile
|
||||
.aggregate([{
|
||||
$match: {
|
||||
'metadata._user.host': { $ne: null },
|
||||
'metadata.deletedAt': { $exists: false }
|
||||
}
|
||||
}, {
|
||||
$project: {
|
||||
length: true
|
||||
}
|
||||
}, {
|
||||
$group: {
|
||||
_id: null,
|
||||
usage: { $sum: '$length' }
|
||||
}
|
||||
}])
|
||||
.then(aggregates => {
|
||||
if (aggregates.length > 0) {
|
||||
return aggregates[0].usage;
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
|
||||
await Stats.insert({
|
||||
date: today,
|
||||
users: {
|
||||
local: {
|
||||
total: localUsersCount,
|
||||
diff: 0
|
||||
},
|
||||
remote: {
|
||||
total: remoteUsersCount,
|
||||
diff: 0
|
||||
}
|
||||
},
|
||||
notes: {
|
||||
local: {
|
||||
total: localNotesCount,
|
||||
diff: 0,
|
||||
diffs: {
|
||||
normal: 0,
|
||||
reply: 0,
|
||||
renote: 0
|
||||
}
|
||||
},
|
||||
remote: {
|
||||
total: remoteNotesCount,
|
||||
diff: 0,
|
||||
diffs: {
|
||||
normal: 0,
|
||||
reply: 0,
|
||||
renote: 0
|
||||
}
|
||||
}
|
||||
},
|
||||
drive: {
|
||||
local: {
|
||||
totalCount: localDriveFilesCount,
|
||||
totalSize: localDriveFilesSize,
|
||||
diffCount: 0,
|
||||
diffSize: 0
|
||||
},
|
||||
remote: {
|
||||
totalCount: remoteDriveFilesCount,
|
||||
totalSize: remoteDriveFilesSize,
|
||||
diffCount: 0,
|
||||
diffSize: 0
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
console.log('done');
|
||||
}
|
||||
|
||||
main();
|
|
@ -33,14 +33,3 @@ node cli/suspend @syuilo@misskey.xyz
|
|||
``` shell
|
||||
node cli/reset-password (User-ID or Username)
|
||||
```
|
||||
|
||||
## Clean up cached remote files
|
||||
``` shell
|
||||
node cli/clean-cached-remote-files
|
||||
```
|
||||
|
||||
## Clean up unused drive files
|
||||
``` shell
|
||||
node cli/clean-unused-drive-files
|
||||
```
|
||||
> We recommend that you announce a user that unused drive files will be deleted before performing this operation, as it may delete the user's important files.
|
||||
|
|
|
@ -33,14 +33,3 @@ node cli/suspend @syuilo@misskey.xyz
|
|||
``` shell
|
||||
node cli/reset-password (ユーザーID または ユーザー名)
|
||||
```
|
||||
|
||||
## キャッシュされたリモートファイルをクリーンアップする
|
||||
``` shell
|
||||
node cli/clean-cached-remote-files
|
||||
```
|
||||
|
||||
## 使われていないドライブのファイルをクリーンアップする
|
||||
``` shell
|
||||
node cli/clean-unused-drive-files
|
||||
```
|
||||
> ユーザーの大事なファイルを削除する可能性があるので、この操作を実行する前にユーザーに告知することをお勧めします。
|
||||
|
|
|
@ -15,6 +15,7 @@ const langs = {
|
|||
'en': loadLang('en'),
|
||||
'fr': loadLang('fr'),
|
||||
'ja': native,
|
||||
'ja-ks': loadLang('ja-ks'),
|
||||
'pl': loadLang('pl'),
|
||||
'es': loadLang('es')
|
||||
};
|
||||
|
|
1412
locales/ja-ks.yml
Normal file
1412
locales/ja-ks.yml
Normal file
File diff suppressed because it is too large
Load diff
|
@ -1,8 +1,8 @@
|
|||
{
|
||||
"name": "misskey",
|
||||
"author": "syuilo <i@syuilo.com>",
|
||||
"version": "6.2.0",
|
||||
"clientVersion": "1.0.8417",
|
||||
"version": "7.0.0",
|
||||
"clientVersion": "1.0.8520",
|
||||
"codename": "nighthike",
|
||||
"main": "./built/index.js",
|
||||
"private": true,
|
||||
|
@ -201,7 +201,7 @@
|
|||
"typescript": "2.9.2",
|
||||
"typescript-eslint-parser": "18.0.0",
|
||||
"uglify-es": "3.3.9",
|
||||
"url-loader": "1.1.0",
|
||||
"url-loader": "1.1.1",
|
||||
"uuid": "3.3.2",
|
||||
"v-animate-css": "0.0.2",
|
||||
"vue": "2.5.17",
|
||||
|
|
10
src/client/app/common/scripts/get-face.ts
Normal file
10
src/client/app/common/scripts/get-face.ts
Normal file
|
@ -0,0 +1,10 @@
|
|||
const faces = [
|
||||
'(=^・・^=)',
|
||||
'v(\'ω\')v',
|
||||
'🐡( \'-\' 🐡 )フグパンチ!!!!',
|
||||
'🖕(´・_・`)🖕',
|
||||
'(。>﹏<。)',
|
||||
'(Δ・x・Δ)'
|
||||
];
|
||||
|
||||
export default () => faces[Math.floor(Math.random() * faces.length)];
|
|
@ -1,9 +0,0 @@
|
|||
const kaos = [
|
||||
'(=^・・^=)',
|
||||
'v(\'ω\')v',
|
||||
'🐡( \'-\' 🐡 )フグパンチ!!!!',
|
||||
'🖕(´・_・`)🖕',
|
||||
'(。>﹏<。)'
|
||||
];
|
||||
|
||||
export default () => kaos[Math.floor(Math.random() * kaos.length)];
|
|
@ -32,6 +32,7 @@
|
|||
<mk-avatar class="avatar" :user="g.user2"/>
|
||||
<span><b>{{ g.user1 | userName }}</b> vs <b>{{ g.user2 | userName }}</b></span>
|
||||
<span class="state">{{ g.isEnded ? '%i18n:@game-state.ended%' : '%i18n:@game-state.playing%' }}</span>
|
||||
<mk-time :time="g.createdAt" />
|
||||
</a>
|
||||
</section>
|
||||
<section v-if="games.length > 0">
|
||||
|
@ -41,6 +42,7 @@
|
|||
<mk-avatar class="avatar" :user="g.user2"/>
|
||||
<span><b>{{ g.user1 | userName }}</b> vs <b>{{ g.user2 | userName }}</b></span>
|
||||
<span class="state">{{ g.isEnded ? '%i18n:@game-state.ended%' : '%i18n:@game-state.playing%' }}</span>
|
||||
<mk-time :time="g.createdAt" />
|
||||
</a>
|
||||
</section>
|
||||
</div>
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
<template>
|
||||
<form class="mk-signup" @submit.prevent="onSubmit" :autocomplete="Math.random()">
|
||||
<ui-input v-if="meta.disableRegistration" v-model="invitationCode" type="text" :autocomplete="Math.random()" spellcheck="false" required>
|
||||
<span>%i18n:@invitation-code%</span>
|
||||
<span slot="prefix">%fa:id-card-alt%</span>
|
||||
<p slot="text" v-html="'%i18n:@invitation-info%'.replace('{}', meta.maintainer.url)"></p>
|
||||
</ui-input>
|
||||
<ui-input v-model="username" type="text" pattern="^[a-zA-Z0-9_]{1,20}$" :autocomplete="Math.random()" spellcheck="false" required @input="onChangeUsername">
|
||||
<span>%i18n:@username%</span>
|
||||
<span slot="prefix">@</span>
|
||||
|
@ -46,11 +51,13 @@ export default Vue.extend({
|
|||
username: '',
|
||||
password: '',
|
||||
retypedPassword: '',
|
||||
invitationCode: '',
|
||||
url,
|
||||
recaptchaSitekey,
|
||||
usernameState: null,
|
||||
passwordStrength: '',
|
||||
passwordRetypeState: null
|
||||
passwordRetypeState: null,
|
||||
meta: null
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
|
@ -61,6 +68,11 @@ export default Vue.extend({
|
|||
this.usernameState != 'max-range');
|
||||
}
|
||||
},
|
||||
created() {
|
||||
(this as any).os.getMeta().then(meta => {
|
||||
this.meta = meta;
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
onChangeUsername() {
|
||||
if (this.username == '') {
|
||||
|
@ -110,6 +122,7 @@ export default Vue.extend({
|
|||
(this as any).api('signup', {
|
||||
username: this.username,
|
||||
password: this.password,
|
||||
invitationCode: this.invitationCode,
|
||||
'g-recaptcha-response': recaptchaSitekey != null ? (window as any).grecaptcha.getResponse() : null
|
||||
}).then(() => {
|
||||
(this as any).api('signin', {
|
||||
|
|
|
@ -44,7 +44,12 @@ import Vue from 'vue';
|
|||
import * as anime from 'animejs';
|
||||
|
||||
export default Vue.extend({
|
||||
props: ['source', 'compact', 'v'],
|
||||
props: ['source', 'compact'],
|
||||
data() {
|
||||
return {
|
||||
v: this.$store.state.device.visibility || 'public'
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.$nextTick(() => {
|
||||
const popover = this.$refs.popover as any;
|
||||
|
@ -92,6 +97,7 @@ export default Vue.extend({
|
|||
},
|
||||
methods: {
|
||||
choose(visibility) {
|
||||
this.$store.commit('device/setVisibility', visibility);
|
||||
this.$emit('chosen', visibility);
|
||||
this.$destroy();
|
||||
},
|
||||
|
|
|
@ -58,7 +58,7 @@
|
|||
import Vue from 'vue';
|
||||
import insertTextAtCursor from 'insert-text-at-cursor';
|
||||
import * as XDraggable from 'vuedraggable';
|
||||
import getKao from '../../../common/scripts/get-kao';
|
||||
import getFace from '../../../common/scripts/get-face';
|
||||
import MkVisibilityChooser from '../../../common/views/components/visibility-chooser.vue';
|
||||
import parse from '../../../../../mfm/parse';
|
||||
import { host } from '../../../config';
|
||||
|
@ -99,7 +99,7 @@ export default Vue.extend({
|
|||
useCw: false,
|
||||
cw: null,
|
||||
geo: null,
|
||||
visibility: 'public',
|
||||
visibility: this.$store.state.device.visibility || 'public',
|
||||
visibleUsers: [],
|
||||
autocomplete: null,
|
||||
draghover: false,
|
||||
|
@ -326,8 +326,7 @@ export default Vue.extend({
|
|||
|
||||
setVisibility() {
|
||||
const w = (this as any).os.new(MkVisibilityChooser, {
|
||||
source: this.$refs.visibilityButton,
|
||||
v: this.visibility
|
||||
source: this.$refs.visibilityButton
|
||||
});
|
||||
w.$once('chosen', v => {
|
||||
this.visibility = v;
|
||||
|
@ -422,7 +421,7 @@ export default Vue.extend({
|
|||
},
|
||||
|
||||
kao() {
|
||||
this.text += getKao();
|
||||
this.text += getFace();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
145
src/client/app/desktop/views/pages/admin/admin.cpu-memory.vue
Normal file
145
src/client/app/desktop/views/pages/admin/admin.cpu-memory.vue
Normal file
|
@ -0,0 +1,145 @@
|
|||
<template>
|
||||
<div class="zyknedwtlthezamcjlolyusmipqmjgxz">
|
||||
<svg :viewBox="`0 0 ${ viewBoxX } ${ viewBoxY }`">
|
||||
<defs>
|
||||
<linearGradient :id="cpuGradientId" x1="0" x2="0" y1="1" y2="0">
|
||||
<stop offset="0%" stop-color="hsl(180, 80%, 70%)"></stop>
|
||||
<stop offset="100%" stop-color="hsl(0, 80%, 70%)"></stop>
|
||||
</linearGradient>
|
||||
<mask :id="cpuMaskId" x="0" y="0" :width="viewBoxX" :height="viewBoxY">
|
||||
<polygon
|
||||
:points="cpuPolygonPoints"
|
||||
fill="#fff"
|
||||
fill-opacity="0.5"/>
|
||||
<polyline
|
||||
:points="cpuPolylinePoints"
|
||||
fill="none"
|
||||
stroke="#fff"
|
||||
stroke-width="0.3"/>
|
||||
</mask>
|
||||
</defs>
|
||||
<rect
|
||||
x="0" y="0"
|
||||
:width="viewBoxX" :height="viewBoxY"
|
||||
:style="`stroke: none; fill: url(#${ cpuGradientId }); mask: url(#${ cpuMaskId })`"/>
|
||||
<text x="1" y="5">CPU <tspan>{{ cpuP }}%</tspan></text>
|
||||
</svg>
|
||||
<svg :viewBox="`0 0 ${ viewBoxX } ${ viewBoxY }`">
|
||||
<defs>
|
||||
<linearGradient :id="memGradientId" x1="0" x2="0" y1="1" y2="0">
|
||||
<stop offset="0%" stop-color="hsl(180, 80%, 70%)"></stop>
|
||||
<stop offset="100%" stop-color="hsl(0, 80%, 70%)"></stop>
|
||||
</linearGradient>
|
||||
<mask :id="memMaskId" x="0" y="0" :width="viewBoxX" :height="viewBoxY">
|
||||
<polygon
|
||||
:points="memPolygonPoints"
|
||||
fill="#fff"
|
||||
fill-opacity="0.5"/>
|
||||
<polyline
|
||||
:points="memPolylinePoints"
|
||||
fill="none"
|
||||
stroke="#fff"
|
||||
stroke-width="0.3"/>
|
||||
</mask>
|
||||
</defs>
|
||||
<rect
|
||||
x="0" y="0"
|
||||
:width="viewBoxX" :height="viewBoxY"
|
||||
:style="`stroke: none; fill: url(#${ memGradientId }); mask: url(#${ memMaskId })`"/>
|
||||
<text x="1" y="5">MEM <tspan>{{ memP }}%</tspan></text>
|
||||
</svg>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import Vue from 'vue';
|
||||
import * as uuid from 'uuid';
|
||||
|
||||
export default Vue.extend({
|
||||
props: ['connection'],
|
||||
data() {
|
||||
return {
|
||||
viewBoxX: 50,
|
||||
viewBoxY: 20,
|
||||
stats: [],
|
||||
cpuGradientId: uuid(),
|
||||
cpuMaskId: uuid(),
|
||||
memGradientId: uuid(),
|
||||
memMaskId: uuid(),
|
||||
cpuPolylinePoints: '',
|
||||
memPolylinePoints: '',
|
||||
cpuPolygonPoints: '',
|
||||
memPolygonPoints: '',
|
||||
cpuP: '',
|
||||
memP: ''
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
this.connection.on('stats', this.onStats);
|
||||
this.connection.on('statsLog', this.onStatsLog);
|
||||
this.connection.send({
|
||||
type: 'requestLog',
|
||||
id: Math.random().toString()
|
||||
});
|
||||
},
|
||||
beforeDestroy() {
|
||||
this.connection.off('stats', this.onStats);
|
||||
this.connection.off('statsLog', this.onStatsLog);
|
||||
},
|
||||
methods: {
|
||||
onStats(stats) {
|
||||
this.stats.push(stats);
|
||||
if (this.stats.length > 50) this.stats.shift();
|
||||
|
||||
const cpuPolylinePoints = this.stats.map((s, i) => [this.viewBoxX - ((this.stats.length - 1) - i), (1 - s.cpu_usage) * this.viewBoxY]);
|
||||
const memPolylinePoints = this.stats.map((s, i) => [this.viewBoxX - ((this.stats.length - 1) - i), (1 - (s.mem.used / s.mem.total)) * this.viewBoxY]);
|
||||
this.cpuPolylinePoints = cpuPolylinePoints.map(xy => `${xy[0]},${xy[1]}`).join(' ');
|
||||
this.memPolylinePoints = memPolylinePoints.map(xy => `${xy[0]},${xy[1]}`).join(' ');
|
||||
|
||||
this.cpuPolygonPoints = `${this.viewBoxX - (this.stats.length - 1)},${this.viewBoxY} ${this.cpuPolylinePoints} ${this.viewBoxX},${this.viewBoxY}`;
|
||||
this.memPolygonPoints = `${this.viewBoxX - (this.stats.length - 1)},${this.viewBoxY} ${this.memPolylinePoints} ${this.viewBoxX},${this.viewBoxY}`;
|
||||
|
||||
this.cpuP = (stats.cpu_usage * 100).toFixed(0);
|
||||
this.memP = (stats.mem.used / stats.mem.total * 100).toFixed(0);
|
||||
},
|
||||
onStatsLog(statsLog) {
|
||||
statsLog.forEach(stats => this.onStats(stats));
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="stylus" scoped>
|
||||
root(isDark)
|
||||
margin-bottom 16px
|
||||
|
||||
> svg
|
||||
display block
|
||||
width 50%
|
||||
float left
|
||||
|
||||
&:first-child
|
||||
padding-right 5px
|
||||
|
||||
&:last-child
|
||||
padding-left 5px
|
||||
|
||||
> text
|
||||
font-size 2px
|
||||
fill isDark ? rgba(#fff, 0.55) : rgba(#000, 0.55)
|
||||
|
||||
> tspan
|
||||
opacity 0.5
|
||||
|
||||
&:after
|
||||
content ""
|
||||
display block
|
||||
clear both
|
||||
|
||||
.zyknedwtlthezamcjlolyusmipqmjgxz[data-darkmode]
|
||||
root(true)
|
||||
|
||||
.zyknedwtlthezamcjlolyusmipqmjgxz:not([data-darkmode])
|
||||
root(false)
|
||||
|
||||
</style>
|
|
@ -1,37 +1,80 @@
|
|||
<template>
|
||||
<div>
|
||||
<h1>%i18n:@dashboard%</h1>
|
||||
<div v-if="stats">
|
||||
<p><b>%i18n:@all-users%</b>: <span>{{ stats.usersCount | number }}</span></p>
|
||||
<p><b>%i18n:@original-users%</b>: <span>{{ stats.originalUsersCount | number }}</span></p>
|
||||
<p><b>%i18n:@all-notes%</b>: <span>{{ stats.notesCount | number }}</span></p>
|
||||
<p><b>%i18n:@original-notes%</b>: <span>{{ stats.originalNotesCount | number }}</span></p>
|
||||
<div class="obdskegsannmntldydackcpzezagxqfy card">
|
||||
<header>%i18n:@dashboard%</header>
|
||||
<div v-if="stats" class="stats">
|
||||
<div><b>%fa:user% {{ stats.originalUsersCount | number }}</b><span>%i18n:@original-users%</span></div>
|
||||
<div><span>%fa:user% {{ stats.usersCount | number }}</span><span>%i18n:@all-users%</span></div>
|
||||
<div><b>%fa:pen% {{ stats.originalNotesCount | number }}</b><span>%i18n:@original-notes%</span></div>
|
||||
<div><span>%fa:pen% {{ stats.notesCount | number }}</span><span>%i18n:@all-notes%</span></div>
|
||||
</div>
|
||||
<div class="cpu-memory">
|
||||
<x-cpu-memory :connection="connection"/>
|
||||
</div>
|
||||
<div>
|
||||
<button class="ui" @click="invite">%i18n:@invite%</button>
|
||||
<p v-if="inviteCode">Code: <code>{{ inviteCode }}</code></p>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import Vue from "vue";
|
||||
import XCpuMemory from "./admin.cpu-memory.vue";
|
||||
|
||||
export default Vue.extend({
|
||||
components: {
|
||||
XCpuMemory
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
stats: null
|
||||
stats: null,
|
||||
inviteCode: null,
|
||||
connection: null,
|
||||
connectionId: null
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.connection = (this as any).os.streams.serverStatsStream.getConnection();
|
||||
this.connectionId = (this as any).os.streams.serverStatsStream.use();
|
||||
|
||||
(this as any).api('stats').then(stats => {
|
||||
this.stats = stats;
|
||||
});
|
||||
},
|
||||
beforeDestroy() {
|
||||
(this as any).os.streams.serverStatsStream.dispose(this.connectionId);
|
||||
},
|
||||
methods: {
|
||||
invite() {
|
||||
(this as any).api('admin/invite').then(x => {
|
||||
this.inviteCode = x.code;
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="stylus" scoped>
|
||||
h1
|
||||
margin 0 0 1em 0
|
||||
padding 0 0 8px 0
|
||||
font-size 1em
|
||||
color #555
|
||||
border-bottom solid 1px #eee
|
||||
@import '~const.styl'
|
||||
|
||||
.obdskegsannmntldydackcpzezagxqfy
|
||||
> .stats
|
||||
display flex
|
||||
justify-content center
|
||||
margin-bottom 16px
|
||||
padding 16px
|
||||
border solid 1px #eee
|
||||
border-radius 8px
|
||||
|
||||
> div
|
||||
flex 1
|
||||
text-align center
|
||||
|
||||
> *:first-child
|
||||
display block
|
||||
color $theme-color
|
||||
|
||||
> *:last-child
|
||||
font-size 70%
|
||||
|
||||
</style>
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
<template>
|
||||
<svg :viewBox="`0 0 ${ viewBoxX } ${ viewBoxY }`">
|
||||
<polyline
|
||||
:points="points"
|
||||
fill="none"
|
||||
stroke-width="1"
|
||||
stroke="#555"/>
|
||||
</svg>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import Vue from 'vue';
|
||||
|
||||
export default Vue.extend({
|
||||
props: {
|
||||
chart: {
|
||||
required: true
|
||||
},
|
||||
type: {
|
||||
type: String,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
viewBoxX: 365,
|
||||
viewBoxY: 70,
|
||||
points: null
|
||||
};
|
||||
},
|
||||
created() {
|
||||
const peak = Math.max.apply(null, this.chart.map(d => this.type == 'local' ? d.drive.local.totalSize : d.drive.remote.totalSize));
|
||||
|
||||
if (peak != 0) {
|
||||
const data = this.chart.slice().reverse().map(x => ({
|
||||
size: this.type == 'local' ? x.drive.local.totalSize : x.drive.remote.totalSize
|
||||
}));
|
||||
|
||||
this.points = data.map((d, i) => `${i},${(1 - (d.size / peak)) * this.viewBoxY}`).join(' ');
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="stylus" scoped>
|
||||
svg
|
||||
display block
|
||||
padding 10px
|
||||
width 100%
|
||||
|
||||
</style>
|
|
@ -0,0 +1,34 @@
|
|||
<template>
|
||||
<div class="card">
|
||||
<header>%i18n:@title%</header>
|
||||
<div class="card">
|
||||
<header>%i18n:@local%</header>
|
||||
<x-chart v-if="chart" :chart="chart" type="local"/>
|
||||
</div>
|
||||
<div class="card">
|
||||
<header>%i18n:@remote%</header>
|
||||
<x-chart v-if="chart" :chart="chart" type="remote"/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import Vue from "vue";
|
||||
import XChart from "./admin.drive-chart.chart.vue";
|
||||
|
||||
export default Vue.extend({
|
||||
components: {
|
||||
XChart
|
||||
},
|
||||
props: {
|
||||
chart: {
|
||||
required: true
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="stylus" scoped>
|
||||
@import '~const.styl'
|
||||
|
||||
</style>
|
|
@ -0,0 +1,76 @@
|
|||
<template>
|
||||
<svg :viewBox="`0 0 ${ viewBoxX } ${ viewBoxY }`">
|
||||
<polyline
|
||||
:points="pointsNote"
|
||||
fill="none"
|
||||
stroke-width="1"
|
||||
stroke="#41ddde"/>
|
||||
<polyline
|
||||
:points="pointsReply"
|
||||
fill="none"
|
||||
stroke-width="1"
|
||||
stroke="#f7796c"/>
|
||||
<polyline
|
||||
:points="pointsRenote"
|
||||
fill="none"
|
||||
stroke-width="1"
|
||||
stroke="#a1de41"/>
|
||||
<polyline
|
||||
:points="pointsTotal"
|
||||
fill="none"
|
||||
stroke-width="1"
|
||||
stroke="#555"
|
||||
stroke-dasharray="2 2"/>
|
||||
</svg>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import Vue from 'vue';
|
||||
|
||||
export default Vue.extend({
|
||||
props: {
|
||||
chart: {
|
||||
required: true
|
||||
},
|
||||
type: {
|
||||
type: String,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
viewBoxX: 365,
|
||||
viewBoxY: 70,
|
||||
pointsNote: null,
|
||||
pointsReply: null,
|
||||
pointsRenote: null,
|
||||
pointsTotal: null
|
||||
};
|
||||
},
|
||||
created() {
|
||||
const peak = Math.max.apply(null, this.chart.map(d => this.type == 'local' ? d.notes.local.diff : d.notes.remote.diff));
|
||||
|
||||
if (peak != 0) {
|
||||
const data = this.chart.slice().reverse().map(x => ({
|
||||
normal: this.type == 'local' ? x.notes.local.diffs.normal : x.notes.remote.diffs.normal,
|
||||
reply: this.type == 'local' ? x.notes.local.diffs.reply : x.notes.remote.diffs.reply,
|
||||
renote: this.type == 'local' ? x.notes.local.diffs.renote : x.notes.remote.diffs.renote,
|
||||
total: this.type == 'local' ? x.notes.local.diff : x.notes.remote.diff
|
||||
}));
|
||||
|
||||
this.pointsNote = data.map((d, i) => `${i},${(1 - (d.normal / peak)) * this.viewBoxY}`).join(' ');
|
||||
this.pointsReply = data.map((d, i) => `${i},${(1 - (d.reply / peak)) * this.viewBoxY}`).join(' ');
|
||||
this.pointsRenote = data.map((d, i) => `${i},${(1 - (d.renote / peak)) * this.viewBoxY}`).join(' ');
|
||||
this.pointsTotal = data.map((d, i) => `${i},${(1 - (d.total / peak)) * this.viewBoxY}`).join(' ');
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="stylus" scoped>
|
||||
svg
|
||||
display block
|
||||
padding 10px
|
||||
width 100%
|
||||
|
||||
</style>
|
|
@ -0,0 +1,34 @@
|
|||
<template>
|
||||
<div class="card">
|
||||
<header>%i18n:@title%</header>
|
||||
<div class="card">
|
||||
<header>%i18n:@local%</header>
|
||||
<x-chart v-if="chart" :chart="chart" type="local"/>
|
||||
</div>
|
||||
<div class="card">
|
||||
<header>%i18n:@remote%</header>
|
||||
<x-chart v-if="chart" :chart="chart" type="remote"/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import Vue from "vue";
|
||||
import XChart from "./admin.notes-chart.chart.vue";
|
||||
|
||||
export default Vue.extend({
|
||||
components: {
|
||||
XChart
|
||||
},
|
||||
props: {
|
||||
chart: {
|
||||
required: true
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="stylus" scoped>
|
||||
@import '~const.styl'
|
||||
|
||||
</style>
|
|
@ -1,5 +1,5 @@
|
|||
<template>
|
||||
<div>
|
||||
<div class="card">
|
||||
<header>%i18n:@suspend-user%</header>
|
||||
<input v-model="username" type="text" class="ui"/>
|
||||
<button class="ui" @click="suspendUser" :disabled="suspending">%i18n:@suspend%</button>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<template>
|
||||
<div>
|
||||
<div class="card">
|
||||
<header>%i18n:@unsuspend-user%</header>
|
||||
<input v-model="username" type="text" class="ui"/>
|
||||
<button class="ui" @click="unsuspendUser" :disabled="unsuspending">%i18n:@unsuspend%</button>
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
<template>
|
||||
<div class="card">
|
||||
<header>%i18n:@unverify-user%</header>
|
||||
<input v-model="username" type="text" class="ui"/>
|
||||
<button class="ui" @click="unverifyUser" :disabled="unverifying">%i18n:@unverify%</button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import Vue from "vue";
|
||||
import parseAcct from "../../../../../../misc/acct/parse";
|
||||
|
||||
export default Vue.extend({
|
||||
data() {
|
||||
return {
|
||||
username: null,
|
||||
unverifying: false
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
async unverifyUser() {
|
||||
this.unverifying = true;
|
||||
|
||||
const user = await (this as any).os.api(
|
||||
"users/show",
|
||||
parseAcct(this.username)
|
||||
);
|
||||
|
||||
await (this as any).os.api("admin/unverify-user", {
|
||||
userId: user.id
|
||||
});
|
||||
|
||||
this.unverifying = false;
|
||||
|
||||
(this as any).os.apis.dialog({ text: "%i18n:@unverified%" });
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="stylus" scoped>
|
||||
@import '~const.styl'
|
||||
|
||||
header
|
||||
margin 10px 0
|
||||
|
||||
|
||||
button
|
||||
margin 16px 0
|
||||
|
||||
</style>
|
|
@ -0,0 +1,51 @@
|
|||
<template>
|
||||
<svg :viewBox="`0 0 ${ viewBoxX } ${ viewBoxY }`">
|
||||
<polyline
|
||||
:points="points"
|
||||
fill="none"
|
||||
stroke-width="1"
|
||||
stroke="#555"/>
|
||||
</svg>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import Vue from 'vue';
|
||||
|
||||
export default Vue.extend({
|
||||
props: {
|
||||
chart: {
|
||||
required: true
|
||||
},
|
||||
type: {
|
||||
type: String,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
viewBoxX: 365,
|
||||
viewBoxY: 70,
|
||||
points: null
|
||||
};
|
||||
},
|
||||
created() {
|
||||
const peak = Math.max.apply(null, this.chart.map(d => this.type == 'local' ? d.users.local.diff : d.users.remote.diff));
|
||||
|
||||
if (peak != 0) {
|
||||
const data = this.chart.slice().reverse().map(x => ({
|
||||
count: this.type == 'local' ? x.users.local.diff : x.users.remote.diff
|
||||
}));
|
||||
|
||||
this.points = data.map((d, i) => `${i},${(1 - (d.count / peak)) * this.viewBoxY}`).join(' ');
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="stylus" scoped>
|
||||
svg
|
||||
display block
|
||||
padding 10px
|
||||
width 100%
|
||||
|
||||
</style>
|
|
@ -0,0 +1,34 @@
|
|||
<template>
|
||||
<div class="card">
|
||||
<header>%i18n:@title%</header>
|
||||
<div class="card">
|
||||
<header>%i18n:@local%</header>
|
||||
<x-chart v-if="chart" :chart="chart" type="local"/>
|
||||
</div>
|
||||
<div class="card">
|
||||
<header>%i18n:@remote%</header>
|
||||
<x-chart v-if="chart" :chart="chart" type="remote"/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import Vue from "vue";
|
||||
import XChart from "./admin.users-chart.chart.vue";
|
||||
|
||||
export default Vue.extend({
|
||||
components: {
|
||||
XChart
|
||||
},
|
||||
props: {
|
||||
chart: {
|
||||
required: true
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="stylus" scoped>
|
||||
@import '~const.styl'
|
||||
|
||||
</style>
|
|
@ -0,0 +1,51 @@
|
|||
<template>
|
||||
<div class="card">
|
||||
<header>%i18n:@verify-user%</header>
|
||||
<input v-model="username" type="text" class="ui"/>
|
||||
<button class="ui" @click="verifyUser" :disabled="verifying">%i18n:@verify%</button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import Vue from "vue";
|
||||
import parseAcct from "../../../../../../misc/acct/parse";
|
||||
|
||||
export default Vue.extend({
|
||||
data() {
|
||||
return {
|
||||
username: null,
|
||||
verifying: false
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
async verifyUser() {
|
||||
this.verifying = true;
|
||||
|
||||
const user = await (this as any).os.api(
|
||||
"users/show",
|
||||
parseAcct(this.username)
|
||||
);
|
||||
|
||||
await (this as any).os.api("admin/verify-user", {
|
||||
userId: user.id
|
||||
});
|
||||
|
||||
this.verifying = false;
|
||||
|
||||
(this as any).os.apis.dialog({ text: "%i18n:@verified%" });
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="stylus" scoped>
|
||||
@import '~const.styl'
|
||||
|
||||
header
|
||||
margin 10px 0
|
||||
|
||||
|
||||
button
|
||||
margin 16px 0
|
||||
|
||||
</style>
|
|
@ -9,12 +9,17 @@
|
|||
</ul>
|
||||
</nav>
|
||||
<main>
|
||||
<div v-if="page == 'dashboard'">
|
||||
<div v-show="page == 'dashboard'">
|
||||
<x-dashboard/>
|
||||
<x-users-chart :chart="chart"/>
|
||||
<x-notes-chart :chart="chart"/>
|
||||
<x-drive-chart :chart="chart"/>
|
||||
</div>
|
||||
<div v-if="page == 'users'">
|
||||
<x-suspend-user/>
|
||||
<x-unsuspend-user/>
|
||||
<x-verify-user/>
|
||||
<x-unverify-user/>
|
||||
</div>
|
||||
<div v-if="page == 'drive'"></div>
|
||||
<div v-if="page == 'update'"></div>
|
||||
|
@ -27,18 +32,34 @@ import Vue from "vue";
|
|||
import XDashboard from "./admin.dashboard.vue";
|
||||
import XSuspendUser from "./admin.suspend-user.vue";
|
||||
import XUnsuspendUser from "./admin.unsuspend-user.vue";
|
||||
import XVerifyUser from "./admin.verify-user.vue";
|
||||
import XUnverifyUser from "./admin.unverify-user.vue";
|
||||
import XUsersChart from "./admin.users-chart.vue";
|
||||
import XNotesChart from "./admin.notes-chart.vue";
|
||||
import XDriveChart from "./admin.drive-chart.vue";
|
||||
|
||||
export default Vue.extend({
|
||||
components: {
|
||||
XDashboard,
|
||||
XSuspendUser,
|
||||
XUnsuspendUser
|
||||
XUnsuspendUser,
|
||||
XVerifyUser,
|
||||
XUnverifyUser,
|
||||
XUsersChart,
|
||||
XNotesChart,
|
||||
XDriveChart
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
page: 'dashboard'
|
||||
page: 'dashboard',
|
||||
chart: null
|
||||
};
|
||||
},
|
||||
created() {
|
||||
(this as any).api('admin/chart').then(chart => {
|
||||
this.chart = chart;
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
nav(page: string) {
|
||||
this.page = page;
|
||||
|
@ -47,7 +68,7 @@ export default Vue.extend({
|
|||
});
|
||||
</script>
|
||||
|
||||
<style lang="stylus" scoped>
|
||||
<style lang="stylus">
|
||||
@import '~const.styl'
|
||||
|
||||
.mk-admin
|
||||
|
@ -90,13 +111,23 @@ export default Vue.extend({
|
|||
width 100%
|
||||
padding 16px 32px
|
||||
|
||||
header
|
||||
margin 10px 0
|
||||
> div
|
||||
> div
|
||||
max-width 800px
|
||||
|
||||
.card
|
||||
padding 32px
|
||||
background #fff
|
||||
box-shadow 0 2px 8px rgba(#000, 0.1)
|
||||
|
||||
button
|
||||
margin 16px 0
|
||||
position absolute
|
||||
right 0
|
||||
&:not(:last-child)
|
||||
margin-bottom 16px
|
||||
|
||||
> header
|
||||
margin 0 0 1em 0
|
||||
padding 0 0 8px 0
|
||||
font-size 1em
|
||||
color #555
|
||||
border-bottom solid 1px #eee
|
||||
|
||||
</style>
|
||||
|
|
|
@ -95,7 +95,7 @@ export default Vue.extend({
|
|||
callbackUrl: this.cb,
|
||||
permission: this.permission
|
||||
}).then(() => {
|
||||
location.href = '/apps';
|
||||
location.href = '/dev/apps';
|
||||
}).catch(() => {
|
||||
alert('アプリの作成に失敗しました。再度お試しください。');
|
||||
});
|
||||
|
|
|
@ -56,7 +56,7 @@ import Vue from 'vue';
|
|||
import insertTextAtCursor from 'insert-text-at-cursor';
|
||||
import * as XDraggable from 'vuedraggable';
|
||||
import MkVisibilityChooser from '../../../common/views/components/visibility-chooser.vue';
|
||||
import getKao from '../../../common/scripts/get-kao';
|
||||
import getFace from '../../../common/scripts/get-face';
|
||||
import parse from '../../../../../mfm/parse';
|
||||
import { host } from '../../../config';
|
||||
|
||||
|
@ -94,7 +94,7 @@ export default Vue.extend({
|
|||
files: [],
|
||||
poll: false,
|
||||
geo: null,
|
||||
visibility: 'public',
|
||||
visibility: this.$store.state.device.visibility || 'public',
|
||||
visibleUsers: [],
|
||||
useCw: false,
|
||||
cw: null,
|
||||
|
@ -240,8 +240,7 @@ export default Vue.extend({
|
|||
setVisibility() {
|
||||
const w = (this as any).os.new(MkVisibilityChooser, {
|
||||
source: this.$refs.visibilityButton,
|
||||
compact: true,
|
||||
v: this.visibility
|
||||
compact: true
|
||||
});
|
||||
w.$once('chosen', v => {
|
||||
this.visibility = v;
|
||||
|
@ -314,7 +313,7 @@ export default Vue.extend({
|
|||
},
|
||||
|
||||
kao() {
|
||||
this.text += getKao();
|
||||
this.text += getFace();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
@import "../app"
|
||||
@import "../reset"
|
||||
|
||||
html
|
||||
color #456267
|
||||
background #fff
|
||||
|
||||
body
|
||||
margin 0
|
||||
padding 0
|
|
@ -1,209 +0,0 @@
|
|||
<mk-index>
|
||||
<h1>Misskey<i>Statistics</i></h1>
|
||||
<main v-if="!initializing">
|
||||
<mk-users stats={ stats }/>
|
||||
<mk-notes stats={ stats }/>
|
||||
</main>
|
||||
<footer><a href={ _URL_ }>{ _HOST_ }</a></footer>
|
||||
<style lang="stylus" scoped>
|
||||
:scope
|
||||
display block
|
||||
margin 0 auto
|
||||
padding 0 16px
|
||||
max-width 700px
|
||||
|
||||
> h1
|
||||
margin 0
|
||||
padding 24px 0 0 0
|
||||
font-size 24px
|
||||
font-weight normal
|
||||
|
||||
> i
|
||||
font-style normal
|
||||
color #f43b16
|
||||
|
||||
> main
|
||||
> *
|
||||
margin 24px 0
|
||||
padding-top 24px
|
||||
border-top solid 1px #eee
|
||||
|
||||
> h2
|
||||
margin 0 0 12px 0
|
||||
font-size 18px
|
||||
font-weight normal
|
||||
|
||||
> footer
|
||||
margin 24px 0
|
||||
text-align center
|
||||
|
||||
> a
|
||||
color #546567
|
||||
</style>
|
||||
<script lang="typescript">
|
||||
this.mixin('api');
|
||||
|
||||
this.initializing = true;
|
||||
|
||||
this.on('mount', () => {
|
||||
this.$root.$data.os.api('stats').then(stats => {
|
||||
this.update({
|
||||
initializing: false,
|
||||
stats
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</mk-index>
|
||||
|
||||
<mk-notes>
|
||||
<h2>%i18n:stats.notes-count% <b>{ stats.notesCount }</b></h2>
|
||||
<mk-notes-chart v-if="!initializing" data={ data }/>
|
||||
<style lang="stylus" scoped>
|
||||
:scope
|
||||
display block
|
||||
</style>
|
||||
<script lang="typescript">
|
||||
this.mixin('api');
|
||||
|
||||
this.initializing = true;
|
||||
this.stats = this.opts.stats;
|
||||
|
||||
this.on('mount', () => {
|
||||
this.$root.$data.os.api('aggregation/notes', {
|
||||
limit: 365
|
||||
}).then(data => {
|
||||
this.update({
|
||||
initializing: false,
|
||||
data
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</mk-notes>
|
||||
|
||||
<mk-users>
|
||||
<h2>%i18n:stats.users-count% <b>{ stats.usersCount }</b></h2>
|
||||
<mk-users-chart v-if="!initializing" data={ data }/>
|
||||
<style lang="stylus" scoped>
|
||||
:scope
|
||||
display block
|
||||
</style>
|
||||
<script lang="typescript">
|
||||
this.mixin('api');
|
||||
|
||||
this.initializing = true;
|
||||
this.stats = this.opts.stats;
|
||||
|
||||
this.on('mount', () => {
|
||||
this.$root.$data.os.api('aggregation/users', {
|
||||
limit: 365
|
||||
}).then(data => {
|
||||
this.update({
|
||||
initializing: false,
|
||||
data
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</mk-users>
|
||||
|
||||
<mk-notes-chart>
|
||||
<svg riot-viewBox="0 0 { viewBoxX } { viewBoxY }" preserveAspectRatio="none">
|
||||
<title>Black ... Total<br/>Blue ... Notes<br/>Red ... Replies<br/>Green ... Renotes</title>
|
||||
<polyline
|
||||
riot-points={ pointsNote }
|
||||
fill="none"
|
||||
stroke-width="1"
|
||||
stroke="#41ddde"/>
|
||||
<polyline
|
||||
riot-points={ pointsReply }
|
||||
fill="none"
|
||||
stroke-width="1"
|
||||
stroke="#f7796c"/>
|
||||
<polyline
|
||||
riot-points={ pointsRenote }
|
||||
fill="none"
|
||||
stroke-width="1"
|
||||
stroke="#a1de41"/>
|
||||
<polyline
|
||||
riot-points={ pointsTotal }
|
||||
fill="none"
|
||||
stroke-width="1"
|
||||
stroke="#555"
|
||||
stroke-dasharray="2 2"/>
|
||||
</svg>
|
||||
<style lang="stylus" scoped>
|
||||
:scope
|
||||
display block
|
||||
|
||||
> svg
|
||||
display block
|
||||
padding 1px
|
||||
width 100%
|
||||
</style>
|
||||
<script lang="typescript">
|
||||
this.viewBoxX = 365;
|
||||
this.viewBoxY = 80;
|
||||
|
||||
this.data = this.opts.data.reverse();
|
||||
this.data.forEach(d => d.total = d.notes + d.replies + d.renotes);
|
||||
const peak = Math.max.apply(null, this.data.map(d => d.total));
|
||||
|
||||
this.on('mount', () => {
|
||||
this.render();
|
||||
});
|
||||
|
||||
this.render = () => {
|
||||
this.update({
|
||||
pointsNote: this.data.map((d, i) => `${i},${(1 - (d.notes / peak)) * this.viewBoxY}`).join(' '),
|
||||
pointsReply: this.data.map((d, i) => `${i},${(1 - (d.replies / peak)) * this.viewBoxY}`).join(' '),
|
||||
pointsRenote: this.data.map((d, i) => `${i},${(1 - (d.renotes / peak)) * this.viewBoxY}`).join(' '),
|
||||
pointsTotal: this.data.map((d, i) => `${i},${(1 - (d.total / peak)) * this.viewBoxY}`).join(' ')
|
||||
});
|
||||
};
|
||||
</script>
|
||||
</mk-notes-chart>
|
||||
|
||||
<mk-users-chart>
|
||||
<svg riot-viewBox="0 0 { viewBoxX } { viewBoxY }" preserveAspectRatio="none">
|
||||
<polyline
|
||||
riot-points={ createdPoints }
|
||||
fill="none"
|
||||
stroke-width="1"
|
||||
stroke="#1cde84"/>
|
||||
<polyline
|
||||
riot-points={ totalPoints }
|
||||
fill="none"
|
||||
stroke-width="1"
|
||||
stroke="#555"/>
|
||||
</svg>
|
||||
<style lang="stylus" scoped>
|
||||
:scope
|
||||
display block
|
||||
|
||||
> svg
|
||||
display block
|
||||
padding 1px
|
||||
width 100%
|
||||
</style>
|
||||
<script lang="typescript">
|
||||
this.viewBoxX = 365;
|
||||
this.viewBoxY = 80;
|
||||
|
||||
this.data = this.opts.data.reverse();
|
||||
const totalPeak = Math.max.apply(null, this.data.map(d => d.total));
|
||||
const createdPeak = Math.max.apply(null, this.data.map(d => d.created));
|
||||
|
||||
this.on('mount', () => {
|
||||
this.render();
|
||||
});
|
||||
|
||||
this.render = () => {
|
||||
this.update({
|
||||
totalPoints: this.data.map((d, i) => `${i},${(1 - (d.total / totalPeak)) * this.viewBoxY}`).join(' '),
|
||||
createdPoints: this.data.map((d, i) => `${i},${(1 - (d.created / createdPeak)) * this.viewBoxY}`).join(' ')
|
||||
});
|
||||
};
|
||||
</script>
|
||||
</mk-users-chart>
|
|
@ -1 +0,0 @@
|
|||
require('./index.tag');
|
|
@ -1,10 +0,0 @@
|
|||
@import "../app"
|
||||
@import "../reset"
|
||||
|
||||
html
|
||||
color #456267
|
||||
background #fff
|
||||
|
||||
body
|
||||
margin 0
|
||||
padding 0
|
|
@ -1,201 +0,0 @@
|
|||
<mk-index>
|
||||
<h1>Misskey<i>Status</i></h1>
|
||||
<p>%fa:info-circle%%i18n:status.all-systems-maybe-operational%</p>
|
||||
<main>
|
||||
<mk-cpu-usage connection={ connection }/>
|
||||
<mk-mem-usage connection={ connection }/>
|
||||
</main>
|
||||
<footer><a href={ _URL_ }>{ _HOST_ }</a></footer>
|
||||
<style lang="stylus" scoped>
|
||||
:scope
|
||||
display block
|
||||
margin 0 auto
|
||||
padding 0 16px
|
||||
max-width 700px
|
||||
|
||||
> h1
|
||||
margin 0
|
||||
padding 24px 0 16px 0
|
||||
font-size 24px
|
||||
font-weight normal
|
||||
|
||||
> [data-fa]
|
||||
font-style normal
|
||||
color #f43b16
|
||||
|
||||
> p
|
||||
display block
|
||||
margin 0
|
||||
padding 12px 16px
|
||||
background #eaf4ef
|
||||
//border solid 1px #99ccb2
|
||||
border-radius 4px
|
||||
|
||||
> [data-fa]
|
||||
margin-right 5px
|
||||
|
||||
> main
|
||||
> *
|
||||
margin 24px 0
|
||||
|
||||
> h2
|
||||
margin 0 0 12px 0
|
||||
font-size 18px
|
||||
font-weight normal
|
||||
|
||||
> footer
|
||||
margin 24px 0
|
||||
text-align center
|
||||
|
||||
> a
|
||||
color #546567
|
||||
</style>
|
||||
<script lang="typescript">
|
||||
import Connection from '../../common/scripts/streaming/server-stream';
|
||||
|
||||
this.mixin('api');
|
||||
|
||||
this.initializing = true;
|
||||
this.connection = new Connection();
|
||||
|
||||
this.on('mount', () => {
|
||||
this.$root.$data.os.api('meta').then(meta => {
|
||||
this.update({
|
||||
initializing: false,
|
||||
meta
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
this.on('unmount', () => {
|
||||
this.connection.close();
|
||||
});
|
||||
|
||||
</script>
|
||||
</mk-index>
|
||||
|
||||
<mk-cpu-usage>
|
||||
<h2>CPU <b>{ percentage }%</b></h2>
|
||||
<mk-line-chart ref="chart"/>
|
||||
<style lang="stylus" scoped>
|
||||
:scope
|
||||
display block
|
||||
</style>
|
||||
<script lang="typescript">
|
||||
this.connection = this.opts.connection;
|
||||
|
||||
this.on('mount', () => {
|
||||
this.connection.on('stats', this.onStats);
|
||||
});
|
||||
|
||||
this.on('unmount', () => {
|
||||
this.connection.off('stats', this.onStats);
|
||||
});
|
||||
|
||||
this.onStats = stats => {
|
||||
this.$refs.chart.addData(1 - stats.cpu_usage);
|
||||
|
||||
const percentage = (stats.cpu_usage * 100).toFixed(0);
|
||||
|
||||
this.update({
|
||||
percentage
|
||||
});
|
||||
};
|
||||
</script>
|
||||
</mk-cpu-usage>
|
||||
|
||||
<mk-mem-usage>
|
||||
<h2>MEM <b>{ percentage }%</b></h2>
|
||||
<mk-line-chart ref="chart"/>
|
||||
<style lang="stylus" scoped>
|
||||
:scope
|
||||
display block
|
||||
</style>
|
||||
<script lang="typescript">
|
||||
this.connection = this.opts.connection;
|
||||
|
||||
this.on('mount', () => {
|
||||
this.connection.on('stats', this.onStats);
|
||||
});
|
||||
|
||||
this.on('unmount', () => {
|
||||
this.connection.off('stats', this.onStats);
|
||||
});
|
||||
|
||||
this.onStats = stats => {
|
||||
stats.mem.used = stats.mem.total - stats.mem.free;
|
||||
this.$refs.chart.addData(1 - (stats.mem.used / stats.mem.total));
|
||||
|
||||
const percentage = (stats.mem.used / stats.mem.total * 100).toFixed(0);
|
||||
|
||||
this.update({
|
||||
percentage
|
||||
});
|
||||
};
|
||||
</script>
|
||||
</mk-mem-usage>
|
||||
|
||||
<mk-line-chart>
|
||||
<svg riot-viewBox="0 0 { viewBoxX } { viewBoxY }" preserveAspectRatio="none">
|
||||
<defs>
|
||||
<linearGradient id={ gradientId } x1="0" x2="0" y1="1" y2="0">
|
||||
<stop offset="0%" stop-color="rgba(244, 59, 22, 0)"></stop>
|
||||
<stop offset="100%" stop-color="#f43b16"></stop>
|
||||
</linearGradient>
|
||||
<mask id={ maskId } x="0" y="0" riot-width={ viewBoxX } riot-height={ viewBoxY }>
|
||||
<polygon
|
||||
riot-points={ polygonPoints }
|
||||
fill="#fff"
|
||||
fill-opacity="0.5"/>
|
||||
</mask>
|
||||
</defs>
|
||||
<line x1="0" y1="0" riot-x2={ viewBoxX } y2="0" stroke="rgba(255, 255, 255, 0.1)" stroke-width="0.25" stroke-dasharray="1"/>
|
||||
<line x1="0" y1="25%" riot-x2={ viewBoxX } y2="25%" stroke="rgba(255, 255, 255, 0.1)" stroke-width="0.25" stroke-dasharray="1"/>
|
||||
<line x1="0" y1="50%" riot-x2={ viewBoxX } y2="50%" stroke="rgba(255, 255, 255, 0.1)" stroke-width="0.25" stroke-dasharray="1"/>
|
||||
<line x1="0" y1="75%" riot-x2={ viewBoxX } y2="75%" stroke="rgba(255, 255, 255, 0.1)" stroke-width="0.25" stroke-dasharray="1"/>
|
||||
<line x1="0" y1="100%" riot-x2={ viewBoxX } y2="100%" stroke="rgba(255, 255, 255, 0.1)" stroke-width="0.25" stroke-dasharray="1"/>
|
||||
<rect
|
||||
x="-1" y="-1"
|
||||
riot-width={ viewBoxX + 2 } riot-height={ viewBoxY + 2 }
|
||||
style="stroke: none; fill: url(#{ gradientId }); mask: url(#{ maskId })"/>
|
||||
<polyline
|
||||
riot-points={ polylinePoints }
|
||||
fill="none"
|
||||
stroke="#f43b16"
|
||||
stroke-width="0.5"/>
|
||||
</svg>
|
||||
<style lang="stylus" scoped>
|
||||
:scope
|
||||
display block
|
||||
padding 16px
|
||||
border-radius 8px
|
||||
background #1c2531
|
||||
|
||||
> svg
|
||||
display block
|
||||
padding 1px
|
||||
width 100%
|
||||
</style>
|
||||
<script lang="typescript">
|
||||
import uuid from 'uuid';
|
||||
|
||||
this.viewBoxX = 100;
|
||||
this.viewBoxY = 30;
|
||||
this.data = [];
|
||||
this.gradientId = uuid();
|
||||
this.maskId = uuid();
|
||||
|
||||
this.addData = data => {
|
||||
this.data.push(data);
|
||||
if (this.data.length > 100) this.data.shift();
|
||||
|
||||
const polylinePoints = this.data.map((d, i) => `${this.viewBoxX - ((this.data.length - 1) - i)},${d * this.viewBoxY}`).join(' ');
|
||||
const polygonPoints = `${this.viewBoxX - (this.data.length - 1)},${ this.viewBoxY } ${ polylinePoints } ${ this.viewBoxX },${ this.viewBoxY }`;
|
||||
|
||||
this.update({
|
||||
polylinePoints,
|
||||
polygonPoints
|
||||
});
|
||||
};
|
||||
</script>
|
||||
</mk-line-chart>
|
|
@ -1 +0,0 @@
|
|||
require('./index.tag');
|
|
@ -110,6 +110,10 @@ export default (os: MiOS) => new Vuex.Store({
|
|||
src: x.src,
|
||||
arg: x.arg
|
||||
};
|
||||
},
|
||||
|
||||
setVisibility(state, visibility) {
|
||||
state.visibility = visibility;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -49,6 +49,9 @@ export default function(html: string): string {
|
|||
text += txt;
|
||||
break;
|
||||
}
|
||||
// メンション以外
|
||||
} else {
|
||||
text += `[${txt}](${node.attrs.find((x: any) => x.name == 'href').value})`;
|
||||
}
|
||||
|
||||
if (node.childNodes) {
|
||||
|
|
|
@ -5,6 +5,10 @@ import config from '../config';
|
|||
import { INote } from '../models/note';
|
||||
import { TextElement } from './parse';
|
||||
|
||||
function intersperse<T>(sep: T, xs: T[]): T[] {
|
||||
return [].concat(...xs.map(x => [sep, x])).slice(1);
|
||||
}
|
||||
|
||||
const handlers: { [key: string]: (window: any, token: any, mentionedRemoteUsers: INote['mentionedRemoteUsers']) => void } = {
|
||||
bold({ document }, { bold }) {
|
||||
const b = document.createElement('b');
|
||||
|
@ -80,12 +84,9 @@ const handlers: { [key: string]: (window: any, token: any, mentionedRemoteUsers:
|
|||
},
|
||||
|
||||
text({ document }, { content }) {
|
||||
for (const text of content.split('\n')) {
|
||||
const node = document.createTextNode(text);
|
||||
document.body.appendChild(node);
|
||||
|
||||
const br = document.createElement('br');
|
||||
document.body.appendChild(br);
|
||||
const nodes = (content as string).split('\n').map(x => document.createTextNode(x));
|
||||
for (const x of intersperse(document.createElement('br'), nodes)) {
|
||||
document.body.appendChild(x);
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -52,6 +52,11 @@ export type IDriveFile = {
|
|||
filename: string;
|
||||
contentType: string;
|
||||
metadata: IMetadata;
|
||||
|
||||
/**
|
||||
* ファイルサイズ
|
||||
*/
|
||||
length: number;
|
||||
};
|
||||
|
||||
export function validateFileName(name: string): boolean {
|
||||
|
|
|
@ -11,4 +11,5 @@ export type IMeta = {
|
|||
usersCount: number;
|
||||
originalUsersCount: number;
|
||||
};
|
||||
disableRegistration: boolean;
|
||||
};
|
||||
|
|
12
src/models/registration-tickets.ts
Normal file
12
src/models/registration-tickets.ts
Normal file
|
@ -0,0 +1,12 @@
|
|||
import * as mongo from 'mongodb';
|
||||
import db from '../db/mongodb';
|
||||
|
||||
const RegistrationTicket = db.get<IRegistrationTicket>('registrationTickets');
|
||||
RegistrationTicket.createIndex('code', { unique: true });
|
||||
export default RegistrationTicket;
|
||||
|
||||
export interface IRegistrationTicket {
|
||||
_id: mongo.ObjectID;
|
||||
createdAt: Date;
|
||||
code: string;
|
||||
}
|
153
src/models/stats.ts
Normal file
153
src/models/stats.ts
Normal file
|
@ -0,0 +1,153 @@
|
|||
import * as mongo from 'mongodb';
|
||||
import db from '../db/mongodb';
|
||||
|
||||
const Stats = db.get<IStats>('stats');
|
||||
Stats.createIndex({ date: -1 }, { unique: true });
|
||||
export default Stats;
|
||||
|
||||
export interface IStats {
|
||||
_id: mongo.ObjectID;
|
||||
|
||||
date: Date;
|
||||
|
||||
/**
|
||||
* ユーザーに関する統計
|
||||
*/
|
||||
users: {
|
||||
local: {
|
||||
/**
|
||||
* この日時点での、ローカルのユーザーの総計
|
||||
*/
|
||||
total: number;
|
||||
|
||||
/**
|
||||
* ローカルのユーザー数の前日比
|
||||
*/
|
||||
diff: number;
|
||||
};
|
||||
|
||||
remote: {
|
||||
/**
|
||||
* この日時点での、リモートのユーザーの総計
|
||||
*/
|
||||
total: number;
|
||||
|
||||
/**
|
||||
* リモートのユーザー数の前日比
|
||||
*/
|
||||
diff: number;
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* 投稿に関する統計
|
||||
*/
|
||||
notes: {
|
||||
local: {
|
||||
/**
|
||||
* この日時点での、ローカルの投稿の総計
|
||||
*/
|
||||
total: number;
|
||||
|
||||
/**
|
||||
* ローカルの投稿数の前日比
|
||||
*/
|
||||
diff: number;
|
||||
|
||||
diffs: {
|
||||
/**
|
||||
* ローカルの通常の投稿数の前日比
|
||||
*/
|
||||
normal: number;
|
||||
|
||||
/**
|
||||
* ローカルのリプライの投稿数の前日比
|
||||
*/
|
||||
reply: number;
|
||||
|
||||
/**
|
||||
* ローカルのRenoteの投稿数の前日比
|
||||
*/
|
||||
renote: number;
|
||||
};
|
||||
};
|
||||
|
||||
remote: {
|
||||
/**
|
||||
* この日時点での、リモートの投稿の総計
|
||||
*/
|
||||
total: number;
|
||||
|
||||
/**
|
||||
* リモートの投稿数の前日比
|
||||
*/
|
||||
diff: number;
|
||||
|
||||
diffs: {
|
||||
/**
|
||||
* リモートの通常の投稿数の前日比
|
||||
*/
|
||||
normal: number;
|
||||
|
||||
/**
|
||||
* リモートのリプライの投稿数の前日比
|
||||
*/
|
||||
reply: number;
|
||||
|
||||
/**
|
||||
* リモートのRenoteの投稿数の前日比
|
||||
*/
|
||||
renote: number;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* ドライブ(のファイル)に関する統計
|
||||
*/
|
||||
drive: {
|
||||
local: {
|
||||
/**
|
||||
* この日時点での、ローカルのドライブファイル数の総計
|
||||
*/
|
||||
totalCount: number;
|
||||
|
||||
/**
|
||||
* この日時点での、ローカルのドライブファイルサイズの総計
|
||||
*/
|
||||
totalSize: number;
|
||||
|
||||
/**
|
||||
* ローカルのドライブファイル数の前日比
|
||||
*/
|
||||
diffCount: number;
|
||||
|
||||
/**
|
||||
* ローカルのドライブファイルサイズの前日比
|
||||
*/
|
||||
diffSize: number;
|
||||
};
|
||||
|
||||
remote: {
|
||||
/**
|
||||
* この日時点での、リモートのドライブファイル数の総計
|
||||
*/
|
||||
totalCount: number;
|
||||
|
||||
/**
|
||||
* この日時点での、リモートのドライブファイルサイズの総計
|
||||
*/
|
||||
totalSize: number;
|
||||
|
||||
/**
|
||||
* リモートのドライブファイル数の前日比
|
||||
*/
|
||||
diffCount: number;
|
||||
|
||||
/**
|
||||
* リモートのドライブファイルサイズの前日比
|
||||
*/
|
||||
diffSize: number;
|
||||
};
|
||||
};
|
||||
}
|
101
src/server/api/endpoints/admin/chart.ts
Normal file
101
src/server/api/endpoints/admin/chart.ts
Normal file
|
@ -0,0 +1,101 @@
|
|||
import Stats, { IStats } from '../../../../models/stats';
|
||||
|
||||
type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
|
||||
|
||||
export const meta = {
|
||||
requireCredential: true,
|
||||
requireAdmin: true
|
||||
};
|
||||
|
||||
export default (params: any) => new Promise(async (res, rej) => {
|
||||
const now = new Date();
|
||||
const y = now.getFullYear();
|
||||
const m = now.getMonth();
|
||||
const d = now.getDate();
|
||||
|
||||
const stats = await Stats.find({
|
||||
date: {
|
||||
$gt: new Date(y - 1, m, d)
|
||||
}
|
||||
}, {
|
||||
sort: {
|
||||
date: -1
|
||||
},
|
||||
fields: {
|
||||
_id: 0
|
||||
}
|
||||
});
|
||||
|
||||
const chart: Array<Omit<IStats, '_id'>> = [];
|
||||
|
||||
for (let i = 364; i >= 0; i--) {
|
||||
const day = new Date(y, m, d - i);
|
||||
|
||||
const stat = stats.find(s => s.date.getTime() == day.getTime());
|
||||
|
||||
if (stat) {
|
||||
chart.unshift(stat);
|
||||
} else { // 隙間埋め
|
||||
const mostRecent = stats.find(s => s.date.getTime() < day.getTime());
|
||||
if (mostRecent) {
|
||||
chart.unshift(Object.assign({}, mostRecent, {
|
||||
date: day
|
||||
}));
|
||||
} else {
|
||||
chart.unshift({
|
||||
date: day,
|
||||
users: {
|
||||
local: {
|
||||
total: 0,
|
||||
diff: 0
|
||||
},
|
||||
remote: {
|
||||
total: 0,
|
||||
diff: 0
|
||||
}
|
||||
},
|
||||
notes: {
|
||||
local: {
|
||||
total: 0,
|
||||
diff: 0,
|
||||
diffs: {
|
||||
normal: 0,
|
||||
reply: 0,
|
||||
renote: 0
|
||||
}
|
||||
},
|
||||
remote: {
|
||||
total: 0,
|
||||
diff: 0,
|
||||
diffs: {
|
||||
normal: 0,
|
||||
reply: 0,
|
||||
renote: 0
|
||||
}
|
||||
}
|
||||
},
|
||||
drive: {
|
||||
local: {
|
||||
totalCount: 0,
|
||||
totalSize: 0,
|
||||
diffCount: 0,
|
||||
diffSize: 0
|
||||
},
|
||||
remote: {
|
||||
totalCount: 0,
|
||||
totalSize: 0,
|
||||
diffCount: 0,
|
||||
diffSize: 0
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
chart.forEach(x => {
|
||||
delete x.date;
|
||||
});
|
||||
|
||||
res(chart);
|
||||
});
|
26
src/server/api/endpoints/admin/invite.ts
Normal file
26
src/server/api/endpoints/admin/invite.ts
Normal file
|
@ -0,0 +1,26 @@
|
|||
import rndstr from 'rndstr';
|
||||
import RegistrationTicket from '../../../../models/registration-tickets';
|
||||
|
||||
export const meta = {
|
||||
desc: {
|
||||
ja: '招待コードを発行します。'
|
||||
},
|
||||
|
||||
requireCredential: true,
|
||||
requireAdmin: true,
|
||||
|
||||
params: {}
|
||||
};
|
||||
|
||||
export default (params: any) => new Promise(async (res, rej) => {
|
||||
const code = rndstr({ length: 5, chars: '0-9' });
|
||||
|
||||
await RegistrationTicket.insert({
|
||||
createdAt: new Date(),
|
||||
code: code
|
||||
});
|
||||
|
||||
res({
|
||||
code: code
|
||||
});
|
||||
});
|
46
src/server/api/endpoints/admin/unverify-user.ts
Normal file
46
src/server/api/endpoints/admin/unverify-user.ts
Normal file
|
@ -0,0 +1,46 @@
|
|||
import $ from 'cafy';
|
||||
import ID from '../../../../misc/cafy-id';
|
||||
import getParams from '../../get-params';
|
||||
import User from '../../../../models/user';
|
||||
|
||||
export const meta = {
|
||||
desc: {
|
||||
ja: '指定したユーザーの公式アカウントを解除します。',
|
||||
en: 'Mark a user as unverified.'
|
||||
},
|
||||
|
||||
requireCredential: true,
|
||||
requireAdmin: true,
|
||||
|
||||
params: {
|
||||
userId: $.type(ID).note({
|
||||
desc: {
|
||||
ja: '対象のユーザーID',
|
||||
en: 'The user ID which you want to unverify'
|
||||
}
|
||||
}),
|
||||
}
|
||||
};
|
||||
|
||||
export default (params: any) => new Promise(async (res, rej) => {
|
||||
const [ps, psErr] = getParams(meta, params);
|
||||
if (psErr) return rej(psErr);
|
||||
|
||||
const user = await User.findOne({
|
||||
_id: ps.userId
|
||||
});
|
||||
|
||||
if (user == null) {
|
||||
return rej('user not found');
|
||||
}
|
||||
|
||||
await User.findOneAndUpdate({
|
||||
_id: user._id
|
||||
}, {
|
||||
$set: {
|
||||
isVerified: false
|
||||
}
|
||||
});
|
||||
|
||||
res();
|
||||
});
|
46
src/server/api/endpoints/admin/verify-user.ts
Normal file
46
src/server/api/endpoints/admin/verify-user.ts
Normal file
|
@ -0,0 +1,46 @@
|
|||
import $ from 'cafy';
|
||||
import ID from '../../../../misc/cafy-id';
|
||||
import getParams from '../../get-params';
|
||||
import User from '../../../../models/user';
|
||||
|
||||
export const meta = {
|
||||
desc: {
|
||||
ja: '指定したユーザーを公式アカウントにします。',
|
||||
en: 'Mark a user as verified.'
|
||||
},
|
||||
|
||||
requireCredential: true,
|
||||
requireAdmin: true,
|
||||
|
||||
params: {
|
||||
userId: $.type(ID).note({
|
||||
desc: {
|
||||
ja: '対象のユーザーID',
|
||||
en: 'The user ID which you want to verify'
|
||||
}
|
||||
}),
|
||||
}
|
||||
};
|
||||
|
||||
export default (params: any) => new Promise(async (res, rej) => {
|
||||
const [ps, psErr] = getParams(meta, params);
|
||||
if (psErr) return rej(psErr);
|
||||
|
||||
const user = await User.findOne({
|
||||
_id: ps.userId
|
||||
});
|
||||
|
||||
if (user == null) {
|
||||
return rej('user not found');
|
||||
}
|
||||
|
||||
await User.findOneAndUpdate({
|
||||
_id: user._id
|
||||
}, {
|
||||
$set: {
|
||||
isVerified: true
|
||||
}
|
||||
});
|
||||
|
||||
res();
|
||||
});
|
|
@ -1,84 +0,0 @@
|
|||
import $ from 'cafy';
|
||||
import Note from '../../../../models/note';
|
||||
|
||||
/**
|
||||
* Aggregate notes
|
||||
*/
|
||||
export default (params: any) => new Promise(async (res, rej) => {
|
||||
// Get 'limit' parameter
|
||||
const [limit = 365, limitErr] = $.num.optional.range(1, 365).get(params.limit);
|
||||
if (limitErr) return rej('invalid limit param');
|
||||
|
||||
const datas = await Note
|
||||
.aggregate([
|
||||
{ $project: {
|
||||
renoteId: '$renoteId',
|
||||
replyId: '$replyId',
|
||||
createdAt: { $add: ['$createdAt', 9 * 60 * 60 * 1000] } // Convert into JST
|
||||
}},
|
||||
{ $project: {
|
||||
date: {
|
||||
year: { $year: '$createdAt' },
|
||||
month: { $month: '$createdAt' },
|
||||
day: { $dayOfMonth: '$createdAt' }
|
||||
},
|
||||
type: {
|
||||
$cond: {
|
||||
if: { $ne: ['$renoteId', null] },
|
||||
then: 'renote',
|
||||
else: {
|
||||
$cond: {
|
||||
if: { $ne: ['$replyId', null] },
|
||||
then: 'reply',
|
||||
else: 'note'
|
||||
}
|
||||
}
|
||||
}
|
||||
}}
|
||||
},
|
||||
{ $group: { _id: {
|
||||
date: '$date',
|
||||
type: '$type'
|
||||
}, count: { $sum: 1 } } },
|
||||
{ $group: {
|
||||
_id: '$_id.date',
|
||||
data: { $addToSet: {
|
||||
type: '$_id.type',
|
||||
count: '$count'
|
||||
}}
|
||||
} }
|
||||
]);
|
||||
|
||||
datas.forEach((data: any) => {
|
||||
data.date = data._id;
|
||||
delete data._id;
|
||||
|
||||
data.notes = (data.data.filter((x: any) => x.type == 'note')[0] || { count: 0 }).count;
|
||||
data.renotes = (data.data.filter((x: any) => x.type == 'renote')[0] || { count: 0 }).count;
|
||||
data.replies = (data.data.filter((x: any) => x.type == 'reply')[0] || { count: 0 }).count;
|
||||
|
||||
delete data.data;
|
||||
});
|
||||
|
||||
const graph = [];
|
||||
|
||||
for (let i = 0; i < limit; i++) {
|
||||
const day = new Date(new Date().setDate(new Date().getDate() - i));
|
||||
|
||||
const data = datas.filter((d: any) =>
|
||||
d.date.year == day.getFullYear() && d.date.month == day.getMonth() + 1 && d.date.day == day.getDate()
|
||||
)[0];
|
||||
|
||||
if (data) {
|
||||
graph.push(data);
|
||||
} else {
|
||||
graph.push({
|
||||
notes: 0,
|
||||
renotes: 0,
|
||||
replies: 0
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
res(graph);
|
||||
});
|
|
@ -1,55 +0,0 @@
|
|||
import $ from 'cafy';
|
||||
import User from '../../../../models/user';
|
||||
|
||||
/**
|
||||
* Aggregate users
|
||||
*/
|
||||
export default (params: any) => new Promise(async (res, rej) => {
|
||||
// Get 'limit' parameter
|
||||
const [limit = 365, limitErr] = $.num.optional.range(1, 365).get(params.limit);
|
||||
if (limitErr) return rej('invalid limit param');
|
||||
|
||||
const users = await User
|
||||
.find({}, {
|
||||
sort: {
|
||||
_id: -1
|
||||
},
|
||||
fields: {
|
||||
_id: false,
|
||||
createdAt: true,
|
||||
deletedAt: true
|
||||
}
|
||||
});
|
||||
|
||||
const graph = [];
|
||||
|
||||
for (let i = 0; i < limit; i++) {
|
||||
let dayStart = new Date(new Date().setDate(new Date().getDate() - i));
|
||||
dayStart = new Date(dayStart.setMilliseconds(0));
|
||||
dayStart = new Date(dayStart.setSeconds(0));
|
||||
dayStart = new Date(dayStart.setMinutes(0));
|
||||
dayStart = new Date(dayStart.setHours(0));
|
||||
|
||||
let dayEnd = new Date(new Date().setDate(new Date().getDate() - i));
|
||||
dayEnd = new Date(dayEnd.setMilliseconds(999));
|
||||
dayEnd = new Date(dayEnd.setSeconds(59));
|
||||
dayEnd = new Date(dayEnd.setMinutes(59));
|
||||
dayEnd = new Date(dayEnd.setHours(23));
|
||||
// day = day.getTime();
|
||||
|
||||
const total = users.filter(u =>
|
||||
u.createdAt < dayEnd && (u.deletedAt == null || u.deletedAt > dayEnd)
|
||||
).length;
|
||||
|
||||
const created = users.filter(u =>
|
||||
u.createdAt < dayEnd && u.createdAt > dayStart
|
||||
).length;
|
||||
|
||||
graph.push({
|
||||
total: total,
|
||||
created: created
|
||||
});
|
||||
}
|
||||
|
||||
res(graph);
|
||||
});
|
|
@ -28,6 +28,7 @@ export default () => new Promise(async (res, rej) => {
|
|||
model: os.cpus()[0].model,
|
||||
cores: os.cpus().length
|
||||
},
|
||||
broadcasts: meta.broadcasts
|
||||
broadcasts: meta.broadcasts,
|
||||
disableRegistration: meta.disableRegistration
|
||||
});
|
||||
});
|
||||
|
|
|
@ -16,8 +16,7 @@ export const meta = {
|
|||
|
||||
limit: {
|
||||
duration: ms('1hour'),
|
||||
max: 300,
|
||||
minInterval: ms('1second')
|
||||
max: 300
|
||||
},
|
||||
|
||||
kind: 'note-write',
|
||||
|
|
|
@ -6,6 +6,7 @@ import User, { IUser, validateUsername, validatePassword, pack } from '../../../
|
|||
import generateUserToken from '../common/generate-native-user-token';
|
||||
import config from '../../../config';
|
||||
import Meta from '../../../models/meta';
|
||||
import RegistrationTicket from '../../../models/registration-tickets';
|
||||
|
||||
if (config.recaptcha) {
|
||||
recaptcha.init({
|
||||
|
@ -29,6 +30,29 @@ export default async (ctx: Koa.Context) => {
|
|||
|
||||
const username = body['username'];
|
||||
const password = body['password'];
|
||||
const invitationCode = body['invitationCode'];
|
||||
|
||||
const meta = await Meta.findOne({});
|
||||
|
||||
if (meta && meta.disableRegistration) {
|
||||
if (invitationCode == null || typeof invitationCode != 'string') {
|
||||
ctx.status = 400;
|
||||
return;
|
||||
}
|
||||
|
||||
const ticket = await RegistrationTicket.findOne({
|
||||
code: invitationCode
|
||||
});
|
||||
|
||||
if (ticket == null) {
|
||||
ctx.status = 400;
|
||||
return;
|
||||
}
|
||||
|
||||
RegistrationTicket.remove({
|
||||
_id: ticket._id
|
||||
});
|
||||
}
|
||||
|
||||
// Validate username
|
||||
if (!validateUsername(username)) {
|
||||
|
|
|
@ -17,6 +17,7 @@ import { isLocalUser, IUser, IRemoteUser } from '../../models/user';
|
|||
import delFile from './delete-file';
|
||||
import config from '../../config';
|
||||
import { getDriveFileThumbnailBucket } from '../../models/drive-file-thumbnail';
|
||||
import { updateDriveStats } from '../update-chart';
|
||||
|
||||
const log = debug('misskey:drive:add-file');
|
||||
|
||||
|
@ -377,7 +378,8 @@ export default async function(
|
|||
publishDriveStream(user._id, 'file_created', packedFile);
|
||||
});
|
||||
|
||||
// TODO: サムネイル生成
|
||||
// 統計を更新
|
||||
updateDriveStats(driveFile, true);
|
||||
|
||||
return driveFile;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ import * as Minio from 'minio';
|
|||
import DriveFile, { DriveFileChunk, IDriveFile } from '../../models/drive-file';
|
||||
import DriveFileThumbnail, { DriveFileThumbnailChunk } from '../../models/drive-file-thumbnail';
|
||||
import config from '../../config';
|
||||
import { updateDriveStats } from '../update-chart';
|
||||
|
||||
export default async function(file: IDriveFile, isExpired = false) {
|
||||
if (file.metadata.storage == 'minio') {
|
||||
|
@ -45,4 +46,7 @@ export default async function(file: IDriveFile, isExpired = false) {
|
|||
await DriveFileThumbnail.remove({ _id: thumbnail._id });
|
||||
}
|
||||
//#endregion
|
||||
|
||||
// 統計を更新
|
||||
updateDriveStats(file, false);
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import registerHashtag from '../register-hashtag';
|
|||
import isQuote from '../../misc/is-quote';
|
||||
import { TextElementMention } from '../../mfm/parse/elements/mention';
|
||||
import { TextElementHashtag } from '../../mfm/parse/elements/hashtag';
|
||||
import { updateNoteStats } from '../update-chart';
|
||||
|
||||
type NotificationType = 'reply' | 'renote' | 'quote' | 'mention';
|
||||
|
||||
|
@ -142,6 +143,9 @@ export default async (user: IUser, data: Option, silent = false) => new Promise<
|
|||
return;
|
||||
}
|
||||
|
||||
// 統計を更新
|
||||
updateNoteStats(note, true);
|
||||
|
||||
// ハッシュタグ登録
|
||||
tags.map(tag => registerHashtag(user, tag));
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ import pack from '../../remote/activitypub/renderer';
|
|||
import { deliver } from '../../queue';
|
||||
import Following from '../../models/following';
|
||||
import renderNote from '../../remote/activitypub/renderer/note';
|
||||
import { updateNoteStats } from '../update-chart';
|
||||
|
||||
/**
|
||||
* 投稿を削除します。
|
||||
|
@ -43,4 +44,7 @@ export default async function(user: IUser, note: INote) {
|
|||
});
|
||||
}
|
||||
//#endregion
|
||||
|
||||
// 統計を更新
|
||||
updateNoteStats(note, false);
|
||||
}
|
||||
|
|
223
src/services/update-chart.ts
Normal file
223
src/services/update-chart.ts
Normal file
|
@ -0,0 +1,223 @@
|
|||
import { INote } from '../models/note';
|
||||
import Stats, { IStats } from '../models/stats';
|
||||
import { isLocalUser, IUser } from '../models/user';
|
||||
import { IDriveFile } from '../models/drive-file';
|
||||
|
||||
type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
|
||||
|
||||
async function getTodayStats(): Promise<IStats> {
|
||||
const now = new Date();
|
||||
const y = now.getFullYear();
|
||||
const m = now.getMonth();
|
||||
const d = now.getDate();
|
||||
const today = new Date(y, m, d);
|
||||
|
||||
// 今日の統計
|
||||
const todayStats = await Stats.findOne({
|
||||
date: today
|
||||
});
|
||||
|
||||
// 日付が変わってから、初めてのチャート更新なら
|
||||
if (todayStats == null) {
|
||||
// 最も最近の統計を持ってくる
|
||||
// * 昨日何もチャートを更新するような出来事がなかった場合は、
|
||||
// 統計がそもそも作られずドキュメントが存在しないということがあり得るため、
|
||||
// 「昨日の」と決め打ちせずに「もっとも最近の」とします
|
||||
const mostRecentStats = await Stats.findOne({}, {
|
||||
sort: {
|
||||
date: -1
|
||||
}
|
||||
});
|
||||
|
||||
// 統計が存在しなかったら
|
||||
// * Misskeyインスタンスを建てて初めてのチャート更新時など
|
||||
if (mostRecentStats == null) {
|
||||
// 空の統計を作成
|
||||
const chart: Omit<IStats, '_id'> = {
|
||||
date: today,
|
||||
users: {
|
||||
local: {
|
||||
total: 0,
|
||||
diff: 0
|
||||
},
|
||||
remote: {
|
||||
total: 0,
|
||||
diff: 0
|
||||
}
|
||||
},
|
||||
notes: {
|
||||
local: {
|
||||
total: 0,
|
||||
diff: 0,
|
||||
diffs: {
|
||||
normal: 0,
|
||||
reply: 0,
|
||||
renote: 0
|
||||
}
|
||||
},
|
||||
remote: {
|
||||
total: 0,
|
||||
diff: 0,
|
||||
diffs: {
|
||||
normal: 0,
|
||||
reply: 0,
|
||||
renote: 0
|
||||
}
|
||||
}
|
||||
},
|
||||
drive: {
|
||||
local: {
|
||||
totalCount: 0,
|
||||
totalSize: 0,
|
||||
diffCount: 0,
|
||||
diffSize: 0
|
||||
},
|
||||
remote: {
|
||||
totalCount: 0,
|
||||
totalSize: 0,
|
||||
diffCount: 0,
|
||||
diffSize: 0
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const stats = await Stats.insert(chart);
|
||||
|
||||
return stats;
|
||||
} else {
|
||||
// 今日の統計を初期挿入
|
||||
const chart: Omit<IStats, '_id'> = {
|
||||
date: today,
|
||||
users: {
|
||||
local: {
|
||||
total: mostRecentStats.users.local.total,
|
||||
diff: 0
|
||||
},
|
||||
remote: {
|
||||
total: mostRecentStats.users.remote.total,
|
||||
diff: 0
|
||||
}
|
||||
},
|
||||
notes: {
|
||||
local: {
|
||||
total: mostRecentStats.notes.local.total,
|
||||
diff: 0,
|
||||
diffs: {
|
||||
normal: 0,
|
||||
reply: 0,
|
||||
renote: 0
|
||||
}
|
||||
},
|
||||
remote: {
|
||||
total: mostRecentStats.notes.remote.total,
|
||||
diff: 0,
|
||||
diffs: {
|
||||
normal: 0,
|
||||
reply: 0,
|
||||
renote: 0
|
||||
}
|
||||
}
|
||||
},
|
||||
drive: {
|
||||
local: {
|
||||
totalCount: mostRecentStats.drive.local.totalCount,
|
||||
totalSize: mostRecentStats.drive.local.totalSize,
|
||||
diffCount: 0,
|
||||
diffSize: 0
|
||||
},
|
||||
remote: {
|
||||
totalCount: mostRecentStats.drive.remote.totalCount,
|
||||
totalSize: mostRecentStats.drive.remote.totalSize,
|
||||
diffCount: 0,
|
||||
diffSize: 0
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const stats = await Stats.insert(chart);
|
||||
|
||||
return stats;
|
||||
}
|
||||
} else {
|
||||
return todayStats;
|
||||
}
|
||||
}
|
||||
|
||||
async function update(inc: any) {
|
||||
const stats = await getTodayStats();
|
||||
|
||||
await Stats.findOneAndUpdate({
|
||||
_id: stats._id
|
||||
}, {
|
||||
$inc: inc
|
||||
});
|
||||
}
|
||||
|
||||
export async function updateUserStats(user: IUser, isAdditional: boolean) {
|
||||
const inc = {} as any;
|
||||
|
||||
const amount = isAdditional ? 1 : -1;
|
||||
|
||||
if (isLocalUser(user)) {
|
||||
inc['users.local.total'] = amount;
|
||||
inc['users.local.diff'] = amount;
|
||||
} else {
|
||||
inc['users.remote.total'] = amount;
|
||||
inc['users.remote.diff'] = amount;
|
||||
}
|
||||
|
||||
await update(inc);
|
||||
}
|
||||
|
||||
export async function updateNoteStats(note: INote, isAdditional: boolean) {
|
||||
const inc = {} as any;
|
||||
|
||||
const amount = isAdditional ? 1 : -1;
|
||||
|
||||
if (isLocalUser(note._user)) {
|
||||
inc['notes.local.total'] = amount;
|
||||
inc['notes.local.diff'] = amount;
|
||||
|
||||
if (note.replyId != null) {
|
||||
inc['notes.local.diffs.reply'] = amount;
|
||||
} else if (note.renoteId != null) {
|
||||
inc['notes.local.diffs.renote'] = amount;
|
||||
} else {
|
||||
inc['notes.local.diffs.normal'] = amount;
|
||||
}
|
||||
} else {
|
||||
inc['notes.remote.total'] = amount;
|
||||
inc['notes.remote.diff'] = amount;
|
||||
|
||||
if (note.replyId != null) {
|
||||
inc['notes.remote.diffs.reply'] = amount;
|
||||
} else if (note.renoteId != null) {
|
||||
inc['notes.remote.diffs.renote'] = amount;
|
||||
} else {
|
||||
inc['notes.remote.diffs.normal'] = amount;
|
||||
}
|
||||
}
|
||||
|
||||
await update(inc);
|
||||
}
|
||||
|
||||
export async function updateDriveStats(file: IDriveFile, isAdditional: boolean) {
|
||||
const inc = {} as any;
|
||||
|
||||
const amount = isAdditional ? 1 : -1;
|
||||
const size = isAdditional ? file.length : -file.length;
|
||||
|
||||
if (isLocalUser(file.metadata._user)) {
|
||||
inc['drive.local.totalCount'] = amount;
|
||||
inc['drive.local.diffCount'] = amount;
|
||||
inc['drive.local.totalSize'] = size;
|
||||
inc['drive.local.diffSize'] = size;
|
||||
} else {
|
||||
inc['drive.remote.total'] = amount;
|
||||
inc['drive.remote.diff'] = amount;
|
||||
inc['drive.remote.totalSize'] = size;
|
||||
inc['drive.remote.diffSize'] = size;
|
||||
}
|
||||
|
||||
await update(inc);
|
||||
}
|
Loading…
Reference in a new issue