forked from AkkomaGang/akkoma
Wrap context creation in transaction.
This commit is contained in:
parent
4c8111c334
commit
379caca01d
1 changed files with 10 additions and 7 deletions
|
@ -319,13 +319,16 @@ defp make_date do
|
||||||
end
|
end
|
||||||
|
|
||||||
def context_to_conversation_id(context) do
|
def context_to_conversation_id(context) do
|
||||||
with %Object{id: id} <- Object.get_by_ap_id(context) do
|
{:ok, id} = Repo.transaction(fn ->
|
||||||
id
|
with %Object{id: id} <- Object.get_by_ap_id(context) do
|
||||||
else _e ->
|
id
|
||||||
changeset = Object.context_mapping(context)
|
else _e ->
|
||||||
{:ok, %{id: id}} = Repo.insert(changeset)
|
changeset = Object.context_mapping(context)
|
||||||
id
|
{:ok, %{id: id}} = Repo.insert(changeset)
|
||||||
end
|
id
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
id
|
||||||
end
|
end
|
||||||
|
|
||||||
def conversation_id_to_context(id) do
|
def conversation_id_to_context(id) do
|
||||||
|
|
Loading…
Reference in a new issue