X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=lib%2Fpleroma%2Fweb%2Factivity_pub%2Futils.ex;h=7b2bf8fa7cc5f437001a2cfc477dd0020d8ea66c;hb=aaacebd906b0506b1d0f55df3047f0d730bd4b26;hp=ac3a57e035414e3b3502bd2cfa118db52e2409bf;hpb=96007753ad099b43fcea33662e22b5528426849d;p=akkoma diff --git a/lib/pleroma/web/activity_pub/utils.ex b/lib/pleroma/web/activity_pub/utils.ex index ac3a57e03..7b2bf8fa7 100644 --- a/lib/pleroma/web/activity_pub/utils.ex +++ b/lib/pleroma/web/activity_pub/utils.ex @@ -50,10 +50,13 @@ defmodule Pleroma.Web.ActivityPub.Utils do changeset = Object.context_mapping(context) case Repo.insert(changeset) do - {:ok, object} -> object + {:ok, object} -> + object + # This should be solved by an upsert, but it seems ecto # has problems accessing the constraint inside the jsonb. - {:error, _} -> Object.get_cached_by_ap_id(context) + {:error, _} -> + Object.get_cached_by_ap_id(context) end end @@ -172,7 +175,8 @@ defmodule Pleroma.Web.ActivityPub.Utils do def update_element_in_object(property, element, object) do with new_data <- - object.data |> Map.put("#{property}_count", length(element)) + object.data + |> Map.put("#{property}_count", length(element)) |> Map.put("#{property}s", element), changeset <- Changeset.change(object, data: new_data), {:ok, object} <- Repo.update(changeset),