projects
/
akkoma
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
be6b571
)
object: add Object.prune()
author
William Pitcock
<nenolod@dereferenced.org>
Tue, 21 May 2019 00:41:40 +0000
(
00:41
+0000)
committer
William Pitcock
<nenolod@dereferenced.org>
Tue, 21 May 2019 21:38:56 +0000
(21:38 +0000)
lib/pleroma/object.ex
patch
|
blob
|
history
diff --git
a/lib/pleroma/object.ex
b/lib/pleroma/object.ex
index 740d687a3505fc03ea0cc2161aa44bba4a5f8872..cc6fc9c5dfeb25c3311778fc4878090069c8dedd 100644
(file)
--- a/
lib/pleroma/object.ex
+++ b/
lib/pleroma/object.ex
@@
-130,6
+130,13
@@
defmodule Pleroma.Object do
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}