Merge branch 'master' into greenkeeper/webpack-cli-2.0.14

This commit is contained in:
syuilo 2018-04-07 17:19:44 +09:00 committed by GitHub
commit b3cb4c7d94
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
114 changed files with 1590 additions and 1446 deletions

View File

@ -60,7 +60,7 @@
"@types/license-checker": "15.0.0", "@types/license-checker": "15.0.0",
"@types/mkdirp": "0.5.2", "@types/mkdirp": "0.5.2",
"@types/mocha": "5.0.0", "@types/mocha": "5.0.0",
"@types/mongodb": "3.0.9", "@types/mongodb": "3.0.10",
"@types/monk": "6.0.0", "@types/monk": "6.0.0",
"@types/morgan": "1.7.35", "@types/morgan": "1.7.35",
"@types/ms": "0.7.30", "@types/ms": "0.7.30",
@ -203,13 +203,13 @@
"vue-cropperjs": "2.2.0", "vue-cropperjs": "2.2.0",
"vue-js-modal": "1.3.12", "vue-js-modal": "1.3.12",
"vue-json-tree-view": "2.1.3", "vue-json-tree-view": "2.1.3",
"vue-loader": "14.2.2", "vue-loader": "15.0.0-rc.1",
"vue-router": "3.0.1", "vue-router": "3.0.1",
"vue-template-compiler": "2.5.16", "vue-template-compiler": "2.5.16",
"vuedraggable": "2.16.0", "vuedraggable": "2.16.0",
"web-push": "3.3.0", "web-push": "3.3.0",
"webfinger.js": "2.6.6", "webfinger.js": "2.6.6",
"webpack": "4.4.1", "webpack": "4.5.0",
"webpack-cli": "2.0.14", "webpack-cli": "2.0.14",
"webpack-replace-loader": "1.3.0", "webpack-replace-loader": "1.3.0",
"websocket": "1.0.25", "websocket": "1.0.25",

View File

@ -165,7 +165,7 @@
<mk-channel-post> <mk-channel-post>
<header> <header>
<a class="index" @click="reply">{ post.index }:</a> <a class="index" @click="reply">{ post.index }:</a>
<a class="name" href={ _URL_ + '/@' + acct }><b>{ post.user.name }</b></a> <a class="name" href={ _URL_ + '/@' + acct }><b>{ getUserName(post.user) }</b></a>
<mk-time time={ post.createdAt }/> <mk-time time={ post.createdAt }/>
<mk-time time={ post.createdAt } mode="detail"/> <mk-time time={ post.createdAt } mode="detail"/>
<span>ID:<i>{ acct }</i></span> <span>ID:<i>{ acct }</i></span>
@ -230,10 +230,12 @@
</style> </style>
<script lang="typescript"> <script lang="typescript">
import getAcct from '../../../../acct/render'; import getAcct from '../../../../acct/render';
import getUserName from '../../../../renderers/get-user-name';
this.post = this.opts.post; this.post = this.opts.post;
this.form = this.opts.form; this.form = this.opts.form;
this.acct = getAcct(this.post.user); this.acct = getAcct(this.post.user);
this.name = getUserName(this.post.user);
this.reply = () => { this.reply = () => {
this.form.update({ this.form.update({
@ -244,7 +246,7 @@
</mk-channel-post> </mk-channel-post>
<mk-channel-form> <mk-channel-form>
<p v-if="reply"><b>&gt;&gt;{ reply.index }</b> ({ reply.user.name }): <a @click="clearReply">[x]</a></p> <p v-if="reply"><b>&gt;&gt;{ reply.index }</b> ({ getUserName(reply.user) }): <a @click="clearReply">[x]</a></p>
<textarea ref="text" disabled={ wait } oninput={ update } onkeydown={ onkeydown } onpaste={ onpaste } placeholder="%i18n:ch.tags.mk-channel-form.textarea%"></textarea> <textarea ref="text" disabled={ wait } oninput={ update } onkeydown={ onkeydown } onpaste={ onpaste } placeholder="%i18n:ch.tags.mk-channel-form.textarea%"></textarea>
<div class="actions"> <div class="actions">
<button @click="selectFile">%fa:upload%%i18n:ch.tags.mk-channel-form.upload%</button> <button @click="selectFile">%fa:upload%%i18n:ch.tags.mk-channel-form.upload%</button>
@ -286,6 +288,8 @@
</style> </style>
<script lang="typescript"> <script lang="typescript">
import getUserName from '../../../../renderers/get-user-name';
this.mixin('api'); this.mixin('api');
this.channel = this.opts.channel; this.channel = this.opts.channel;
@ -373,6 +377,8 @@
} }
}); });
}; };
this.getUserName = getUserName;
</script> </script>
</mk-channel-form> </mk-channel-form>

View File

