use Kernel.put_in instead of Map.merge

This commit is contained in:
Rin Toshaka 2018-12-29 21:50:34 +01:00
parent 19f9889fbe
commit 9a0163db53
1 changed files with 6 additions and 4 deletions

View File

@ -300,17 +300,19 @@ def get_scrubbed_html(
if !(new_scrubber_cache == scrubber_cache) or scrubbed_html == nil do if !(new_scrubber_cache == scrubber_cache) or scrubbed_html == nil do
scrubbed_html = HTML.filter_tags(content, scrubbers) scrubbed_html = HTML.filter_tags(content, scrubbers)
new_scrubber_cache = [%{:scrubbers => key, :content => scrubbed_html} | new_scrubber_cache] new_scrubber_cache = [%{:scrubbers => key, :content => scrubbed_html} | new_scrubber_cache]
IO.puts(activity)
activity = activity =
Map.merge(activity, %{ Map.put(
data: %{"object" => %{"scrubber_cache" => new_scrubber_cache}} activity,
}) :data,
Kernel.put_in(activity.data, ["object", "scrubber_cache"], new_scrubber_cache)
)
cng = Ecto.Changeset.change(activity) cng = Ecto.Changeset.change(activity)
Repo.update(cng) Repo.update(cng)
scrubbed_html scrubbed_html
else else
IO.puts("got the post from cache")
scrubbed_html scrubbed_html
end end
end end