Improve member adding and excluding flow
Allow to exclude a member Send emails to the member when it's excluded Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
19
lib/web/cache/activity_pub.ex
vendored
19
lib/web/cache/activity_pub.ex
vendored
@@ -16,13 +16,30 @@ defmodule Mobilizon.Web.Cache.ActivityPub do
|
||||
|
||||
@cache :activity_pub
|
||||
|
||||
@doc """
|
||||
Gets a actor by username and eventually domain.
|
||||
"""
|
||||
@spec get_actor_by_name(String.t()) ::
|
||||
{:commit, Actor.t()} | {:ignore, nil}
|
||||
def get_actor_by_name(name) do
|
||||
Cachex.fetch(@cache, "actor_" <> name, fn "actor_" <> name ->
|
||||
case Actors.get_actor_by_name(name) do
|
||||
%Actor{} = actor ->
|
||||
{:commit, actor}
|
||||
|
||||
nil ->
|
||||
{:ignore, nil}
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
@doc """
|
||||
Gets a local actor by username.
|
||||
"""
|
||||
@spec get_local_actor_by_name(String.t()) ::
|
||||
{:commit, Actor.t()} | {:ignore, nil}
|
||||
def get_local_actor_by_name(name) do
|
||||
Cachex.fetch(@cache, "actor_" <> name, fn "actor_" <> name ->
|
||||
Cachex.fetch(@cache, "local_actor_" <> name, fn "local_actor_" <> name ->
|
||||
case Actors.get_local_actor_by_name(name) do
|
||||
%Actor{} = actor ->
|
||||
{:commit, actor}
|
||||
|
||||
1
lib/web/cache/cache.ex
vendored
1
lib/web/cache/cache.ex
vendored
@@ -17,6 +17,7 @@ defmodule Mobilizon.Web.Cache do
|
||||
Enum.each(@caches, &Cachex.del(&1, "actor_" <> preferred_username))
|
||||
end
|
||||
|
||||
defdelegate get_actor_by_name(name), to: ActivityPub
|
||||
defdelegate get_local_actor_by_name(name), to: ActivityPub
|
||||
defdelegate get_public_event_by_uuid_with_preload(uuid), to: ActivityPub
|
||||
defdelegate get_comment_by_uuid_with_preload(uuid), to: ActivityPub
|
||||
|
||||
Reference in New Issue
Block a user