diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/object.ex | 9 | ||||
-rw-r--r-- | lib/pleroma/web/activity_pub/activity_pub.ex | 2 | ||||
-rw-r--r-- | lib/pleroma/web/activity_pub/utils.ex | 2 |
3 files changed, 10 insertions, 3 deletions
diff --git a/lib/pleroma/object.ex b/lib/pleroma/object.ex index 9ff6e588a..0b8532832 100644 --- a/lib/pleroma/object.ex +++ b/lib/pleroma/object.ex @@ -19,14 +19,21 @@ defmodule Pleroma.Object do schema "objects" do field(:data, :map) + # This is set by a database side trigger on insert and update field(:ap_id, :string) timestamps() end + # Add the default 'returning' options, so we get the generated ap_id column + def insert(cng, options \\ []) do + cng + |> Repo.insert(Keyword.put(options, :returning, true)) + end + def create(data) do Object.change(%Object{}, %{data: data}) - |> Repo.insert() + |> insert() end def change(struct, params \\ %{}) do diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex index 5052d1304..91f2cf972 100644 --- a/lib/pleroma/web/activity_pub/activity_pub.ex +++ b/lib/pleroma/web/activity_pub/activity_pub.ex @@ -1013,7 +1013,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do data end - Repo.insert(%Object{data: obj_data}) + Object.insert(%Object{data: obj_data}) end end diff --git a/lib/pleroma/web/activity_pub/utils.ex b/lib/pleroma/web/activity_pub/utils.ex index 4ef479f96..711a74e69 100644 --- a/lib/pleroma/web/activity_pub/utils.ex +++ b/lib/pleroma/web/activity_pub/utils.ex @@ -143,7 +143,7 @@ defmodule Pleroma.Web.ActivityPub.Utils do with true <- is_nil(object), changeset <- Object.context_mapping(context), - {:ok, inserted_object} <- Repo.insert(changeset) do + {:ok, inserted_object} <- Object.insert(changeset) do inserted_object else _ -> |