From 9455dedd6d1fd02e3d45b9b550d0a6c7b1d09799 Mon Sep 17 00:00:00 2001 From: cutestnekoaqua Date: Mon, 12 Dec 2022 20:44:11 +0100 Subject: [PATCH 1/2] POV: coding at 3am bad --- .../backend/src/server/api/endpoints/i/move.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/packages/backend/src/server/api/endpoints/i/move.ts b/packages/backend/src/server/api/endpoints/i/move.ts index 4c0371979..8345ce094 100644 --- a/packages/backend/src/server/api/endpoints/i/move.ts +++ b/packages/backend/src/server/api/endpoints/i/move.ts @@ -7,8 +7,10 @@ import { genId } from '@/misc/gen-id.js'; import define from '../../define.js'; import { ApiError } from '../../error.js'; import { apiLogger } from '../../logger.js'; +import { Users } from '@/models/index.js'; import { UserProfiles } from '@/models/index.js'; import config from '@/config/index.js'; +import { publishMainStream } from '@/services/stream.js'; export const meta = { tags: ['users'], @@ -100,10 +102,24 @@ export default define(meta, paramDef, async (ps, user) => { if (!allowed || !toUrl || !fromUrl) throw new ApiError(meta.errors.remoteAccountForbids); + const updates = {} as Partial; + + if (!toUrl) toUrl = ''; + updates.movedToUri = toUrl; + + await Users.update(user.id, updates); + const iObj = await Users.pack(user.id, user, { + detail: true, + includeSecrets: true, + }); + const moveAct = moveActivity(toUrl, fromUrl); const dm = new DeliverManager(user, moveAct); dm.addFollowersRecipe(); dm.execute(); + // Publish meUpdated event + publishMainStream(user.id, 'meUpdated', iObj); + return true; }); From 072d14df9553276d5f7b3c592a0749913c426ad9 Mon Sep 17 00:00:00 2001 From: cutestnekoaqua Date: Mon, 12 Dec 2022 20:45:10 +0100 Subject: [PATCH 2/2] send moved user object back :3 --- packages/backend/src/server/api/endpoints/i/move.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/backend/src/server/api/endpoints/i/move.ts b/packages/backend/src/server/api/endpoints/i/move.ts index 8345ce094..89dc4617c 100644 --- a/packages/backend/src/server/api/endpoints/i/move.ts +++ b/packages/backend/src/server/api/endpoints/i/move.ts @@ -121,5 +121,5 @@ export default define(meta, paramDef, async (ps, user) => { // Publish meUpdated event publishMainStream(user.id, 'meUpdated', iObj); - return true; + return iObj; });