From 255152f615eb6f38a4d019b2c4f2ccd1e03251fc Mon Sep 17 00:00:00 2001 From: syuilo Date: Thu, 26 Apr 2018 20:30:49 +0900 Subject: [PATCH] #1029 --- src/config/types.ts | 6 ++++++ src/models/user.ts | 4 ++++ src/server/api/endpoints/users/lists/push.ts | 12 +++++++++++- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/config/types.ts b/src/config/types.ts index b181f2c8c..dff3f7d37 100644 --- a/src/config/types.ts +++ b/src/config/types.ts @@ -40,6 +40,12 @@ export type Source = { site_key: string; secret_key: string; }; + + /** + * ゴーストアカウントのID + */ + ghost?: string; + accesslog?: string; twitter?: { consumer_key: string; diff --git a/src/models/user.ts b/src/models/user.ts index a65fcc187..352819f61 100644 --- a/src/models/user.ts +++ b/src/models/user.ts @@ -458,3 +458,7 @@ function img(url) { }; } */ + +export function getGhost(): Promise { + return User.findOne({ _id: new mongo.ObjectId(config.ghost) }); +} diff --git a/src/server/api/endpoints/users/lists/push.ts b/src/server/api/endpoints/users/lists/push.ts index 467c08efd..5d6f20152 100644 --- a/src/server/api/endpoints/users/lists/push.ts +++ b/src/server/api/endpoints/users/lists/push.ts @@ -1,7 +1,10 @@ import $ from 'cafy'; import ID from '../../../../../cafy-id'; import UserList from '../../../../../models/user-list'; -import User, { pack as packUser } from '../../../../../models/user'; +import User, { pack as packUser, isRemoteUser, getGhost } from '../../../../../models/user'; import { publishUserListStream } from '../../../../../publishers/stream'; +import ap from '../../../../../remote/activitypub/renderer'; +import renderFollow from '../../../../../remote/activitypub/renderer/follow'; +import { deliver } from '../../../../../queue'; /** * Add a user to a user list @@ -48,4 +51,11 @@ module.exports = async (params, me) => new Promise(async (res, rej) => { res(); publishUserListStream(userList._id, 'userAdded', await packUser(user)); + + // このインスタンス内にこのリモートユーザーをフォローしているユーザーがいなくても投稿を受け取るためにダミーのユーザーがフォローしたということにする + if (isRemoteUser(user)) { + const ghost = await getGhost(); + const content = ap(renderFollow(ghost, user)); + deliver(ghost, content, user.inbox); + } });