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

@@ -467,6 +467,20 @@ defmodule Mobilizon.Actors do
|> Repo.preload(:organized_events)
end
@doc """
Returns a cached local actor by username
"""
@spec get_cached_local_actor_by_name(String.t()) ::
{:ok, Actor.t()} | {:commit, Actor.t()} | {:ignore, any()}
def get_cached_local_actor_by_name(name) do
Cachex.fetch(:activity_pub, "actor_" <> name, fn "actor_" <> name ->
case get_local_actor_by_name(name) do
nil -> {:ignore, nil}
%Actor{} = actor -> {:commit, actor}
end
end)
end
@doc """
Getting an actor from url, eventually creating it
"""