From 024a0fe6432088d8c11abe341a5e9f2447b25f6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E8=BE=89?= <1101635162@qq.com> Date: Tue, 8 Oct 2024 10:22:56 +0800 Subject: [PATCH] :art: --- .../b3log/symphony/processor/FollowProcessor.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/b3log/symphony/processor/FollowProcessor.java b/src/main/java/org/b3log/symphony/processor/FollowProcessor.java index 478a64f9..429f8b90 100644 --- a/src/main/java/org/b3log/symphony/processor/FollowProcessor.java +++ b/src/main/java/org/b3log/symphony/processor/FollowProcessor.java @@ -116,7 +116,11 @@ public void followUser(final RequestContext context) { final JSONObject requestJSONObject = context.requestJSON(); final String followingUserId = requestJSONObject.optString(Follow.FOLLOWING_ID); - final JSONObject currentUser = Sessions.getUser(); + JSONObject currentUser = Sessions.getUser(); + try { + currentUser = ApiProcessor.getUserByKey(requestJSONObject.optString("apiKey")); + } catch (NullPointerException ignored) { + } final String followerUserId = currentUser.optString(Keys.OBJECT_ID); followMgmtService.followUser(followerUserId, followingUserId); @@ -149,7 +153,11 @@ public void unfollowUser(final RequestContext context) { context.renderJSON(StatusCodes.SUCC); final JSONObject requestJSONObject = context.requestJSON(); final String followingUserId = requestJSONObject.optString(Follow.FOLLOWING_ID); - final JSONObject currentUser = Sessions.getUser(); + JSONObject currentUser = Sessions.getUser(); + try { + currentUser = ApiProcessor.getUserByKey(requestJSONObject.optString("apiKey")); + } catch (NullPointerException ignored) { + } final String followerUserId = currentUser.optString(Keys.OBJECT_ID); followMgmtService.unfollowUser(followerUserId, followingUserId); }