20
lib/web/cache/activity_pub.ex
vendored
20
lib/web/cache/activity_pub.ex
vendored
@@ -3,9 +3,10 @@ defmodule Mobilizon.Web.Cache.ActivityPub do
|
||||
ActivityPub related cache.
|
||||
"""
|
||||
|
||||
alias Mobilizon.{Actors, Discussions, Events, Posts, Resources, Todos, Tombstone}
|
||||
alias Mobilizon.{Actors, Conversations, Discussions, Events, Posts, Resources, Todos, Tombstone}
|
||||
alias Mobilizon.Actors.Actor, as: ActorModel
|
||||
alias Mobilizon.Actors.Member
|
||||
alias Mobilizon.Conversations.Conversation
|
||||
alias Mobilizon.Discussions.{Comment, Discussion}
|
||||
alias Mobilizon.Events.Event
|
||||
alias Mobilizon.Federation.ActivityPub.{Actor, Relay}
|
||||
@@ -184,6 +185,23 @@ defmodule Mobilizon.Web.Cache.ActivityPub do
|
||||
end)
|
||||
end
|
||||
|
||||
@doc """
|
||||
Gets a conversation participant by it's ID, with all associations loaded.
|
||||
"""
|
||||
@spec get_conversation_by_id_with_preload(String.t()) ::
|
||||
{:commit, Todo.t()} | {:ignore, nil}
|
||||
def get_conversation_by_id_with_preload(id) do
|
||||
Cachex.fetch(@cache, "conversation_participant_" <> id, fn "conversation_participant_" <> id ->
|
||||
case Conversations.get_conversation_participant(id) do
|
||||
%Conversation{} = conversation ->
|
||||
{:commit, conversation}
|
||||
|
||||
nil ->
|
||||
{:ignore, nil}
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
@doc """
|
||||
Gets a member by its UUID, with all associations loaded.
|
||||
"""
|
||||
|
||||
5
lib/web/cache/cache.ex
vendored
5
lib/web/cache/cache.ex
vendored
@@ -4,6 +4,7 @@ defmodule Mobilizon.Web.Cache do
|
||||
"""
|
||||
|
||||
alias Mobilizon.Actors.{Actor, Member}
|
||||
alias Mobilizon.Conversations.Conversation
|
||||
alias Mobilizon.Discussions.{Comment, Discussion}
|
||||
alias Mobilizon.Events.Event
|
||||
alias Mobilizon.Posts.Post
|
||||
@@ -27,6 +28,10 @@ defmodule Mobilizon.Web.Cache do
|
||||
defdelegate get_todo_list_by_uuid_with_preload(uuid), to: ActivityPub
|
||||
@spec get_todo_by_uuid_with_preload(binary) :: {:commit, Todo.t()} | {:ignore, nil}
|
||||
defdelegate get_todo_by_uuid_with_preload(uuid), to: ActivityPub
|
||||
|
||||
@spec get_conversation_by_id_with_preload(binary) ::
|
||||
{:commit, Conversation.t()} | {:ignore, nil}
|
||||
defdelegate get_conversation_by_id_with_preload(uuid), to: ActivityPub
|
||||
@spec get_member_by_uuid_with_preload(binary) :: {:commit, Member.t()} | {:ignore, nil}
|
||||
defdelegate get_member_by_uuid_with_preload(uuid), to: ActivityPub
|
||||
@spec get_post_by_slug_with_preload(binary) :: {:commit, Post.t()} | {:ignore, nil}
|
||||
|
||||
Reference in New Issue
Block a user