mirror of
https://git.pleroma.social/pleroma/pleroma.git
synced 2024-12-22 16:16:34 +00:00
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 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do
|
|||
end
|
||||
|
||||
def context_to_conversation_id(context) do
|
||||
with %Object{id: id} <- Object.get_by_ap_id(context) do
|
||||
id
|
||||
else _e ->
|
||||
changeset = Object.context_mapping(context)
|
||||
{:ok, %{id: id}} = Repo.insert(changeset)
|
||||
id
|
||||
end
|
||||
{:ok, id} = Repo.transaction(fn ->
|
||||
with %Object{id: id} <- Object.get_by_ap_id(context) do
|
||||
id
|
||||
else _e ->
|
||||
changeset = Object.context_mapping(context)
|
||||
{:ok, %{id: id}} = Repo.insert(changeset)
|
||||
id
|
||||
end
|
||||
end)
|
||||
id
|
||||
end
|
||||
|
||||
def conversation_id_to_context(id) do
|
||||
|
|
Loading…
Reference in a new issue