From 5a2bd3d3791184cf0b138bc59188d3b81146b54d Mon Sep 17 00:00:00 2001 From: cutestnekoaqua Date: Mon, 12 Dec 2022 21:09:31 +0100 Subject: [PATCH] add local move follower migration --- .../remote/activitypub/kernel/move/index.ts | 11 +------- .../src/server/api/endpoints/i/move.ts | 28 ++++++++++++++++++- 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/packages/backend/src/remote/activitypub/kernel/move/index.ts b/packages/backend/src/remote/activitypub/kernel/move/index.ts index bdd82d9be4..660e106c07 100644 --- a/packages/backend/src/remote/activitypub/kernel/move/index.ts +++ b/packages/backend/src/remote/activitypub/kernel/move/index.ts @@ -58,9 +58,6 @@ export default async (actor: CacheableRemoteUser, activity: IMove): Promise { //if follower is local if (!following.followerHost) { @@ -71,13 +68,7 @@ export default async (actor: CacheableRemoteUser, activity: IMove): Promise { // Publish meUpdated event publishMainStream(user.id, 'meUpdated', iObj); + const followings = await Followings.findBy({ + followeeId: user.id, + }); + + followings.forEach(async following => { + //if follower is local + if (!following.followerHost) { + const follower = await getUser(following.followerId).catch(e => { + if (e.id === '15348ddd-432d-49c2-8a5a-8069753becff') throw new ApiError(meta.errors.noSuchUser); + throw e; + }); + await deleteFollowing(follower!, user); + try { + await create(follower!, moveTo); + } catch (e) { /* empty */ } + } + }); + return iObj; });