From 57e7ab96e785fb93fa367bbfc885e390ad998609 Mon Sep 17 00:00:00 2001 From: kPherox Date: Wed, 6 Mar 2024 18:49:29 +0900 Subject: [PATCH] fix: split comparison for acct uri and nickname --- lib/mix/tasks/pleroma/user.ex | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/lib/mix/tasks/pleroma/user.ex b/lib/mix/tasks/pleroma/user.ex index 346345767..ed17265fb 100644 --- a/lib/mix/tasks/pleroma/user.ex +++ b/lib/mix/tasks/pleroma/user.ex @@ -460,12 +460,11 @@ defmodule Mix.Tasks.Pleroma.User do with {_, %User{} = before_user} <- {:before, User.get_cached_by_nickname(nickname)}, {_, {:ok, %{"ap_id" => ap_id, "subject" => "acct:" <> acct}}} when not is_nil(ap_id) <- {:webfinger, Pleroma.Web.WebFinger.finger(nickname)}, + {_, true, _, _} <- {:acct_uri_comparison, nickname == acct, ap_id, acct}, {_, %User{} = current_user} <- {:current, User.get_cached_by_ap_id(ap_id)}, - {_, false, false, _, _} <- - {:nickname_comparison, nickname == current_user.nickname, - acct == current_user.nickname, ap_id, acct}, {_, false, _} <- - {:ap_id_comparison, before_user.ap_id == current_user.ap_id, current_user.ap_id} do + {:ap_id_comparison, before_user.ap_id == current_user.ap_id, current_user.ap_id}, + {_, false, _} <- {:nickname_comparison, nickname == current_user.nickname, ap_id} do shell_info( "Found an before user for #{nickname}, the before ap id is #{before_user.ap_id}, current one is #{current_user.ap_id}, renaming." ) @@ -484,18 +483,18 @@ defmodule Mix.Tasks.Pleroma.User do {x, _} when x in [:current, :webfinger] -> shell_error("Not found remote users for #{nickname}") - {:nickname_comparison, true, _, ap_id, _} -> - shell_info( - "Found a user for #{nickname}, but the ap id #{ap_id} is the same as the current user. Race condition? Not changing anything." - ) - - {:nickname_comparison, false, true, ap_id, acct} -> + {:acct_uri_comparison, false, ap_id, acct} -> shell_info( "Found a user for #{nickname}, but the ap id #{ap_id} is current nickname #{acct}. Not changing anything." ) {:ap_id_comparison, true, ap_id} -> shell_info("Found a user for #{nickname}. Correct ap id #{ap_id}.") + + {:nickname_comparison, true, ap_id} -> + shell_info( + "Found a user for #{nickname}, but the ap id #{ap_id} is the same as the current user. Race condition? Not changing anything." + ) end end