@ -1,5 +1,6 @@
import getPostSummary from '../../../../renderers/get-post-summary'; import getPostSummary from '../../../../renderers/get-post-summary';
import getReactionEmoji from '../../../../renderers/get-reaction-emoji'; import getReactionEmoji from '../../../../renderers/get-reaction-emoji';
import getUserName from '../../../../renderers/get-user-name';
type Notification = { type Notification = {
title: string; title: string;
@ -21,35 +22,35 @@ export default function(type, data): Notification {
case 'mention': case 'mention':
return { return {
title: `${data.user.name}さんから:`, title: `${getUserName(data.user)}さんから:`,
body: getPostSummary(data), body: getPostSummary(data),
icon: data.user.avatarUrl + '?thumbnail&size=64' icon: data.user.avatarUrl + '?thumbnail&size=64'
}; };
case 'reply': case 'reply':
return { return {
title: `${data.user.name}さんから返信:`, title: `${getUserName(data.user)}さんから返信:`,
body: getPostSummary(data), body: getPostSummary(data),
icon: data.user.avatarUrl + '?thumbnail&size=64' icon: data.user.avatarUrl + '?thumbnail&size=64'
}; };
case 'quote': case 'quote':
return { return {
title: `${data.user.name}さんが引用:`, title: `${getUserName(data.user)}さんが引用:`,
body: getPostSummary(data), body: getPostSummary(data),
icon: data.user.avatarUrl + '?thumbnail&size=64' icon: data.user.avatarUrl + '?thumbnail&size=64'
}; };
case 'reaction': case 'reaction':
return { return {
title: `${data.user.name}: ${getReactionEmoji(data.reaction)}:`, title: `${getUserName(data.user)}: ${getReactionEmoji(data.reaction)}:`,
body: getPostSummary(data.post), body: getPostSummary(data.post),
icon: data.user.avatarUrl + '?thumbnail&size=64' icon: data.user.avatarUrl + '?thumbnail&size=64'
}; };
case 'unread_messaging_message': case 'unread_messaging_message':
return { return {
title: `${data.user.name}さんからメッセージ:`, title: `${getUserName(data.user)}さんからメッセージ:`,
body: data.text, // TODO: getMessagingMessageSummary(data), body: data.text, // TODO: getMessagingMessageSummary(data),
icon: data.user.avatarUrl + '?thumbnail&size=64' icon: data.user.avatarUrl + '?thumbnail&size=64'
}; };
@ -57,7 +58,7 @@ export default function(type, data): Notification {
case 'othello_invited': case 'othello_invited':
return { return {
title: '対局への招待があります', title: '対局への招待があります',
body: `${data.parent.name}さんから`, body: `${getUserName(data.parent)}さんから`,
icon: data.parent.avatarUrl + '?thumbnail&size=64' icon: data.parent.avatarUrl + '?thumbnail&size=64'
}; };

View File

@ -3,7 +3,7 @@
<ol class="users" ref="suggests" v-if="users.length > 0"> <ol class="users" ref="suggests" v-if="users.length > 0">
<li v-for="user in users" @click="complete(type, user)" @keydown="onKeydown" tabindex="-1"> <li v-for="user in users" @click="complete(type, user)" @keydown="onKeydown" tabindex="-1">
<img class="avatar" :src="`${user.avatarUrl}?thumbnail&size=32`" alt=""/> <img class="avatar" :src="`${user.avatarUrl}?thumbnail&size=32`" alt=""/>
<span class="name">{{ user.name }}</span> <span class="name">{{ getUserName(user) }}</span>
<span class="username">@{{ getAcct(user) }}</span> <span class="username">@{{ getAcct(user) }}</span>
</li> </li>
</ol> </ol>
@ -22,6 +22,7 @@ import Vue from 'vue';
import * as emojilib from 'emojilib'; import * as emojilib from 'emojilib';
import contains from '../../../common/scripts/contains'; import contains from '../../../common/scripts/contains';
import getAcct from '../../../../../acct/render'; import getAcct from '../../../../../acct/render';
import getUserName from '../../../../../renderers/get-user-name';
const lib = Object.entries(emojilib.lib).filter((x: any) => { const lib = Object.entries(emojilib.lib).filter((x: any) => {
return x[1].category != 'flags'; return x[1].category != 'flags';
@ -107,6 +108,7 @@ export default Vue.extend({
}, },
methods: { methods: {
getAcct, getAcct,
getUserName,
exec() { exec() {
this.select = -1; this.select = -1;
if (this.$refs.suggests) { if (this.$refs.suggests) {

View File

@ -14,7 +14,7 @@
tabindex="-1" tabindex="-1"
> >
<img class="avatar" :src="`${user.avatarUrl}?thumbnail&size=32`" alt=""/> <img class="avatar" :src="`${user.avatarUrl}?thumbnail&size=32`" alt=""/>
<span class="name">{{ user.name }}</span> <span class="name">{{ getUserName(user) }}</span>
<span class="username">@{{ getAcct(user) }}</span> <span class="username">@{{ getAcct(user) }}</span>
</li> </li>
</ol> </ol>
@ -33,7 +33,7 @@
<div> <div>
<img class="avatar" :src="`${isMe(message) ? message.recipient.avatarUrl : message.user.avatarUrl}?thumbnail&size=64`" alt=""/> <img class="avatar" :src="`${isMe(message) ? message.recipient.avatarUrl : message.user.avatarUrl}?thumbnail&size=64`" alt=""/>
<header> <header>
<span class="name">{{ isMe(message) ? message.recipient.name : message.user.name }}</span> <span class="name">{{ getUserName(isMe(message) ? message.recipient : message.user) }}</span>
<span class="username">@{{ getAcct(isMe(message) ? message.recipient : message.user) }}</span> <span class="username">@{{ getAcct(isMe(message) ? message.recipient : message.user) }}</span>
<mk-time :time="message.createdAt"/> <mk-time :time="message.createdAt"/>
</header> </header>
@ -52,6 +52,7 @@
<script lang="ts"> <script lang="ts">
import Vue from 'vue'; import Vue from 'vue';
import getAcct from '../../../../../acct/render'; import getAcct from '../../../../../acct/render';
import getUserName from '../../../../../renderers/get-user-name';
export default Vue.extend({ export default Vue.extend({
props: { props: {
@ -94,6 +95,7 @@ export default Vue.extend({
}, },
methods: { methods: {
getAcct, getAcct,
getUserName,
isMe(message) { isMe(message) {
return message.userId == (this as any).os.i.id; return message.userId == (this as any).os.i.id;
}, },

View File

@ -6,7 +6,7 @@
</router-link> </router-link>
<div class="body"> <div class="body">
<header> <header>
<router-link class="name" :to="`/@${getAcct(post.user)}`" v-user-preview="post.user.id">{{ post.user.name }}</router-link> <router-link class="name" :to="`/@${getAcct(post.user)}`" v-user-preview="post.user.id">{{ getUserName(post.user) }}</router-link>
<span class="username">@{{ getAcct(post.user) }}</span> <span class="username">@{{ getAcct(post.user) }}</span>
<div class="info"> <div class="info">
<router-link class="created-at" :to="`/@${getAcct(post.user)}/${post.id}`"> <router-link class="created-at" :to="`/@${getAcct(post.user)}/${post.id}`">
@ -25,6 +25,7 @@
<script lang="ts"> <script lang="ts">
import Vue from 'vue'; import Vue from 'vue';
import getAcct from '../../../../../acct/render'; import getAcct from '../../../../../acct/render';
import getUserName from '../../../../../renderers/get-user-name';
export default Vue.extend({ export default Vue.extend({
data() { data() {
@ -38,6 +39,7 @@ export default Vue.extend({
}, },
methods: { methods: {
getAcct, getAcct,
getUserName,
fetch(cb?) { fetch(cb?) {
this.fetching = true; this.fetching = true;
(this as any).api('posts', { (this as any).api('posts', {

View File

@ -1,7 +1,7 @@
<template> <template>
<mk-window width="400px" height="550px" @closed="$destroy"> <mk-window width="400px" height="550px" @closed="$destroy">
<span slot="header" :class="$style.header"> <span slot="header" :class="$style.header">
<img :src="`${user.avatarUrl}?thumbnail&size=64`" alt=""/>{{ user.name }}のフォロワー <img :src="`${user.avatarUrl}?thumbnail&size=64`" alt=""/>{{ name }}のフォロワー
</span> </span>
<mk-followers :user="user"/> <mk-followers :user="user"/>
</mk-window> </mk-window>
@ -9,8 +9,15 @@
<script lang="ts"> <script lang="ts">
import Vue from 'vue'; import Vue from 'vue';
import getUserName from '../../../../../renderers/get-user-name';
export default Vue.extend({ export default Vue.extend({
props: ['user'] props: ['user'],
computed {
name() {
return getUserName(this.user);
}
}
}); });
</script> </script>

View File

@ -1,7 +1,7 @@
<template> <template>
<mk-window width="400px" height="550px" @closed="$destroy"> <mk-window width="400px" height="550px" @closed="$destroy">
<span slot="header" :class="$style.header"> <span slot="header" :class="$style.header">
<img :src="`${user.avatarUrl}?thumbnail&size=64`" alt=""/>{{ user.name }}のフォロー <img :src="`${user.avatarUrl}?thumbnail&size=64`" alt=""/>{{ name }}のフォロー
</span> </span>
<mk-following :user="user"/> <mk-following :user="user"/>
</mk-window> </mk-window>
@ -9,8 +9,15 @@
<script lang="ts"> <script lang="ts">
import Vue from 'vue'; import Vue from 'vue';
import getUserName from '../../../../../renderers/get-user-name';
export default Vue.extend({ export default Vue.extend({
props: ['user'] props: ['user'],
computed: {
name() {
return getUserName(this.user);
}
}
}); });
</script> </script>

View File

@ -7,7 +7,7 @@
<img class="avatar" :src="`${user.avatarUrl}?thumbnail&size=42`" alt="" v-user-preview="user.id"/> <img class="avatar" :src="`${user.avatarUrl}?thumbnail&size=42`" alt="" v-user-preview="user.id"/>
</router-link> </router-link>
<div class="body"> <div class="body">
<router-link class="name" :to="`/@${getAcct(user)}`" v-user-preview="user.id">{{ user.name }}</router-link> <router-link class="name" :to="`/@${getAcct(user)}`" v-user-preview="user.id">{{ getUserName(user) }}</router-link>
<p class="username">@{{ getAcct(user) }}</p> <p class="username">@{{ getAcct(user) }}</p>
</div> </div>
<mk-follow-button :user="user"/> <mk-follow-button :user="user"/>
@ -23,6 +23,7 @@
<script lang="ts"> <script lang="ts">
import Vue from 'vue'; import Vue from 'vue';
import getAcct from '../../../../../acct/render'; import getAcct from '../../../../../acct/render';
import getUserName from '../../../../../renderers/get-user-name';
export default Vue.extend({ export default Vue.extend({
data() { data() {
@ -38,6 +39,7 @@ export default Vue.extend({
}, },
methods: { methods: {
getAcct, getAcct,
getUserName,
fetch() { fetch() {
this.fetching = true; this.fetching = true;
this.users = []; this.users = [];

View File

@ -1,6 +1,6 @@
<template> <template>
<mk-window ref="window" width="500px" height="560px" :popout-url="popout" @closed="$destroy"> <mk-window ref="window" width="500px" height="560px" :popout-url="popout" @closed="$destroy">
<span slot="header" :class="$style.header">%fa:comments%メッセージ: {{ user.name }}</span> <span slot="header" :class="$style.header">%fa:comments%メッセージ: {{ name }}</span>
<mk-messaging-room :user="user" :class="$style.content"/> <mk-messaging-room :user="user" :class="$style.content"/>
</mk-window> </mk-window>
</template> </template>
@ -9,10 +9,14 @@
import Vue from 'vue'; import Vue from 'vue';
import { url } from '../../../config'; import { url } from '../../../config';
import getAcct from '../../../../../acct/render'; import getAcct from '../../../../../acct/render';
import getUserName from '../../../../../renderers/get-user-name';
export default Vue.extend({ export default Vue.extend({
props: ['user'], props: ['user'],
computed: { computed: {
name(): string {
return getUserName(this.user);
},
popout(): string { popout(): string {
return `${url}/i/messaging/${getAcct(this.user)}`; return `${url}/i/messaging/${getAcct(this.user)}`;
} }

View File

@ -11,7 +11,7 @@
<div class="text"> <div class="text">
<p> <p>
<mk-reaction-icon :reaction="notification.reaction"/> <mk-reaction-icon :reaction="notification.reaction"/>
<router-link :to="`/@${getAcct(notification.user)}`" v-user-preview="notification.user.id">{{ notification.user.name }}</router-link> <router-link :to="`/@${getAcct(notification.user)}`" v-user-preview="notification.user.id">{{ getUserName(notification.user) }}</router-link>
</p> </p>
<router-link class="post-ref" :to="`/@${getAcct(notification.post.user)}/${notification.post.id}`"> <router-link class="post-ref" :to="`/@${getAcct(notification.post.user)}/${notification.post.id}`">
%fa:quote-left%{{ getPostSummary(notification.post) }}%fa:quote-right% %fa:quote-left%{{ getPostSummary(notification.post) }}%fa:quote-right%
@ -24,7 +24,7 @@
</router-link> </router-link>
<div class="text"> <div class="text">
<p>%fa:retweet% <p>%fa:retweet%
<router-link :to="`/@${getAcct(notification.post.user)}`" v-user-preview="notification.post.userId">{{ notification.post.user.name }}</router-link> <router-link :to="`/@${getAcct(notification.post.user)}`" v-user-preview="notification.post.userId">{{ getUserName(notification.post.user) }}</router-link>
</p> </p>
<router-link class="post-ref" :to="`/@${getAcct(notification.post.user)}/${notification.post.id}`"> <router-link class="post-ref" :to="`/@${getAcct(notification.post.user)}/${notification.post.id}`">
%fa:quote-left%{{ getPostSummary(notification.post.repost) }}%fa:quote-right% %fa:quote-left%{{ getPostSummary(notification.post.repost) }}%fa:quote-right%
@ -37,7 +37,7 @@
</router-link> </router-link>
<div class="text"> <div class="text">
<p>%fa:quote-left% <p>%fa:quote-left%
<router-link :to="`/@${getAcct(notification.post.user)}`" v-user-preview="notification.post.userId">{{ notification.post.user.name }}</router-link> <router-link :to="`/@${getAcct(notification.post.user)}`" v-user-preview="notification.post.userId">{{ getUserName(notification.post.user) }}</router-link>
</p> </p>
<router-link class="post-preview" :to="`/@${getAcct(notification.post.user)}/${notification.post.id}`">{{ getPostSummary(notification.post) }}</router-link> <router-link class="post-preview" :to="`/@${getAcct(notification.post.user)}/${notification.post.id}`">{{ getPostSummary(notification.post) }}</router-link>
</div> </div>
@ -48,7 +48,7 @@
</router-link> </router-link>
<div class="text"> <div class="text">
<p>%fa:user-plus% <p>%fa:user-plus%
<router-link :to="`/@${getAcct(notification.user)}`" v-user-preview="notification.user.id">{{ notification.user.name }}</router-link> <router-link :to="`/@${getAcct(notification.user)}`" v-user-preview="notification.user.id">{{ getUserName(notification.user) }}</router-link>
</p> </p>
</div> </div>
</template> </template>
@ -58,7 +58,7 @@
</router-link> </router-link>
<div class="text"> <div class="text">
<p>%fa:reply% <p>%fa:reply%
<router-link :to="`/@${getAcct(notification.post.user)}`" v-user-preview="notification.post.userId">{{ notification.post.user.name }}</router-link> <router-link :to="`/@${getAcct(notification.post.user)}`" v-user-preview="notification.post.userId">{{ getUserName(notification.post.user) }}</router-link>
</p> </p>
<router-link class="post-preview" :to="`/@${getAcct(notification.post.user)}/${notification.post.id}`">{{ getPostSummary(notification.post) }}</router-link> <router-link class="post-preview" :to="`/@${getAcct(notification.post.user)}/${notification.post.id}`">{{ getPostSummary(notification.post) }}</router-link>
</div> </div>
@ -69,7 +69,7 @@
</router-link> </router-link>
<div class="text"> <div class="text">
<p>%fa:at% <p>%fa:at%
<router-link :to="`/@${getAcct(notification.post.user)}`" v-user-preview="notification.post.userId">{{ notification.post.user.name }}</router-link> <router-link :to="`/@${getAcct(notification.post.user)}`" v-user-preview="notification.post.userId">{{ getUserName(notification.post.user) }}</router-link>
</p> </p>
<a class="post-preview" :href="`/@${getAcct(notification.post.user)}/${notification.post.id}`">{{ getPostSummary(notification.post) }}</a> <a class="post-preview" :href="`/@${getAcct(notification.post.user)}/${notification.post.id}`">{{ getPostSummary(notification.post) }}</a>
</div> </div>
@ -79,7 +79,7 @@
<img class="avatar" :src="`${notification.user.avatarUrl}?thumbnail&size=48`" alt="avatar"/> <img class="avatar" :src="`${notification.user.avatarUrl}?thumbnail&size=48`" alt="avatar"/>
</router-link> </router-link>
<div class="text"> <div class="text">
<p>%fa:chart-pie%<a :href="`/@${getAcct(notification.user)}`" v-user-preview="notification.user.id">{{ notification.user.name }}</a></p> <p>%fa:chart-pie%<a :href="`/@${getAcct(notification.user)}`" v-user-preview="notification.user.id">{{ getUserName(notification.user) }}</a></p>
<router-link class="post-ref" :to="`/@${getAcct(notification.post.user)}/${notification.post.id}`"> <router-link class="post-ref" :to="`/@${getAcct(notification.post.user)}/${notification.post.id}`">
%fa:quote-left%{{ getPostSummary(notification.post) }}%fa:quote-right% %fa:quote-left%{{ getPostSummary(notification.post) }}%fa:quote-right%
</router-link> </router-link>
@ -104,6 +104,7 @@
import Vue from 'vue'; import Vue from 'vue';
import getAcct from '../../../../../acct/render'; import getAcct from '../../../../../acct/render';
import getPostSummary from '../../../../../renderers/get-post-summary'; import getPostSummary from '../../../../../renderers/get-post-summary';
import getUserName from '../../../../../renderers/get-user-name';
export default Vue.extend({ export default Vue.extend({
data() { data() {
@ -154,6 +155,7 @@ export default Vue.extend({
}, },
methods: { methods: {
getAcct, getAcct,
getUserName,
fetchMoreNotifications() { fetchMoreNotifications() {
this.fetchingMoreNotifications = true; this.fetchingMoreNotifications = true;

View File

@ -6,7 +6,7 @@
<div class="main"> <div class="main">
<header> <header>
<div class="left"> <div class="left">
<router-link class="name" :to="`/@${acct}`" v-user-preview="post.userId">{{ post.user.name }}</router-link> <router-link class="name" :to="`/@${acct}`" v-user-preview="post.userId">{{ getUserName(post.user) }}</router-link>
<span class="username">@{{ acct }}</span> <span class="username">@{{ acct }}</span>
</div> </div>
<div class="right"> <div class="right">
@ -29,6 +29,7 @@
import Vue from 'vue'; import Vue from 'vue';
import dateStringify from '../../../common/scripts/date-stringify'; import dateStringify from '../../../common/scripts/date-stringify';
import getAcct from '../../../../../acct/render'; import getAcct from '../../../../../acct/render';
import getUserName from '../../../../../renderers/get-user-name';
export default Vue.extend({ export default Vue.extend({
props: ['post'], props: ['post'],
@ -36,6 +37,9 @@ export default Vue.extend({
acct() { acct() {
return getAcct(this.post.user); return getAcct(this.post.user);
}, },
name() {
return getUserName(this.post.user);
},
title(): string { title(): string {
return dateStringify(this.post.createdAt); return dateStringify(this.post.createdAt);
} }

View File

@ -22,7 +22,7 @@
<img class="avatar" :src="`${post.user.avatarUrl}?thumbnail&size=32`" alt="avatar"/> <img class="avatar" :src="`${post.user.avatarUrl}?thumbnail&size=32`" alt="avatar"/>
</router-link> </router-link>
%fa:retweet% %fa:retweet%
<router-link class="name" :href="`/@${acct}`">{{ post.user.name }}</router-link> <router-link class="name" :href="`/@${acct}`">{{ getUserName(post.user) }}</router-link>
がRepost がRepost
</p> </p>
</div> </div>
@ -31,7 +31,7 @@
<img class="avatar" :src="`${p.user.avatarUrl}?thumbnail&size=64`" alt="avatar" v-user-preview="p.user.id"/> <img class="avatar" :src="`${p.user.avatarUrl}?thumbnail&size=64`" alt="avatar" v-user-preview="p.user.id"/>
</router-link> </router-link>
<header> <header>
<router-link class="name" :to="`/@${pAcct}`" v-user-preview="p.user.id">{{ p.user.name }}</router-link> <router-link class="name" :to="`/@${pAcct}`" v-user-preview="p.user.id">{{ getUserName(p.user) }}</router-link>
<span class="username">@{{ pAcct }}</span> <span class="username">@{{ pAcct }}</span>
<router-link class="time" :to="`/@${pAcct}/${p.id}`"> <router-link class="time" :to="`/@${pAcct}/${p.id}`">
<mk-time :time="p.createdAt"/> <mk-time :time="p.createdAt"/>
@ -79,6 +79,7 @@
import Vue from 'vue'; import Vue from 'vue';
import dateStringify from '../../../common/scripts/date-stringify'; import dateStringify from '../../../common/scripts/date-stringify';
import getAcct from '../../../../../acct/render'; import getAcct from '../../../../../acct/render';
import getUserName from '../../../../../renderers/get-user-name';
import parse from '../../../../../text/parse'; import parse from '../../../../../text/parse';
import MkPostFormWindow from './post-form-window.vue'; import MkPostFormWindow from './post-form-window.vue';
@ -133,9 +134,15 @@ export default Vue.extend({
acct(): string { acct(): string {
return getAcct(this.post.user); return getAcct(this.post.user);
}, },
name(): string {
return getUserName(this.post.user);
},
pAcct(): string { pAcct(): string {
return getAcct(this.p.user); return getAcct(this.p.user);
}, },
pName(): string {
return getUserName(this.p.user);
},
urls(): string[] { urls(): string[] {
if (this.p.text) { if (this.p.text) {
const ast = parse(this.p.text); const ast = parse(this.p.text);

View File

@ -5,7 +5,7 @@
</router-link> </router-link>
<div class="main"> <div class="main">
<header> <header>
<router-link class="name" :to="`/@${acct}`" v-user-preview="post.userId">{{ post.user.name }}</router-link> <router-link class="name" :to="`/@${acct}`" v-user-preview="post.userId">{{ name }}</router-link>
<span class="username">@{{ acct }}</span> <span class="username">@{{ acct }}</span>
<router-link class="time" :to="`/@${acct}/${post.id}`"> <router-link class="time" :to="`/@${acct}/${post.id}`">
<mk-time :time="post.createdAt"/> <mk-time :time="post.createdAt"/>
@ -22,6 +22,7 @@
import Vue from 'vue'; import Vue from 'vue';
import dateStringify from '../../../common/scripts/date-stringify'; import dateStringify from '../../../common/scripts/date-stringify';
import getAcct from '../../../../../acct/render'; import getAcct from '../../../../../acct/render';
import getUserName from '../../../../../renderers/get-user-name';
export default Vue.extend({ export default Vue.extend({
props: ['post'], props: ['post'],
@ -29,6 +30,9 @@ export default Vue.extend({
acct() { acct() {
return getAcct(this.post.user); return getAcct(this.post.user);
}, },
name() {
return getUserName(this.post.user);
},
title(): string { title(): string {
return dateStringify(this.post.createdAt); return dateStringify(this.post.createdAt);
} }

View File

@ -5,7 +5,7 @@
</router-link> </router-link>
<div class="main"> <div class="main">
<header> <header>
<router-link class="name" :to="`/@${acct}`" v-user-preview="post.userId">{{ post.user.name }}</router-link> <router-link class="name" :to="`/@${acct}`" v-user-preview="post.userId">{{ name }}</router-link>
<span class="username">@{{ acct }}</span> <span class="username">@{{ acct }}</span>
<router-link class="created-at" :to="`/@${acct}/${post.id}`"> <router-link class="created-at" :to="`/@${acct}/${post.id}`">
<mk-time :time="post.createdAt"/> <mk-time :time="post.createdAt"/>
@ -22,6 +22,7 @@
import Vue from 'vue'; import Vue from 'vue';
import dateStringify from '../../../common/scripts/date-stringify'; import dateStringify from '../../../common/scripts/date-stringify';
import getAcct from '../../../../../acct/render'; import getAcct from '../../../../../acct/render';
import getUserName from '../../../../../renderers/get-user-name';
export default Vue.extend({ export default Vue.extend({
props: ['post'], props: ['post'],
@ -29,6 +30,9 @@ export default Vue.extend({
acct() { acct() {
return getAcct(this.post.user); return getAcct(this.post.user);
}, },
name(): string {
return getUserName(this.post.user);
},
title(): string { title(): string {
return dateStringify(this.post.createdAt); return dateStringify(this.post.createdAt);
} }

View File

@ -10,7 +10,7 @@
</router-link> </router-link>
%fa:retweet% %fa:retweet%
<span>{{ '%i18n:desktop.tags.mk-timeline-post.reposted-by%'.substr(0, '%i18n:desktop.tags.mk-timeline-post.reposted-by%'.indexOf('{')) }}</span> <span>{{ '%i18n:desktop.tags.mk-timeline-post.reposted-by%'.substr(0, '%i18n:desktop.tags.mk-timeline-post.reposted-by%'.indexOf('{')) }}</span>
<a class="name" :href="`/@${acct}`" v-user-preview="post.userId">{{ post.user.name }}</a> <a class="name" :href="`/@${acct}`" v-user-preview="post.userId">{{ getUserName(post.user) }}</a>
<span>{{ '%i18n:desktop.tags.mk-timeline-post.reposted-by%'.substr('%i18n:desktop.tags.mk-timeline-post.reposted-by%'.indexOf('}') + 1) }}</span> <span>{{ '%i18n:desktop.tags.mk-timeline-post.reposted-by%'.substr('%i18n:desktop.tags.mk-timeline-post.reposted-by%'.indexOf('}') + 1) }}</span>
</p> </p>
<mk-time :time="post.createdAt"/> <mk-time :time="post.createdAt"/>
@ -86,6 +86,7 @@
import Vue from 'vue'; import Vue from 'vue';
import dateStringify from '../../../common/scripts/date-stringify'; import dateStringify from '../../../common/scripts/date-stringify';
import getAcct from '../../../../../acct/render'; import getAcct from '../../../../../acct/render';
import getUserName from '../../../../../renderers/get-user-name';
import parse from '../../../../../text/parse'; import parse from '../../../../../text/parse';
import MkPostFormWindow from './post-form-window.vue'; import MkPostFormWindow from './post-form-window.vue';
@ -124,6 +125,9 @@ export default Vue.extend({
acct(): string { acct(): string {
return getAcct(this.p.user); return getAcct(this.p.user);
}, },
name(): string {
return getUserName(this.p.user);
},
isRepost(): boolean { isRepost(): boolean {
return (this.post.repost && return (this.post.repost &&
this.post.text == null && this.post.text == null &&

View File

@ -5,7 +5,7 @@
</div> </div>
<div class="users" v-if="users.length != 0"> <div class="users" v-if="users.length != 0">
<div v-for="user in users" :key="user.id"> <div v-for="user in users" :key="user.id">
<p><b>{{ user.name }}</b> @{{ getAcct(user) }}</p> <p><b>{{ getUserName(user) }}</b> @{{ getAcct(user) }}</p>
</div> </div>
</div> </div>
</div> </div>
@ -14,6 +14,7 @@
<script lang="ts"> <script lang="ts">
import Vue from 'vue'; import Vue from 'vue';
import getAcct from '../../../../../acct/render'; import getAcct from '../../../../../acct/render';
import getUserName from '../../../../../renderers/get-user-name';
export default Vue.extend({ export default Vue.extend({
data() { data() {
@ -23,7 +24,8 @@ export default Vue.extend({
}; };
}, },
methods: { methods: {
getAcct getAcct,
getUserName
}, },
mounted() { mounted() {
(this as any).api('mute/list').then(x => { (this as any).api('mute/list').then(x => {

View File

@ -42,7 +42,7 @@ export default Vue.extend({
}; };
}, },
created() { created() {
this.name = (this as any).os.i.name; this.name = (this as any).os.i.name || '';
this.location = (this as any).os.i.account.profile.location; this.location = (this as any).os.i.account.profile.location;
this.description = (this as any).os.i.description; this.description = (this as any).os.i.description;
this.birthday = (this as any).os.i.account.profile.birthday; this.birthday = (this as any).os.i.account.profile.birthday;
@ -53,7 +53,7 @@ export default Vue.extend({
}, },
save() { save() {
(this as any).api('i/update', { (this as any).api('i/update', {
name: this.name, name: this.name || null,
location: this.location || null, location: this.location || null,
description: this.description || null, description: this.description || null,
birthday: this.birthday || null birthday: this.birthday || null

View File

@ -4,7 +4,7 @@
<div class="main" ref="main"> <div class="main" ref="main">
<div class="backdrop"></div> <div class="backdrop"></div>
<div class="main"> <div class="main">
<p ref="welcomeback" v-if="os.isSignedIn">おかえりなさい<b>{{ os.i.name }}</b>さん</p> <p ref="welcomeback" v-if="os.isSignedIn">おかえりなさい<b>{{ name }}</b>さん</p>
<div class="container" ref="mainContainer"> <div class="container" ref="mainContainer">
<div class="left"> <div class="left">
<x-nav/> <x-nav/>
@ -33,7 +33,14 @@ import XNotifications from './ui.header.notifications.vue';
import XPost from './ui.header.post.vue'; import XPost from './ui.header.post.vue';
import XClock from './ui.header.clock.vue'; import XClock from './ui.header.clock.vue';
import getUserName from '../../../../../renderers/get-user-name';
export default Vue.extend({ export default Vue.extend({
computed: {
name() {
return getUserName(this.os.i);
}
},
components: { components: {
XNav, XNav,
XSearch, XSearch,

View File

@ -5,7 +5,7 @@
</router-link> </router-link>
<div class="main"> <div class="main">
<header> <header>
<router-link class="name" :to="`/@${acct}`" v-user-preview="user.id">{{ user.name }}</router-link> <router-link class="name" :to="`/@${acct}`" v-user-preview="user.id">{{ name }}</router-link>
<span class="username">@{{ acct }}</span> <span class="username">@{{ acct }}</span>
</header> </header>
<div class="body"> <div class="body">
@ -20,12 +20,16 @@
<script lang="ts"> <script lang="ts">
import Vue from 'vue'; import Vue from 'vue';
import getAcct from '../../../../../acct/render'; import getAcct from '../../../../../acct/render';
import getUserName from '../../../../../renderers/get-user-name';
export default Vue.extend({ export default Vue.extend({
props: ['user'], props: ['user'],
computed: { computed: {
acct() { acct() {
return getAcct(this.user); return getAcct(this.user);
},
name() {
return getUserName(this.user);
} }
} }
}); });

View File

@ -8,6 +8,7 @@
import Vue from 'vue'; import Vue from 'vue';
import Progress from '../../../common/scripts/loading'; import Progress from '../../../common/scripts/loading';
import parseAcct from '../../../../../acct/parse'; import parseAcct from '../../../../../acct/parse';
import getUserName from '../../../../../renderers/get-user-name';
export default Vue.extend({ export default Vue.extend({
data() { data() {
@ -34,7 +35,7 @@ export default Vue.extend({
this.user = user; this.user = user;
this.fetching = false; this.fetching = false;
document.title = 'メッセージ: ' + this.user.name; document.title = 'メッセージ: ' + getUserName(this.user);
Progress.done(); Progress.done();
}); });

View File

@ -4,7 +4,7 @@
<p class="initializing" v-if="fetching">%fa:spinner .pulse .fw%%i18n:desktop.tags.mk-user.followers-you-know.loading%<mk-ellipsis/></p> <p class="initializing" v-if="fetching">%fa:spinner .pulse .fw%%i18n:desktop.tags.mk-user.followers-you-know.loading%<mk-ellipsis/></p>
<div v-if="!fetching && users.length > 0"> <div v-if="!fetching && users.length > 0">
<router-link v-for="user in users" :to="`/@${getAcct(user)}`" :key="user.id"> <router-link v-for="user in users" :to="`/@${getAcct(user)}`" :key="user.id">
<img :src="`${user.avatarUrl}?thumbnail&size=64`" :alt="user.name" v-user-preview="user.id"/> <img :src="`${user.avatarUrl}?thumbnail&size=64`" :alt="getUserName(user)" v-user-preview="user.id"/>
</router-link> </router-link>
</div> </div>
<p class="empty" v-if="!fetching && users.length == 0">%i18n:desktop.tags.mk-user.followers-you-know.no-users%</p> <p class="empty" v-if="!fetching && users.length == 0">%i18n:desktop.tags.mk-user.followers-you-know.no-users%</p>
@ -14,6 +14,7 @@
<script lang="ts"> <script lang="ts">
import Vue from 'vue'; import Vue from 'vue';
import getAcct from '../../../../../../acct/render'; import getAcct from '../../../../../../acct/render';
import getUserName from '../../../../../../renderers/get-user-name';
export default Vue.extend({ export default Vue.extend({
props: ['user'], props: ['user'],
@ -24,7 +25,8 @@ export default Vue.extend({
}; };
}, },
method() { method() {
getAcct getAcct,
getUserName
}, },
mounted() { mounted() {
(this as any).api('users/followers', { (this as any).api('users/followers', {

View File

@ -7,7 +7,7 @@
<div class="container"> <div class="container">
<img class="avatar" :src="`${user.avatarUrl}?thumbnail&size=150`" alt="avatar"/> <img class="avatar" :src="`${user.avatarUrl}?thumbnail&size=150`" alt="avatar"/>
<div class="title"> <div class="title">
<p class="name">{{ user.name }}</p> <p class="name">{{ name }}</p>
<p class="username">@{{ acct }}</p> <p class="username">@{{ acct }}</p>
<p class="location" v-if="user.host === null && user.account.profile.location">%fa:map-marker%{{ user.account.profile.location }}</p> <p class="location" v-if="user.host === null && user.account.profile.location">%fa:map-marker%{{ user.account.profile.location }}</p>
</div> </div>
@ -23,12 +23,16 @@
<script lang="ts"> <script lang="ts">
import Vue from 'vue'; import Vue from 'vue';
import getAcct from '../../../../../../acct/render'; import getAcct from '../../../../../../acct/render';
import getUserName from '../../../../../../renderers/get-user-name';
export default Vue.extend({ export default Vue.extend({
props: ['user'], props: ['user'],
computed: { computed: {
acct() { acct() {
return getAcct(this.user); return getAcct(this.user);
},
name() {
return getUserName(this.user);
} }
}, },
mounted() { mounted() {

View File

@ -10,6 +10,7 @@
<script lang="ts"> <script lang="ts">
import Vue from 'vue'; import Vue from 'vue';
import parseAcct from '../../../../../../acct/parse'; import parseAcct from '../../../../../../acct/parse';
import getUserName from '../../../../../../renderers/get-user-name';
import Progress from '../../../../common/scripts/loading'; import Progress from '../../../../common/scripts/loading';
import XHeader from './user.header.vue'; import XHeader from './user.header.vue';
import XHome from './user.home.vue'; import XHome from './user.home.vue';
@ -44,7 +45,7 @@ export default Vue.extend({
this.user = user; this.user = user;
this.fetching = false; this.fetching = false;
Progress.done(); Progress.done();
document.title = user.name + ' | Misskey'; document.title = getUserName(user) + ' | Misskey';
}); });
} }
} }

View File

@ -2,7 +2,7 @@
<div class="post"> <div class="post">
<header> <header>
<a class="index" @click="reply">{{ post.index }}:</a> <a class="index" @click="reply">{{ post.index }}:</a>
<router-link class="name" :to="`/@${acct}`" v-user-preview="post.user.id"><b>{{ post.user.name }}</b></router-link> <router-link class="name" :to="`/@${acct}`" v-user-preview="post.user.id"><b>{{ name }}</b></router-link>
<span>ID:<i>{{ acct }}</i></span> <span>ID:<i>{{ acct }}</i></span>
</header> </header>
<div> <div>
@ -20,12 +20,16 @@
<script lang="ts"> <script lang="ts">
import Vue from 'vue'; import Vue from 'vue';
import getAcct from '../../../../../acct/render'; import getAcct from '../../../../../acct/render';
import getUserName from '../../../../../renderers/get-user-name';
export default Vue.extend({ export default Vue.extend({
props: ['post'], props: ['post'],
computed: { computed: {
acct() { acct() {
return getAcct(this.post.user); return getAcct(this.post.user);
},
name() {
return getUserName(this.post.user);
} }
}, },
methods: { methods: {

View File

@ -15,19 +15,26 @@
title="クリックでアバター編集" title="クリックでアバター編集"
v-user-preview="os.i.id" v-user-preview="os.i.id"
/> />
<router-link class="name" :to="`/@${os.i.username}`">{{ os.i.name }}</router-link> <router-link class="name" :to="`/@${os.i.username}`">{{ name }}</router-link>
<p class="username">@{{ os.i.username }}</p> <p class="username">@{{ os.i.username }}</p>
</div> </div>
</template> </template>
<script lang="ts"> <script lang="ts">
import define from '../../../common/define-widget'; import define from '../../../common/define-widget';
import getUserName from '../../../../../renderers/get-user-name';
export default define({ export default define({
name: 'profile', name: 'profile',
props: () => ({ props: () => ({
design: 0 design: 0
}) })
}).extend({ }).extend({
computed: {
name() {
return getUserName(this.os.i);
}
},
methods: { methods: {
func() { func() {
if (this.props.design == 2) { if (this.props.design == 2) {

View File

@ -11,7 +11,7 @@
<img class="avatar" :src="`${_user.avatarUrl}?thumbnail&size=42`" alt="" v-user-preview="_user.id"/> <img class="avatar" :src="`${_user.avatarUrl}?thumbnail&size=42`" alt="" v-user-preview="_user.id"/>
</router-link> </router-link>
<div class="body"> <div class="body">
<router-link class="name" :to="`/@${getAcct(_user)}`" v-user-preview="_user.id">{{ _user.name }}</router-link> <router-link class="name" :to="`/@${getAcct(_user)}`" v-user-preview="_user.id">{{ getUserName(_user) }}</router-link>
<p class="username">@{{ getAcct(_user) }}</p> <p class="username">@{{ getAcct(_user) }}</p>
</div> </div>
<mk-follow-button :user="_user"/> <mk-follow-button :user="_user"/>
@ -24,6 +24,7 @@
<script lang="ts"> <script lang="ts">
import define from '../../../common/define-widget'; import define from '../../../common/define-widget';
import getAcct from '../../../../../acct/render'; import getAcct from '../../../../../acct/render';
import getUserName from '../../../../../renderers/get-user-name';
const limit = 3; const limit = 3;
@ -45,6 +46,7 @@ export default define({
}, },
methods: { methods: {
getAcct, getAcct,
getUserName,
func() { func() {
this.props.compact = !this.props.compact; this.props.compact = !this.props.compact;
}, },

View File

@ -14,7 +14,7 @@ import ElementLocaleJa from 'element-ui/lib/locale/lang/ja';
import App from './app.vue'; import App from './app.vue';
import checkForUpdate from './common/scripts/check-for-update'; import checkForUpdate from './common/scripts/check-for-update';
import MiOS, { API } from './common/mios'; import MiOS, { API } from './common/mios';
import { version, codename, hostname, lang } from './config'; import { version, codename, lang } from './config';
let elementLocale; let elementLocale;
switch (lang) { switch (lang) {
@ -60,10 +60,6 @@ console.info(
window.clearTimeout((window as any).mkBootTimer); window.clearTimeout((window as any).mkBootTimer);
delete (window as any).mkBootTimer; delete (window as any).mkBootTimer;
if (hostname != 'localhost') {
document.domain = hostname;
}
//#region Set lang attr //#region Set lang attr
const html = document.documentElement; const html = document.documentElement;
html.setAttribute('lang', lang); html.setAttribute('lang', lang);

View File

@ -3,7 +3,7 @@
<template v-if="notification.type == 'reaction'"> <template v-if="notification.type == 'reaction'">
<img class="avatar" :src="`${notification.user.avatarUrl}?thumbnail&size=64`" alt="avatar"/> <img class="avatar" :src="`${notification.user.avatarUrl}?thumbnail&size=64`" alt="avatar"/>
<div class="text"> <div class="text">
<p><mk-reaction-icon :reaction="notification.reaction"/>{{ notification.user.name }}</p> <p><mk-reaction-icon :reaction="notification.reaction"/>{{ name }}</p>
<p class="post-ref">%fa:quote-left%{{ getPostSummary(notification.post) }}%fa:quote-right%</p> <p class="post-ref">%fa:quote-left%{{ getPostSummary(notification.post) }}%fa:quote-right%</p>
</div> </div>
</template> </template>
@ -11,7 +11,7 @@
<template v-if="notification.type == 'repost'"> <template v-if="notification.type == 'repost'">
<img class="avatar" :src="`${notification.post.user.avatarUrl}?thumbnail&size=64`" alt="avatar"/> <img class="avatar" :src="`${notification.post.user.avatarUrl}?thumbnail&size=64`" alt="avatar"/>
<div class="text"> <div class="text">
<p>%fa:retweet%{{ notification.post.user.name }}</p> <p>%fa:retweet%{{ posterName }}</p>
<p class="post-ref">%fa:quote-left%{{ getPostSummary(notification.post.repost) }}%fa:quote-right%</p> <p class="post-ref">%fa:quote-left%{{ getPostSummary(notification.post.repost) }}%fa:quote-right%</p>
</div> </div>
</template> </template>
@ -19,7 +19,7 @@
<template v-if="notification.type == 'quote'"> <template v-if="notification.type == 'quote'">
<img class="avatar" :src="`${notification.post.user.avatarUrl}?thumbnail&size=64`" alt="avatar"/> <img class="avatar" :src="`${notification.post.user.avatarUrl}?thumbnail&size=64`" alt="avatar"/>
<div class="text"> <div class="text">
<p>%fa:quote-left%{{ notification.post.user.name }}</p> <p>%fa:quote-left%{{ posterName }}</p>
<p class="post-preview">{{ getPostSummary(notification.post) }}</p> <p class="post-preview">{{ getPostSummary(notification.post) }}</p>
</div> </div>
</template> </template>
@ -27,14 +27,14 @@
<template v-if="notification.type == 'follow'"> <template v-if="notification.type == 'follow'">
<img class="avatar" :src="`${notification.user.avatarUrl}?thumbnail&size=64`" alt="avatar"/> <img class="avatar" :src="`${notification.user.avatarUrl}?thumbnail&size=64`" alt="avatar"/>
<div class="text"> <div class="text">
<p>%fa:user-plus%{{ notification.user.name }}</p> <p>%fa:user-plus%{{ name }}</p>
</div> </div>
</template> </template>
<template v-if="notification.type == 'reply'"> <template v-if="notification.type == 'reply'">
<img class="avatar" :src="`${notification.post.user.avatarUrl}?thumbnail&size=64`" alt="avatar"/> <img class="avatar" :src="`${notification.post.user.avatarUrl}?thumbnail&size=64`" alt="avatar"/>
<div class="text"> <div class="text">
<p>%fa:reply%{{ notification.post.user.name }}</p> <p>%fa:reply%{{ posterName }}</p>
<p class="post-preview">{{ getPostSummary(notification.post) }}</p> <p class="post-preview">{{ getPostSummary(notification.post) }}</p>
</div> </div>
</template> </template>
@ -42,7 +42,7 @@
<template v-if="notification.type == 'mention'"> <template v-if="notification.type == 'mention'">
<img class="avatar" :src="`${notification.post.user.avatarUrl}?thumbnail&size=64`" alt="avatar"/> <img class="avatar" :src="`${notification.post.user.avatarUrl}?thumbnail&size=64`" alt="avatar"/>
<div class="text"> <div class="text">
<p>%fa:at%{{ notification.post.user.name }}</p> <p>%fa:at%{{ posterName }}</p>
<p class="post-preview">{{ getPostSummary(notification.post) }}</p> <p class="post-preview">{{ getPostSummary(notification.post) }}</p>
</div> </div>
</template> </template>
@ -50,7 +50,7 @@
<template v-if="notification.type == 'poll_vote'"> <template v-if="notification.type == 'poll_vote'">
<img class="avatar" :src="`${notification.user.avatarUrl}?thumbnail&size=64`" alt="avatar"/> <img class="avatar" :src="`${notification.user.avatarUrl}?thumbnail&size=64`" alt="avatar"/>
<div class="text"> <div class="text">
<p>%fa:chart-pie%{{ notification.user.name }}</p> <p>%fa:chart-pie%{{ name }}</p>
<p class="post-ref">%fa:quote-left%{{ getPostSummary(notification.post) }}%fa:quote-right%</p> <p class="post-ref">%fa:quote-left%{{ getPostSummary(notification.post) }}%fa:quote-right%</p>
</div> </div>
</template> </template>
@ -60,9 +60,18 @@
<script lang="ts"> <script lang="ts">
import Vue from 'vue'; import Vue from 'vue';
import getPostSummary from '../../../../../renderers/get-post-summary'; import getPostSummary from '../../../../../renderers/get-post-summary';
import getUserName from '../../../../../renderers/get-user-name';
export default Vue.extend({ export default Vue.extend({
props: ['notification'], props: ['notification'],
computed: {
name() {
return getUserName(this.notification.user);
},
posterName() {
return getUserName(this.notification.post.user);
}
},
data() { data() {
return { return {
getPostSummary getPostSummary

View File

@ -8,7 +8,7 @@
<div class="text"> <div class="text">
<p> <p>
<mk-reaction-icon :reaction="notification.reaction"/> <mk-reaction-icon :reaction="notification.reaction"/>
<router-link :to="`/@${acct}`">{{ notification.user.name }}</router-link> <router-link :to="`/@${acct}`">{{ getUserName(notification.user) }}</router-link>
</p> </p>
<router-link class="post-ref" :to="`/@${acct}/${notification.post.id}`"> <router-link class="post-ref" :to="`/@${acct}/${notification.post.id}`">
%fa:quote-left%{{ getPostSummary(notification.post) }} %fa:quote-left%{{ getPostSummary(notification.post) }}
@ -25,7 +25,7 @@
<div class="text"> <div class="text">
<p> <p>
%fa:retweet% %fa:retweet%
<router-link :to="`/@${acct}`">{{ notification.post.user.name }}</router-link> <router-link :to="`/@${acct}`">{{ getUserName(notification.post.user) }}</router-link>
</p> </p>
<router-link class="post-ref" :to="`/@${acct}/${notification.post.id}`"> <router-link class="post-ref" :to="`/@${acct}/${notification.post.id}`">
%fa:quote-left%{{ getPostSummary(notification.post.repost) }}%fa:quote-right% %fa:quote-left%{{ getPostSummary(notification.post.repost) }}%fa:quote-right%
@ -45,7 +45,7 @@
<div class="text"> <div class="text">
<p> <p>
%fa:user-plus% %fa:user-plus%
<router-link :to="`/@${acct}`">{{ notification.user.name }}</router-link> <router-link :to="`/@${acct}`">{{ getUserName(notification.user) }}</router-link>
</p> </p>
</div> </div>
</div> </div>
@ -66,7 +66,7 @@
<div class="text"> <div class="text">
<p> <p>
%fa:chart-pie% %fa:chart-pie%
<router-link :to="`/@${acct}`">{{ notification.user.name }}</router-link> <router-link :to="`/@${acct}`">{{ getUserName(notification.user) }}</router-link>
</p> </p>
<router-link class="post-ref" :to="`/@${acct}/${notification.post.id}`"> <router-link class="post-ref" :to="`/@${acct}/${notification.post.id}`">
%fa:quote-left%{{ getPostSummary(notification.post) }}%fa:quote-right% %fa:quote-left%{{ getPostSummary(notification.post) }}%fa:quote-right%
@ -80,12 +80,19 @@
import Vue from 'vue'; import Vue from 'vue';
import getPostSummary from '../../../../../renderers/get-post-summary'; import getPostSummary from '../../../../../renderers/get-post-summary';
import getAcct from '../../../../../acct/render'; import getAcct from '../../../../../acct/render';
import getUserName from '../../../../../renderers/get-user-name';
export default Vue.extend({ export default Vue.extend({
props: ['notification'], props: ['notification'],
computed: { computed: {
acct() { acct() {
return getAcct(this.notification.user); return getAcct(this.notification.user);
},
name() {
return getUserName(this.notification.user);
},
posterName() {
return getUserName(this.notification.post.user);
} }
}, },
data() { data() {

View File

@ -2,7 +2,7 @@
<div class="mk-post-card"> <div class="mk-post-card">
<a :href="`/@${acct}/${post.id}`"> <a :href="`/@${acct}/${post.id}`">
<header> <header>
<img :src="`${acct}?thumbnail&size=64`" alt="avatar"/><h3>{{ post.user.name }}</h3> <img :src="`${acct}?thumbnail&size=64`" alt="avatar"/><h3>{{ name }}</h3>
</header> </header>
<div> <div>
{{ text }} {{ text }}
@ -16,6 +16,7 @@
import Vue from 'vue'; import Vue from 'vue';
import summary from '../../../../../renderers/get-post-summary'; import summary from '../../../../../renderers/get-post-summary';
import getAcct from '../../../../../acct/render'; import getAcct from '../../../../../acct/render';
import getUserName from '../../../../../renderers/get-user-name';
export default Vue.extend({ export default Vue.extend({
props: ['post'], props: ['post'],
@ -23,6 +24,9 @@ export default Vue.extend({
acct() { acct() {
return getAcct(this.post.user); return getAcct(this.post.user);
}, },
name() {
return getUserName(this.post.user);
},
text(): string { text(): string {
return summary(this.post); return summary(this.post);
} }

View File

@ -5,7 +5,7 @@
</router-link> </router-link>
<div class="main"> <div class="main">
<header> <header>
<router-link class="name" :to="`/@${acct}`">{{ post.user.name }}</router-link> <router-link class="name" :to="`/@${acct}`">{{ getUserName(post.user) }}</router-link>
<span class="username">@{{ acct }}</span> <span class="username">@{{ acct }}</span>
<router-link class="time" :to="`/@${acct}/${post.id}`"> <router-link class="time" :to="`/@${acct}/${post.id}`">
<mk-time :time="post.createdAt"/> <mk-time :time="post.createdAt"/>
@ -21,12 +21,16 @@
<script lang="ts"> <script lang="ts">
import Vue from 'vue'; import Vue from 'vue';
import getAcct from '../../../../../acct/render'; import getAcct from '../../../../../acct/render';
import getUserName from '../../../../../renderers/get-user-name';
export default Vue.extend({ export default Vue.extend({
props: ['post'], props: ['post'],
computed: { computed: {
acct() { acct() {
return getAcct(this.post.user); return getAcct(this.post.user);
},
name() {
return getUserName(this.post.user);
} }
} }
}); });

View File

@ -22,7 +22,7 @@
</router-link> </router-link>
%fa:retweet% %fa:retweet%
<router-link class="name" :to="`/@${acct}`"> <router-link class="name" :to="`/@${acct}`">
{{ post.user.name }} {{ name }}
</router-link> </router-link>
がRepost がRepost
</p> </p>
@ -33,7 +33,7 @@
<img class="avatar" :src="`${p.user.avatarUrl}?thumbnail&size=64`" alt="avatar"/> <img class="avatar" :src="`${p.user.avatarUrl}?thumbnail&size=64`" alt="avatar"/>
</router-link> </router-link>
<div> <div>
<router-link class="name" :to="`/@${pAcct}`">{{ p.user.name }}</router-link> <router-link class="name" :to="`/@${pAcct}`">{{ pName }}</router-link>
<span class="username">@{{ pAcct }}</span> <span class="username">@{{ pAcct }}</span>
</div> </div>
</header> </header>
@ -81,6 +81,7 @@
<script lang="ts"> <script lang="ts">
import Vue from 'vue'; import Vue from 'vue';
import getAcct from '../../../../../acct/render'; import getAcct from '../../../../../acct/render';
import getUserName from '../../../../../renderers/get-user-name';
import parse from '../../../../../text/parse'; import parse from '../../../../../text/parse';
import MkPostMenu from '../../../common/views/components/post-menu.vue'; import MkPostMenu from '../../../common/views/components/post-menu.vue';
@ -114,9 +115,15 @@ export default Vue.extend({
acct(): string { acct(): string {
return getAcct(this.post.user); return getAcct(this.post.user);
}, },
name(): string {
return getUserName(this.post.user);
},
pAcct(): string { pAcct(): string {
return getAcct(this.p.user); return getAcct(this.p.user);
}, },
pName(): string {
return getUserName(this.p.user);
},
isRepost(): boolean { isRepost(): boolean {
return (this.post.repost && return (this.post.repost &&
this.post.text == null && this.post.text == null &&

View File

@ -5,7 +5,7 @@
</router-link> </router-link>
<div class="main"> <div class="main">
<header> <header>
<router-link class="name" :to="`/@${acct}`">{{ post.user.name }}</router-link> <router-link class="name" :to="`/@${acct}`">{{ name }}</router-link>
<span class="username">@{{ acct }}</span> <span class="username">@{{ acct }}</span>
<router-link class="time" :to="`/@${acct}/${post.id}`"> <router-link class="time" :to="`/@${acct}/${post.id}`">
<mk-time :time="post.createdAt"/> <mk-time :time="post.createdAt"/>
@ -21,12 +21,16 @@
<script lang="ts"> <script lang="ts">
import Vue from 'vue'; import Vue from 'vue';
import getAcct from '../../../../../acct/render'; import getAcct from '../../../../../acct/render';
import getUserName from '../../../../../renderers/get-user-name';
export default Vue.extend({ export default Vue.extend({
props: ['post'], props: ['post'],
computed: { computed: {
acct() { acct() {
return getAcct(this.post.user); return getAcct(this.post.user);
},
name() {
return getUserName(this.post.user);
} }
} }
}); });

View File

@ -5,7 +5,7 @@
</router-link> </router-link>
<div class="main"> <div class="main">
<header> <header>
<router-link class="name" :to="`/@${acct}`">{{ post.user.name }}</router-link> <router-link class="name" :to="`/@${acct}`">{{ getUserName(post.user) }}</router-link>
<span class="username">@{{ acct }}</span> <span class="username">@{{ acct }}</span>
<router-link class="created-at" :to="`/@${acct}/${post.id}`"> <router-link class="created-at" :to="`/@${acct}/${post.id}`">
<mk-time :time="post.createdAt"/> <mk-time :time="post.createdAt"/>
@ -21,12 +21,16 @@
<script lang="ts"> <script lang="ts">
import Vue from 'vue'; import Vue from 'vue';
import getAcct from '../../../../../acct/render'; import getAcct from '../../../../../acct/render';
import getUserName from '../../../../../renderers/get-user-name';
export default Vue.extend({ export default Vue.extend({
props: ['post'], props: ['post'],
computed: { computed: {
acct() { acct() {
return getAcct(this.post.user); return getAcct(this.post.user);
},
name() {
return getUserName(this.post.user);
} }
} }
}); });

View File

@ -10,7 +10,7 @@
</router-link> </router-link>
%fa:retweet% %fa:retweet%
<span>{{ '%i18n:mobile.tags.mk-timeline-post.reposted-by%'.substr(0, '%i18n:mobile.tags.mk-timeline-post.reposted-by%'.indexOf('{')) }}</span> <span>{{ '%i18n:mobile.tags.mk-timeline-post.reposted-by%'.substr(0, '%i18n:mobile.tags.mk-timeline-post.reposted-by%'.indexOf('{')) }}</span>
<router-link class="name" :to="`/@${acct}`">{{ post.user.name }}</router-link> <router-link class="name" :to="`/@${acct}`">{{ name }}</router-link>
<span>{{ '%i18n:mobile.tags.mk-timeline-post.reposted-by%'.substr('%i18n:mobile.tags.mk-timeline-post.reposted-by%'.indexOf('}') + 1) }}</span> <span>{{ '%i18n:mobile.tags.mk-timeline-post.reposted-by%'.substr('%i18n:mobile.tags.mk-timeline-post.reposted-by%'.indexOf('}') + 1) }}</span>
</p> </p>
<mk-time :time="post.createdAt"/> <mk-time :time="post.createdAt"/>
@ -21,7 +21,7 @@
</router-link> </router-link>
<div class="main"> <div class="main">
<header> <header>
<router-link class="name" :to="`/@${pAcct}`">{{ p.user.name }}</router-link> <router-link class="name" :to="`/@${pAcct}`">{{ pName }}</router-link>
<span class="is-bot" v-if="p.user.host === null && p.user.account.isBot">bot</span> <span class="is-bot" v-if="p.user.host === null && p.user.account.isBot">bot</span>
<span class="username">@{{ pAcct }}</span> <span class="username">@{{ pAcct }}</span>
<div class="info"> <div class="info">
@ -78,6 +78,7 @@
<script lang="ts"> <script lang="ts">
import Vue from 'vue'; import Vue from 'vue';
import getAcct from '../../../../../acct/render'; import getAcct from '../../../../../acct/render';
import getUserName from '../../../../../renderers/get-user-name';
import parse from '../../../../../text/parse'; import parse from '../../../../../text/parse';
import MkPostMenu from '../../../common/views/components/post-menu.vue'; import MkPostMenu from '../../../common/views/components/post-menu.vue';
@ -102,9 +103,15 @@ export default Vue.extend({
acct(): string { acct(): string {
return getAcct(this.post.user); return getAcct(this.post.user);
}, },
name(): string {
return getUserName(this.post.user);
},
pAcct(): string { pAcct(): string {
return getAcct(this.p.user); return getAcct(this.p.user);
}, },
pName(): string {
return getUserName(this.p.user);
},
isRepost(): boolean { isRepost(): boolean {
return (this.post.repost && return (this.post.repost &&
this.post.text == null && this.post.text == null &&

View File

@ -3,7 +3,7 @@
<mk-special-message/> <mk-special-message/>
<div class="main" ref="main"> <div class="main" ref="main">
<div class="backdrop"></div> <div class="backdrop"></div>
<p ref="welcomeback" v-if="os.isSignedIn">おかえりなさい<b>{{ os.i.name }}</b>さん</p> <p ref="welcomeback" v-if="os.isSignedIn">おかえりなさい<b>{{ name }}</b>さん</p>
<div class="content" ref="mainContainer"> <div class="content" ref="mainContainer">
<button class="nav" @click="$parent.isDrawerOpening = true">%fa:bars%</button> <button class="nav" @click="$parent.isDrawerOpening = true">%fa:bars%</button>
<template v-if="hasUnreadNotifications || hasUnreadMessagingMessages || hasGameInvitations">%fa:circle%</template> <template v-if="hasUnreadNotifications || hasUnreadMessagingMessages || hasGameInvitations">%fa:circle%</template>
@ -19,9 +19,15 @@
<script lang="ts"> <script lang="ts">
import Vue from 'vue'; import Vue from 'vue';
import * as anime from 'animejs'; import * as anime from 'animejs';
import getUserName from '../../../../../renderers/get-user-name';
export default Vue.extend({ export default Vue.extend({
props: ['func'], props: ['func'],
computed: {
name() {
return getUserName(this.os.i);
}
},
data() { data() {
return { return {
hasUnreadNotifications: false, hasUnreadNotifications: false,

View File

@ -11,7 +11,7 @@
<div class="body" v-if="isOpen"> <div class="body" v-if="isOpen">
<router-link class="me" v-if="os.isSignedIn" :to="`/@${os.i.username}`"> <router-link class="me" v-if="os.isSignedIn" :to="`/@${os.i.username}`">
<img class="avatar" :src="`${os.i.avatarUrl}?thumbnail&size=128`" alt="avatar"/> <img class="avatar" :src="`${os.i.avatarUrl}?thumbnail&size=128`" alt="avatar"/>
<p class="name">{{ os.i.name }}</p> <p class="name">{{ name }}</p>
</router-link> </router-link>
<div class="links"> <div class="links">
<ul> <ul>
@ -40,9 +40,15 @@
<script lang="ts"> <script lang="ts">
import Vue from 'vue'; import Vue from 'vue';
import { docsUrl, chUrl, lang } from '../../../config'; import { docsUrl, chUrl, lang } from '../../../config';
import getUserName from '../../../../../renderers/get-user-name';
export default Vue.extend({ export default Vue.extend({
props: ['isOpen'], props: ['isOpen'],
computed: {
name() {
return getUserName(this.os.i);
}
},
data() { data() {
return { return {
hasUnreadNotifications: false, hasUnreadNotifications: false,

View File

@ -5,7 +5,7 @@
<img :src="`${user.avatarUrl}?thumbnail&size=200`" alt="avatar"/> <img :src="`${user.avatarUrl}?thumbnail&size=200`" alt="avatar"/>
</a> </a>
</header> </header>
<a class="name" :href="`/@${acct}`" target="_blank">{{ user.name }}</a> <a class="name" :href="`/@${acct}`" target="_blank">{{ name }}</a>
<p class="username">@{{ acct }}</p> <p class="username">@{{ acct }}</p>
<mk-follow-button :user="user"/> <mk-follow-button :user="user"/>
</div> </div>
@ -14,12 +14,16 @@
<script lang="ts"> <script lang="ts">
import Vue from 'vue'; import Vue from 'vue';
import getAcct from '../../../../../acct/render'; import getAcct from '../../../../../acct/render';
import getUserName from '../../../../../renderers/get-user-name';
export default Vue.extend({ export default Vue.extend({
props: ['user'], props: ['user'],
computed: { computed: {
acct() { acct() {
return getAcct(this.user); return getAcct(this.user);
},
name() {
return getUserName(this.user);
} }
} }
}); });

View File

@ -5,7 +5,7 @@
</router-link> </router-link>
<div class="main"> <div class="main">
<header> <header>
<router-link class="name" :to="`/@${acct}`">{{ user.name }}</router-link> <router-link class="name" :to="`/@${acct}`">{{ name }}</router-link>
<span class="username">@{{ acct }}</span> <span class="username">@{{ acct }}</span>
</header> </header>
<div class="body"> <div class="body">
@ -18,12 +18,16 @@
<script lang="ts"> <script lang="ts">
import Vue from 'vue'; import Vue from 'vue';
import getAcct from '../../../../../acct/render'; import getAcct from '../../../../../acct/render';
import getUserName from '../../../../../renderers/get-user-name';
export default Vue.extend({ export default Vue.extend({
props: ['user'], props: ['user'],
computed: { computed: {
acct() { acct() {
return getAcct(this.user); return getAcct(this.user);
},
name() {
return getUserName(this.user);
} }
} }
}); });

View File

@ -2,7 +2,7 @@
<mk-ui> <mk-ui>
<template slot="header" v-if="!fetching"> <template slot="header" v-if="!fetching">
<img :src="`${user.avatarUrl}?thumbnail&size=64`" alt=""> <img :src="`${user.avatarUrl}?thumbnail&size=64`" alt="">
{{ '%i18n:mobile.tags.mk-user-followers-page.followers-of%'.replace('{}', user.name) }} {{ '%i18n:mobile.tags.mk-user-followers-page.followers-of%'.replace('{}', name) }}
</template> </template>
<mk-users-list <mk-users-list
v-if="!fetching" v-if="!fetching"
@ -20,6 +20,7 @@
import Vue from 'vue'; import Vue from 'vue';
import Progress from '../../../common/scripts/loading'; import Progress from '../../../common/scripts/loading';
import parseAcct from '../../../../../acct/parse'; import parseAcct from '../../../../../acct/parse';
import getUserName from '../../../../../renderers/get-user-name';
export default Vue.extend({ export default Vue.extend({
data() { data() {
@ -28,6 +29,11 @@ export default Vue.extend({
user: null user: null
}; };
}, },
computed: {
name() {
return getUserName(this.user);
}
},
watch: { watch: {
$route: 'fetch' $route: 'fetch'
}, },
@ -46,7 +52,7 @@ export default Vue.extend({
this.user = user; this.user = user;
this.fetching = false; this.fetching = false;
document.title = '%i18n:mobile.tags.mk-user-followers-page.followers-of%'.replace('{}', user.name) + ' | Misskey'; document.title = '%i18n:mobile.tags.mk-user-followers-page.followers-of%'.replace('{}', this.name) + ' | Misskey';
}); });
}, },
onLoaded() { onLoaded() {

View File

@ -2,7 +2,7 @@
<mk-ui> <mk-ui>
<template slot="header" v-if="!fetching"> <template slot="header" v-if="!fetching">
<img :src="`${user.avatarUrl}?thumbnail&size=64`" alt=""> <img :src="`${user.avatarUrl}?thumbnail&size=64`" alt="">
{{ '%i18n:mobile.tags.mk-user-following-page.following-of%'.replace('{}', user.name) }} {{ '%i18n:mobile.tags.mk-user-following-page.following-of%'.replace('{}', name) }}
</template> </template>
<mk-users-list <mk-users-list
v-if="!fetching" v-if="!fetching"
@ -20,6 +20,7 @@
import Vue from 'vue'; import Vue from 'vue';
import Progress from '../../../common/scripts/loading'; import Progress from '../../../common/scripts/loading';
import parseAcct from '../../../../../acct/parse'; import parseAcct from '../../../../../acct/parse';
import getUserName from '../../../../../renderers/get-user-name';
export default Vue.extend({ export default Vue.extend({
data() { data() {
@ -28,6 +29,11 @@ export default Vue.extend({
user: null user: null
}; };
}, },
computed: {
name() {
return getUserName(this.user);
}
},
watch: { watch: {
$route: 'fetch' $route: 'fetch'
}, },
@ -46,7 +52,7 @@ export default Vue.extend({
this.user = user; this.user = user;
this.fetching = false; this.fetching = false;
document.title = '%i18n:mobile.tags.mk-user-followers-page.followers-of%'.replace('{}', user.name) + ' | Misskey'; document.title = '%i18n:mobile.tags.mk-user-followers-page.followers-of%'.replace('{}', this.name) + ' | Misskey';
}); });
}, },
onLoaded() { onLoaded() {

View File

@ -1,7 +1,7 @@
<template> <template>
<mk-ui> <mk-ui>
<span slot="header"> <span slot="header">
<template v-if="user">%fa:R comments%{{ user.name }}</template> <template v-if="user">%fa:R comments%{{ name }}</template>
<template v-else><mk-ellipsis/></template> <template v-else><mk-ellipsis/></template>
</span> </span>
<mk-messaging-room v-if="!fetching" :user="user" :is-naked="true"/> <mk-messaging-room v-if="!fetching" :user="user" :is-naked="true"/>
@ -11,6 +11,7 @@
<script lang="ts"> <script lang="ts">
import Vue from 'vue'; import Vue from 'vue';
import parseAcct from '../../../../../acct/parse'; import parseAcct from '../../../../../acct/parse';
import getUserName from '../../../../../renderers/get-user-name';
export default Vue.extend({ export default Vue.extend({
data() { data() {
@ -19,6 +20,11 @@ export default Vue.extend({
user: null user: null
}; };
}, },
computed: {
name() {
return getUserName(this.user);
}
},
watch: { watch: {
$route: 'fetch' $route: 'fetch'
}, },
@ -33,7 +39,7 @@ export default Vue.extend({
this.user = user; this.user = user;
this.fetching = false; this.fetching = false;
document.title = `%i18n:mobile.tags.mk-messaging-room-page.message%: ${user.name} | Misskey`; document.title = `%i18n:mobile.tags.mk-messaging-room-page.message%: ${this.name} | Misskey`;
}); });
} }
} }

View File

@ -52,7 +52,7 @@ export default Vue.extend({
}; };
}, },
created() { created() {
this.name = (this as any).os.i.name; this.name = (this as any).os.i.name || '';
this.location = (this as any).os.i.account.profile.location; this.location = (this as any).os.i.account.profile.location;
this.description = (this as any).os.i.description; this.description = (this as any).os.i.description;
this.birthday = (this as any).os.i.account.profile.birthday; this.birthday = (this as any).os.i.account.profile.birthday;
@ -94,7 +94,7 @@ export default Vue.extend({
this.saving = true; this.saving = true;
(this as any).api('i/update', { (this as any).api('i/update', {
name: this.name, name: this.name || null,
location: this.location || null, location: this.location || null,
description: this.description || null, description: this.description || null,
birthday: this.birthday || null birthday: this.birthday || null

View File

@ -2,7 +2,7 @@
<mk-ui> <mk-ui>
<span slot="header">%fa:cog%%i18n:mobile.tags.mk-settings-page.settings%</span> <span slot="header">%fa:cog%%i18n:mobile.tags.mk-settings-page.settings%</span>
<div :class="$style.content"> <div :class="$style.content">
<p v-html="'%i18n:mobile.tags.mk-settings.signed-in-as%'.replace('{}', '<b>' + os.i.name + '</b>')"></p> <p v-html="'%i18n:mobile.tags.mk-settings.signed-in-as%'.replace('{}', '<b>' + name + '</b>')"></p>
<ul> <ul>
<li><router-link to="./settings/profile">%fa:user%%i18n:mobile.tags.mk-settings-page.profile%%fa:angle-right%</router-link></li> <li><router-link to="./settings/profile">%fa:user%%i18n:mobile.tags.mk-settings-page.profile%%fa:angle-right%</router-link></li>
<li><router-link to="./settings/authorized-apps">%fa:puzzle-piece%%i18n:mobile.tags.mk-settings-page.applications%%fa:angle-right%</router-link></li> <li><router-link to="./settings/authorized-apps">%fa:puzzle-piece%%i18n:mobile.tags.mk-settings-page.applications%%fa:angle-right%</router-link></li>
@ -20,6 +20,7 @@
<script lang="ts"> <script lang="ts">
import Vue from 'vue'; import Vue from 'vue';
import { version, codename } from '../../../config'; import { version, codename } from '../../../config';
import getUserName from '../../../../../renderers/get-user-name';
export default Vue.extend({ export default Vue.extend({
data() { data() {
@ -28,6 +29,11 @@ export default Vue.extend({
codename codename
}; };
}, },
computed: {
name() {
return getUserName(this.os.i);
}
},
mounted() { mounted() {
document.title = 'Misskey | %i18n:mobile.tags.mk-settings-page.settings%'; document.title = 'Misskey | %i18n:mobile.tags.mk-settings-page.settings%';
document.documentElement.style.background = '#313a42'; document.documentElement.style.background = '#313a42';

View File

@ -1,6 +1,6 @@
<template> <template>
<mk-ui> <mk-ui>
<span slot="header" v-if="!fetching">%fa:user% {{ user.name }}</span> <span slot="header" v-if="!fetching">%fa:user% {{ user }}</span>
<main v-if="!fetching"> <main v-if="!fetching">
<header> <header>
<div class="banner" :style="user.bannerUrl ? `background-image: url(${user.bannerUrl}?thumbnail&size=1024)` : ''"></div> <div class="banner" :style="user.bannerUrl ? `background-image: url(${user.bannerUrl}?thumbnail&size=1024)` : ''"></div>
@ -12,7 +12,7 @@
<mk-follow-button v-if="os.isSignedIn && os.i.id != user.id" :user="user"/> <mk-follow-button v-if="os.isSignedIn && os.i.id != user.id" :user="user"/>
</div> </div>
<div class="title"> <div class="title">
<h1>{{ user.name }}</h1> <h1>{{ user }}</h1>
<span class="username">@{{ acct }}</span> <span class="username">@{{ acct }}</span>
<span class="followed" v-if="user.isFollowed">%i18n:mobile.tags.mk-user.follows-you%</span> <span class="followed" v-if="user.isFollowed">%i18n:mobile.tags.mk-user.follows-you%</span>
</div> </div>
@ -61,7 +61,7 @@
import Vue from 'vue'; import Vue from 'vue';
import * as age from 's-age'; import * as age from 's-age';
import getAcct from '../../../../../acct/render'; import getAcct from '../../../../../acct/render';
import getAcct from '../../../../../acct/parse'; import getUserName from '../../../../../renderers/get-user-name';
import Progress from '../../../common/scripts/loading'; import Progress from '../../../common/scripts/loading';
import XHome from './user/home.vue'; import XHome from './user/home.vue';
@ -82,6 +82,9 @@ export default Vue.extend({
}, },
age(): number { age(): number {
return age(this.user.account.profile.birthday); return age(this.user.account.profile.birthday);
},
name() {
return getUserName(this.user);
} }
}, },
watch: { watch: {
@ -102,7 +105,7 @@ export default Vue.extend({
this.fetching = false; this.fetching = false;
Progress.done(); Progress.done();
document.title = user.name + ' | Misskey'; document.title = this.name + ' | Misskey';
}); });
} }
} }

View File

@ -3,7 +3,7 @@
<p class="initializing" v-if="fetching">%fa:spinner .pulse .fw%%i18n:mobile.tags.mk-user-overview-followers-you-know.loading%<mk-ellipsis/></p> <p class="initializing" v-if="fetching">%fa:spinner .pulse .fw%%i18n:mobile.tags.mk-user-overview-followers-you-know.loading%<mk-ellipsis/></p>
<div v-if="!fetching && users.length > 0"> <div v-if="!fetching && users.length > 0">
<a v-for="user in users" :key="user.id" :href="`/@${getAcct(user)}`"> <a v-for="user in users" :key="user.id" :href="`/@${getAcct(user)}`">
<img :src="`${user.avatarUrl}?thumbnail&size=64`" :alt="user.name"/> <img :src="`${user.avatarUrl}?thumbnail&size=64`" :alt="getUserName(user)"/>
</a> </a>
</div> </div>
<p class="empty" v-if="!fetching && users.length == 0">%i18n:mobile.tags.mk-user-overview-followers-you-know.no-users%</p> <p class="empty" v-if="!fetching && users.length == 0">%i18n:mobile.tags.mk-user-overview-followers-you-know.no-users%</p>
@ -13,6 +13,7 @@
<script lang="ts"> <script lang="ts">
import Vue from 'vue'; import Vue from 'vue';
import getAcct from '../../../../../../acct/render'; import getAcct from '../../../../../../acct/render';
import getUserName from '../../../../../../renderers/get-user-name';
export default Vue.extend({ export default Vue.extend({
props: ['user'], props: ['user'],
@ -22,6 +23,11 @@ export default Vue.extend({
users: [] users: []
}; };
}, },
computed: {
name() {
return getUserName(this.user);
}
},
methods: { methods: {
getAcct getAcct
}, },

View File

@ -8,15 +8,23 @@
:src="`${os.i.avatarUrl}?thumbnail&size=96`" :src="`${os.i.avatarUrl}?thumbnail&size=96`"
alt="avatar" alt="avatar"
/> />
<router-link :class="$style.name" :to="`/@${os.i.username}`">{{ os.i.name }}</router-link> <router-link :class="$style.name" :to="`/@${os.i.username}`">{{ name }}</router-link>
</mk-widget-container> </mk-widget-container>
</div> </div>
</template> </template>
<script lang="ts"> <script lang="ts">
import define from '../../../common/define-widget'; import define from '../../../common/define-widget';
import getUserName from '../../../../../renderers/get-user-name';
export default define({ export default define({
name: 'profile' name: 'profile'
}).extend({
computed: {
name() {
return getUserName(this.os.i);
}
}
}); });
</script> </script>

View File

@ -1,42 +0,0 @@
import User, { pack as packUser } from '../models/user';
import FollowingLog from '../models/following-log';
import FollowedLog from '../models/followed-log';
import event from '../publishers/stream';
import notify from '../publishers/notify';
export default async (follower, followee) => Promise.all([
// Increment following count
User.update(follower._id, {
$inc: {
followingCount: 1
}
}),
FollowingLog.insert({
createdAt: new Date(),
userId: followee._id,
count: follower.followingCount + 1
}),
// Increment followers count
User.update({ _id: followee._id }, {
$inc: {
followersCount: 1
}
}),
FollowedLog.insert({
createdAt: new Date(),
userId: follower._id,
count: followee.followersCount + 1
}),
followee.host === null && Promise.all([
// Notify
notify(followee.id, follower.id, 'follow'),
// Publish follow event
packUser(follower, followee)
.then(packed => event(followee._id, 'followed', packed))
])
]);

View File

@ -30,8 +30,12 @@ const ev = new Xev();
process.title = 'Misskey'; process.title = 'Misskey';
if (process.env.NODE_ENV != 'production') {
process.env.DEBUG = 'misskey:*';
}
// https://github.com/Automattic/kue/issues/822 // https://github.com/Automattic/kue/issues/822
require('events').EventEmitter.prototype._maxListeners = 256; require('events').EventEmitter.prototype._maxListeners = 512;
// Start app // Start app
main(); main();
@ -99,7 +103,7 @@ async function workerMain(opt) {
if (!opt['only-server']) { if (!opt['only-server']) {
// start processor // start processor
require('./queue').process(); require('./queue').default();
} }
// Send a 'ready' message to parent process // Send a 'ready' message to parent process

View File

@ -2,6 +2,7 @@ import * as mongo from 'mongodb';
import db from '../db/mongodb'; import db from '../db/mongodb';
const PostWatching = db.get<IPostWatching>('postWatching'); const PostWatching = db.get<IPostWatching>('postWatching');
PostWatching.createIndex(['userId', 'postId'], { unique: true });
export default PostWatching; export default PostWatching;
export interface IPostWatching { export interface IPostWatching {

View File

@ -27,6 +27,7 @@ export type IPost = {
_id: mongo.ObjectID; _id: mongo.ObjectID;
channelId: mongo.ObjectID; channelId: mongo.ObjectID;
createdAt: Date; createdAt: Date;
deletedAt: Date;
mediaIds: mongo.ObjectID[]; mediaIds: mongo.ObjectID[];
replyId: mongo.ObjectID; replyId: mongo.ObjectID;
repostId: mongo.ObjectID; repostId: mongo.ObjectID;
@ -52,6 +53,20 @@ export type IPost = {
speed: number; speed: number;
}; };
uri: string; uri: string;
_reply?: {
userId: mongo.ObjectID;
};
_repost?: {
userId: mongo.ObjectID;
};
_user: {
host: string;
hostLower: string;
account: {
inbox?: string;
};
};
}; };
/** /**

View File

@ -21,7 +21,7 @@ type IUserBase = {
deletedAt: Date; deletedAt: Date;
followersCount: number; followersCount: number;
followingCount: number; followingCount: number;
name: string; name?: string;
postsCount: number; postsCount: number;
driveCapacity: number; driveCapacity: number;
username: string; username: string;
@ -99,8 +99,8 @@ export function validatePassword(password: string): boolean {
return typeof password == 'string' && password != ''; return typeof password == 'string' && password != '';
} }
export function isValidName(name: string): boolean { export function isValidName(name?: string): boolean {
return typeof name == 'string' && name.length < 30 && name.trim() != ''; return name === null || (typeof name == 'string' && name.length < 30 && name.trim() != '');
} }
export function isValidDescription(description: string): boolean { export function isValidDescription(description: string): boolean {

View File

@ -9,6 +9,7 @@
import * as request from 'request-promise-native'; import * as request from 'request-promise-native';
import Othello, { Color } from '../core'; import Othello, { Color } from '../core';
import conf from '../../config'; import conf from '../../config';
import getUserName from '../../renderers/get-user-name';
let game; let game;
let form; let form;
@ -47,8 +48,8 @@ process.on('message', async msg => {
const user = game.user1Id == id ? game.user2 : game.user1; const user = game.user1Id == id ? game.user2 : game.user1;
const isSettai = form[0].value === 0; const isSettai = form[0].value === 0;
const text = isSettai const text = isSettai
? `?[${user.name}](${conf.url}/@${user.username})さんの接待を始めました!` ? `?[${getUserName(user)}](${conf.url}/@${user.username})さんの接待を始めました!`
: `対局を?[${user.name}](${conf.url}/@${user.username})さんと始めました! (強さ${form[0].value})`; : `対局を?[${getUserName(user)}](${conf.url}/@${user.username})さんと始めました! (強さ${form[0].value})`;
const res = await request.post(`${conf.api_url}/posts/create`, { const res = await request.post(`${conf.api_url}/posts/create`, {
json: { i, json: { i,
@ -72,15 +73,15 @@ process.on('message', async msg => {
const isSettai = form[0].value === 0; const isSettai = form[0].value === 0;
const text = isSettai const text = isSettai
? msg.body.winnerId === null ? msg.body.winnerId === null
? `?[${user.name}](${conf.url}/@${user.username})さんに接待で引き分けました...` ? `?[${getUserName(user)}](${conf.url}/@${user.username})さんに接待で引き分けました...`
: msg.body.winnerId == id : msg.body.winnerId == id
? `?[${user.name}](${conf.url}/@${user.username})さんに接待で勝ってしまいました...` ? `?[${getUserName(user)}](${conf.url}/@${user.username})さんに接待で勝ってしまいました...`
: `?[${user.name}](${conf.url}/@${user.username})さんに接待で負けてあげました♪` : `?[${getUserName(user)}](${conf.url}/@${user.username})さんに接待で負けてあげました♪`
: msg.body.winnerId === null : msg.body.winnerId === null
? `?[${user.name}](${conf.url}/@${user.username})さんと引き分けました~` ? `?[${getUserName(user)}](${conf.url}/@${user.username})さんと引き分けました~`
: msg.body.winnerId == id : msg.body.winnerId == id
? `?[${user.name}](${conf.url}/@${user.username})さんに勝ちました♪` ? `?[${getUserName(user)}](${conf.url}/@${user.username})さんに勝ちました♪`
: `?[${user.name}](${conf.url}/@${user.username})さんに負けました...`; : `?[${getUserName(user)}](${conf.url}/@${user.username})さんに負けました...`;
await request.post(`${conf.api_url}/posts/create`, { await request.post(`${conf.api_url}/posts/create`, {
json: { i, json: { i,

View File

@ -1,40 +0,0 @@
import Post from '../models/post';
export default async (post, reply, repost, mentions) => {
post.mentions = [];
function addMention(mentionee) {
// Reject if already added
if (post.mentions.some(x => x.equals(mentionee))) return;
// Add mention
post.mentions.push(mentionee);
}
if (reply) {
// Add mention
addMention(reply.userId);
post.replyId = reply._id;
post._reply = { userId: reply.userId };
} else {
post.replyId = null;
post._reply = null;
}
if (repost) {
if (post.text) {
// Add mention
addMention(repost.userId);
}
post.repostId = repost._id;
post._repost = { userId: repost.userId };
} else {
post.repostId = null;
post._repost = null;
}
await Promise.all(mentions.map(({ _id }) => addMention(_id)));
return Post.insert(post);
};

View File

@ -1,274 +0,0 @@
import Channel from '../models/channel';
import ChannelWatching from '../models/channel-watching';
import Following from '../models/following';
import Mute from '../models/mute';
import Post, { pack } from '../models/post';
import Watching from '../models/post-watching';
import User, { isLocalUser } from '../models/user';
import stream, { publishChannelStream } from '../publishers/stream';
import notify from '../publishers/notify';
import pushSw from '../publishers/push-sw';
import { createHttp } from '../queue';
import watch from './watch';
export default async (user, mentions, post) => {
const promisedPostObj = pack(post);
const promises = [
User.update({ _id: user._id }, {
// Increment my posts count
$inc: {
postsCount: 1
},
$set: {
latestPost: post._id
}
}),
] as Array<Promise<any>>;
function addMention(promisedMentionee, reason) {
// Publish event
promises.push(promisedMentionee.then(mentionee => {
if (user._id.equals(mentionee)) {
return Promise.resolve();
}
return Promise.all([
promisedPostObj,
Mute.find({
muterId: mentionee,
deletedAt: { $exists: false }
})
]).then(([postObj, mentioneeMutes]) => {
const mentioneesMutedUserIds = mentioneeMutes.map(m => m.muteeId.toString());
if (mentioneesMutedUserIds.indexOf(user._id.toString()) == -1) {
stream(mentionee, reason, postObj);
pushSw(mentionee, reason, postObj);
}
});
}));
}
// タイムラインへの投稿
if (!post.channelId) {
promises.push(
// Publish event to myself's stream
promisedPostObj.then(postObj => {
stream(post.userId, 'post', postObj);
}),
Promise.all([
User.findOne({ _id: post.userId }),
// Fetch all followers
Following.aggregate([{
$lookup: {
from: 'users',
localField: 'followerId',
foreignField: '_id',
as: 'follower'
}
}, {
$match: {
followeeId: post.userId
}
}], {
_id: false
})
]).then(([user, followers]) => Promise.all(followers.map(following => {
if (isLocalUser(following.follower)) {
// Publish event to followers stream
return promisedPostObj.then(postObj => {
stream(following.followerId, 'post', postObj);
});
}
return new Promise((resolve, reject) => {
createHttp({
type: 'deliverPost',
fromId: user._id,
toId: following.followerId,
postId: post._id
}).save(error => {
if (error) {
reject(error);
} else {
resolve();
}
});
});
})))
);
}
// チャンネルへの投稿
if (post.channelId) {
promises.push(
// Increment channel index(posts count)
Channel.update({ _id: post.channelId }, {
$inc: {
index: 1
}
}),
// Publish event to channel
promisedPostObj.then(postObj => {
publishChannelStream(post.channelId, 'post', postObj);
}),
Promise.all([
promisedPostObj,
// Get channel watchers
ChannelWatching.find({
channelId: post.channelId,
// 削除されたドキュメントは除く
deletedAt: { $exists: false }
})
]).then(([postObj, watches]) => {
// チャンネルの視聴者(のタイムライン)に配信
watches.forEach(w => {
stream(w.userId, 'post', postObj);
});
})
);
}
// If has in reply to post
if (post.replyId) {
promises.push(
// Increment replies count
Post.update({ _id: post.replyId }, {
$inc: {
repliesCount: 1
}
}),
// 自分自身へのリプライでない限りは通知を作成
promisedPostObj.then(({ reply }) => {
return notify(reply.userId, user._id, 'reply', {
postId: post._id
});
}),
// Fetch watchers
Watching
.find({
postId: post.replyId,
userId: { $ne: user._id },
// 削除されたドキュメントは除く
deletedAt: { $exists: false }
}, {
fields: {
userId: true
}
})
.then(watchers => {
watchers.forEach(watcher => {
notify(watcher.userId, user._id, 'reply', {
postId: post._id
});
});
})
);
// Add mention
addMention(promisedPostObj.then(({ reply }) => reply.userId), 'reply');
// この投稿をWatchする
if (user.account.settings.autoWatch !== false) {
promises.push(promisedPostObj.then(({ reply }) => {
return watch(user._id, reply);
}));
}
}
// If it is repost
if (post.repostId) {
const type = post.text ? 'quote' : 'repost';
promises.push(
promisedPostObj.then(({ repost }) => Promise.all([
// Notify
notify(repost.userId, user._id, type, {
postId: post._id
}),
// この投稿をWatchする
// TODO: ユーザーが「Repostしたときに自動でWatchする」設定を
// オフにしていた場合はしない
watch(user._id, repost)
])),
// Fetch watchers
Watching
.find({
postId: post.repostId,
userId: { $ne: user._id },
// 削除されたドキュメントは除く
deletedAt: { $exists: false }
}, {
fields: {
userId: true
}
})
.then(watchers => {
watchers.forEach(watcher => {
notify(watcher.userId, user._id, type, {
postId: post._id
});
});
})
);
// If it is quote repost
if (post.text) {
// Add mention
addMention(promisedPostObj.then(({ repost }) => repost.userId), 'quote');
} else {
promises.push(promisedPostObj.then(postObj => {
// Publish event
if (!user._id.equals(postObj.repost.userId)) {
stream(postObj.repost.userId, 'repost', postObj);
}
}));
}
// 今までで同じ投稿をRepostしているか
const existRepost = await Post.findOne({
userId: user._id,
repostId: post.repostId,
_id: {
$ne: post._id
}
});
if (!existRepost) {
// Update repostee status
promises.push(Post.update({ _id: post.repostId }, {
$inc: {
repostCount: 1
}
}));
}
}
// Resolve all mentions
await promisedPostObj.then(({ reply, repost }) => Promise.all(mentions.map(async mention => {
// 既に言及されたユーザーに対する返信や引用repostの場合も無視
if (reply && reply.userId.equals(mention)) return;
if (repost && repost.userId.equals(mention)) return;
// Add mention
addMention(mention, 'mention');
// Create notification
await notify(mention, user._id, 'mention', {
postId: post._id
});
})));
await Promise.all(promises);
return promisedPostObj;
};

View File

@ -1,6 +1,6 @@
import { createQueue } from 'kue'; import { createQueue } from 'kue';
import config from '../config'; import config from '../config';
import db from './processors/db';
import http from './processors/http'; import http from './processors/http';
const queue = createQueue({ const queue = createQueue({
@ -18,17 +18,19 @@ export function createHttp(data) {
.backoff({ delay: 16384, type: 'exponential' }); .backoff({ delay: 16384, type: 'exponential' });
} }
export function createDb(data) { export function deliver(user, content, to) {
return queue.create('db', data); return createHttp({
type: 'deliver',
user,
content,
to
});
} }
export function process() { export default function() {
queue.process('db', db);
/* /*
256 is the default concurrency limit of Mozilla Firefox and Google 256 is the default concurrency limit of Mozilla Firefox and Google
Chromium. Chromium.
a8af215e691f3a2205a3758d2d96e9d328e100ff - chromium/src.git - Git at Google a8af215e691f3a2205a3758d2d96e9d328e100ff - chromium/src.git - Git at Google
https://chromium.googlesource.com/chromium/src.git/+/a8af215e691f3a2205a3758d2d96e9d328e100ff https://chromium.googlesource.com/chromium/src.git/+/a8af215e691f3a2205a3758d2d96e9d328e100ff
Network.http.max-connections - MozillaZine Knowledge Base Network.http.max-connections - MozillaZine Knowledge Base

View File

@ -1,22 +0,0 @@
import Favorite from '../../../models/favorite';
import Notification from '../../../models/notification';
import PollVote from '../../../models/poll-vote';
import PostReaction from '../../../models/post-reaction';
import PostWatching from '../../../models/post-watching';
import Post from '../../../models/post';
export default ({ data }, done) => Promise.all([
Favorite.remove({ postId: data._id }),
Notification.remove({ postId: data._id }),
PollVote.remove({ postId: data._id }),
PostReaction.remove({ postId: data._id }),
PostWatching.remove({ postId: data._id }),
Post.find({ repostId: data._id }).then(reposts => Promise.all([
Notification.remove({
postId: {
$in: reposts.map(({ _id }) => _id)
}
}),
Post.remove({ repostId: data._id })
]))
]).then(() => done(), done);

View File

@ -1,7 +0,0 @@
import deletePostDependents from './delete-post-dependents';
const handlers = {
deletePostDependents
};
export default (job, done) => handlers[job.data.type](job, done);

View File

@ -1,27 +0,0 @@
import Post from '../../../models/post';
import User, { IRemoteUser } from '../../../models/user';
import context from '../../../remote/activitypub/renderer/context';
import renderCreate from '../../../remote/activitypub/renderer/create';
import renderNote from '../../../remote/activitypub/renderer/note';
import request from '../../../remote/request';
export default async ({ data }, done) => {
try {
const promisedTo = User.findOne({ _id: data.toId }) as Promise<IRemoteUser>;
const [from, post] = await Promise.all([
User.findOne({ _id: data.fromId }),
Post.findOne({ _id: data.postId })
]);
const note = await renderNote(from, post);
const to = await promisedTo;
const create = renderCreate(note);
create['@context'] = context;
await request(from, to.account.inbox, create);
} catch (error) {
done(error);
}
done();
};

View File

@ -0,0 +1,19 @@
import * as kue from 'kue';
import request from '../../../remote/request';
export default async (job: kue.Job, done): Promise<void> => {
try {
await request(job.data.user, job.data.to, job.data.content);
done();
} catch (res) {
if (res.statusCode >= 400 && res.statusCode < 500) {
// HTTPステータスコード4xxはクライアントエラーであり、それはつまり
// 何回再送しても成功することはないということなのでエラーにはしないでおく
done();
} else {
console.warn(`deliver failed: ${res.statusMessage}`);
done(new Error(res.statusMessage));
}
}
};

View File

@ -1,66 +0,0 @@
import User, { isLocalUser, isRemoteUser, pack as packUser } from '../../../models/user';
import Following from '../../../models/following';
import FollowingLog from '../../../models/following-log';
import FollowedLog from '../../../models/followed-log';
import event from '../../../publishers/stream';
import notify from '../../../publishers/notify';
import context from '../../../remote/activitypub/renderer/context';
import render from '../../../remote/activitypub/renderer/follow';
import request from '../../../remote/request';
export default ({ data }, done) => Following.findOne({ _id: data.following }).then(async ({ followerId, followeeId }) => {
const [follower, followee] = await Promise.all([
User.findOne({ _id: followerId }),
User.findOne({ _id: followeeId })
]);
if (isLocalUser(follower) && isRemoteUser(followee)) {
const rendered = render(follower, followee);
rendered['@context'] = context;
await request(follower, followee.account.inbox, rendered);
}
return [follower, followee];
}).then(([follower, followee]) => Promise.all([
// Increment following count
User.update(follower._id, {
$inc: {
followingCount: 1
}
}),
FollowingLog.insert({
createdAt: data.following.createdAt,
userId: follower._id,
count: follower.followingCount + 1
}),
// Increment followers count
User.update({ _id: followee._id }, {
$inc: {
followersCount: 1
}
}),
FollowedLog.insert({
createdAt: data.following.createdAt,
userId: follower._id,
count: followee.followersCount + 1
}),
// Publish follow event
isLocalUser(follower) && packUser(followee, follower)
.then(packed => event(follower._id, 'follow', packed)),
isLocalUser(followee) && Promise.all([
packUser(follower, followee)
.then(packed => event(followee._id, 'followed', packed)),
// Notify
isLocalUser(followee) && notify(followee._id, follower._id, 'follow')
])
]).then(() => done(), error => {
done();
throw error;
}), done);

View File

@ -1,17 +1,20 @@
import deliverPost from './deliver-post'; import deliver from './deliver';
import follow from './follow';
import performActivityPub from './perform-activitypub';
import processInbox from './process-inbox'; import processInbox from './process-inbox';
import reportGitHubFailure from './report-github-failure'; import reportGitHubFailure from './report-github-failure';
import unfollow from './unfollow';
const handlers = { const handlers = {
deliverPost, deliver,
follow,
performActivityPub,
processInbox, processInbox,
reportGitHubFailure, reportGitHubFailure
unfollow
}; };
export default (job, done) => handlers[job.data.type](job, done); export default (job, done) => {
const handler = handlers[job.data.type];
if (handler) {
handler(job, done);
} else {
console.error(`Unknown job: ${job.data.type}`);
done();
}
};

View File

@ -1,8 +0,0 @@
import User from '../../../models/user';
import act from '../../../remote/activitypub/act';
import Resolver from '../../../remote/activitypub/resolver';
export default ({ data }, done) => User.findOne({ _id: data.actor })
.then(actor => act(new Resolver(), actor, data.outbox))
.then(Promise.all)
.then(() => done(), done);

View File

@ -1,18 +1,33 @@
import * as kue from 'kue';
import * as debug from 'debug';
import { verifySignature } from 'http-signature'; import { verifySignature } from 'http-signature';
import parseAcct from '../../../acct/parse'; import parseAcct from '../../../acct/parse';
import User, { IRemoteUser } from '../../../models/user'; import User, { IRemoteUser } from '../../../models/user';
import act from '../../../remote/activitypub/act'; import act from '../../../remote/activitypub/act';
import resolvePerson from '../../../remote/activitypub/resolve-person'; import resolvePerson from '../../../remote/activitypub/resolve-person';
import Resolver from '../../../remote/activitypub/resolver';
export default async ({ data }, done) => { const log = debug('misskey:queue:inbox');
try {
const keyIdLower = data.signature.keyId.toLowerCase(); // ユーザーのinboxにアクティビティが届いた時の処理
export default async (job: kue.Job, done): Promise<void> => {
const signature = job.data.signature;
const activity = job.data.activity;
//#region Log
const info = Object.assign({}, activity);
delete info['@context'];
delete info['signature'];
log(info);
//#endregion
const keyIdLower = signature.keyId.toLowerCase();
let user; let user;
if (keyIdLower.startsWith('acct:')) { if (keyIdLower.startsWith('acct:')) {
const { username, host } = parseAcct(keyIdLower.slice('acct:'.length)); const { username, host } = parseAcct(keyIdLower.slice('acct:'.length));
if (host === null) { if (host === null) {
console.warn(`request was made by local user: @${username}`);
done(); done();
return; return;
} }
@ -21,24 +36,31 @@ export default async ({ data }, done) => {
} else { } else {
user = await User.findOne({ user = await User.findOne({
host: { $ne: null }, host: { $ne: null },
'account.publicKey.id': data.signature.keyId 'account.publicKey.id': signature.keyId
}) as IRemoteUser; }) as IRemoteUser;
// アクティビティを送信してきたユーザーがまだMisskeyサーバーに登録されていなかったら登録する
if (user === null) { if (user === null) {
user = await resolvePerson(new Resolver(), data.signature.keyId); user = await resolvePerson(signature.keyId);
} }
} }
if (user === null || !verifySignature(data.signature, user.account.publicKey.publicKeyPem)) { if (user === null) {
done(new Error('failed to resolve user'));
return;
}
if (!verifySignature(signature, user.account.publicKey.publicKeyPem)) {
console.warn('signature verification failed');
done(); done();
return; return;
} }
await Promise.all(await act(new Resolver(), user, data.inbox, true)); // アクティビティを処理
} catch (error) { try {
done(error); await act(user, activity);
return;
}
done(); done();
} catch (e) {
done(e);
}
}; };

View File

@ -1,9 +1,8 @@
import * as request from 'request-promise-native'; import * as request from 'request-promise-native';
import User from '../../../models/user'; import User from '../../../models/user';
const createPost = require('../../../server/api/endpoints/posts/create'); import createPost from '../../../services/post/create';
export default async ({ data }, done) => { export default async ({ data }) => {
try {
const asyncBot = User.findOne({ _id: data.userId }); const asyncBot = User.findOne({ _id: data.userId });
// Fetch parent status // Fetch parent status
@ -21,11 +20,5 @@ export default async ({ data }, done) => {
`**⚠BUILD STILL FAILED⚠**: ?[${data.message}](${data.htmlUrl})` : `**⚠BUILD STILL FAILED⚠**: ?[${data.message}](${data.htmlUrl})` :
`**🚨BUILD FAILED🚨**: →→→?[${data.message}](${data.htmlUrl})←←←`; `**🚨BUILD FAILED🚨**: →→→?[${data.message}](${data.htmlUrl})←←←`;
createPost({ text }, await asyncBot); createPost(await asyncBot, { text });
} catch (error) {
done(error);
return;
}
done();
}; };

View File

@ -1,71 +0,0 @@
import FollowedLog from '../../../models/followed-log';
import Following from '../../../models/following';
import FollowingLog from '../../../models/following-log';
import User, { isLocalUser, isRemoteUser, pack as packUser } from '../../../models/user';
import stream from '../../../publishers/stream';
import renderFollow from '../../../remote/activitypub/renderer/follow';
import renderUndo from '../../../remote/activitypub/renderer/undo';
import context from '../../../remote/activitypub/renderer/context';
import request from '../../../remote/request';
export default async ({ data }, done) => {
const following = await Following.findOne({ _id: data.id });
if (following === null) {
done();
return;
}
let follower;
let followee;
try {
[follower, followee] = await Promise.all([
User.findOne({ _id: following.followerId }),
User.findOne({ _id: following.followeeId })
]);
if (isLocalUser(follower) && isRemoteUser(followee)) {
const undo = renderUndo(renderFollow(follower, followee));
undo['@context'] = context;
await request(follower, followee.account.inbox, undo);
}
} catch (error) {
done(error);
return;
}
try {
await Promise.all([
// Delete following
Following.findOneAndDelete({ _id: data.id }),
// Decrement following count
User.update({ _id: follower._id }, { $inc: { followingCount: -1 } }),
FollowingLog.insert({
createdAt: new Date(),
userId: follower._id,
count: follower.followingCount - 1
}),
// Decrement followers count
User.update({ _id: followee._id }, { $inc: { followersCount: -1 } }),
FollowedLog.insert({
createdAt: new Date(),
userId: followee._id,
count: followee.followersCount - 1
})
]);
if (isLocalUser(follower)) {
return;
}
const promisedPackedUser = packUser(followee, follower);
// Publish follow event
stream(follower._id, 'unfollow', promisedPackedUser);
} finally {
done();
}
};

View File

@ -1,10 +0,0 @@
import create from '../create';
import Resolver from '../resolver';
export default (resolver: Resolver, actor, activity, distribute) => {
if ('actor' in activity && actor.account.uri !== activity.actor) {
throw new Error();
}
return create(resolver, actor, activity.object, distribute);
};

View File

@ -0,0 +1,18 @@
import * as debug from 'debug';
import uploadFromUrl from '../../../../services/drive/upload-from-url';
import { IRemoteUser } from '../../../../models/user';
import { IDriveFile } from '../../../../models/drive-file';
const log = debug('misskey:activitypub');
export default async function(actor: IRemoteUser, image): Promise<IDriveFile> {
if ('attributedTo' in image && actor.account.uri !== image.attributedTo) {
log(`invalid image: ${JSON.stringify(image, null, 2)}`);
throw new Error('invalid image');
}
log(`Creating the Image: ${image.id}`);
return await uploadFromUrl(image.url, actor);
}

View File

@ -0,0 +1,44 @@
import * as debug from 'debug';
import Resolver from '../../resolver';
import { IRemoteUser } from '../../../../models/user';
import createNote from './note';
import createImage from './image';
import { ICreate } from '../../type';
const log = debug('misskey:activitypub');
export default async (actor: IRemoteUser, activity: ICreate): Promise<void> => {
if ('actor' in activity && actor.account.uri !== activity.actor) {
throw new Error('invalid actor');
}
const uri = activity.id || activity;
log(`Create: ${uri}`);
const resolver = new Resolver();
let object;
try {
object = await resolver.resolve(activity.object);
} catch (e) {
log(`Resolution failed: ${e}`);
throw e;
}
switch (object.type) {
case 'Image':
createImage(actor, object);
break;
case 'Note':
createNote(resolver, actor, object);
break;
default:
console.warn(`Unknown type: ${object.type}`);
break;
}
};

View File

@ -0,0 +1,89 @@
import { JSDOM } from 'jsdom';
import * as debug from 'debug';
import Resolver from '../../resolver';
import Post, { IPost } from '../../../../models/post';
import createPost from '../../../../services/post/create';
import { IRemoteUser } from '../../../../models/user';
import resolvePerson from '../../resolve-person';
import createImage from './image';
import config from '../../../../config';
const log = debug('misskey:activitypub');
/**
* 稿
*/
export default async function createNote(resolver: Resolver, actor: IRemoteUser, note, silent = false): Promise<IPost> {
if (typeof note.id !== 'string') {
log(`invalid note: ${JSON.stringify(note, null, 2)}`);
throw new Error('invalid note');
}
// 既に同じURIを持つものが登録されていないかチェックし、登録されていたらそれを返す
const exist = await Post.findOne({ uri: note.id });
if (exist) {
return exist;
}
log(`Creating the Note: ${note.id}`);
//#region Visibility
let visibility = 'public';
if (!note.to.includes('https://www.w3.org/ns/activitystreams#Public')) visibility = 'unlisted';
if (note.cc.length == 0) visibility = 'private';
// TODO
if (visibility != 'public') throw new Error('unspported visibility');
//#endergion
//#region 添付メディア
const media = [];
if ('attachment' in note && note.attachment != null) {
// TODO: attachmentは必ずしもImageではない
// TODO: attachmentは必ずしも配列ではない
// TODO: ループの中でawaitはすべきでない
note.attachment.forEach(async media => {
const created = await createImage(note.actor, media);
media.push(created);
});
}
//#endregion
//#region リプライ
let reply = null;
if ('inReplyTo' in note && note.inReplyTo != null) {
// リプライ先の投稿がMisskeyに登録されているか調べる
const uri: string = note.inReplyTo.id || note.inReplyTo;
const inReplyToPost = uri.startsWith(config.url + '/')
? await Post.findOne({ _id: uri.split('/').pop() })
: await Post.findOne({ uri });
if (inReplyToPost) {
reply = inReplyToPost;
} else {
// 無かったらフェッチ
const inReplyTo = await resolver.resolve(note.inReplyTo) as any;
// リプライ先の投稿の投稿者をフェッチ
const actor = await resolvePerson(inReplyTo.attributedTo) as IRemoteUser;
// TODO: silentを常にtrueにしてはならない
reply = await createNote(resolver, actor, inReplyTo);
}
}
//#endregion
const { window } = new JSDOM(note.content);
return await createPost(actor, {
createdAt: new Date(note.published),
media,
reply,
repost: undefined,
text: window.document.body.textContent,
viaMobile: false,
geo: undefined,
visibility,
uri: note.id
});
}

View File

@ -1,21 +0,0 @@
import create from '../create';
import deleteObject from '../delete';
export default async (resolver, actor, activity) => {
if ('actor' in activity && actor.account.uri !== activity.actor) {
throw new Error();
}
const results = await create(resolver, actor, activity.object);
await Promise.all(results.map(async promisedResult => {
const result = await promisedResult;
if (result === null) {
return;
}
await deleteObject(result);
}));
return null;
};

View File

@ -0,0 +1,36 @@
import Resolver from '../../resolver';
import deleteNote from './note';
import Post from '../../../../models/post';
import { IRemoteUser } from '../../../../models/user';
/**
*
*/
export default async (actor: IRemoteUser, activity): Promise<void> => {
if ('actor' in activity && actor.account.uri !== activity.actor) {
throw new Error('invalid actor');
}
const resolver = new Resolver();
const object = await resolver.resolve(activity.object);
const uri = (object as any).id;
switch (object.type) {
case 'Note':
deleteNote(actor, uri);
break;
case 'Tombstone':
const post = await Post.findOne({ uri });
if (post != null) {
deleteNote(actor, uri);
}
break;
default:
console.warn(`Unknown type: ${object.type}`);
break;
}
};

View File

@ -0,0 +1,30 @@
import * as debug from 'debug';
import Post from '../../../../models/post';
import { IRemoteUser } from '../../../../models/user';
const log = debug('misskey:activitypub');
export default async function(actor: IRemoteUser, uri: string): Promise<void> {
log(`Deleting the Note: ${uri}`);
const post = await Post.findOne({ uri });
if (post == null) {
throw new Error('post not found');
}
if (!post.userId.equals(actor._id)) {
throw new Error('投稿を削除しようとしているユーザーは投稿の作成者ではありません');
}
Post.update({ _id: post._id }, {
$set: {
deletedAt: new Date(),
text: null,
textHtml: null,
mediaIds: [],
poll: null
}
});
}

View File

@ -1,17 +1,12 @@
import { MongoError } from 'mongodb';
import parseAcct from '../../../acct/parse'; import parseAcct from '../../../acct/parse';
import Following, { IFollowing } from '../../../models/following'; import User, { IRemoteUser } from '../../../models/user';
import User from '../../../models/user';
import config from '../../../config'; import config from '../../../config';
import { createHttp } from '../../../queue'; import follow from '../../../services/following/create';
import context from '../renderer/context'; import { IFollow } from '../type';
import renderAccept from '../renderer/accept';
import request from '../../request';
import Resolver from '../resolver';
export default async (resolver: Resolver, actor, activity, distribute) => { export default async (actor: IRemoteUser, activity: IFollow): Promise<void> => {
const prefix = config.url + '/@'; const prefix = config.url + '/@';
const id = activity.object.id || activity.object; const id = typeof activity == 'string' ? activity : activity.id;
if (!id.startsWith(prefix)) { if (!id.startsWith(prefix)) {
return null; return null;
@ -27,52 +22,5 @@ export default async (resolver: Resolver, actor, activity, distribute) => {
throw new Error(); throw new Error();
} }
if (!distribute) { await follow(actor, followee, activity);
const { _id } = await Following.findOne({
followerId: actor._id,
followeeId: followee._id
});
return {
resolver,
object: { $ref: 'following', $id: _id }
};
}
const promisedFollowing = Following.insert({
createdAt: new Date(),
followerId: actor._id,
followeeId: followee._id
}).then(following => new Promise((resolve, reject) => {
createHttp({
type: 'follow',
following: following._id
}).save(error => {
if (error) {
reject(error);
} else {
resolve(following);
}
});
}) as Promise<IFollowing>, async error => {
// duplicate key error
if (error instanceof MongoError && error.code === 11000) {
return Following.findOne({
followerId: actor._id,
followeeId: followee._id
});
}
throw error;
});
const accept = renderAccept(activity);
accept['@context'] = context;
await request(followee, actor.account.inbox, accept);
return promisedFollowing.then(({ _id }) => ({
resolver,
object: { $ref: 'following', $id: _id }
}));
}; };

View File

@ -1,36 +1,46 @@
import { Object } from '../type';
import { IRemoteUser } from '../../../models/user';
import create from './create'; import create from './create';
import performDeleteActivity from './delete'; import performDeleteActivity from './delete';
import follow from './follow'; import follow from './follow';
import undo from './undo'; import undo from './undo';
import createObject from '../create'; import like from './like';
import Resolver from '../resolver';
export default async (parentResolver: Resolver, actor, value, distribute?: boolean) => { const self = async (actor: IRemoteUser, activity: Object): Promise<void> => {
const collection = await parentResolver.resolveCollection(value); switch (activity.type) {
return collection.object.map(async element => {
const { resolver, object } = await collection.resolver.resolveOne(element);
const created = await (await createObject(resolver, actor, [object], distribute))[0];
if (created !== null) {
return created;
}
switch (object.type) {
case 'Create': case 'Create':
return create(resolver, actor, object, distribute); await create(actor, activity);
break;
case 'Delete': case 'Delete':
return performDeleteActivity(resolver, actor, object); await performDeleteActivity(actor, activity);
break;
case 'Follow': case 'Follow':
return follow(resolver, actor, object, distribute); await follow(actor, activity);
break;
case 'Accept':
// noop
break;
case 'Like':
await like(actor, activity);
break;
case 'Undo': case 'Undo':
return undo(resolver, actor, object); await undo(actor, activity);
break;
case 'Collection':
case 'OrderedCollection':
// TODO
break;
default: default:
console.warn(`unknown activity type: ${(activity as any).type}`);
return null; return null;
} }
});
}; };
export default self;

View File

@ -1,10 +1,10 @@
import { MongoError } from 'mongodb';
import Reaction, { IPostReaction } from '../../../models/post-reaction';
import Post from '../../../models/post'; import Post from '../../../models/post';
import queue from '../../../queue'; import { IRemoteUser } from '../../../models/user';
import { ILike } from '../type';
import create from '../../../services/post/reaction/create';
export default async (resolver, actor, activity, distribute) => { export default async (actor: IRemoteUser, activity: ILike) => {
const id = activity.object.id || activity.object; const id = typeof activity.object == 'string' ? activity.object : activity.object.id;
// Transform: // Transform:
// https://misskey.ex/@syuilo/xxxx to // https://misskey.ex/@syuilo/xxxx to
@ -16,48 +16,5 @@ export default async (resolver, actor, activity, distribute) => {
throw new Error(); throw new Error();
} }
if (!distribute) { await create(actor, post, 'pudding');
const { _id } = await Reaction.findOne({
userId: actor._id,
postId: post._id
});
return {
resolver,
object: { $ref: 'postPeactions', $id: _id }
};
}
const promisedReaction = Reaction.insert({
createdAt: new Date(),
userId: actor._id,
postId: post._id,
reaction: 'pudding'
}).then(reaction => new Promise<IPostReaction>((resolve, reject) => {
queue.create('http', {
type: 'reaction',
reactionId: reaction._id
}).save(error => {
if (error) {
reject(error);
} else {
resolve(reaction);
}
});
}), async error => {
// duplicate key error
if (error instanceof MongoError && error.code === 11000) {
return Reaction.findOne({
userId: actor._id,
postId: post._id
});
}
throw error;
});
return promisedReaction.then(({ _id }) => ({
resolver,
object: { $ref: 'postPeactions', $id: _id }
}));
}; };

View File

@ -0,0 +1,26 @@
import parseAcct from '../../../../acct/parse';
import User, { IRemoteUser } from '../../../../models/user';
import config from '../../../../config';
import unfollow from '../../../../services/following/delete';
import { IFollow } from '../../type';
export default async (actor: IRemoteUser, activity: IFollow): Promise<void> => {
const prefix = config.url + '/@';
const id = typeof activity == 'string' ? activity : activity.id;
if (!id.startsWith(prefix)) {
return null;
}
const { username, host } = parseAcct(id.slice(prefix.length));
if (host !== null) {
throw new Error();
}
const followee = await User.findOne({ username, host });
if (followee === null) {
throw new Error();
}
await unfollow(actor, followee, activity);
};

View File

@ -1,27 +1,37 @@
import act from '../../act'; import * as debug from 'debug';
import deleteObject from '../../delete';
import unfollow from './unfollow'; import { IRemoteUser } from '../../../../models/user';
import { IUndo } from '../../type';
import unfollow from './follow';
import Resolver from '../../resolver'; import Resolver from '../../resolver';
export default async (resolver: Resolver, actor, activity): Promise<void> => { const log = debug('misskey:activitypub');
export default async (actor: IRemoteUser, activity: IUndo): Promise<void> => {
if ('actor' in activity && actor.account.uri !== activity.actor) { if ('actor' in activity && actor.account.uri !== activity.actor) {
throw new Error(); throw new Error('invalid actor');
} }
const results = await act(resolver, actor, activity.object); const uri = activity.id || activity;
await Promise.all(results.map(async promisedResult => { log(`Undo: ${uri}`);
const result = await promisedResult;
if (result === null || await deleteObject(result) !== null) { const resolver = new Resolver();
return;
let object;
try {
object = await resolver.resolve(activity.object);
} catch (e) {
log(`Resolution failed: ${e}`);
throw e;
} }
switch (result.object.$ref) { switch (object.type) {
case 'following': case 'Follow':
await unfollow(result.object); unfollow(actor, object);
break;
} }
}));
return null; return null;
}; };

View File

@ -1,11 +0,0 @@
import { createHttp } from '../../../../queue';
export default ({ $id }) => new Promise((resolve, reject) => {
createHttp({ type: 'unfollow', id: $id }).save(error => {
if (error) {
reject(error);
} else {
resolve();
}
});
});

View File

@ -1,185 +0,0 @@
import { JSDOM } from 'jsdom';
import { ObjectID } from 'mongodb';
import config from '../../config';
import DriveFile from '../../models/drive-file';
import Post from '../../models/post';
import { IRemoteUser } from '../../models/user';
import uploadFromUrl from '../../drive/upload-from-url';
import createPost from '../../post/create';
import distributePost from '../../post/distribute';
import resolvePerson from './resolve-person';
import Resolver from './resolver';
const createDOMPurify = require('dompurify');
type IResult = {
resolver: Resolver;
object: {
$ref: string;
$id: ObjectID;
};
};
class Creator {
private actor: IRemoteUser;
private distribute: boolean;
constructor(actor, distribute) {
this.actor = actor;
this.distribute = distribute;
}
private async createImage(resolver: Resolver, image) {
if ('attributedTo' in image && this.actor.account.uri !== image.attributedTo) {
throw new Error();
}
const { _id } = await uploadFromUrl(image.url, this.actor, image.id || null);
return {
resolver,
object: { $ref: 'driveFiles.files', $id: _id }
};
}
private async createNote(resolver: Resolver, note) {
if (
('attributedTo' in note && this.actor.account.uri !== note.attributedTo) ||
typeof note.id !== 'string'
) {
throw new Error();
}
const { window } = new JSDOM(note.content);
const mentions = [];
const tags = [];
for (const { href, name, type } of note.tags) {
switch (type) {
case 'Hashtag':
if (name.startsWith('#')) {
tags.push(name.slice(1));
}
break;
case 'Mention':
mentions.push(resolvePerson(resolver, href));
break;
}
}
const [mediaIds, reply] = await Promise.all([
'attachment' in note && this.create(resolver, note.attachment)
.then(collection => Promise.all(collection))
.then(collection => collection
.filter(media => media !== null && media.object.$ref === 'driveFiles.files')
.map(({ object }: IResult) => object.$id)),
'inReplyTo' in note && this.create(resolver, note.inReplyTo)
.then(collection => Promise.all(collection.map(promise => promise.then(result => {
if (result !== null && result.object.$ref === 'posts') {
throw result.object;
}
}, () => { }))))
.then(() => null, ({ $id }) => Post.findOne({ _id: $id }))
]);
const inserted = await createPost({
channelId: undefined,
index: undefined,
createdAt: new Date(note.published),
mediaIds,
poll: undefined,
text: window.document.body.textContent,
textHtml: note.content && createDOMPurify(window).sanitize(note.content),
userId: this.actor._id,
appId: null,
viaMobile: false,
geo: undefined,
uri: note.id,
tags
}, reply, null, await Promise.all(mentions));
const promises = [];
if (this.distribute) {
promises.push(distributePost(this.actor, inserted.mentions, inserted));
}
// Register to search database
if (note.content && config.elasticsearch.enable) {
const es = require('../../db/elasticsearch');
promises.push(new Promise((resolve, reject) => {
es.index({
index: 'misskey',
type: 'post',
id: inserted._id.toString(),
body: {
text: window.document.body.textContent
}
}, resolve);
}));
}
await Promise.all(promises);
return {
resolver,
object: { $ref: 'posts', id: inserted._id }
};
}
public async create(parentResolver: Resolver, value): Promise<Array<Promise<IResult>>> {
const collection = await parentResolver.resolveCollection(value);
return collection.object.map(async element => {
const uri = element.id || element;
try {
await Promise.all([
DriveFile.findOne({ 'metadata.uri': uri }).then(file => {
if (file === null) {
return;
}
throw {
$ref: 'driveFile.files',
$id: file._id
};
}, () => {}),
Post.findOne({ uri }).then(post => {
if (post === null) {
return;
}
throw {
$ref: 'posts',
$id: post._id
};
}, () => {})
]);
} catch (object) {
return {
resolver: collection.resolver,
object
};
}
const { resolver, object } = await collection.resolver.resolveOne(element);
switch (object.type) {
case 'Image':
return this.createImage(resolver, object);
case 'Note':
return this.createNote(resolver, object);
}
return null;
});
}
}
export default (resolver: Resolver, actor, value, distribute?: boolean) => {
const creator = new Creator(actor, distribute);
return creator.create(resolver, value);
};

View File

@ -1,10 +0,0 @@
import deletePost from './post';
export default async ({ object }) => {
switch (object.$ref) {
case 'posts':
return deletePost(object);
}
return null;
};

View File

@ -1,13 +0,0 @@
import Post from '../../../models/post';
import { createDb } from '../../../queue';
export default async ({ $id }) => {
const promisedDeletion = Post.findOneAndDelete({ _id: $id });
await new Promise((resolve, reject) => createDb({
type: 'deletePostDependents',
id: $id
}).delay(65536).save(error => error ? reject(error) : resolve()));
return promisedDeletion;
};

View File

@ -0,0 +1,9 @@
import config from '../../../config';
export default (user, post) => {
return {
type: 'Like',
actor: `${config.url}/@${user.username}`,
object: post.uri ? post.uri : `${config.url}/posts/${post._id}`
};
};

View File

@ -2,11 +2,14 @@ import renderDocument from './document';
import renderHashtag from './hashtag'; import renderHashtag from './hashtag';
import config from '../../../config'; import config from '../../../config';
import DriveFile from '../../../models/drive-file'; import DriveFile from '../../../models/drive-file';
import Post from '../../../models/post'; import Post, { IPost } from '../../../models/post';
import User from '../../../models/user'; import User, { IUser } from '../../../models/user';
export default async (user: IUser, post: IPost) => {
const promisedFiles = post.mediaIds
? DriveFile.find({ _id: { $in: post.mediaIds } })
: Promise.resolve([]);
export default async (user, post) => {
const promisedFiles = DriveFile.find({ _id: { $in: post.mediaIds } });
let inReplyTo; let inReplyTo;
if (post.replyId) { if (post.replyId) {
@ -16,11 +19,11 @@ export default async (user, post) => {
if (inReplyToPost !== null) { if (inReplyToPost !== null) {
const inReplyToUser = await User.findOne({ const inReplyToUser = await User.findOne({
_id: post.userId, _id: inReplyToPost.userId,
}); });
if (inReplyToUser !== null) { if (inReplyToUser !== null) {
inReplyTo = `${config.url}@${inReplyToUser.username}/${inReplyToPost._id}`; inReplyTo = inReplyToPost.uri || `${config.url}/posts/${inReplyToPost._id}`;
} }
} }
} else { } else {
@ -30,7 +33,7 @@ export default async (user, post) => {
const attributedTo = `${config.url}/@${user.username}`; const attributedTo = `${config.url}/@${user.username}`;
return { return {
id: `${attributedTo}/${post._id}`, id: `${config.url}/posts/${post._id}`,
type: 'Note', type: 'Note',
attributedTo, attributedTo,
content: post.textHtml, content: post.textHtml,
@ -39,6 +42,6 @@ export default async (user, post) => {
cc: `${attributedTo}/followers`, cc: `${attributedTo}/followers`,
inReplyTo, inReplyTo,
attachment: (await promisedFiles).map(renderDocument), attachment: (await promisedFiles).map(renderDocument),
tag: post.tags.map(renderHashtag) tag: (post.tags || []).map(renderHashtag)
}; };
}; };

View File

@ -1,42 +1,50 @@
import { JSDOM } from 'jsdom'; import { JSDOM } from 'jsdom';
import { toUnicode } from 'punycode'; import { toUnicode } from 'punycode';
import parseAcct from '../../acct/parse';
import config from '../../config';
import User, { validateUsername, isValidName, isValidDescription } from '../../models/user'; import User, { validateUsername, isValidName, isValidDescription } from '../../models/user';
import { createHttp } from '../../queue';
import webFinger from '../webfinger'; import webFinger from '../webfinger';
import create from './create'; import Resolver from './resolver';
import uploadFromUrl from '../../services/drive/upload-from-url';
import { isCollectionOrOrderedCollection } from './type';
async function isCollection(collection) { export default async (value, verifier?: string) => {
return ['Collection', 'OrderedCollection'].includes(collection.type); const id = value.id || value;
} const localPrefix = config.url + '/@';
export default async (parentResolver, value, verifier?: string) => { if (id.startsWith(localPrefix)) {
const { resolver, object } = await parentResolver.resolveOne(value); return User.findOne(parseAcct(id.slice(localPrefix)));
}
const resolver = new Resolver();
const object = await resolver.resolve(value) as any;
if ( if (
object === null || object == null ||
object.type !== 'Person' || object.type !== 'Person' ||
typeof object.preferredUsername !== 'string' || typeof object.preferredUsername !== 'string' ||
!validateUsername(object.preferredUsername) || !validateUsername(object.preferredUsername) ||
!isValidName(object.name) || !isValidName(object.name == '' ? null : object.name) ||
!isValidDescription(object.summary) !isValidDescription(object.summary)
) { ) {
throw new Error(); throw new Error('invalid person');
} }
const [followers, following, outbox, finger] = await Promise.all([ const [followersCount = 0, followingCount = 0, postsCount = 0, finger] = await Promise.all([
resolver.resolveOne(object.followers).then( resolver.resolve(object.followers).then(
resolved => isCollection(resolved.object) ? resolved.object : null, resolved => isCollectionOrOrderedCollection(resolved) ? resolved.totalItems : undefined,
() => null () => undefined
), ),
resolver.resolveOne(object.following).then( resolver.resolve(object.following).then(
resolved => isCollection(resolved.object) ? resolved.object : null, resolved => isCollectionOrOrderedCollection(resolved) ? resolved.totalItems : undefined,
() => null () => undefined
), ),
resolver.resolveOne(object.outbox).then( resolver.resolve(object.outbox).then(
resolved => isCollection(resolved.object) ? resolved.object : null, resolved => isCollectionOrOrderedCollection(resolved) ? resolved.totalItems : undefined,
() => null () => undefined
), ),
webFinger(object.id, verifier), webFinger(id, verifier)
]); ]);
const host = toUnicode(finger.subject.replace(/^.*?@/, '')); const host = toUnicode(finger.subject.replace(/^.*?@/, ''));
@ -47,12 +55,12 @@ export default async (parentResolver, value, verifier?: string) => {
const user = await User.insert({ const user = await User.insert({
avatarId: null, avatarId: null,
bannerId: null, bannerId: null,
createdAt: Date.parse(object.published), createdAt: Date.parse(object.published) || null,
description: summaryDOM.textContent, description: summaryDOM.textContent,
followersCount: followers ? followers.totalItem || 0 : 0, followersCount,
followingCount: following ? following.totalItem || 0 : 0, followingCount,
postsCount,
name: object.name, name: object.name,
postsCount: outbox ? outbox.totalItem || 0 : 0,
driveCapacity: 1024 * 1024 * 8, // 8MiB driveCapacity: 1024 * 1024 * 8, // 8MiB
username: object.preferredUsername, username: object.preferredUsername,
usernameLower: object.preferredUsername.toLowerCase(), usernameLower: object.preferredUsername.toLowerCase(),
@ -64,38 +72,18 @@ export default async (parentResolver, value, verifier?: string) => {
publicKeyPem: object.publicKey.publicKeyPem publicKeyPem: object.publicKey.publicKeyPem
}, },
inbox: object.inbox, inbox: object.inbox,
uri: object.id, uri: id,
}, },
}); });
createHttp({ const [avatarId, bannerId] = (await Promise.all([
type: 'performActivityPub',
actor: user._id,
outbox
}).save();
const [avatarId, bannerId] = await Promise.all([
object.icon, object.icon,
object.image object.image
].map(async value => { ].map(img =>
if (value === undefined) { img == null
return null; ? Promise.resolve(null)
} : uploadFromUrl(img.url, user)
))).map(file => file != null ? file._id : null);
try {
const created = await create(resolver, user, value);
await Promise.all(created.map(asyncCreated => asyncCreated.then(created => {
if (created !== null && created.object.$ref === 'driveFiles.files') {
throw created.object.$id;
}
}, () => {})));
return null;
} catch (id) {
return id;
}
}));
User.update({ _id: user._id }, { $set: { avatarId, bannerId } }); User.update({ _id: user._id }, { $set: { avatarId, bannerId } });

View File

@ -1,20 +1,51 @@
const request = require('request-promise-native'); import * as request from 'request-promise-native';
import * as debug from 'debug';
import { IObject } from './type';
const log = debug('misskey:activitypub:resolver');
export default class Resolver { export default class Resolver {
private requesting: Set<string>; private history: Set<string>;
constructor(iterable?: Iterable<string>) { constructor() {
this.requesting = new Set(iterable); this.history = new Set();
}
public async resolveCollection(value) {
const collection = typeof value === 'string'
? await this.resolve(value)
: value;
switch (collection.type) {
case 'Collection':
collection.objects = collection.object.items;
break;
case 'OrderedCollection':
collection.objects = collection.object.orderedItems;
break;
default:
throw new Error(`unknown collection type: ${collection.type}`);
}
return collection;
}
public async resolve(value): Promise<IObject> {
if (value == null) {
throw new Error('resolvee is null (or undefined)');
} }
private async resolveUnrequestedOne(value) {
if (typeof value !== 'string') { if (typeof value !== 'string') {
return { resolver: this, object: value }; return value;
} }
const resolver = new Resolver(this.requesting); if (this.history.has(value)) {
throw new Error('cannot resolve already resolved one');
}
resolver.requesting.add(value); this.history.add(value);
const object = await request({ const object = await request({
url: value, url: value,
@ -29,41 +60,11 @@ export default class Resolver {
!object['@context'].includes('https://www.w3.org/ns/activitystreams') : !object['@context'].includes('https://www.w3.org/ns/activitystreams') :
object['@context'] !== 'https://www.w3.org/ns/activitystreams' object['@context'] !== 'https://www.w3.org/ns/activitystreams'
)) { )) {
throw new Error(); throw new Error('invalid response');
} }
return { resolver, object }; log(`resolved: ${JSON.stringify(object, null, 2)}`);
}
public async resolveCollection(value) { return object;
const resolved = typeof value === 'string' ?
await this.resolveUnrequestedOne(value) :
{ resolver: this, object: value };
switch (resolved.object.type) {
case 'Collection':
resolved.object = resolved.object.items;
break;
case 'OrderedCollection':
resolved.object = resolved.object.orderedItems;
break;
default:
if (!Array.isArray(value)) {
resolved.object = [resolved.object];
}
break;
}
return resolved;
}
public resolveOne(value) {
if (this.requesting.has(value)) {
throw new Error();
}
return this.resolveUnrequestedOne(value);
} }
} }

View File

@ -1,3 +1,70 @@
export type IObject = { export type obj = { [x: string]: any };
export interface IObject {
'@context': string | obj | obj[];
type: string; type: string;
}; id?: string;
summary?: string;
}
export interface IActivity extends IObject {
//type: 'Activity';
actor: IObject | string;
object: IObject | string;
target?: IObject | string;
}
export interface ICollection extends IObject {
type: 'Collection';
totalItems: number;
items: IObject | string | IObject[] | string[];
}
export interface IOrderedCollection extends IObject {
type: 'OrderedCollection';
totalItems: number;
orderedItems: IObject | string | IObject[] | string[];
}
export const isCollection = (object: IObject): object is ICollection =>
object.type === 'Collection';
export const isOrderedCollection = (object: IObject): object is IOrderedCollection =>
object.type === 'OrderedCollection';
export const isCollectionOrOrderedCollection = (object: IObject): object is ICollection | IOrderedCollection =>
isCollection(object) || isOrderedCollection(object);
export interface ICreate extends IActivity {
type: 'Create';
}
export interface IDelete extends IActivity {
type: 'Delete';
}
export interface IUndo extends IActivity {
type: 'Undo';
}
export interface IFollow extends IActivity {
type: 'Follow';
}
export interface IAccept extends IActivity {
type: 'Accept';
}
export interface ILike extends IActivity {
type: 'Like';
}
export type Object =
ICollection |
IOrderedCollection |
ICreate |
IDelete |
IUndo |
IFollow |
IAccept |
ILike;

View File

@ -1,9 +1,15 @@
import { request } from 'https'; import { request } from 'https';
import { sign } from 'http-signature'; import { sign } from 'http-signature';
import { URL } from 'url'; import { URL } from 'url';
import * as debug from 'debug';
import config from '../config'; import config from '../config';
const log = debug('misskey:activitypub:deliver');
export default ({ account, username }, url, object) => new Promise((resolve, reject) => { export default ({ account, username }, url, object) => new Promise((resolve, reject) => {
log(`--> ${url}`);
const { protocol, hostname, port, pathname, search } = new URL(url); const { protocol, hostname, port, pathname, search } = new URL(url);
const req = request({ const req = request({
@ -14,6 +20,8 @@ export default ({ account, username }, url, object) => new Promise((resolve, rej
path: pathname + search, path: pathname + search,
}, res => { }, res => {
res.on('end', () => { res.on('end', () => {
log(`${url} --> ${res.statusCode}`);
if (res.statusCode >= 200 && res.statusCode < 300) { if (res.statusCode >= 200 && res.statusCode < 300) {
resolve(); resolve();
} else { } else {

View File

@ -1,7 +1,6 @@
import { toUnicode, toASCII } from 'punycode'; import { toUnicode, toASCII } from 'punycode';
import User from '../models/user'; import User from '../models/user';
import resolvePerson from './activitypub/resolve-person'; import resolvePerson from './activitypub/resolve-person';
import Resolver from './activitypub/resolver';
import webFinger from './webfinger'; import webFinger from './webfinger';
export default async (username, host, option) => { export default async (username, host, option) => {
@ -17,10 +16,10 @@ export default async (username, host, option) => {
const finger = await webFinger(acctLower, acctLower); const finger = await webFinger(acctLower, acctLower);
const self = finger.links.find(link => link.rel && link.rel.toLowerCase() === 'self'); const self = finger.links.find(link => link.rel && link.rel.toLowerCase() === 'self');
if (!self) { if (!self) {
throw new Error(); throw new Error('self link not found');
} }
user = await resolvePerson(new Resolver(), self.href, acctLower); user = await resolvePerson(self.href, acctLower);
} }
return user; return user;

View File

@ -1,3 +1,4 @@
import getUserName from '../renderers/get-user-name';
import getPostSummary from './get-post-summary'; import getPostSummary from './get-post-summary';
import getReactionEmoji from './get-reaction-emoji'; import getReactionEmoji from './get-reaction-emoji';
@ -8,19 +9,19 @@ import getReactionEmoji from './get-reaction-emoji';
export default function(notification: any): string { export default function(notification: any): string {
switch (notification.type) { switch (notification.type) {
case 'follow': case 'follow':
return `${notification.user.name}にフォローされました`; return `${getUserName(notification.user)}にフォローされました`;
case 'mention': case 'mention':
return `言及されました:\n${notification.user.name}${getPostSummary(notification.post)}`; return `言及されました:\n${getUserName(notification.user)}${getPostSummary(notification.post)}`;
case 'reply': case 'reply':
return `返信されました:\n${notification.user.name}${getPostSummary(notification.post)}`; return `返信されました:\n${getUserName(notification.user)}${getPostSummary(notification.post)}`;
case 'repost': case 'repost':
return `Repostされました:\n${notification.user.name}${getPostSummary(notification.post)}`; return `Repostされました:\n${getUserName(notification.user)}${getPostSummary(notification.post)}`;
case 'quote': case 'quote':
return `引用されました:\n${notification.user.name}${getPostSummary(notification.post)}`; return `引用されました:\n${getUserName(notification.user)}${getPostSummary(notification.post)}`;
case 'reaction': case 'reaction':
return `リアクションされました:\n${notification.user.name} <${getReactionEmoji(notification.reaction)}>「${getPostSummary(notification.post)}`; return `リアクションされました:\n${getUserName(notification.user)} <${getReactionEmoji(notification.reaction)}>「${getPostSummary(notification.post)}`;
case 'poll_vote': case 'poll_vote':
return `投票されました:\n${notification.user.name}${getPostSummary(notification.post)}`; return `投票されました:\n${getUserName(notification.user)}${getPostSummary(notification.post)}`;
default: default:
return `<不明な通知タイプ: ${notification.type}>`; return `<不明な通知タイプ: ${notification.type}>`;
} }

View File

@ -0,0 +1,5 @@
import { IUser } from '../models/user';
export default function(user: IUser): string {
return user.name || '名無し';
}

View File

@ -1,12 +1,13 @@
import { IUser, isLocalUser } from '../models/user'; import { IUser, isLocalUser } from '../models/user';
import getAcct from '../acct/render'; import getAcct from '../acct/render';
import getUserName from './get-user-name';
/** /**
* *
* @param user * @param user
*/ */
export default function(user: IUser): string { export default function(user: IUser): string {
let string = `${user.name} (@${getAcct(user)})\n` + let string = `${getUserName(user)} (@${getAcct(user)})\n` +
`${user.postsCount}投稿、${user.followingCount}フォロー、${user.followersCount}フォロワー\n`; `${user.postsCount}投稿、${user.followingCount}フォロー、${user.followersCount}フォロワー\n`;
if (isLocalUser(user)) { if (isLocalUser(user)) {

View File

@ -3,9 +3,7 @@ import * as express from 'express';
import { parseRequest } from 'http-signature'; import { parseRequest } from 'http-signature';
import { createHttp } from '../../queue'; import { createHttp } from '../../queue';
const app = express(); const app = express.Router();
app.disable('x-powered-by');
app.post('/@:user/inbox', bodyParser.json({ app.post('/@:user/inbox', bodyParser.json({
type() { type() {
@ -24,7 +22,7 @@ app.post('/@:user/inbox', bodyParser.json({
createHttp({ createHttp({
type: 'processInbox', type: 'processInbox',
inbox: req.body, activity: req.body,
signature, signature,
}).save(); }).save();

View File

@ -6,8 +6,7 @@ import config from '../../config';
import Post from '../../models/post'; import Post from '../../models/post';
import withUser from './with-user'; import withUser from './with-user';
const app = express(); const app = express.Router();
app.disable('x-powered-by');
app.get('/@:user/outbox', withUser(username => { app.get('/@:user/outbox', withUser(username => {
return `${config.url}/@${username}/inbox`; return `${config.url}/@${username}/inbox`;

View File

@ -5,8 +5,7 @@ import parseAcct from '../../acct/parse';
import Post from '../../models/post'; import Post from '../../models/post';
import User from '../../models/user'; import User from '../../models/user';
const app = express(); const app = express.Router();
app.disable('x-powered-by');
app.get('/@:user/:post', async (req, res, next) => { app.get('/@:user/:post', async (req, res, next) => {
const accepted = req.accepts(['html', 'application/activity+json', 'application/ld+json']); const accepted = req.accepts(['html', 'application/activity+json', 'application/ld+json']);

View File

@ -4,8 +4,7 @@ import render from '../../remote/activitypub/renderer/key';
import config from '../../config'; import config from '../../config';
import withUser from './with-user'; import withUser from './with-user';
const app = express(); const app = express.Router();
app.disable('x-powered-by');
app.get('/@:user/publickey', withUser(username => { app.get('/@:user/publickey', withUser(username => {
return `${config.url}/@${username}/publickey`; return `${config.url}/@${username}/publickey`;

View File

@ -11,8 +11,7 @@ const respond = withUser(username => `${config.url}/@${username}`, (user, req, r
res.json(rendered); res.json(rendered);
}); });
const app = express(); const app = express.Router();
app.disable('x-powered-by');
app.get('/@:user', (req, res, next) => { app.get('/@:user', (req, res, next) => {
const accepted = req.accepts(['html', 'application/activity+json', 'application/ld+json']); const accepted = req.accepts(['html', 'application/activity+json', 'application/ld+json']);

View File

@ -4,6 +4,7 @@ import * as bcrypt from 'bcryptjs';
import User, { IUser, init as initUser, ILocalUser } from '../../../models/user'; import User, { IUser, init as initUser, ILocalUser } from '../../../models/user';
import getPostSummary from '../../../renderers/get-post-summary'; import getPostSummary from '../../../renderers/get-post-summary';
import getUserName from '../../../renderers/get-user-name';
import getUserSummary from '../../../renderers/get-user-summary'; import getUserSummary from '../../../renderers/get-user-summary';
import parseAcct from '../../../acct/parse'; import parseAcct from '../../../acct/parse';
import getNotificationSummary from '../../../renderers/get-notification-summary'; import getNotificationSummary from '../../../renderers/get-notification-summary';
@ -90,7 +91,7 @@ export default class BotCore extends EventEmitter {
'タイムラインや通知を見た後、「次」というとさらに遡ることができます。'; 'タイムラインや通知を見た後、「次」というとさらに遡ることができます。';
case 'me': case 'me':
return this.user ? `${this.user.name}としてサインインしています。\n\n${getUserSummary(this.user)}` : 'サインインしていません'; return this.user ? `${getUserName(this.user)}としてサインインしています。\n\n${getUserSummary(this.user)}` : 'サインインしていません';
case 'login': case 'login':
case 'signin': case 'signin':
@ -230,7 +231,7 @@ class SigninContext extends Context {
if (same) { if (same) {
this.bot.signin(this.temporaryUser); this.bot.signin(this.temporaryUser);
this.bot.clearContext(); this.bot.clearContext();
return `${this.temporaryUser.name}さん、おかえりなさい!`; return `${getUserName(this.temporaryUser)}さん、おかえりなさい!`;
} else { } else {
return `パスワードが違います... もう一度教えてください:`; return `パスワードが違います... もう一度教えてください:`;
} }
@ -305,7 +306,7 @@ class TlContext extends Context {
this.emit('updated'); this.emit('updated');
const text = tl const text = tl
.map(post => `${post.user.name}\n「${getPostSummary(post)}`) .map(post => `${getUserName(post.user)}\n「${getPostSummary(post)}`)
.join('\n-----\n'); .join('\n-----\n');
return text; return text;

View File

@ -10,6 +10,7 @@ import prominence = require('prominence');
import getAcct from '../../../../acct/render'; import getAcct from '../../../../acct/render';
import parseAcct from '../../../../acct/parse'; import parseAcct from '../../../../acct/parse';
import getPostSummary from '../../../../renderers/get-post-summary'; import getPostSummary from '../../../../renderers/get-post-summary';
import getUserName from '../../../../renderers/get-user-name';
const redis = prominence(_redis); const redis = prominence(_redis);
@ -131,7 +132,7 @@ class LineBot extends BotCore {
template: { template: {
type: 'buttons', type: 'buttons',
thumbnailImageUrl: `${user.avatarUrl}?thumbnail&size=1024`, thumbnailImageUrl: `${user.avatarUrl}?thumbnail&size=1024`,
title: `${user.name} (@${acct})`, title: `${getUserName(user)} (@${acct})`,
text: user.description || '(no description)', text: user.description || '(no description)',
actions: actions actions: actions
} }
@ -146,7 +147,7 @@ class LineBot extends BotCore {
limit: 5 limit: 5
}, this.user); }, this.user);
const text = `${tl[0].user.name}さんのタイムラインはこちらです:\n\n` + tl const text = `${getUserName(tl[0].user)}さんのタイムラインはこちらです:\n\n` + tl
.map(post => getPostSummary(post)) .map(post => getPostSummary(post))
.join('\n-----\n'); .join('\n-----\n');

Some files were not shown because too many files have changed in this diff Show More