Auto join own events

Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
marcin mikołajczak 2022-11-30 23:36:40 +01:00
parent e4b568b963
commit 60a51cd047
2 changed files with 14 additions and 1 deletions

View file

@ -19,7 +19,9 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
alias Pleroma.Repo alias Pleroma.Repo
alias Pleroma.Upload alias Pleroma.Upload
alias Pleroma.User alias Pleroma.User
alias Pleroma.Web.ActivityPub.Builder
alias Pleroma.Web.ActivityPub.MRF alias Pleroma.Web.ActivityPub.MRF
alias Pleroma.Web.ActivityPub.Pipeline
alias Pleroma.Web.ActivityPub.Transmogrifier alias Pleroma.Web.ActivityPub.Transmogrifier
alias Pleroma.Web.Streamer alias Pleroma.Web.Streamer
alias Pleroma.Web.WebFinger alias Pleroma.Web.WebFinger
@ -319,6 +321,7 @@ defp do_create(%{to: to, actor: actor, context: context, object: object} = param
_ <- notify_and_stream(activity), _ <- notify_and_stream(activity),
:ok <- maybe_schedule_poll_notifications(activity), :ok <- maybe_schedule_poll_notifications(activity),
:ok <- maybe_schedule_event_notifications(activity), :ok <- maybe_schedule_event_notifications(activity),
:ok <- maybe_join_own_event(actor, activity),
:ok <- maybe_federate(activity) do :ok <- maybe_federate(activity) do
{:ok, activity} {:ok, activity}
else else
@ -343,6 +346,16 @@ defp maybe_schedule_event_notifications(activity) do
:ok :ok
end end
defp maybe_join_own_event(actor, %{object: %{data: %{"type" => "Event"}} = object}) do
{:ok, join_object, meta} = Builder.join(actor, object)
{:ok, _, _} = Pipeline.common_pipeline(join_object, Keyword.put(meta, :local, true))
:ok
end
defp maybe_join_own_event(_, _), do: :ok
@spec listen(map()) :: {:ok, Activity.t()} | {:error, any()} @spec listen(map()) :: {:ok, Activity.t()} | {:error, any()}
def listen(%{to: to, actor: actor, context: context, object: object} = params) do def listen(%{to: to, actor: actor, context: context, object: object} = params) do
additional = params[:additional] || %{} additional = params[:additional] || %{}

View file

@ -337,7 +337,7 @@ def join(%User{} = user, event_id, params \\ %{}) do
end end
end end
def join_helper(user, id, participation_message) do defp join_helper(user, id, participation_message) do
with {_, %Activity{object: object}} <- {:find_object, Activity.get_by_id_with_object(id)}, with {_, %Activity{object: object}} <- {:find_object, Activity.get_by_id_with_object(id)},
{_, {:ok, join_object, meta}} <- {_, {:ok, join_object, meta}} <-
{:build_object, Builder.join(user, object, participation_message)}, {:build_object, Builder.join(user, object, participation_message)},