[#530] Prevents user `info` from being overwritten because of race conditions
authorIvan Tashkinov <ivantashkinov@gmail.com>
Mon, 21 Jan 2019 11:16:51 +0000 (14:16 +0300)
committerIvan Tashkinov <ivantashkinov@gmail.com>
Mon, 21 Jan 2019 11:16:51 +0000 (14:16 +0300)
and non-partial update of embed (in WebFinger.ensure_keys_present and other places).

lib/pleroma/web/activity_pub/activity_pub.ex

index 0431d62aff40ae9e0df11566b7ff236ee1ab02eb..32c08c9d2149ed62ccd8aabe18717223d99885c2 100644 (file)
@@ -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