Compare commits
47 Commits
Author | SHA1 | Date | |
---|---|---|---|
ab4f97ff20 | |||
79640d6861 | |||
d305c7e401 | |||
8afaca36d9 | |||
9950fafff7 | |||
0d9857db63 | |||
10c932876d | |||
d5d7a527a0 | |||
9eb8595130 | |||
8c46e5b3d9 | |||
73bd877993 | |||
de6cbf8a22 | |||
89f618d732 | |||
4955df3911 | |||
6785f50a1f | |||
a549327170 | |||
1f018d87f2 | |||
769ee734fa | |||
6419185228 | |||
b77cbeca22 | |||
4cce10a7d7 | |||
1a6fd7d72e | |||
97ce939a73 | |||
3f2a7a561e | |||
332af15e3c | |||
fe184ce84a | |||
661c7f45ba | |||
01c0545409 | |||
c6492d3d58 | |||
638a2ab684 | |||
650f79d0fd | |||
a64817cea1 | |||
c32c3c1370 | |||
29ad7ab0cf | |||
11716fa9d3 | |||
210f11ffd8 | |||
814751d76a | |||
440cf139bb | |||
276d8ffc66 | |||
f850283147 | |||
c512c07630 | |||
105623e398 | |||
6c75bc6d51 | |||
a068741d05 | |||
4e83106853 | |||
0b688a909e | |||
fabcad6db9 |
@ -52,9 +52,9 @@ If you want to translate Misskey, please see [Translation guide](./docs/translat
|
||||
[List of all contributors](https://github.com/syuilo/misskey/graphs/contributors)
|
||||
|
||||
### :earth_americas: Translators
|
||||
| ![][mirro-san-icon] | ![][Conan-kun-icon] |
|
||||
|:-:|:-:|
|
||||
| [Mirro][mirro-san-link]<br>English, French | [Asriel][Conan-kun-link]<br>English, French |
|
||||
| ![][mirro-san-icon] | ![][Conan-kun-icon] | ![][m4sk1n-icon] |
|
||||
|:-:|:-:|:-:|
|
||||
| [Mirro][mirro-san-link]<br>English, French | [Asriel][Conan-kun-link]<br>English, French | [Marcin Mikołajczak][m4sk1n-link]<br>Polish |
|
||||
|
||||
:four_leaf_clover: Copyright
|
||||
----------------------------------------------------------------
|
||||
@ -100,4 +100,5 @@ Misskey is an open-source software licensed under [GNU AGPLv3](LICENSE).
|
||||
[mirro-san-icon]: https://avatars1.githubusercontent.com/u/17948612?s=70&v=4
|
||||
[Conan-kun-link]: https://github.com/Conan-kun
|
||||
[Conan-kun-icon]: https://avatars3.githubusercontent.com/u/30003708?s=70&v=4
|
||||
|
||||
[m4sk1n-link]: https://github.com/m4sk1n
|
||||
[m4sk1n-icon]: https://avatars3.githubusercontent.com/u/21127288?s=70&v=4
|
||||
|
@ -59,9 +59,15 @@ gulp.task('build:ts', () => {
|
||||
.pipe(gulp.dest('./built/'));
|
||||
});
|
||||
|
||||
gulp.task('build:copy', () =>
|
||||
gulp.task('build:copy:views', () =>
|
||||
gulp.src('./src/server/web/views/**/*').pipe(gulp.dest('./built/server/web/views'))
|
||||
);
|
||||
|
||||
gulp.task('build:copy', ['build:copy:views'], () =>
|
||||
gulp.src([
|
||||
'./build/Release/crypto_key.node',
|
||||
'./src/const.json',
|
||||
'./src/server/web/views/**/*',
|
||||
'./src/**/assets/**/*',
|
||||
'!./src/client/app/**/assets/**/*'
|
||||
]).pipe(gulp.dest('./built/'))
|
||||
|
@ -95,7 +95,7 @@ common/views/components/nav.vue:
|
||||
donors: "Sponsorzy"
|
||||
repository: "Repozytorium"
|
||||
develop: "Autorzy"
|
||||
feedback: "Opinie"
|
||||
feedback: "Podziel się opinią"
|
||||
|
||||
common/views/components/note-menu.vue:
|
||||
favorite: "Dodaj do ulubionych"
|
||||
@ -232,7 +232,7 @@ desktop/views/components/drive.nav-folder.vue:
|
||||
desktop/views/components/drive.vue:
|
||||
search: "Szukaj"
|
||||
load-more: "Załaduj więcej"
|
||||
empty-drive: "Twój dysk jest posty"
|
||||
empty-drive: "Twój dysk jest pusty"
|
||||
empty-drive-description: "Możesz wysłać plik klikając prawym przyciskiem myszy i wybierając \"Wyślij plik\" lub przeciągnąć plik i upuścić w tym oknie."
|
||||
empty-folder: "Ten katalog jest posty"
|
||||
unable-to-process: "Nie udało się dokończyć działania."
|
||||
@ -240,6 +240,7 @@ desktop/views/components/drive.vue:
|
||||
unhandled-error: "Nieznany błąd"
|
||||
url-upload: "Wyślij z adresu"
|
||||
url-of-file: "Adres URL pliku, który chcesz wysłać"
|
||||
url-upload-requested: "Zaplanowano wysyłanie"
|
||||
may-take-time: "Może trochę potrwać, zanim wysyłanie zostanie ukończone."
|
||||
create-folder: "Utwórz katalog"
|
||||
folder-name: "Nazwa katalogu"
|
||||
@ -254,6 +255,7 @@ desktop/views/components/messaging-window.vue:
|
||||
desktop/views/components/notes.note.vue:
|
||||
reposted-by: "Udostępniono przez {}"
|
||||
reply: "Odpowiedz"
|
||||
renote: "Przeredaguj"
|
||||
add-reaction: "Dodaj reakcję"
|
||||
detail: "Pokaż szczegóły"
|
||||
|
||||
@ -267,11 +269,13 @@ desktop/views/components/post-form.vue:
|
||||
quote-placeholder: "Zacytuj ten wpis…"
|
||||
note: "Wyślij"
|
||||
reply: "Odpowiedz"
|
||||
posted: "Posted!"
|
||||
renote: "Przeredaguj"
|
||||
posted: "Opublikowano!"
|
||||
replied: "Odpowiedziano!"
|
||||
reposted: "Udostępniono!"
|
||||
note-failed: "Nie udało się wysłać"
|
||||
reply-failed: "Nie udało się odpowiedzieć"
|
||||
renote-failed: "Nie udało się przeredagować"
|
||||
posting: "Wysyłanie"
|
||||
attach-media-from-local: "Załącz zawartość multimedialną z komputera"
|
||||
attach-media-from-drive: "Załącz zawartość multimedialną z dysku"
|
||||
@ -289,14 +293,19 @@ desktop/views/components/post-form-window.vue:
|
||||
desktop/views/components/renote-form.vue:
|
||||
quote: "Cytuj…"
|
||||
cancel: "Anuluj"
|
||||
renote: "Przeredaguj"
|
||||
reposting: "Udostępnianie…"
|
||||
success: "Udostępniono!"
|
||||
failure: "Nie udało się przeredagować"
|
||||
|
||||
desktop/views/components/renote-form-window.vue:
|
||||
title: "Czy na pewno chcesz przeredagować ten wpis?"
|
||||
|
||||
desktop/views/components/settings.vue:
|
||||
profile: "Profil"
|
||||
notification: "Powiadomienie"
|
||||
notification: "Powiadomienia"
|
||||
apps: "Aplikacje"
|
||||
mute: "Wycisz"
|
||||
mute: "Wyciszanie"
|
||||
drive: "Dysk"
|
||||
security: "Bezpieczeństwo"
|
||||
password: "Hasło"
|
||||
@ -392,7 +401,7 @@ desktop/views/pages/user/user.followers-you-know.vue:
|
||||
no-users: "Brak użytkowników"
|
||||
|
||||
desktop/views/pages/user/user.friends.vue:
|
||||
title: "Najczęściej odpisujący"
|
||||
title: "Najbardziej aktywni"
|
||||
loading: "Ładowanie"
|
||||
no-users: "Brak użytkowników"
|
||||
|
||||
|
71
migration/2.4.0.js
Normal file
71
migration/2.4.0.js
Normal file
@ -0,0 +1,71 @@
|
||||
// for Node.js interpret
|
||||
|
||||
const chalk = require('chalk');
|
||||
const sequential = require('promise-sequential');
|
||||
|
||||
const { default: User } = require('../built/models/user');
|
||||
const { default: DriveFile } = require('../built/models/drive-file');
|
||||
|
||||
async function main() {
|
||||
const promiseGens = [];
|
||||
|
||||
const count = await User.count({});
|
||||
|
||||
let prev;
|
||||
|
||||
for (let i = 0; i < count; i++) {
|
||||
promiseGens.push(() => {
|
||||
const promise = new Promise(async (res, rej) => {
|
||||
const user = await User.findOne(prev ? {
|
||||
_id: { $gt: prev._id }
|
||||
} : {}, {
|
||||
sort: {
|
||||
_id: 1
|
||||
}
|
||||
});
|
||||
|
||||
prev = user;
|
||||
|
||||
const set = {};
|
||||
|
||||
if (user.avatarId != null) {
|
||||
const file = await DriveFile.findOne({ _id: user.avatarId });
|
||||
|
||||
if (file && file.metadata.properties.avgColor) {
|
||||
set.avatarColor = file.metadata.properties.avgColor;
|
||||
}
|
||||
}
|
||||
|
||||
if (user.bannerId != null) {
|
||||
const file = await DriveFile.findOne({ _id: user.bannerId });
|
||||
|
||||
if (file && file.metadata.properties.avgColor) {
|
||||
set.bannerColor = file.metadata.properties.avgColor;
|
||||
}
|
||||
}
|
||||
|
||||
if (Object.keys(set).length === 0) return res([i, user]);
|
||||
|
||||
User.update({
|
||||
_id: user._id
|
||||
}, {
|
||||
$set: set
|
||||
}).then(() => {
|
||||
res([i, user]);
|
||||
}).catch(rej);
|
||||
});
|
||||
|
||||
promise.then(([i, user]) => {
|
||||
console.log(chalk`{gray ${i}} {green done: {bold ${user._id}} @${user.username}}`);
|
||||
});
|
||||
|
||||
return promise;
|
||||
});
|
||||
}
|
||||
|
||||
return await sequential(promiseGens);
|
||||
}
|
||||
|
||||
main().then(() => {
|
||||
console.log('ALL DONE');
|
||||
}).catch(console.error);
|
@ -1,8 +1,8 @@
|
||||
{
|
||||
"name": "misskey",
|
||||
"author": "syuilo <i@syuilo.com>",
|
||||
"version": "2.2.0",
|
||||
"clientVersion": "1.0.5193",
|
||||
"version": "2.5.0",
|
||||
"clientVersion": "1.0.5241",
|
||||
"codename": "nighthike",
|
||||
"main": "./built/index.js",
|
||||
"private": true,
|
||||
@ -58,6 +58,7 @@
|
||||
"@types/koa-multer": "1.0.0",
|
||||
"@types/koa-router": "7.0.28",
|
||||
"@types/koa-send": "4.1.1",
|
||||
"@types/koa-views": "^2.0.3",
|
||||
"@types/koa__cors": "2.2.2",
|
||||
"@types/kue": "0.11.8",
|
||||
"@types/license-checker": "15.0.0",
|
||||
@ -68,6 +69,7 @@
|
||||
"@types/ms": "0.7.30",
|
||||
"@types/node": "9.6.6",
|
||||
"@types/nopt": "3.0.29",
|
||||
"@types/parse5": "^3.0.0",
|
||||
"@types/pug": "2.0.4",
|
||||
"@types/qrcode": "0.8.1",
|
||||
"@types/ratelimiter": "2.1.28",
|
||||
@ -146,6 +148,7 @@
|
||||
"koa-router": "7.4.0",
|
||||
"koa-send": "4.1.3",
|
||||
"koa-slow": "2.1.0",
|
||||
"koa-views": "^6.1.4",
|
||||
"kue": "0.11.6",
|
||||
"license-checker": "18.0.0",
|
||||
"loader-utils": "1.1.0",
|
||||
@ -164,6 +167,7 @@
|
||||
"object-assign-deep": "0.4.0",
|
||||
"on-build-webpack": "0.1.0",
|
||||
"os-utils": "0.0.14",
|
||||
"parse5": "^4.0.0",
|
||||
"progress-bar-webpack-plugin": "1.11.0",
|
||||
"prominence": "0.2.0",
|
||||
"promise-sequential": "^1.1.1",
|
||||
|
@ -7,7 +7,7 @@ import locale from '../../locales';
|
||||
export default class Replacer {
|
||||
private lang: string;
|
||||
|
||||
public pattern = /%i18n:([a-z_\-@\.\!]+?)%/g;
|
||||
public pattern = /%i18n:([a-z0-9_\-@\.\!]+?)%/g;
|
||||
|
||||
constructor(lang: string) {
|
||||
this.lang = lang;
|
||||
|
@ -1,3 +1,5 @@
|
||||
block vars
|
||||
|
||||
doctype html
|
||||
|
||||
!= '\n<!-- Thank you for using Misskey! @syuilo -->\n'
|
||||
@ -9,9 +11,17 @@ html
|
||||
meta(name='application-name' content='Misskey')
|
||||
meta(name='theme-color' content=themeColor)
|
||||
meta(name='referrer' content='origin')
|
||||
meta(property='og:site_name' content='Misskey')
|
||||
link(rel='manifest' href='/manifest.json')
|
||||
|
||||
title Misskey
|
||||
title
|
||||
block title
|
||||
| Misskey
|
||||
|
||||
block desc
|
||||
meta(name='description' content='A SNS')
|
||||
|
||||
block meta
|
||||
|
||||
style
|
||||
include ./../../../built/client/assets/init.css
|
||||
|
@ -1,8 +1,6 @@
|
||||
<template>
|
||||
<router-link class="mk-avatar" :to="user | userPage" :title="user | acct" :target="target" :style="{ borderRadius: clientSettings.circleIcons ? '100%' : null }">
|
||||
<img v-if="disablePreview" :src="`${user.avatarUrl}?thumbnail&size=128`" alt=""/>
|
||||
<img v-else :src="`${user.avatarUrl}?thumbnail&size=128`" alt="" v-user-preview="user.id"/>
|
||||
</router-link>
|
||||
<router-link class="mk-avatar" :to="user | userPage" :title="user | acct" :target="target" :style="style" v-if="disablePreview"></router-link>
|
||||
<router-link class="mk-avatar" :to="user | userPage" :title="user | acct" :target="target" :style="style" v-else v-user-preview="user.id"></router-link>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
@ -10,6 +8,7 @@ import Vue from 'vue';
|
||||
export default Vue.extend({
|
||||
props: {
|
||||
user: {
|
||||
type: Object,
|
||||
required: true
|
||||
},
|
||||
target: {
|
||||
@ -20,6 +19,15 @@ export default Vue.extend({
|
||||
required: false,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
style(): any {
|
||||
return {
|
||||
backgroundColor: this.user.avatarColor ? `rgb(${ this.user.avatarColor.join(',') })` : null,
|
||||
backgroundImage: `url(${ this.user.avatarUrl }?thumbnail)`,
|
||||
borderRadius: (this as any).clientSettings.circleIcons ? '100%' : null
|
||||
};
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@ -27,13 +35,8 @@ export default Vue.extend({
|
||||
<style lang="stylus" scoped>
|
||||
.mk-avatar
|
||||
display inline-block
|
||||
|
||||
> img
|
||||
display inline-block
|
||||
width 100%
|
||||
height 100%
|
||||
margin 0
|
||||
border-radius inherit
|
||||
vertical-align bottom
|
||||
transition border-radius 1s ease
|
||||
vertical-align bottom
|
||||
background-size cover
|
||||
background-position center center
|
||||
transition border-radius 1s ease
|
||||
</style>
|
||||
|
@ -333,7 +333,7 @@ root(isDark)
|
||||
|
||||
> .renote
|
||||
display flex
|
||||
align-items baseline
|
||||
align-items center
|
||||
padding 16px 32px
|
||||
line-height 28px
|
||||
color #9dbb00
|
||||
|
@ -105,21 +105,11 @@ export default Vue.extend({
|
||||
}
|
||||
},
|
||||
|
||||
watch: {
|
||||
text() {
|
||||
this.saveDraft();
|
||||
},
|
||||
|
||||
poll() {
|
||||
this.saveDraft();
|
||||
},
|
||||
|
||||
files() {
|
||||
this.saveDraft();
|
||||
}
|
||||
},
|
||||
|
||||
mounted() {
|
||||
if (this.reply && this.reply.user.host != null) {
|
||||
this.text = `@${this.reply.user.username}@${this.reply.user.host} `;
|
||||
}
|
||||
|
||||
this.$nextTick(() => {
|
||||
// 書きかけの投稿を復元
|
||||
const draft = JSON.parse(localStorage.getItem('drafts') || '{}')[this.draftId];
|
||||
@ -134,10 +124,18 @@ export default Vue.extend({
|
||||
}
|
||||
this.$emit('change-attached-media', this.files);
|
||||
}
|
||||
|
||||
this.$nextTick(() => this.watch());
|
||||
});
|
||||
},
|
||||
|
||||
methods: {
|
||||
watch() {
|
||||
this.$watch('text', () => this.saveDraft());
|
||||
this.$watch('poll', () => this.saveDraft());
|
||||
this.$watch('files', () => this.saveDraft());
|
||||
},
|
||||
|
||||
focus() {
|
||||
(this.$refs.text as any).focus();
|
||||
},
|
||||
|
@ -31,6 +31,12 @@ export default Vue.extend({
|
||||
};
|
||||
},
|
||||
|
||||
created() {
|
||||
if ((this as any).os.i.followingCount == 0) {
|
||||
this.src = 'local';
|
||||
}
|
||||
},
|
||||
|
||||
mounted() {
|
||||
(this.$refs.tl as any).$once('loaded', () => {
|
||||
this.$emit('loaded');
|
||||
|
@ -2,8 +2,8 @@
|
||||
<div class="header" :data-is-dark-background="user.bannerUrl != null">
|
||||
<div class="is-suspended" v-if="user.isSuspended"><p>%fa:exclamation-triangle% %i18n:@is-suspended%</p></div>
|
||||
<div class="is-remote" v-if="user.host != null"><p>%fa:exclamation-triangle% %i18n:@is-remote%<a :href="user.url || user.uri" target="_blank">%i18n:@view-remote%</a></p></div>
|
||||
<div class="banner-container" :style="user.bannerUrl ? `background-image: url(${user.bannerUrl})` : ''">
|
||||
<div class="banner" ref="banner" :style="user.bannerUrl ? `background-image: url(${user.bannerUrl})` : ''" @click="onBannerClick"></div>
|
||||
<div class="banner-container" :style="style">
|
||||
<div class="banner" ref="banner" :style="style" @click="onBannerClick"></div>
|
||||
<div class="fade"></div>
|
||||
</div>
|
||||
<div class="container">
|
||||
@ -25,6 +25,15 @@ import Vue from 'vue';
|
||||
|
||||
export default Vue.extend({
|
||||
props: ['user'],
|
||||
computed: {
|
||||
style(): any {
|
||||
if (this.user.bannerUrl == null) return {};
|
||||
return {
|
||||
backgroundColor: this.user.bannerColor ? `rgb(${ this.user.bannerColor.join(',') })` : null,
|
||||
backgroundImage: `url(${ this.user.bannerUrl })`
|
||||
};
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
if (this.user.bannerUrl) {
|
||||
window.addEventListener('load', this.onScroll);
|
||||
|
@ -252,7 +252,7 @@ root(isDark)
|
||||
|
||||
> .renote
|
||||
display flex
|
||||
align-items baseline
|
||||
align-items center
|
||||
padding 8px 16px
|
||||
line-height 28px
|
||||
color #9dbb00
|
||||
|
@ -188,6 +188,11 @@ export default Vue.extend({
|
||||
}
|
||||
|
||||
if ((this as any).clientSettings.fetchOnScroll !== false) {
|
||||
// 親要素が display none だったら弾く
|
||||
// https://github.com/syuilo/misskey/issues/1569
|
||||
// http://d.hatena.ne.jp/favril/20091105/1257403319
|
||||
if (this.$el.offsetHeight == 0) return;
|
||||
|
||||
const current = window.scrollY + window.innerHeight;
|
||||
if (current > document.body.offsetHeight - 8) this.loadMore();
|
||||
}
|
||||
|
@ -25,13 +25,15 @@
|
||||
</div>
|
||||
<mk-poll-editor v-if="poll" ref="poll" @destroyed="poll = false"/>
|
||||
<mk-uploader ref="uploader" @uploaded="attachMedia" @change="onChangeUploadings"/>
|
||||
<button class="upload" @click="chooseFile">%fa:upload%</button>
|
||||
<button class="drive" @click="chooseFileFromDrive">%fa:cloud%</button>
|
||||
<button class="kao" @click="kao">%fa:R smile%</button>
|
||||
<button class="poll" @click="poll = true">%fa:chart-pie%</button>
|
||||
<button class="poll" @click="useCw = !useCw">%fa:eye-slash%</button>
|
||||
<button class="geo" @click="geo ? removeGeo() : setGeo()">%fa:map-marker-alt%</button>
|
||||
<button class="visibility" @click="setVisibility" ref="visibilityButton">%fa:lock%</button>
|
||||
<footer>
|
||||
<button class="upload" @click="chooseFile">%fa:upload%</button>
|
||||
<button class="drive" @click="chooseFileFromDrive">%fa:cloud%</button>
|
||||
<button class="kao" @click="kao">%fa:R smile%</button>
|
||||
<button class="poll" @click="poll = true">%fa:chart-pie%</button>
|
||||
<button class="poll" @click="useCw = !useCw">%fa:eye-slash%</button>
|
||||
<button class="geo" @click="geo ? removeGeo() : setGeo()">%fa:map-marker-alt%</button>
|
||||
<button class="visibility" @click="setVisibility" ref="visibilityButton">%fa:lock%</button>
|
||||
</footer>
|
||||
<input ref="file" class="file" type="file" accept="image/*" multiple="multiple" @change="onChangeFile"/>
|
||||
</div>
|
||||
</div>
|
||||
@ -67,6 +69,10 @@ export default Vue.extend({
|
||||
},
|
||||
|
||||
mounted() {
|
||||
if (this.reply && this.reply.user.host != null) {
|
||||
this.text = `@${this.reply.user.username}@${this.reply.user.host} `;
|
||||
}
|
||||
|
||||
this.$nextTick(() => {
|
||||
this.focus();
|
||||
});
|
||||
@ -332,24 +338,25 @@ root(isDark)
|
||||
> .file
|
||||
display none
|
||||
|
||||
> .upload
|
||||
> .drive
|
||||
> .kao
|
||||
> .poll
|
||||
> .geo
|
||||
> .visibility
|
||||
display inline-block
|
||||
padding 0
|
||||
margin 0
|
||||
width 48px
|
||||
height 48px
|
||||
font-size 20px
|
||||
color #657786
|
||||
background transparent
|
||||
outline none
|
||||
border none
|
||||
border-radius 0
|
||||
box-shadow none
|
||||
> footer
|
||||
white-space nowrap
|
||||
overflow auto
|
||||
-webkit-overflow-scrolling touch
|
||||
overflow-scrolling touch
|
||||
|
||||
> *
|
||||
display inline-block
|
||||
padding 0
|
||||
margin 0
|
||||
width 48px
|
||||
height 48px
|
||||
font-size 20px
|
||||
color #657786
|
||||
background transparent
|
||||
outline none
|
||||
border none
|
||||
border-radius 0
|
||||
box-shadow none
|
||||
|
||||
.mk-post-form[data-darkmode]
|
||||
root(true)
|
||||
|
@ -75,6 +75,12 @@ export default Vue.extend({
|
||||
}
|
||||
},
|
||||
|
||||
created() {
|
||||
if ((this as any).os.i.followingCount == 0) {
|
||||
this.src = 'local';
|
||||
}
|
||||
},
|
||||
|
||||
mounted() {
|
||||
document.title = 'Misskey';
|
||||
|
||||
|
@ -5,11 +5,11 @@
|
||||
<div class="is-suspended" v-if="user.isSuspended"><p>%fa:exclamation-triangle% %i18n:@is-suspended%</p></div>
|
||||
<div class="is-remote" v-if="user.host != null"><p>%fa:exclamation-triangle% %i18n:@is-remote%<a :href="user.url || user.uri" target="_blank">%i18n:@view-remote%</a></p></div>
|
||||
<header>
|
||||
<div class="banner" :style="user.bannerUrl ? `background-image: url(${user.bannerUrl})` : ''"></div>
|
||||
<div class="banner" :style="style"></div>
|
||||
<div class="body">
|
||||
<div class="top">
|
||||
<a class="avatar">
|
||||
<img :src="`${user.avatarUrl}?thumbnail&size=200`" alt="avatar"/>
|
||||
<img :src="user.avatarUrl" alt="avatar"/>
|
||||
</a>
|
||||
<mk-follow-button v-if="os.isSignedIn && os.i.id != user.id" :user="user"/>
|
||||
</div>
|
||||
@ -80,6 +80,13 @@ export default Vue.extend({
|
||||
computed: {
|
||||
age(): number {
|
||||
return age(this.user.profile.birthday);
|
||||
},
|
||||
style(): any {
|
||||
if (this.user.bannerUrl == null) return {};
|
||||
return {
|
||||
backgroundColor: this.user.bannerColor ? `rgb(${ this.user.bannerColor.join(',') })` : null,
|
||||
backgroundImage: `url(${ this.user.bannerUrl })`
|
||||
};
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
|
@ -14,13 +14,13 @@ mixin propTable(props)
|
||||
if prop.kind == 'id'
|
||||
if prop.entity
|
||||
| (
|
||||
a(href=`/${lang}/api/entities/${kebab(prop.entity)}`)= prop.entity
|
||||
a(href=`/docs/${lang}/api/entities/${kebab(prop.entity)}`)= prop.entity
|
||||
| ID)
|
||||
else
|
||||
| (ID)
|
||||
else if prop.kind == 'entity'
|
||||
| (
|
||||
a(href=`/${lang}/api/entities/${kebab(prop.entity)}`)= prop.entity
|
||||
a(href=`/docs/${lang}/api/entities/${kebab(prop.entity)}`)= prop.entity
|
||||
| )
|
||||
else if prop.kind == 'object'
|
||||
if prop.def
|
||||
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"copyright": "Copyright (c) 2014-2018 syuilo",
|
||||
"themeColor": "#5cbb2d",
|
||||
"themeColor": "#f66e4f",
|
||||
"themeColorForeground": "#fff"
|
||||
}
|
||||
|
@ -286,7 +286,7 @@ export const pack = async (
|
||||
_id: -1
|
||||
}
|
||||
});
|
||||
return prev ? prev._id : null;
|
||||
return prev ? prev._id.toHexString() : null;
|
||||
})();
|
||||
|
||||
// Get next note info
|
||||
@ -304,7 +304,7 @@ export const pack = async (
|
||||
_id: 1
|
||||
}
|
||||
});
|
||||
return next ? next._id : null;
|
||||
return next ? next._id.toHexString() : null;
|
||||
})();
|
||||
|
||||
if (_note.replyId) {
|
||||
|
@ -2,6 +2,7 @@ import { createQueue } from 'kue';
|
||||
|
||||
import config from '../config';
|
||||
import http from './processors/http';
|
||||
import { ILocalUser } from '../models/user';
|
||||
|
||||
const queue = createQueue({
|
||||
redis: {
|
||||
@ -20,7 +21,7 @@ export function createHttp(data) {
|
||||
.backoff({ delay: 16384, type: 'exponential' });
|
||||
}
|
||||
|
||||
export function deliver(user, content, to) {
|
||||
export function deliver(user: ILocalUser, content, to) {
|
||||
createHttp({
|
||||
title: 'deliver',
|
||||
type: 'deliver',
|
||||
|
@ -7,6 +7,7 @@ export default async (job: kue.Job, done): Promise<void> => {
|
||||
await request(job.data.user, job.data.to, job.data.content);
|
||||
done();
|
||||
} catch (res) {
|
||||
if (res.statusCode == null) return done();
|
||||
if (res.statusCode >= 400 && res.statusCode < 500) {
|
||||
// HTTPステータスコード4xxはクライアントエラーであり、それはつまり
|
||||
// 何回再送しても成功することはないということなのでエラーにはしないでおく
|
||||
|
@ -11,7 +11,12 @@ export default function(note: INote) {
|
||||
if (note.poll != null) {
|
||||
const url = `${config.url}/notes/${note._id}`;
|
||||
// TODO: i18n
|
||||
html += `<p>【投票】<br />${url}</p>`;
|
||||
html += `<p><a href="${url}">【Misskeyで投票を見る】</a></p>`;
|
||||
}
|
||||
|
||||
if (note.renoteId != null) {
|
||||
const url = `${config.url}/notes/${note.renoteId}`;
|
||||
html += `<p>RE: <a href="${url}">${url}</a></p>`;
|
||||
}
|
||||
|
||||
return html;
|
||||
|
@ -1,5 +1,5 @@
|
||||
import * as mongo from 'mongodb';
|
||||
import { JSDOM } from 'jsdom';
|
||||
import * as parse5 from 'parse5';
|
||||
import * as debug from 'debug';
|
||||
|
||||
import config from '../../../config';
|
||||
@ -13,6 +13,82 @@ import { IRemoteUser } from '../../../models/user';
|
||||
|
||||
const log = debug('misskey:activitypub');
|
||||
|
||||
function parse(html: string): string {
|
||||
const dom = parse5.parseFragment(html) as parse5.AST.Default.Document;
|
||||
|
||||
let text = '';
|
||||
|
||||
dom.childNodes.forEach(n => analyze(n));
|
||||
|
||||
return text.trim();
|
||||
|
||||
function getText(node) {
|
||||
if (node.nodeName == '#text') return node.value;
|
||||
|
||||
if (node.childNodes) {
|
||||
return node.childNodes.map(n => getText(n)).join('');
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
function analyze(node) {
|
||||
switch (node.nodeName) {
|
||||
case '#text':
|
||||
text += node.value;
|
||||
break;
|
||||
|
||||
case 'br':
|
||||
text += '\n';
|
||||
break;
|
||||
|
||||
case 'a':
|
||||
const cls = node.attrs
|
||||
? (node.attrs.find(x => x.name == 'class') || { value: '' }).value.split(' ')
|
||||
: [];
|
||||
|
||||
// for Mastodon
|
||||
if (cls.includes('mention')) {
|
||||
const mention = getText(node);
|
||||
|
||||
const part = mention.split('@');
|
||||
|
||||
if (part.length == 2) {
|
||||
//#region ホスト名部分が省略されているので復元する
|
||||
|
||||
const href = new URL(node.attrs.find(x => x.name == 'href').value);
|
||||
const acct = mention + '@' + href.hostname;
|
||||
text += acct;
|
||||
break;
|
||||
|
||||
//#endregion
|
||||
} else if (part.length == 3) {
|
||||
text += mention;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (node.childNodes) {
|
||||
node.childNodes.forEach(n => analyze(n));
|
||||
}
|
||||
break;
|
||||
|
||||
case 'p':
|
||||
text += '\n\n';
|
||||
if (node.childNodes) {
|
||||
node.childNodes.forEach(n => analyze(n));
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
if (node.childNodes) {
|
||||
node.childNodes.forEach(n => analyze(n));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Noteをフェッチします。
|
||||
*
|
||||
@ -87,9 +163,8 @@ export async function createNote(value: any, resolver?: Resolver, silent = false
|
||||
// リプライ
|
||||
const reply = note.inReplyTo ? await resolveNote(note.inReplyTo, resolver) : null;
|
||||
|
||||
// MastodonはHTMLを送り付けてくる
|
||||
// そして改行は<br />で表現されている
|
||||
const { window } = new JSDOM(note.content.replace(/<br \/>/g, '\n'));
|
||||
// テキストのパース
|
||||
const text = parse(note.content);
|
||||
|
||||
// ユーザーの情報が古かったらついでに更新しておく
|
||||
if (actor.updatedAt == null || Date.now() - actor.updatedAt.getTime() > 1000 * 60 * 60 * 24) {
|
||||
@ -101,7 +176,7 @@ export async function createNote(value: any, resolver?: Resolver, silent = false
|
||||
media,
|
||||
reply,
|
||||
renote: undefined,
|
||||
text: window.document.body.textContent,
|
||||
text: text,
|
||||
viaMobile: false,
|
||||
geo: undefined,
|
||||
visibility,
|
||||
|
@ -15,6 +15,7 @@ export interface IObject {
|
||||
icon?: any;
|
||||
image?: any;
|
||||
url?: string;
|
||||
tag?: any[];
|
||||
}
|
||||
|
||||
export interface IActivity extends IObject {
|
||||
|
@ -1,11 +1,16 @@
|
||||
import { toUnicode, toASCII } from 'punycode';
|
||||
import User from '../models/user';
|
||||
import User, { IUser } from '../models/user';
|
||||
import webFinger from './webfinger';
|
||||
import config from '../config';
|
||||
import { createPerson } from './activitypub/models/person';
|
||||
|
||||
export default async (username, _host, option) => {
|
||||
export default async (username, _host, option?): Promise<IUser> => {
|
||||
const usernameLower = username.toLowerCase();
|
||||
|
||||
if (_host == null) {
|
||||
return await User.findOne({ usernameLower });
|
||||
}
|
||||
|
||||
const hostAscii = toASCII(_host).toLowerCase();
|
||||
const host = toUnicode(hostAscii);
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/**
|
||||
* 投稿を表す文字列を取得します。
|
||||
* @param {*} note 投稿
|
||||
* @param {*} note (packされた)投稿
|
||||
*/
|
||||
const summarize = (note: any): string => {
|
||||
if (note.isHidden) {
|
||||
|
@ -4,6 +4,7 @@
|
||||
import $ from 'cafy'; import ID from '../../../../cafy-id';
|
||||
import User, { isValidName, isValidDescription, isValidLocation, isValidBirthday, pack } from '../../../../models/user';
|
||||
import event from '../../../../publishers/stream';
|
||||
import DriveFile from '../../../../models/drive-file';
|
||||
|
||||
/**
|
||||
* Update myself
|
||||
@ -51,12 +52,34 @@ module.exports = async (params, user, app) => new Promise(async (res, rej) => {
|
||||
if (autoWatchErr) return rej('invalid autoWatch param');
|
||||
if (autoWatch != null) user.settings.autoWatch = autoWatch;
|
||||
|
||||
if (avatarId) {
|
||||
const avatar = await DriveFile.findOne({
|
||||
_id: avatarId
|
||||
});
|
||||
|
||||
if (avatar != null && avatar.metadata.properties.avgColor) {
|
||||
user.avatarColor = avatar.metadata.properties.avgColor;
|
||||
}
|
||||
}
|
||||
|
||||
if (bannerId) {
|
||||
const banner = await DriveFile.findOne({
|
||||
_id: bannerId
|
||||
});
|
||||
|
||||
if (banner != null && banner.metadata.properties.avgColor) {
|
||||
user.bannerColor = banner.metadata.properties.avgColor;
|
||||
}
|
||||
}
|
||||
|
||||
await User.update(user._id, {
|
||||
$set: {
|
||||
name: user.name,
|
||||
description: user.description,
|
||||
avatarId: user.avatarId,
|
||||
avatarColor: user.avatarColor,
|
||||
bannerId: user.bannerId,
|
||||
bannerColor: user.bannerColor,
|
||||
profile: user.profile,
|
||||
isBot: user.isBot,
|
||||
settings: user.settings
|
||||
|
@ -7,14 +7,32 @@ import * as Koa from 'koa';
|
||||
import * as Router from 'koa-router';
|
||||
import * as send from 'koa-send';
|
||||
import * as favicon from 'koa-favicon';
|
||||
import * as views from 'koa-views';
|
||||
|
||||
import docs from './docs';
|
||||
import User from '../../models/user';
|
||||
import parseAcct from '../../acct/parse';
|
||||
import { fa } from '../../build/fa';
|
||||
import config from '../../config';
|
||||
import Note, { pack as packNote } from '../../models/note';
|
||||
import getNoteSummary from '../../renderers/get-note-summary';
|
||||
const consts = require('../../const.json');
|
||||
|
||||
const client = `${__dirname}/../../client/`;
|
||||
|
||||
// Init app
|
||||
const app = new Koa();
|
||||
|
||||
// Init renderer
|
||||
app.use(views(__dirname + '/views', {
|
||||
extension: 'pug',
|
||||
options: {
|
||||
config,
|
||||
themeColor: consts.themeColor,
|
||||
facss: fa.dom.css()
|
||||
}
|
||||
}));
|
||||
|
||||
// Serve favicon
|
||||
app.use(favicon(`${client}/assets/favicon.ico`));
|
||||
|
||||
@ -67,6 +85,38 @@ router.use('/docs', docs.routes());
|
||||
// URL preview endpoint
|
||||
router.get('/url', require('./url-preview'));
|
||||
|
||||
//#region for crawlers
|
||||
// User
|
||||
router.get('/@:user', async ctx => {
|
||||
const { username, host } = parseAcct(ctx.params.user);
|
||||
const user = await User.findOne({
|
||||
usernameLower: username.toLowerCase(),
|
||||
host
|
||||
});
|
||||
|
||||
if (user != null) {
|
||||
await ctx.render('user', { user });
|
||||
} else {
|
||||
ctx.status = 404;
|
||||
}
|
||||
});
|
||||
|
||||
// Note
|
||||
router.get('/notes/:note', async ctx => {
|
||||
const note = await Note.findOne({ _id: ctx.params.note });
|
||||
|
||||
if (note != null) {
|
||||
const _note = await packNote(note);
|
||||
await ctx.render('note', {
|
||||
note: _note,
|
||||
summary: getNoteSummary(_note)
|
||||
});
|
||||
} else {
|
||||
ctx.status = 404;
|
||||
}
|
||||
});
|
||||
//#endregion
|
||||
|
||||
// Render base html for all requests
|
||||
router.get('*', async ctx => {
|
||||
await send(ctx, `app/base.html`, {
|
||||
|
@ -14,6 +14,8 @@ module.exports = async (ctx: Koa.Context) => {
|
||||
|
||||
function wrap(url: string): string {
|
||||
return url != null
|
||||
? `https://images.weserv.nl/?url=${url.replace(/^https?:\/\//, '')}`
|
||||
? url.startsWith('https://')
|
||||
? url
|
||||
: `https://images.weserv.nl/?url=${url.replace(/^http:\/\//, '')}`
|
||||
: null;
|
||||
}
|
||||
|
25
src/server/web/views/note.pug
Normal file
25
src/server/web/views/note.pug
Normal file
@ -0,0 +1,25 @@
|
||||
extends ../../../../src/client/app/base
|
||||
|
||||
block vars
|
||||
- const user = note.user;
|
||||
- const title = user.name ? `${user.name} (@${user.username})` : `@${user.username}`;
|
||||
- const url = `${config.url}/notes/${note.id}`;
|
||||
|
||||
block title
|
||||
= `${title} | Misskey`
|
||||
|
||||
block desc
|
||||
meta(name='description' content= summary)
|
||||
|
||||
block meta
|
||||
meta(name='twitter:card' content='summary')
|
||||
meta(property='og:type' content='article')
|
||||
meta(property='og:title' content= title)
|
||||
meta(property='og:description' content= summary)
|
||||
meta(property='og:url' content= url)
|
||||
meta(property='og:image' content= user.avatarUrl)
|
||||
|
||||
if note.prev
|
||||
link(rel='prev' href=`${config.url}/notes/${note.prev}`)
|
||||
if note.next
|
||||
link(rel='next' href=`${config.url}/notes/${note.next}`)
|
20
src/server/web/views/user.pug
Normal file
20
src/server/web/views/user.pug
Normal file
@ -0,0 +1,20 @@
|
||||
extends ../../../../src/client/app/base
|
||||
|
||||
block vars
|
||||
- const title = user.name ? `${user.name} (@${user.username})` : `@${user.username}`;
|
||||
- const url = config.url + '/@' + (user.host ? `${user.username}@${user.host}` : user.username);
|
||||
- const img = user.avatarId ? `${config.drive_url}/${user.avatarId}` : null;
|
||||
|
||||
block title
|
||||
= `${title} | Misskey`
|
||||
|
||||
block desc
|
||||
meta(name='description' content= user.description)
|
||||
|
||||
block meta
|
||||
meta(name='twitter:card' content='summary')
|
||||
meta(property='og:type' content='blog')
|
||||
meta(property='og:title' content= title)
|
||||
meta(property='og:description' content= user.description)
|
||||
meta(property='og:url' content= url)
|
||||
meta(property='og:image' content= img)
|
@ -1,5 +1,5 @@
|
||||
import Note, { pack, INote } from '../../models/note';
|
||||
import User, { isLocalUser, IUser, isRemoteUser } from '../../models/user';
|
||||
import User, { isLocalUser, IUser, isRemoteUser, IRemoteUser, ILocalUser } from '../../models/user';
|
||||
import stream, { publishLocalTimelineStream, publishGlobalTimelineStream, publishUserListStream } from '../../publishers/stream';
|
||||
import Following from '../../models/following';
|
||||
import { deliver } from '../../queue';
|
||||
@ -17,6 +17,62 @@ import event from '../../publishers/stream';
|
||||
import parse from '../../text/parse';
|
||||
import { IApp } from '../../models/app';
|
||||
import UserList from '../../models/user-list';
|
||||
import resolveUser from '../../remote/resolve-user';
|
||||
|
||||
type Reason = 'reply' | 'quote' | 'mention';
|
||||
|
||||
/**
|
||||
* ServiceWorkerへの通知を担当
|
||||
*/
|
||||
class NotificationManager {
|
||||
private user: IUser;
|
||||
private note: any;
|
||||
private list: Array<{
|
||||
user: ILocalUser['_id'],
|
||||
reason: Reason;
|
||||
}> = [];
|
||||
|
||||
constructor(user, note) {
|
||||
this.user = user;
|
||||
this.note = note;
|
||||
}
|
||||
|
||||
public push(user: ILocalUser['_id'], reason: Reason) {
|
||||
// 自分自身へは通知しない
|
||||
if (this.user._id.equals(user)) return;
|
||||
|
||||
const exist = this.list.find(x => x.user.equals(user));
|
||||
|
||||
if (exist) {
|
||||
// 「メンションされているかつ返信されている」場合は、メンションとしての通知ではなく返信としての通知にする
|
||||
if (reason != 'mention') {
|
||||
exist.reason = reason;
|
||||
}
|
||||
} else {
|
||||
this.list.push({
|
||||
user, reason
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public deliver() {
|
||||
this.list.forEach(async x => {
|
||||
const mentionee = x.user;
|
||||
|
||||
// ミュート情報を取得
|
||||
const mentioneeMutes = await Mute.find({
|
||||
muterId: mentionee
|
||||
});
|
||||
|
||||
const mentioneesMutedUserIds = mentioneeMutes.map(m => m.muteeId.toString());
|
||||
|
||||
// 通知される側のユーザーが通知する側のユーザーをミュートしていない限りは通知する
|
||||
if (!mentioneesMutedUserIds.includes(this.user._id.toString())) {
|
||||
pushSw(mentionee, x.reason, this.note);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export default async (user: IUser, data: {
|
||||
createdAt?: Date;
|
||||
@ -40,7 +96,7 @@ export default async (user: IUser, data: {
|
||||
|
||||
const tags = data.tags || [];
|
||||
|
||||
let tokens = null;
|
||||
let tokens: any[] = null;
|
||||
|
||||
if (data.text) {
|
||||
// Analyze
|
||||
@ -119,152 +175,142 @@ export default async (user: IUser, data: {
|
||||
// Serialize
|
||||
const noteObj = await pack(note);
|
||||
|
||||
// タイムラインへの投稿
|
||||
if (note.channelId == null) {
|
||||
if (!silent) {
|
||||
if (isLocalUser(user)) {
|
||||
if (note.visibility == 'private' || note.visibility == 'followers' || note.visibility == 'specified') {
|
||||
// Publish event to myself's stream
|
||||
stream(note.userId, 'note', await pack(note, user, {
|
||||
detail: true
|
||||
}));
|
||||
} else {
|
||||
// Publish event to myself's stream
|
||||
stream(note.userId, 'note', noteObj);
|
||||
const nm = new NotificationManager(user, noteObj);
|
||||
|
||||
// Publish note to local timeline stream
|
||||
if (note.visibility != 'home') {
|
||||
publishLocalTimelineStream(noteObj);
|
||||
}
|
||||
const render = async () => {
|
||||
const content = data.renote && data.text == null
|
||||
? renderAnnounce(data.renote.uri ? data.renote.uri : await renderNote(data.renote))
|
||||
: renderCreate(await renderNote(note));
|
||||
return packAp(content);
|
||||
};
|
||||
|
||||
if (!silent) {
|
||||
if (isLocalUser(user)) {
|
||||
if (note.visibility == 'private' || note.visibility == 'followers' || note.visibility == 'specified') {
|
||||
// Publish event to myself's stream
|
||||
stream(note.userId, 'note', await pack(note, user, {
|
||||
detail: true
|
||||
}));
|
||||
} else {
|
||||
// Publish event to myself's stream
|
||||
stream(note.userId, 'note', noteObj);
|
||||
|
||||
// Publish note to local timeline stream
|
||||
if (note.visibility != 'home') {
|
||||
publishLocalTimelineStream(noteObj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Publish note to global timeline stream
|
||||
publishGlobalTimelineStream(noteObj);
|
||||
// Publish note to global timeline stream
|
||||
publishGlobalTimelineStream(noteObj);
|
||||
|
||||
if (note.visibility == 'specified') {
|
||||
data.visibleUsers.forEach(async u => {
|
||||
stream(u._id, 'note', await pack(note, u, {
|
||||
detail: true
|
||||
}));
|
||||
});
|
||||
}
|
||||
if (note.visibility == 'specified') {
|
||||
data.visibleUsers.forEach(async u => {
|
||||
stream(u._id, 'note', await pack(note, u, {
|
||||
detail: true
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
if (note.visibility == 'public' || note.visibility == 'home' || note.visibility == 'followers') {
|
||||
// フォロワーに配信
|
||||
Following.find({
|
||||
followeeId: note.userId
|
||||
}).then(followers => {
|
||||
followers.map(async following => {
|
||||
const follower = following._follower;
|
||||
if (note.visibility == 'public' || note.visibility == 'home' || note.visibility == 'followers') {
|
||||
// フォロワーに配信
|
||||
Following.find({
|
||||
followeeId: note.userId
|
||||
}).then(followers => {
|
||||
followers.map(async following => {
|
||||
const follower = following._follower;
|
||||
|
||||
if (isLocalUser(follower)) {
|
||||
// ストーキングしていない場合
|
||||
if (!following.stalk) {
|
||||
// この投稿が返信ならスキップ
|
||||
if (note.replyId && !note._reply.userId.equals(following.followerId) && !note._reply.userId.equals(note.userId)) return;
|
||||
}
|
||||
|
||||
// Publish event to followers stream
|
||||
stream(following.followerId, 'note', noteObj);
|
||||
} else {
|
||||
//#region AP配送
|
||||
// フォロワーがリモートユーザーかつ投稿者がローカルユーザーなら投稿を配信
|
||||
if (isLocalUser(user)) {
|
||||
deliver(user, await render(), follower.inbox);
|
||||
}
|
||||
//#endergion
|
||||
if (isLocalUser(follower)) {
|
||||
// ストーキングしていない場合
|
||||
if (!following.stalk) {
|
||||
// この投稿が返信ならスキップ
|
||||
if (note.replyId && !note._reply.userId.equals(following.followerId) && !note._reply.userId.equals(note.userId)) return;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// リストに配信
|
||||
UserList.find({
|
||||
userIds: note.userId
|
||||
}).then(lists => {
|
||||
lists.forEach(list => {
|
||||
publishUserListStream(list._id, 'note', noteObj);
|
||||
// Publish event to followers stream
|
||||
stream(following.followerId, 'note', noteObj);
|
||||
} else {
|
||||
//#region AP配送
|
||||
// フォロワーがリモートユーザーかつ投稿者がローカルユーザーなら投稿を配信
|
||||
if (isLocalUser(user)) {
|
||||
deliver(user, await render(), follower.inbox);
|
||||
}
|
||||
//#endergion
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
//#region リプライとAnnounceのAP配送
|
||||
const render = async () => {
|
||||
const content = data.renote && data.text == null
|
||||
? renderAnnounce(data.renote.uri ? data.renote.uri : await renderNote(data.renote))
|
||||
: renderCreate(await renderNote(note));
|
||||
return packAp(content);
|
||||
};
|
||||
|
||||
// 投稿がリプライかつ投稿者がローカルユーザーかつリプライ先の投稿の投稿者がリモートユーザーなら配送
|
||||
if (data.reply && isLocalUser(user) && isRemoteUser(data.reply._user)) {
|
||||
deliver(user, await render(), data.reply._user.inbox);
|
||||
}
|
||||
|
||||
// 投稿がRenoteかつ投稿者がローカルユーザーかつRenote元の投稿の投稿者がリモートユーザーなら配送
|
||||
if (data.renote && isLocalUser(user) && isRemoteUser(data.renote._user)) {
|
||||
deliver(user, await render(), data.renote._user.inbox);
|
||||
}
|
||||
//#endergion
|
||||
// リストに配信
|
||||
UserList.find({
|
||||
userIds: note.userId
|
||||
}).then(lists => {
|
||||
lists.forEach(list => {
|
||||
publishUserListStream(list._id, 'note', noteObj);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// チャンネルへの投稿
|
||||
/* TODO
|
||||
if (note.channelId) {
|
||||
promises.push(
|
||||
// Increment channel index(notes count)
|
||||
Channel.update({ _id: note.channelId }, {
|
||||
$inc: {
|
||||
index: 1
|
||||
//#region リプライとAnnounceのAP配送
|
||||
|
||||
// 投稿がリプライかつ投稿者がローカルユーザーかつリプライ先の投稿の投稿者がリモートユーザーなら配送
|
||||
if (data.reply && isLocalUser(user) && isRemoteUser(data.reply._user)) {
|
||||
deliver(user, await render(), data.reply._user.inbox);
|
||||
}
|
||||
|
||||
// 投稿がRenoteかつ投稿者がローカルユーザーかつRenote元の投稿の投稿者がリモートユーザーなら配送
|
||||
if (data.renote && isLocalUser(user) && isRemoteUser(data.renote._user)) {
|
||||
deliver(user, await render(), data.renote._user.inbox);
|
||||
}
|
||||
//#endergion
|
||||
|
||||
//#region メンション
|
||||
if (data.text) {
|
||||
// TODO: Drop dupulicates
|
||||
const mentions = tokens
|
||||
.filter(t => t.type == 'mention');
|
||||
|
||||
let mentionedUsers = await Promise.all(mentions.map(async m => {
|
||||
try {
|
||||
return await resolveUser(m.username, m.host);
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
}));
|
||||
|
||||
// TODO: Drop dupulicates
|
||||
mentionedUsers = mentionedUsers.filter(x => x != null);
|
||||
|
||||
mentionedUsers.filter(u => isLocalUser(u)).forEach(async u => {
|
||||
// 既に言及されたユーザーに対する返信や引用renoteの場合も無視
|
||||
if (data.reply && data.reply.userId.equals(u._id)) return;
|
||||
if (data.renote && data.renote.userId.equals(u._id)) return;
|
||||
|
||||
// Create notification
|
||||
notify(u._id, user._id, 'mention', {
|
||||
noteId: note._id
|
||||
});
|
||||
|
||||
nm.push(u._id, 'mention');
|
||||
});
|
||||
|
||||
if (isLocalUser(user)) {
|
||||
mentionedUsers.filter(u => isRemoteUser(u)).forEach(async u => {
|
||||
deliver(user, await render(), (u as IRemoteUser).inbox);
|
||||
});
|
||||
}
|
||||
|
||||
// Append mentions data
|
||||
if (mentionedUsers.length > 0) {
|
||||
Note.update({ _id: note._id }, {
|
||||
$set: {
|
||||
mentions: mentionedUsers.map(u => u._id)
|
||||
}
|
||||
}),
|
||||
|
||||
// Publish event to channel
|
||||
promisedNoteObj.then(noteObj => {
|
||||
publishChannelStream(note.channelId, 'note', noteObj);
|
||||
}),
|
||||
|
||||
Promise.all([
|
||||
promisedNoteObj,
|
||||
|
||||
// Get channel watchers
|
||||
ChannelWatching.find({
|
||||
channelId: note.channelId,
|
||||
// 削除されたドキュメントは除く
|
||||
deletedAt: { $exists: false }
|
||||
})
|
||||
]).then(([noteObj, watches]) => {
|
||||
// チャンネルの視聴者(のタイムライン)に配信
|
||||
watches.forEach(w => {
|
||||
stream(w.userId, 'note', noteObj);
|
||||
});
|
||||
})
|
||||
);
|
||||
}*/
|
||||
|
||||
const mentions = [];
|
||||
|
||||
async function addMention(mentionee, reason) {
|
||||
// Reject if already added
|
||||
if (mentions.some(x => x.equals(mentionee))) return;
|
||||
|
||||
// Add mention
|
||||
mentions.push(mentionee);
|
||||
|
||||
// Publish event
|
||||
if (!user._id.equals(mentionee)) {
|
||||
const mentioneeMutes = await Mute.find({
|
||||
muter_id: mentionee,
|
||||
deleted_at: { $exists: false }
|
||||
});
|
||||
const mentioneesMutedUserIds = mentioneeMutes.map(m => m.muteeId.toString());
|
||||
if (mentioneesMutedUserIds.indexOf(user._id.toString()) == -1) {
|
||||
event(mentionee, reason, noteObj);
|
||||
pushSw(mentionee, reason, noteObj);
|
||||
}
|
||||
}
|
||||
}
|
||||
//#endregion
|
||||
|
||||
// If has in reply to note
|
||||
if (data.reply) {
|
||||
@ -303,8 +349,7 @@ export default async (user: IUser, data: {
|
||||
watch(user._id, data.reply);
|
||||
}
|
||||
|
||||
// Add mention
|
||||
addMention(data.reply.userId, 'reply');
|
||||
nm.push(data.reply.userId, 'reply');
|
||||
}
|
||||
|
||||
// If it is renote
|
||||
@ -339,7 +384,7 @@ export default async (user: IUser, data: {
|
||||
// If it is quote renote
|
||||
if (data.text) {
|
||||
// Add mention
|
||||
addMention(data.renote.userId, 'quote');
|
||||
nm.push(data.renote.userId, 'quote');
|
||||
} else {
|
||||
// Publish event
|
||||
if (!user._id.equals(data.renote.userId)) {
|
||||
@ -365,48 +410,4 @@ export default async (user: IUser, data: {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// If has text content
|
||||
if (data.text) {
|
||||
// Extract an '@' mentions
|
||||
const atMentions = tokens
|
||||
.filter(t => t.type == 'mention')
|
||||
.map(m => m.username)
|
||||
// Drop dupulicates
|
||||
.filter((v, i, s) => s.indexOf(v) == i);
|
||||
|
||||
// Resolve all mentions
|
||||
await Promise.all(atMentions.map(async mention => {
|
||||
// Fetch mentioned user
|
||||
// SELECT _id
|
||||
const mentionee = await User
|
||||
.findOne({
|
||||
usernameLower: mention.toLowerCase()
|
||||
}, { _id: true });
|
||||
|
||||
// When mentioned user not found
|
||||
if (mentionee == null) return;
|
||||
|
||||
// 既に言及されたユーザーに対する返信や引用renoteの場合も無視
|
||||
if (data.reply && data.reply.userId.equals(mentionee._id)) return;
|
||||
if (data.renote && data.renote.userId.equals(mentionee._id)) return;
|
||||
|
||||
// Add mention
|
||||
addMention(mentionee._id, 'mention');
|
||||
|
||||
// Create notification
|
||||
notify(mentionee._id, user._id, 'mention', {
|
||||
noteId: note._id
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
// Append mentions data
|
||||
if (mentions.length > 0) {
|
||||
Note.update({ _id: note._id }, {
|
||||
$set: {
|
||||
mentions
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
Reference in New Issue
Block a user