Redirect properly to correct endpoint depending on content-type

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2019-03-04 17:20:18 +01:00
parent 634157eb4b
commit 66e67aa816
12 changed files with 237 additions and 70 deletions

View File

@@ -154,6 +154,16 @@ defmodule Mobilizon.Events do
|> Repo.one()
end
def get_cached_event_full_by_uuid(uuid) do
Cachex.fetch(:activity_pub, "event_" <> uuid, fn "event_" <> uuid ->
with %Event{} = event <- get_event_full_by_uuid(uuid) do
{:commit, event}
else
_ -> {:ignore, nil}
end
end)
end
@doc """
Gets a single event, with all associations loaded.
"""
@@ -1018,6 +1028,16 @@ defmodule Mobilizon.Events do
end
end
def get_cached_comment_full_by_uuid("comment_" <> uuid) do
Cachex.fetch(:activity_pub, "comment_" <> uuid, fn "comment_" <> uuid ->
with %Comment{} = comment <- Events.get_comment_full_from_uuid(uuid) do
{:commit, comment}
else
_ -> {:ignore, nil}
end
end)
end
def get_comment_from_url(url), do: Repo.get_by(Comment, url: url)
def get_comment_from_url!(url), do: Repo.get_by!(Comment, url: url)