SideEffects: Run in transaction.
This fixes race conditions.
This commit is contained in:
parent
1cd38dfffa
commit
e62173dfc8
2 changed files with 34 additions and 4 deletions
|
|
@ -15,12 +15,15 @@ defmodule Pleroma.Web.ActivityPub.SideEffects do
|
|||
# - Add like to object
|
||||
# - Set up notification
|
||||
def handle(%{data: %{"type" => "Like"}} = object, meta) do
|
||||
liked_object = Object.get_by_ap_id(object.data["object"])
|
||||
Utils.add_like_to_object(object, liked_object)
|
||||
Pleroma.Repo.transaction(fn ->
|
||||
liked_object = Object.get_by_ap_id(object.data["object"])
|
||||
Utils.add_like_to_object(object, liked_object)
|
||||
|
||||
Notification.create_notifications(object)
|
||||
Notification.create_notifications(object)
|
||||
|
||||
{:ok, object, meta}
|
||||
{:ok, object, meta}
|
||||
end)
|
||||
|> (fn {:ok, res} -> res end).()
|
||||
end
|
||||
|
||||
# Nothing to do
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue