X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=lib%2Fpleroma%2Fweb%2Factivity_pub%2Futils.ex;h=6a89374d0126d792bd37d18e8a326e60766730cd;hb=833161b5d21f85e2276cd0cee3e148ecbe6e1f05;hp=e34dd1d4112a1cfd29ac7a9190d670f6456cb1a8;hpb=3f32d7b937a2368707794b55d1256bfa9fa508f4;p=akkoma diff --git a/lib/pleroma/web/activity_pub/utils.ex b/lib/pleroma/web/activity_pub/utils.ex index e34dd1d41..6a89374d0 100644 --- a/lib/pleroma/web/activity_pub/utils.ex +++ b/lib/pleroma/web/activity_pub/utils.ex @@ -142,8 +142,14 @@ defmodule Pleroma.Web.ActivityPub.Utils do context = context || generate_id("contexts") changeset = Object.context_mapping(context) - with {:ok, object} <- Object.insert_or_get(changeset) do - object + case Repo.insert(changeset) do + {: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) end end