Compare commits

..

12 Commits

Author SHA1 Message Date
792632d726 3.0.1 2018-06-16 15:23:44 +09:00
9cac293efc #1708 2018-06-16 15:23:03 +09:00
cd8bfca29c npm install --only=dev するのが既存のドキュメントと互換性が無いため戻す 2018-06-16 13:10:17 +09:00
b5b437b878 ✌️ 2018-06-16 12:43:58 +09:00
cc2947063a add lock file 2018-06-16 12:42:59 +09:00
2864a9027f save-exact=true 2018-06-16 12:02:38 +09:00
e11f547308 #1715 2018-06-16 10:40:53 +09:00
f164661ef2 2.42.0 2018-06-16 07:40:39 +09:00
c9d993b838 ✌️ 2018-06-16 07:40:07 +09:00
65f35dc9f4 ✌️ 2018-06-16 07:31:35 +09:00
b600d462c1 ✌️ 2018-06-16 07:13:45 +09:00
fa5a82c9ab ✌️ 2018-06-16 07:06:58 +09:00
18 changed files with 12146 additions and 211 deletions

1
.gitattributes vendored
View File

@ -1,3 +1,4 @@
*.svg -diff -text *.svg -diff -text
*.psd -diff -text *.psd -diff -text
*.ai -diff -text *.ai -diff -text
yarn.lock -diff -text

1
.npmrc
View File

@ -1 +1,2 @@
package-lock = false package-lock = false
save-exact=true

11
CHANGELOG.md Normal file
View File

@ -0,0 +1,11 @@
ChangeLog
=========
3.0.0
-----
### Migration
起動する前に、`node cli/recount-stats`してください。
Please run `node cli/recount-stats` before launch.

42
cli/recount-stats.js Normal file
View File

@ -0,0 +1,42 @@
const { default: Note } = require('../built/models/note');
const { default: Meta } = require('../built/models/meta');
const { default: User } = require('../built/models/user');
async function main() {
const meta = await Meta.findOne({});
const notesCount = await Note.count();
const usersCount = await User.count();
const originalNotesCount = await Note.count({
'_user.host': null
});
const originalUsersCount = await User.count({
host: null
});
const stats = {
notesCount,
usersCount,
originalNotesCount,
originalUsersCount
};
if (meta) {
await Meta.update({}, {
$set: {
stats
}
});
} else {
await Meta.insert({
stats
});
}
}
main().then(() => {
console.log('done');
}).catch(console.error);

View File

