commit: adb93f7e5d9b86a02f5114f0597b8274e4ada88d
parent f79a16c062a14634d8b5f90e08df0b22b799bb45
Author: Mark Felder <feld@feld.me>
Date: Mon, 22 Jul 2024 19:11:22 -0400
Fix order of args for unfollow/2
Diffstat:
5 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/lib/pleroma/following_relationship.ex b/lib/pleroma/following_relationship.ex
@@ -200,7 +200,7 @@ defmodule Pleroma.FollowingRelationship do
|> Repo.all()
|> Enum.map(fn following_relationship ->
Pleroma.Web.CommonAPI.follow(target, following_relationship.follower)
- Pleroma.Web.CommonAPI.unfollow(following_relationship.follower, origin)
+ Pleroma.Web.CommonAPI.unfollow(origin, following_relationship.follower)
end)
|> case do
[] ->
diff --git a/lib/pleroma/web/common_api.ex b/lib/pleroma/web/common_api.ex
@@ -136,7 +136,7 @@ defmodule Pleroma.Web.CommonAPI do
end
@spec unfollow(User.t(), User.t()) :: {:ok, User.t()} | {:error, any()}
- def unfollow(follower, unfollowed) do
+ def unfollow(unfollowed, follower) do
with {:ok, follower, _follow_activity} <- User.unfollow(follower, unfollowed),
{:ok, _activity} <- ActivityPub.unfollow(follower, unfollowed),
{:ok, _subscription} <- User.unsubscribe(follower, unfollowed),
diff --git a/lib/pleroma/web/mastodon_api/controllers/account_controller.ex b/lib/pleroma/web/mastodon_api/controllers/account_controller.ex
@@ -460,7 +460,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountController do
end
def unfollow(%{assigns: %{user: follower, account: followed}} = conn, _params) do
- with {:ok, follower} <- CommonAPI.unfollow(follower, followed) do
+ with {:ok, follower} <- CommonAPI.unfollow(followed, follower) do
render(conn, "relationship.json", user: follower, target: followed)
end
end
diff --git a/test/pleroma/notification_test.exs b/test/pleroma/notification_test.exs
@@ -353,7 +353,7 @@ defmodule Pleroma.NotificationTest do
assert FollowingRelationship.following?(user, followed_user)
assert [notification] = Notification.for_user(followed_user)
- CommonAPI.unfollow(user, followed_user)
+ CommonAPI.unfollow(followed_user, user)
{:ok, _, _, _activity_dupe} = CommonAPI.follow(followed_user, user)
notification_id = notification.id
diff --git a/test/pleroma/web/common_api_test.exs b/test/pleroma/web/common_api_test.exs
@@ -1434,7 +1434,7 @@ defmodule Pleroma.Web.CommonAPITest do
assert User.subscribed_to?(follower, followed)
- {:ok, follower} = CommonAPI.unfollow(follower, followed)
+ {:ok, follower} = CommonAPI.unfollow(followed, follower)
refute User.subscribed_to?(follower, followed)
end
@@ -1446,7 +1446,7 @@ defmodule Pleroma.Web.CommonAPITest do
assert User.endorses?(follower, followed)
- {:ok, follower} = CommonAPI.unfollow(follower, followed)
+ {:ok, follower} = CommonAPI.unfollow(followed, follower)
refute User.endorses?(follower, followed)
end
@@ -1459,7 +1459,7 @@ defmodule Pleroma.Web.CommonAPITest do
CommonAPI.follow(followed, follower)
assert User.get_follow_state(follower, followed) == :follow_pending
- assert {:ok, follower} = CommonAPI.unfollow(follower, followed)
+ assert {:ok, follower} = CommonAPI.unfollow(followed, follower)
assert User.get_follow_state(follower, followed) == nil
assert %{id: ^activity_id, data: %{"state" => "cancelled"}} =
@@ -1481,7 +1481,7 @@ defmodule Pleroma.Web.CommonAPITest do
CommonAPI.follow(followed, follower)
assert User.get_follow_state(follower, followed) == :follow_pending
- assert {:ok, follower} = CommonAPI.unfollow(follower, followed)
+ assert {:ok, follower} = CommonAPI.unfollow(followed, follower)
assert User.get_follow_state(follower, followed) == nil
assert %{id: ^activity_id, data: %{"state" => "cancelled"}} =