Remove unnecessary re-fetch of the actor

This commit is contained in:
Mark Felder 2024-08-22 13:43:01 -04:00
parent a9aa810d3d
commit 39108c5f12

View file

@ -16,11 +16,7 @@ defmodule Pleroma.User.Import do
def perform(:mute_import, %User{} = user, actor) do def perform(:mute_import, %User{} = user, actor) do
with {:ok, %User{} = muted_user} <- User.get_or_fetch(actor), with {:ok, %User{} = muted_user} <- User.get_or_fetch(actor),
{_, false} <- {:existing_mute, User.mutes_user?(user, muted_user)}, {_, false} <- {:existing_mute, User.mutes_user?(user, muted_user)},
{:ok, _} <- User.mute(user, muted_user), {:ok, _} <- User.mute(user, muted_user) do
# User.mute/2 returns a FollowingRelationship not a %User{} like we get
# from CommonAPI.block/2 or CommonAPI.follow/2, so we fetch again to
# return the target actor for consistency
{:ok, muted_user} <- User.get_or_fetch(actor) do
{:ok, muted_user} {:ok, muted_user}
else else
{:existing_mute, true} -> :ok {:existing_mute, true} -> :ok