From cc701f8994e75e8461d8a15afa4da7371a03bd1e Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Mon, 14 Oct 2019 15:44:16 +0200 Subject: [PATCH] Properly update event ics export cache and fix export desc html Signed-off-by: Thomas Citharel --- lib/mobilizon/events/events.ex | 2 ++ lib/mobilizon_web/controllers/feed_controller.ex | 10 +++++----- lib/service/export/icalendar.ex | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/mobilizon/events/events.ex b/lib/mobilizon/events/events.ex index 739c65a41..5458cc087 100644 --- a/lib/mobilizon/events/events.ex +++ b/lib/mobilizon/events/events.ex @@ -298,6 +298,8 @@ defmodule Mobilizon.Events do }) end + Cachex.del(:ics, "event_#{new_event.uuid}") + Mobilizon.Service.Events.Tool.calculate_event_diff_and_send_notifications( old_event, new_event, diff --git a/lib/mobilizon_web/controllers/feed_controller.ex b/lib/mobilizon_web/controllers/feed_controller.ex index 4e4669b7d..83af58938 100644 --- a/lib/mobilizon_web/controllers/feed_controller.ex +++ b/lib/mobilizon_web/controllers/feed_controller.ex @@ -8,7 +8,7 @@ defmodule MobilizonWeb.FeedController do def actor(conn, %{"name" => name, "format" => "atom"}) do case Cachex.fetch(:feed, "actor_" <> name) do - {:commit, data} -> + {status, data} when status in [:commit, :ok] -> conn |> put_resp_content_type("application/atom+xml") |> send_resp(200, data) @@ -20,7 +20,7 @@ defmodule MobilizonWeb.FeedController do def actor(conn, %{"name" => name, "format" => "ics"}) do case Cachex.fetch(:ics, "actor_" <> name) do - {:commit, data} -> + {status, data} when status in [:commit, :ok] -> conn |> put_resp_content_type("text/calendar") |> send_resp(200, data) @@ -32,7 +32,7 @@ defmodule MobilizonWeb.FeedController do def event(conn, %{"uuid" => uuid, "format" => "ics"}) do case Cachex.fetch(:ics, "event_" <> uuid) do - {:commit, data} -> + {status, data} when status in [:commit, :ok] -> conn |> put_resp_content_type("text/calendar") |> send_resp(200, data) @@ -44,7 +44,7 @@ defmodule MobilizonWeb.FeedController do def going(conn, %{"token" => token, "format" => "ics"}) do case Cachex.fetch(:ics, "token_" <> token) do - {:commit, data} -> + {status, data} when status in [:commit, :ok] -> conn |> put_resp_content_type("text/calendar") |> send_resp(200, data) @@ -56,7 +56,7 @@ defmodule MobilizonWeb.FeedController do def going(conn, %{"token" => token, "format" => "atom"}) do case Cachex.fetch(:feed, "token_" <> token) do - {:commit, data} -> + {status, data} when status in [:commit, :ok] -> conn |> put_resp_content_type("application/atom+xml") |> send_resp(200, data) diff --git a/lib/service/export/icalendar.ex b/lib/service/export/icalendar.ex index 94a465d5a..2d65e519e 100644 --- a/lib/service/export/icalendar.ex +++ b/lib/service/export/icalendar.ex @@ -29,7 +29,7 @@ defmodule Mobilizon.Service.Export.ICalendar do dtstart: event.begins_on, dtstamp: event.publish_at || DateTime.utc_now(), dtend: event.ends_on, - description: event.description, + description: HtmlSanitizeEx.strip_tags(event.description), uid: event.uuid, categories: event.tags |> Enum.map(& &1.slug) }