Introduce group basic federation, event new page and notifications
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
62
lib/web/cache/activity_pub.ex
vendored
62
lib/web/cache/activity_pub.ex
vendored
@@ -3,12 +3,13 @@ defmodule Mobilizon.Web.Cache.ActivityPub do
|
||||
ActivityPub related cache.
|
||||
"""
|
||||
|
||||
alias Mobilizon.{Actors, Events, Tombstone}
|
||||
alias Mobilizon.{Actors, Conversations, Events, Resources, Todos, Tombstone}
|
||||
alias Mobilizon.Actors.Actor
|
||||
alias Mobilizon.Events.{Comment, Event}
|
||||
|
||||
alias Mobilizon.Conversations.Comment
|
||||
alias Mobilizon.Events.Event
|
||||
alias Mobilizon.Federation.ActivityPub.Relay
|
||||
|
||||
alias Mobilizon.Resources.Resource
|
||||
alias Mobilizon.Todos.{Todo, TodoList}
|
||||
alias Mobilizon.Web.Endpoint
|
||||
alias Mobilizon.Web.Router.Helpers, as: Routes
|
||||
|
||||
@@ -60,7 +61,7 @@ defmodule Mobilizon.Web.Cache.ActivityPub do
|
||||
{:commit, Comment.t()} | {:ignore, nil}
|
||||
def get_comment_by_uuid_with_preload(uuid) do
|
||||
Cachex.fetch(@cache, "comment_" <> uuid, fn "comment_" <> uuid ->
|
||||
case Events.get_comment_from_uuid_with_preload(uuid) do
|
||||
case Conversations.get_comment_from_uuid_with_preload(uuid) do
|
||||
%Comment{} = comment ->
|
||||
{:commit, comment}
|
||||
|
||||
@@ -70,6 +71,57 @@ defmodule Mobilizon.Web.Cache.ActivityPub do
|
||||
end)
|
||||
end
|
||||
|
||||
@doc """
|
||||
Gets a resource by its UUID, with all associations loaded.
|
||||
"""
|
||||
@spec get_resource_by_uuid_with_preload(String.t()) ::
|
||||
{:commit, Resource.t()} | {:ignore, nil}
|
||||
def get_resource_by_uuid_with_preload(uuid) do
|
||||
Cachex.fetch(@cache, "resource_" <> uuid, fn "resource_" <> uuid ->
|
||||
case Resources.get_resource_with_preloads(uuid) do
|
||||
%Resource{} = resource ->
|
||||
{:commit, resource}
|
||||
|
||||
nil ->
|
||||
{:ignore, nil}
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
@doc """
|
||||
Gets a todo list by its UUID, with all associations loaded.
|
||||
"""
|
||||
@spec get_todo_list_by_uuid_with_preload(String.t()) ::
|
||||
{:commit, TodoList.t()} | {:ignore, nil}
|
||||
def get_todo_list_by_uuid_with_preload(uuid) do
|
||||
Cachex.fetch(@cache, "todo_list_" <> uuid, fn "todo_list_" <> uuid ->
|
||||
case Todos.get_todo_list(uuid) do
|
||||
%TodoList{} = todo_list ->
|
||||
{:commit, todo_list}
|
||||
|
||||
nil ->
|
||||
{:ignore, nil}
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
@doc """
|
||||
Gets a todo by its UUID, with all associations loaded.
|
||||
"""
|
||||
@spec get_todo_by_uuid_with_preload(String.t()) ::
|
||||
{:commit, Todo.t()} | {:ignore, nil}
|
||||
def get_todo_by_uuid_with_preload(uuid) do
|
||||
Cachex.fetch(@cache, "todo_" <> uuid, fn "todo_" <> uuid ->
|
||||
case Todos.get_todo(uuid) do
|
||||
%Todo{} = todo ->
|
||||
{:commit, todo}
|
||||
|
||||
nil ->
|
||||
{:ignore, nil}
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
@doc """
|
||||
Gets a relay.
|
||||
"""
|
||||
|
||||
3
lib/web/cache/cache.ex
vendored
3
lib/web/cache/cache.ex
vendored
@@ -20,5 +20,8 @@ defmodule Mobilizon.Web.Cache do
|
||||
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
|
||||
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_relay, to: ActivityPub
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user