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:
parent
99fd199bda
commit
f8388be9c6
4 changed files with 53 additions and 19 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue