Add an authenticated fetch route for members
If the member is remote, it redirects to original instance 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
@@ -4,7 +4,7 @@ defmodule Mobilizon.Web.Cache.ActivityPub do
|
||||
"""
|
||||
|
||||
alias Mobilizon.{Actors, Discussions, Events, Posts, Resources, Todos, Tombstone}
|
||||
alias Mobilizon.Actors.Actor
|
||||
alias Mobilizon.Actors.{Actor, Member}
|
||||
alias Mobilizon.Discussions.{Comment, Discussion}
|
||||
alias Mobilizon.Events.Event
|
||||
alias Mobilizon.Federation.ActivityPub.Relay
|
||||
@@ -174,6 +174,23 @@ defmodule Mobilizon.Web.Cache.ActivityPub do
|
||||
end)
|
||||
end
|
||||
|
||||
@doc """
|
||||
Gets a member by its UUID, with all associations loaded.
|
||||
"""
|
||||
@spec get_member_by_uuid_with_preload(String.t()) ::
|
||||
{:commit, Todo.t()} | {:ignore, nil}
|
||||
def get_member_by_uuid_with_preload(uuid) do
|
||||
Cachex.fetch(@cache, "member_" <> uuid, fn "member_" <> uuid ->
|
||||
case Actors.get_member(uuid) do
|
||||
%Member{} = member ->
|
||||
{:commit, member}
|
||||
|
||||
nil ->
|
||||
{:ignore, nil}
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
@doc """
|
||||
Gets a relay.
|
||||
"""
|
||||
|
||||
1
lib/web/cache/cache.ex
vendored
1
lib/web/cache/cache.ex
vendored
@@ -24,6 +24,7 @@ defmodule Mobilizon.Web.Cache do
|
||||
defdelegate get_resource_by_uuid_with_preload(uuid), to: ActivityPub
|
||||
defdelegate get_todo_list_by_uuid_with_preload(uuid), to: ActivityPub
|
||||
defdelegate get_todo_by_uuid_with_preload(uuid), to: ActivityPub
|
||||
defdelegate get_member_by_uuid_with_preload(uuid), to: ActivityPub
|
||||
defdelegate get_post_by_slug_with_preload(slug), to: ActivityPub
|
||||
defdelegate get_discussion_by_slug_with_preload(slug), to: ActivityPub
|
||||
defdelegate get_relay, to: ActivityPub
|
||||
|
||||
Reference in New Issue
Block a user