projects
/
akkoma
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
add ignore hosts and TLDs for rich_media
[akkoma]
/
lib
/
pleroma
/
object.ex
diff --git
a/lib/pleroma/object.ex
b/lib/pleroma/object.ex
index a0f7659eb18f2dbfc7686d2b314293a3f0c406bb..4b181ec59f0ab225d3c1c44add562587036cf226 100644
(file)
--- a/
lib/pleroma/object.ex
+++ b/
lib/pleroma/object.ex
@@
-35,6
+35,9
@@
defmodule Pleroma.Object do
|> unique_constraint(:ap_id, name: :objects_unique_apid_index)
end
|> unique_constraint(:ap_id, name: :objects_unique_apid_index)
end
+ def get_by_id(nil), do: nil
+ def get_by_id(id), do: Repo.get(Object, id)
+
def get_by_ap_id(nil), do: nil
def get_by_ap_id(ap_id) do
def get_by_ap_id(nil), do: nil
def get_by_ap_id(ap_id) do
@@
-130,6
+133,13
@@
defmodule Pleroma.Object do
end
end
end
end
+ def prune(%Object{data: %{"id" => id}} = object) do
+ with {:ok, object} <- Repo.delete(object),
+ {:ok, true} <- Cachex.del(:object_cache, "object:#{id}") do
+ {:ok, object}
+ end
+ end
+
def set_cache(%Object{data: %{"id" => ap_id}} = object) do
Cachex.put(:object_cache, "object:#{ap_id}", object)
{:ok, object}
def set_cache(%Object{data: %{"id" => ap_id}} = object) do
Cachex.put(:object_cache, "object:#{ap_id}", object)
{:ok, object}