projects
/
akkoma
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'develop' of git.pleroma.social:pleroma/pleroma into alexgleason/pleroma...
[akkoma]
/
lib
/
pleroma
/
web
/
activity_pub
/
activity_pub.ex
diff --git
a/lib/pleroma/web/activity_pub/activity_pub.ex
b/lib/pleroma/web/activity_pub/activity_pub.ex
index 61c1043ed8163e00512b4db4f6b1cad3a0e4cda1..3e346d49a7a0c5a7bd3d5aebb4298093d4074e1d 100644
(file)
--- a/
lib/pleroma/web/activity_pub/activity_pub.ex
+++ b/
lib/pleroma/web/activity_pub/activity_pub.ex
@@
-32,6
+32,9
@@
defmodule Pleroma.Web.ActivityPub.ActivityPub do
require Logger
require Pleroma.Constants
require Logger
require Pleroma.Constants
+ @behaviour Pleroma.Web.ActivityPub.ActivityPub.Persisting
+ @behaviour Pleroma.Web.ActivityPub.ActivityPub.Streaming
+
defp get_recipients(%{"type" => "Create"} = data) do
to = Map.get(data, "to", [])
cc = Map.get(data, "cc", [])
defp get_recipients(%{"type" => "Create"} = data) do
to = Map.get(data, "to", [])
cc = Map.get(data, "cc", [])
@@
-85,13
+88,14
@@
defmodule Pleroma.Web.ActivityPub.ActivityPub do
defp increase_replies_count_if_reply(_create_data), do: :noop
@object_types ~w[ChatMessage Question Answer Audio Video Event Article]
defp increase_replies_count_if_reply(_create_data), do: :noop
@object_types ~w[ChatMessage Question Answer Audio Video Event Article]
- @
spec persist(map(), keyword()) :: {:ok, Activity.t() | Object.t()}
+ @
impl true
def persist(%{"type" => type} = object, meta) when type in @object_types do
with {:ok, object} <- Object.create(object) do
{:ok, object, meta}
end
end
def persist(%{"type" => type} = object, meta) when type in @object_types do
with {:ok, object} <- Object.create(object) do
{:ok, object, meta}
end
end
+ @impl true
def persist(object, meta) do
with local <- Keyword.fetch!(meta, :local),
{recipients, _, _} <- get_recipients(object),
def persist(object, meta) do
with local <- Keyword.fetch!(meta, :local),
{recipients, _, _} <- get_recipients(object),
@@
-221,6
+225,7
@@
defmodule Pleroma.Web.ActivityPub.ActivityPub do
Streamer.stream("participation", participations)
end
Streamer.stream("participation", participations)
end
+ @impl true
def stream_out_participations(%Object{data: %{"context" => context}}, user) do
with %Conversation{} = conversation <- Conversation.get_for_ap_id(context) do
conversation = Repo.preload(conversation, :participations)
def stream_out_participations(%Object{data: %{"context" => context}}, user) do
with %Conversation{} = conversation <- Conversation.get_for_ap_id(context) do
conversation = Repo.preload(conversation, :participations)
@@
-237,8
+242,10
@@
defmodule Pleroma.Web.ActivityPub.ActivityPub do
end
end
end
end
+ @impl true
def stream_out_participations(_, _), do: :noop
def stream_out_participations(_, _), do: :noop
+ @impl true
def stream_out(%Activity{data: %{"type" => data_type}} = activity)
when data_type in ["Create", "Announce", "Delete"] do
activity
def stream_out(%Activity{data: %{"type" => data_type}} = activity)
when data_type in ["Create", "Announce", "Delete"] do
activity
@@
-246,6
+253,7
@@
defmodule Pleroma.Web.ActivityPub.ActivityPub do
|> Streamer.stream(activity)
end
|> Streamer.stream(activity)
end
+ @impl true
def stream_out(_activity) do
:noop
end
def stream_out(_activity) do
:noop
end
@@
-600,12
+608,18
@@
defmodule Pleroma.Web.ActivityPub.ActivityPub do
|> Map.put(:muting_user, reading_user)
end
|> Map.put(:muting_user, reading_user)
end
+ pagination_type =
+ cond do
+ !Map.has_key?(params, :offset) -> :keyset
+ true -> :offset
+ end
+
%{
godmode: params[:godmode],
reading_user: reading_user
}
|> user_activities_recipients()
%{
godmode: params[:godmode],
reading_user: reading_user
}
|> user_activities_recipients()
- |> fetch_activities(params)
+ |> fetch_activities(params
, pagination_type
)
|> Enum.reverse()
end
|> Enum.reverse()
end
@@
-666,7
+680,7
@@
defmodule Pleroma.Web.ActivityPub.ActivityPub do
defp restrict_tag_reject(query, %{tag_reject: [_ | _] = tag_reject}) do
from(
[_activity, object] in query,
defp restrict_tag_reject(query, %{tag_reject: [_ | _] = tag_reject}) do
from(
[_activity, object] in query,
- where: fragment("not (?)->'
hashtags
' \\?| (?)", object.data, ^tag_reject)
+ where: fragment("not (?)->'
tag
' \\?| (?)", object.data, ^tag_reject)
)
end
)
end
@@
-679,7
+693,7
@@
defmodule Pleroma.Web.ActivityPub.ActivityPub do
defp restrict_tag_all(query, %{tag_all: [_ | _] = tag_all}) do
from(
[_activity, object] in query,
defp restrict_tag_all(query, %{tag_all: [_ | _] = tag_all}) do
from(
[_activity, object] in query,
- where: fragment("(?)->'
hashtags
' \\?& (?)", object.data, ^tag_all)
+ where: fragment("(?)->'
tag
' \\?& (?)", object.data, ^tag_all)
)
end
)
end
@@
-692,14
+706,14
@@
defmodule Pleroma.Web.ActivityPub.ActivityPub do
defp restrict_tag(query, %{tag: tag}) when is_list(tag) do
from(
[_activity, object] in query,
defp restrict_tag(query, %{tag: tag}) when is_list(tag) do
from(
[_activity, object] in query,
- where: fragment("(?)->'
hashtags
' \\?| (?)", object.data, ^tag)
+ where: fragment("(?)->'
tag
' \\?| (?)", object.data, ^tag)
)
end
defp restrict_tag(query, %{tag: tag}) when is_binary(tag) do
from(
[_activity, object] in query,
)
end
defp restrict_tag(query, %{tag: tag}) when is_binary(tag) do
from(
[_activity, object] in query,
- where: fragment("(?)->'
hashtags
' \\? (?)", object.data, ^tag)
+ where: fragment("(?)->'
tag
' \\? (?)", object.data, ^tag)
)
end
)
end