Do object insertion through Cachex

So we don't flood our postgres logs with errors. Should also make things
slightly faster.
This commit is contained in:
lain 2019-02-09 22:01:08 +01:00
commit f8388be9c6
4 changed files with 53 additions and 19 deletions

View file

@ -134,14 +134,8 @@ defmodule Pleroma.Web.ActivityPub.Utils do
context = context || generate_id("contexts")
changeset = Object.context_mapping(context)
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)
with {:ok, object} <- Object.insert_or_get(changeset) do
object
end
end