X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=lib%2Fpleroma%2Fweb%2Factivity_pub%2Futils.ex;h=7b2bf8fa7cc5f437001a2cfc477dd0020d8ea66c;hb=114ca9e069a0914cc1ad8bf13690818eb132b0bf;hp=ac3a57e035414e3b3502bd2cfa118db52e2409bf;hpb=bc31bee7c4d5fc96d4c1923b61db7489b78f4558;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),