Fix order of args for update/2
This commit is contained in:
parent
7e37882cf7
commit
f602813d31
@ -461,8 +461,8 @@ defmodule Pleroma.Web.CommonAPI do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@spec update(User.t(), Activity.t(), map()) :: {:ok, Activity.t()} | {:error, any()}
|
@spec update(Activity.t(), User.t(), map()) :: {:ok, Activity.t()} | {:error, any()}
|
||||||
def update(user, orig_activity, changes) do
|
def update(orig_activity, %User{} = user, changes) do
|
||||||
with orig_object <- Object.normalize(orig_activity),
|
with orig_object <- Object.normalize(orig_activity),
|
||||||
{:ok, new_object} <- make_update_data(user, orig_object, changes),
|
{:ok, new_object} <- make_update_data(user, orig_object, changes),
|
||||||
{:ok, update_data, _} <- Builder.update(user, new_object),
|
{:ok, update_data, _} <- Builder.update(user, new_object),
|
||||||
|
@ -276,7 +276,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusController do
|
|||||||
actor <- Activity.user_actor(activity),
|
actor <- Activity.user_actor(activity),
|
||||||
{_, true} <- {:own_status, actor.id == user.id},
|
{_, true} <- {:own_status, actor.id == user.id},
|
||||||
changes <- body_params |> put_application(conn),
|
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
|
{_, %Activity{}} = {_, activity} <- {:refetched, Activity.get_by_id_with_object(id)} do
|
||||||
try_render(conn, "show.json",
|
try_render(conn, "show.json",
|
||||||
activity: activity,
|
activity: activity,
|
||||||
|
@ -440,7 +440,7 @@ defmodule Pleroma.Integration.MastodonWebsocketTest do
|
|||||||
|
|
||||||
assert_receive {:text, _raw_json}, 1_000
|
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
|
assert_receive {:text, raw_json}, 1_000
|
||||||
|
|
||||||
|
@ -165,7 +165,7 @@ defmodule Pleroma.NotificationTest do
|
|||||||
{:ok, _activity_two} = CommonAPI.repeat(activity_one.id, repeated_user)
|
{:ok, _activity_two} = CommonAPI.repeat(activity_one.id, repeated_user)
|
||||||
|
|
||||||
{:ok, _edit_activity} =
|
{:ok, _edit_activity} =
|
||||||
CommonAPI.update(user, activity_one, %{
|
CommonAPI.update(activity_one, user, %{
|
||||||
status: "hey @#{other_user.nickname}! mew mew"
|
status: "hey @#{other_user.nickname}! mew mew"
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -748,7 +748,7 @@ defmodule Pleroma.NotificationTest do
|
|||||||
{:ok, _activity_two} = CommonAPI.repeat(activity_one.id, repeated_user)
|
{:ok, _activity_two} = CommonAPI.repeat(activity_one.id, repeated_user)
|
||||||
|
|
||||||
{:ok, edit_activity} =
|
{:ok, edit_activity} =
|
||||||
CommonAPI.update(user, activity_one, %{
|
CommonAPI.update(activity_one, user, %{
|
||||||
status: "hey @#{other_user.nickname}! mew mew"
|
status: "hey @#{other_user.nickname}! mew mew"
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.ArticleNotePageValidatorTest
|
|||||||
setup do
|
setup do
|
||||||
user = insert(:user)
|
user = insert(:user)
|
||||||
{:ok, activity} = Pleroma.Web.CommonAPI.post(user, %{status: "mew mew :dinosaur:"})
|
{: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}} =
|
{:ok, %{"object" => external_rep}} =
|
||||||
Pleroma.Web.ActivityPub.Transmogrifier.prepare_outgoing(edit.data)
|
Pleroma.Web.ActivityPub.Transmogrifier.prepare_outgoing(edit.data)
|
||||||
|
@ -132,7 +132,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.UpdateHandlingTest do
|
|||||||
setup do
|
setup do
|
||||||
user = insert(:user)
|
user = insert(:user)
|
||||||
{:ok, activity} = Pleroma.Web.CommonAPI.post(user, %{status: "mew mew :dinosaur:"})
|
{: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)
|
{:ok, external_rep} = Pleroma.Web.ActivityPub.Transmogrifier.prepare_outgoing(edit.data)
|
||||||
%{external_rep: external_rep}
|
%{external_rep: external_rep}
|
||||||
end
|
end
|
||||||
|
@ -353,7 +353,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||||||
user = insert(:user)
|
user = insert(:user)
|
||||||
|
|
||||||
{:ok, activity} = CommonAPI.post(user, %{status: "everybody do the dinosaur :dinosaur:"})
|
{: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)
|
{:ok, prepared} = Transmogrifier.prepare_outgoing(update.data)
|
||||||
|
|
||||||
|
@ -1753,7 +1753,7 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||||||
user = insert(:user)
|
user = insert(:user)
|
||||||
{:ok, activity} = CommonAPI.post(user, %{status: "foo1", spoiler_text: "title 1"})
|
{: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)
|
updated_object = Object.normalize(updated)
|
||||||
assert updated_object.data["content"] == "updated 2"
|
assert updated_object.data["content"] == "updated 2"
|
||||||
@ -1767,7 +1767,7 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||||||
{:ok, activity} =
|
{:ok, activity} =
|
||||||
CommonAPI.post(user, %{status: "foo1", spoiler_text: "title 1", visibility: "private"})
|
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)
|
updated_object = Object.normalize(updated)
|
||||||
assert updated_object.data["content"] == "updated 2"
|
assert updated_object.data["content"] == "updated 2"
|
||||||
@ -1784,7 +1784,7 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||||||
{:ok, activity} =
|
{:ok, activity} =
|
||||||
CommonAPI.post(user, %{status: "foo1", spoiler_text: "title 1 :#{emoji1}:"})
|
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)
|
updated_object = Object.normalize(updated)
|
||||||
assert updated_object.data["content"] == "updated 2 :#{emoji2}:"
|
assert updated_object.data["content"] == "updated 2 :#{emoji2}:"
|
||||||
@ -1803,7 +1803,7 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||||||
|
|
||||||
with_mock Pleroma.Web.Federator,
|
with_mock Pleroma.Web.Federator,
|
||||||
publish: fn _p -> nil end do
|
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 updated.data["object"]["content"] == "updated 2 :#{emoji2}:"
|
||||||
assert %{^emoji2 => _} = updated.data["object"]["emoji"]
|
assert %{^emoji2 => _} = updated.data["object"]["emoji"]
|
||||||
@ -1847,7 +1847,7 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||||||
assert reply.object.data["emoji"]["remoteemoji"] == remote_emoji_uri
|
assert reply.object.data["emoji"]["remoteemoji"] == remote_emoji_uri
|
||||||
|
|
||||||
{:ok, edit} =
|
{: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)
|
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"})
|
{:ok, activity} = CommonAPI.post(user, %{status: "foo1", spoiler_text: "updated 1"})
|
||||||
assert Object.normalize(activity).data["summary"] == "mewmew 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)
|
updated_object = Object.normalize(updated)
|
||||||
assert updated_object.data["content"] == "mewmew 2"
|
assert updated_object.data["content"] == "mewmew 2"
|
||||||
|
@ -290,7 +290,7 @@ defmodule Pleroma.Web.MastodonAPI.NotificationViewTest do
|
|||||||
|
|
||||||
{:ok, activity} = CommonAPI.post(user, %{status: "mew"})
|
{:ok, activity} = CommonAPI.post(user, %{status: "mew"})
|
||||||
{:ok, _} = CommonAPI.repeat(activity.id, repeat_user)
|
{: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)
|
user = Pleroma.User.get_by_ap_id(user.ap_id)
|
||||||
activity = Pleroma.Activity.normalize(activity)
|
activity = Pleroma.Activity.normalize(activity)
|
||||||
|
@ -938,7 +938,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
|
|||||||
status = StatusView.render("show.json", activity: post)
|
status = StatusView.render("show.json", activity: post)
|
||||||
refute status.edited_at
|
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)
|
edited = Pleroma.Activity.normalize(post)
|
||||||
|
|
||||||
status = StatusView.render("show.json", activity: edited)
|
status = StatusView.render("show.json", activity: edited)
|
||||||
|
@ -81,7 +81,7 @@ defmodule Pleroma.Web.Metadata.UtilsTest do
|
|||||||
object = Pleroma.Object.normalize(activity)
|
object = Pleroma.Object.normalize(activity)
|
||||||
assert Utils.scrub_html_and_truncate(object) == "mew mew #def"
|
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)
|
update = Pleroma.Activity.normalize(update)
|
||||||
object = Pleroma.Object.normalize(update)
|
object = Pleroma.Object.normalize(update)
|
||||||
assert Utils.scrub_html_and_truncate(object) == "mew mew #abc"
|
assert Utils.scrub_html_and_truncate(object) == "mew mew #abc"
|
||||||
|
@ -225,7 +225,7 @@ defmodule Pleroma.Web.Push.ImplTest do
|
|||||||
|
|
||||||
{:ok, activity} = CommonAPI.post(user, %{status: "lorem ipsum"})
|
{: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)
|
object = Object.normalize(activity, fetch: false)
|
||||||
|
|
||||||
assert Impl.format_body(%{activity: activity, type: "update"}, user, object) ==
|
assert Impl.format_body(%{activity: activity, type: "update"}, user, object) ==
|
||||||
|
@ -70,7 +70,7 @@ defmodule Pleroma.Web.RichMedia.CardTest do
|
|||||||
Card.get_by_activity(activity)
|
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)
|
activity = Pleroma.Activity.get_by_id(activity.id)
|
||||||
|
|
||||||
|
@ -541,7 +541,7 @@ defmodule Pleroma.Web.StreamerTest do
|
|||||||
{:ok, activity} = CommonAPI.post(sender, %{status: "hey"})
|
{:ok, activity} = CommonAPI.post(sender, %{status: "hey"})
|
||||||
|
|
||||||
Streamer.get_topic_and_add_socket("user", user, oauth_token)
|
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"])
|
create = Pleroma.Activity.get_create_by_object_ap_id_with_object(activity.object.data["id"])
|
||||||
|
|
||||||
assert_receive {:render_with_user, _, "status_update.json", ^create, _}
|
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"})
|
{:ok, activity} = CommonAPI.post(user, %{status: "hey"})
|
||||||
|
|
||||||
Streamer.get_topic_and_add_socket("user", user, oauth_token)
|
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"])
|
create = Pleroma.Activity.get_create_by_object_ap_id_with_object(activity.object.data["id"])
|
||||||
|
|
||||||
assert_receive {:render_with_user, _, "status_update.json", ^create, _}
|
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"})
|
{:ok, activity} = CommonAPI.post(sender, %{status: "hey"})
|
||||||
assert_receive {:text, _}
|
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)
|
edited = Pleroma.Activity.normalize(edited)
|
||||||
|
|
||||||
@ -627,7 +627,7 @@ defmodule Pleroma.Web.StreamerTest do
|
|||||||
{:ok, activity} = CommonAPI.post(sender, %{status: "hey"})
|
{:ok, activity} = CommonAPI.post(sender, %{status: "hey"})
|
||||||
assert_receive {:text, _}
|
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)
|
edited = Pleroma.Activity.normalize(edited)
|
||||||
|
|
||||||
@ -638,7 +638,7 @@ defmodule Pleroma.Web.StreamerTest do
|
|||||||
assert %{"id" => ^activity_id} = Jason.decode!(payload)
|
assert %{"id" => ^activity_id} = Jason.decode!(payload)
|
||||||
refute Streamer.filtered_by_user?(sender, edited)
|
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)
|
edited = Pleroma.Activity.normalize(edited)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user