Fix order of args for update/2

This commit is contained in:
Mark Felder 2024-07-22 17:49:30 -04:00
parent 7e37882cf7
commit f602813d31
14 changed files with 25 additions and 25 deletions

View file

@ -461,8 +461,8 @@ def post(user, %{status: _} = data) do
end
end
@spec update(User.t(), Activity.t(), map()) :: {:ok, Activity.t()} | {:error, any()}
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),

View file

@ -276,7 +276,7 @@ def update(
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,

View file

@ -440,7 +440,7 @@ test "receives edits", %{user: reading_user, token: token} 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

View file

@ -165,7 +165,7 @@ test "it sends edited notifications to those who repeated a status" 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"
})
@ -748,7 +748,7 @@ test "it sends edited notifications to those who repeated a status" 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"
})

View file

@ -43,7 +43,7 @@ test "a note from factory validates" 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, %{"object" => external_rep}} =
Pleroma.Web.ActivityPub.Transmogrifier.prepare_outgoing(edit.data)

View file

@ -132,7 +132,7 @@ test "returns object_data in meta for a remote Update" 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

View file

@ -353,7 +353,7 @@ test "Updates of Notes are handled" 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)

View file

@ -1753,7 +1753,7 @@ test "updates a post" 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 @@ test "does not change visibility" 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 @@ test "updates a post with emoji" 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 @@ test "updates a post with emoji and federate properly" 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 @@ test "editing a post that copied a remote title with remote emoji should keep th
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 @@ test "respects MRF" 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"

View file

@ -290,7 +290,7 @@ test "Edit notification" 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)

View file

@ -938,7 +938,7 @@ test "it shows edited_at" 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)

View file

@ -81,7 +81,7 @@ test "it does not return old content after editing" 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"

View file

@ -225,7 +225,7 @@ test "renders title and body for update activity" 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) ==

View file

@ -70,7 +70,7 @@ test "recrawls URLs on status edits/updates" 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)

View file

@ -541,7 +541,7 @@ test "it streams edits in the 'user' stream", %{user: user, token: oauth_token}
{: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 @@ test "it streams own edits in the 'user' stream", %{user: user, token: oauth_tok
{: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 @@ test "it streams edits in the 'public' stream" 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 @@ test "it streams multiple edits in the 'public' stream correctly" 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 @@ test "it streams multiple edits in the 'public' stream correctly" 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)