From 8d5c9e96e46f54ba09ba35fc9758bce82a7a16f5 Mon Sep 17 00:00:00 2001 From: Johann150 Date: Wed, 25 May 2022 16:17:00 +0200 Subject: [PATCH] fix: assume remote users are following each other (#8734) Misskey does not know if two remote users are following each other. Because ActivityPub actions would otherwise fail on followers only notes, we have to assume that two remote users are following each other when an interaction about a remote note occurs. --- .../backend/src/models/repositories/note.ts | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/packages/backend/src/models/repositories/note.ts b/packages/backend/src/models/repositories/note.ts index cf5fcb178..638d78f62 100644 --- a/packages/backend/src/models/repositories/note.ts +++ b/packages/backend/src/models/repositories/note.ts @@ -168,16 +168,22 @@ export const NoteRepository = db.getRepository(Note).extend({ return true; } else { // フォロワーかどうか - const following = await Followings.findOneBy({ - followeeId: note.userId, - followerId: meId, - }); + const [following, user] = await Promise.all([ + Followings.findOneBy({ + followeeId: note.userId, + followerId: meId, + }), + Users.findOneByOrFail({ id: meId }), + ]); - if (following == null) { - return false; - } else { - return true; - } + /* If we know the following, everyhting is fine. + + But if we do not know the following, it might be that both the + author of the note and the author of the like are remote users, + in which case we can never know the following. Instead we have + to assume that the users are following each other. + */ + return following != null || (note.userHost != null && user.host != null); } }