Add cached RSS feeds for actors endpoints

This commit is contained in:
Thomas Citharel
2019-02-27 16:28:09 +01:00
parent 976186a18d
commit 02d1cea2d7
14 changed files with 462 additions and 62 deletions

View File

@@ -354,6 +354,9 @@ defmodule Mobilizon.Actors.Actor do
end
end
@doc """
Return the preferred_username with the eventual @domain suffix if it's a distant actor
"""
@spec actor_acct_from_actor(struct()) :: String.t()
def actor_acct_from_actor(%Actor{preferred_username: preferred_username, domain: domain}) do
if is_nil(domain) do
@@ -362,4 +365,16 @@ defmodule Mobilizon.Actors.Actor do
"#{preferred_username}@#{domain}"
end
end
@doc """
Returns the display name if available, or the preferred_username (with the eventual @domain suffix if it's a distant actor).
"""
@spec display_name(struct()) :: String.t()
def display_name(%Actor{name: name} = actor) do
case name do
nil -> actor_acct_from_actor(actor)
"" -> actor_acct_from_actor(actor)
name -> name
end
end
end