Merge branch 'develop' of git.pleroma.social:pleroma/pleroma into remake-remodel-dms
This commit is contained in:
commit
3cff4e24cd
104 changed files with 2453 additions and 1310 deletions
|
|
@ -79,7 +79,7 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
test "it works with pruned objects" do
|
||||
user = insert(:user)
|
||||
|
||||
{:ok, post} = CommonAPI.post(user, %{"status" => "namu amida butsu"})
|
||||
{:ok, post} = CommonAPI.post(user, %{status: "namu amida butsu"})
|
||||
|
||||
Object.normalize(post, false)
|
||||
|> Object.prune()
|
||||
|
|
@ -97,7 +97,7 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
test "it allows users to delete their posts" do
|
||||
user = insert(:user)
|
||||
|
||||
{:ok, post} = CommonAPI.post(user, %{"status" => "namu amida butsu"})
|
||||
{:ok, post} = CommonAPI.post(user, %{status: "namu amida butsu"})
|
||||
|
||||
with_mock Pleroma.Web.Federator,
|
||||
publish: fn _ -> nil end do
|
||||
|
|
@ -113,7 +113,7 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
user = insert(:user)
|
||||
other_user = insert(:user)
|
||||
|
||||
{:ok, post} = CommonAPI.post(user, %{"status" => "namu amida butsu"})
|
||||
{:ok, post} = CommonAPI.post(user, %{status: "namu amida butsu"})
|
||||
|
||||
assert {:error, "Could not delete"} = CommonAPI.delete(post.id, other_user)
|
||||
assert Activity.get_by_id(post.id)
|
||||
|
|
@ -123,7 +123,7 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
user = insert(:user)
|
||||
moderator = insert(:user, is_moderator: true)
|
||||
|
||||
{:ok, post} = CommonAPI.post(user, %{"status" => "namu amida butsu"})
|
||||
{:ok, post} = CommonAPI.post(user, %{status: "namu amida butsu"})
|
||||
|
||||
assert {:ok, delete} = CommonAPI.delete(post.id, moderator)
|
||||
assert delete.local
|
||||
|
|
@ -135,7 +135,7 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
user = insert(:user)
|
||||
moderator = insert(:user, is_admin: true)
|
||||
|
||||
{:ok, post} = CommonAPI.post(user, %{"status" => "namu amida butsu"})
|
||||
{:ok, post} = CommonAPI.post(user, %{status: "namu amida butsu"})
|
||||
|
||||
assert {:ok, delete} = CommonAPI.delete(post.id, moderator)
|
||||
assert delete.local
|
||||
|
|
@ -176,7 +176,7 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
users_serial = insert_list(10, :user)
|
||||
users = insert_list(10, :user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "."})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "."})
|
||||
|
||||
users_serial
|
||||
|> Enum.map(fn user ->
|
||||
|
|
@ -203,7 +203,7 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
users_serial = insert_list(10, :user)
|
||||
users = insert_list(10, :user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "."})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "."})
|
||||
|
||||
users_serial
|
||||
|> Enum.map(fn user ->
|
||||
|
|
@ -227,12 +227,12 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
|
||||
test "when replying to a conversation / participation, it will set the correct context id even if no explicit reply_to is given" do
|
||||
user = insert(:user)
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => ".", "visibility" => "direct"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: ".", visibility: "direct"})
|
||||
|
||||
[participation] = Participation.for_user(user)
|
||||
|
||||
{:ok, convo_reply} =
|
||||
CommonAPI.post(user, %{"status" => ".", "in_reply_to_conversation_id" => participation.id})
|
||||
CommonAPI.post(user, %{status: ".", in_reply_to_conversation_id: participation.id})
|
||||
|
||||
assert Visibility.is_direct?(convo_reply)
|
||||
|
||||
|
|
@ -246,8 +246,8 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(har, %{
|
||||
"status" => "@#{jafnhar.nickname} hey",
|
||||
"visibility" => "direct"
|
||||
status: "@#{jafnhar.nickname} hey",
|
||||
visibility: "direct"
|
||||
})
|
||||
|
||||
assert har.ap_id in activity.recipients
|
||||
|
|
@ -257,10 +257,10 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(har, %{
|
||||
"status" => "I don't really like @#{tridi.nickname}",
|
||||
"visibility" => "direct",
|
||||
"in_reply_to_status_id" => activity.id,
|
||||
"in_reply_to_conversation_id" => participation.id
|
||||
status: "I don't really like @#{tridi.nickname}",
|
||||
visibility: "direct",
|
||||
in_reply_to_status_id: activity.id,
|
||||
in_reply_to_conversation_id: participation.id
|
||||
})
|
||||
|
||||
assert har.ap_id in activity.recipients
|
||||
|
|
@ -277,8 +277,8 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(har, %{
|
||||
"status" => "@#{jafnhar.nickname} hey, i never want to see @#{tridi.nickname} again",
|
||||
"visibility" => "direct"
|
||||
status: "@#{jafnhar.nickname} hey, i never want to see @#{tridi.nickname} again",
|
||||
visibility: "direct"
|
||||
})
|
||||
|
||||
refute tridi.ap_id in activity.recipients
|
||||
|
|
@ -287,7 +287,7 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
|
||||
test "it de-duplicates tags" do
|
||||
user = insert(:user)
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "#2hu #2HU"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "#2hu #2HU"})
|
||||
|
||||
object = Object.normalize(activity)
|
||||
|
||||
|
|
@ -296,7 +296,7 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
|
||||
test "it adds emoji in the object" do
|
||||
user = insert(:user)
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => ":firefox:"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: ":firefox:"})
|
||||
|
||||
assert Object.normalize(activity).data["emoji"]["firefox"]
|
||||
end
|
||||
|
|
@ -310,9 +310,9 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(user, %{
|
||||
"status" =>
|
||||
status:
|
||||
"Hey, I think @#{user_three.nickname} is ugly. @#{user_four.nickname} is alright though.",
|
||||
"to" => [user_two.nickname, user_four.nickname, "nonexistent"]
|
||||
to: [user_two.nickname, user_four.nickname, "nonexistent"]
|
||||
})
|
||||
|
||||
assert user.ap_id in activity.recipients
|
||||
|
|
@ -328,8 +328,8 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(user, %{
|
||||
"status" => post,
|
||||
"content_type" => "text/html"
|
||||
status: post,
|
||||
content_type: "text/html"
|
||||
})
|
||||
|
||||
object = Object.normalize(activity)
|
||||
|
|
@ -344,8 +344,8 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(user, %{
|
||||
"status" => post,
|
||||
"content_type" => "text/markdown"
|
||||
status: post,
|
||||
content_type: "text/markdown"
|
||||
})
|
||||
|
||||
object = Object.normalize(activity)
|
||||
|
|
@ -356,21 +356,21 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
test "it does not allow replies to direct messages that are not direct messages themselves" do
|
||||
user = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "suya..", "visibility" => "direct"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "suya..", visibility: "direct"})
|
||||
|
||||
assert {:ok, _} =
|
||||
CommonAPI.post(user, %{
|
||||
"status" => "suya..",
|
||||
"visibility" => "direct",
|
||||
"in_reply_to_status_id" => activity.id
|
||||
status: "suya..",
|
||||
visibility: "direct",
|
||||
in_reply_to_status_id: activity.id
|
||||
})
|
||||
|
||||
Enum.each(["public", "private", "unlisted"], fn visibility ->
|
||||
assert {:error, "The message visibility must be direct"} =
|
||||
CommonAPI.post(user, %{
|
||||
"status" => "suya..",
|
||||
"visibility" => visibility,
|
||||
"in_reply_to_status_id" => activity.id
|
||||
status: "suya..",
|
||||
visibility: visibility,
|
||||
in_reply_to_status_id: activity.id
|
||||
})
|
||||
end)
|
||||
end
|
||||
|
|
@ -379,8 +379,7 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
user = insert(:user)
|
||||
{:ok, list} = Pleroma.List.create("foo", user)
|
||||
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(user, %{"status" => "foobar", "visibility" => "list:#{list.id}"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "foobar", visibility: "list:#{list.id}"})
|
||||
|
||||
assert activity.data["bcc"] == [list.ap_id]
|
||||
assert activity.recipients == [list.ap_id, user.ap_id]
|
||||
|
|
@ -391,7 +390,7 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
user = insert(:user)
|
||||
|
||||
assert {:error, "Cannot post an empty status without attachments"} =
|
||||
CommonAPI.post(user, %{"status" => ""})
|
||||
CommonAPI.post(user, %{status: ""})
|
||||
end
|
||||
|
||||
test "it validates character limits are correctly enforced" do
|
||||
|
|
@ -400,9 +399,9 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
user = insert(:user)
|
||||
|
||||
assert {:error, "The status is over the character limit"} =
|
||||
CommonAPI.post(user, %{"status" => "foobar"})
|
||||
CommonAPI.post(user, %{status: "foobar"})
|
||||
|
||||
assert {:ok, activity} = CommonAPI.post(user, %{"status" => "12345"})
|
||||
assert {:ok, activity} = CommonAPI.post(user, %{status: "12345"})
|
||||
end
|
||||
|
||||
test "it can handle activities that expire" do
|
||||
|
|
@ -413,8 +412,7 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
|> NaiveDateTime.truncate(:second)
|
||||
|> NaiveDateTime.add(1_000_000, :second)
|
||||
|
||||
assert {:ok, activity} =
|
||||
CommonAPI.post(user, %{"status" => "chai", "expires_in" => 1_000_000})
|
||||
assert {:ok, activity} = CommonAPI.post(user, %{status: "chai", expires_in: 1_000_000})
|
||||
|
||||
assert expiration = Pleroma.ActivityExpiration.get_by_activity_id(activity.id)
|
||||
assert expiration.scheduled_at == expires_at
|
||||
|
|
@ -426,14 +424,14 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
user = insert(:user)
|
||||
other_user = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(other_user, %{"status" => "cofe"})
|
||||
{:ok, activity} = CommonAPI.post(other_user, %{status: "cofe"})
|
||||
|
||||
{:ok, reaction} = CommonAPI.react_with_emoji(activity.id, user, "👍")
|
||||
|
||||
assert reaction.data["actor"] == user.ap_id
|
||||
assert reaction.data["content"] == "👍"
|
||||
|
||||
{:ok, activity} = CommonAPI.post(other_user, %{"status" => "cofe"})
|
||||
{:ok, activity} = CommonAPI.post(other_user, %{status: "cofe"})
|
||||
|
||||
{:error, _} = CommonAPI.react_with_emoji(activity.id, user, ".")
|
||||
end
|
||||
|
|
@ -442,7 +440,7 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
user = insert(:user)
|
||||
other_user = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(other_user, %{"status" => "cofe"})
|
||||
{:ok, activity} = CommonAPI.post(other_user, %{status: "cofe"})
|
||||
{:ok, reaction} = CommonAPI.react_with_emoji(activity.id, user, "👍")
|
||||
|
||||
{:ok, unreaction} = CommonAPI.unreact_with_emoji(activity.id, user, "👍")
|
||||
|
|
@ -456,7 +454,7 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
user = insert(:user)
|
||||
other_user = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(other_user, %{"status" => "cofe"})
|
||||
{:ok, activity} = CommonAPI.post(other_user, %{status: "cofe"})
|
||||
|
||||
{:ok, %Activity{}, _} = CommonAPI.repeat(activity.id, user)
|
||||
end
|
||||
|
|
@ -464,7 +462,7 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
test "can't repeat a repeat" do
|
||||
user = insert(:user)
|
||||
other_user = insert(:user)
|
||||
{:ok, activity} = CommonAPI.post(other_user, %{"status" => "cofe"})
|
||||
{:ok, activity} = CommonAPI.post(other_user, %{status: "cofe"})
|
||||
|
||||
{:ok, %Activity{} = announce, _} = CommonAPI.repeat(activity.id, other_user)
|
||||
|
||||
|
|
@ -475,10 +473,10 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
user = insert(:user)
|
||||
other_user = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(other_user, %{"status" => "cofe"})
|
||||
{:ok, activity} = CommonAPI.post(other_user, %{status: "cofe"})
|
||||
|
||||
{:ok, %Activity{} = announce_activity, _} =
|
||||
CommonAPI.repeat(activity.id, user, %{"visibility" => "private"})
|
||||
CommonAPI.repeat(activity.id, user, %{visibility: "private"})
|
||||
|
||||
assert Visibility.is_private?(announce_activity)
|
||||
end
|
||||
|
|
@ -487,7 +485,7 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
user = insert(:user)
|
||||
other_user = insert(:user)
|
||||
|
||||
{:ok, post_activity} = CommonAPI.post(other_user, %{"status" => "cofe"})
|
||||
{:ok, post_activity} = CommonAPI.post(other_user, %{status: "cofe"})
|
||||
|
||||
{:ok, %Activity{data: data}} = CommonAPI.favorite(user, post_activity.id)
|
||||
assert data["type"] == "Like"
|
||||
|
|
@ -499,7 +497,7 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
user = insert(:user)
|
||||
other_user = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(other_user, %{"status" => "cofe"})
|
||||
{:ok, activity} = CommonAPI.post(other_user, %{status: "cofe"})
|
||||
{:ok, %Activity{} = announce, object} = CommonAPI.repeat(activity.id, user)
|
||||
{:ok, ^announce, ^object} = CommonAPI.repeat(activity.id, user)
|
||||
end
|
||||
|
|
@ -508,7 +506,7 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
user = insert(:user)
|
||||
other_user = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(other_user, %{"status" => "cofe"})
|
||||
{:ok, activity} = CommonAPI.post(other_user, %{status: "cofe"})
|
||||
{:ok, %Activity{}} = CommonAPI.favorite(user, activity.id)
|
||||
assert {:ok, :already_liked} = CommonAPI.favorite(user, activity.id)
|
||||
end
|
||||
|
|
@ -519,7 +517,7 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
Pleroma.Config.put([:instance, :max_pinned_statuses], 1)
|
||||
|
||||
user = insert(:user)
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "HI!!!"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "HI!!!"})
|
||||
|
||||
[user: user, activity: activity]
|
||||
end
|
||||
|
|
@ -536,8 +534,8 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
test "pin poll", %{user: user} do
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(user, %{
|
||||
"status" => "How is fediverse today?",
|
||||
"poll" => %{"options" => ["Absolutely outstanding", "Not good"], "expires_in" => 20}
|
||||
status: "How is fediverse today?",
|
||||
poll: %{options: ["Absolutely outstanding", "Not good"], expires_in: 20}
|
||||
})
|
||||
|
||||
assert {:ok, ^activity} = CommonAPI.pin(activity.id, user)
|
||||
|
|
@ -549,7 +547,7 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
end
|
||||
|
||||
test "unlisted statuses can be pinned", %{user: user} do
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "HI!!!", "visibility" => "unlisted"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "HI!!!", visibility: "unlisted"})
|
||||
assert {:ok, ^activity} = CommonAPI.pin(activity.id, user)
|
||||
end
|
||||
|
||||
|
|
@ -560,7 +558,7 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
end
|
||||
|
||||
test "max pinned statuses", %{user: user, activity: activity_one} do
|
||||
{:ok, activity_two} = CommonAPI.post(user, %{"status" => "HI!!!"})
|
||||
{:ok, activity_two} = CommonAPI.post(user, %{status: "HI!!!"})
|
||||
|
||||
assert {:ok, ^activity_one} = CommonAPI.pin(activity_one.id, user)
|
||||
|
||||
|
|
@ -628,7 +626,7 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
reporter = insert(:user)
|
||||
target_user = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(target_user, %{"status" => "foobar"})
|
||||
{:ok, activity} = CommonAPI.post(target_user, %{status: "foobar"})
|
||||
|
||||
reporter_ap_id = reporter.ap_id
|
||||
target_ap_id = target_user.ap_id
|
||||
|
|
@ -865,8 +863,8 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(user, %{
|
||||
"status" => "Am I cute?",
|
||||
"poll" => %{"options" => ["Yes", "No"], "expires_in" => 20}
|
||||
status: "Am I cute?",
|
||||
poll: %{options: ["Yes", "No"], expires_in: 20}
|
||||
})
|
||||
|
||||
object = Object.normalize(activity)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue