From cb85b4a1de2a88e62163c27fc48e0df22ca34e28 Mon Sep 17 00:00:00 2001 From: Jesse Wierzbinski Date: Tue, 9 Apr 2024 20:22:36 -1000 Subject: [PATCH] Only mark as followed in database if federation works --- database/entities/User.ts | 22 +++++++++++----------- server/api/api/v1/accounts/lookup/index.ts | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/database/entities/User.ts b/database/entities/User.ts index 4b07daf9..72a546a1 100644 --- a/database/entities/User.ts +++ b/database/entities/User.ts @@ -71,17 +71,6 @@ export const followRequestUser = async ( ) => { const isRemote = follower.instanceId !== followee.instanceId; - const relationship = await client.relationship.update({ - where: { id: relationshipId }, - data: { - following: isRemote ? false : !followee.isLocked, - requested: isRemote ? true : followee.isLocked, - showingReblogs: reblogs, - notifying: notify, - languages: languages, - }, - }); - if (isRemote) { // Federate // TODO: Make database job @@ -120,6 +109,17 @@ export const followRequestUser = async ( } } + const relationship = await client.relationship.update({ + where: { id: relationshipId }, + data: { + following: isRemote ? false : !followee.isLocked, + requested: isRemote ? true : followee.isLocked, + showingReblogs: reblogs, + notifying: notify, + languages: languages, + }, + }); + return relationship; }; diff --git a/server/api/api/v1/accounts/lookup/index.ts b/server/api/api/v1/accounts/lookup/index.ts index 76cd18cb..21f709a1 100644 --- a/server/api/api/v1/accounts/lookup/index.ts +++ b/server/api/api/v1/accounts/lookup/index.ts @@ -68,5 +68,5 @@ export default apiRoute<{ return jsonResponse(userToAPI(account)); } - return errorResponse(`Account with username ${username} not found"`, 404); + return errorResponse(`Account with username ${username} not found`, 404); });