projects
/
akkoma
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add function to deactivate users.
[akkoma]
/
lib
/
pleroma
/
object.ex
diff --git
a/lib/pleroma/object.ex
b/lib/pleroma/object.ex
index 715a35591815394f5bfd25b1856b3252f9c98cce..30ba7b57a88f615557ea38884a9f40835e223784 100644
(file)
--- a/
lib/pleroma/object.ex
+++ b/
lib/pleroma/object.ex
@@
-9,16
+9,22
@@
defmodule Pleroma.Object do
timestamps()
end
timestamps()
end
+ def create(data) do
+ Object.change(%Object{}, %{data: data})
+ |> Repo.insert
+ end
+
def change(struct, params \\ %{}) do
def change(struct, params \\ %{}) do
-
changeset =
struct
+ struct
|> cast(params, [:data])
|> validate_required([:data])
|> unique_constraint(:ap_id, name: :objects_unique_apid_index)
end
|> 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,
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
end
def get_cached_by_ap_id(ap_id) do
@@
-38,6
+44,6
@@
defmodule Pleroma.Object do
end
def context_mapping(context) do
end
def context_mapping(context) do
- %Object{data: %{"id" => context}}
+ Object.change(%Object{}, %{data: %{"id" => context}})
end
end
end
end