From: William Pitcock Date: Tue, 21 May 2019 00:41:40 +0000 (+0000) Subject: object: add Object.prune() X-Git-Url: https://git.squeep.com/?a=commitdiff_plain;h=c2b0b82e6a6d40f945feacc001ad984a17e23336;p=akkoma object: add Object.prune() --- diff --git a/lib/pleroma/object.ex b/lib/pleroma/object.ex index 740d687a3..cc6fc9c5d 100644 --- 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}