Wrap context creation in transaction.

This commit is contained in:
Roger Braun 2017-04-30 13:58:40 +02:00
parent 4c8111c334
commit 379caca01d

View file

@ -319,6 +319,7 @@ defp make_date do
end end
def context_to_conversation_id(context) do def context_to_conversation_id(context) do
{:ok, id} = Repo.transaction(fn ->
with %Object{id: id} <- Object.get_by_ap_id(context) do with %Object{id: id} <- Object.get_by_ap_id(context) do
id id
else _e -> else _e ->
@ -326,6 +327,8 @@ def context_to_conversation_id(context) do
{:ok, %{id: id}} = Repo.insert(changeset) {:ok, %{id: id}} = Repo.insert(changeset)
id id
end end
end)
id
end end
def conversation_id_to_context(id) do def conversation_id_to_context(id) do