From c119ea3a5727d521c36d60eca22fa3f20d507b63 Mon Sep 17 00:00:00 2001 From: Rin Toshaka Date: Sun, 30 Dec 2018 20:00:01 +0100 Subject: [PATCH] Friendship ended with Postgresql now Cachex is my best friend --- lib/pleroma/object.ex | 16 +++++++++------- lib/pleroma/web/common_api/utils.ex | 1 - 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/pleroma/object.ex b/lib/pleroma/object.ex index e148c1d75..d9f0e91b0 100644 --- a/lib/pleroma/object.ex +++ b/lib/pleroma/object.ex @@ -73,10 +73,10 @@ def delete(%Object{data: %{"id" => id}} = object) do {:ok, object} end end - + def get_cached_scrubbed_html(content, scrubbers, object) do key = "#{generate_scrubber_signature(scrubbers)}|#{object.id}" - Cachex.fetch!(:scrubber_cache, key, fn(_key) -> ensure_scrubbed_html(content, scrubbers) end ) + Cachex.fetch!(:scrubber_cache, key, fn _key -> ensure_scrubbed_html(content, scrubbers) end) end def get_cached_stripped_html(content, object) do @@ -87,22 +87,24 @@ def ensure_scrubbed_html( content, scrubbers ) do - {:commit, HTML.filter_tags(content, scrubbers)} + {:commit, HTML.filter_tags(content, scrubbers)} end - + defp generate_scrubber_signature(scrubber) when is_atom(scrubber) do generate_scrubber_signature([scrubber]) end defp generate_scrubber_signature(scrubbers) do Enum.reduce(scrubbers, "", fn scrubber, signature -> - # If a scrubber does not have a version(e.g HtmlSanitizeEx.Scrubber) it is assumed it is always 0) - version = if Kernel.function_exported?(scrubber, :version, 0) do + # If a scrubber does not have a version(e.g HtmlSanitizeEx.Scrubber) it is assumed it is always 0) + version = + if Kernel.function_exported?(scrubber, :version, 0) do scrubber.version else 0 end - "#{signature}#{to_string(scrubber)}#{version}" + + "#{signature}#{to_string(scrubber)}#{version}" end) end end diff --git a/lib/pleroma/web/common_api/utils.ex b/lib/pleroma/web/common_api/utils.ex index 813eb4093..b91cfc4bb 100644 --- a/lib/pleroma/web/common_api/utils.ex +++ b/lib/pleroma/web/common_api/utils.ex @@ -261,5 +261,4 @@ def emoji_from_profile(%{info: _info} = user) do } end) end - end