diff options
Diffstat (limited to 'lib/pleroma/object.ex')
-rw-r--r-- | lib/pleroma/object.ex | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/pleroma/object.ex b/lib/pleroma/object.ex index 5b51d6be3..30ba7b57a 100644 --- a/lib/pleroma/object.ex +++ b/lib/pleroma/object.ex @@ -15,15 +15,16 @@ defmodule Pleroma.Object do end def change(struct, params \\ %{}) do - changeset = struct + struct |> cast(params, [:data]) |> validate_required([:data]) |> unique_constraint(:ap_id, name: :objects_unique_apid_index) end + def get_by_ap_id(nil), do: nil def get_by_ap_id(ap_id) do Repo.one(from object in Object, - where: fragment("? @> ?", object.data, ^%{id: ap_id})) + where: fragment("(?)->>'id' = ?", object.data, ^ap_id)) end def get_cached_by_ap_id(ap_id) do |