@ -1,8 +1,8 @@
{ {
"name": "misskey", "name": "misskey",
"author": "syuilo <i@syuilo.com>", "author": "syuilo <i@syuilo.com>",
"version": "2.41.1", "version": "3.0.1",
"clientVersion": "1.0.6512", "clientVersion": "1.0.6517",
"codename": "nighthike", "codename": "nighthike",
"main": "./built/index.js", "main": "./built/index.js",
"private": true, "private": true,
@ -86,9 +86,8 @@
"webfinger.js": "2.6.6", "webfinger.js": "2.6.6",
"websocket": "1.0.26", "websocket": "1.0.26",
"ws": "5.2.0", "ws": "5.2.0",
"xev": "2.0.1" "xev": "2.0.1",
},
"devDependencies": {
"@prezzemolo/zip": "0.0.3", "@prezzemolo/zip": "0.0.3",
"@types/bcryptjs": "2.4.1", "@types/bcryptjs": "2.4.1",
"@types/debug": "0.0.30", "@types/debug": "0.0.30",

View File

@ -1,6 +1,7 @@
<template> <template>
<form class="mk-signin" :class="{ signing }" @submit.prevent="onSubmit"> <form class="mk-signin" :class="{ signing }" @submit.prevent="onSubmit">
<ui-input v-model="username" type="text" pattern="^[a-zA-Z0-9_]+$" autofocus required @change="onUsernameChange"> <div class="avatar" :style="{ backgroundImage: user ? `url('${ user.avatarUrl }')` : null }" v-show="withAvatar"></div>
<ui-input v-model="username" type="text" pattern="^[a-zA-Z0-9_]+$" spellcheck="false" autofocus required @input="onUsernameChange">
<span>%i18n:@username%</span> <span>%i18n:@username%</span>
<span slot="prefix">@</span> <span slot="prefix">@</span>
<span slot="suffix">@{{ host }}</span> <span slot="suffix">@{{ host }}</span>
@ -20,6 +21,13 @@ import Vue from 'vue';
import { apiUrl, host } from '../../../config'; import { apiUrl, host } from '../../../config';
export default Vue.extend({ export default Vue.extend({
props: {
withAvatar: {
type: Boolean,
required: false,
default: true
}
},
data() { data() {
return { return {
signing: false, signing: false,
@ -37,6 +45,8 @@ export default Vue.extend({
username: this.username username: this.username
}).then(user => { }).then(user => {
this.user = user; this.user = user;
}, () => {
this.user = null;
}); });
}, },
onSubmit() { onSubmit() {
@ -61,84 +71,19 @@ export default Vue.extend({
@import '~const.styl' @import '~const.styl'
.mk-signin .mk-signin
color #555
&.signing &.signing
&, * &, *
cursor wait !important cursor wait !important
label > .avatar
display block margin 16px auto 0 auto
margin 12px 0 width 64px
height 64px
[data-fa] background #ddd
display block background-position center
pointer-events none background-size cover
position absolute border-radius 100%
bottom 0
top 0
left 0
z-index 1
margin auto
padding 0 16px
height 1em
color #898786
input[type=text]
input[type=password]
input[type=number]
user-select text
display inline-block
cursor auto
padding 0 0 0 38px
margin 0
width 100%
line-height 44px
font-size 1em
color rgba(#000, 0.7)
background #fff
outline none
border solid 1px #eee
border-radius 4px
&:hover
background rgba(255, 255, 255, 0.7)
border-color #ddd
& + i
color #797776
&:focus
background #fff
border-color #ccc
& + i
color #797776
[type=submit]
cursor pointer
padding 16px
margin -6px 0 0 0
width 100%
font-size 1.2em
color rgba(#000, 0.5)
outline none
border none
border-radius 0
background transparent
transition all .5s ease
&:hover
color $theme-color
transition all .2s ease
&:focus
color $theme-color
transition all .2s ease
&:active
color darken($theme-color, 30%)
transition all .2s ease
&:disabled
opacity 0.7
</style> </style>

View File

@ -1,7 +1,7 @@
<template> <template>
<div class="ui-input" :class="[{ focused, filled }, styl]"> <div class="ui-input" :class="[{ focused, filled }, styl]">
<div class="icon" ref="icon"><slot name="icon"></slot></div> <div class="icon" ref="icon"><slot name="icon"></slot></div>
<div class="input" @click="focus" @mousedown="focus"> <div class="input">
<div class="password-meter" v-if="withPasswordMeter" v-show="passwordStrength != ''" :data-strength="passwordStrength"> <div class="password-meter" v-if="withPasswordMeter" v-show="passwordStrength != ''" :data-strength="passwordStrength">
<div class="value" ref="passwordMetar"></div> <div class="value" ref="passwordMetar"></div>
</div> </div>
@ -30,7 +30,7 @@
:value="value" :value="value"
@change="onChangeFile"> @change="onChangeFile">
</template> </template>
<div class="suffix"><slot name="suffix"></slot></div> <div class="suffix" ref="suffix"><slot name="suffix"></slot></div>
</div> </div>
<div class="text"><slot name="text"></slot></div> <div class="text"><slot name="text"></slot></div>
</div> </div>
@ -128,6 +128,14 @@ export default Vue.extend({
mounted() { mounted() {
if (this.$refs.prefix) { if (this.$refs.prefix) {
this.$refs.label.style.left = (this.$refs.prefix.offsetLeft + this.$refs.prefix.offsetWidth) + 'px'; this.$refs.label.style.left = (this.$refs.prefix.offsetLeft + this.$refs.prefix.offsetWidth) + 'px';
if (this.$refs.prefix.offsetWidth) {
this.$refs.input.style.paddingLeft = this.$refs.prefix.offsetWidth + 'px';
}
}
if (this.$refs.suffix) {
if (this.$refs.suffix.offsetWidth) {
this.$refs.input.style.paddingRight = this.$refs.suffix.offsetWidth + 'px';
}
} }
}, },
methods: { methods: {
@ -165,14 +173,8 @@ root(isDark, fill)
margin-left 28px margin-left 28px
> .input > .input
display flex
cursor text
if fill if !fill
padding 6px 12px
background rgba(#000, 0.035)
border-radius 6px
else
&:before &:before
content '' content ''
display block display block
@ -232,6 +234,7 @@ root(isDark, fill)
> .label > .label
position absolute position absolute
z-index 1
top fill ? 6px : 0 top fill ? 6px : 0
left 0 left 0
pointer-events none pointer-events none
@ -247,7 +250,6 @@ root(isDark, fill)
> input > input
display block display block
flex 1
width 100% width 100%
margin 0 margin 0
padding 0 padding 0
@ -262,29 +264,46 @@ root(isDark, fill)
outline none outline none
box-shadow none box-shadow none
if fill
padding 6px 12px
background rgba(#000, 0.035)
border-radius 6px
&[type='file'] &[type='file']
display none display none
> .prefix > .prefix
> .suffix > .suffix
display block display block
align-self center position absolute
justify-self center z-index 1
top 0
font-size 16px font-size 16px
line-height 32px line-height fill ? 44px : 32px
color isDark ? rgba(#fff, 0.7) : rgba(#000, 0.54) color isDark ? rgba(#fff, 0.7) : rgba(#000, 0.54)
pointer-events none pointer-events none
&:empty
display none
> * > *
display block display block
min-width 16px min-width 16px
> .prefix > .prefix
left 0
padding-right 4px padding-right 4px
if fill
padding-left 12px
> .suffix > .suffix
right 0
padding-left 4px padding-left 4px
if fill
padding-right 12px
> .text > .text
margin 6px 0 margin 6px 0
font-size 13px font-size 13px

View File

@ -7,13 +7,6 @@
</button> </button>
<div class="body" :style="{ backgroundImage: `url('${ welcomeBgUrl }')` }"> <div class="body" :style="{ backgroundImage: `url('${ welcomeBgUrl }')` }">
<div class="container"> <div class="container">
<div class="info">
<span>%i18n:common.misskey% <b>{{ host }}</b></span>
<span class="stats" v-if="stats">
<span>%fa:user% {{ stats.originalUsersCount | number }}</span>
<span>%fa:pencil-alt% {{ stats.originalNotesCount | number }}</span>
</span>
</div>
<main> <main>
<div class="about"> <div class="about">
<h1 v-if="name">{{ name }}</h1> <h1 v-if="name">{{ name }}</h1>
@ -26,6 +19,13 @@
<mk-signin/> <mk-signin/>
</div> </div>
</main> </main>
<div class="info">
<span>%i18n:common.misskey% <b>{{ host }}</b></span>
<span class="stats" v-if="stats">
<span>%fa:user% {{ stats.originalUsersCount | number }}</span>
<span>%fa:pencil-alt% {{ stats.originalNotesCount | number }}</span>
</span>
</div>
<mk-nav class="nav"/> <mk-nav class="nav"/>
</div> </div>
<mk-forkit class="forkit"/> <mk-forkit class="forkit"/>
@ -38,10 +38,6 @@
<header :class="$style.signupFormHeader">%i18n:@signup%</header> <header :class="$style.signupFormHeader">%i18n:@signup%</header>
<mk-signup :class="$style.signupForm"/> <mk-signup :class="$style.signupForm"/>
</modal> </modal>
<modal name="signin" width="500px" height="auto" scrollable>
<header :class="$style.signinFormHeader">%i18n:@signin%</header>
<mk-signin :class="$style.signinForm"/>
</modal>
</div> </div>
</template> </template>
@ -57,7 +53,8 @@ export default Vue.extend({
welcomeBgUrl, welcomeBgUrl,
host, host,
name, name,
description description,
pointerInterval: null
}; };
}, },
created() { created() {
@ -66,11 +63,18 @@ export default Vue.extend({
}); });
}, },
mounted() { mounted() {
const x = this.$refs.signup.getBoundingClientRect(); this.point();
this.$refs.pointer.style.top = x.top + x.height + 'px'; this.pointerInterval = setInterval(this.point, 100);
this.$refs.pointer.style.left = x.left + 'px'; },
beforeDestroy() {
clearInterval(this.pointerInterval);
}, },
methods: { methods: {
point() {
const x = this.$refs.signup.getBoundingClientRect();
this.$refs.pointer.style.top = x.top + x.height + 'px';
this.$refs.pointer.style.left = x.left + 'px';
},
signup() { signup() {
this.$modal.show('signup'); this.$modal.show('signup');
}, },
@ -109,7 +113,7 @@ root(isDark)
right 0 right 0
width 180px width 180px
margin 0 0 0 -180px margin 0 0 0 -180px
transform rotateY(180deg) translateX(-10px) translateY(-25px) transform rotateY(180deg) translateX(-10px) translateY(-48px)
pointer-events none pointer-events none
> button > button
@ -157,23 +161,6 @@ root(isDark)
$loginWidth = 340px $loginWidth = 340px
$width = $aboutWidth + $loginWidth $width = $aboutWidth + $loginWidth
> .info
margin 0 auto 16px auto
padding 12px
width $width
font-size 14px
color #fff
background rgba(#000, 0.2)
border-radius 8px
> .stats
margin-left 16px
padding-left 16px
border-left solid 1px #fff
> *
margin-right 16px
> main > main
display flex display flex
margin auto margin auto
@ -214,6 +201,23 @@ root(isDark)
padding 16px 32px 32px 32px padding 16px 32px 32px 32px
background #f5f5f5 background #f5f5f5
> .info
margin 16px auto
padding 12px
width $width
font-size 14px
color #fff
background rgba(#000, 0.2)
border-radius 8px
> .stats
margin-left 16px
padding-left 16px
border-left solid 1px #fff
> *
margin-right 16px
> .nav > .nav
display block display block
margin 16px 0 margin 16px 0

View File

@ -9,26 +9,15 @@
<router-link class="signup" to="/signup">新規登録</router-link> <router-link class="signup" to="/signup">新規登録</router-link>
</div> </div>
<div class="login"> <div class="login">
<form @submit.prevent="onSubmit"> <mk-signin :with-avatar="false"/>
<ui-input v-model="username" type="text" pattern="^[a-zA-Z0-9_]+$" autofocus required @change="onUsernameChange">
<span>ユーザー名</span>
<span slot="prefix">@</span>
<span slot="suffix">@{{ host }}</span>
</ui-input>
<ui-input v-model="password" type="password" required>
<span>パスワード</span>
<span slot="prefix">%fa:lock%</span>
</ui-input>
<ui-input v-if="user && user.twoFactorEnabled" v-model="token" type="number" required/>
<ui-button type="submit" :disabled="signing">{{ signing ? 'ログインしています' : 'ログイン' }}</ui-button>
</form>
<div style="margin: 8px 0;">
<a :href="`${apiUrl}/signin/twitter`">Twitterでログイン</a>
</div>
</div> </div>
<div class="tl"> <div class="tl">
<mk-welcome-timeline/> <mk-welcome-timeline/>
</div> </div>
<div class="stats" v-if="stats">
<span>%fa:user% {{ stats.originalUsersCount | number }}</span>
<span>%fa:pencil-alt% {{ stats.originalNotesCount | number }}</span>
</div>
<footer> <footer>
<small>{{ copyright }}</small> <small>{{ copyright }}</small>
</footer> </footer>
@ -43,49 +32,18 @@ import { apiUrl, copyright, host, name, description } from '../../../config';
export default Vue.extend({ export default Vue.extend({
data() { data() {
return { return {
signing: false,
user: null,
username: '',
password: '',
token: '',
apiUrl, apiUrl,
copyright, copyright,
users: [], stats: null,
host, host,
name, name,
description description
}; };
}, },
mounted() { created() {
(this as any).api('users', { (this as any).api('stats').then(stats => {
sort: '+follower', this.stats = stats;
limit: 20
}).then(users => {
this.users = users;
}); });
},
methods: {
onUsernameChange() {
(this as any).api('users/show', {
username: this.username
}).then(user => {
this.user = user;
});
},
onSubmit() {
this.signing = true;
(this as any).api('signin', {
username: this.username,
password: this.password,
token: this.user && this.user.twoFactorEnabled ? this.token : undefined
}).then(() => {
location.reload();
}).catch(() => {
alert('something happened');
this.signing = false;
});
}
} }
}); });
</script> </script>
@ -164,6 +122,17 @@ export default Vue.extend({
overflow auto overflow auto
-webkit-overflow-scrolling touch -webkit-overflow-scrolling touch
> .stats
margin 16px 0
padding 8px
font-size 14px
color #444
background rgba(#000, 0.1)
border-radius 6px
> *
margin 0 8px
> footer > footer
text-align center text-align center
color #444 color #444

View File

@ -5,4 +5,10 @@ export default Meta;
export type IMeta = { export type IMeta = {
broadcasts: any[]; broadcasts: any[];
stats: {
notesCount: number;
originalNotesCount: number;
usersCount: number;
originalUsersCount: number;
};
}; };

View File

@ -16,7 +16,7 @@ import Following from './following';
const Note = db.get<INote>('notes'); const Note = db.get<INote>('notes');
Note.createIndex('uri', { sparse: true, unique: true }); Note.createIndex('uri', { sparse: true, unique: true });
Note.createIndex('userId'); Note.createIndex('userId');
Note.createIndex('tags', { sparse: true }); Note.createIndex('tagsLower');
Note.createIndex({ Note.createIndex({
createdAt: -1 createdAt: -1
}); });
@ -40,6 +40,7 @@ export type INote = {
poll: any; // todo poll: any; // todo
text: string; text: string;
tags: string[]; tags: string[];
tagsLower: string[];
cw: string; cw: string;
userId: mongo.ObjectID; userId: mongo.ObjectID;
appId: mongo.ObjectID; appId: mongo.ObjectID;

View File

@ -10,6 +10,7 @@ import Resolver from '../resolver';
import { resolveImage } from './image'; import { resolveImage } from './image';
import { isCollectionOrOrderedCollection, IObject, IPerson } from '../type'; import { isCollectionOrOrderedCollection, IObject, IPerson } from '../type';
import { IDriveFile } from '../../../models/drive-file'; import { IDriveFile } from '../../../models/drive-file';
import Meta from '../../../models/meta';
const log = debug('misskey:activitypub'); const log = debug('misskey:activitypub');
@ -117,6 +118,14 @@ export async function createPerson(value: any, resolver?: Resolver): Promise<IUs
throw e; throw e;
} }
//#region Increment users count
Meta.update({}, {
$inc: {
'stats.usersCount': 1
}
}, { upsert: true });
//#endregion
//#region アイコンとヘッダー画像をフェッチ //#region アイコンとヘッダー画像をフェッチ
const [avatar, banner] = (await Promise.all<IDriveFile>([ const [avatar, banner] = (await Promise.all<IDriveFile>([
person.icon, person.icon,

View File

@ -7,7 +7,7 @@ import Note from '../../../../models/note';
const rangeA = 1000 * 60 * 30; // 30分 const rangeA = 1000 * 60 * 30; // 30分
const rangeB = 1000 * 60 * 120; // 2時間 const rangeB = 1000 * 60 * 120; // 2時間
const coefficient = 1.5; // 「n倍」の部分 const coefficient = 1.25; // 「n倍」の部分
const requiredUsers = 3; // 最低何人がそのタグを投稿している必要があるか const requiredUsers = 3; // 最低何人がそのタグを投稿している必要があるか
const max = 5; const max = 5;
@ -22,20 +22,20 @@ module.exports = () => new Promise(async (res, rej) => {
createdAt: { createdAt: {
$gt: new Date(Date.now() - rangeA) $gt: new Date(Date.now() - rangeA)
}, },
tags: { tagsLower: {
$exists: true, $exists: true,
$ne: [] $ne: []
} }
} }
}, { }, {
$unwind: '$tags' $unwind: '$tagsLower'
}, { }, {
$group: { $group: {
_id: { tags: '$tags', userId: '$userId' } _id: { tag: '$tagsLower', userId: '$userId' }
} }
}]) as Array<{ }]) as Array<{
_id: { _id: {
tags: string; tag: string;
userId: any; userId: any;
} }
}>; }>;
@ -49,12 +49,12 @@ module.exports = () => new Promise(async (res, rej) => {
// カウント // カウント
data.map(x => x._id).forEach(x => { data.map(x => x._id).forEach(x => {
const i = tags.findIndex(tag => tag.name == x.tags); const i = tags.findIndex(tag => tag.name == x.tag);
if (i != -1) { if (i != -1) {
tags[i].count++; tags[i].count++;
} else { } else {
tags.push({ tags.push({
name: x.tags, name: x.tag,
count: 1 count: 1
}); });
} }
@ -66,7 +66,7 @@ module.exports = () => new Promise(async (res, rej) => {
//#region 2. 1で取得したそれぞれのタグについて、「直近a分間のユニーク投稿数が今からa分前今からb分前の間のユニーク投稿数のn倍以上」かどうかを判定する //#region 2. 1で取得したそれぞれのタグについて、「直近a分間のユニーク投稿数が今からa分前今からb分前の間のユニーク投稿数のn倍以上」かどうかを判定する
const hotsPromises = limitedTags.map(async tag => { const hotsPromises = limitedTags.map(async tag => {
const passedCount = (await Note.distinct('userId', { const passedCount = (await Note.distinct('userId', {
tags: tag.name, tagsLower: tag.name,
createdAt: { createdAt: {
$lt: new Date(Date.now() - rangeA), $lt: new Date(Date.now() - rangeA),
$gt: new Date(Date.now() - rangeB) $gt: new Date(Date.now() - rangeB)
@ -108,7 +108,7 @@ module.exports = () => new Promise(async (res, rej) => {
for (let i = 0; i < range; i++) { for (let i = 0; i < range; i++) {
countPromises.push(Promise.all(hots.map(tag => Note.distinct('userId', { countPromises.push(Promise.all(hots.map(tag => Note.distinct('userId', {
tags: tag, tagsLower: tag,
createdAt: { createdAt: {
$lt: new Date(Date.now() - (interval * i)), $lt: new Date(Date.now() - (interval * i)),
$gt: new Date(Date.now() - (interval * (i + 1))) $gt: new Date(Date.now() - (interval * (i + 1)))
@ -119,7 +119,7 @@ module.exports = () => new Promise(async (res, rej) => {
const countsLog = await Promise.all(countPromises); const countsLog = await Promise.all(countPromises);
const totalCounts: any = await Promise.all(hots.map(tag => Note.distinct('userId', { const totalCounts: any = await Promise.all(hots.map(tag => Note.distinct('userId', {
tags: tag, tagsLower: tag,
createdAt: { createdAt: {
$gt: new Date(Date.now() - (interval * range)) $gt: new Date(Date.now() - (interval * range))
} }

View File

@ -101,7 +101,7 @@ async function search(
let q: any = { let q: any = {
$and: [{ $and: [{
tags: tag tagsLower: tag.toLowerCase()
}] }]
}; };

View File

@ -1,26 +1,10 @@
import Note from '../../../models/note'; import Meta from '../../../models/meta';
import User from '../../../models/user';
/** /**
* Get the misskey's statistics * Get the misskey's statistics
*/ */
module.exports = params => new Promise(async (res, rej) => { module.exports = () => new Promise(async (res, rej) => {
const notesCount = await Note.count(); const meta = await Meta.findOne();
const usersCount = await User.count(); res(meta.stats);
const originalNotesCount = await Note.count({
'_user.host': null
});
const originalUsersCount = await User.count({
host: null
});
res({
notesCount,
usersCount,
originalNotesCount,
originalUsersCount
});
}); });

View File

@ -5,6 +5,7 @@ import recaptcha = require('recaptcha-promise');
import User, { IUser, validateUsername, validatePassword, pack } from '../../../models/user'; import User, { IUser, validateUsername, validatePassword, pack } from '../../../models/user';
import generateUserToken from '../common/generate-native-user-token'; import generateUserToken from '../common/generate-native-user-token';
import config from '../../../config'; import config from '../../../config';
import Meta from '../../../models/meta';
recaptcha.init({ recaptcha.init({
secret_key: config.recaptcha.secret_key secret_key: config.recaptcha.secret_key
@ -93,6 +94,15 @@ export default async (ctx: Koa.Context) => {
} }
}); });
//#region Increment users count
Meta.update({}, {
$inc: {
'stats.usersCount': 1,
'stats.originalUsersCount': 1
}
}, { upsert: true });
//#endregion
// Response // Response
ctx.body = await pack(account); ctx.body = await pack(account);
}; };

View File

@ -18,6 +18,7 @@ import parse from '../../text/parse';
import { IApp } from '../../models/app'; import { IApp } from '../../models/app';
import UserList from '../../models/user-list'; import UserList from '../../models/user-list';
import resolveUser from '../../remote/resolve-user'; import resolveUser from '../../remote/resolve-user';
import Meta from '../../models/meta';
type Reason = 'reply' | 'quote' | 'mention'; type Reason = 'reply' | 'quote' | 'mention';
@ -129,6 +130,7 @@ export default async (user: IUser, data: {
poll: data.poll, poll: data.poll,
cw: data.cw == null ? null : data.cw, cw: data.cw == null ? null : data.cw,
tags, tags,
tagsLower: tags.map(tag => tag.toLowerCase()),
userId: user._id, userId: user._id,
viaMobile: data.viaMobile, viaMobile: data.viaMobile,
geo: data.geo || null, geo: data.geo || null,
@ -167,7 +169,24 @@ export default async (user: IUser, data: {
res(note); res(note);
// Increment notes count //#region Increment notes count
if (isLocalUser(user)) {
Meta.update({}, {
$inc: {
'stats.notesCount': 1,
'stats.originalNotesCount': 1
}
}, { upsert: true });
} else {
Meta.update({}, {
$inc: {
'stats.notesCount': 1
}
}, { upsert: true });
}
//#endregion
// Increment notes count (user)
User.update({ _id: user._id }, { User.update({ _id: user._id }, {
$inc: { $inc: {
notesCount: 1 notesCount: 1

11915
yarn.lock Normal file

File diff suppressed because it is too large Load Diff