diff --git a/changelog.d/commonapi-reordering.skip b/changelog.d/commonapi-reordering.skip new file mode 100644 index 000000000..e69de29bb diff --git a/lib/pleroma/conversation/participation.ex b/lib/pleroma/conversation/participation.ex index 4ed93e5bd..5d3344cc5 100644 --- a/lib/pleroma/conversation/participation.ex +++ b/lib/pleroma/conversation/participation.ex @@ -12,6 +12,8 @@ defmodule Pleroma.Conversation.Participation do import Ecto.Changeset import Ecto.Query + @type t :: %__MODULE__{} + schema "conversation_participations" do belongs_to(:user, User, type: FlakeId.Ecto.CompatType) belongs_to(:conversation, Conversation) diff --git a/lib/pleroma/following_relationship.ex b/lib/pleroma/following_relationship.ex index f38c2fce9..495488dfd 100644 --- a/lib/pleroma/following_relationship.ex +++ b/lib/pleroma/following_relationship.ex @@ -199,8 +199,8 @@ defmodule Pleroma.FollowingRelationship do |> preload([:follower]) |> Repo.all() |> Enum.map(fn following_relationship -> - Pleroma.Web.CommonAPI.follow(following_relationship.follower, target) - Pleroma.Web.CommonAPI.unfollow(following_relationship.follower, origin) + Pleroma.Web.CommonAPI.follow(target, following_relationship.follower) + Pleroma.Web.CommonAPI.unfollow(origin, following_relationship.follower) end) |> case do [] -> diff --git a/lib/pleroma/notification.ex b/lib/pleroma/notification.ex index de2508b93..75f4ba503 100644 --- a/lib/pleroma/notification.ex +++ b/lib/pleroma/notification.ex @@ -734,7 +734,7 @@ defmodule Pleroma.Notification do def mark_as_read?(activity, target_user) do user = Activity.user_actor(activity) - User.mutes_user?(target_user, user) || CommonAPI.thread_muted?(target_user, activity) + User.mutes_user?(target_user, user) || CommonAPI.thread_muted?(activity, target_user) end def for_user_and_activity(user, activity) do diff --git a/lib/pleroma/user/import.ex b/lib/pleroma/user/import.ex index 4baa7e3a4..53ffd1ab3 100644 --- a/lib/pleroma/user/import.ex +++ b/lib/pleroma/user/import.ex @@ -31,7 +31,7 @@ defmodule Pleroma.User.Import do identifiers, fn identifier -> with {:ok, %User{} = blocked} <- User.get_or_fetch(identifier), - {:ok, _block} <- CommonAPI.block(blocker, blocked) do + {:ok, _block} <- CommonAPI.block(blocked, blocker) do blocked else error -> handle_error(:blocks_import, identifier, error) @@ -46,7 +46,7 @@ defmodule Pleroma.User.Import do fn identifier -> with {:ok, %User{} = followed} <- User.get_or_fetch(identifier), {:ok, follower, followed} <- User.maybe_direct_follow(follower, followed), - {:ok, _, _, _} <- CommonAPI.follow(follower, followed) do + {:ok, _, _, _} <- CommonAPI.follow(followed, follower) do followed else error -> handle_error(:follow_import, identifier, error) diff --git a/lib/pleroma/web/activity_pub/mrf/follow_bot_policy.ex b/lib/pleroma/web/activity_pub/mrf/follow_bot_policy.ex index 5a4a97626..55ea2683c 100644 --- a/lib/pleroma/web/activity_pub/mrf/follow_bot_policy.ex +++ b/lib/pleroma/web/activity_pub/mrf/follow_bot_policy.ex @@ -49,7 +49,7 @@ defmodule Pleroma.Web.ActivityPub.MRF.FollowBotPolicy do "#{__MODULE__}: Follow request from #{follower.nickname} to #{user.nickname}" ) - CommonAPI.follow(follower, user) + CommonAPI.follow(user, follower) end end) diff --git a/lib/pleroma/web/activity_pub/relay.ex b/lib/pleroma/web/activity_pub/relay.ex index 91a647f29..cff234940 100644 --- a/lib/pleroma/web/activity_pub/relay.ex +++ b/lib/pleroma/web/activity_pub/relay.ex @@ -22,7 +22,7 @@ defmodule Pleroma.Web.ActivityPub.Relay do def follow(target_instance) do with %User{} = local_user <- get_actor(), {:ok, %User{} = target_user} <- User.get_or_fetch_by_ap_id(target_instance), - {:ok, _, _, activity} <- CommonAPI.follow(local_user, target_user) do + {:ok, _, _, activity} <- CommonAPI.follow(target_user, local_user) do Logger.info("relay: followed instance: #{target_instance}; id=#{activity.data["id"]}") {:ok, activity} else diff --git a/lib/pleroma/web/common_api.ex b/lib/pleroma/web/common_api.ex index 36e7efd8d..06faf845e 100644 --- a/lib/pleroma/web/common_api.ex +++ b/lib/pleroma/web/common_api.ex @@ -26,13 +26,16 @@ defmodule Pleroma.Web.CommonAPI do require Pleroma.Constants require Logger - def block(blocker, blocked) do + @spec block(User.t(), User.t()) :: {:ok, Activity.t()} | {:error, any()} + def block(blocked, blocker) do with {:ok, block_data, _} <- Builder.block(blocker, blocked), {:ok, block, _} <- Pipeline.common_pipeline(block_data, local: true) do {:ok, block} end end + @spec post_chat_message(User.t(), User.t(), String.t(), list()) :: + {:ok, Activity.t()} | {:error, any()} def post_chat_message(%User{} = user, %User{} = recipient, content, opts \\ []) do with maybe_attachment <- opts[:media_id] && Object.get_by_id(opts[:media_id]), :ok <- validate_chat_attachment_attribution(maybe_attachment, user), @@ -96,7 +99,8 @@ defmodule Pleroma.Web.CommonAPI do end end - def unblock(blocker, blocked) do + @spec unblock(User.t(), User.t()) :: {:ok, Activity.t()} | {:error, any()} + def unblock(blocked, blocker) do with {_, %Activity{} = block} <- {:fetch_block, Utils.fetch_latest_block(blocker, blocked)}, {:ok, unblock_data, _} <- Builder.undo(blocker, block), {:ok, unblock, _} <- Pipeline.common_pipeline(unblock_data, local: true) do @@ -115,7 +119,9 @@ defmodule Pleroma.Web.CommonAPI do end end - def follow(follower, followed) do + @spec follow(User.t(), User.t()) :: + {:ok, User.t(), User.t(), Activity.t() | Object.t()} | {:error, :rejected} + def follow(followed, follower) do timeout = Pleroma.Config.get([:activitypub, :follow_handshake_timeout]) with {:ok, follow_data, _} <- Builder.follow(follower, followed), @@ -129,7 +135,8 @@ defmodule Pleroma.Web.CommonAPI do end end - def unfollow(follower, unfollowed) do + @spec unfollow(User.t(), User.t()) :: {:ok, User.t()} | {:error, any()} + 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), @@ -138,6 +145,7 @@ defmodule Pleroma.Web.CommonAPI do end end + @spec accept_follow_request(User.t(), User.t()) :: {:ok, User.t()} | {:error, any()} def accept_follow_request(follower, followed) do with %Activity{} = follow_activity <- Utils.fetch_latest_follow(follower, followed), {:ok, accept_data, _} <- Builder.accept(followed, follow_activity), @@ -146,6 +154,7 @@ defmodule Pleroma.Web.CommonAPI do end end + @spec reject_follow_request(User.t(), User.t()) :: {:ok, User.t()} | {:error, any()} | nil def reject_follow_request(follower, followed) do with %Activity{} = follow_activity <- Utils.fetch_latest_follow(follower, followed), {:ok, reject_data, _} <- Builder.reject(followed, follow_activity), @@ -154,6 +163,7 @@ defmodule Pleroma.Web.CommonAPI do end end + @spec delete(String.t(), User.t()) :: {:ok, Activity.t()} | {:error, any()} def delete(activity_id, user) do with {_, %Activity{data: %{"object" => _, "type" => "Create"}} = activity} <- {:find_activity, Activity.get_by_id(activity_id, filter: [])}, @@ -203,6 +213,7 @@ defmodule Pleroma.Web.CommonAPI do end end + @spec repeat(String.t(), User.t(), map()) :: {:ok, Activity.t()} | {:error, any()} def repeat(id, user, params \\ %{}) do with %Activity{data: %{"type" => "Create"}} = activity <- Activity.get_by_id(id), object = %Object{} <- Object.normalize(activity, fetch: false), @@ -220,6 +231,7 @@ defmodule Pleroma.Web.CommonAPI do end end + @spec unrepeat(String.t(), User.t()) :: {:ok, Activity.t()} | {:error, any()} def unrepeat(id, user) do with {_, %Activity{data: %{"type" => "Create"}} = activity} <- {:find_activity, Activity.get_by_id(id)}, @@ -235,8 +247,8 @@ defmodule Pleroma.Web.CommonAPI do end end - @spec favorite(User.t(), binary()) :: {:ok, Activity.t() | :already_liked} | {:error, any()} - def favorite(%User{} = user, id) do + @spec favorite(String.t(), User.t()) :: {:ok, Activity.t()} | {:error, any()} + def favorite(id, %User{} = user) do case favorite_helper(user, id) do {:ok, _} = res -> res @@ -250,7 +262,7 @@ defmodule Pleroma.Web.CommonAPI do end end - def favorite_helper(user, id) do + defp favorite_helper(user, id) do with {_, %Activity{object: object}} <- {:find_object, Activity.get_by_id_with_object(id)}, {_, {:ok, like_object, meta}} <- {:build_object, Builder.like(user, object)}, {_, {:ok, %Activity{} = activity, _meta}} <- @@ -273,6 +285,7 @@ defmodule Pleroma.Web.CommonAPI do end end + @spec unfavorite(String.t(), User.t()) :: {:ok, Activity.t()} | {:error, any()} def unfavorite(id, user) do with {_, %Activity{data: %{"type" => "Create"}} = activity} <- {:find_activity, Activity.get_by_id(id)}, @@ -288,6 +301,8 @@ defmodule Pleroma.Web.CommonAPI do end end + @spec react_with_emoji(String.t(), User.t(), String.t()) :: + {:ok, Activity.t()} | {:error, any()} def react_with_emoji(id, user, emoji) do with %Activity{} = activity <- Activity.get_by_id(id), object <- Object.normalize(activity, fetch: false), @@ -300,6 +315,8 @@ defmodule Pleroma.Web.CommonAPI do end end + @spec unreact_with_emoji(String.t(), User.t(), String.t()) :: + {:ok, Activity.t()} | {:error, any()} def unreact_with_emoji(id, user, emoji) do with %Activity{} = reaction_activity <- Utils.get_latest_reaction(id, user, emoji), {_, {:ok, _}} <- {:cancel_jobs, maybe_cancel_jobs(reaction_activity)}, @@ -312,7 +329,8 @@ defmodule Pleroma.Web.CommonAPI do end end - def vote(user, %{data: %{"type" => "Question"}} = object, choices) do + @spec vote(Object.t(), User.t(), list()) :: {:ok, list(), Object.t()} | {:error, any()} + def vote(%Object{data: %{"type" => "Question"}} = object, %User{} = user, choices) do with :ok <- validate_not_author(object, user), :ok <- validate_existing_votes(user, object), {:ok, options, choices} <- normalize_and_validate_choices(choices, object) do @@ -373,14 +391,16 @@ defmodule Pleroma.Web.CommonAPI do end end - def public_announce?(_, %{visibility: visibility}) - when visibility in ~w{public unlisted private direct}, - do: visibility in ~w(public unlisted) + defp public_announce?(_, %{visibility: visibility}) + when visibility in ~w{public unlisted private direct}, + do: visibility in ~w(public unlisted) - def public_announce?(object, _) do + defp public_announce?(object, _) do Visibility.public?(object) end + @spec get_visibility(map(), map() | nil, Participation.t() | nil) :: + {String.t() | nil, String.t() | nil} def get_visibility(_, _, %Participation{}), do: {"direct", "direct"} def get_visibility(%{visibility: visibility}, in_reply_to, _) @@ -399,6 +419,7 @@ defmodule Pleroma.Web.CommonAPI do def get_visibility(_, in_reply_to, _), do: {"public", get_replied_to_visibility(in_reply_to)} + @spec get_replied_to_visibility(Activity.t() | nil) :: String.t() | nil def get_replied_to_visibility(nil), do: nil def get_replied_to_visibility(activity) do @@ -407,6 +428,8 @@ defmodule Pleroma.Web.CommonAPI do end end + @spec check_expiry_date({:ok, nil | integer()} | String.t()) :: + {:ok, boolean() | nil} | {:error, String.t()} def check_expiry_date({:ok, nil} = res), do: res def check_expiry_date({:ok, in_seconds}) do @@ -424,19 +447,22 @@ defmodule Pleroma.Web.CommonAPI do |> check_expiry_date() end + @spec listen(User.t(), map()) :: {:ok, Activity.t()} | {:error, any()} def listen(user, data) do with {:ok, draft} <- ActivityDraft.listen(user, data) do ActivityPub.listen(draft.changes) end end + @spec post(User.t(), map()) :: {:ok, Activity.t()} | {:error, any()} def post(user, %{status: _} = data) do with {:ok, draft} <- ActivityDraft.create(user, data) do ActivityPub.create(draft.changes, draft.preview?) end end - def update(user, orig_activity, changes) do + @spec update(Activity.t(), User.t(), map()) :: {:ok, Activity.t()} | {:error, any()} + def update(orig_activity, %User{} = user, changes) do with orig_object <- Object.normalize(orig_activity), {:ok, new_object} <- make_update_data(user, orig_object, changes), {:ok, update_data, _} <- Builder.update(user, new_object), @@ -526,7 +552,8 @@ defmodule Pleroma.Web.CommonAPI do end end - def add_mute(user, activity, params \\ %{}) do + @spec add_mute(Activity.t(), User.t(), map()) :: {:ok, Activity.t()} | {:error, any()} + def add_mute(activity, user, params \\ %{}) do expires_in = Map.get(params, :expires_in, 0) with {:ok, _} <- ThreadMute.add_mute(user.id, activity.data["context"]), @@ -545,15 +572,17 @@ defmodule Pleroma.Web.CommonAPI do end end - def remove_mute(%User{} = user, %Activity{} = activity) do + @spec remove_mute(Activity.t(), User.t()) :: {:ok, Activity.t()} | {:error, any()} + def remove_mute(%Activity{} = activity, %User{} = user) do ThreadMute.remove_mute(user.id, activity.data["context"]) {:ok, activity} end - def remove_mute(user_id, activity_id) do + @spec remove_mute(String.t(), String.t()) :: {:ok, Activity.t()} | {:error, any()} + def remove_mute(activity_id, user_id) do with {:user, %User{} = user} <- {:user, User.get_by_id(user_id)}, {:activity, %Activity{} = activity} <- {:activity, Activity.get_by_id(activity_id)} do - remove_mute(user, activity) + remove_mute(activity, user) else {what, result} = error -> Logger.warning( @@ -564,13 +593,15 @@ defmodule Pleroma.Web.CommonAPI do end end - def thread_muted?(%User{id: user_id}, %{data: %{"context" => context}}) + @spec thread_muted?(Activity.t(), User.t()) :: boolean() + def thread_muted?(%{data: %{"context" => context}}, %User{id: user_id}) when is_binary(context) do ThreadMute.exists?(user_id, context) end def thread_muted?(_, _), do: false + @spec report(User.t(), map()) :: {:ok, Activity.t()} | {:error, any()} def report(user, data) do with {:ok, account} <- get_reported_account(data.account_id), {:ok, {content_html, _, _}} <- make_report_content_html(data[:comment]), @@ -604,6 +635,8 @@ defmodule Pleroma.Web.CommonAPI do |> Enum.filter(&Rule.exists?/1) end + @spec update_report_state(String.t() | [String.t()], String.t()) :: + {:ok, any()} | {:error, any()} def update_report_state(activity_ids, state) when is_list(activity_ids) do case Utils.update_report_state(activity_ids, state) do :ok -> {:ok, activity_ids} @@ -619,6 +652,7 @@ defmodule Pleroma.Web.CommonAPI do end end + @spec update_activity_scope(String.t(), map()) :: {:ok, any()} | {:error, any()} def update_activity_scope(activity_id, opts \\ %{}) do with %Activity{} = activity <- Activity.get_by_id_with_object(activity_id), {:ok, activity} <- toggle_sensitive(activity, opts) do @@ -652,14 +686,17 @@ defmodule Pleroma.Web.CommonAPI do defp set_visibility(activity, _), do: {:ok, activity} - def hide_reblogs(%User{} = user, %User{} = target) do + @spec hide_reblogs(User.t(), User.t()) :: {:ok, any()} | {:error, any()} + def hide_reblogs(%User{} = target, %User{} = user) do UserRelationship.create_reblog_mute(user, target) end - def show_reblogs(%User{} = user, %User{} = target) do + @spec show_reblogs(User.t(), User.t()) :: {:ok, any()} | {:error, any()} + def show_reblogs(%User{} = target, %User{} = user) do UserRelationship.delete_reblog_mute(user, target) end + @spec get_user(String.t(), boolean()) :: User.t() | nil def get_user(ap_id, fake_record_fallback \\ true) do cond do user = User.get_cached_by_ap_id(ap_id) -> diff --git a/lib/pleroma/web/mastodon_api/controllers/account_controller.ex b/lib/pleroma/web/mastodon_api/controllers/account_controller.ex index 47e6f0a64..80ab95a57 100644 --- 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 @@ -495,7 +495,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountController do @doc "POST /api/v1/accounts/:id/block" def block(%{assigns: %{user: blocker, account: blocked}} = conn, _params) do - with {:ok, _activity} <- CommonAPI.block(blocker, blocked) do + with {:ok, _activity} <- CommonAPI.block(blocked, blocker) do render(conn, "relationship.json", user: blocker, target: blocked) else {:error, message} -> json_response(conn, :forbidden, %{error: message}) @@ -504,7 +504,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountController do @doc "POST /api/v1/accounts/:id/unblock" def unblock(%{assigns: %{user: blocker, account: blocked}} = conn, _params) do - with {:ok, _activity} <- CommonAPI.unblock(blocker, blocked) do + with {:ok, _activity} <- CommonAPI.unblock(blocked, blocker) do render(conn, "relationship.json", user: blocker, target: blocked) else {:error, message} -> json_response(conn, :forbidden, %{error: message}) diff --git a/lib/pleroma/web/mastodon_api/controllers/poll_controller.ex b/lib/pleroma/web/mastodon_api/controllers/poll_controller.ex index b074ee405..a2af8148c 100644 --- a/lib/pleroma/web/mastodon_api/controllers/poll_controller.ex +++ b/lib/pleroma/web/mastodon_api/controllers/poll_controller.ex @@ -51,7 +51,7 @@ defmodule Pleroma.Web.MastodonAPI.PollController do with %Object{data: %{"type" => "Question"}} = object <- Object.get_by_id(id), %Activity{} = activity <- Activity.get_create_by_object_ap_id(object.data["id"]), true <- Visibility.visible_for_user?(activity, user), - {:ok, _activities, object} <- get_cached_vote_or_vote(user, object, choices) do + {:ok, _activities, object} <- get_cached_vote_or_vote(object, user, choices) do try_render(conn, "show.json", %{object: object, for: user}) else nil -> render_error(conn, :not_found, "Record not found") @@ -60,11 +60,11 @@ defmodule Pleroma.Web.MastodonAPI.PollController do end end - defp get_cached_vote_or_vote(user, object, choices) do + defp get_cached_vote_or_vote(object, user, choices) do idempotency_key = "polls:#{user.id}:#{object.data["id"]}" @cachex.fetch!(:idempotency_cache, idempotency_key, fn _ -> - case CommonAPI.vote(user, object, choices) do + case CommonAPI.vote(object, user, choices) do {:error, _message} = res -> {:ignore, res} res -> {:commit, res} end diff --git a/lib/pleroma/web/mastodon_api/controllers/status_controller.ex b/lib/pleroma/web/mastodon_api/controllers/status_controller.ex index 83e1bee54..b9b236920 100644 --- a/lib/pleroma/web/mastodon_api/controllers/status_controller.ex +++ b/lib/pleroma/web/mastodon_api/controllers/status_controller.ex @@ -276,7 +276,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusController do actor <- Activity.user_actor(activity), {_, true} <- {:own_status, actor.id == user.id}, changes <- body_params |> put_application(conn), - {_, {:ok, _update_activity}} <- {:pipeline, CommonAPI.update(user, activity, changes)}, + {_, {:ok, _update_activity}} <- {:pipeline, CommonAPI.update(activity, user, changes)}, {_, %Activity{}} = {_, activity} <- {:refetched, Activity.get_by_id_with_object(id)} do try_render(conn, "show.json", activity: activity, @@ -357,7 +357,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusController do conn, _ ) do - with {:ok, _fav} <- CommonAPI.favorite(user, activity_id), + with {:ok, _fav} <- CommonAPI.favorite(activity_id, user), %Activity{} = activity <- Activity.get_by_id(activity_id) do try_render(conn, "show.json", activity: activity, for: user, as: :activity) end @@ -453,7 +453,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusController do _ ) do with %Activity{} = activity <- Activity.get_by_id(id), - {:ok, activity} <- CommonAPI.add_mute(user, activity, params) do + {:ok, activity} <- CommonAPI.add_mute(activity, user, params) do try_render(conn, "show.json", activity: activity, for: user, as: :activity) end end @@ -467,7 +467,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusController do _ ) do with %Activity{} = activity <- Activity.get_by_id(id), - {:ok, activity} <- CommonAPI.remove_mute(user, activity) do + {:ok, activity} <- CommonAPI.remove_mute(activity, user) do try_render(conn, "show.json", activity: activity, for: user, as: :activity) end end diff --git a/lib/pleroma/web/mastodon_api/mastodon_api.ex b/lib/pleroma/web/mastodon_api/mastodon_api.ex index 467dc2fac..6dcbfb097 100644 --- a/lib/pleroma/web/mastodon_api/mastodon_api.ex +++ b/lib/pleroma/web/mastodon_api/mastodon_api.ex @@ -16,7 +16,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPI do def follow(follower, followed, params \\ %{}) do result = if not User.following?(follower, followed) do - CommonAPI.follow(follower, followed) + CommonAPI.follow(followed, follower) else {:ok, follower, followed, nil} end @@ -30,11 +30,11 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPI do end defp set_reblogs_visibility(false, {:ok, follower, followed, _}) do - CommonAPI.hide_reblogs(follower, followed) + CommonAPI.hide_reblogs(followed, follower) end defp set_reblogs_visibility(_, {:ok, follower, followed, _}) do - CommonAPI.show_reblogs(follower, followed) + CommonAPI.show_reblogs(followed, follower) end defp set_subscription(true, {:ok, follower, followed, _}) do diff --git a/lib/pleroma/web/mastodon_api/views/status_view.ex b/lib/pleroma/web/mastodon_api/views/status_view.ex index d9d7e516a..747638c53 100644 --- a/lib/pleroma/web/mastodon_api/views/status_view.ex +++ b/lib/pleroma/web/mastodon_api/views/status_view.ex @@ -293,7 +293,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do cond do is_nil(opts[:for]) -> false is_boolean(activity.thread_muted?) -> activity.thread_muted? - true -> CommonAPI.thread_muted?(opts[:for], activity) + true -> CommonAPI.thread_muted?(activity, opts[:for]) end attachment_data = object.data["attachment"] || [] diff --git a/lib/pleroma/web/streamer.ex b/lib/pleroma/web/streamer.ex index 9abdfae30..76dc0f42d 100644 --- a/lib/pleroma/web/streamer.ex +++ b/lib/pleroma/web/streamer.ex @@ -206,7 +206,7 @@ defmodule Pleroma.Web.Streamer do false <- Pleroma.Web.ActivityPub.MRF.subdomain_match?(domain_blocks, item_host), false <- Pleroma.Web.ActivityPub.MRF.subdomain_match?(domain_blocks, parent_host), true <- thread_containment(item, user), - false <- CommonAPI.thread_muted?(user, parent) do + false <- CommonAPI.thread_muted?(parent, user) do false else _ -> true diff --git a/lib/pleroma/web/twitter_api/controllers/remote_follow_controller.ex b/lib/pleroma/web/twitter_api/controllers/remote_follow_controller.ex index 1557d95ab..38ebc8c5d 100644 --- a/lib/pleroma/web/twitter_api/controllers/remote_follow_controller.ex +++ b/lib/pleroma/web/twitter_api/controllers/remote_follow_controller.ex @@ -73,7 +73,7 @@ defmodule Pleroma.Web.TwitterAPI.RemoteFollowController do # def do_follow(%{assigns: %{user: %User{} = user}} = conn, %{"user" => %{"id" => id}}) do with {:fetch_user, %User{} = followee} <- {:fetch_user, User.get_cached_by_id(id)}, - {:ok, _, _, _} <- CommonAPI.follow(user, followee) do + {:ok, _, _, _} <- CommonAPI.follow(followee, user) do redirect(conn, to: "/users/#{followee.id}") else error -> @@ -90,7 +90,7 @@ defmodule Pleroma.Web.TwitterAPI.RemoteFollowController do with {_, %User{} = followee} <- {:fetch_user, User.get_cached_by_id(id)}, {_, {:ok, user}, _} <- {:auth, WrapperAuthenticator.get_user(conn), followee}, {_, _, _, false} <- {:mfa_required, followee, user, MFA.require?(user)}, - {:ok, _, _, _} <- CommonAPI.follow(user, followee) do + {:ok, _, _, _} <- CommonAPI.follow(followee, user) do redirect(conn, to: "/users/#{followee.id}") else error -> @@ -108,7 +108,7 @@ defmodule Pleroma.Web.TwitterAPI.RemoteFollowController do {_, _, {:ok, %{user: user}}} <- {:mfa_token, followee, MFA.Token.validate(token)}, {_, _, _, {:ok, _}} <- {:verify_mfa_code, followee, token, TOTPAuthenticator.verify(code, user)}, - {:ok, _, _, _} <- CommonAPI.follow(user, followee) do + {:ok, _, _, _} <- CommonAPI.follow(followee, user) do redirect(conn, to: "/users/#{followee.id}") else error -> diff --git a/lib/pleroma/workers/mute_expire_worker.ex b/lib/pleroma/workers/mute_expire_worker.ex index 8ad287a7f..a7ab5883a 100644 --- a/lib/pleroma/workers/mute_expire_worker.ex +++ b/lib/pleroma/workers/mute_expire_worker.ex @@ -14,7 +14,7 @@ defmodule Pleroma.Workers.MuteExpireWorker do def perform(%Job{ args: %{"op" => "unmute_conversation", "user_id" => user_id, "activity_id" => activity_id} }) do - Pleroma.Web.CommonAPI.remove_mute(user_id, activity_id) + Pleroma.Web.CommonAPI.remove_mute(activity_id, user_id) :ok end diff --git a/test/mix/tasks/pleroma/database_test.exs b/test/mix/tasks/pleroma/database_test.exs index d773038cb..a51a3bf3d 100644 --- a/test/mix/tasks/pleroma/database_test.exs +++ b/test/mix/tasks/pleroma/database_test.exs @@ -251,7 +251,7 @@ defmodule Mix.Tasks.Pleroma.DatabaseTest do |> Repo.update!() {:ok, old_favourite_activity} = - CommonAPI.favorite(remote_user2, old_remote_post_activity.id) + CommonAPI.favorite(old_remote_post_activity.id, remote_user2) old_favourite_activity |> Ecto.Changeset.change(%{local: false, updated_at: old_insert_date}) @@ -302,7 +302,7 @@ defmodule Mix.Tasks.Pleroma.DatabaseTest do |> Ecto.Changeset.change(%{local: false, updated_at: old_insert_date}) |> Repo.update!() - {:ok, old_favourite_activity} = CommonAPI.favorite(local_user, old_remote_post3_activity.id) + {:ok, old_favourite_activity} = CommonAPI.favorite(old_remote_post3_activity.id, local_user) old_favourite_activity |> Ecto.Changeset.change(%{local: true, updated_at: old_insert_date}) @@ -586,7 +586,7 @@ defmodule Mix.Tasks.Pleroma.DatabaseTest do {:ok, %{id: id, object: object}} = CommonAPI.post(user, %{status: "test"}) {:ok, %{object: object2}} = CommonAPI.post(user, %{status: "test test"}) - CommonAPI.favorite(user2, id) + CommonAPI.favorite(id, user2) likes = %{ "first" => diff --git a/test/pleroma/activity_test.exs b/test/pleroma/activity_test.exs index 67943d879..62d07b1ee 100644 --- a/test/pleroma/activity_test.exs +++ b/test/pleroma/activity_test.exs @@ -249,7 +249,7 @@ defmodule Pleroma.ActivityTest do {:ok, %{id: id, object: %{data: %{"id" => obj_id}}}} = Pleroma.Web.CommonAPI.post(user, %{status: "cofe"}) - Pleroma.Web.CommonAPI.favorite(another, id) + Pleroma.Web.CommonAPI.favorite(id, another) assert obj_id |> Pleroma.Activity.Queries.by_object_id() diff --git a/test/pleroma/integration/mastodon_websocket_test.exs b/test/pleroma/integration/mastodon_websocket_test.exs index a0ffddf8d..f499f54ad 100644 --- a/test/pleroma/integration/mastodon_websocket_test.exs +++ b/test/pleroma/integration/mastodon_websocket_test.exs @@ -404,7 +404,7 @@ defmodule Pleroma.Integration.MastodonWebsocketTest do test "receives private statuses", %{user: reading_user, token: token} do user = insert(:user) - CommonAPI.follow(reading_user, user) + CommonAPI.follow(user, reading_user) {:ok, _} = start_socket("?stream=user&access_token=#{token.token}") @@ -431,7 +431,7 @@ defmodule Pleroma.Integration.MastodonWebsocketTest do test "receives edits", %{user: reading_user, token: token} do user = insert(:user) - CommonAPI.follow(reading_user, user) + CommonAPI.follow(user, reading_user) {:ok, _} = start_socket("?stream=user&access_token=#{token.token}") @@ -440,7 +440,7 @@ defmodule Pleroma.Integration.MastodonWebsocketTest do assert_receive {:text, _raw_json}, 1_000 - {:ok, _} = CommonAPI.update(user, activity, %{status: "mew mew", visibility: "private"}) + {:ok, _} = CommonAPI.update(activity, user, %{status: "mew mew", visibility: "private"}) assert_receive {:text, raw_json}, 1_000 @@ -459,7 +459,7 @@ defmodule Pleroma.Integration.MastodonWebsocketTest do test "receives notifications", %{user: reading_user, token: token} do user = insert(:user) - CommonAPI.follow(reading_user, user) + CommonAPI.follow(user, reading_user) {:ok, _} = start_socket("?stream=user:notification&access_token=#{token.token}") diff --git a/test/pleroma/migration_helper/notification_backfill_test.exs b/test/pleroma/migration_helper/notification_backfill_test.exs index 6d47bb6a8..2797cfb2c 100644 --- a/test/pleroma/migration_helper/notification_backfill_test.exs +++ b/test/pleroma/migration_helper/notification_backfill_test.exs @@ -21,7 +21,7 @@ defmodule Pleroma.MigrationHelper.NotificationBackfillTest do {:ok, post} = CommonAPI.post(user, %{status: "yeah, @#{other_user.nickname}"}) {:ok, chat} = CommonAPI.post_chat_message(user, other_user, "yo") {:ok, react} = CommonAPI.react_with_emoji(post.id, other_user, "☕") - {:ok, like} = CommonAPI.favorite(other_user, post.id) + {:ok, like} = CommonAPI.favorite(post.id, other_user) {:ok, react_2} = CommonAPI.react_with_emoji(post.id, other_user, "☕") data = diff --git a/test/pleroma/notification_test.exs b/test/pleroma/notification_test.exs index 21bea4c3f..e595c5c53 100644 --- a/test/pleroma/notification_test.exs +++ b/test/pleroma/notification_test.exs @@ -165,7 +165,7 @@ defmodule Pleroma.NotificationTest do {:ok, _activity_two} = CommonAPI.repeat(activity_one.id, repeated_user) {:ok, _edit_activity} = - CommonAPI.update(user, activity_one, %{ + CommonAPI.update(activity_one, user, %{ status: "hey @#{other_user.nickname}! mew mew" }) @@ -180,8 +180,8 @@ defmodule Pleroma.NotificationTest do question = insert(:question, user: user1) activity = insert(:question_activity, question: question) - {:ok, _, _} = CommonAPI.vote(user2, question, [0]) - {:ok, _, _} = CommonAPI.vote(user3, question, [1]) + {:ok, _, _} = CommonAPI.vote(question, user2, [0]) + {:ok, _, _} = CommonAPI.vote(question, user3, [1]) {:ok, notifications} = Notification.create_poll_notifications(activity) @@ -209,7 +209,7 @@ defmodule Pleroma.NotificationTest do notification_settings: %Pleroma.User.NotificationSetting{block_from_strangers: true} ) - CommonAPI.follow(follower, followed) + CommonAPI.follow(followed, follower) {:ok, activity} = CommonAPI.post(follower, %{status: "hey @#{followed.nickname}"}) refute Notification.create_notification(activity, followed) end @@ -222,7 +222,7 @@ defmodule Pleroma.NotificationTest do notification_settings: %Pleroma.User.NotificationSetting{block_from_strangers: true} ) - CommonAPI.follow(receiver, poster) + CommonAPI.follow(poster, receiver) {:ok, activity} = CommonAPI.post(poster, %{status: "hey @#{receiver.nickname}"}) assert Notification.create_notification(activity, receiver) end @@ -238,7 +238,7 @@ defmodule Pleroma.NotificationTest do user = insert(:user) subscriber = insert(:user) - {:ok, _, _, _} = CommonAPI.follow(subscriber, user) + {:ok, _, _, _} = CommonAPI.follow(user, subscriber) User.subscribe(subscriber, user) {:ok, status} = CommonAPI.post(user, %{status: "Akariiiin"}) {:ok, [_notif]} = Notification.create_notifications(status) @@ -295,7 +295,7 @@ defmodule Pleroma.NotificationTest do insert(:filter, user: user, phrase: "tesla", hide: true) {:ok, activity_one} = CommonAPI.post(user, %{status: "wow tesla"}) - {:ok, activity_two} = CommonAPI.favorite(other_user, activity_one.id) + {:ok, activity_two} = CommonAPI.favorite(activity_one.id, other_user) {:ok, [notification]} = Notification.create_notifications(activity_two) @@ -309,7 +309,7 @@ defmodule Pleroma.NotificationTest do user = insert(:user) followed_user = insert(:user, is_locked: false) - {:ok, _, _, _activity} = CommonAPI.follow(user, followed_user) + {:ok, _, _, _activity} = CommonAPI.follow(followed_user, user) assert FollowingRelationship.following?(user, followed_user) assert [notification] = Notification.for_user(followed_user) @@ -324,7 +324,7 @@ defmodule Pleroma.NotificationTest do user = insert(:user) followed_user = insert(:user, is_locked: true) - {:ok, _, _, _activity} = CommonAPI.follow(user, followed_user) + {:ok, _, _, _activity} = CommonAPI.follow(followed_user, user) refute FollowingRelationship.following?(user, followed_user) assert [notification] = Notification.for_user(followed_user) @@ -349,12 +349,12 @@ defmodule Pleroma.NotificationTest do user = insert(:user) followed_user = insert(:user, is_locked: false) - {:ok, _, _, _activity} = CommonAPI.follow(user, followed_user) + {:ok, _, _, _activity} = CommonAPI.follow(followed_user, user) assert FollowingRelationship.following?(user, followed_user) assert [notification] = Notification.for_user(followed_user) - CommonAPI.unfollow(user, followed_user) - {:ok, _, _, _activity_dupe} = CommonAPI.follow(user, followed_user) + CommonAPI.unfollow(followed_user, user) + {:ok, _, _, _activity_dupe} = CommonAPI.follow(followed_user, user) notification_id = notification.id assert [%{id: ^notification_id}] = Notification.for_user(followed_user) @@ -363,7 +363,7 @@ defmodule Pleroma.NotificationTest do test "dismisses the notification on follow request rejection" do user = insert(:user, is_locked: true) follower = insert(:user) - {:ok, _, _, _follow_activity} = CommonAPI.follow(follower, user) + {:ok, _, _, _follow_activity} = CommonAPI.follow(user, follower) assert [_notification] = Notification.for_user(user) {:ok, _follower} = CommonAPI.reject_follow_request(follower, user) assert [] = Notification.for_user(user) @@ -617,7 +617,7 @@ defmodule Pleroma.NotificationTest do status: "hey @#{other_user.nickname}!" }) - {:ok, activity_two} = CommonAPI.favorite(third_user, activity_one.id) + {:ok, activity_two} = CommonAPI.favorite(activity_one.id, third_user) enabled_receivers = Notification.get_notified_from_activity(activity_two) @@ -693,7 +693,7 @@ defmodule Pleroma.NotificationTest do {:ok, activity} = CommonAPI.post(user, %{status: "hey @#{other_user.nickname}!"}) - {:ok, _} = CommonAPI.add_mute(other_user, activity) + {:ok, _} = CommonAPI.add_mute(activity, other_user) {:ok, same_context_activity} = CommonAPI.post(user, %{ @@ -748,7 +748,7 @@ defmodule Pleroma.NotificationTest do {:ok, _activity_two} = CommonAPI.repeat(activity_one.id, repeated_user) {:ok, edit_activity} = - CommonAPI.update(user, activity_one, %{ + CommonAPI.update(activity_one, user, %{ status: "hey @#{other_user.nickname}! mew mew" }) @@ -768,7 +768,7 @@ defmodule Pleroma.NotificationTest do assert Enum.empty?(Notification.for_user(user)) - {:ok, _} = CommonAPI.favorite(other_user, activity.id) + {:ok, _} = CommonAPI.favorite(activity.id, other_user) assert length(Notification.for_user(user)) == 1 @@ -785,7 +785,7 @@ defmodule Pleroma.NotificationTest do assert Enum.empty?(Notification.for_user(user)) - {:ok, _} = CommonAPI.favorite(other_user, activity.id) + {:ok, _} = CommonAPI.favorite(activity.id, other_user) assert length(Notification.for_user(user)) == 1 @@ -840,7 +840,7 @@ defmodule Pleroma.NotificationTest do assert Enum.empty?(Notification.for_user(user)) - {:error, :not_found} = CommonAPI.favorite(other_user, activity.id) + {:error, :not_found} = CommonAPI.favorite(activity.id, other_user) assert Enum.empty?(Notification.for_user(user)) end @@ -1090,7 +1090,7 @@ defmodule Pleroma.NotificationTest do another_user = insert(:user) {:ok, activity} = CommonAPI.post(user, %{status: "Give me my cofe!"}) - {:ok, _} = CommonAPI.favorite(another_user, activity.id) + {:ok, _} = CommonAPI.favorite(activity.id, another_user) assert length(Notification.for_user(user)) == 1 end @@ -1101,7 +1101,7 @@ defmodule Pleroma.NotificationTest do insert(:filter, user: followed_user, phrase: "test", hide: true) - {:ok, _, _, _activity} = CommonAPI.follow(user, followed_user) + {:ok, _, _, _activity} = CommonAPI.follow(followed_user, user) refute FollowingRelationship.following?(user, followed_user) assert [notification] = Notification.for_user(followed_user) diff --git a/test/pleroma/object_test.exs b/test/pleroma/object_test.exs index 2025d93e4..48d4d86eb 100644 --- a/test/pleroma/object_test.exs +++ b/test/pleroma/object_test.exs @@ -403,7 +403,7 @@ defmodule Pleroma.ObjectTest do user = insert(:user) activity = Activity.get_create_by_object_ap_id(object.data["id"]) - {:ok, activity} = CommonAPI.favorite(user, activity.id) + {:ok, activity} = CommonAPI.favorite(activity.id, user) object = Object.get_by_ap_id(activity.data["object"]) assert object.data["like_count"] == 1 diff --git a/test/pleroma/resilience_test.exs b/test/pleroma/resilience_test.exs index 9dc5d0dd6..0c4195fa8 100644 --- a/test/pleroma/resilience_test.exs +++ b/test/pleroma/resilience_test.exs @@ -18,7 +18,7 @@ defmodule Pleroma.ResilienceTest do other_user = insert(:user) {:ok, post_one} = CommonAPI.post(user, %{status: "Here is a post"}) - {:ok, like} = CommonAPI.favorite(other_user, post_one.id) + {:ok, like} = CommonAPI.favorite(post_one.id, other_user) %{ user: user, @@ -90,7 +90,7 @@ defmodule Pleroma.ResilienceTest do |> json_response(200) # Favoriting again doesn't hurt - {:ok, _like_two} = CommonAPI.favorite(other_user, post.id) + {:ok, _like_two} = CommonAPI.favorite(post.id, other_user) post = Repo.get(Activity, post.id) diff --git a/test/pleroma/stats_test.exs b/test/pleroma/stats_test.exs index 37a085afc..c70603ab9 100644 --- a/test/pleroma/stats_test.exs +++ b/test/pleroma/stats_test.exs @@ -73,8 +73,8 @@ defmodule Pleroma.StatsTest do user = insert(:user) other_user = insert(:user) {:ok, activity} = CommonAPI.post(user, %{visibility: "public", status: "hey"}) - _ = CommonAPI.follow(user, other_user) - CommonAPI.favorite(other_user, activity.id) + _ = CommonAPI.follow(other_user, user) + CommonAPI.favorite(activity.id, other_user) CommonAPI.repeat(activity.id, other_user) assert %{"direct" => 0, "private" => 0, "public" => 1, "unlisted" => 0} = diff --git a/test/pleroma/user/backup_test.exs b/test/pleroma/user/backup_test.exs index 753e35982..d82d1719b 100644 --- a/test/pleroma/user/backup_test.exs +++ b/test/pleroma/user/backup_test.exs @@ -177,13 +177,13 @@ defmodule Pleroma.User.BackupTest do {:ok, %{object: %{data: %{"id" => id3}}} = status3} = CommonAPI.post(user, %{status: "status3"}) - CommonAPI.favorite(user, status1.id) - CommonAPI.favorite(user, status2.id) + CommonAPI.favorite(status1.id, user) + CommonAPI.favorite(status2.id, user) Bookmark.create(user.id, status2.id) Bookmark.create(user.id, status3.id) - CommonAPI.follow(user, other_user) + CommonAPI.follow(other_user, user) assert {:ok, backup} = user |> Backup.new() |> Repo.insert() assert {:ok, path} = Backup.export(backup, self()) @@ -283,7 +283,7 @@ defmodule Pleroma.User.BackupTest do Enum.map(1..120, fn i -> {:ok, status} = CommonAPI.post(user, %{status: "status #{i}"}) - CommonAPI.favorite(user, status.id) + CommonAPI.favorite(status.id, user) Bookmark.create(user.id, status.id) end) @@ -337,8 +337,8 @@ defmodule Pleroma.User.BackupTest do {:ok, status1} = CommonAPI.post(user, %{status: "status1"}) {:ok, status2} = CommonAPI.post(user, %{status: "status2"}) {:ok, status3} = CommonAPI.post(user, %{status: "status3"}) - CommonAPI.favorite(user, status1.id) - CommonAPI.favorite(user, status2.id) + CommonAPI.favorite(status1.id, user) + CommonAPI.favorite(status2.id, user) Bookmark.create(user.id, status2.id) Bookmark.create(user.id, status3.id) diff --git a/test/pleroma/user_test.exs b/test/pleroma/user_test.exs index 78018fedc..036ae78fb 100644 --- a/test/pleroma/user_test.exs +++ b/test/pleroma/user_test.exs @@ -182,8 +182,8 @@ defmodule Pleroma.UserTest do locked = insert(:user, is_locked: true) follower = insert(:user) - CommonAPI.follow(follower, unlocked) - CommonAPI.follow(follower, locked) + CommonAPI.follow(unlocked, follower) + CommonAPI.follow(locked, follower) assert [] = User.get_follow_requests(unlocked) assert [activity] = User.get_follow_requests(locked) @@ -196,9 +196,9 @@ defmodule Pleroma.UserTest do pending_follower = insert(:user) accepted_follower = insert(:user) - CommonAPI.follow(pending_follower, locked) - CommonAPI.follow(pending_follower, locked) - CommonAPI.follow(accepted_follower, locked) + CommonAPI.follow(locked, pending_follower) + CommonAPI.follow(locked, pending_follower) + CommonAPI.follow(locked, accepted_follower) Pleroma.FollowingRelationship.update(accepted_follower, locked, :follow_accept) @@ -209,7 +209,7 @@ defmodule Pleroma.UserTest do locked = insert(:user, is_locked: true) pending_follower = insert(:user, %{is_active: false}) - CommonAPI.follow(pending_follower, locked) + CommonAPI.follow(locked, pending_follower) refute pending_follower.is_active assert [] = User.get_follow_requests(locked) @@ -219,7 +219,7 @@ defmodule Pleroma.UserTest do followed = insert(:user, is_locked: true) follower = insert(:user) - CommonAPI.follow(follower, followed) + CommonAPI.follow(followed, follower) assert [_activity] = User.get_follow_requests(followed) {:ok, _user_relationship} = User.block(followed, follower) @@ -1526,7 +1526,7 @@ defmodule Pleroma.UserTest do assert [activity] == ActivityPub.fetch_public_activities(%{}) |> Repo.preload(:bookmark) - assert [%{activity | thread_muted?: CommonAPI.thread_muted?(user2, activity)}] == + assert [%{activity | thread_muted?: CommonAPI.thread_muted?(activity, user2)}] == ActivityPub.fetch_activities([user2.ap_id | User.following(user2)], %{ user: user2 }) @@ -1691,8 +1691,8 @@ defmodule Pleroma.UserTest do object_two = insert(:note, user: follower) activity_two = insert(:note_activity, user: follower, note: object_two) - {:ok, like} = CommonAPI.favorite(user, activity_two.id) - {:ok, like_two} = CommonAPI.favorite(follower, activity.id) + {:ok, like} = CommonAPI.favorite(activity_two.id, user) + {:ok, like_two} = CommonAPI.favorite(activity.id, follower) {:ok, repeat} = CommonAPI.repeat(activity_two.id, user) {:ok, job} = User.delete(user) diff --git a/test/pleroma/web/activity_pub/activity_pub_controller_test.exs b/test/pleroma/web/activity_pub/activity_pub_controller_test.exs index 043efeda1..6aae61835 100644 --- a/test/pleroma/web/activity_pub/activity_pub_controller_test.exs +++ b/test/pleroma/web/activity_pub/activity_pub_controller_test.exs @@ -1224,7 +1224,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do note = insert(:note_activity, user: reported_user) - Pleroma.Web.CommonAPI.favorite(another, note.id) + Pleroma.Web.CommonAPI.favorite(note.id, another) mock_json_body = "test/fixtures/mastodon/application_actor.json" @@ -1402,7 +1402,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do assert question = Object.normalize(activity, fetch: false) - {:ok, [activity], _object} = CommonAPI.vote(voter, question, [1]) + {:ok, [activity], _object} = CommonAPI.vote(question, voter, [1]) assert outbox_get = conn @@ -1747,7 +1747,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do %{conn: conn} do user = insert(:user, hide_followers: true) other_user = insert(:user) - {:ok, _other_user, user, _activity} = CommonAPI.follow(other_user, user) + {:ok, _other_user, user, _activity} = CommonAPI.follow(user, other_user) result = conn @@ -1843,7 +1843,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do %{conn: conn} do user = insert(:user, hide_follows: true) other_user = insert(:user) - {:ok, user, _other_user, _activity} = CommonAPI.follow(user, other_user) + {:ok, user, _other_user, _activity} = CommonAPI.follow(other_user, user) result = conn diff --git a/test/pleroma/web/activity_pub/activity_pub_test.exs b/test/pleroma/web/activity_pub/activity_pub_test.exs index c3c59df35..b4f6fb68a 100644 --- a/test/pleroma/web/activity_pub/activity_pub_test.exs +++ b/test/pleroma/web/activity_pub/activity_pub_test.exs @@ -1038,7 +1038,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do refute activity in activities followed_user = insert(:user) - CommonAPI.follow(user, followed_user) + CommonAPI.follow(followed_user, user) {:ok, repeat_activity} = CommonAPI.repeat(activity.id, followed_user) activities = ActivityPub.fetch_activities([], %{blocking_user: user, skip_preload: true}) @@ -1171,7 +1171,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do note_two = insert(:note, data: %{"context" => "suya.."}) activity_two = insert(:note_activity, note: note_two) - {:ok, _activity_two} = CommonAPI.add_mute(user, activity_two) + {:ok, _activity_two} = CommonAPI.add_mute(activity_two, user) assert [_activity_one] = ActivityPub.fetch_activities([], %{muting_user: user}) end @@ -1182,7 +1182,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do note_two = insert(:note, data: %{"context" => "suya.."}) activity_two = insert(:note_activity, note: note_two) - {:ok, _activity_two} = CommonAPI.add_mute(user, activity_two) + {:ok, _activity_two} = CommonAPI.add_mute(activity_two, user) assert [_activity_two, _activity_one] = ActivityPub.fetch_activities([], %{muting_user: user, with_muted: true}) @@ -1358,7 +1358,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do activity = insert(:note_activity) user = insert(:user) booster = insert(:user) - {:ok, _reblog_mute} = CommonAPI.hide_reblogs(user, booster) + {:ok, _reblog_mute} = CommonAPI.hide_reblogs(booster, user) {:ok, activity} = CommonAPI.repeat(activity.id, booster) @@ -1371,8 +1371,8 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do activity = insert(:note_activity) user = insert(:user) booster = insert(:user) - {:ok, _reblog_mute} = CommonAPI.hide_reblogs(user, booster) - {:ok, _reblog_mute} = CommonAPI.show_reblogs(user, booster) + {:ok, _reblog_mute} = CommonAPI.hide_reblogs(booster, user) + {:ok, _reblog_mute} = CommonAPI.show_reblogs(booster, user) {:ok, activity} = CommonAPI.repeat(activity.id, booster) @@ -1452,7 +1452,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do follower = insert(:user) followed = insert(:user) - {:ok, _, _, follow_activity} = CommonAPI.follow(follower, followed) + {:ok, _, _, follow_activity} = CommonAPI.follow(followed, follower) with_mock(Utils, [:passthrough], maybe_federate: fn _ -> {:error, :reverted} end) do assert {:error, :reverted} = ActivityPub.unfollow(follower, followed) @@ -1469,7 +1469,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do follower = insert(:user) followed = insert(:user) - {:ok, _, _, follow_activity} = CommonAPI.follow(follower, followed) + {:ok, _, _, follow_activity} = CommonAPI.follow(followed, follower) {:ok, activity} = ActivityPub.unfollow(follower, followed) assert activity.data["type"] == "Undo" @@ -1486,7 +1486,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do follower = insert(:user) followed = insert(:user, %{is_locked: true}) - {:ok, _, _, follow_activity} = CommonAPI.follow(follower, followed) + {:ok, _, _, follow_activity} = CommonAPI.follow(followed, follower) {:ok, activity} = ActivityPub.unfollow(follower, followed) assert activity.data["type"] == "Undo" @@ -1854,14 +1854,14 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do {:ok, a4} = CommonAPI.post(user2, %{status: "Agent Smith "}) {:ok, a5} = CommonAPI.post(user1, %{status: "Red or Blue "}) - {:ok, _} = CommonAPI.favorite(user, a4.id) - {:ok, _} = CommonAPI.favorite(other_user, a3.id) - {:ok, _} = CommonAPI.favorite(user, a3.id) - {:ok, _} = CommonAPI.favorite(other_user, a5.id) - {:ok, _} = CommonAPI.favorite(user, a5.id) - {:ok, _} = CommonAPI.favorite(other_user, a4.id) - {:ok, _} = CommonAPI.favorite(user, a1.id) - {:ok, _} = CommonAPI.favorite(other_user, a1.id) + {:ok, _} = CommonAPI.favorite(a4.id, user) + {:ok, _} = CommonAPI.favorite(a3.id, other_user) + {:ok, _} = CommonAPI.favorite(a3.id, user) + {:ok, _} = CommonAPI.favorite(a5.id, other_user) + {:ok, _} = CommonAPI.favorite(a5.id, user) + {:ok, _} = CommonAPI.favorite(a4.id, other_user) + {:ok, _} = CommonAPI.favorite(a1.id, user) + {:ok, _} = CommonAPI.favorite(a1.id, other_user) result = ActivityPub.fetch_favourites(user) assert Enum.map(result, & &1.id) == [a1.id, a5.id, a3.id, a4.id] diff --git a/test/pleroma/web/activity_pub/mrf/simple_policy_test.exs b/test/pleroma/web/activity_pub/mrf/simple_policy_test.exs index 57fc00af5..1a51b7d30 100644 --- a/test/pleroma/web/activity_pub/mrf/simple_policy_test.exs +++ b/test/pleroma/web/activity_pub/mrf/simple_policy_test.exs @@ -318,7 +318,7 @@ defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicyTest do following_user = insert(:user) non_following_user = insert(:user) - {:ok, _, _, _} = CommonAPI.follow(following_user, actor) + {:ok, _, _, _} = CommonAPI.follow(actor, following_user) activity = %{ "actor" => actor.ap_id, diff --git a/test/pleroma/web/activity_pub/object_validators/article_note_page_validator_test.exs b/test/pleroma/web/activity_pub/object_validators/article_note_page_validator_test.exs index 2b33950d6..e1dbb20c3 100644 --- a/test/pleroma/web/activity_pub/object_validators/article_note_page_validator_test.exs +++ b/test/pleroma/web/activity_pub/object_validators/article_note_page_validator_test.exs @@ -43,7 +43,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.ArticleNotePageValidatorTest setup do user = insert(:user) {:ok, activity} = Pleroma.Web.CommonAPI.post(user, %{status: "mew mew :dinosaur:"}) - {:ok, edit} = Pleroma.Web.CommonAPI.update(user, activity, %{status: "edited :blank:"}) + {:ok, edit} = Pleroma.Web.CommonAPI.update(activity, user, %{status: "edited :blank:"}) {:ok, %{"object" => external_rep}} = Pleroma.Web.ActivityPub.Transmogrifier.prepare_outgoing(edit.data) diff --git a/test/pleroma/web/activity_pub/object_validators/like_validation_test.exs b/test/pleroma/web/activity_pub/object_validators/like_validation_test.exs index ebc181a6d..620173119 100644 --- a/test/pleroma/web/activity_pub/object_validators/like_validation_test.exs +++ b/test/pleroma/web/activity_pub/object_validators/like_validation_test.exs @@ -94,7 +94,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.LikeValidationTest do user: user, post_activity: post_activity } do - _like = CommonAPI.favorite(user, post_activity.id) + _like = CommonAPI.favorite(post_activity.id, user) refute LikeValidator.cast_and_validate(valid_like).valid? end diff --git a/test/pleroma/web/activity_pub/object_validators/undo_handling_test.exs b/test/pleroma/web/activity_pub/object_validators/undo_handling_test.exs index db95b8e3c..589b70ac7 100644 --- a/test/pleroma/web/activity_pub/object_validators/undo_handling_test.exs +++ b/test/pleroma/web/activity_pub/object_validators/undo_handling_test.exs @@ -15,7 +15,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.UndoHandlingTest do setup do user = insert(:user) {:ok, post_activity} = CommonAPI.post(user, %{status: "uguu"}) - {:ok, like} = CommonAPI.favorite(user, post_activity.id) + {:ok, like} = CommonAPI.favorite(post_activity.id, user) {:ok, valid_like_undo, []} = Builder.undo(user, like) %{user: user, like: like, valid_like_undo: valid_like_undo} diff --git a/test/pleroma/web/activity_pub/object_validators/update_handling_test.exs b/test/pleroma/web/activity_pub/object_validators/update_handling_test.exs index a09dbf5c6..c88339d14 100644 --- a/test/pleroma/web/activity_pub/object_validators/update_handling_test.exs +++ b/test/pleroma/web/activity_pub/object_validators/update_handling_test.exs @@ -132,7 +132,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.UpdateHandlingTest do setup do user = insert(:user) {:ok, activity} = Pleroma.Web.CommonAPI.post(user, %{status: "mew mew :dinosaur:"}) - {:ok, edit} = Pleroma.Web.CommonAPI.update(user, activity, %{status: "edited :blank:"}) + {:ok, edit} = Pleroma.Web.CommonAPI.update(activity, user, %{status: "edited :blank:"}) {:ok, external_rep} = Pleroma.Web.ActivityPub.Transmogrifier.prepare_outgoing(edit.data) %{external_rep: external_rep} end diff --git a/test/pleroma/web/activity_pub/relay_test.exs b/test/pleroma/web/activity_pub/relay_test.exs index 5867246d7..7c45593ed 100644 --- a/test/pleroma/web/activity_pub/relay_test.exs +++ b/test/pleroma/web/activity_pub/relay_test.exs @@ -53,7 +53,7 @@ defmodule Pleroma.Web.ActivityPub.RelayTest do test "returns activity" do user = insert(:user) service_actor = Relay.get_actor() - CommonAPI.follow(service_actor, user) + CommonAPI.follow(user, service_actor) assert "#{user.ap_id}/followers" in User.following(service_actor) assert {:ok, %Activity{} = activity} = Relay.unfollow(user.ap_id) assert activity.actor == "#{Pleroma.Web.Endpoint.url()}/relay" @@ -74,7 +74,7 @@ defmodule Pleroma.Web.ActivityPub.RelayTest do end) service_actor = Relay.get_actor() - CommonAPI.follow(service_actor, user) + CommonAPI.follow(user, service_actor) assert "#{user.ap_id}/followers" in User.following(service_actor) assert Pleroma.Repo.get_by( diff --git a/test/pleroma/web/activity_pub/side_effects/delete_test.exs b/test/pleroma/web/activity_pub/side_effects/delete_test.exs index 9a2703c4c..637007b7e 100644 --- a/test/pleroma/web/activity_pub/side_effects/delete_test.exs +++ b/test/pleroma/web/activity_pub/side_effects/delete_test.exs @@ -50,7 +50,7 @@ defmodule Pleroma.Web.ActivityPub.SideEffects.DeleteTest do {:ok, op} = CommonAPI.post(other_user, %{status: "big oof"}) {:ok, post} = CommonAPI.post(user, %{status: "hey", in_reply_to_id: op}) - {:ok, favorite} = CommonAPI.favorite(user, post.id) + {:ok, favorite} = CommonAPI.favorite(post.id, user) object = Object.normalize(post, fetch: false) {:ok, delete_data, _meta} = Builder.delete(user, object.data["id"]) {:ok, delete, _meta} = ActivityPub.persist(delete_data, local: true) diff --git a/test/pleroma/web/activity_pub/side_effects_test.exs b/test/pleroma/web/activity_pub/side_effects_test.exs index 7af50e12c..68922e536 100644 --- a/test/pleroma/web/activity_pub/side_effects_test.exs +++ b/test/pleroma/web/activity_pub/side_effects_test.exs @@ -516,10 +516,10 @@ defmodule Pleroma.Web.ActivityPub.SideEffectsTest do poster = insert(:user) user = insert(:user) {:ok, post} = CommonAPI.post(poster, %{status: "hey"}) - {:ok, like} = CommonAPI.favorite(user, post.id) + {:ok, like} = CommonAPI.favorite(post.id, user) {:ok, reaction} = CommonAPI.react_with_emoji(post.id, user, "👍") {:ok, announce} = CommonAPI.repeat(post.id, user) - {:ok, block} = CommonAPI.block(user, poster) + {:ok, block} = CommonAPI.block(poster, user) {:ok, undo_data, _meta} = Builder.undo(user, like) {:ok, like_undo, _meta} = ActivityPub.persist(undo_data, local: true) @@ -834,7 +834,7 @@ defmodule Pleroma.Web.ActivityPub.SideEffectsTest do user = insert(:user) followed = insert(:user) - {:ok, _, _, follow_activity} = CommonAPI.follow(user, followed) + {:ok, _, _, follow_activity} = CommonAPI.follow(followed, user) {:ok, reject_data, []} = Builder.reject(followed, follow_activity) {:ok, reject, _meta} = ActivityPub.persist(reject_data, local: true) @@ -965,7 +965,7 @@ defmodule Pleroma.Web.ActivityPub.SideEffectsTest do group: group, poster: poster } do - {:ok, _} = CommonAPI.block(group, poster) + {:ok, _} = CommonAPI.block(poster, group) create_activity_data = make_create.([group]) {:ok, create_activity, _meta} = ActivityPub.persist(create_activity_data, local: false) diff --git a/test/pleroma/web/activity_pub/transmogrifier/accept_handling_test.exs b/test/pleroma/web/activity_pub/transmogrifier/accept_handling_test.exs index 968fd4ede..4209a24a7 100644 --- a/test/pleroma/web/activity_pub/transmogrifier/accept_handling_test.exs +++ b/test/pleroma/web/activity_pub/transmogrifier/accept_handling_test.exs @@ -18,7 +18,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.AcceptHandlingTest do {:ok, follower, followed} = User.follow(follower, followed) assert User.following?(follower, followed) == true - {:ok, _, _, follow_activity} = CommonAPI.follow(follower, followed) + {:ok, _, _, follow_activity} = CommonAPI.follow(followed, follower) accept_data = File.read!("test/fixtures/mastodon-accept-activity.json") @@ -48,7 +48,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.AcceptHandlingTest do follower = insert(:user) followed = insert(:user, is_locked: true) - {:ok, _, _, follow_activity} = CommonAPI.follow(follower, followed) + {:ok, _, _, follow_activity} = CommonAPI.follow(followed, follower) accept_data = File.read!("test/fixtures/mastodon-accept-activity.json") diff --git a/test/pleroma/web/activity_pub/transmogrifier/reject_handling_test.exs b/test/pleroma/web/activity_pub/transmogrifier/reject_handling_test.exs index 11562422d..225898e85 100644 --- a/test/pleroma/web/activity_pub/transmogrifier/reject_handling_test.exs +++ b/test/pleroma/web/activity_pub/transmogrifier/reject_handling_test.exs @@ -36,7 +36,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.RejectHandlingTest do followed = insert(:user, is_locked: true) {:ok, follower, followed} = User.follow(follower, followed) - {:ok, _, _, follow_activity} = CommonAPI.follow(follower, followed) + {:ok, _, _, follow_activity} = CommonAPI.follow(followed, follower) assert User.following?(follower, followed) == true diff --git a/test/pleroma/web/activity_pub/transmogrifier_test.exs b/test/pleroma/web/activity_pub/transmogrifier_test.exs index 2fb0cd079..6da7e4a89 100644 --- a/test/pleroma/web/activity_pub/transmogrifier_test.exs +++ b/test/pleroma/web/activity_pub/transmogrifier_test.exs @@ -353,7 +353,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do user = insert(:user) {:ok, activity} = CommonAPI.post(user, %{status: "everybody do the dinosaur :dinosaur:"}) - {:ok, update} = CommonAPI.update(user, activity, %{status: "mew mew :blank:"}) + {:ok, update} = CommonAPI.update(activity, user, %{status: "mew mew :blank:"}) {:ok, prepared} = Transmogrifier.prepare_outgoing(update.data) diff --git a/test/pleroma/web/activity_pub/utils_test.exs b/test/pleroma/web/activity_pub/utils_test.exs index cd61e3e4b..872a440cb 100644 --- a/test/pleroma/web/activity_pub/utils_test.exs +++ b/test/pleroma/web/activity_pub/utils_test.exs @@ -201,7 +201,7 @@ defmodule Pleroma.Web.ActivityPub.UtilsTest do }) object = Object.normalize(activity, fetch: false) - {:ok, votes, object} = CommonAPI.vote(other_user, object, [0, 1]) + {:ok, votes, object} = CommonAPI.vote(object, other_user, [0, 1]) assert Enum.sort(Utils.get_existing_votes(other_user.ap_id, object)) == Enum.sort(votes) end @@ -219,8 +219,8 @@ defmodule Pleroma.Web.ActivityPub.UtilsTest do }) object = Object.normalize(activity, fetch: false) - {:ok, [vote], object} = CommonAPI.vote(other_user, object, [0]) - {:ok, _activity} = CommonAPI.favorite(user, activity.id) + {:ok, [vote], object} = CommonAPI.vote(object, other_user, [0]) + {:ok, _activity} = CommonAPI.favorite(activity.id, user) [fetched_vote] = Utils.get_existing_votes(other_user.ap_id, object) assert fetched_vote.id == vote.id end @@ -231,8 +231,8 @@ defmodule Pleroma.Web.ActivityPub.UtilsTest do user = insert(:user, is_locked: true) follower = insert(:user) - {:ok, _, _, follow_activity} = CommonAPI.follow(follower, user) - {:ok, _, _, follow_activity_two} = CommonAPI.follow(follower, user) + {:ok, _, _, follow_activity} = CommonAPI.follow(user, follower) + {:ok, _, _, follow_activity_two} = CommonAPI.follow(user, follower) data = follow_activity_two.data @@ -253,8 +253,8 @@ defmodule Pleroma.Web.ActivityPub.UtilsTest do user = insert(:user) follower = insert(:user) - {:ok, _, _, follow_activity} = CommonAPI.follow(follower, user) - {:ok, _, _, follow_activity_two} = CommonAPI.follow(follower, user) + {:ok, _, _, follow_activity} = CommonAPI.follow(user, follower) + {:ok, _, _, follow_activity_two} = CommonAPI.follow(user, follower) {:ok, follow_activity_two} = Utils.update_follow_state_for_all(follow_activity_two, "reject") @@ -269,8 +269,8 @@ defmodule Pleroma.Web.ActivityPub.UtilsTest do user = insert(:user, is_locked: true) follower = insert(:user) - {:ok, _, _, follow_activity} = CommonAPI.follow(follower, user) - {:ok, _, _, follow_activity_two} = CommonAPI.follow(follower, user) + {:ok, _, _, follow_activity} = CommonAPI.follow(user, follower) + {:ok, _, _, follow_activity_two} = CommonAPI.follow(user, follower) data = follow_activity_two.data @@ -355,7 +355,7 @@ defmodule Pleroma.Web.ActivityPub.UtilsTest do user = insert(:user) refute Utils.get_existing_like(user.ap_id, object) - {:ok, like_activity} = CommonAPI.favorite(user, note_activity.id) + {:ok, like_activity} = CommonAPI.favorite(note_activity.id, user) assert ^like_activity = Utils.get_existing_like(user.ap_id, object) end @@ -382,9 +382,9 @@ defmodule Pleroma.Web.ActivityPub.UtilsTest do user1 = insert(:user) user2 = insert(:user) - assert {:ok, %Activity{} = _} = CommonAPI.block(user1, user2) - assert {:ok, %Activity{} = _} = CommonAPI.block(user1, user2) - assert {:ok, %Activity{} = activity} = CommonAPI.block(user1, user2) + assert {:ok, %Activity{} = _} = CommonAPI.block(user2, user1) + assert {:ok, %Activity{} = _} = CommonAPI.block(user2, user1) + assert {:ok, %Activity{} = activity} = CommonAPI.block(user2, user1) assert Utils.fetch_latest_block(user1, user2) == activity end @@ -546,7 +546,7 @@ defmodule Pleroma.Web.ActivityPub.UtilsTest do target_account = insert(:user) {:ok, activity} = CommonAPI.post(posting_account, %{status: "foobar"}) - {:ok, like} = CommonAPI.favorite(target_account, activity.id) + {:ok, like} = CommonAPI.favorite(activity.id, target_account) context = Utils.generate_context_id() content = "foobar" diff --git a/test/pleroma/web/activity_pub/views/object_view_test.exs b/test/pleroma/web/activity_pub/views/object_view_test.exs index d94878e31..14258795f 100644 --- a/test/pleroma/web/activity_pub/views/object_view_test.exs +++ b/test/pleroma/web/activity_pub/views/object_view_test.exs @@ -59,7 +59,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectViewTest do object = Object.normalize(note, fetch: false) user = insert(:user) - {:ok, like_activity} = CommonAPI.favorite(user, note.id) + {:ok, like_activity} = CommonAPI.favorite(note.id, user) result = ObjectView.render("object.json", %{object: like_activity}) diff --git a/test/pleroma/web/activity_pub/views/user_view_test.exs b/test/pleroma/web/activity_pub/views/user_view_test.exs index c75149dab..c94f8a2bc 100644 --- a/test/pleroma/web/activity_pub/views/user_view_test.exs +++ b/test/pleroma/web/activity_pub/views/user_view_test.exs @@ -138,7 +138,7 @@ defmodule Pleroma.Web.ActivityPub.UserViewTest do test "sets totalItems to zero when followers are hidden" do user = insert(:user) other_user = insert(:user) - {:ok, _other_user, user, _activity} = CommonAPI.follow(other_user, user) + {:ok, _other_user, user, _activity} = CommonAPI.follow(user, other_user) assert %{"totalItems" => 1} = UserView.render("followers.json", %{user: user}) user = Map.merge(user, %{hide_followers_count: true, hide_followers: true}) refute UserView.render("followers.json", %{user: user}) |> Map.has_key?("totalItems") @@ -147,7 +147,7 @@ defmodule Pleroma.Web.ActivityPub.UserViewTest do test "sets correct totalItems when followers are hidden but the follower counter is not" do user = insert(:user) other_user = insert(:user) - {:ok, _other_user, user, _activity} = CommonAPI.follow(other_user, user) + {:ok, _other_user, user, _activity} = CommonAPI.follow(user, other_user) assert %{"totalItems" => 1} = UserView.render("followers.json", %{user: user}) user = Map.merge(user, %{hide_followers_count: false, hide_followers: true}) assert %{"totalItems" => 1} = UserView.render("followers.json", %{user: user}) @@ -158,7 +158,7 @@ defmodule Pleroma.Web.ActivityPub.UserViewTest do test "sets totalItems to zero when follows are hidden" do user = insert(:user) other_user = insert(:user) - {:ok, user, _other_user, _activity} = CommonAPI.follow(user, other_user) + {:ok, user, _other_user, _activity} = CommonAPI.follow(other_user, user) assert %{"totalItems" => 1} = UserView.render("following.json", %{user: user}) user = Map.merge(user, %{hide_follows_count: true, hide_follows: true}) assert %{"totalItems" => 0} = UserView.render("following.json", %{user: user}) @@ -167,7 +167,7 @@ defmodule Pleroma.Web.ActivityPub.UserViewTest do test "sets correct totalItems when follows are hidden but the follow counter is not" do user = insert(:user) other_user = insert(:user) - {:ok, user, _other_user, _activity} = CommonAPI.follow(user, other_user) + {:ok, user, _other_user, _activity} = CommonAPI.follow(other_user, user) assert %{"totalItems" => 1} = UserView.render("following.json", %{user: user}) user = Map.merge(user, %{hide_follows_count: false, hide_follows: true}) assert %{"totalItems" => 1} = UserView.render("following.json", %{user: user}) diff --git a/test/pleroma/web/admin_api/controllers/user_controller_test.exs b/test/pleroma/web/admin_api/controllers/user_controller_test.exs index 8edfda54c..c8495c477 100644 --- a/test/pleroma/web/admin_api/controllers/user_controller_test.exs +++ b/test/pleroma/web/admin_api/controllers/user_controller_test.exs @@ -69,8 +69,8 @@ defmodule Pleroma.Web.AdminAPI.UserControllerTest do # Create some activities to check they got deleted later follower = insert(:user) {:ok, _} = CommonAPI.post(user, %{status: "test"}) - {:ok, _, _, _} = CommonAPI.follow(user, follower) {:ok, _, _, _} = CommonAPI.follow(follower, user) + {:ok, _, _, _} = CommonAPI.follow(user, follower) user = Repo.get(User, user.id) assert user.note_count == 1 assert user.follower_count == 1 diff --git a/test/pleroma/web/common_api_test.exs b/test/pleroma/web/common_api_test.exs index 4c1add82e..b6fba6999 100644 --- a/test/pleroma/web/common_api_test.exs +++ b/test/pleroma/web/common_api_test.exs @@ -80,8 +80,8 @@ defmodule Pleroma.Web.CommonAPITest do setup do blocker = insert(:user) blocked = insert(:user, local: false) - CommonAPI.follow(blocker, blocked) CommonAPI.follow(blocked, blocker) + CommonAPI.follow(blocker, blocked) CommonAPI.accept_follow_request(blocker, blocked) CommonAPI.accept_follow_request(blocked, blocked) %{blocker: blocker, blocked: blocked} @@ -95,7 +95,7 @@ defmodule Pleroma.Web.CommonAPITest do assert User.get_follow_state(blocker, blocked) == :follow_accept refute is_nil(Pleroma.Web.ActivityPub.Utils.fetch_latest_follow(blocker, blocked)) - assert {:ok, block} = CommonAPI.block(blocker, blocked) + assert {:ok, block} = CommonAPI.block(blocked, blocker) assert block.local assert User.blocks?(blocker, blocked) @@ -120,7 +120,7 @@ defmodule Pleroma.Web.CommonAPITest do with_mock Pleroma.Web.Federator, publish: fn _ -> nil end do - assert {:ok, block} = CommonAPI.block(blocker, blocked) + assert {:ok, block} = CommonAPI.block(blocked, blocker) assert block.local assert User.blocks?(blocker, blocked) @@ -324,7 +324,7 @@ defmodule Pleroma.Web.CommonAPITest do User.block(blocker, blocked) assert User.blocks?(blocker, blocked) - assert {:ok, :no_activity} == CommonAPI.unblock(blocker, blocked) + assert {:ok, :no_activity} == CommonAPI.unblock(blocked, blocker) refute User.blocks?(blocker, blocked) end end @@ -454,7 +454,7 @@ defmodule Pleroma.Web.CommonAPITest do users_serial |> Enum.map(fn user -> - CommonAPI.favorite(user, activity.id) + CommonAPI.favorite(activity.id, user) end) object = Object.get_by_ap_id(activity.data["object"]) @@ -463,7 +463,7 @@ defmodule Pleroma.Web.CommonAPITest do users |> Enum.map(fn user -> Task.async(fn -> - CommonAPI.favorite(user, activity.id) + CommonAPI.favorite(activity.id, user) end) end) |> Enum.map(&Task.await/1) @@ -955,7 +955,7 @@ defmodule Pleroma.Web.CommonAPITest do test "author can repeat own private statuses" do author = insert(:user) follower = insert(:user) - CommonAPI.follow(follower, author) + CommonAPI.follow(author, follower) {:ok, activity} = CommonAPI.post(author, %{status: "cofe", visibility: "private"}) @@ -974,7 +974,7 @@ defmodule Pleroma.Web.CommonAPITest do {:ok, post_activity} = CommonAPI.post(other_user, %{status: "cofe"}) - {:ok, %Activity{data: data}} = CommonAPI.favorite(user, post_activity.id) + {:ok, %Activity{data: data}} = CommonAPI.favorite(post_activity.id, user) assert data["type"] == "Like" assert data["actor"] == user.ap_id assert data["object"] == post_activity.data["object"] @@ -994,8 +994,8 @@ defmodule Pleroma.Web.CommonAPITest do other_user = insert(:user) {:ok, activity} = CommonAPI.post(other_user, %{status: "cofe"}) - {:ok, %Activity{}} = CommonAPI.favorite(user, activity.id) - assert {:ok, :already_liked} = CommonAPI.favorite(user, activity.id) + {:ok, %Activity{}} = CommonAPI.favorite(activity.id, user) + assert {:ok, :already_liked} = CommonAPI.favorite(activity.id, user) end end @@ -1149,7 +1149,7 @@ defmodule Pleroma.Web.CommonAPITest do } ) - {:ok, favorite_activity} = CommonAPI.favorite(friend2, activity.id) + {:ok, favorite_activity} = CommonAPI.favorite(activity.id, friend2) {:ok, repeat_activity} = CommonAPI.repeat(activity.id, friend1) assert Repo.aggregate( @@ -1172,8 +1172,8 @@ defmodule Pleroma.Web.CommonAPITest do n.type == "mention" && n.activity_id == reply_activity.id end) - {:ok, _} = CommonAPI.add_mute(author, activity) - assert CommonAPI.thread_muted?(author, activity) + {:ok, _} = CommonAPI.add_mute(activity, author) + assert CommonAPI.thread_muted?(activity, author) assert Repo.aggregate( from(n in Notification, where: n.seen == false and n.user_id == ^friend1.id), @@ -1197,13 +1197,13 @@ defmodule Pleroma.Web.CommonAPITest do end test "add mute", %{user: user, activity: activity} do - {:ok, _} = CommonAPI.add_mute(user, activity) - assert CommonAPI.thread_muted?(user, activity) + {:ok, _} = CommonAPI.add_mute(activity, user) + assert CommonAPI.thread_muted?(activity, user) end test "add expiring mute", %{user: user, activity: activity} do - {:ok, _} = CommonAPI.add_mute(user, activity, %{expires_in: 60}) - assert CommonAPI.thread_muted?(user, activity) + {:ok, _} = CommonAPI.add_mute(activity, user, %{expires_in: 60}) + assert CommonAPI.thread_muted?(activity, user) worker = Pleroma.Workers.MuteExpireWorker args = %{"op" => "unmute_conversation", "user_id" => user.id, "activity_id" => activity.id} @@ -1214,24 +1214,24 @@ defmodule Pleroma.Web.CommonAPITest do ) assert :ok = perform_job(worker, args) - refute CommonAPI.thread_muted?(user, activity) + refute CommonAPI.thread_muted?(activity, user) end test "remove mute", %{user: user, activity: activity} do - CommonAPI.add_mute(user, activity) - {:ok, _} = CommonAPI.remove_mute(user, activity) - refute CommonAPI.thread_muted?(user, activity) + CommonAPI.add_mute(activity, user) + {:ok, _} = CommonAPI.remove_mute(activity, user) + refute CommonAPI.thread_muted?(activity, user) end test "remove mute by ids", %{user: user, activity: activity} do - CommonAPI.add_mute(user, activity) - {:ok, _} = CommonAPI.remove_mute(user.id, activity.id) - refute CommonAPI.thread_muted?(user, activity) + CommonAPI.add_mute(activity, user) + {:ok, _} = CommonAPI.remove_mute(activity.id, user.id) + refute CommonAPI.thread_muted?(activity, user) end test "check that mutes can't be duplicate", %{user: user, activity: activity} do - CommonAPI.add_mute(user, activity) - {:error, _} = CommonAPI.add_mute(user, activity) + CommonAPI.add_mute(activity, user) + {:error, _} = CommonAPI.add_mute(activity, user) end end @@ -1404,14 +1404,14 @@ defmodule Pleroma.Web.CommonAPITest do end test "add a reblog mute", %{muter: muter, muted: muted} do - {:ok, _reblog_mute} = CommonAPI.hide_reblogs(muter, muted) + {:ok, _reblog_mute} = CommonAPI.hide_reblogs(muted, muter) assert User.showing_reblogs?(muter, muted) == false end test "remove a reblog mute", %{muter: muter, muted: muted} do - {:ok, _reblog_mute} = CommonAPI.hide_reblogs(muter, muted) - {:ok, _reblog_mute} = CommonAPI.show_reblogs(muter, muted) + {:ok, _reblog_mute} = CommonAPI.hide_reblogs(muted, muter) + {:ok, _reblog_mute} = CommonAPI.show_reblogs(muted, muter) assert User.showing_reblogs?(muter, muted) == true end @@ -1420,7 +1420,7 @@ defmodule Pleroma.Web.CommonAPITest do describe "follow/2" do test "directly follows a non-locked local user" do [follower, followed] = insert_pair(:user) - {:ok, follower, followed, _} = CommonAPI.follow(follower, followed) + {:ok, follower, followed, _} = CommonAPI.follow(followed, follower) assert User.following?(follower, followed) end @@ -1429,24 +1429,24 @@ defmodule Pleroma.Web.CommonAPITest do describe "unfollow/2" do test "also unsubscribes a user" do [follower, followed] = insert_pair(:user) - {:ok, follower, followed, _} = CommonAPI.follow(follower, followed) + {:ok, follower, followed, _} = CommonAPI.follow(followed, follower) {:ok, _subscription} = User.subscribe(follower, followed) 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 test "also unpins a user" do [follower, followed] = insert_pair(:user) - {:ok, follower, followed, _} = CommonAPI.follow(follower, followed) + {:ok, follower, followed, _} = CommonAPI.follow(followed, follower) {:ok, _endorsement} = User.endorse(follower, followed) assert User.endorses?(follower, followed) - {:ok, follower} = CommonAPI.unfollow(follower, followed) + {:ok, follower} = CommonAPI.unfollow(followed, follower) refute User.endorses?(follower, followed) end @@ -1456,10 +1456,10 @@ defmodule Pleroma.Web.CommonAPITest do followed = insert(:user, is_locked: true) assert {:ok, follower, followed, %{id: activity_id, data: %{"state" => "pending"}}} = - CommonAPI.follow(follower, followed) + 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"}} = @@ -1478,10 +1478,10 @@ defmodule Pleroma.Web.CommonAPITest do followed = insert(:user, is_locked: true, local: false) assert {:ok, follower, followed, %{id: activity_id, data: %{"state" => "pending"}}} = - CommonAPI.follow(follower, followed) + 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"}} = @@ -1502,9 +1502,9 @@ defmodule Pleroma.Web.CommonAPITest do follower = insert(:user) follower_two = insert(:user) - {:ok, _, _, follow_activity} = CommonAPI.follow(follower, user) - {:ok, _, _, follow_activity_two} = CommonAPI.follow(follower, user) - {:ok, _, _, follow_activity_three} = CommonAPI.follow(follower_two, user) + {:ok, _, _, follow_activity} = CommonAPI.follow(user, follower) + {:ok, _, _, follow_activity_two} = CommonAPI.follow(user, follower) + {:ok, _, _, follow_activity_three} = CommonAPI.follow(user, follower_two) assert follow_activity.data["state"] == "pending" assert follow_activity_two.data["state"] == "pending" @@ -1522,9 +1522,9 @@ defmodule Pleroma.Web.CommonAPITest do follower = insert(:user) follower_two = insert(:user) - {:ok, _, _, follow_activity} = CommonAPI.follow(follower, user) - {:ok, _, _, follow_activity_two} = CommonAPI.follow(follower, user) - {:ok, _, _, follow_activity_three} = CommonAPI.follow(follower_two, user) + {:ok, _, _, follow_activity} = CommonAPI.follow(user, follower) + {:ok, _, _, follow_activity_two} = CommonAPI.follow(user, follower) + {:ok, _, _, follow_activity_three} = CommonAPI.follow(user, follower_two) assert follow_activity.data["state"] == "pending" assert follow_activity_two.data["state"] == "pending" @@ -1559,9 +1559,9 @@ defmodule Pleroma.Web.CommonAPITest do object = Object.normalize(activity, fetch: false) - {:ok, _, object} = CommonAPI.vote(other_user, object, [0]) + {:ok, _, object} = CommonAPI.vote(object, other_user, [0]) - assert {:error, "Already voted"} == CommonAPI.vote(other_user, object, [1]) + assert {:error, "Already voted"} == CommonAPI.vote(object, other_user, [1]) end end @@ -1695,7 +1695,7 @@ defmodule Pleroma.Web.CommonAPITest do with_mock Pleroma.Web.Federator, publish: fn _ -> :ok end do assert {:ok, %Activity{data: %{"type" => "Like"}} = activity} = - CommonAPI.favorite(user, activity.id) + CommonAPI.favorite(activity.id, user) assert Visibility.local_public?(activity) refute called(Pleroma.Web.Federator.publish(activity)) @@ -1708,7 +1708,7 @@ defmodule Pleroma.Web.CommonAPITest do {:ok, activity} = CommonAPI.post(other_user, %{status: "cofe", visibility: "local"}) - {:ok, %Activity{}} = CommonAPI.favorite(user, activity.id) + {:ok, %Activity{}} = CommonAPI.favorite(activity.id, user) with_mock Pleroma.Web.Federator, publish: fn _ -> :ok end do assert {:ok, activity} = CommonAPI.unfavorite(activity.id, user) @@ -1753,7 +1753,7 @@ defmodule Pleroma.Web.CommonAPITest do user = insert(:user) {:ok, activity} = CommonAPI.post(user, %{status: "foo1", spoiler_text: "title 1"}) - {:ok, updated} = CommonAPI.update(user, activity, %{status: "updated 2"}) + {:ok, updated} = CommonAPI.update(activity, user, %{status: "updated 2"}) updated_object = Object.normalize(updated) assert updated_object.data["content"] == "updated 2" @@ -1767,7 +1767,7 @@ defmodule Pleroma.Web.CommonAPITest do {:ok, activity} = CommonAPI.post(user, %{status: "foo1", spoiler_text: "title 1", visibility: "private"}) - {:ok, updated} = CommonAPI.update(user, activity, %{status: "updated 2"}) + {:ok, updated} = CommonAPI.update(activity, user, %{status: "updated 2"}) updated_object = Object.normalize(updated) assert updated_object.data["content"] == "updated 2" @@ -1784,7 +1784,7 @@ defmodule Pleroma.Web.CommonAPITest do {:ok, activity} = CommonAPI.post(user, %{status: "foo1", spoiler_text: "title 1 :#{emoji1}:"}) - {:ok, updated} = CommonAPI.update(user, activity, %{status: "updated 2 :#{emoji2}:"}) + {:ok, updated} = CommonAPI.update(activity, user, %{status: "updated 2 :#{emoji2}:"}) updated_object = Object.normalize(updated) assert updated_object.data["content"] == "updated 2 :#{emoji2}:" @@ -1803,7 +1803,7 @@ defmodule Pleroma.Web.CommonAPITest do with_mock Pleroma.Web.Federator, publish: fn _p -> nil end do - {:ok, updated} = CommonAPI.update(user, activity, %{status: "updated 2 :#{emoji2}:"}) + {:ok, updated} = CommonAPI.update(activity, user, %{status: "updated 2 :#{emoji2}:"}) assert updated.data["object"]["content"] == "updated 2 :#{emoji2}:" assert %{^emoji2 => _} = updated.data["object"]["emoji"] @@ -1847,7 +1847,7 @@ defmodule Pleroma.Web.CommonAPITest do assert reply.object.data["emoji"]["remoteemoji"] == remote_emoji_uri {:ok, edit} = - CommonAPI.update(user, reply, %{status: "reply mew mew", spoiler_text: ":remoteemoji:"}) + CommonAPI.update(reply, user, %{status: "reply mew mew", spoiler_text: ":remoteemoji:"}) edited_note = Pleroma.Object.normalize(edit) @@ -1863,7 +1863,7 @@ defmodule Pleroma.Web.CommonAPITest do {:ok, activity} = CommonAPI.post(user, %{status: "foo1", spoiler_text: "updated 1"}) assert Object.normalize(activity).data["summary"] == "mewmew 1" - {:ok, updated} = CommonAPI.update(user, activity, %{status: "updated 2"}) + {:ok, updated} = CommonAPI.update(activity, user, %{status: "updated 2"}) updated_object = Object.normalize(updated) assert updated_object.data["content"] == "mewmew 2" @@ -1914,7 +1914,7 @@ defmodule Pleroma.Web.CommonAPITest do end test "it does not boost if group is blocking poster", %{poster: poster, group: group} do - {:ok, _} = CommonAPI.block(group, poster) + {:ok, _} = CommonAPI.block(poster, group) {:ok, post} = CommonAPI.post(poster, %{status: "hey @#{group.nickname}"}) announces = get_announces_of_object(post.object) @@ -2002,7 +2002,7 @@ defmodule Pleroma.Web.CommonAPITest do CommonAPI.post(remote_user, %{status: "I like turtles!"}) {:ok, %{data: %{"id" => ap_id}} = _favorite} = - CommonAPI.favorite(local_user, activity.id) + CommonAPI.favorite(activity.id, local_user) # Generate the publish_one jobs ObanHelpers.perform_all() diff --git a/test/pleroma/web/mastodon_api/controllers/account_controller_test.exs b/test/pleroma/web/mastodon_api/controllers/account_controller_test.exs index e87b33960..54f6818bd 100644 --- a/test/pleroma/web/mastodon_api/controllers/account_controller_test.exs +++ b/test/pleroma/web/mastodon_api/controllers/account_controller_test.exs @@ -1120,7 +1120,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do |> json_response_and_validate_schema(200) # Follow the user, then the pinned status can be seen - CommonAPI.follow(reader, user) + CommonAPI.follow(user, reader) ObanHelpers.perform_all() assert [%{"id" => ^activity_id, "pinned" => true}] = @@ -2118,7 +2118,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do test "pin account", %{user: user, conn: conn} do %{id: id1} = other_user1 = insert(:user) - CommonAPI.follow(user, other_user1) + CommonAPI.follow(other_user1, user) assert %{"id" => ^id1, "endorsed" => true} = conn @@ -2136,7 +2136,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do test "unpin account", %{user: user, conn: conn} do %{id: id1} = other_user1 = insert(:user) - CommonAPI.follow(user, other_user1) + CommonAPI.follow(other_user1, user) User.endorse(user, other_user1) assert %{"id" => ^id1, "endorsed" => false} = @@ -2156,8 +2156,8 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do %{id: id1} = other_user1 = insert(:user) %{id: id2} = other_user2 = insert(:user) - CommonAPI.follow(user, other_user1) - CommonAPI.follow(user, other_user2) + CommonAPI.follow(other_user1, user) + CommonAPI.follow(other_user2, user) conn |> put_req_header("content-type", "application/json") @@ -2227,7 +2227,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do test "removing user from followers", %{conn: conn, user: user} do %{id: other_user_id} = other_user = insert(:user) - CommonAPI.follow(other_user, user) + CommonAPI.follow(user, other_user) assert %{"id" => ^other_user_id, "followed_by" => false} = conn @@ -2240,7 +2240,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do test "removing remote user from followers", %{conn: conn, user: user} do %{id: other_user_id} = other_user = insert(:user, local: false) - CommonAPI.follow(other_user, user) + CommonAPI.follow(user, other_user) assert User.following?(other_user, user) diff --git a/test/pleroma/web/mastodon_api/controllers/follow_request_controller_test.exs b/test/pleroma/web/mastodon_api/controllers/follow_request_controller_test.exs index ff01b549c..b7c7ccae0 100644 --- a/test/pleroma/web/mastodon_api/controllers/follow_request_controller_test.exs +++ b/test/pleroma/web/mastodon_api/controllers/follow_request_controller_test.exs @@ -20,7 +20,7 @@ defmodule Pleroma.Web.MastodonAPI.FollowRequestControllerTest do test "/api/v1/follow_requests works", %{user: user, conn: conn} do other_user = insert(:user) - {:ok, _, _, _activity} = CommonAPI.follow(other_user, user) + {:ok, _, _, _activity} = CommonAPI.follow(user, other_user) {:ok, other_user, user} = User.follow(other_user, user, :follow_pending) assert User.following?(other_user, user) == false @@ -34,7 +34,7 @@ defmodule Pleroma.Web.MastodonAPI.FollowRequestControllerTest do test "/api/v1/follow_requests/:id/authorize works", %{user: user, conn: conn} do other_user = insert(:user) - {:ok, _, _, _activity} = CommonAPI.follow(other_user, user) + {:ok, _, _, _activity} = CommonAPI.follow(user, other_user) {:ok, other_user, user} = User.follow(other_user, user, :follow_pending) user = User.get_cached_by_id(user.id) @@ -56,7 +56,7 @@ defmodule Pleroma.Web.MastodonAPI.FollowRequestControllerTest do test "/api/v1/follow_requests/:id/reject works", %{user: user, conn: conn} do other_user = insert(:user) - {:ok, _, _, _activity} = CommonAPI.follow(other_user, user) + {:ok, _, _, _activity} = CommonAPI.follow(user, other_user) user = User.get_cached_by_id(user.id) diff --git a/test/pleroma/web/mastodon_api/controllers/notification_controller_test.exs b/test/pleroma/web/mastodon_api/controllers/notification_controller_test.exs index 350b935d7..8fc22dde1 100644 --- a/test/pleroma/web/mastodon_api/controllers/notification_controller_test.exs +++ b/test/pleroma/web/mastodon_api/controllers/notification_controller_test.exs @@ -148,7 +148,7 @@ defmodule Pleroma.Web.MastodonAPI.NotificationControllerTest do %{user: user, conn: conn} = oauth_access(["read:notifications"]) blocker = insert(:user) - {:ok, _} = CommonAPI.block(blocker, user) + {:ok, _} = CommonAPI.block(user, blocker) {:ok, activity} = CommonAPI.post(blocker, %{status: "hi @#{user.nickname}"}) {:ok, [_notification]} = Notification.create_notifications(activity) @@ -326,10 +326,10 @@ defmodule Pleroma.Web.MastodonAPI.NotificationControllerTest do {:ok, private_activity} = CommonAPI.post(other_user, %{status: ".", visibility: "private"}) - {:ok, _} = CommonAPI.favorite(user, public_activity.id) - {:ok, _} = CommonAPI.favorite(user, direct_activity.id) - {:ok, _} = CommonAPI.favorite(user, unlisted_activity.id) - {:ok, _} = CommonAPI.favorite(user, private_activity.id) + {:ok, _} = CommonAPI.favorite(public_activity.id, user) + {:ok, _} = CommonAPI.favorite(direct_activity.id, user) + {:ok, _} = CommonAPI.favorite(unlisted_activity.id, user) + {:ok, _} = CommonAPI.favorite(private_activity.id, user) activity_ids = conn @@ -414,7 +414,7 @@ defmodule Pleroma.Web.MastodonAPI.NotificationControllerTest do in_reply_to_status_id: activity.id }) - {:ok, _favorite} = CommonAPI.favorite(user, reply.id) + {:ok, _favorite} = CommonAPI.favorite(reply.id, user) activity_ids = conn @@ -432,9 +432,9 @@ defmodule Pleroma.Web.MastodonAPI.NotificationControllerTest do {:ok, mention_activity} = CommonAPI.post(other_user, %{status: "hey @#{user.nickname}"}) {:ok, create_activity} = CommonAPI.post(user, %{status: "hey"}) - {:ok, favorite_activity} = CommonAPI.favorite(other_user, create_activity.id) + {:ok, favorite_activity} = CommonAPI.favorite(create_activity.id, other_user) {:ok, reblog_activity} = CommonAPI.repeat(create_activity.id, other_user) - {:ok, _, _, follow_activity} = CommonAPI.follow(other_user, user) + {:ok, _, _, follow_activity} = CommonAPI.follow(user, other_user) mention_notification_id = get_notification_id_by_activity(mention_activity) favorite_notification_id = get_notification_id_by_activity(favorite_activity) @@ -470,9 +470,9 @@ defmodule Pleroma.Web.MastodonAPI.NotificationControllerTest do {:ok, mention_activity} = CommonAPI.post(other_user, %{status: "hey @#{user.nickname}"}) {:ok, create_activity} = CommonAPI.post(user, %{status: "hey"}) - {:ok, favorite_activity} = CommonAPI.favorite(other_user, create_activity.id) + {:ok, favorite_activity} = CommonAPI.favorite(create_activity.id, other_user) {:ok, reblog_activity} = CommonAPI.repeat(create_activity.id, other_user) - {:ok, _, _, follow_activity} = CommonAPI.follow(other_user, user) + {:ok, _, _, follow_activity} = CommonAPI.follow(user, other_user) mention_notification_id = get_notification_id_by_activity(mention_activity) favorite_notification_id = get_notification_id_by_activity(favorite_activity) @@ -517,9 +517,9 @@ defmodule Pleroma.Web.MastodonAPI.NotificationControllerTest do {:ok, _activity} = CommonAPI.post(other_user, %{status: "hey @#{user.nickname}"}) {:ok, create_activity} = CommonAPI.post(user, %{status: "hey"}) - {:ok, _activity} = CommonAPI.favorite(other_user, create_activity.id) + {:ok, _activity} = CommonAPI.favorite(create_activity.id, other_user) {:ok, _activity} = CommonAPI.repeat(create_activity.id, other_user) - {:ok, _, _, follow_activity} = CommonAPI.follow(other_user, user) + {:ok, _, _, follow_activity} = CommonAPI.follow(user, other_user) follow_notification_id = get_notification_id_by_activity(follow_activity) @@ -578,7 +578,7 @@ defmodule Pleroma.Web.MastodonAPI.NotificationControllerTest do %{user: user, conn: conn} = oauth_access(["read:notifications"]) user2 = insert(:user) - {:ok, _, _, _} = CommonAPI.follow(user, user2) + {:ok, _, _, _} = CommonAPI.follow(user2, user) {:ok, _} = CommonAPI.post(user2, %{status: "hey @#{user.nickname}"}) ret_conn = get(conn, "/api/v1/notifications") @@ -596,7 +596,7 @@ defmodule Pleroma.Web.MastodonAPI.NotificationControllerTest do %{user: user, conn: conn} = oauth_access(["read:notifications"]) user2 = insert(:user) - {:ok, _, _, _} = CommonAPI.follow(user, user2) + {:ok, _, _, _} = CommonAPI.follow(user2, user) {:ok, _} = CommonAPI.post(user2, %{status: "hey @#{user.nickname}"}) ret_conn = get(conn, "/api/v1/notifications") @@ -614,7 +614,7 @@ defmodule Pleroma.Web.MastodonAPI.NotificationControllerTest do %{user: user, conn: conn} = oauth_access(["read:notifications"]) user2 = insert(:user) - {:ok, _, _, _} = CommonAPI.follow(user, user2) + {:ok, _, _, _} = CommonAPI.follow(user2, user) {:ok, _} = CommonAPI.post(user2, %{status: "hey @#{user.nickname}"}) ret_conn = get(conn, "/api/v1/notifications") diff --git a/test/pleroma/web/mastodon_api/controllers/status_controller_test.exs b/test/pleroma/web/mastodon_api/controllers/status_controller_test.exs index f34911e5b..904bf1471 100644 --- a/test/pleroma/web/mastodon_api/controllers/status_controller_test.exs +++ b/test/pleroma/web/mastodon_api/controllers/status_controller_test.exs @@ -1356,7 +1356,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do user1 = insert(:user) user2 = insert(:user) user3 = insert(:user) - {:ok, _} = CommonAPI.favorite(user2, activity.id) + {:ok, _} = CommonAPI.favorite(activity.id, user2) {:ok, _bookmark} = Pleroma.Bookmark.create(user2.id, activity.id) {:ok, reblog_activity1} = CommonAPI.repeat(activity.id, user1) {:ok, _} = CommonAPI.repeat(activity.id, user2) @@ -1483,7 +1483,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do test "unfavorites a status and returns it", %{user: user, conn: conn} do activity = insert(:note_activity) - {:ok, _} = CommonAPI.favorite(user, activity.id) + {:ok, _} = CommonAPI.favorite(activity.id, user) conn = conn @@ -1771,7 +1771,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do end test "cannot mute already muted conversation", %{conn: conn, user: user, activity: activity} do - {:ok, _} = CommonAPI.add_mute(user, activity) + {:ok, _} = CommonAPI.add_mute(activity, user) conn = conn @@ -1784,7 +1784,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do end test "unmute conversation", %{conn: conn, user: user, activity: activity} do - {:ok, _} = CommonAPI.add_mute(user, activity) + {:ok, _} = CommonAPI.add_mute(activity, user) id_str = to_string(activity.id) @@ -1859,7 +1859,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do test "returns users who have favorited the status", %{conn: conn, activity: activity} do other_user = insert(:user) - {:ok, _} = CommonAPI.favorite(other_user, activity.id) + {:ok, _} = CommonAPI.favorite(activity.id, other_user) response = conn @@ -1890,7 +1890,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do other_user = insert(:user) {:ok, _user_relationship} = User.block(user, other_user) - {:ok, _} = CommonAPI.favorite(other_user, activity.id) + {:ok, _} = CommonAPI.favorite(activity.id, other_user) response = conn @@ -1902,7 +1902,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do test "does not fail on an unauthenticated request", %{activity: activity} do other_user = insert(:user) - {:ok, _} = CommonAPI.favorite(other_user, activity.id) + {:ok, _} = CommonAPI.favorite(activity.id, other_user) response = build_conn() @@ -1922,7 +1922,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do visibility: "direct" }) - {:ok, _} = CommonAPI.favorite(other_user, activity.id) + {:ok, _} = CommonAPI.favorite(activity.id, other_user) favourited_by_url = "/api/v1/statuses/#{activity.id}/favourited_by" @@ -1953,7 +1953,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do clear_config([:instance, :show_reactions], false) other_user = insert(:user) - {:ok, _} = CommonAPI.favorite(other_user, activity.id) + {:ok, _} = CommonAPI.favorite(activity.id, other_user) response = conn @@ -2096,9 +2096,9 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do {:ok, second_post} = CommonAPI.post(other_user, %{status: "bla"}) {:ok, third_post} = CommonAPI.post(other_user, %{status: "bla"}) - {:ok, _first_favorite} = CommonAPI.favorite(user, third_post.id) - {:ok, _second_favorite} = CommonAPI.favorite(user, first_post.id) - {:ok, third_favorite} = CommonAPI.favorite(user, second_post.id) + {:ok, _first_favorite} = CommonAPI.favorite(third_post.id, user) + {:ok, _second_favorite} = CommonAPI.favorite(first_post.id, user) + {:ok, third_favorite} = CommonAPI.favorite(second_post.id, user) result = conn @@ -2134,7 +2134,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do {:ok, _} = CommonAPI.post(other_user, %{status: "bla"}) {:ok, activity} = CommonAPI.post(other_user, %{status: "trees are happy"}) - {:ok, last_like} = CommonAPI.favorite(user, activity.id) + {:ok, last_like} = CommonAPI.favorite(activity.id, user) first_conn = get(conn, "/api/v1/favourites") @@ -2150,7 +2150,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do status: "Trees Are Never Sad Look At Them Every Once In Awhile They're Quite Beautiful." }) - {:ok, _} = CommonAPI.favorite(user, second_activity.id) + {:ok, _} = CommonAPI.favorite(second_activity.id, user) second_conn = get(conn, "/api/v1/favourites?since_id=#{last_like.id}") diff --git a/test/pleroma/web/mastodon_api/controllers/suggestion_controller_test.exs b/test/pleroma/web/mastodon_api/controllers/suggestion_controller_test.exs index c0f3d5a2a..01c3384e7 100644 --- a/test/pleroma/web/mastodon_api/controllers/suggestion_controller_test.exs +++ b/test/pleroma/web/mastodon_api/controllers/suggestion_controller_test.exs @@ -47,7 +47,7 @@ defmodule Pleroma.Web.MastodonAPI.SuggestionControllerTest do test "returns v2 suggestions excluding blocked accounts", %{conn: conn, user: blocker} do blocked = insert(:user, is_suggested: true) - {:ok, _} = CommonAPI.block(blocker, blocked) + {:ok, _} = CommonAPI.block(blocked, blocker) res = conn @@ -59,7 +59,7 @@ defmodule Pleroma.Web.MastodonAPI.SuggestionControllerTest do test "returns v2 suggestions excluding followed accounts", %{conn: conn, user: follower} do followed = insert(:user, is_suggested: true) - {:ok, _, _, _} = CommonAPI.follow(follower, followed) + {:ok, _, _, _} = CommonAPI.follow(followed, follower) res = conn diff --git a/test/pleroma/web/mastodon_api/views/account_view_test.exs b/test/pleroma/web/mastodon_api/views/account_view_test.exs index 8dcdaf447..f0711fa0d 100644 --- a/test/pleroma/web/mastodon_api/views/account_view_test.exs +++ b/test/pleroma/web/mastodon_api/views/account_view_test.exs @@ -436,7 +436,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do {:ok, other_user, user} = User.follow(other_user, user) {:ok, _subscription} = User.subscribe(user, other_user) {:ok, _user_relationships} = User.mute(user, other_user, %{notifications: true}) - {:ok, _reblog_mute} = CommonAPI.hide_reblogs(user, other_user) + {:ok, _reblog_mute} = CommonAPI.hide_reblogs(other_user, user) expected = Map.merge( @@ -493,7 +493,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do user = insert(:user) other_user = insert(:user, is_locked: true) - {:ok, user, other_user, _} = CommonAPI.follow(user, other_user) + {:ok, user, other_user, _} = CommonAPI.follow(other_user, user) user = User.get_cached_by_id(user.id) other_user = User.get_cached_by_id(other_user.id) @@ -547,8 +547,8 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do }) other_user = insert(:user) - {:ok, user, other_user, _activity} = CommonAPI.follow(user, other_user) - {:ok, _other_user, user, _activity} = CommonAPI.follow(other_user, user) + {:ok, user, other_user, _activity} = CommonAPI.follow(other_user, user) + {:ok, _other_user, user, _activity} = CommonAPI.follow(user, other_user) assert %{ followers_count: 0, @@ -560,8 +560,8 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do test "shows when follows/followers are hidden" do user = insert(:user, hide_followers: true, hide_follows: true) other_user = insert(:user) - {:ok, user, other_user, _activity} = CommonAPI.follow(user, other_user) - {:ok, _other_user, user, _activity} = CommonAPI.follow(other_user, user) + {:ok, user, other_user, _activity} = CommonAPI.follow(other_user, user) + {:ok, _other_user, user, _activity} = CommonAPI.follow(user, other_user) assert %{ followers_count: 1, @@ -573,11 +573,11 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do test "shows actual follower/following count to the account owner" do user = insert(:user, hide_followers: true, hide_follows: true) other_user = insert(:user) - {:ok, user, other_user, _activity} = CommonAPI.follow(user, other_user) + {:ok, user, other_user, _activity} = CommonAPI.follow(other_user, user) assert User.following?(user, other_user) assert Pleroma.FollowingRelationship.follower_count(other_user) == 1 - {:ok, _other_user, user, _activity} = CommonAPI.follow(other_user, user) + {:ok, _other_user, user, _activity} = CommonAPI.follow(user, other_user) assert %{ followers_count: 1, @@ -684,7 +684,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do AccountView.render("show.json", %{user: user, for: user}) other_user = insert(:user) - {:ok, _other_user, user, _activity} = CommonAPI.follow(other_user, user) + {:ok, _other_user, user, _activity} = CommonAPI.follow(user, other_user) assert %{follow_requests_count: 0} = AccountView.render("show.json", %{user: user, for: user}) @@ -696,7 +696,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do assert %{locked: true} = AccountView.render("show.json", %{user: user, for: user}) other_user = insert(:user) - {:ok, _other_user, user, _activity} = CommonAPI.follow(other_user, user) + {:ok, _other_user, user, _activity} = CommonAPI.follow(user, other_user) assert %{locked: true, follow_requests_count: 1} = AccountView.render("show.json", %{user: user, for: user}) @@ -708,7 +708,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do assert %{locked: true} = AccountView.render("show.json", %{user: user, for: user}) other_user = insert(:user) - {:ok, other_user, user, _activity} = CommonAPI.follow(other_user, user) + {:ok, other_user, user, _activity} = CommonAPI.follow(user, other_user) assert %{locked: true, follow_requests_count: 1} = AccountView.render("show.json", %{user: user, for: user}) @@ -725,7 +725,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do assert %{locked: true} = AccountView.render("show.json", %{user: user, for: user}) other_user = insert(:user) - {:ok, other_user, user, _activity} = CommonAPI.follow(other_user, user) + {:ok, other_user, user, _activity} = CommonAPI.follow(user, other_user) assert %{locked: true, follow_requests_count: 1} = AccountView.render("show.json", %{user: user, for: user}) @@ -742,7 +742,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do assert %{locked: true} = AccountView.render("show.json", %{user: user, for: user}) other_user = insert(:user) - {:ok, _other_user, user, _activity} = CommonAPI.follow(other_user, user) + {:ok, _other_user, user, _activity} = CommonAPI.follow(user, other_user) {:ok, user} = User.update_and_set_cache(user, %{is_locked: false}) diff --git a/test/pleroma/web/mastodon_api/views/notification_view_test.exs b/test/pleroma/web/mastodon_api/views/notification_view_test.exs index 9896f81b6..fae672871 100644 --- a/test/pleroma/web/mastodon_api/views/notification_view_test.exs +++ b/test/pleroma/web/mastodon_api/views/notification_view_test.exs @@ -93,7 +93,7 @@ defmodule Pleroma.Web.MastodonAPI.NotificationViewTest do user = insert(:user) another_user = insert(:user) {:ok, create_activity} = CommonAPI.post(user, %{status: "hey"}) - {:ok, favorite_activity} = CommonAPI.favorite(another_user, create_activity.id) + {:ok, favorite_activity} = CommonAPI.favorite(create_activity.id, another_user) {:ok, [notification]} = Notification.create_notifications(favorite_activity) create_activity = Activity.get_by_id(create_activity.id) @@ -132,7 +132,7 @@ defmodule Pleroma.Web.MastodonAPI.NotificationViewTest do test "Follow notification" do follower = insert(:user) followed = insert(:user) - {:ok, follower, followed, _activity} = CommonAPI.follow(follower, followed) + {:ok, follower, followed, _activity} = CommonAPI.follow(followed, follower) notification = Notification |> Repo.one() |> Repo.preload(:activity) expected = %{ @@ -290,7 +290,7 @@ defmodule Pleroma.Web.MastodonAPI.NotificationViewTest do {:ok, activity} = CommonAPI.post(user, %{status: "mew"}) {:ok, _} = CommonAPI.repeat(activity.id, repeat_user) - {:ok, update} = CommonAPI.update(user, activity, %{status: "mew mew"}) + {:ok, update} = CommonAPI.update(activity, user, %{status: "mew mew"}) user = Pleroma.User.get_by_ap_id(user.ap_id) activity = Pleroma.Activity.normalize(activity) @@ -316,7 +316,7 @@ defmodule Pleroma.Web.MastodonAPI.NotificationViewTest do {:ok, _} = Pleroma.UserRelationship.create_mute(user, another_user) {:ok, create_activity} = CommonAPI.post(user, %{status: "hey"}) - {:ok, favorite_activity} = CommonAPI.favorite(another_user, create_activity.id) + {:ok, favorite_activity} = CommonAPI.favorite(create_activity.id, another_user) {:ok, [notification]} = Notification.create_notifications(favorite_activity) create_activity = Activity.get_by_id(create_activity.id) diff --git a/test/pleroma/web/mastodon_api/views/poll_view_test.exs b/test/pleroma/web/mastodon_api/views/poll_view_test.exs index 3aa73c224..6de001421 100644 --- a/test/pleroma/web/mastodon_api/views/poll_view_test.exs +++ b/test/pleroma/web/mastodon_api/views/poll_view_test.exs @@ -74,7 +74,7 @@ defmodule Pleroma.Web.MastodonAPI.PollViewTest do object = Object.normalize(activity, fetch: false) - {:ok, _votes, object} = CommonAPI.vote(voter, object, [0, 1]) + {:ok, _votes, object} = CommonAPI.vote(object, voter, [0, 1]) assert match?( %{ @@ -119,7 +119,7 @@ defmodule Pleroma.Web.MastodonAPI.PollViewTest do object = Object.normalize(activity, fetch: false) - {:ok, _, object} = CommonAPI.vote(other_user, object, [1, 2]) + {:ok, _, object} = CommonAPI.vote(object, other_user, [1, 2]) result = PollView.render("show.json", %{object: object, for: other_user}) diff --git a/test/pleroma/web/mastodon_api/views/status_view_test.exs b/test/pleroma/web/mastodon_api/views/status_view_test.exs index f42d9d1c6..afe0ccb28 100644 --- a/test/pleroma/web/mastodon_api/views/status_view_test.exs +++ b/test/pleroma/web/mastodon_api/views/status_view_test.exs @@ -388,7 +388,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do assert status.pleroma.thread_muted == false - {:ok, activity} = CommonAPI.add_mute(user, activity) + {:ok, activity} = CommonAPI.add_mute(activity, user) status = StatusView.render("show.json", %{activity: activity, for: user}) @@ -479,7 +479,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do # After following the user, the quote is rendered follower = insert(:user) - CommonAPI.follow(follower, user) + CommonAPI.follow(user, follower) status = StatusView.render("show.json", %{activity: quote_private, for: follower}) assert status.pleroma.quote.id == to_string(private.id) @@ -938,7 +938,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do status = StatusView.render("show.json", activity: post) refute status.edited_at - {:ok, _} = CommonAPI.update(poster, post, %{status: "mew mew"}) + {:ok, _} = CommonAPI.update(post, poster, %{status: "mew mew"}) edited = Pleroma.Activity.normalize(post) status = StatusView.render("show.json", activity: edited) diff --git a/test/pleroma/web/metadata/utils_test.exs b/test/pleroma/web/metadata/utils_test.exs index 9bc02dadf..f986d3fd5 100644 --- a/test/pleroma/web/metadata/utils_test.exs +++ b/test/pleroma/web/metadata/utils_test.exs @@ -81,7 +81,7 @@ defmodule Pleroma.Web.Metadata.UtilsTest do object = Pleroma.Object.normalize(activity) assert Utils.scrub_html_and_truncate(object) == "mew mew #def" - {:ok, update} = Pleroma.Web.CommonAPI.update(user, activity, %{status: "mew mew #abc"}) + {:ok, update} = Pleroma.Web.CommonAPI.update(activity, user, %{status: "mew mew #abc"}) update = Pleroma.Activity.normalize(update) object = Pleroma.Object.normalize(update) assert Utils.scrub_html_and_truncate(object) == "mew mew #abc" diff --git a/test/pleroma/web/o_status/o_status_controller_test.exs b/test/pleroma/web/o_status/o_status_controller_test.exs index 3e8fcd956..5387ec94e 100644 --- a/test/pleroma/web/o_status/o_status_controller_test.exs +++ b/test/pleroma/web/o_status/o_status_controller_test.exs @@ -186,7 +186,7 @@ defmodule Pleroma.Web.OStatus.OStatusControllerTest do user = insert(:user) - {:ok, like_activity} = CommonAPI.favorite(user, note_activity.id) + {:ok, like_activity} = CommonAPI.favorite(note_activity.id, user) assert like_activity.data["type"] == "Like" diff --git a/test/pleroma/web/pleroma_api/controllers/account_controller_test.exs b/test/pleroma/web/pleroma_api/controllers/account_controller_test.exs index 8f000760f..61880e2c0 100644 --- a/test/pleroma/web/pleroma_api/controllers/account_controller_test.exs +++ b/test/pleroma/web/pleroma_api/controllers/account_controller_test.exs @@ -78,7 +78,7 @@ defmodule Pleroma.Web.PleromaAPI.AccountControllerTest do user: user } do [activity | _] = insert_pair(:note_activity) - CommonAPI.favorite(user, activity.id) + CommonAPI.favorite(activity.id, user) response = conn @@ -95,7 +95,7 @@ defmodule Pleroma.Web.PleromaAPI.AccountControllerTest do user: user } do activity = insert(:note_activity) - CommonAPI.favorite(user, activity.id) + CommonAPI.favorite(activity.id, user) response = build_conn() @@ -115,7 +115,7 @@ defmodule Pleroma.Web.PleromaAPI.AccountControllerTest do visibility: "direct" }) - CommonAPI.favorite(user, direct.id) + CommonAPI.favorite(direct.id, user) for u <- [user, current_user] do response = @@ -148,7 +148,7 @@ defmodule Pleroma.Web.PleromaAPI.AccountControllerTest do visibility: "direct" }) - CommonAPI.favorite(user, direct.id) + CommonAPI.favorite(direct.id, user) response = conn @@ -165,7 +165,7 @@ defmodule Pleroma.Web.PleromaAPI.AccountControllerTest do activities = insert_list(10, :note_activity) Enum.each(activities, fn activity -> - CommonAPI.favorite(user, activity.id) + CommonAPI.favorite(activity.id, user) end) third_activity = Enum.at(activities, 2) @@ -190,7 +190,7 @@ defmodule Pleroma.Web.PleromaAPI.AccountControllerTest do 7 |> insert_list(:note_activity) |> Enum.each(fn activity -> - CommonAPI.favorite(user, activity.id) + CommonAPI.favorite(activity.id, user) end) response = @@ -222,7 +222,7 @@ defmodule Pleroma.Web.PleromaAPI.AccountControllerTest do test "returns 403 error when user has hidden own favorites", %{conn: conn} do user = insert(:user, hide_favorites: true) activity = insert(:note_activity) - CommonAPI.favorite(user, activity.id) + CommonAPI.favorite(activity.id, user) conn = get(conn, "/api/v1/pleroma/accounts/#{user.id}/favourites") @@ -232,7 +232,7 @@ defmodule Pleroma.Web.PleromaAPI.AccountControllerTest do test "hides favorites for new users by default", %{conn: conn} do user = insert(:user) activity = insert(:note_activity) - CommonAPI.favorite(user, activity.id) + CommonAPI.favorite(activity.id, user) assert user.hide_favorites conn = get(conn, "/api/v1/pleroma/accounts/#{user.id}/favourites") @@ -286,8 +286,8 @@ defmodule Pleroma.Web.PleromaAPI.AccountControllerTest do %{id: id2} = user2 = insert(:user) %{id: id3} = user3 = insert(:user) - CommonAPI.follow(user1, user2) - CommonAPI.follow(user1, user3) + CommonAPI.follow(user2, user1) + CommonAPI.follow(user3, user1) User.endorse(user1, user2) User.endorse(user1, user3) @@ -324,9 +324,9 @@ defmodule Pleroma.Web.PleromaAPI.AccountControllerTest do user3 = insert(:user) - CommonAPI.follow(user, user1) - CommonAPI.follow(user, user2) - CommonAPI.follow(user, user3) + CommonAPI.follow(user1, user) + CommonAPI.follow(user2, user) + CommonAPI.follow(user3, user) [%{"id" => ^id1}] = conn @@ -350,8 +350,8 @@ defmodule Pleroma.Web.PleromaAPI.AccountControllerTest do show_birthday: true }) - CommonAPI.follow(user, user1) - CommonAPI.follow(user, user2) + CommonAPI.follow(user1, user) + CommonAPI.follow(user2, user) [%{"id" => ^id2}] = conn diff --git a/test/pleroma/web/push/impl_test.exs b/test/pleroma/web/push/impl_test.exs index adaae93d0..ffc38dc80 100644 --- a/test/pleroma/web/push/impl_test.exs +++ b/test/pleroma/web/push/impl_test.exs @@ -78,7 +78,7 @@ defmodule Pleroma.Web.Push.ImplTest do ) other_user = insert(:user) - {:ok, _, _, activity} = CommonAPI.follow(user, other_user) + {:ok, _, _, activity} = CommonAPI.follow(other_user, user) notif = insert(:notification, @@ -103,7 +103,7 @@ defmodule Pleroma.Web.Push.ImplTest do ) other_user = insert(:user) - {:ok, _, _, activity} = CommonAPI.follow(user, other_user) + {:ok, _, _, activity} = CommonAPI.follow(other_user, user) notif = insert(:notification, @@ -154,7 +154,7 @@ defmodule Pleroma.Web.Push.ImplTest do test "renders title and body for follow activity" do user = insert(:user, nickname: "Bob") other_user = insert(:user) - {:ok, _, _, activity} = CommonAPI.follow(user, other_user) + {:ok, _, _, activity} = CommonAPI.follow(other_user, user) object = Object.normalize(activity, fetch: false) assert Impl.format_body(%{activity: activity, type: "follow"}, user, object) == @@ -192,7 +192,7 @@ defmodule Pleroma.Web.Push.ImplTest do "Lorem ipsum dolor sit amet, consectetur :firefox: adipiscing elit. Fusce sagittis finibus turpis." }) - {:ok, activity} = CommonAPI.favorite(user, activity.id) + {:ok, activity} = CommonAPI.favorite(activity.id, user) object = Object.normalize(activity, fetch: false) assert Impl.format_body(%{activity: activity, type: "favourite"}, user, object) == @@ -225,7 +225,7 @@ defmodule Pleroma.Web.Push.ImplTest do {:ok, activity} = CommonAPI.post(user, %{status: "lorem ipsum"}) - {:ok, activity} = CommonAPI.update(user, activity, %{status: "edited status"}) + {:ok, activity} = CommonAPI.update(activity, user, %{status: "edited status"}) object = Object.normalize(activity, fetch: false) assert Impl.format_body(%{activity: activity, type: "update"}, user, object) == @@ -351,7 +351,7 @@ defmodule Pleroma.Web.Push.ImplTest do body: "New Mention" } - {:ok, activity} = CommonAPI.favorite(user, activity.id) + {:ok, activity} = CommonAPI.favorite(activity.id, user) notif = insert(:notification, user: user2, activity: activity, type: "favourite") @@ -408,7 +408,7 @@ defmodule Pleroma.Web.Push.ImplTest do title: "New Mention" } - {:ok, activity} = CommonAPI.favorite(user, activity.id) + {:ok, activity} = CommonAPI.favorite(activity.id, user) notif = insert(:notification, user: user2, activity: activity, type: "favourite") diff --git a/test/pleroma/web/rich_media/card_test.exs b/test/pleroma/web/rich_media/card_test.exs index 9541627c1..387defc8c 100644 --- a/test/pleroma/web/rich_media/card_test.exs +++ b/test/pleroma/web/rich_media/card_test.exs @@ -70,7 +70,7 @@ defmodule Pleroma.Web.RichMedia.CardTest do Card.get_by_activity(activity) ) - {:ok, _} = CommonAPI.update(user, activity, %{status: "I like this site #{updated_url}"}) + {:ok, _} = CommonAPI.update(activity, user, %{status: "I like this site #{updated_url}"}) activity = Pleroma.Activity.get_by_id(activity.id) diff --git a/test/pleroma/web/streamer_test.exs b/test/pleroma/web/streamer_test.exs index d85358fd4..262ff11d2 100644 --- a/test/pleroma/web/streamer_test.exs +++ b/test/pleroma/web/streamer_test.exs @@ -418,7 +418,7 @@ defmodule Pleroma.Web.StreamerTest do Streamer.get_topic_and_add_socket("user:notification", user, oauth_token) {:ok, activity} = CommonAPI.post(user, %{status: ":("}) - {:ok, _} = CommonAPI.favorite(blocked, activity.id) + {:ok, _} = CommonAPI.favorite(activity.id, blocked) refute_receive _ end @@ -430,11 +430,11 @@ defmodule Pleroma.Web.StreamerTest do user2 = insert(:user) {:ok, activity} = CommonAPI.post(user, %{status: "super hot take"}) - {:ok, _} = CommonAPI.add_mute(user, activity) + {:ok, _} = CommonAPI.add_mute(activity, user) Streamer.get_topic_and_add_socket("user:notification", user, oauth_token) - {:ok, favorite_activity} = CommonAPI.favorite(user2, activity.id) + {:ok, favorite_activity} = CommonAPI.favorite(activity.id, user2) refute_receive _ assert Streamer.filtered_by_user?(user, favorite_activity) @@ -448,7 +448,7 @@ defmodule Pleroma.Web.StreamerTest do {:ok, activity} = CommonAPI.post(user, %{status: "super hot take"}) Streamer.get_topic_and_add_socket("user:notification", user, oauth_token) - {:ok, favorite_activity} = CommonAPI.favorite(user2, activity.id) + {:ok, favorite_activity} = CommonAPI.favorite(activity.id, user2) assert_receive {:render_with_user, _, "notification.json", notif, _} assert notif.activity.id == favorite_activity.id @@ -464,7 +464,7 @@ defmodule Pleroma.Web.StreamerTest do {:ok, user} = User.block_domain(user, "hecking-lewd-place.com") {:ok, activity} = CommonAPI.post(user, %{status: "super hot take"}) Streamer.get_topic_and_add_socket("user:notification", user, oauth_token) - {:ok, favorite_activity} = CommonAPI.favorite(user2, activity.id) + {:ok, favorite_activity} = CommonAPI.favorite(activity.id, user2) refute_receive _ assert Streamer.filtered_by_user?(user, favorite_activity) @@ -477,7 +477,7 @@ defmodule Pleroma.Web.StreamerTest do user2 = insert(:user) Streamer.get_topic_and_add_socket("user:notification", user, oauth_token) - {:ok, _follower, _followed, follow_activity} = CommonAPI.follow(user2, user) + {:ok, _follower, _followed, follow_activity} = CommonAPI.follow(user, user2) assert_receive {:render_with_user, _, "notification.json", notif, _} assert notif.activity.id == follow_activity.id @@ -493,7 +493,7 @@ defmodule Pleroma.Web.StreamerTest do other_user_id = other_user.id Streamer.get_topic_and_add_socket("user", user, oauth_token) - {:ok, _follower, _followed, _follow_activity} = CommonAPI.follow(user, other_user) + {:ok, _follower, _followed, _follow_activity} = CommonAPI.follow(other_user, user) assert_receive {:text, event} @@ -536,12 +536,12 @@ defmodule Pleroma.Web.StreamerTest do test "it streams edits in the 'user' stream", %{user: user, token: oauth_token} do sender = insert(:user) - {:ok, _, _, _} = CommonAPI.follow(user, sender) + {:ok, _, _, _} = CommonAPI.follow(sender, user) {:ok, activity} = CommonAPI.post(sender, %{status: "hey"}) Streamer.get_topic_and_add_socket("user", user, oauth_token) - {:ok, edited} = CommonAPI.update(sender, activity, %{status: "mew mew"}) + {:ok, edited} = CommonAPI.update(activity, sender, %{status: "mew mew"}) create = Pleroma.Activity.get_create_by_object_ap_id_with_object(activity.object.data["id"]) assert_receive {:render_with_user, _, "status_update.json", ^create, _} @@ -552,7 +552,7 @@ defmodule Pleroma.Web.StreamerTest do {:ok, activity} = CommonAPI.post(user, %{status: "hey"}) Streamer.get_topic_and_add_socket("user", user, oauth_token) - {:ok, edited} = CommonAPI.update(user, activity, %{status: "mew mew"}) + {:ok, edited} = CommonAPI.update(activity, user, %{status: "mew mew"}) create = Pleroma.Activity.get_create_by_object_ap_id_with_object(activity.object.data["id"]) assert_receive {:render_with_user, _, "status_update.json", ^create, _} @@ -608,7 +608,7 @@ defmodule Pleroma.Web.StreamerTest do {:ok, activity} = CommonAPI.post(sender, %{status: "hey"}) assert_receive {:text, _} - {:ok, edited} = CommonAPI.update(sender, activity, %{status: "mew mew"}) + {:ok, edited} = CommonAPI.update(activity, sender, %{status: "mew mew"}) edited = Pleroma.Activity.normalize(edited) @@ -627,7 +627,7 @@ defmodule Pleroma.Web.StreamerTest do {:ok, activity} = CommonAPI.post(sender, %{status: "hey"}) assert_receive {:text, _} - {:ok, edited} = CommonAPI.update(sender, activity, %{status: "mew mew"}) + {:ok, edited} = CommonAPI.update(activity, sender, %{status: "mew mew"}) edited = Pleroma.Activity.normalize(edited) @@ -638,7 +638,7 @@ defmodule Pleroma.Web.StreamerTest do assert %{"id" => ^activity_id} = Jason.decode!(payload) refute Streamer.filtered_by_user?(sender, edited) - {:ok, edited} = CommonAPI.update(sender, activity, %{status: "mew mew 2"}) + {:ok, edited} = CommonAPI.update(activity, sender, %{status: "mew mew 2"}) edited = Pleroma.Activity.normalize(edited) @@ -826,8 +826,8 @@ defmodule Pleroma.Web.StreamerTest do test "it filters muted reblogs", %{user: user1, token: user1_token} do user2 = insert(:user) user3 = insert(:user) - CommonAPI.follow(user1, user2) - CommonAPI.hide_reblogs(user1, user2) + CommonAPI.follow(user2, user1) + CommonAPI.hide_reblogs(user2, user1) {:ok, create_activity} = CommonAPI.post(user3, %{status: "I'm kawen"}) @@ -842,8 +842,8 @@ defmodule Pleroma.Web.StreamerTest do token: user1_token } do user2 = insert(:user) - CommonAPI.follow(user1, user2) - CommonAPI.hide_reblogs(user1, user2) + CommonAPI.follow(user2, user1) + CommonAPI.hide_reblogs(user2, user1) {:ok, create_activity} = CommonAPI.post(user1, %{status: "I'm kawen"}) Streamer.get_topic_and_add_socket("user", user1, user1_token) @@ -858,12 +858,12 @@ defmodule Pleroma.Web.StreamerTest do token: user1_token } do user2 = insert(:user) - CommonAPI.follow(user1, user2) - CommonAPI.hide_reblogs(user1, user2) + CommonAPI.follow(user2, user1) + CommonAPI.hide_reblogs(user2, user1) {:ok, create_activity} = CommonAPI.post(user1, %{status: "I'm kawen"}) Streamer.get_topic_and_add_socket("user", user1, user1_token) - {:ok, _favorite_activity} = CommonAPI.favorite(user2, create_activity.id) + {:ok, _favorite_activity} = CommonAPI.favorite(create_activity.id, user2) assert_receive {:render_with_user, _, "notification.json", notif, _} refute Streamer.filtered_by_user?(user1, notif) @@ -876,9 +876,9 @@ defmodule Pleroma.Web.StreamerTest do %{user: user2, token: user2_token} = oauth_access(["read"]) Streamer.get_topic_and_add_socket("user", user2, user2_token) - {:ok, user2, user, _activity} = CommonAPI.follow(user2, user) + {:ok, user2, user, _activity} = CommonAPI.follow(user, user2) {:ok, activity} = CommonAPI.post(user, %{status: "super hot take"}) - {:ok, _} = CommonAPI.add_mute(user2, activity) + {:ok, _} = CommonAPI.add_mute(activity, user2) assert_receive {:render_with_user, _, _, ^activity, _} assert Streamer.filtered_by_user?(user2, activity) @@ -1026,8 +1026,8 @@ defmodule Pleroma.Web.StreamerTest do %{user: user2, token: user2_token} = oauth_access(["read"]) post_user = insert(:user) - CommonAPI.follow(user, post_user) - CommonAPI.follow(user2, post_user) + CommonAPI.follow(post_user, user) + CommonAPI.follow(post_user, user2) tasks = [ Task.async(child_proc.(starter.(user, token), hit)), @@ -1058,7 +1058,7 @@ defmodule Pleroma.Web.StreamerTest do %{user: user, token: token} = oauth_access(["read"]) post_user = insert(:user) - CommonAPI.follow(user, post_user) + CommonAPI.follow(post_user, user) tasks = [ Task.async(child_proc.(starter.(user, token), hit)), diff --git a/test/pleroma/web/twitter_api/remote_follow_controller_test.exs b/test/pleroma/web/twitter_api/remote_follow_controller_test.exs index c6ecb53f4..f762b1356 100644 --- a/test/pleroma/web/twitter_api/remote_follow_controller_test.exs +++ b/test/pleroma/web/twitter_api/remote_follow_controller_test.exs @@ -216,7 +216,7 @@ defmodule Pleroma.Web.TwitterAPI.RemoteFollowControllerTest do test "returns success result when user already in followers", %{conn: conn} do user = insert(:user) user2 = insert(:user) - {:ok, _, _, _} = CommonAPI.follow(user, user2) + {:ok, _, _, _} = CommonAPI.follow(user2, user) conn = conn