Various typespec and compilation improvements

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2021-09-10 11:27:59 +02:00
parent 029a4ea194
commit de047c8939
125 changed files with 790 additions and 357 deletions

View File

@@ -4,16 +4,19 @@ defmodule Mobilizon.Web.Cache do
"""
alias Mobilizon.Actors.Actor
alias Mobilizon.Web.Cache.ActivityPub
import Mobilizon.Service.Guards, only: [is_valid_string: 1]
@caches [:activity_pub, :feed, :ics]
@type local_actor :: %Actor{domain: nil}
@doc """
Clears all caches for an actor.
Clears all caches for a local actor.
"""
@spec clear_cache(Actor.t()) :: {:ok, true}
def clear_cache(%Actor{preferred_username: preferred_username, domain: nil}) do
@spec clear_cache(%Actor{domain: nil, preferred_username: String.t()}) :: :ok
def clear_cache(%Actor{preferred_username: preferred_username, domain: nil})
when is_valid_string(preferred_username) do
Enum.each(@caches, &Cachex.del(&1, "actor_" <> preferred_username))
end