From: Ivan Tashkinov Date: Mon, 21 Jan 2019 11:16:51 +0000 (+0300) Subject: [#530] Prevents user `info` from being overwritten because of race conditions X-Git-Url: https://git.squeep.com/?a=commitdiff_plain;h=aa480f4a8b46f24a07491228462b4318ca25eda7;p=akkoma [#530] Prevents user `info` from being overwritten because of race conditions and non-partial update of embed (in WebFinger.ensure_keys_present and other places). --- diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex index 0431d62af..32c08c9d2 100644 --- a/lib/pleroma/web/activity_pub/activity_pub.ex +++ b/lib/pleroma/web/activity_pub/activity_pub.ex @@ -140,8 +140,9 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do additional ), {:ok, activity} <- insert(create_data, local), - :ok <- maybe_federate(activity), - {:ok, _actor} <- User.increase_note_count(actor) do + # Changing note count prior to federation in order not to reload `actor` (potentially updated by federator) + {:ok, _actor} <- User.increase_note_count(actor), + :ok <- maybe_federate(activity) do {:ok, activity} end end @@ -288,8 +289,9 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do with {:ok, _} <- Object.delete(object), {:ok, activity} <- insert(data, local), - :ok <- maybe_federate(activity), - {:ok, _actor} <- User.decrease_note_count(user) do + # Changing note count prior to federation in order not to reload `actor` (potentially updated by federator) + {:ok, _actor} <- User.decrease_note_count(user), + :ok <- maybe_federate(activity) do {:ok, activity} end end