summaryrefslogtreecommitdiff
path: root/lib/pleroma/web/activity_pub
diff options
context:
space:
mode:
Diffstat (limited to 'lib/pleroma/web/activity_pub')
-rw-r--r--lib/pleroma/web/activity_pub/activity_pub.ex2
-rw-r--r--lib/pleroma/web/activity_pub/activity_pub_controller.ex2
-rw-r--r--lib/pleroma/web/activity_pub/mrf/ensure_re_prepended.ex4
-rw-r--r--lib/pleroma/web/activity_pub/transmogrifier.ex82
-rw-r--r--lib/pleroma/web/activity_pub/utils.ex2
5 files changed, 46 insertions, 46 deletions
diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex
index bf81d8039..31455343c 100644
--- a/lib/pleroma/web/activity_pub/activity_pub.ex
+++ b/lib/pleroma/web/activity_pub/activity_pub.ex
@@ -799,7 +799,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
end
# guard
- def entire_thread_visible_for_user?(nil, user), do: false
+ def entire_thread_visible_for_user?(nil, _user), do: false
# child
def entire_thread_visible_for_user?(
diff --git a/lib/pleroma/web/activity_pub/activity_pub_controller.ex b/lib/pleroma/web/activity_pub/activity_pub_controller.ex
index 3570a75cb..0317f3c8c 100644
--- a/lib/pleroma/web/activity_pub/activity_pub_controller.ex
+++ b/lib/pleroma/web/activity_pub/activity_pub_controller.ex
@@ -141,7 +141,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubController do
json(conn, "error")
end
- def relay(conn, params) do
+ def relay(conn, _params) do
with %User{} = user <- Relay.get_actor(),
{:ok, user} <- Pleroma.Web.WebFinger.ensure_keys_present(user) do
conn
diff --git a/lib/pleroma/web/activity_pub/mrf/ensure_re_prepended.ex b/lib/pleroma/web/activity_pub/mrf/ensure_re_prepended.ex
index c8c74ede6..6fa48454a 100644
--- a/lib/pleroma/web/activity_pub/mrf/ensure_re_prepended.ex
+++ b/lib/pleroma/web/activity_pub/mrf/ensure_re_prepended.ex
@@ -5,7 +5,7 @@ defmodule Pleroma.Web.ActivityPub.MRF.EnsureRePrepended do
@reply_prefix Regex.compile!("^re:[[:space:]]*", [:caseless])
def filter_by_summary(
- %{"summary" => parent_summary} = parent,
+ %{"summary" => parent_summary} = _parent,
%{"summary" => child_summary} = child
)
when not is_nil(child_summary) and byte_size(child_summary) > 0 and
@@ -19,7 +19,7 @@ defmodule Pleroma.Web.ActivityPub.MRF.EnsureRePrepended do
end
end
- def filter_by_summary(parent, child), do: child
+ def filter_by_summary(_parent, child), do: child
def filter(%{"type" => activity_type} = object) when activity_type == "Create" do
child = object["object"]
diff --git a/lib/pleroma/web/activity_pub/transmogrifier.ex b/lib/pleroma/web/activity_pub/transmogrifier.ex
index 17b063609..e6af4b211 100644
--- a/lib/pleroma/web/activity_pub/transmogrifier.ex
+++ b/lib/pleroma/web/activity_pub/transmogrifier.ex
@@ -37,9 +37,9 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
@doc """
Checks that an imported AP object's actor matches the domain it came from.
"""
- def contain_origin(id, %{"actor" => nil}), do: :error
+ def contain_origin(_id, %{"actor" => nil}), do: :error
- def contain_origin(id, %{"actor" => actor} = params) do
+ def contain_origin(id, %{"actor" => _actor} = params) do
id_uri = URI.parse(id)
actor_uri = URI.parse(get_actor(params))
@@ -50,9 +50,9 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
end
end
- def contain_origin_from_id(id, %{"id" => nil}), do: :error
+ def contain_origin_from_id(_id, %{"id" => nil}), do: :error
- def contain_origin_from_id(id, %{"id" => other_id} = params) do
+ def contain_origin_from_id(id, %{"id" => other_id} = _params) do
id_uri = URI.parse(id)
other_uri = URI.parse(other_id)
@@ -266,6 +266,32 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
def fix_content_map(object), do: object
+ defp mastodon_follow_hack(%{"id" => id, "actor" => follower_id}, followed) do
+ with true <- id =~ "follows",
+ %User{local: true} = follower <- User.get_cached_by_ap_id(follower_id),
+ %Activity{} = activity <- Utils.fetch_latest_follow(follower, followed) do
+ {:ok, activity}
+ else
+ _ -> {:error, nil}
+ end
+ end
+
+ defp mastodon_follow_hack(_, _), do: {:error, nil}
+
+ defp get_follow_activity(follow_object, followed) do
+ with object_id when not is_nil(object_id) <- Utils.get_ap_id(follow_object),
+ {_, %Activity{} = activity} <- {:activity, Activity.get_by_ap_id(object_id)} do
+ {:ok, activity}
+ else
+ # Can't find the activity. This might a Mastodon 2.3 "Accept"
+ {:activity, nil} ->
+ mastodon_follow_hack(follow_object, followed)
+
+ _ ->
+ {:error, nil}
+ end
+ end
+
# disallow objects with bogus IDs
def handle_incoming(%{"id" => nil}), do: :error
def handle_incoming(%{"id" => ""}), do: :error
@@ -331,34 +357,8 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
end
end
- defp mastodon_follow_hack(%{"id" => id, "actor" => follower_id}, followed) do
- with true <- id =~ "follows",
- %User{local: true} = follower <- User.get_cached_by_ap_id(follower_id),
- %Activity{} = activity <- Utils.fetch_latest_follow(follower, followed) do
- {:ok, activity}
- else
- _ -> {:error, nil}
- end
- end
-
- defp mastodon_follow_hack(_), do: {:error, nil}
-
- defp get_follow_activity(follow_object, followed) do
- with object_id when not is_nil(object_id) <- Utils.get_ap_id(follow_object),
- {_, %Activity{} = activity} <- {:activity, Activity.get_by_ap_id(object_id)} do
- {:ok, activity}
- else
- # Can't find the activity. This might a Mastodon 2.3 "Accept"
- {:activity, nil} ->
- mastodon_follow_hack(follow_object, followed)
-
- _ ->
- {:error, nil}
- end
- end
-
def handle_incoming(
- %{"type" => "Accept", "object" => follow_object, "actor" => actor, "id" => id} = data
+ %{"type" => "Accept", "object" => follow_object, "actor" => _actor, "id" => _id} = data
) do
with actor <- get_actor(data),
%User{} = followed <- User.get_or_fetch_by_ap_id(actor),
@@ -374,7 +374,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
local: false
}) do
if not User.following?(follower, followed) do
- {:ok, follower} = User.follow(follower, followed)
+ {:ok, _follower} = User.follow(follower, followed)
end
{:ok, activity}
@@ -384,7 +384,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
end
def handle_incoming(
- %{"type" => "Reject", "object" => follow_object, "actor" => actor, "id" => id} = data
+ %{"type" => "Reject", "object" => follow_object, "actor" => _actor, "id" => _id} = data
) do
with actor <- get_actor(data),
%User{} = followed <- User.get_or_fetch_by_ap_id(actor),
@@ -408,7 +408,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
end
def handle_incoming(
- %{"type" => "Like", "object" => object_id, "actor" => actor, "id" => id} = data
+ %{"type" => "Like", "object" => object_id, "actor" => _actor, "id" => id} = data
) do
with actor <- get_actor(data),
%User{} = actor <- User.get_or_fetch_by_ap_id(actor),
@@ -421,7 +421,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
end
def handle_incoming(
- %{"type" => "Announce", "object" => object_id, "actor" => actor, "id" => id} = data
+ %{"type" => "Announce", "object" => object_id, "actor" => _actor, "id" => id} = data
) do
with actor <- get_actor(data),
%User{} = actor <- User.get_or_fetch_by_ap_id(actor),
@@ -492,7 +492,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
%{
"type" => "Undo",
"object" => %{"type" => "Announce", "object" => object_id},
- "actor" => actor,
+ "actor" => _actor,
"id" => id
} = data
) do
@@ -520,7 +520,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
User.unfollow(follower, followed)
{:ok, activity}
else
- e -> :error
+ _e -> :error
end
end
@@ -539,12 +539,12 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
User.unblock(blocker, blocked)
{:ok, activity}
else
- e -> :error
+ _e -> :error
end
end
def handle_incoming(
- %{"type" => "Block", "object" => blocked, "actor" => blocker, "id" => id} = data
+ %{"type" => "Block", "object" => blocked, "actor" => blocker, "id" => id} = _data
) do
with true <- Pleroma.Config.get([:activitypub, :accept_blocks]),
%User{local: true} = blocked = User.get_cached_by_ap_id(blocked),
@@ -554,7 +554,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
User.block(blocker, blocked)
{:ok, activity}
else
- e -> :error
+ _e -> :error
end
end
@@ -562,7 +562,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
%{
"type" => "Undo",
"object" => %{"type" => "Like", "object" => object_id},
- "actor" => actor,
+ "actor" => _actor,
"id" => id
} = data
) do
diff --git a/lib/pleroma/web/activity_pub/utils.ex b/lib/pleroma/web/activity_pub/utils.ex
index 549148989..074622f2b 100644
--- a/lib/pleroma/web/activity_pub/utils.ex
+++ b/lib/pleroma/web/activity_pub/utils.ex
@@ -292,7 +292,7 @@ defmodule Pleroma.Web.ActivityPub.Utils do
"""
def make_follow_data(
%User{ap_id: follower_id},
- %User{ap_id: followed_id} = followed,
+ %User{ap_id: followed_id} = _followed,
activity_id
) do
data = %{