aboutsummaryrefslogtreecommitdiff
path: root/lib/pleroma/web/twitter_api/twitter_api.ex
diff options
context:
space:
mode:
authorlain <lain@soykaf.club>2019-02-09 22:01:08 +0100
committerlain <lain@soykaf.club>2019-02-10 16:52:42 +0100
commit8a270b438c993288853bad94be1daf39f7675e5c (patch)
treeab26d304e36c01de054091320c03eb9214e1f7e1 /lib/pleroma/web/twitter_api/twitter_api.ex
parent1aebe8c6d94e8e49e96df16809a70c71d977310b (diff)
downloadpleroma-8a270b438c993288853bad94be1daf39f7675e5c.tar.gz
Do object insertion through Cachex
So we don't flood our postgres logs with errors. Should also make things slightly faster.
Diffstat (limited to 'lib/pleroma/web/twitter_api/twitter_api.ex')
-rw-r--r--lib/pleroma/web/twitter_api/twitter_api.ex12
1 files changed, 2 insertions, 10 deletions
diff --git a/lib/pleroma/web/twitter_api/twitter_api.ex b/lib/pleroma/web/twitter_api/twitter_api.ex
index 7d00c01a1..ddd5c5cfb 100644
--- a/lib/pleroma/web/twitter_api/twitter_api.ex
+++ b/lib/pleroma/web/twitter_api/twitter_api.ex
@@ -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