Merge branch 'bug/fix-event-ics-cache' into 'master'

Properly update event ics export cache and fix export desc html

See merge request framasoft/mobilizon!266
This commit is contained in:
Thomas Citharel 2019-10-14 16:03:49 +02:00
commit ea40e1b6d9
3 changed files with 8 additions and 6 deletions

View file

@ -298,6 +298,8 @@ defmodule Mobilizon.Events do
}) })
end end
Cachex.del(:ics, "event_#{new_event.uuid}")
Mobilizon.Service.Events.Tool.calculate_event_diff_and_send_notifications( Mobilizon.Service.Events.Tool.calculate_event_diff_and_send_notifications(
old_event, old_event,
new_event, new_event,

View file

@ -8,7 +8,7 @@ defmodule MobilizonWeb.FeedController do
def actor(conn, %{"name" => name, "format" => "atom"}) do def actor(conn, %{"name" => name, "format" => "atom"}) do
case Cachex.fetch(:feed, "actor_" <> name) do case Cachex.fetch(:feed, "actor_" <> name) do
{:commit, data} -> {status, data} when status in [:commit, :ok] ->
conn conn
|> put_resp_content_type("application/atom+xml") |> put_resp_content_type("application/atom+xml")
|> send_resp(200, data) |> send_resp(200, data)
@ -20,7 +20,7 @@ defmodule MobilizonWeb.FeedController do
def actor(conn, %{"name" => name, "format" => "ics"}) do def actor(conn, %{"name" => name, "format" => "ics"}) do
case Cachex.fetch(:ics, "actor_" <> name) do case Cachex.fetch(:ics, "actor_" <> name) do
{:commit, data} -> {status, data} when status in [:commit, :ok] ->
conn conn
|> put_resp_content_type("text/calendar") |> put_resp_content_type("text/calendar")
|> send_resp(200, data) |> send_resp(200, data)
@ -32,7 +32,7 @@ defmodule MobilizonWeb.FeedController do
def event(conn, %{"uuid" => uuid, "format" => "ics"}) do def event(conn, %{"uuid" => uuid, "format" => "ics"}) do
case Cachex.fetch(:ics, "event_" <> uuid) do case Cachex.fetch(:ics, "event_" <> uuid) do
{:commit, data} -> {status, data} when status in [:commit, :ok] ->
conn conn
|> put_resp_content_type("text/calendar") |> put_resp_content_type("text/calendar")
|> send_resp(200, data) |> send_resp(200, data)
@ -44,7 +44,7 @@ defmodule MobilizonWeb.FeedController do
def going(conn, %{"token" => token, "format" => "ics"}) do def going(conn, %{"token" => token, "format" => "ics"}) do
case Cachex.fetch(:ics, "token_" <> token) do case Cachex.fetch(:ics, "token_" <> token) do
{:commit, data} -> {status, data} when status in [:commit, :ok] ->
conn conn
|> put_resp_content_type("text/calendar") |> put_resp_content_type("text/calendar")
|> send_resp(200, data) |> send_resp(200, data)
@ -56,7 +56,7 @@ defmodule MobilizonWeb.FeedController do
def going(conn, %{"token" => token, "format" => "atom"}) do def going(conn, %{"token" => token, "format" => "atom"}) do
case Cachex.fetch(:feed, "token_" <> token) do case Cachex.fetch(:feed, "token_" <> token) do
{:commit, data} -> {status, data} when status in [:commit, :ok] ->
conn conn
|> put_resp_content_type("application/atom+xml") |> put_resp_content_type("application/atom+xml")
|> send_resp(200, data) |> send_resp(200, data)

View file

@ -29,7 +29,7 @@ defmodule Mobilizon.Service.Export.ICalendar do
dtstart: event.begins_on, dtstart: event.begins_on,
dtstamp: event.publish_at || DateTime.utc_now(), dtstamp: event.publish_at || DateTime.utc_now(),
dtend: event.ends_on, dtend: event.ends_on,
description: event.description, description: HtmlSanitizeEx.strip_tags(event.description),
uid: event.uuid, uid: event.uuid,
categories: event.tags |> Enum.map(& &1.slug) categories: event.tags |> Enum.map(& &1.slug)
} }