diff --git a/src/models/follow-request.ts b/src/models/follow-request.ts index fdb20011f4..8ed131c80e 100644 --- a/src/models/follow-request.ts +++ b/src/models/follow-request.ts @@ -17,10 +17,12 @@ export type IFollowRequest = { _followee: { host: string; inbox?: string; + sharedInbox?: string; }, _follower: { host: string; inbox?: string; + sharedInbox?: string; } }; diff --git a/src/models/following.ts b/src/models/following.ts index 4712379a70..8aa588f557 100644 --- a/src/models/following.ts +++ b/src/models/following.ts @@ -16,10 +16,12 @@ export type IFollowing = { _followee: { host: string; inbox?: string; + sharedInbox?: string; }, _follower: { host: string; inbox?: string; + sharedInbox?: string; } }; diff --git a/src/services/following/create.ts b/src/services/following/create.ts index ea78a781e7..e1164c0bd9 100644 --- a/src/services/following/create.ts +++ b/src/services/following/create.ts @@ -22,11 +22,13 @@ export default async function(follower: IUser, followee: IUser) { // 非正規化 _follower: { host: follower.host, - inbox: isRemoteUser(follower) ? follower.inbox : undefined + inbox: isRemoteUser(follower) ? follower.inbox : undefined, + sharedInbox: isRemoteUser(follower) ? follower.sharedInbox : undefined }, _followee: { host: followee.host, - inbox: isRemoteUser(followee) ? followee.inbox : undefined + inbox: isRemoteUser(followee) ? followee.inbox : undefined, + sharedInbox: isRemoteUser(followee) ? followee.sharedInbox : undefined } }); diff --git a/src/services/following/requests/accept.ts b/src/services/following/requests/accept.ts index c874adc167..0a7674a4b8 100644 --- a/src/services/following/requests/accept.ts +++ b/src/services/following/requests/accept.ts @@ -18,11 +18,13 @@ export default async function(followee: IUser, follower: IUser) { // 非正規化 _follower: { host: follower.host, - inbox: isRemoteUser(follower) ? follower.inbox : undefined + inbox: isRemoteUser(follower) ? follower.inbox : undefined, + sharedInbox: isRemoteUser(follower) ? follower.sharedInbox : undefined }, _followee: { host: followee.host, - inbox: isRemoteUser(followee) ? followee.inbox : undefined + inbox: isRemoteUser(followee) ? followee.inbox : undefined, + sharedInbox: isRemoteUser(followee) ? followee.sharedInbox : undefined } }); diff --git a/src/services/following/requests/create.ts b/src/services/following/requests/create.ts index 98936f32e6..1b474dd8be 100644 --- a/src/services/following/requests/create.ts +++ b/src/services/following/requests/create.ts @@ -17,11 +17,13 @@ export default async function(follower: IUser, followee: IUser) { // 非正規化 _follower: { host: follower.host, - inbox: isRemoteUser(follower) ? follower.inbox : undefined + inbox: isRemoteUser(follower) ? follower.inbox : undefined, + sharedInbox: isRemoteUser(follower) ? follower.sharedInbox : undefined }, _followee: { host: followee.host, - inbox: isRemoteUser(followee) ? followee.inbox : undefined + inbox: isRemoteUser(followee) ? followee.inbox : undefined, + sharedInbox: isRemoteUser(followee) ? followee.sharedInbox : undefined } }); diff --git a/src/services/note/create.ts b/src/services/note/create.ts index 7bc2dddc4f..8536b8b561 100644 --- a/src/services/note/create.ts +++ b/src/services/note/create.ts @@ -403,7 +403,9 @@ async function publishToFollowers(note: INote, noteObj: any, user: IUser, noteAc followeeId: note.userId }); - followers.map(async (following) => { + const queue: string[] = []; + + followers.map(following => { const follower = following._follower; if (isLocalUser(follower)) { @@ -423,10 +425,15 @@ async function publishToFollowers(note: INote, noteObj: any, user: IUser, noteAc } else { // フォロワーがリモートユーザーかつ投稿者がローカルユーザーなら投稿を配信 if (isLocalUser(user)) { - deliver(user, noteActivity, follower.inbox); + const inbox = follower.sharedInbox || follower.inbox; + if (!queue.includes(inbox)) queue.push(inbox); } } }); + + queue.forEach(inbox => { + deliver(user, noteActivity, inbox); + }); } function deliverNoteToMentionedRemoteUsers(mentionedUsers: IUser[], user: ILocalUser, noteActivity: any) {