commit: 1e6491ec96c3eb4e7ce1ca76b521b892206fac03
parent: 069daf644d984c479eae6483595a3307e923950b
Author: Roger Braun <roger@rogerbraun.net>
Date: Tue, 20 Jun 2017 11:49:41 +0200
Merge branch 'develop' into refactor/user-view
Diffstat:
2 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/lib/pleroma/object.ex b/lib/pleroma/object.ex
@@ -43,6 +43,6 @@ defmodule Pleroma.Object do
end
def context_mapping(context) do
- %Object{data: %{"id" => context}}
+ Object.change(%Object{}, %{data: %{"id" => context}})
end
end
diff --git a/lib/pleroma/web/twitter_api/twitter_api.ex b/lib/pleroma/web/twitter_api/twitter_api.ex
@@ -282,10 +282,14 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do
def context_to_conversation_id(context) do
with %Object{id: id} <- Object.get_cached_by_ap_id(context) do
id
- else _e ->
- changeset = Object.context_mapping(context)
- {:ok, %{id: id}} = Repo.insert(changeset)
- id
+ 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
end
end