diff options
| author | Akihiko Odaki <nekomanma@pixiv.co.jp> | 2018-03-27 16:51:12 +0900 |
|---|---|---|
| committer | Akihiko Odaki <nekomanma@pixiv.co.jp> | 2018-03-27 23:51:21 +0900 |
| commit | 68ce6d574882c1badbb4a3d2772451534014dd01 (patch) | |
| tree | 3b468556c25dd5b63e3774aca1869b71dd9b1919 /src/api/endpoints/posts/create.ts | |
| parent | Merge pull request #1316 from akihikodaki/host (diff) | |
| download | sharkey-68ce6d574882c1badbb4a3d2772451534014dd01.tar.gz sharkey-68ce6d574882c1badbb4a3d2772451534014dd01.tar.bz2 sharkey-68ce6d574882c1badbb4a3d2772451534014dd01.zip | |
Implement remote account resolution
Diffstat (limited to 'src/api/endpoints/posts/create.ts')
| -rw-r--r-- | src/api/endpoints/posts/create.ts | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/api/endpoints/posts/create.ts b/src/api/endpoints/posts/create.ts index f46a84e1f1..286e18bb76 100644 --- a/src/api/endpoints/posts/create.ts +++ b/src/api/endpoints/posts/create.ts @@ -5,7 +5,7 @@ import $ from 'cafy'; import deepEqual = require('deep-equal'); import parse from '../../common/text'; import { default as Post, IPost, isValidText } from '../../models/post'; -import { default as User, IUser } from '../../models/user'; +import { default as User, ILocalAccount, IUser } from '../../models/user'; import { default as Channel, IChannel } from '../../models/channel'; import Following from '../../models/following'; import Mute from '../../models/mute'; @@ -16,6 +16,8 @@ import { pack } from '../../models/post'; import notify from '../../common/notify'; import watch from '../../common/watch-post'; import event, { pushSw, publishChannelStream } from '../../event'; +import getAcct from '../../../common/user/get-acct'; +import parseAcct from '../../../common/user/parse-acct'; import config from '../../../conf'; /** @@ -390,7 +392,7 @@ module.exports = (params, user: IUser, app) => new Promise(async (res, rej) => { }); // この投稿をWatchする - if (user.account.settings.auto_watch !== false) { + if ((user.account as ILocalAccount).settings.auto_watch !== false) { watch(user._id, reply); } @@ -477,7 +479,7 @@ module.exports = (params, user: IUser, app) => new Promise(async (res, rej) => { // Extract an '@' mentions const atMentions = tokens .filter(t => t.type == 'mention') - .map(m => m.username) + .map(getAcct) // Drop dupulicates .filter((v, i, s) => s.indexOf(v) == i); @@ -486,9 +488,7 @@ module.exports = (params, user: IUser, app) => new Promise(async (res, rej) => { // Fetch mentioned user // SELECT _id const mentionee = await User - .findOne({ - username_lower: mention.toLowerCase() - }, { _id: true }); + .findOne(parseAcct(mention), { _id: true }); // When mentioned user not found if (mentionee == null) return; |