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

@ -305,16 +305,8 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do
else
_e ->
changeset = Object.context_mapping(context)
case Repo.insert(changeset) do
{:ok, %{id: id}} ->
id
# 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).id
end
{:ok, object} = Object.insert_or_get(changeset)
object.id
end
end