Merge branch 'openapi/statuses' into 'develop'
Add OpenAPI spec for StatusController See merge request pleroma/pleroma!2521
This commit is contained in:
commit
156c8a5088
71 changed files with 1853 additions and 1082 deletions
|
|
@ -125,8 +125,8 @@ defmodule Pleroma.ActivityTest do
|
|||
"to" => ["https://www.w3.org/ns/activitystreams#Public"]
|
||||
}
|
||||
|
||||
{:ok, local_activity} = Pleroma.Web.CommonAPI.post(user, %{"status" => "find me!"})
|
||||
{:ok, japanese_activity} = Pleroma.Web.CommonAPI.post(user, %{"status" => "更新情報"})
|
||||
{:ok, local_activity} = Pleroma.Web.CommonAPI.post(user, %{status: "find me!"})
|
||||
{:ok, japanese_activity} = Pleroma.Web.CommonAPI.post(user, %{status: "更新情報"})
|
||||
{:ok, job} = Pleroma.Web.Federator.incoming_ap_doc(params)
|
||||
{:ok, remote_activity} = ObanHelpers.perform(job)
|
||||
|
||||
|
|
@ -225,8 +225,8 @@ defmodule Pleroma.ActivityTest do
|
|||
test "all_by_actor_and_id/2" do
|
||||
user = insert(:user)
|
||||
|
||||
{:ok, %{id: id1}} = Pleroma.Web.CommonAPI.post(user, %{"status" => "cofe"})
|
||||
{:ok, %{id: id2}} = Pleroma.Web.CommonAPI.post(user, %{"status" => "cofefe"})
|
||||
{:ok, %{id: id1}} = Pleroma.Web.CommonAPI.post(user, %{status: "cofe"})
|
||||
{:ok, %{id: id2}} = Pleroma.Web.CommonAPI.post(user, %{status: "cofefe"})
|
||||
|
||||
assert [] == Activity.all_by_actor_and_id(user, [])
|
||||
|
||||
|
|
|
|||
|
|
@ -21,8 +21,8 @@ defmodule Pleroma.BBS.HandlerTest do
|
|||
|
||||
{:ok, user} = User.follow(user, followed)
|
||||
|
||||
{:ok, _first} = CommonAPI.post(user, %{"status" => "hey"})
|
||||
{:ok, _second} = CommonAPI.post(followed, %{"status" => "hello"})
|
||||
{:ok, _first} = CommonAPI.post(user, %{status: "hey"})
|
||||
{:ok, _second} = CommonAPI.post(followed, %{status: "hello"})
|
||||
|
||||
output =
|
||||
capture_io(fn ->
|
||||
|
|
@ -62,7 +62,7 @@ defmodule Pleroma.BBS.HandlerTest do
|
|||
user = insert(:user)
|
||||
another_user = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(another_user, %{"status" => "this is a test post"})
|
||||
{:ok, activity} = CommonAPI.post(another_user, %{status: "this is a test post"})
|
||||
activity_object = Object.normalize(activity)
|
||||
|
||||
output =
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ defmodule Pleroma.BookmarkTest do
|
|||
describe "create/2" do
|
||||
test "with valid params" do
|
||||
user = insert(:user)
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "Some cool information"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "Some cool information"})
|
||||
{:ok, bookmark} = Bookmark.create(user.id, activity.id)
|
||||
assert bookmark.user_id == user.id
|
||||
assert bookmark.activity_id == activity.id
|
||||
|
|
@ -32,7 +32,7 @@ defmodule Pleroma.BookmarkTest do
|
|||
test "with valid params" do
|
||||
user = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "Some cool information"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "Some cool information"})
|
||||
{:ok, _bookmark} = Bookmark.create(user.id, activity.id)
|
||||
|
||||
{:ok, _deleted_bookmark} = Bookmark.destroy(user.id, activity.id)
|
||||
|
|
@ -45,7 +45,7 @@ defmodule Pleroma.BookmarkTest do
|
|||
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(user, %{
|
||||
"status" =>
|
||||
status:
|
||||
"Scientists Discover The Secret Behind Tenshi Eating A Corndog Being So Cute – Science Daily"
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ defmodule Pleroma.Conversation.ParticipationTest do
|
|||
other_user = insert(:user)
|
||||
|
||||
{:ok, _activity} =
|
||||
CommonAPI.post(user, %{"status" => "Hey @#{other_user.nickname}.", "visibility" => "direct"})
|
||||
CommonAPI.post(user, %{status: "Hey @#{other_user.nickname}.", visibility: "direct"})
|
||||
|
||||
[participation] = Participation.for_user(user)
|
||||
|
||||
|
|
@ -30,7 +30,7 @@ defmodule Pleroma.Conversation.ParticipationTest do
|
|||
other_user = insert(:user)
|
||||
|
||||
{:ok, _} =
|
||||
CommonAPI.post(user, %{"status" => "Hey @#{other_user.nickname}.", "visibility" => "direct"})
|
||||
CommonAPI.post(user, %{status: "Hey @#{other_user.nickname}.", visibility: "direct"})
|
||||
|
||||
user = User.get_cached_by_id(user.id)
|
||||
other_user = User.get_cached_by_id(other_user.id)
|
||||
|
|
@ -43,9 +43,9 @@ defmodule Pleroma.Conversation.ParticipationTest do
|
|||
|
||||
{:ok, _} =
|
||||
CommonAPI.post(other_user, %{
|
||||
"status" => "Hey @#{user.nickname}.",
|
||||
"visibility" => "direct",
|
||||
"in_reply_to_conversation_id" => participation.id
|
||||
status: "Hey @#{user.nickname}.",
|
||||
visibility: "direct",
|
||||
in_reply_to_conversation_id: participation.id
|
||||
})
|
||||
|
||||
user = User.get_cached_by_id(user.id)
|
||||
|
|
@ -64,7 +64,7 @@ defmodule Pleroma.Conversation.ParticipationTest do
|
|||
third_user = insert(:user)
|
||||
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(user, %{"status" => "Hey @#{other_user.nickname}.", "visibility" => "direct"})
|
||||
CommonAPI.post(user, %{status: "Hey @#{other_user.nickname}.", visibility: "direct"})
|
||||
|
||||
user = User.get_cached_by_id(user.id)
|
||||
other_user = User.get_cached_by_id(other_user.id)
|
||||
|
|
@ -79,9 +79,9 @@ defmodule Pleroma.Conversation.ParticipationTest do
|
|||
|
||||
{:ok, _activity} =
|
||||
CommonAPI.post(user, %{
|
||||
"in_reply_to_status_id" => activity.id,
|
||||
"status" => "Hey @#{third_user.nickname}.",
|
||||
"visibility" => "direct"
|
||||
in_reply_to_status_id: activity.id,
|
||||
status: "Hey @#{third_user.nickname}.",
|
||||
visibility: "direct"
|
||||
})
|
||||
|
||||
[participation] = Participation.for_user(user)
|
||||
|
|
@ -154,14 +154,14 @@ defmodule Pleroma.Conversation.ParticipationTest do
|
|||
|
||||
test "gets all the participations for a user, ordered by updated at descending" do
|
||||
user = insert(:user)
|
||||
{:ok, activity_one} = CommonAPI.post(user, %{"status" => "x", "visibility" => "direct"})
|
||||
{:ok, activity_two} = CommonAPI.post(user, %{"status" => "x", "visibility" => "direct"})
|
||||
{:ok, activity_one} = CommonAPI.post(user, %{status: "x", visibility: "direct"})
|
||||
{:ok, activity_two} = CommonAPI.post(user, %{status: "x", visibility: "direct"})
|
||||
|
||||
{:ok, activity_three} =
|
||||
CommonAPI.post(user, %{
|
||||
"status" => "x",
|
||||
"visibility" => "direct",
|
||||
"in_reply_to_status_id" => activity_one.id
|
||||
status: "x",
|
||||
visibility: "direct",
|
||||
in_reply_to_status_id: activity_one.id
|
||||
})
|
||||
|
||||
# Offset participations because the accuracy of updated_at is down to a second
|
||||
|
|
@ -201,7 +201,7 @@ defmodule Pleroma.Conversation.ParticipationTest do
|
|||
test "Doesn't die when the conversation gets empty" do
|
||||
user = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => ".", "visibility" => "direct"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: ".", visibility: "direct"})
|
||||
[participation] = Participation.for_user_with_last_activity_id(user)
|
||||
|
||||
assert participation.last_activity_id == activity.id
|
||||
|
|
@ -215,7 +215,7 @@ defmodule Pleroma.Conversation.ParticipationTest do
|
|||
user = insert(:user)
|
||||
other_user = insert(:user)
|
||||
|
||||
{:ok, _activity} = CommonAPI.post(user, %{"status" => ".", "visibility" => "direct"})
|
||||
{:ok, _activity} = CommonAPI.post(user, %{status: ".", visibility: "direct"})
|
||||
[participation] = Participation.for_user_with_last_activity_id(user)
|
||||
|
||||
participation = Repo.preload(participation, :recipients)
|
||||
|
|
@ -239,26 +239,26 @@ defmodule Pleroma.Conversation.ParticipationTest do
|
|||
|
||||
{:ok, _direct1} =
|
||||
CommonAPI.post(third_user, %{
|
||||
"status" => "Hi @#{blocker.nickname}",
|
||||
"visibility" => "direct"
|
||||
status: "Hi @#{blocker.nickname}",
|
||||
visibility: "direct"
|
||||
})
|
||||
|
||||
{:ok, _direct2} =
|
||||
CommonAPI.post(third_user, %{
|
||||
"status" => "Hi @#{blocker.nickname}, @#{blocked.nickname}",
|
||||
"visibility" => "direct"
|
||||
status: "Hi @#{blocker.nickname}, @#{blocked.nickname}",
|
||||
visibility: "direct"
|
||||
})
|
||||
|
||||
{:ok, _direct3} =
|
||||
CommonAPI.post(blocked, %{
|
||||
"status" => "Hi @#{blocker.nickname}",
|
||||
"visibility" => "direct"
|
||||
status: "Hi @#{blocker.nickname}",
|
||||
visibility: "direct"
|
||||
})
|
||||
|
||||
{:ok, _direct4} =
|
||||
CommonAPI.post(blocked, %{
|
||||
"status" => "Hi @#{blocker.nickname}, @#{third_user.nickname}",
|
||||
"visibility" => "direct"
|
||||
status: "Hi @#{blocker.nickname}, @#{third_user.nickname}",
|
||||
visibility: "direct"
|
||||
})
|
||||
|
||||
assert [%{read: false}, %{read: false}, %{read: false}, %{read: false}] =
|
||||
|
|
@ -293,8 +293,8 @@ defmodule Pleroma.Conversation.ParticipationTest do
|
|||
# When the blocked user is the author
|
||||
{:ok, _direct1} =
|
||||
CommonAPI.post(blocked, %{
|
||||
"status" => "Hi @#{blocker.nickname}",
|
||||
"visibility" => "direct"
|
||||
status: "Hi @#{blocker.nickname}",
|
||||
visibility: "direct"
|
||||
})
|
||||
|
||||
assert [%{read: true}] = Participation.for_user(blocker)
|
||||
|
|
@ -303,8 +303,8 @@ defmodule Pleroma.Conversation.ParticipationTest do
|
|||
# When the blocked user is a recipient
|
||||
{:ok, _direct2} =
|
||||
CommonAPI.post(third_user, %{
|
||||
"status" => "Hi @#{blocker.nickname}, @#{blocked.nickname}",
|
||||
"visibility" => "direct"
|
||||
status: "Hi @#{blocker.nickname}, @#{blocked.nickname}",
|
||||
visibility: "direct"
|
||||
})
|
||||
|
||||
assert [%{read: true}, %{read: true}] = Participation.for_user(blocker)
|
||||
|
|
@ -321,8 +321,8 @@ defmodule Pleroma.Conversation.ParticipationTest do
|
|||
|
||||
{:ok, _direct1} =
|
||||
CommonAPI.post(blocker, %{
|
||||
"status" => "Hi @#{third_user.nickname}, @#{blocked.nickname}",
|
||||
"visibility" => "direct"
|
||||
status: "Hi @#{third_user.nickname}, @#{blocked.nickname}",
|
||||
visibility: "direct"
|
||||
})
|
||||
|
||||
{:ok, _user_relationship} = User.block(blocker, blocked)
|
||||
|
|
@ -334,9 +334,9 @@ defmodule Pleroma.Conversation.ParticipationTest do
|
|||
# When it's a reply from the blocked user
|
||||
{:ok, _direct2} =
|
||||
CommonAPI.post(blocked, %{
|
||||
"status" => "reply",
|
||||
"visibility" => "direct",
|
||||
"in_reply_to_conversation_id" => blocked_participation.id
|
||||
status: "reply",
|
||||
visibility: "direct",
|
||||
in_reply_to_conversation_id: blocked_participation.id
|
||||
})
|
||||
|
||||
assert [%{read: true}] = Participation.for_user(blocker)
|
||||
|
|
@ -347,9 +347,9 @@ defmodule Pleroma.Conversation.ParticipationTest do
|
|||
# When it's a reply from the third user
|
||||
{:ok, _direct3} =
|
||||
CommonAPI.post(third_user, %{
|
||||
"status" => "reply",
|
||||
"visibility" => "direct",
|
||||
"in_reply_to_conversation_id" => third_user_participation.id
|
||||
status: "reply",
|
||||
visibility: "direct",
|
||||
in_reply_to_conversation_id: third_user_participation.id
|
||||
})
|
||||
|
||||
assert [%{read: true}] = Participation.for_user(blocker)
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ defmodule Pleroma.ConversationTest do
|
|||
other_user = insert(:user)
|
||||
|
||||
{:ok, _activity} =
|
||||
CommonAPI.post(user, %{"visibility" => "direct", "status" => "hey @#{other_user.nickname}"})
|
||||
CommonAPI.post(user, %{visibility: "direct", status: "hey @#{other_user.nickname}"})
|
||||
|
||||
Pleroma.Tests.ObanHelpers.perform_all()
|
||||
|
||||
|
|
@ -46,7 +46,7 @@ defmodule Pleroma.ConversationTest do
|
|||
|
||||
test "public posts don't create conversations" do
|
||||
user = insert(:user)
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "Hey"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "Hey"})
|
||||
|
||||
object = Pleroma.Object.normalize(activity)
|
||||
context = object.data["context"]
|
||||
|
|
@ -62,7 +62,7 @@ defmodule Pleroma.ConversationTest do
|
|||
tridi = insert(:user)
|
||||
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(har, %{"status" => "Hey @#{jafnhar.nickname}", "visibility" => "direct"})
|
||||
CommonAPI.post(har, %{status: "Hey @#{jafnhar.nickname}", visibility: "direct"})
|
||||
|
||||
object = Pleroma.Object.normalize(activity)
|
||||
context = object.data["context"]
|
||||
|
|
@ -81,9 +81,9 @@ defmodule Pleroma.ConversationTest do
|
|||
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(jafnhar, %{
|
||||
"status" => "Hey @#{har.nickname}",
|
||||
"visibility" => "direct",
|
||||
"in_reply_to_status_id" => activity.id
|
||||
status: "Hey @#{har.nickname}",
|
||||
visibility: "direct",
|
||||
in_reply_to_status_id: activity.id
|
||||
})
|
||||
|
||||
object = Pleroma.Object.normalize(activity)
|
||||
|
|
@ -105,9 +105,9 @@ defmodule Pleroma.ConversationTest do
|
|||
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(tridi, %{
|
||||
"status" => "Hey @#{har.nickname}",
|
||||
"visibility" => "direct",
|
||||
"in_reply_to_status_id" => activity.id
|
||||
status: "Hey @#{har.nickname}",
|
||||
visibility: "direct",
|
||||
in_reply_to_status_id: activity.id
|
||||
})
|
||||
|
||||
object = Pleroma.Object.normalize(activity)
|
||||
|
|
@ -149,14 +149,14 @@ defmodule Pleroma.ConversationTest do
|
|||
jafnhar = insert(:user, local: false)
|
||||
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(har, %{"status" => "Hey @#{jafnhar.nickname}", "visibility" => "direct"})
|
||||
CommonAPI.post(har, %{status: "Hey @#{jafnhar.nickname}", visibility: "direct"})
|
||||
|
||||
{:ok, conversation} = Conversation.create_or_bump_for(activity)
|
||||
|
||||
assert length(conversation.participations) == 2
|
||||
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(har, %{"status" => "Hey @#{jafnhar.nickname}", "visibility" => "public"})
|
||||
CommonAPI.post(har, %{status: "Hey @#{jafnhar.nickname}", visibility: "public"})
|
||||
|
||||
assert {:error, _} = Conversation.create_or_bump_for(activity)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -171,7 +171,7 @@ defmodule Pleroma.HTMLTest do
|
|||
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(user, %{
|
||||
"status" =>
|
||||
status:
|
||||
"I think I just found the best github repo https://github.com/komeiji-satori/Dress"
|
||||
})
|
||||
|
||||
|
|
@ -186,7 +186,7 @@ defmodule Pleroma.HTMLTest do
|
|||
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(user, %{
|
||||
"status" =>
|
||||
status:
|
||||
"@#{other_user.nickname} install misskey! https://github.com/syuilo/misskey/blob/develop/docs/setup.en.md"
|
||||
})
|
||||
|
||||
|
|
@ -203,8 +203,7 @@ defmodule Pleroma.HTMLTest do
|
|||
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(user, %{
|
||||
"status" =>
|
||||
"#cofe https://www.pixiv.net/member_illust.php?mode=medium&illust_id=72255140"
|
||||
status: "#cofe https://www.pixiv.net/member_illust.php?mode=medium&illust_id=72255140"
|
||||
})
|
||||
|
||||
object = Object.normalize(activity)
|
||||
|
|
@ -218,9 +217,9 @@ defmodule Pleroma.HTMLTest do
|
|||
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(user, %{
|
||||
"status" =>
|
||||
status:
|
||||
"<a href=\"https://pleroma.gov/tags/cofe\" rel=\"tag\">#cofe</a> https://www.pixiv.net/member_illust.php?mode=medium&illust_id=72255140",
|
||||
"content_type" => "text/html"
|
||||
content_type: "text/html"
|
||||
})
|
||||
|
||||
object = Object.normalize(activity)
|
||||
|
|
@ -232,8 +231,7 @@ defmodule Pleroma.HTMLTest do
|
|||
test "does not crash when there is an HTML entity in a link" do
|
||||
user = insert(:user)
|
||||
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(user, %{"status" => "\"http://cofe.com/?boomer=ok&foo=bar\""})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "\"http://cofe.com/?boomer=ok&foo=bar\""})
|
||||
|
||||
object = Object.normalize(activity)
|
||||
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ defmodule Pleroma.Integration.MastodonWebsocketTest do
|
|||
test "receives well formatted events" do
|
||||
user = insert(:user)
|
||||
{:ok, _} = start_socket("?stream=public")
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "nice echo chamber"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "nice echo chamber"})
|
||||
|
||||
assert_receive {:text, raw_json}, 1_000
|
||||
assert {:ok, json} = Jason.decode(raw_json)
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ defmodule Pleroma.NotificationTest do
|
|||
user = insert(:user)
|
||||
other_user = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "yeah"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "yeah"})
|
||||
{:ok, activity} = CommonAPI.react_with_emoji(activity.id, other_user, "☕")
|
||||
|
||||
{:ok, [notification]} = Notification.create_notifications(activity)
|
||||
|
|
@ -40,7 +40,7 @@ defmodule Pleroma.NotificationTest do
|
|||
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(user, %{
|
||||
"status" => "hey @#{other_user.nickname} and @#{third_user.nickname}"
|
||||
status: "hey @#{other_user.nickname} and @#{third_user.nickname}"
|
||||
})
|
||||
|
||||
{:ok, [notification, other_notification]} = Notification.create_notifications(activity)
|
||||
|
|
@ -60,7 +60,7 @@ defmodule Pleroma.NotificationTest do
|
|||
|
||||
User.subscribe(subscriber, user)
|
||||
|
||||
{:ok, status} = CommonAPI.post(user, %{"status" => "Akariiiin"})
|
||||
{:ok, status} = CommonAPI.post(user, %{status: "Akariiiin"})
|
||||
{:ok, [notification]} = Notification.create_notifications(status)
|
||||
|
||||
assert notification.user_id == subscriber.id
|
||||
|
|
@ -73,12 +73,12 @@ defmodule Pleroma.NotificationTest do
|
|||
|
||||
User.subscribe(subscriber, other_user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "test post"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "test post"})
|
||||
|
||||
{:ok, _reply_activity} =
|
||||
CommonAPI.post(other_user, %{
|
||||
"status" => "test reply",
|
||||
"in_reply_to_status_id" => activity.id
|
||||
status: "test reply",
|
||||
in_reply_to_status_id: activity.id
|
||||
})
|
||||
|
||||
user_notifications = Notification.for_user(user)
|
||||
|
|
@ -98,7 +98,7 @@ defmodule Pleroma.NotificationTest do
|
|||
blocker = insert(:user)
|
||||
{:ok, _user_relationship} = User.block(blocker, user)
|
||||
|
||||
{:ok, _activity} = CommonAPI.post(user, %{"status" => "hey @#{blocker.nickname}!"})
|
||||
{:ok, _activity} = CommonAPI.post(user, %{status: "hey @#{blocker.nickname}!"})
|
||||
|
||||
blocker_id = blocker.id
|
||||
assert [%Notification{user_id: ^blocker_id}] = Repo.all(Notification)
|
||||
|
|
@ -113,7 +113,7 @@ defmodule Pleroma.NotificationTest do
|
|||
muter = insert(:user)
|
||||
{:ok, _user_relationships} = User.mute(muter, user)
|
||||
|
||||
{:ok, _activity} = CommonAPI.post(user, %{"status" => "hey @#{muter.nickname}!"})
|
||||
{:ok, _activity} = CommonAPI.post(user, %{status: "hey @#{muter.nickname}!"})
|
||||
|
||||
muter_id = muter.id
|
||||
assert [%Notification{user_id: ^muter_id}] = Repo.all(Notification)
|
||||
|
|
@ -127,14 +127,14 @@ defmodule Pleroma.NotificationTest do
|
|||
user = insert(:user)
|
||||
thread_muter = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "hey @#{thread_muter.nickname}!"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "hey @#{thread_muter.nickname}!"})
|
||||
|
||||
{:ok, _} = CommonAPI.add_mute(thread_muter, activity)
|
||||
|
||||
{:ok, _same_context_activity} =
|
||||
CommonAPI.post(user, %{
|
||||
"status" => "hey-hey-hey @#{thread_muter.nickname}!",
|
||||
"in_reply_to_status_id" => activity.id
|
||||
status: "hey-hey-hey @#{thread_muter.nickname}!",
|
||||
in_reply_to_status_id: activity.id
|
||||
})
|
||||
|
||||
[pre_mute_notification, post_mute_notification] =
|
||||
|
|
@ -202,7 +202,7 @@ defmodule Pleroma.NotificationTest do
|
|||
muted = insert(:user)
|
||||
{:ok, _} = User.mute(muter, muted)
|
||||
muter = Repo.get(User, muter.id)
|
||||
{:ok, activity} = CommonAPI.post(muted, %{"status" => "Hi @#{muter.nickname}"})
|
||||
{:ok, activity} = CommonAPI.post(muted, %{status: "Hi @#{muter.nickname}"})
|
||||
|
||||
assert Notification.create_notification(activity, muter)
|
||||
end
|
||||
|
|
@ -213,7 +213,7 @@ defmodule Pleroma.NotificationTest do
|
|||
|
||||
{:ok, _user_relationships} = User.mute(muter, muted, false)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(muted, %{"status" => "Hi @#{muter.nickname}"})
|
||||
{:ok, activity} = CommonAPI.post(muted, %{status: "Hi @#{muter.nickname}"})
|
||||
|
||||
assert Notification.create_notification(activity, muter)
|
||||
end
|
||||
|
|
@ -221,13 +221,13 @@ defmodule Pleroma.NotificationTest do
|
|||
test "it creates a notification for an activity from a muted thread" do
|
||||
muter = insert(:user)
|
||||
other_user = insert(:user)
|
||||
{:ok, activity} = CommonAPI.post(muter, %{"status" => "hey"})
|
||||
{:ok, activity} = CommonAPI.post(muter, %{status: "hey"})
|
||||
CommonAPI.add_mute(muter, activity)
|
||||
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(other_user, %{
|
||||
"status" => "Hi @#{muter.nickname}",
|
||||
"in_reply_to_status_id" => activity.id
|
||||
status: "Hi @#{muter.nickname}",
|
||||
in_reply_to_status_id: activity.id
|
||||
})
|
||||
|
||||
assert Notification.create_notification(activity, muter)
|
||||
|
|
@ -240,7 +240,7 @@ defmodule Pleroma.NotificationTest do
|
|||
insert(:user, notification_settings: %Pleroma.User.NotificationSetting{followers: false})
|
||||
|
||||
User.follow(follower, followed)
|
||||
{:ok, activity} = CommonAPI.post(follower, %{"status" => "hey @#{followed.nickname}"})
|
||||
{:ok, activity} = CommonAPI.post(follower, %{status: "hey @#{followed.nickname}"})
|
||||
refute Notification.create_notification(activity, followed)
|
||||
end
|
||||
|
||||
|
|
@ -252,7 +252,7 @@ defmodule Pleroma.NotificationTest do
|
|||
notification_settings: %Pleroma.User.NotificationSetting{non_followers: false}
|
||||
)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(follower, %{"status" => "hey @#{followed.nickname}"})
|
||||
{:ok, activity} = CommonAPI.post(follower, %{status: "hey @#{followed.nickname}"})
|
||||
refute Notification.create_notification(activity, followed)
|
||||
end
|
||||
|
||||
|
|
@ -263,7 +263,7 @@ defmodule Pleroma.NotificationTest do
|
|||
followed = insert(:user)
|
||||
User.follow(follower, followed)
|
||||
follower = Repo.get(User, follower.id)
|
||||
{:ok, activity} = CommonAPI.post(followed, %{"status" => "hey @#{follower.nickname}"})
|
||||
{:ok, activity} = CommonAPI.post(followed, %{status: "hey @#{follower.nickname}"})
|
||||
refute Notification.create_notification(activity, follower)
|
||||
end
|
||||
|
||||
|
|
@ -272,7 +272,7 @@ defmodule Pleroma.NotificationTest do
|
|||
insert(:user, notification_settings: %Pleroma.User.NotificationSetting{non_follows: false})
|
||||
|
||||
followed = insert(:user)
|
||||
{:ok, activity} = CommonAPI.post(followed, %{"status" => "hey @#{follower.nickname}"})
|
||||
{:ok, activity} = CommonAPI.post(followed, %{status: "hey @#{follower.nickname}"})
|
||||
refute Notification.create_notification(activity, follower)
|
||||
end
|
||||
|
||||
|
|
@ -289,7 +289,7 @@ defmodule Pleroma.NotificationTest do
|
|||
|
||||
{:ok, _, _, _} = CommonAPI.follow(subscriber, user)
|
||||
User.subscribe(subscriber, user)
|
||||
{:ok, status} = CommonAPI.post(user, %{"status" => "Akariiiin"})
|
||||
{:ok, status} = CommonAPI.post(user, %{status: "Akariiiin"})
|
||||
{:ok, [_notif]} = Notification.create_notifications(status)
|
||||
end
|
||||
|
||||
|
|
@ -299,7 +299,7 @@ defmodule Pleroma.NotificationTest do
|
|||
|
||||
User.subscribe(subscriber, user)
|
||||
|
||||
{:ok, status} = CommonAPI.post(user, %{"status" => "inwisible", "visibility" => "direct"})
|
||||
{:ok, status} = CommonAPI.post(user, %{status: "inwisible", visibility: "direct"})
|
||||
|
||||
assert {:ok, []} == Notification.create_notifications(status)
|
||||
end
|
||||
|
|
@ -370,7 +370,7 @@ defmodule Pleroma.NotificationTest do
|
|||
user = insert(:user)
|
||||
other_user = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "hey @#{other_user.nickname}"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "hey @#{other_user.nickname}"})
|
||||
|
||||
{:ok, [notification]} = Notification.create_notifications(activity)
|
||||
{:ok, notification} = Notification.get(other_user, notification.id)
|
||||
|
|
@ -382,7 +382,7 @@ defmodule Pleroma.NotificationTest do
|
|||
user = insert(:user)
|
||||
other_user = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "hey @#{other_user.nickname}"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "hey @#{other_user.nickname}"})
|
||||
|
||||
{:ok, [notification]} = Notification.create_notifications(activity)
|
||||
{:error, _notification} = Notification.get(user, notification.id)
|
||||
|
|
@ -394,7 +394,7 @@ defmodule Pleroma.NotificationTest do
|
|||
user = insert(:user)
|
||||
other_user = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "hey @#{other_user.nickname}"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "hey @#{other_user.nickname}"})
|
||||
|
||||
{:ok, [notification]} = Notification.create_notifications(activity)
|
||||
{:ok, notification} = Notification.dismiss(other_user, notification.id)
|
||||
|
|
@ -406,7 +406,7 @@ defmodule Pleroma.NotificationTest do
|
|||
user = insert(:user)
|
||||
other_user = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "hey @#{other_user.nickname}"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "hey @#{other_user.nickname}"})
|
||||
|
||||
{:ok, [notification]} = Notification.create_notifications(activity)
|
||||
{:error, _notification} = Notification.dismiss(user, notification.id)
|
||||
|
|
@ -421,14 +421,14 @@ defmodule Pleroma.NotificationTest do
|
|||
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(user, %{
|
||||
"status" => "hey @#{other_user.nickname} and @#{third_user.nickname} !"
|
||||
status: "hey @#{other_user.nickname} and @#{third_user.nickname} !"
|
||||
})
|
||||
|
||||
{:ok, _notifs} = Notification.create_notifications(activity)
|
||||
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(user, %{
|
||||
"status" => "hey again @#{other_user.nickname} and @#{third_user.nickname} !"
|
||||
status: "hey again @#{other_user.nickname} and @#{third_user.nickname} !"
|
||||
})
|
||||
|
||||
{:ok, _notifs} = Notification.create_notifications(activity)
|
||||
|
|
@ -446,12 +446,12 @@ defmodule Pleroma.NotificationTest do
|
|||
|
||||
{:ok, _activity} =
|
||||
CommonAPI.post(user, %{
|
||||
"status" => "hey @#{other_user.nickname}!"
|
||||
status: "hey @#{other_user.nickname}!"
|
||||
})
|
||||
|
||||
{:ok, _activity} =
|
||||
CommonAPI.post(user, %{
|
||||
"status" => "hey again @#{other_user.nickname}!"
|
||||
status: "hey again @#{other_user.nickname}!"
|
||||
})
|
||||
|
||||
[n2, n1] = notifs = Notification.for_user(other_user)
|
||||
|
|
@ -461,7 +461,7 @@ defmodule Pleroma.NotificationTest do
|
|||
|
||||
{:ok, _activity} =
|
||||
CommonAPI.post(user, %{
|
||||
"status" => "hey yet again @#{other_user.nickname}!"
|
||||
status: "hey yet again @#{other_user.nickname}!"
|
||||
})
|
||||
|
||||
Notification.set_read_up_to(other_user, n2.id)
|
||||
|
|
@ -500,7 +500,7 @@ defmodule Pleroma.NotificationTest do
|
|||
Enum.each(0..10, fn i ->
|
||||
{:ok, _activity} =
|
||||
CommonAPI.post(user1, %{
|
||||
"status" => "hey ##{i} @#{user2.nickname}!"
|
||||
status: "hey ##{i} @#{user2.nickname}!"
|
||||
})
|
||||
end)
|
||||
|
||||
|
|
@ -536,7 +536,7 @@ defmodule Pleroma.NotificationTest do
|
|||
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(user, %{
|
||||
"status" => "hey @#{other_user.nickname}!"
|
||||
status: "hey @#{other_user.nickname}!"
|
||||
})
|
||||
|
||||
{enabled_receivers, _disabled_receivers} = Notification.get_notified_from_activity(activity)
|
||||
|
|
@ -605,7 +605,7 @@ defmodule Pleroma.NotificationTest do
|
|||
|
||||
{:ok, activity_one} =
|
||||
CommonAPI.post(user, %{
|
||||
"status" => "hey @#{other_user.nickname}!"
|
||||
status: "hey @#{other_user.nickname}!"
|
||||
})
|
||||
|
||||
{:ok, activity_two} = CommonAPI.favorite(third_user, activity_one.id)
|
||||
|
|
@ -623,7 +623,7 @@ defmodule Pleroma.NotificationTest do
|
|||
|
||||
{:ok, activity_one} =
|
||||
CommonAPI.post(user, %{
|
||||
"status" => "hey @#{other_user.nickname}!"
|
||||
status: "hey @#{other_user.nickname}!"
|
||||
})
|
||||
|
||||
{:ok, like_data, _} = Builder.like(third_user, activity_one.object)
|
||||
|
|
@ -645,7 +645,7 @@ defmodule Pleroma.NotificationTest do
|
|||
|
||||
{:ok, activity_one} =
|
||||
CommonAPI.post(user, %{
|
||||
"status" => "hey @#{other_user.nickname}!"
|
||||
status: "hey @#{other_user.nickname}!"
|
||||
})
|
||||
|
||||
{:ok, activity_two, _} = CommonAPI.repeat(activity_one.id, third_user)
|
||||
|
|
@ -661,7 +661,7 @@ defmodule Pleroma.NotificationTest do
|
|||
other_user = insert(:user)
|
||||
{:ok, _user_relationship} = User.block(other_user, user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "hey @#{other_user.nickname}!"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "hey @#{other_user.nickname}!"})
|
||||
|
||||
{enabled_receivers, disabled_receivers} = Notification.get_notified_from_activity(activity)
|
||||
|
||||
|
|
@ -674,7 +674,7 @@ defmodule Pleroma.NotificationTest do
|
|||
other_user = insert(:user)
|
||||
{:ok, _user_relationships} = User.mute(other_user, user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "hey @#{other_user.nickname}!"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "hey @#{other_user.nickname}!"})
|
||||
|
||||
{enabled_receivers, disabled_receivers} = Notification.get_notified_from_activity(activity)
|
||||
|
||||
|
|
@ -686,14 +686,14 @@ defmodule Pleroma.NotificationTest do
|
|||
user = insert(:user)
|
||||
other_user = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "hey @#{other_user.nickname}!"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "hey @#{other_user.nickname}!"})
|
||||
|
||||
{:ok, _} = CommonAPI.add_mute(other_user, activity)
|
||||
|
||||
{:ok, same_context_activity} =
|
||||
CommonAPI.post(user, %{
|
||||
"status" => "hey-hey-hey @#{other_user.nickname}!",
|
||||
"in_reply_to_status_id" => activity.id
|
||||
status: "hey-hey-hey @#{other_user.nickname}!",
|
||||
in_reply_to_status_id: activity.id
|
||||
})
|
||||
|
||||
{enabled_receivers, disabled_receivers} =
|
||||
|
|
@ -710,7 +710,7 @@ defmodule Pleroma.NotificationTest do
|
|||
|
||||
{:ok, other_user} = User.block_domain(other_user, blocked_domain)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "hey @#{other_user.nickname}!"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "hey @#{other_user.nickname}!"})
|
||||
|
||||
{enabled_receivers, disabled_receivers} = Notification.get_notified_from_activity(activity)
|
||||
|
||||
|
|
@ -726,7 +726,7 @@ defmodule Pleroma.NotificationTest do
|
|||
{:ok, other_user} = User.block_domain(other_user, blocked_domain)
|
||||
{:ok, other_user} = User.follow(other_user, user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "hey @#{other_user.nickname}!"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "hey @#{other_user.nickname}!"})
|
||||
|
||||
{enabled_receivers, disabled_receivers} = Notification.get_notified_from_activity(activity)
|
||||
|
||||
|
|
@ -740,7 +740,7 @@ defmodule Pleroma.NotificationTest do
|
|||
user = insert(:user)
|
||||
other_user = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "test post"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "test post"})
|
||||
|
||||
assert Enum.empty?(Notification.for_user(user))
|
||||
|
||||
|
|
@ -757,7 +757,7 @@ defmodule Pleroma.NotificationTest do
|
|||
user = insert(:user)
|
||||
other_user = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "test post"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "test post"})
|
||||
|
||||
assert Enum.empty?(Notification.for_user(user))
|
||||
|
||||
|
|
@ -774,7 +774,7 @@ defmodule Pleroma.NotificationTest do
|
|||
user = insert(:user)
|
||||
other_user = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "test post"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "test post"})
|
||||
|
||||
assert Enum.empty?(Notification.for_user(user))
|
||||
|
||||
|
|
@ -791,7 +791,7 @@ defmodule Pleroma.NotificationTest do
|
|||
user = insert(:user)
|
||||
other_user = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "test post"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "test post"})
|
||||
|
||||
assert Enum.empty?(Notification.for_user(user))
|
||||
|
||||
|
|
@ -808,7 +808,7 @@ defmodule Pleroma.NotificationTest do
|
|||
user = insert(:user)
|
||||
other_user = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "test post"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "test post"})
|
||||
|
||||
assert Enum.empty?(Notification.for_user(user))
|
||||
|
||||
|
|
@ -825,7 +825,7 @@ defmodule Pleroma.NotificationTest do
|
|||
user = insert(:user)
|
||||
other_user = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "test post"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "test post"})
|
||||
|
||||
assert Enum.empty?(Notification.for_user(user))
|
||||
|
||||
|
|
@ -842,13 +842,13 @@ defmodule Pleroma.NotificationTest do
|
|||
user = insert(:user)
|
||||
other_user = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "test post"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "test post"})
|
||||
{:ok, _deletion_activity} = CommonAPI.delete(activity.id, user)
|
||||
|
||||
{:ok, _reply_activity} =
|
||||
CommonAPI.post(other_user, %{
|
||||
"status" => "test reply",
|
||||
"in_reply_to_status_id" => activity.id
|
||||
status: "test reply",
|
||||
in_reply_to_status_id: activity.id
|
||||
})
|
||||
|
||||
assert Enum.empty?(Notification.for_user(user))
|
||||
|
|
@ -859,7 +859,7 @@ defmodule Pleroma.NotificationTest do
|
|||
other_user = insert(:user)
|
||||
|
||||
{:ok, _activity} =
|
||||
CommonAPI.post(user, %{"status" => "hi @#{other_user.nickname}", "visibility" => "direct"})
|
||||
CommonAPI.post(user, %{status: "hi @#{other_user.nickname}", visibility: "direct"})
|
||||
|
||||
refute Enum.empty?(Notification.for_user(other_user))
|
||||
|
||||
|
|
@ -970,7 +970,7 @@ defmodule Pleroma.NotificationTest do
|
|||
muted = insert(:user)
|
||||
{:ok, _user_relationships} = User.mute(user, muted, false)
|
||||
|
||||
{:ok, _activity} = CommonAPI.post(muted, %{"status" => "hey @#{user.nickname}"})
|
||||
{:ok, _activity} = CommonAPI.post(muted, %{status: "hey @#{user.nickname}"})
|
||||
|
||||
assert length(Notification.for_user(user)) == 1
|
||||
end
|
||||
|
|
@ -980,7 +980,7 @@ defmodule Pleroma.NotificationTest do
|
|||
muted = insert(:user)
|
||||
{:ok, _user_relationships} = User.mute(user, muted)
|
||||
|
||||
{:ok, _activity} = CommonAPI.post(muted, %{"status" => "hey @#{user.nickname}"})
|
||||
{:ok, _activity} = CommonAPI.post(muted, %{status: "hey @#{user.nickname}"})
|
||||
|
||||
assert Notification.for_user(user) == []
|
||||
end
|
||||
|
|
@ -990,7 +990,7 @@ defmodule Pleroma.NotificationTest do
|
|||
blocked = insert(:user)
|
||||
{:ok, _user_relationship} = User.block(user, blocked)
|
||||
|
||||
{:ok, _activity} = CommonAPI.post(blocked, %{"status" => "hey @#{user.nickname}"})
|
||||
{:ok, _activity} = CommonAPI.post(blocked, %{status: "hey @#{user.nickname}"})
|
||||
|
||||
assert Notification.for_user(user) == []
|
||||
end
|
||||
|
|
@ -1000,7 +1000,7 @@ defmodule Pleroma.NotificationTest do
|
|||
blocked = insert(:user, ap_id: "http://some-domain.com")
|
||||
{:ok, user} = User.block_domain(user, "some-domain.com")
|
||||
|
||||
{:ok, _activity} = CommonAPI.post(blocked, %{"status" => "hey @#{user.nickname}"})
|
||||
{:ok, _activity} = CommonAPI.post(blocked, %{status: "hey @#{user.nickname}"})
|
||||
|
||||
assert Notification.for_user(user) == []
|
||||
end
|
||||
|
|
@ -1012,7 +1012,7 @@ defmodule Pleroma.NotificationTest do
|
|||
{:ok, user} = User.block_domain(user, "some-domain.com")
|
||||
{:ok, _} = User.follow(user, blocked)
|
||||
|
||||
{:ok, _activity} = CommonAPI.post(blocked, %{"status" => "hey @#{user.nickname}"})
|
||||
{:ok, _activity} = CommonAPI.post(blocked, %{status: "hey @#{user.nickname}"})
|
||||
|
||||
assert length(Notification.for_user(user)) == 1
|
||||
end
|
||||
|
|
@ -1021,7 +1021,7 @@ defmodule Pleroma.NotificationTest do
|
|||
user = insert(:user)
|
||||
another_user = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(another_user, %{"status" => "hey @#{user.nickname}"})
|
||||
{:ok, activity} = CommonAPI.post(another_user, %{status: "hey @#{user.nickname}"})
|
||||
|
||||
{:ok, _} = Pleroma.ThreadMute.add_mute(user.id, activity.data["context"])
|
||||
assert Notification.for_user(user) == []
|
||||
|
|
@ -1032,7 +1032,7 @@ defmodule Pleroma.NotificationTest do
|
|||
muted = insert(:user)
|
||||
{:ok, _user_relationships} = User.mute(user, muted)
|
||||
|
||||
{:ok, _activity} = CommonAPI.post(muted, %{"status" => "hey @#{user.nickname}"})
|
||||
{:ok, _activity} = CommonAPI.post(muted, %{status: "hey @#{user.nickname}"})
|
||||
|
||||
assert length(Notification.for_user(user, %{with_muted: true})) == 1
|
||||
end
|
||||
|
|
@ -1042,7 +1042,7 @@ defmodule Pleroma.NotificationTest do
|
|||
blocked = insert(:user)
|
||||
{:ok, _user_relationship} = User.block(user, blocked)
|
||||
|
||||
{:ok, _activity} = CommonAPI.post(blocked, %{"status" => "hey @#{user.nickname}"})
|
||||
{:ok, _activity} = CommonAPI.post(blocked, %{status: "hey @#{user.nickname}"})
|
||||
|
||||
assert Enum.empty?(Notification.for_user(user, %{with_muted: true}))
|
||||
end
|
||||
|
|
@ -1053,7 +1053,7 @@ defmodule Pleroma.NotificationTest do
|
|||
blocked = insert(:user, ap_id: "http://some-domain.com")
|
||||
{:ok, user} = User.block_domain(user, "some-domain.com")
|
||||
|
||||
{:ok, _activity} = CommonAPI.post(blocked, %{"status" => "hey @#{user.nickname}"})
|
||||
{:ok, _activity} = CommonAPI.post(blocked, %{status: "hey @#{user.nickname}"})
|
||||
|
||||
assert Enum.empty?(Notification.for_user(user, %{with_muted: true}))
|
||||
end
|
||||
|
|
@ -1062,7 +1062,7 @@ defmodule Pleroma.NotificationTest do
|
|||
user = insert(:user)
|
||||
another_user = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(another_user, %{"status" => "hey @#{user.nickname}"})
|
||||
{:ok, activity} = CommonAPI.post(another_user, %{status: "hey @#{user.nickname}"})
|
||||
|
||||
{:ok, _} = Pleroma.ThreadMute.add_mute(user.id, activity.data["context"])
|
||||
assert length(Notification.for_user(user, %{with_muted: true})) == 1
|
||||
|
|
|
|||
|
|
@ -22,26 +22,26 @@ defmodule Pleroma.StatsTest do
|
|||
user = insert(:user)
|
||||
other_user = insert(:user)
|
||||
|
||||
CommonAPI.post(user, %{"visibility" => "public", "status" => "hey"})
|
||||
CommonAPI.post(user, %{visibility: "public", status: "hey"})
|
||||
|
||||
Enum.each(0..1, fn _ ->
|
||||
CommonAPI.post(user, %{
|
||||
"visibility" => "unlisted",
|
||||
"status" => "hey"
|
||||
visibility: "unlisted",
|
||||
status: "hey"
|
||||
})
|
||||
end)
|
||||
|
||||
Enum.each(0..2, fn _ ->
|
||||
CommonAPI.post(user, %{
|
||||
"visibility" => "direct",
|
||||
"status" => "hey @#{other_user.nickname}"
|
||||
visibility: "direct",
|
||||
status: "hey @#{other_user.nickname}"
|
||||
})
|
||||
end)
|
||||
|
||||
Enum.each(0..3, fn _ ->
|
||||
CommonAPI.post(user, %{
|
||||
"visibility" => "private",
|
||||
"status" => "hey"
|
||||
visibility: "private",
|
||||
status: "hey"
|
||||
})
|
||||
end)
|
||||
|
||||
|
|
@ -51,7 +51,7 @@ defmodule Pleroma.StatsTest do
|
|||
|
||||
test "on status delete" do
|
||||
user = insert(:user)
|
||||
{:ok, activity} = CommonAPI.post(user, %{"visibility" => "public", "status" => "hey"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{visibility: "public", status: "hey"})
|
||||
assert %{public: 1} = Pleroma.Stats.get_status_visibility_count()
|
||||
CommonAPI.delete(activity.id, user)
|
||||
assert %{public: 0} = Pleroma.Stats.get_status_visibility_count()
|
||||
|
|
@ -59,16 +59,16 @@ defmodule Pleroma.StatsTest do
|
|||
|
||||
test "on status visibility update" do
|
||||
user = insert(:user)
|
||||
{:ok, activity} = CommonAPI.post(user, %{"visibility" => "public", "status" => "hey"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{visibility: "public", status: "hey"})
|
||||
assert %{public: 1, private: 0} = Pleroma.Stats.get_status_visibility_count()
|
||||
{:ok, _} = CommonAPI.update_activity_scope(activity.id, %{"visibility" => "private"})
|
||||
{:ok, _} = CommonAPI.update_activity_scope(activity.id, %{visibility: "private"})
|
||||
assert %{public: 0, private: 1} = Pleroma.Stats.get_status_visibility_count()
|
||||
end
|
||||
|
||||
test "doesn't count unrelated activities" do
|
||||
user = insert(:user)
|
||||
other_user = insert(:user)
|
||||
{:ok, activity} = CommonAPI.post(user, %{"visibility" => "public", "status" => "hey"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{visibility: "public", status: "hey"})
|
||||
_ = CommonAPI.follow(user, other_user)
|
||||
CommonAPI.favorite(other_user, activity.id)
|
||||
CommonAPI.repeat(activity.id, other_user)
|
||||
|
|
|
|||
|
|
@ -13,11 +13,11 @@ defmodule Mix.Tasks.Pleroma.CountStatusesTest do
|
|||
|
||||
test "counts statuses" do
|
||||
user = insert(:user)
|
||||
{:ok, _} = CommonAPI.post(user, %{"status" => "test"})
|
||||
{:ok, _} = CommonAPI.post(user, %{"status" => "test2"})
|
||||
{:ok, _} = CommonAPI.post(user, %{status: "test"})
|
||||
{:ok, _} = CommonAPI.post(user, %{status: "test2"})
|
||||
|
||||
user2 = insert(:user)
|
||||
{:ok, _} = CommonAPI.post(user2, %{"status" => "test3"})
|
||||
{:ok, _} = CommonAPI.post(user2, %{status: "test3"})
|
||||
|
||||
user = refresh_record(user)
|
||||
user2 = refresh_record(user2)
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ defmodule Mix.Tasks.Pleroma.DatabaseTest do
|
|||
describe "running remove_embedded_objects" do
|
||||
test "it replaces objects with references" do
|
||||
user = insert(:user)
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "test"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "test"})
|
||||
new_data = Map.put(activity.data, "object", activity.object.data)
|
||||
|
||||
{:ok, activity} =
|
||||
|
|
@ -99,8 +99,8 @@ defmodule Mix.Tasks.Pleroma.DatabaseTest do
|
|||
test "it turns OrderedCollection likes into empty arrays" do
|
||||
[user, user2] = insert_pair(:user)
|
||||
|
||||
{:ok, %{id: id, object: object}} = CommonAPI.post(user, %{"status" => "test"})
|
||||
{:ok, %{object: object2}} = CommonAPI.post(user, %{"status" => "test test"})
|
||||
{:ok, %{id: id, object: object}} = CommonAPI.post(user, %{status: "test"})
|
||||
{:ok, %{object: object2}} = CommonAPI.post(user, %{status: "test test"})
|
||||
|
||||
CommonAPI.favorite(user2, id)
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ defmodule Mix.Tasks.Pleroma.DigestTest do
|
|||
Enum.each(0..10, fn i ->
|
||||
{:ok, _activity} =
|
||||
CommonAPI.post(user1, %{
|
||||
"status" => "hey ##{i} @#{user2.nickname}!"
|
||||
status: "hey ##{i} @#{user2.nickname}!"
|
||||
})
|
||||
end)
|
||||
|
||||
|
|
|
|||
|
|
@ -12,26 +12,26 @@ defmodule Mix.Tasks.Pleroma.RefreshCounterCacheTest do
|
|||
user = insert(:user)
|
||||
other_user = insert(:user)
|
||||
|
||||
CommonAPI.post(user, %{"visibility" => "public", "status" => "hey"})
|
||||
CommonAPI.post(user, %{visibility: "public", status: "hey"})
|
||||
|
||||
Enum.each(0..1, fn _ ->
|
||||
CommonAPI.post(user, %{
|
||||
"visibility" => "unlisted",
|
||||
"status" => "hey"
|
||||
visibility: "unlisted",
|
||||
status: "hey"
|
||||
})
|
||||
end)
|
||||
|
||||
Enum.each(0..2, fn _ ->
|
||||
CommonAPI.post(user, %{
|
||||
"visibility" => "direct",
|
||||
"status" => "hey @#{other_user.nickname}"
|
||||
visibility: "direct",
|
||||
status: "hey @#{other_user.nickname}"
|
||||
})
|
||||
end)
|
||||
|
||||
Enum.each(0..3, fn _ ->
|
||||
CommonAPI.post(user, %{
|
||||
"visibility" => "private",
|
||||
"status" => "hey"
|
||||
visibility: "private",
|
||||
status: "hey"
|
||||
})
|
||||
end)
|
||||
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do
|
|||
test "a remote user's create activity is deleted when the object has been pruned" do
|
||||
user = insert(:user)
|
||||
|
||||
{:ok, post} = CommonAPI.post(user, %{"status" => "uguu"})
|
||||
{:ok, post} = CommonAPI.post(user, %{status: "uguu"})
|
||||
object = Object.normalize(post)
|
||||
Object.prune(object)
|
||||
|
||||
|
|
|
|||
|
|
@ -990,7 +990,7 @@ defmodule Pleroma.UserTest do
|
|||
actor = insert(:user)
|
||||
user = insert(:user, local: true)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(actor, %{"status" => "hello"})
|
||||
{:ok, activity} = CommonAPI.post(actor, %{status: "hello"})
|
||||
{:ok, announce, _} = CommonAPI.repeat(activity.id, user)
|
||||
|
||||
recipients = User.get_recipients_from_activity(announce)
|
||||
|
|
@ -1007,7 +1007,7 @@ defmodule Pleroma.UserTest do
|
|||
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(actor, %{
|
||||
"status" => "hey @#{addressed.nickname} @#{addressed_remote.nickname}"
|
||||
status: "hey @#{addressed.nickname} @#{addressed_remote.nickname}"
|
||||
})
|
||||
|
||||
assert Enum.map([actor, addressed], & &1.ap_id) --
|
||||
|
|
@ -1029,7 +1029,7 @@ defmodule Pleroma.UserTest do
|
|||
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(actor, %{
|
||||
"status" => "hey @#{addressed.nickname}"
|
||||
status: "hey @#{addressed.nickname}"
|
||||
})
|
||||
|
||||
assert Enum.map([actor, addressed], & &1.ap_id) --
|
||||
|
|
@ -1090,7 +1090,7 @@ defmodule Pleroma.UserTest do
|
|||
|
||||
{:ok, user2} = User.follow(user2, user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "hey @#{user2.nickname}"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "hey @#{user2.nickname}"})
|
||||
|
||||
activity = Repo.preload(activity, :bookmark)
|
||||
|
||||
|
|
@ -1126,7 +1126,7 @@ defmodule Pleroma.UserTest do
|
|||
setup do: clear_config([:instance, :federating])
|
||||
|
||||
test ".delete_user_activities deletes all create activities", %{user: user} do
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "2hu"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "2hu"})
|
||||
|
||||
User.delete_user_activities(user)
|
||||
|
||||
|
|
@ -1411,7 +1411,7 @@ defmodule Pleroma.UserTest do
|
|||
|
||||
{:ok, _} =
|
||||
CommonAPI.post(user, %{
|
||||
"status" => "hey @#{to.nickname}"
|
||||
status: "hey @#{to.nickname}"
|
||||
})
|
||||
end)
|
||||
|
||||
|
|
@ -1443,12 +1443,12 @@ defmodule Pleroma.UserTest do
|
|||
Enum.each(recipients, fn to ->
|
||||
{:ok, _} =
|
||||
CommonAPI.post(sender, %{
|
||||
"status" => "hey @#{to.nickname}"
|
||||
status: "hey @#{to.nickname}"
|
||||
})
|
||||
|
||||
{:ok, _} =
|
||||
CommonAPI.post(sender, %{
|
||||
"status" => "hey again @#{to.nickname}"
|
||||
status: "hey again @#{to.nickname}"
|
||||
})
|
||||
end)
|
||||
|
||||
|
|
|
|||
|
|
@ -341,7 +341,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do
|
|||
|
||||
test "cached purged after activity deletion", %{conn: conn} do
|
||||
user = insert(:user)
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "cofe"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "cofe"})
|
||||
|
||||
uuid = String.split(activity.data["id"], "/") |> List.last()
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
describe "streaming out participations" do
|
||||
test "it streams them out" do
|
||||
user = insert(:user)
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => ".", "visibility" => "direct"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: ".", visibility: "direct"})
|
||||
|
||||
{:ok, conversation} = Pleroma.Conversation.create_or_bump_for(activity)
|
||||
|
||||
|
|
@ -56,8 +56,8 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
stream: fn _, _ -> nil end do
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(user_one, %{
|
||||
"status" => "@#{user_two.nickname}",
|
||||
"visibility" => "direct"
|
||||
status: "@#{user_two.nickname}",
|
||||
visibility: "direct"
|
||||
})
|
||||
|
||||
conversation =
|
||||
|
|
@ -74,15 +74,13 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
test "it restricts by the appropriate visibility" do
|
||||
user = insert(:user)
|
||||
|
||||
{:ok, public_activity} = CommonAPI.post(user, %{"status" => ".", "visibility" => "public"})
|
||||
{:ok, public_activity} = CommonAPI.post(user, %{status: ".", visibility: "public"})
|
||||
|
||||
{:ok, direct_activity} = CommonAPI.post(user, %{"status" => ".", "visibility" => "direct"})
|
||||
{:ok, direct_activity} = CommonAPI.post(user, %{status: ".", visibility: "direct"})
|
||||
|
||||
{:ok, unlisted_activity} =
|
||||
CommonAPI.post(user, %{"status" => ".", "visibility" => "unlisted"})
|
||||
{:ok, unlisted_activity} = CommonAPI.post(user, %{status: ".", visibility: "unlisted"})
|
||||
|
||||
{:ok, private_activity} =
|
||||
CommonAPI.post(user, %{"status" => ".", "visibility" => "private"})
|
||||
{:ok, private_activity} = CommonAPI.post(user, %{status: ".", visibility: "private"})
|
||||
|
||||
activities =
|
||||
ActivityPub.fetch_activities([], %{:visibility => "direct", "actor_id" => user.ap_id})
|
||||
|
|
@ -118,15 +116,13 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
test "it excludes by the appropriate visibility" do
|
||||
user = insert(:user)
|
||||
|
||||
{:ok, public_activity} = CommonAPI.post(user, %{"status" => ".", "visibility" => "public"})
|
||||
{:ok, public_activity} = CommonAPI.post(user, %{status: ".", visibility: "public"})
|
||||
|
||||
{:ok, direct_activity} = CommonAPI.post(user, %{"status" => ".", "visibility" => "direct"})
|
||||
{:ok, direct_activity} = CommonAPI.post(user, %{status: ".", visibility: "direct"})
|
||||
|
||||
{:ok, unlisted_activity} =
|
||||
CommonAPI.post(user, %{"status" => ".", "visibility" => "unlisted"})
|
||||
{:ok, unlisted_activity} = CommonAPI.post(user, %{status: ".", visibility: "unlisted"})
|
||||
|
||||
{:ok, private_activity} =
|
||||
CommonAPI.post(user, %{"status" => ".", "visibility" => "private"})
|
||||
{:ok, private_activity} = CommonAPI.post(user, %{status: ".", visibility: "private"})
|
||||
|
||||
activities =
|
||||
ActivityPub.fetch_activities([], %{
|
||||
|
|
@ -193,9 +189,9 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
test "it fetches the appropriate tag-restricted posts" do
|
||||
user = insert(:user)
|
||||
|
||||
{:ok, status_one} = CommonAPI.post(user, %{"status" => ". #test"})
|
||||
{:ok, status_two} = CommonAPI.post(user, %{"status" => ". #essais"})
|
||||
{:ok, status_three} = CommonAPI.post(user, %{"status" => ". #test #reject"})
|
||||
{:ok, status_one} = CommonAPI.post(user, %{status: ". #test"})
|
||||
{:ok, status_two} = CommonAPI.post(user, %{status: ". #essais"})
|
||||
{:ok, status_three} = CommonAPI.post(user, %{status: ". #test #reject"})
|
||||
|
||||
fetch_one = ActivityPub.fetch_activities([], %{"type" => "Create", "tag" => "test"})
|
||||
|
||||
|
|
@ -432,26 +428,26 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
|
||||
{:ok, _} =
|
||||
CommonAPI.post(User.get_cached_by_id(user.id), %{
|
||||
"status" => "1",
|
||||
"visibility" => "public"
|
||||
status: "1",
|
||||
visibility: "public"
|
||||
})
|
||||
|
||||
{:ok, _} =
|
||||
CommonAPI.post(User.get_cached_by_id(user.id), %{
|
||||
"status" => "2",
|
||||
"visibility" => "unlisted"
|
||||
status: "2",
|
||||
visibility: "unlisted"
|
||||
})
|
||||
|
||||
{:ok, _} =
|
||||
CommonAPI.post(User.get_cached_by_id(user.id), %{
|
||||
"status" => "2",
|
||||
"visibility" => "private"
|
||||
status: "2",
|
||||
visibility: "private"
|
||||
})
|
||||
|
||||
{:ok, _} =
|
||||
CommonAPI.post(User.get_cached_by_id(user.id), %{
|
||||
"status" => "3",
|
||||
"visibility" => "direct"
|
||||
status: "3",
|
||||
visibility: "direct"
|
||||
})
|
||||
|
||||
user = User.get_cached_by_id(user.id)
|
||||
|
|
@ -462,27 +458,27 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
user = insert(:user)
|
||||
user2 = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "1", "visibility" => "public"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "1", visibility: "public"})
|
||||
ap_id = activity.data["id"]
|
||||
reply_data = %{"status" => "1", "in_reply_to_status_id" => activity.id}
|
||||
reply_data = %{status: "1", in_reply_to_status_id: activity.id}
|
||||
|
||||
# public
|
||||
{:ok, _} = CommonAPI.post(user2, Map.put(reply_data, "visibility", "public"))
|
||||
{:ok, _} = CommonAPI.post(user2, Map.put(reply_data, :visibility, "public"))
|
||||
assert %{data: data, object: object} = Activity.get_by_ap_id_with_object(ap_id)
|
||||
assert object.data["repliesCount"] == 1
|
||||
|
||||
# unlisted
|
||||
{:ok, _} = CommonAPI.post(user2, Map.put(reply_data, "visibility", "unlisted"))
|
||||
{:ok, _} = CommonAPI.post(user2, Map.put(reply_data, :visibility, "unlisted"))
|
||||
assert %{data: data, object: object} = Activity.get_by_ap_id_with_object(ap_id)
|
||||
assert object.data["repliesCount"] == 2
|
||||
|
||||
# private
|
||||
{:ok, _} = CommonAPI.post(user2, Map.put(reply_data, "visibility", "private"))
|
||||
{:ok, _} = CommonAPI.post(user2, Map.put(reply_data, :visibility, "private"))
|
||||
assert %{data: data, object: object} = Activity.get_by_ap_id_with_object(ap_id)
|
||||
assert object.data["repliesCount"] == 2
|
||||
|
||||
# direct
|
||||
{:ok, _} = CommonAPI.post(user2, Map.put(reply_data, "visibility", "direct"))
|
||||
{:ok, _} = CommonAPI.post(user2, Map.put(reply_data, :visibility, "direct"))
|
||||
assert %{data: data, object: object} = Activity.get_by_ap_id_with_object(ap_id)
|
||||
assert object.data["repliesCount"] == 2
|
||||
end
|
||||
|
|
@ -569,13 +565,13 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
|
||||
{:ok, _user_relationship} = User.block(blocker, blockee)
|
||||
|
||||
{:ok, activity_one} = CommonAPI.post(friend, %{"status" => "hey!"})
|
||||
{:ok, activity_one} = CommonAPI.post(friend, %{status: "hey!"})
|
||||
|
||||
{:ok, activity_two} = CommonAPI.post(friend, %{"status" => "hey! @#{blockee.nickname}"})
|
||||
{:ok, activity_two} = CommonAPI.post(friend, %{status: "hey! @#{blockee.nickname}"})
|
||||
|
||||
{:ok, activity_three} = CommonAPI.post(blockee, %{"status" => "hey! @#{friend.nickname}"})
|
||||
{:ok, activity_three} = CommonAPI.post(blockee, %{status: "hey! @#{friend.nickname}"})
|
||||
|
||||
{:ok, activity_four} = CommonAPI.post(blockee, %{"status" => "hey! @#{blocker.nickname}"})
|
||||
{:ok, activity_four} = CommonAPI.post(blockee, %{status: "hey! @#{blocker.nickname}"})
|
||||
|
||||
activities = ActivityPub.fetch_activities([], %{"blocking_user" => blocker})
|
||||
|
||||
|
|
@ -592,9 +588,9 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
|
||||
{:ok, _user_relationship} = User.block(blocker, blockee)
|
||||
|
||||
{:ok, activity_one} = CommonAPI.post(friend, %{"status" => "hey!"})
|
||||
{:ok, activity_one} = CommonAPI.post(friend, %{status: "hey!"})
|
||||
|
||||
{:ok, activity_two} = CommonAPI.post(blockee, %{"status" => "hey! @#{friend.nickname}"})
|
||||
{:ok, activity_two} = CommonAPI.post(blockee, %{status: "hey! @#{friend.nickname}"})
|
||||
|
||||
{:ok, activity_three, _} = CommonAPI.repeat(activity_two.id, friend)
|
||||
|
||||
|
|
@ -774,10 +770,9 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
test "doesn't retrieve unlisted activities" do
|
||||
user = insert(:user)
|
||||
|
||||
{:ok, _unlisted_activity} =
|
||||
CommonAPI.post(user, %{"status" => "yeah", "visibility" => "unlisted"})
|
||||
{:ok, _unlisted_activity} = CommonAPI.post(user, %{status: "yeah", visibility: "unlisted"})
|
||||
|
||||
{:ok, listed_activity} = CommonAPI.post(user, %{"status" => "yeah"})
|
||||
{:ok, listed_activity} = CommonAPI.post(user, %{status: "yeah"})
|
||||
|
||||
[activity] = ActivityPub.fetch_public_activities()
|
||||
|
||||
|
|
@ -912,7 +907,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
describe "announcing a private object" do
|
||||
test "adds an announce activity to the db if the audience is not widened" do
|
||||
user = insert(:user)
|
||||
{:ok, note_activity} = CommonAPI.post(user, %{"status" => ".", "visibility" => "private"})
|
||||
{:ok, note_activity} = CommonAPI.post(user, %{status: ".", visibility: "private"})
|
||||
object = Object.normalize(note_activity)
|
||||
|
||||
{:ok, announce_activity, object} = ActivityPub.announce(user, object, nil, true, false)
|
||||
|
|
@ -926,7 +921,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
|
||||
test "does not add an announce activity to the db if the audience is widened" do
|
||||
user = insert(:user)
|
||||
{:ok, note_activity} = CommonAPI.post(user, %{"status" => ".", "visibility" => "private"})
|
||||
{:ok, note_activity} = CommonAPI.post(user, %{status: ".", visibility: "private"})
|
||||
object = Object.normalize(note_activity)
|
||||
|
||||
assert {:error, _} = ActivityPub.announce(user, object, nil, true, true)
|
||||
|
|
@ -935,7 +930,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
test "does not add an announce activity to the db if the announcer is not the author" do
|
||||
user = insert(:user)
|
||||
announcer = insert(:user)
|
||||
{:ok, note_activity} = CommonAPI.post(user, %{"status" => ".", "visibility" => "private"})
|
||||
{:ok, note_activity} = CommonAPI.post(user, %{status: ".", visibility: "private"})
|
||||
object = Object.normalize(note_activity)
|
||||
|
||||
assert {:error, _} = ActivityPub.announce(announcer, object, nil, true, false)
|
||||
|
|
@ -1111,23 +1106,22 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
{:ok, user3} = User.follow(user3, user2)
|
||||
assert User.following?(user3, user2)
|
||||
|
||||
{:ok, public_activity} = CommonAPI.post(user3, %{"status" => "hi 1"})
|
||||
{:ok, public_activity} = CommonAPI.post(user3, %{status: "hi 1"})
|
||||
|
||||
{:ok, private_activity_1} =
|
||||
CommonAPI.post(user3, %{"status" => "hi 2", "visibility" => "private"})
|
||||
{:ok, private_activity_1} = CommonAPI.post(user3, %{status: "hi 2", visibility: "private"})
|
||||
|
||||
{:ok, private_activity_2} =
|
||||
CommonAPI.post(user2, %{
|
||||
"status" => "hi 3",
|
||||
"visibility" => "private",
|
||||
"in_reply_to_status_id" => private_activity_1.id
|
||||
status: "hi 3",
|
||||
visibility: "private",
|
||||
in_reply_to_status_id: private_activity_1.id
|
||||
})
|
||||
|
||||
{:ok, private_activity_3} =
|
||||
CommonAPI.post(user3, %{
|
||||
"status" => "hi 4",
|
||||
"visibility" => "private",
|
||||
"in_reply_to_status_id" => private_activity_2.id
|
||||
status: "hi 4",
|
||||
visibility: "private",
|
||||
in_reply_to_status_id: private_activity_2.id
|
||||
})
|
||||
|
||||
activities =
|
||||
|
|
@ -1177,9 +1171,9 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
Config.put([:instance, :max_pinned_statuses], 3)
|
||||
user = insert(:user)
|
||||
|
||||
{:ok, activity_one} = CommonAPI.post(user, %{"status" => "HI!!!"})
|
||||
{:ok, activity_two} = CommonAPI.post(user, %{"status" => "HI!!!"})
|
||||
{:ok, activity_three} = CommonAPI.post(user, %{"status" => "HI!!!"})
|
||||
{:ok, activity_one} = CommonAPI.post(user, %{status: "HI!!!"})
|
||||
{:ok, activity_two} = CommonAPI.post(user, %{status: "HI!!!"})
|
||||
{:ok, activity_three} = CommonAPI.post(user, %{status: "HI!!!"})
|
||||
|
||||
CommonAPI.pin(activity_one.id, user)
|
||||
user = refresh_record(user)
|
||||
|
|
@ -1200,7 +1194,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
reporter = insert(:user)
|
||||
target_account = insert(:user)
|
||||
content = "foobar"
|
||||
{:ok, activity} = CommonAPI.post(target_account, %{"status" => content})
|
||||
{:ok, activity} = CommonAPI.post(target_account, %{status: content})
|
||||
context = Utils.generate_context_id()
|
||||
|
||||
reporter_ap_id = reporter.ap_id
|
||||
|
|
@ -1296,8 +1290,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
{:ok, list} = Pleroma.List.create("foo", user)
|
||||
{:ok, list} = Pleroma.List.follow(list, member)
|
||||
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(user, %{"status" => "foobar", "visibility" => "list:#{list.id}"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "foobar", visibility: "list:#{list.id}"})
|
||||
|
||||
activity = Repo.preload(activity, :bookmark)
|
||||
activity = %Activity{activity | thread_muted?: !!activity.thread_muted?}
|
||||
|
|
@ -1315,8 +1308,8 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(user, %{
|
||||
"status" => "thought I looked cute might delete later :3",
|
||||
"visibility" => "private"
|
||||
status: "thought I looked cute might delete later :3",
|
||||
visibility: "private"
|
||||
})
|
||||
|
||||
[result] = ActivityPub.fetch_activities_bounded([user.follower_address], [])
|
||||
|
|
@ -1325,12 +1318,12 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
|
||||
test "fetches only public posts for other users" do
|
||||
user = insert(:user)
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "#cofe", "visibility" => "public"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "#cofe", visibility: "public"})
|
||||
|
||||
{:ok, _private_activity} =
|
||||
CommonAPI.post(user, %{
|
||||
"status" => "why is tenshi eating a corndog so cute?",
|
||||
"visibility" => "private"
|
||||
status: "why is tenshi eating a corndog so cute?",
|
||||
visibility: "private"
|
||||
})
|
||||
|
||||
[result] = ActivityPub.fetch_activities_bounded([], [user.follower_address])
|
||||
|
|
@ -1458,11 +1451,11 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
other_user = insert(:user)
|
||||
user1 = insert(:user)
|
||||
user2 = insert(:user)
|
||||
{:ok, a1} = CommonAPI.post(user1, %{"status" => "bla"})
|
||||
{:ok, _a2} = CommonAPI.post(user2, %{"status" => "traps are happy"})
|
||||
{:ok, a3} = CommonAPI.post(user2, %{"status" => "Trees Are "})
|
||||
{:ok, a4} = CommonAPI.post(user2, %{"status" => "Agent Smith "})
|
||||
{:ok, a5} = CommonAPI.post(user1, %{"status" => "Red or Blue "})
|
||||
{:ok, a1} = CommonAPI.post(user1, %{status: "bla"})
|
||||
{:ok, _a2} = CommonAPI.post(user2, %{status: "traps are happy"})
|
||||
{:ok, a3} = CommonAPI.post(user2, %{status: "Trees Are "})
|
||||
{: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)
|
||||
|
|
@ -1542,10 +1535,9 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
test "doesn't retrieve replies activities with exclude_replies" do
|
||||
user = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "yeah"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "yeah"})
|
||||
|
||||
{:ok, _reply} =
|
||||
CommonAPI.post(user, %{"status" => "yeah", "in_reply_to_status_id" => activity.id})
|
||||
{:ok, _reply} = CommonAPI.post(user, %{status: "yeah", in_reply_to_status_id: activity.id})
|
||||
|
||||
[result] = ActivityPub.fetch_public_activities(%{"exclude_replies" => "true"})
|
||||
|
||||
|
|
@ -1858,84 +1850,84 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
{:ok, u2} = User.follow(u2, u3)
|
||||
{:ok, u3} = User.follow(u3, u2)
|
||||
|
||||
{:ok, a1} = CommonAPI.post(u1, %{"status" => "Status"})
|
||||
{:ok, a1} = CommonAPI.post(u1, %{status: "Status"})
|
||||
|
||||
{:ok, r1_1} =
|
||||
CommonAPI.post(u2, %{
|
||||
"status" => "@#{u1.nickname} reply from u2 to u1",
|
||||
"in_reply_to_status_id" => a1.id
|
||||
status: "@#{u1.nickname} reply from u2 to u1",
|
||||
in_reply_to_status_id: a1.id
|
||||
})
|
||||
|
||||
{:ok, r1_2} =
|
||||
CommonAPI.post(u3, %{
|
||||
"status" => "@#{u1.nickname} reply from u3 to u1",
|
||||
"in_reply_to_status_id" => a1.id
|
||||
status: "@#{u1.nickname} reply from u3 to u1",
|
||||
in_reply_to_status_id: a1.id
|
||||
})
|
||||
|
||||
{:ok, r1_3} =
|
||||
CommonAPI.post(u4, %{
|
||||
"status" => "@#{u1.nickname} reply from u4 to u1",
|
||||
"in_reply_to_status_id" => a1.id
|
||||
status: "@#{u1.nickname} reply from u4 to u1",
|
||||
in_reply_to_status_id: a1.id
|
||||
})
|
||||
|
||||
{:ok, a2} = CommonAPI.post(u2, %{"status" => "Status"})
|
||||
{:ok, a2} = CommonAPI.post(u2, %{status: "Status"})
|
||||
|
||||
{:ok, r2_1} =
|
||||
CommonAPI.post(u1, %{
|
||||
"status" => "@#{u2.nickname} reply from u1 to u2",
|
||||
"in_reply_to_status_id" => a2.id
|
||||
status: "@#{u2.nickname} reply from u1 to u2",
|
||||
in_reply_to_status_id: a2.id
|
||||
})
|
||||
|
||||
{:ok, r2_2} =
|
||||
CommonAPI.post(u3, %{
|
||||
"status" => "@#{u2.nickname} reply from u3 to u2",
|
||||
"in_reply_to_status_id" => a2.id
|
||||
status: "@#{u2.nickname} reply from u3 to u2",
|
||||
in_reply_to_status_id: a2.id
|
||||
})
|
||||
|
||||
{:ok, r2_3} =
|
||||
CommonAPI.post(u4, %{
|
||||
"status" => "@#{u2.nickname} reply from u4 to u2",
|
||||
"in_reply_to_status_id" => a2.id
|
||||
status: "@#{u2.nickname} reply from u4 to u2",
|
||||
in_reply_to_status_id: a2.id
|
||||
})
|
||||
|
||||
{:ok, a3} = CommonAPI.post(u3, %{"status" => "Status"})
|
||||
{:ok, a3} = CommonAPI.post(u3, %{status: "Status"})
|
||||
|
||||
{:ok, r3_1} =
|
||||
CommonAPI.post(u1, %{
|
||||
"status" => "@#{u3.nickname} reply from u1 to u3",
|
||||
"in_reply_to_status_id" => a3.id
|
||||
status: "@#{u3.nickname} reply from u1 to u3",
|
||||
in_reply_to_status_id: a3.id
|
||||
})
|
||||
|
||||
{:ok, r3_2} =
|
||||
CommonAPI.post(u2, %{
|
||||
"status" => "@#{u3.nickname} reply from u2 to u3",
|
||||
"in_reply_to_status_id" => a3.id
|
||||
status: "@#{u3.nickname} reply from u2 to u3",
|
||||
in_reply_to_status_id: a3.id
|
||||
})
|
||||
|
||||
{:ok, r3_3} =
|
||||
CommonAPI.post(u4, %{
|
||||
"status" => "@#{u3.nickname} reply from u4 to u3",
|
||||
"in_reply_to_status_id" => a3.id
|
||||
status: "@#{u3.nickname} reply from u4 to u3",
|
||||
in_reply_to_status_id: a3.id
|
||||
})
|
||||
|
||||
{:ok, a4} = CommonAPI.post(u4, %{"status" => "Status"})
|
||||
{:ok, a4} = CommonAPI.post(u4, %{status: "Status"})
|
||||
|
||||
{:ok, r4_1} =
|
||||
CommonAPI.post(u1, %{
|
||||
"status" => "@#{u4.nickname} reply from u1 to u4",
|
||||
"in_reply_to_status_id" => a4.id
|
||||
status: "@#{u4.nickname} reply from u1 to u4",
|
||||
in_reply_to_status_id: a4.id
|
||||
})
|
||||
|
||||
{:ok, r4_2} =
|
||||
CommonAPI.post(u2, %{
|
||||
"status" => "@#{u4.nickname} reply from u2 to u4",
|
||||
"in_reply_to_status_id" => a4.id
|
||||
status: "@#{u4.nickname} reply from u2 to u4",
|
||||
in_reply_to_status_id: a4.id
|
||||
})
|
||||
|
||||
{:ok, r4_3} =
|
||||
CommonAPI.post(u3, %{
|
||||
"status" => "@#{u4.nickname} reply from u3 to u4",
|
||||
"in_reply_to_status_id" => a4.id
|
||||
status: "@#{u4.nickname} reply from u3 to u4",
|
||||
in_reply_to_status_id: a4.id
|
||||
})
|
||||
|
||||
{:ok,
|
||||
|
|
@ -1959,68 +1951,68 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
{:ok, u2} = User.follow(u2, u3)
|
||||
{:ok, u3} = User.follow(u3, u2)
|
||||
|
||||
{:ok, a1} = CommonAPI.post(u1, %{"status" => "Status", "visibility" => "private"})
|
||||
{:ok, a1} = CommonAPI.post(u1, %{status: "Status", visibility: "private"})
|
||||
|
||||
{:ok, r1_1} =
|
||||
CommonAPI.post(u2, %{
|
||||
"status" => "@#{u1.nickname} reply from u2 to u1",
|
||||
"in_reply_to_status_id" => a1.id,
|
||||
"visibility" => "private"
|
||||
status: "@#{u1.nickname} reply from u2 to u1",
|
||||
in_reply_to_status_id: a1.id,
|
||||
visibility: "private"
|
||||
})
|
||||
|
||||
{:ok, r1_2} =
|
||||
CommonAPI.post(u3, %{
|
||||
"status" => "@#{u1.nickname} reply from u3 to u1",
|
||||
"in_reply_to_status_id" => a1.id,
|
||||
"visibility" => "private"
|
||||
status: "@#{u1.nickname} reply from u3 to u1",
|
||||
in_reply_to_status_id: a1.id,
|
||||
visibility: "private"
|
||||
})
|
||||
|
||||
{:ok, r1_3} =
|
||||
CommonAPI.post(u4, %{
|
||||
"status" => "@#{u1.nickname} reply from u4 to u1",
|
||||
"in_reply_to_status_id" => a1.id,
|
||||
"visibility" => "private"
|
||||
status: "@#{u1.nickname} reply from u4 to u1",
|
||||
in_reply_to_status_id: a1.id,
|
||||
visibility: "private"
|
||||
})
|
||||
|
||||
{:ok, a2} = CommonAPI.post(u2, %{"status" => "Status", "visibility" => "private"})
|
||||
{:ok, a2} = CommonAPI.post(u2, %{status: "Status", visibility: "private"})
|
||||
|
||||
{:ok, r2_1} =
|
||||
CommonAPI.post(u1, %{
|
||||
"status" => "@#{u2.nickname} reply from u1 to u2",
|
||||
"in_reply_to_status_id" => a2.id,
|
||||
"visibility" => "private"
|
||||
status: "@#{u2.nickname} reply from u1 to u2",
|
||||
in_reply_to_status_id: a2.id,
|
||||
visibility: "private"
|
||||
})
|
||||
|
||||
{:ok, r2_2} =
|
||||
CommonAPI.post(u3, %{
|
||||
"status" => "@#{u2.nickname} reply from u3 to u2",
|
||||
"in_reply_to_status_id" => a2.id,
|
||||
"visibility" => "private"
|
||||
status: "@#{u2.nickname} reply from u3 to u2",
|
||||
in_reply_to_status_id: a2.id,
|
||||
visibility: "private"
|
||||
})
|
||||
|
||||
{:ok, a3} = CommonAPI.post(u3, %{"status" => "Status", "visibility" => "private"})
|
||||
{:ok, a3} = CommonAPI.post(u3, %{status: "Status", visibility: "private"})
|
||||
|
||||
{:ok, r3_1} =
|
||||
CommonAPI.post(u1, %{
|
||||
"status" => "@#{u3.nickname} reply from u1 to u3",
|
||||
"in_reply_to_status_id" => a3.id,
|
||||
"visibility" => "private"
|
||||
status: "@#{u3.nickname} reply from u1 to u3",
|
||||
in_reply_to_status_id: a3.id,
|
||||
visibility: "private"
|
||||
})
|
||||
|
||||
{:ok, r3_2} =
|
||||
CommonAPI.post(u2, %{
|
||||
"status" => "@#{u3.nickname} reply from u2 to u3",
|
||||
"in_reply_to_status_id" => a3.id,
|
||||
"visibility" => "private"
|
||||
status: "@#{u3.nickname} reply from u2 to u3",
|
||||
in_reply_to_status_id: a3.id,
|
||||
visibility: "private"
|
||||
})
|
||||
|
||||
{:ok, a4} = CommonAPI.post(u4, %{"status" => "Status", "visibility" => "private"})
|
||||
{:ok, a4} = CommonAPI.post(u4, %{status: "Status", visibility: "private"})
|
||||
|
||||
{:ok, r4_1} =
|
||||
CommonAPI.post(u1, %{
|
||||
"status" => "@#{u4.nickname} reply from u1 to u4",
|
||||
"in_reply_to_status_id" => a4.id,
|
||||
"visibility" => "private"
|
||||
status: "@#{u4.nickname} reply from u1 to u4",
|
||||
in_reply_to_status_id: a4.id,
|
||||
visibility: "private"
|
||||
})
|
||||
|
||||
{:ok,
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidatorTest do
|
|||
describe "EmojiReacts" do
|
||||
setup do
|
||||
user = insert(:user)
|
||||
{:ok, post_activity} = CommonAPI.post(user, %{"status" => "uguu"})
|
||||
{:ok, post_activity} = CommonAPI.post(user, %{status: "uguu"})
|
||||
|
||||
object = Pleroma.Object.get_by_ap_id(post_activity.data["object"])
|
||||
|
||||
|
|
@ -53,7 +53,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidatorTest do
|
|||
describe "Undos" do
|
||||
setup do
|
||||
user = insert(:user)
|
||||
{:ok, post_activity} = CommonAPI.post(user, %{"status" => "uguu"})
|
||||
{:ok, post_activity} = CommonAPI.post(user, %{status: "uguu"})
|
||||
{:ok, like} = CommonAPI.favorite(user, post_activity.id)
|
||||
{:ok, valid_like_undo, []} = Builder.undo(user, like)
|
||||
|
||||
|
|
@ -93,7 +93,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidatorTest do
|
|||
describe "deletes" do
|
||||
setup do
|
||||
user = insert(:user)
|
||||
{:ok, post_activity} = CommonAPI.post(user, %{"status" => "cancel me daddy"})
|
||||
{:ok, post_activity} = CommonAPI.post(user, %{status: "cancel me daddy"})
|
||||
|
||||
{:ok, valid_post_delete, _} = Builder.delete(user, post_activity.data["object"])
|
||||
{:ok, valid_user_delete, _} = Builder.delete(user, user.ap_id)
|
||||
|
|
@ -185,7 +185,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidatorTest do
|
|||
describe "likes" do
|
||||
setup do
|
||||
user = insert(:user)
|
||||
{:ok, post_activity} = CommonAPI.post(user, %{"status" => "uguu"})
|
||||
{:ok, post_activity} = CommonAPI.post(user, %{status: "uguu"})
|
||||
|
||||
valid_like = %{
|
||||
"to" => [user.ap_id],
|
||||
|
|
|
|||
|
|
@ -25,8 +25,8 @@ defmodule Pleroma.Web.ActivityPub.SideEffectsTest do
|
|||
user = insert(:user)
|
||||
other_user = insert(:user)
|
||||
|
||||
{:ok, op} = CommonAPI.post(other_user, %{"status" => "big oof"})
|
||||
{:ok, post} = CommonAPI.post(user, %{"status" => "hey", "in_reply_to_id" => op})
|
||||
{: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)
|
||||
object = Object.normalize(post)
|
||||
{:ok, delete_data, _meta} = Builder.delete(user, object.data["id"])
|
||||
|
|
@ -118,7 +118,7 @@ defmodule Pleroma.Web.ActivityPub.SideEffectsTest do
|
|||
poster = insert(:user)
|
||||
user = insert(:user)
|
||||
|
||||
{:ok, post} = CommonAPI.post(poster, %{"status" => "hey"})
|
||||
{:ok, post} = CommonAPI.post(poster, %{status: "hey"})
|
||||
|
||||
{:ok, emoji_react_data, []} = Builder.emoji_react(user, post.object, "👌")
|
||||
{:ok, emoji_react, _meta} = ActivityPub.persist(emoji_react_data, local: true)
|
||||
|
|
@ -144,7 +144,7 @@ defmodule Pleroma.Web.ActivityPub.SideEffectsTest do
|
|||
setup do
|
||||
poster = insert(:user)
|
||||
user = insert(:user)
|
||||
{:ok, post} = CommonAPI.post(poster, %{"status" => "hey"})
|
||||
{:ok, post} = CommonAPI.post(poster, %{status: "hey"})
|
||||
{:ok, like} = CommonAPI.favorite(user, post.id)
|
||||
{:ok, reaction} = CommonAPI.react_with_emoji(post.id, user, "👍")
|
||||
{:ok, announce, _} = CommonAPI.repeat(post.id, user)
|
||||
|
|
@ -244,7 +244,7 @@ defmodule Pleroma.Web.ActivityPub.SideEffectsTest do
|
|||
setup do
|
||||
poster = insert(:user)
|
||||
user = insert(:user)
|
||||
{:ok, post} = CommonAPI.post(poster, %{"status" => "hey"})
|
||||
{:ok, post} = CommonAPI.post(poster, %{status: "hey"})
|
||||
|
||||
{:ok, like_data, _meta} = Builder.like(user, post.object)
|
||||
{:ok, like, _meta} = ActivityPub.persist(like_data, local: true)
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.EmojiReactHandlingTest do
|
|||
test "it works for incoming emoji reactions" do
|
||||
user = insert(:user)
|
||||
other_user = insert(:user, local: false)
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "hello"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "hello"})
|
||||
|
||||
data =
|
||||
File.read!("test/fixtures/emoji-reaction.json")
|
||||
|
|
@ -40,7 +40,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.EmojiReactHandlingTest do
|
|||
test "it reject invalid emoji reactions" do
|
||||
user = insert(:user)
|
||||
other_user = insert(:user, local: false)
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "hello"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "hello"})
|
||||
|
||||
data =
|
||||
File.read!("test/fixtures/emoji-reaction-too-long.json")
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.LikeHandlingTest do
|
|||
test "it works for incoming likes" do
|
||||
user = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "hello"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "hello"})
|
||||
|
||||
data =
|
||||
File.read!("test/fixtures/mastodon-like.json")
|
||||
|
|
@ -36,7 +36,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.LikeHandlingTest do
|
|||
test "it works for incoming misskey likes, turning them into EmojiReacts" do
|
||||
user = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "hello"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "hello"})
|
||||
|
||||
data =
|
||||
File.read!("test/fixtures/misskey-like.json")
|
||||
|
|
@ -57,7 +57,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.LikeHandlingTest do
|
|||
test "it works for incoming misskey likes that contain unicode emojis, turning them into EmojiReacts" do
|
||||
user = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "hello"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "hello"})
|
||||
|
||||
data =
|
||||
File.read!("test/fixtures/misskey-like.json")
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.UndoHandlingTest do
|
|||
test "it works for incoming emoji reaction undos" do
|
||||
user = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "hello"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "hello"})
|
||||
{:ok, reaction_activity} = CommonAPI.react_with_emoji(activity.id, user, "👌")
|
||||
|
||||
data =
|
||||
|
|
@ -34,7 +34,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.UndoHandlingTest do
|
|||
|
||||
test "it returns an error for incoming unlikes wihout a like activity" do
|
||||
user = insert(:user)
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "leave a like pls"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "leave a like pls"})
|
||||
|
||||
data =
|
||||
File.read!("test/fixtures/mastodon-undo-like.json")
|
||||
|
|
@ -46,7 +46,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.UndoHandlingTest do
|
|||
|
||||
test "it works for incoming unlikes with an existing like activity" do
|
||||
user = insert(:user)
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "leave a like pls"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "leave a like pls"})
|
||||
|
||||
like_data =
|
||||
File.read!("test/fixtures/mastodon-like.json")
|
||||
|
|
@ -77,7 +77,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.UndoHandlingTest do
|
|||
|
||||
test "it works for incoming unlikes with an existing like activity and a compact object" do
|
||||
user = insert(:user)
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "leave a like pls"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "leave a like pls"})
|
||||
|
||||
like_data =
|
||||
File.read!("test/fixtures/mastodon-like.json")
|
||||
|
|
@ -104,7 +104,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.UndoHandlingTest do
|
|||
|
||||
test "it works for incoming unannounces with an existing notice" do
|
||||
user = insert(:user)
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "hey"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "hey"})
|
||||
|
||||
announce_data =
|
||||
File.read!("test/fixtures/mastodon-announce.json")
|
||||
|
|
|
|||
|
|
@ -212,8 +212,8 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(user, %{
|
||||
"status" => "suya...",
|
||||
"poll" => %{"options" => ["suya", "suya.", "suya.."], "expires_in" => 10}
|
||||
status: "suya...",
|
||||
poll: %{options: ["suya", "suya.", "suya.."], expires_in: 10}
|
||||
})
|
||||
|
||||
object = Object.normalize(activity)
|
||||
|
|
@ -263,7 +263,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
test "it works for incoming honk announces" do
|
||||
_user = insert(:user, ap_id: "https://honktest/u/test", local: false)
|
||||
other_user = insert(:user)
|
||||
{:ok, post} = CommonAPI.post(other_user, %{"status" => "bonkeronk"})
|
||||
{:ok, post} = CommonAPI.post(other_user, %{status: "bonkeronk"})
|
||||
|
||||
announce = %{
|
||||
"@context" => "https://www.w3.org/ns/activitystreams",
|
||||
|
|
@ -362,7 +362,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
|
||||
test "it works for incoming announces with an existing activity" do
|
||||
user = insert(:user)
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "hey"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "hey"})
|
||||
|
||||
data =
|
||||
File.read!("test/fixtures/mastodon-announce.json")
|
||||
|
|
@ -412,7 +412,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
|
||||
test "it does not clobber the addressing on announce activities" do
|
||||
user = insert(:user)
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "hey"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "hey"})
|
||||
|
||||
data =
|
||||
File.read!("test/fixtures/mastodon-announce.json")
|
||||
|
|
@ -498,7 +498,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
|
||||
test "it strips internal reactions" do
|
||||
user = insert(:user)
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "#cofe"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "#cofe"})
|
||||
{:ok, _} = CommonAPI.react_with_emoji(activity.id, user, "📢")
|
||||
|
||||
%{object: object} = Activity.get_by_id_with_object(activity.id)
|
||||
|
|
@ -996,7 +996,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
user = insert(:user)
|
||||
other_user = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "test post"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "test post"})
|
||||
object = Object.normalize(activity)
|
||||
|
||||
note_obj = %{
|
||||
|
|
@ -1140,13 +1140,13 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
setup do
|
||||
user = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "post1"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "post1"})
|
||||
|
||||
{:ok, reply1} =
|
||||
CommonAPI.post(user, %{"status" => "reply1", "in_reply_to_status_id" => activity.id})
|
||||
CommonAPI.post(user, %{status: "reply1", in_reply_to_status_id: activity.id})
|
||||
|
||||
{:ok, reply2} =
|
||||
CommonAPI.post(user, %{"status" => "reply2", "in_reply_to_status_id" => activity.id})
|
||||
CommonAPI.post(user, %{status: "reply2", in_reply_to_status_id: activity.id})
|
||||
|
||||
replies_uris = Enum.map([reply1, reply2], fn a -> a.object.data["id"] end)
|
||||
|
||||
|
|
@ -1186,7 +1186,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
test "it inlines private announced objects" do
|
||||
user = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "hey", "visibility" => "private"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "hey", visibility: "private"})
|
||||
|
||||
{:ok, announce_activity, _} = CommonAPI.repeat(activity.id, user)
|
||||
|
||||
|
|
@ -1201,7 +1201,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
other_user = insert(:user)
|
||||
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(user, %{"status" => "hey, @#{other_user.nickname}, how are ya? #2hu"})
|
||||
CommonAPI.post(user, %{status: "hey, @#{other_user.nickname}, how are ya? #2hu"})
|
||||
|
||||
{:ok, modified} = Transmogrifier.prepare_outgoing(activity.data)
|
||||
object = modified["object"]
|
||||
|
|
@ -1225,7 +1225,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
test "it adds the sensitive property" do
|
||||
user = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "#nsfw hey"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "#nsfw hey"})
|
||||
{:ok, modified} = Transmogrifier.prepare_outgoing(activity.data)
|
||||
|
||||
assert modified["object"]["sensitive"]
|
||||
|
|
@ -1234,7 +1234,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
test "it adds the json-ld context and the conversation property" do
|
||||
user = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "hey"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "hey"})
|
||||
{:ok, modified} = Transmogrifier.prepare_outgoing(activity.data)
|
||||
|
||||
assert modified["@context"] ==
|
||||
|
|
@ -1246,7 +1246,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
test "it sets the 'attributedTo' property to the actor of the object if it doesn't have one" do
|
||||
user = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "hey"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "hey"})
|
||||
{:ok, modified} = Transmogrifier.prepare_outgoing(activity.data)
|
||||
|
||||
assert modified["object"]["actor"] == modified["object"]["attributedTo"]
|
||||
|
|
@ -1255,7 +1255,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
test "it strips internal hashtag data" do
|
||||
user = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "#2hu"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "#2hu"})
|
||||
|
||||
expected_tag = %{
|
||||
"href" => Pleroma.Web.Endpoint.url() <> "/tags/2hu",
|
||||
|
|
@ -1271,7 +1271,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
test "it strips internal fields" do
|
||||
user = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "#2hu :firefox:"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "#2hu :firefox:"})
|
||||
|
||||
{:ok, modified} = Transmogrifier.prepare_outgoing(activity.data)
|
||||
|
||||
|
|
@ -1303,14 +1303,13 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
user = insert(:user)
|
||||
other_user = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "2hu :moominmamma:"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "2hu :moominmamma:"})
|
||||
|
||||
{:ok, modified} = Transmogrifier.prepare_outgoing(activity.data)
|
||||
|
||||
assert modified["directMessage"] == false
|
||||
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(user, %{"status" => "@#{other_user.nickname} :moominmamma:"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "@#{other_user.nickname} :moominmamma:"})
|
||||
|
||||
{:ok, modified} = Transmogrifier.prepare_outgoing(activity.data)
|
||||
|
||||
|
|
@ -1318,8 +1317,8 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(user, %{
|
||||
"status" => "@#{other_user.nickname} :moominmamma:",
|
||||
"visibility" => "direct"
|
||||
status: "@#{other_user.nickname} :moominmamma:",
|
||||
visibility: "direct"
|
||||
})
|
||||
|
||||
{:ok, modified} = Transmogrifier.prepare_outgoing(activity.data)
|
||||
|
|
@ -1331,8 +1330,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest 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}"})
|
||||
|
||||
{:ok, modified} = Transmogrifier.prepare_outgoing(activity.data)
|
||||
|
||||
|
|
@ -1367,8 +1365,8 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
user_two = insert(:user)
|
||||
Pleroma.FollowingRelationship.follow(user_two, user, :follow_accept)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "test"})
|
||||
{:ok, unrelated_activity} = CommonAPI.post(user_two, %{"status" => "test"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "test"})
|
||||
{:ok, unrelated_activity} = CommonAPI.post(user_two, %{status: "test"})
|
||||
assert "http://localhost:4001/users/rye@niu.moe/followers" in activity.recipients
|
||||
|
||||
user = User.get_cached_by_id(user.id)
|
||||
|
|
@ -1534,8 +1532,8 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
|
||||
{:ok, poll_activity} =
|
||||
CommonAPI.post(user, %{
|
||||
"status" => "suya...",
|
||||
"poll" => %{"options" => ["suya", "suya.", "suya.."], "expires_in" => 10}
|
||||
status: "suya...",
|
||||
poll: %{options: ["suya", "suya.", "suya.."], expires_in: 10}
|
||||
})
|
||||
|
||||
poll_object = Object.normalize(poll_activity)
|
||||
|
|
@ -1878,28 +1876,27 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
test "sets `replies` collection with a limited number of self-replies" do
|
||||
[user, another_user] = insert_list(2, :user)
|
||||
|
||||
{:ok, %{id: id1} = activity} = CommonAPI.post(user, %{"status" => "1"})
|
||||
{:ok, %{id: id1} = activity} = CommonAPI.post(user, %{status: "1"})
|
||||
|
||||
{:ok, %{id: id2} = self_reply1} =
|
||||
CommonAPI.post(user, %{"status" => "self-reply 1", "in_reply_to_status_id" => id1})
|
||||
CommonAPI.post(user, %{status: "self-reply 1", in_reply_to_status_id: id1})
|
||||
|
||||
{:ok, self_reply2} =
|
||||
CommonAPI.post(user, %{"status" => "self-reply 2", "in_reply_to_status_id" => id1})
|
||||
CommonAPI.post(user, %{status: "self-reply 2", in_reply_to_status_id: id1})
|
||||
|
||||
# Assuming to _not_ be present in `replies` due to :note_replies_output_limit is set to 2
|
||||
{:ok, _} =
|
||||
CommonAPI.post(user, %{"status" => "self-reply 3", "in_reply_to_status_id" => id1})
|
||||
{:ok, _} = CommonAPI.post(user, %{status: "self-reply 3", in_reply_to_status_id: id1})
|
||||
|
||||
{:ok, _} =
|
||||
CommonAPI.post(user, %{
|
||||
"status" => "self-reply to self-reply",
|
||||
"in_reply_to_status_id" => id2
|
||||
status: "self-reply to self-reply",
|
||||
in_reply_to_status_id: id2
|
||||
})
|
||||
|
||||
{:ok, _} =
|
||||
CommonAPI.post(another_user, %{
|
||||
"status" => "another user's reply",
|
||||
"in_reply_to_status_id" => id1
|
||||
status: "another user's reply",
|
||||
in_reply_to_status_id: id1
|
||||
})
|
||||
|
||||
object = Object.normalize(activity)
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ defmodule Pleroma.Web.ActivityPub.UtilsTest do
|
|||
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(user, %{
|
||||
"status" =>
|
||||
status:
|
||||
"hey @#{other_user.nickname}, @#{third_user.nickname} how about beering together this weekend?"
|
||||
})
|
||||
|
||||
|
|
@ -139,8 +139,8 @@ defmodule Pleroma.Web.ActivityPub.UtilsTest do
|
|||
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(user, %{
|
||||
"status" => "@#{other_user.nickname} @#{third_user.nickname} bought a new swimsuit!",
|
||||
"visibility" => "private"
|
||||
status: "@#{other_user.nickname} @#{third_user.nickname} bought a new swimsuit!",
|
||||
visibility: "private"
|
||||
})
|
||||
|
||||
%{"to" => to, "cc" => cc} = Utils.make_like_data(other_user, activity, nil)
|
||||
|
|
@ -168,11 +168,11 @@ defmodule Pleroma.Web.ActivityPub.UtilsTest do
|
|||
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(user, %{
|
||||
"status" => "How do I pronounce LaTeX?",
|
||||
"poll" => %{
|
||||
"options" => ["laytekh", "lahtekh", "latex"],
|
||||
"expires_in" => 20,
|
||||
"multiple" => true
|
||||
status: "How do I pronounce LaTeX?",
|
||||
poll: %{
|
||||
options: ["laytekh", "lahtekh", "latex"],
|
||||
expires_in: 20,
|
||||
multiple: true
|
||||
}
|
||||
})
|
||||
|
||||
|
|
@ -187,10 +187,10 @@ defmodule Pleroma.Web.ActivityPub.UtilsTest do
|
|||
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(user, %{
|
||||
"status" => "Are we living in a society?",
|
||||
"poll" => %{
|
||||
"options" => ["yes", "no"],
|
||||
"expires_in" => 20
|
||||
status: "Are we living in a society?",
|
||||
poll: %{
|
||||
options: ["yes", "no"],
|
||||
expires_in: 20
|
||||
}
|
||||
})
|
||||
|
||||
|
|
@ -469,7 +469,7 @@ defmodule Pleroma.Web.ActivityPub.UtilsTest do
|
|||
test "returns map with Flag object" do
|
||||
reporter = insert(:user)
|
||||
target_account = insert(:user)
|
||||
{:ok, activity} = CommonAPI.post(target_account, %{"status" => "foobar"})
|
||||
{:ok, activity} = CommonAPI.post(target_account, %{status: "foobar"})
|
||||
context = Utils.generate_context_id()
|
||||
content = "foobar"
|
||||
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectViewTest do
|
|||
activity = insert(:note_activity, user: user)
|
||||
|
||||
{:ok, self_reply1} =
|
||||
CommonAPI.post(user, %{"status" => "self-reply 1", "in_reply_to_status_id" => activity.id})
|
||||
CommonAPI.post(user, %{status: "self-reply 1", in_reply_to_status_id: activity.id})
|
||||
|
||||
replies_uris = [self_reply1.object.data["id"]]
|
||||
result = ObjectView.render("object.json", %{object: refresh_record(activity)})
|
||||
|
|
|
|||
|
|
@ -164,7 +164,7 @@ defmodule Pleroma.Web.ActivityPub.UserViewTest do
|
|||
|
||||
posts =
|
||||
for i <- 0..25 do
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "post #{i}"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "post #{i}"})
|
||||
activity
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -21,21 +21,21 @@ defmodule Pleroma.Web.ActivityPub.VisibilityTest do
|
|||
Pleroma.List.follow(list, unrelated)
|
||||
|
||||
{:ok, public} =
|
||||
CommonAPI.post(user, %{"status" => "@#{mentioned.nickname}", "visibility" => "public"})
|
||||
CommonAPI.post(user, %{status: "@#{mentioned.nickname}", visibility: "public"})
|
||||
|
||||
{:ok, private} =
|
||||
CommonAPI.post(user, %{"status" => "@#{mentioned.nickname}", "visibility" => "private"})
|
||||
CommonAPI.post(user, %{status: "@#{mentioned.nickname}", visibility: "private"})
|
||||
|
||||
{:ok, direct} =
|
||||
CommonAPI.post(user, %{"status" => "@#{mentioned.nickname}", "visibility" => "direct"})
|
||||
CommonAPI.post(user, %{status: "@#{mentioned.nickname}", visibility: "direct"})
|
||||
|
||||
{:ok, unlisted} =
|
||||
CommonAPI.post(user, %{"status" => "@#{mentioned.nickname}", "visibility" => "unlisted"})
|
||||
CommonAPI.post(user, %{status: "@#{mentioned.nickname}", visibility: "unlisted"})
|
||||
|
||||
{:ok, list} =
|
||||
CommonAPI.post(user, %{
|
||||
"status" => "@#{mentioned.nickname}",
|
||||
"visibility" => "list:#{list.id}"
|
||||
status: "@#{mentioned.nickname}",
|
||||
visibility: "list:#{list.id}"
|
||||
})
|
||||
|
||||
%{
|
||||
|
|
|
|||
|
|
@ -1747,7 +1747,7 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
test "change visibility flag", %{conn: conn, id: id, admin: admin} do
|
||||
response =
|
||||
conn
|
||||
|> put("/api/pleroma/admin/statuses/#{id}", %{"visibility" => "public"})
|
||||
|> put("/api/pleroma/admin/statuses/#{id}", %{visibility: "public"})
|
||||
|> json_response(:ok)
|
||||
|
||||
assert response["visibility"] == "public"
|
||||
|
|
@ -1759,21 +1759,21 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
|
||||
response =
|
||||
conn
|
||||
|> put("/api/pleroma/admin/statuses/#{id}", %{"visibility" => "private"})
|
||||
|> put("/api/pleroma/admin/statuses/#{id}", %{visibility: "private"})
|
||||
|> json_response(:ok)
|
||||
|
||||
assert response["visibility"] == "private"
|
||||
|
||||
response =
|
||||
conn
|
||||
|> put("/api/pleroma/admin/statuses/#{id}", %{"visibility" => "unlisted"})
|
||||
|> put("/api/pleroma/admin/statuses/#{id}", %{visibility: "unlisted"})
|
||||
|> json_response(:ok)
|
||||
|
||||
assert response["visibility"] == "unlisted"
|
||||
end
|
||||
|
||||
test "returns 400 when visibility is unknown", %{conn: conn, id: id} do
|
||||
conn = put(conn, "/api/pleroma/admin/statuses/#{id}", %{"visibility" => "test"})
|
||||
conn = put(conn, "/api/pleroma/admin/statuses/#{id}", %{visibility: "test"})
|
||||
|
||||
assert json_response(conn, :bad_request) == "Unsupported visibility"
|
||||
end
|
||||
|
|
@ -2977,13 +2977,12 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
user = insert(:user)
|
||||
User.block(admin, blocked)
|
||||
|
||||
{:ok, _} =
|
||||
CommonAPI.post(user, %{"status" => "@#{admin.nickname}", "visibility" => "direct"})
|
||||
{:ok, _} = CommonAPI.post(user, %{status: "@#{admin.nickname}", visibility: "direct"})
|
||||
|
||||
{:ok, _} = CommonAPI.post(user, %{"status" => ".", "visibility" => "unlisted"})
|
||||
{:ok, _} = CommonAPI.post(user, %{"status" => ".", "visibility" => "private"})
|
||||
{:ok, _} = CommonAPI.post(user, %{"status" => ".", "visibility" => "public"})
|
||||
{:ok, _} = CommonAPI.post(blocked, %{"status" => ".", "visibility" => "public"})
|
||||
{:ok, _} = CommonAPI.post(user, %{status: ".", visibility: "unlisted"})
|
||||
{:ok, _} = CommonAPI.post(user, %{status: ".", visibility: "private"})
|
||||
{:ok, _} = CommonAPI.post(user, %{status: ".", visibility: "public"})
|
||||
{:ok, _} = CommonAPI.post(blocked, %{status: ".", visibility: "public"})
|
||||
|
||||
response =
|
||||
conn
|
||||
|
|
@ -3011,11 +3010,10 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
test "returns private and direct statuses with godmode on", %{conn: conn, admin: admin} do
|
||||
user = insert(:user)
|
||||
|
||||
{:ok, _} =
|
||||
CommonAPI.post(user, %{"status" => "@#{admin.nickname}", "visibility" => "direct"})
|
||||
{:ok, _} = CommonAPI.post(user, %{status: "@#{admin.nickname}", visibility: "direct"})
|
||||
|
||||
{:ok, _} = CommonAPI.post(user, %{"status" => ".", "visibility" => "private"})
|
||||
{:ok, _} = CommonAPI.post(user, %{"status" => ".", "visibility" => "public"})
|
||||
{:ok, _} = CommonAPI.post(user, %{status: ".", visibility: "private"})
|
||||
{:ok, _} = CommonAPI.post(user, %{status: ".", visibility: "public"})
|
||||
conn = get(conn, "/api/pleroma/admin/statuses?godmode=true")
|
||||
assert json_response(conn, 200) |> length() == 3
|
||||
end
|
||||
|
|
@ -3049,11 +3047,9 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
end
|
||||
|
||||
test "doesn't return private statuses by default", %{conn: conn, user: user} do
|
||||
{:ok, _private_status} =
|
||||
CommonAPI.post(user, %{"status" => "private", "visibility" => "private"})
|
||||
{:ok, _private_status} = CommonAPI.post(user, %{status: "private", visibility: "private"})
|
||||
|
||||
{:ok, _public_status} =
|
||||
CommonAPI.post(user, %{"status" => "public", "visibility" => "public"})
|
||||
{:ok, _public_status} = CommonAPI.post(user, %{status: "public", visibility: "public"})
|
||||
|
||||
conn = get(conn, "/api/pleroma/admin/users/#{user.nickname}/statuses")
|
||||
|
||||
|
|
@ -3061,11 +3057,9 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
end
|
||||
|
||||
test "returns private statuses with godmode on", %{conn: conn, user: user} do
|
||||
{:ok, _private_status} =
|
||||
CommonAPI.post(user, %{"status" => "private", "visibility" => "private"})
|
||||
{:ok, _private_status} = CommonAPI.post(user, %{status: "private", visibility: "private"})
|
||||
|
||||
{:ok, _public_status} =
|
||||
CommonAPI.post(user, %{"status" => "public", "visibility" => "public"})
|
||||
{:ok, _public_status} = CommonAPI.post(user, %{status: "public", visibility: "public"})
|
||||
|
||||
conn = get(conn, "/api/pleroma/admin/users/#{user.nickname}/statuses?godmode=true")
|
||||
|
||||
|
|
@ -3074,7 +3068,7 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
|
||||
test "excludes reblogs by default", %{conn: conn, user: user} do
|
||||
other_user = insert(:user)
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "."})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "."})
|
||||
{:ok, %Activity{}, _} = CommonAPI.repeat(activity.id, other_user)
|
||||
|
||||
conn_res = get(conn, "/api/pleroma/admin/users/#{other_user.nickname}/statuses")
|
||||
|
|
@ -3599,9 +3593,9 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
test "status visibility count", %{conn: conn} do
|
||||
admin = insert(:user, is_admin: true)
|
||||
user = insert(:user)
|
||||
CommonAPI.post(user, %{"visibility" => "public", "status" => "hey"})
|
||||
CommonAPI.post(user, %{"visibility" => "unlisted", "status" => "hey"})
|
||||
CommonAPI.post(user, %{"visibility" => "unlisted", "status" => "hey"})
|
||||
CommonAPI.post(user, %{visibility: "public", status: "hey"})
|
||||
CommonAPI.post(user, %{visibility: "unlisted", status: "hey"})
|
||||
CommonAPI.post(user, %{visibility: "unlisted", status: "hey"})
|
||||
|
||||
response =
|
||||
conn
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ defmodule Pleroma.Web.AdminAPI.ReportViewTest do
|
|||
test "includes reported statuses" do
|
||||
user = insert(:user)
|
||||
other_user = insert(:user)
|
||||
{:ok, activity} = CommonAPI.post(other_user, %{"status" => "toot"})
|
||||
{:ok, activity} = CommonAPI.post(other_user, %{status: "toot"})
|
||||
|
||||
{:ok, report_activity} =
|
||||
CommonAPI.report(user, %{account_id: other_user.id, status_ids: [activity.id]})
|
||||
|
|
|
|||
|
|
@ -27,7 +27,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()
|
||||
|
|
@ -45,7 +45,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
|
||||
|
|
@ -61,7 +61,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)
|
||||
|
|
@ -71,7 +71,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
|
||||
|
|
@ -83,7 +83,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
|
||||
|
|
@ -124,7 +124,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 ->
|
||||
|
|
@ -151,7 +151,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 ->
|
||||
|
|
@ -175,12 +175,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)
|
||||
|
||||
|
|
@ -194,8 +194,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
|
||||
|
|
@ -205,10 +205,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
|
||||
|
|
@ -225,8 +225,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
|
||||
|
|
@ -235,7 +235,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)
|
||||
|
||||
|
|
@ -244,7 +244,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
|
||||
|
|
@ -258,9 +258,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
|
||||
|
|
@ -276,8 +276,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)
|
||||
|
|
@ -292,8 +292,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)
|
||||
|
|
@ -304,21 +304,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
|
||||
|
|
@ -327,8 +327,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]
|
||||
|
|
@ -339,7 +338,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
|
||||
|
|
@ -348,9 +347,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
|
||||
|
|
@ -361,8 +360,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
|
||||
|
|
@ -374,14 +372,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
|
||||
|
|
@ -390,7 +388,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, "👍")
|
||||
|
|
@ -404,7 +402,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
|
||||
|
|
@ -412,7 +410,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)
|
||||
|
||||
|
|
@ -423,10 +421,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
|
||||
|
|
@ -435,7 +433,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"
|
||||
|
|
@ -447,7 +445,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
|
||||
|
|
@ -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.favorite(user, activity.id)
|
||||
assert {:ok, :already_liked} = CommonAPI.favorite(user, activity.id)
|
||||
end
|
||||
|
|
@ -467,7 +465,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
|
||||
|
|
@ -484,8 +482,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)
|
||||
|
|
@ -497,7 +495,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
|
||||
|
||||
|
|
@ -508,7 +506,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)
|
||||
|
||||
|
|
@ -576,7 +574,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
|
||||
|
|
@ -813,8 +811,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)
|
||||
|
|
|
|||
|
|
@ -228,7 +228,7 @@ defmodule Pleroma.Web.CommonAPI.UtilsTest do
|
|||
user = insert(:user)
|
||||
mentioned_user = insert(:user)
|
||||
third_user = insert(:user)
|
||||
{:ok, activity} = CommonAPI.post(third_user, %{"status" => "uguu"})
|
||||
{:ok, activity} = CommonAPI.post(third_user, %{status: "uguu"})
|
||||
mentions = [mentioned_user.ap_id]
|
||||
|
||||
{to, cc} = Utils.get_to_and_cc(user, mentions, activity, "public", nil)
|
||||
|
|
@ -261,7 +261,7 @@ defmodule Pleroma.Web.CommonAPI.UtilsTest do
|
|||
user = insert(:user)
|
||||
mentioned_user = insert(:user)
|
||||
third_user = insert(:user)
|
||||
{:ok, activity} = CommonAPI.post(third_user, %{"status" => "uguu"})
|
||||
{:ok, activity} = CommonAPI.post(third_user, %{status: "uguu"})
|
||||
mentions = [mentioned_user.ap_id]
|
||||
|
||||
{to, cc} = Utils.get_to_and_cc(user, mentions, activity, "unlisted", nil)
|
||||
|
|
@ -292,7 +292,7 @@ defmodule Pleroma.Web.CommonAPI.UtilsTest do
|
|||
user = insert(:user)
|
||||
mentioned_user = insert(:user)
|
||||
third_user = insert(:user)
|
||||
{:ok, activity} = CommonAPI.post(third_user, %{"status" => "uguu"})
|
||||
{:ok, activity} = CommonAPI.post(third_user, %{status: "uguu"})
|
||||
mentions = [mentioned_user.ap_id]
|
||||
|
||||
{to, cc} = Utils.get_to_and_cc(user, mentions, activity, "private", nil)
|
||||
|
|
@ -322,7 +322,7 @@ defmodule Pleroma.Web.CommonAPI.UtilsTest do
|
|||
user = insert(:user)
|
||||
mentioned_user = insert(:user)
|
||||
third_user = insert(:user)
|
||||
{:ok, activity} = CommonAPI.post(third_user, %{"status" => "uguu"})
|
||||
{:ok, activity} = CommonAPI.post(third_user, %{status: "uguu"})
|
||||
mentions = [mentioned_user.ap_id]
|
||||
|
||||
{to, cc} = Utils.get_to_and_cc(user, mentions, activity, "direct", nil)
|
||||
|
|
@ -463,8 +463,8 @@ defmodule Pleroma.Web.CommonAPI.UtilsTest do
|
|||
desc = Jason.encode!(%{object.id => "test-desc"})
|
||||
|
||||
assert Utils.attachments_from_ids(%{
|
||||
"media_ids" => ["#{object.id}"],
|
||||
"descriptions" => desc
|
||||
media_ids: ["#{object.id}"],
|
||||
descriptions: desc
|
||||
}) == [
|
||||
Map.merge(object.data, %{"name" => "test-desc"})
|
||||
]
|
||||
|
|
@ -472,7 +472,7 @@ defmodule Pleroma.Web.CommonAPI.UtilsTest do
|
|||
|
||||
test "returns attachments without descs" do
|
||||
object = insert(:note)
|
||||
assert Utils.attachments_from_ids(%{"media_ids" => ["#{object.id}"]}) == [object.data]
|
||||
assert Utils.attachments_from_ids(%{media_ids: ["#{object.id}"]}) == [object.data]
|
||||
end
|
||||
|
||||
test "returns [] when not pass media_ids" do
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ defmodule Pleroma.Web.FederatorTest do
|
|||
describe "Publish an activity" do
|
||||
setup do
|
||||
user = insert(:user)
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "HI"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "HI"})
|
||||
|
||||
relay_mock = {
|
||||
Pleroma.Web.ActivityPub.Relay,
|
||||
|
|
@ -96,7 +96,7 @@ defmodule Pleroma.Web.FederatorTest do
|
|||
Instances.set_consistently_unreachable(URI.parse(inbox2).host)
|
||||
|
||||
{:ok, _activity} =
|
||||
CommonAPI.post(user, %{"status" => "HI @nick1@domain.com, @nick2@domain2.com!"})
|
||||
CommonAPI.post(user, %{status: "HI @nick1@domain.com, @nick2@domain2.com!"})
|
||||
|
||||
expected_dt = NaiveDateTime.to_iso8601(dt)
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ defmodule Pleroma.Web.Feed.TagControllerTest do
|
|||
)
|
||||
|
||||
user = insert(:user)
|
||||
{:ok, activity1} = CommonAPI.post(user, %{"status" => "yeah #PleromaArt"})
|
||||
{:ok, activity1} = CommonAPI.post(user, %{status: "yeah #PleromaArt"})
|
||||
|
||||
object = Object.normalize(activity1)
|
||||
|
||||
|
|
@ -43,9 +43,9 @@ defmodule Pleroma.Web.Feed.TagControllerTest do
|
|||
|> Ecto.Changeset.change(data: object_data)
|
||||
|> Pleroma.Repo.update()
|
||||
|
||||
{:ok, activity2} = CommonAPI.post(user, %{"status" => "42 This is :moominmamma #PleromaArt"})
|
||||
{:ok, activity2} = CommonAPI.post(user, %{status: "42 This is :moominmamma #PleromaArt"})
|
||||
|
||||
{:ok, _activity3} = CommonAPI.post(user, %{"status" => "This is :moominmamma"})
|
||||
{:ok, _activity3} = CommonAPI.post(user, %{status: "This is :moominmamma"})
|
||||
|
||||
response =
|
||||
conn
|
||||
|
|
@ -88,7 +88,7 @@ defmodule Pleroma.Web.Feed.TagControllerTest do
|
|||
)
|
||||
|
||||
user = insert(:user)
|
||||
{:ok, activity1} = CommonAPI.post(user, %{"status" => "yeah #PleromaArt"})
|
||||
{:ok, activity1} = CommonAPI.post(user, %{status: "yeah #PleromaArt"})
|
||||
|
||||
object = Object.normalize(activity1)
|
||||
|
||||
|
|
@ -110,9 +110,9 @@ defmodule Pleroma.Web.Feed.TagControllerTest do
|
|||
|> Ecto.Changeset.change(data: object_data)
|
||||
|> Pleroma.Repo.update()
|
||||
|
||||
{:ok, activity2} = CommonAPI.post(user, %{"status" => "42 This is :moominmamma #PleromaArt"})
|
||||
{:ok, activity2} = CommonAPI.post(user, %{status: "42 This is :moominmamma #PleromaArt"})
|
||||
|
||||
{:ok, _activity3} = CommonAPI.post(user, %{"status" => "This is :moominmamma"})
|
||||
{:ok, _activity3} = CommonAPI.post(user, %{status: "This is :moominmamma"})
|
||||
|
||||
response =
|
||||
conn
|
||||
|
|
|
|||
|
|
@ -226,7 +226,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
|||
user = insert(:user, ap_id: "https://honktest/u/test", local: false)
|
||||
other_user = insert(:user)
|
||||
|
||||
{:ok, post} = CommonAPI.post(other_user, %{"status" => "bonkeronk"})
|
||||
{:ok, post} = CommonAPI.post(other_user, %{status: "bonkeronk"})
|
||||
|
||||
{:ok, announce, _} =
|
||||
%{
|
||||
|
|
@ -255,7 +255,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
|||
|
||||
User.block(user_one, user_two)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user_two, %{"status" => "User one sux0rz"})
|
||||
{:ok, activity} = CommonAPI.post(user_two, %{status: "User one sux0rz"})
|
||||
{:ok, repeat, _} = CommonAPI.repeat(activity.id, user_three)
|
||||
|
||||
assert resp =
|
||||
|
|
@ -298,16 +298,16 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
|||
|
||||
{:ok, _user_three} = User.follow(user_three, user_one)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user_one, %{"status" => "HI!!!"})
|
||||
{:ok, activity} = CommonAPI.post(user_one, %{status: "HI!!!"})
|
||||
|
||||
{:ok, direct_activity} =
|
||||
CommonAPI.post(user_one, %{
|
||||
"status" => "Hi, @#{user_two.nickname}.",
|
||||
"visibility" => "direct"
|
||||
status: "Hi, @#{user_two.nickname}.",
|
||||
visibility: "direct"
|
||||
})
|
||||
|
||||
{:ok, private_activity} =
|
||||
CommonAPI.post(user_one, %{"status" => "private", "visibility" => "private"})
|
||||
CommonAPI.post(user_one, %{status: "private", visibility: "private"})
|
||||
|
||||
# TODO!!!
|
||||
resp =
|
||||
|
|
@ -362,8 +362,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
|||
|
||||
{:ok, %{id: media_id}} = ActivityPub.upload(file, actor: user.ap_id)
|
||||
|
||||
{:ok, %{id: image_post_id}} =
|
||||
CommonAPI.post(user, %{"status" => "cofe", "media_ids" => [media_id]})
|
||||
{:ok, %{id: image_post_id}} = CommonAPI.post(user, %{status: "cofe", media_ids: [media_id]})
|
||||
|
||||
conn = get(conn, "/api/v1/accounts/#{user.id}/statuses?only_media=true")
|
||||
|
||||
|
|
@ -375,7 +374,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
|||
end
|
||||
|
||||
test "gets a user's statuses without reblogs", %{user: user, conn: conn} do
|
||||
{:ok, %{id: post_id}} = CommonAPI.post(user, %{"status" => "HI!!!"})
|
||||
{:ok, %{id: post_id}} = CommonAPI.post(user, %{status: "HI!!!"})
|
||||
{:ok, _, _} = CommonAPI.repeat(post_id, user)
|
||||
|
||||
conn = get(conn, "/api/v1/accounts/#{user.id}/statuses?exclude_reblogs=true")
|
||||
|
|
@ -386,8 +385,8 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
|||
end
|
||||
|
||||
test "filters user's statuses by a hashtag", %{user: user, conn: conn} do
|
||||
{:ok, %{id: post_id}} = CommonAPI.post(user, %{"status" => "#hashtag"})
|
||||
{:ok, _post} = CommonAPI.post(user, %{"status" => "hashtag"})
|
||||
{:ok, %{id: post_id}} = CommonAPI.post(user, %{status: "#hashtag"})
|
||||
{:ok, _post} = CommonAPI.post(user, %{status: "hashtag"})
|
||||
|
||||
conn = get(conn, "/api/v1/accounts/#{user.id}/statuses?tagged=hashtag")
|
||||
assert [%{"id" => ^post_id}] = json_response_and_validate_schema(conn, 200)
|
||||
|
|
@ -398,9 +397,9 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
|||
conn: conn
|
||||
} do
|
||||
{:ok, %{id: public_activity_id}} =
|
||||
CommonAPI.post(user, %{"status" => ".", "visibility" => "public"})
|
||||
CommonAPI.post(user, %{status: ".", visibility: "public"})
|
||||
|
||||
{:ok, _direct_activity} = CommonAPI.post(user, %{"status" => ".", "visibility" => "direct"})
|
||||
{:ok, _direct_activity} = CommonAPI.post(user, %{status: ".", visibility: "direct"})
|
||||
|
||||
conn = get(conn, "/api/v1/accounts/#{user.id}/statuses?exclude_visibilities[]=direct")
|
||||
assert [%{"id" => ^public_activity_id}] = json_response_and_validate_schema(conn, 200)
|
||||
|
|
@ -678,7 +677,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
|||
|
||||
assert %{"showing_reblogs" => false} = json_response_and_validate_schema(ret_conn, 200)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(other_user, %{"status" => "hey"})
|
||||
{:ok, activity} = CommonAPI.post(other_user, %{status: "hey"})
|
||||
{:ok, %{id: reblog_id}, _} = CommonAPI.repeat(activity.id, followed)
|
||||
|
||||
assert [] ==
|
||||
|
|
@ -777,7 +776,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
|||
describe "pinned statuses" do
|
||||
setup do
|
||||
user = insert(:user)
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "HI!!!"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "HI!!!"})
|
||||
%{conn: conn} = oauth_access(["read:statuses"], user: user)
|
||||
|
||||
[conn: conn, user: user, activity: activity]
|
||||
|
|
|
|||
|
|
@ -22,16 +22,16 @@ defmodule Pleroma.Web.MastodonAPI.ConversationControllerTest do
|
|||
|
||||
{:ok, direct} =
|
||||
CommonAPI.post(user_one, %{
|
||||
"status" => "Hi @#{user_two.nickname}, @#{user_three.nickname}!",
|
||||
"visibility" => "direct"
|
||||
status: "Hi @#{user_two.nickname}, @#{user_three.nickname}!",
|
||||
visibility: "direct"
|
||||
})
|
||||
|
||||
assert User.get_cached_by_id(user_two.id).unread_conversation_count == 1
|
||||
|
||||
{:ok, _follower_only} =
|
||||
CommonAPI.post(user_one, %{
|
||||
"status" => "Hi @#{user_two.nickname}!",
|
||||
"visibility" => "private"
|
||||
status: "Hi @#{user_two.nickname}!",
|
||||
visibility: "private"
|
||||
})
|
||||
|
||||
res_conn = get(conn, "/api/v1/conversations")
|
||||
|
|
@ -63,32 +63,32 @@ defmodule Pleroma.Web.MastodonAPI.ConversationControllerTest do
|
|||
|
||||
{:ok, direct1} =
|
||||
CommonAPI.post(user_one, %{
|
||||
"status" => "Hi @#{user_two.nickname}!",
|
||||
"visibility" => "direct"
|
||||
status: "Hi @#{user_two.nickname}!",
|
||||
visibility: "direct"
|
||||
})
|
||||
|
||||
{:ok, _direct2} =
|
||||
CommonAPI.post(user_one, %{
|
||||
"status" => "Hi @#{user_three.nickname}!",
|
||||
"visibility" => "direct"
|
||||
status: "Hi @#{user_three.nickname}!",
|
||||
visibility: "direct"
|
||||
})
|
||||
|
||||
{:ok, direct3} =
|
||||
CommonAPI.post(user_one, %{
|
||||
"status" => "Hi @#{user_two.nickname}, @#{user_three.nickname}!",
|
||||
"visibility" => "direct"
|
||||
status: "Hi @#{user_two.nickname}, @#{user_three.nickname}!",
|
||||
visibility: "direct"
|
||||
})
|
||||
|
||||
{:ok, _direct4} =
|
||||
CommonAPI.post(user_two, %{
|
||||
"status" => "Hi @#{user_three.nickname}!",
|
||||
"visibility" => "direct"
|
||||
status: "Hi @#{user_three.nickname}!",
|
||||
visibility: "direct"
|
||||
})
|
||||
|
||||
{:ok, direct5} =
|
||||
CommonAPI.post(user_two, %{
|
||||
"status" => "Hi @#{user_one.nickname}!",
|
||||
"visibility" => "direct"
|
||||
status: "Hi @#{user_one.nickname}!",
|
||||
visibility: "direct"
|
||||
})
|
||||
|
||||
assert [conversation1, conversation2] =
|
||||
|
|
@ -112,15 +112,15 @@ defmodule Pleroma.Web.MastodonAPI.ConversationControllerTest do
|
|||
|
||||
{:ok, direct} =
|
||||
CommonAPI.post(user_one, %{
|
||||
"status" => "Hi @#{user_two.nickname}",
|
||||
"visibility" => "direct"
|
||||
status: "Hi @#{user_two.nickname}",
|
||||
visibility: "direct"
|
||||
})
|
||||
|
||||
{:ok, direct_reply} =
|
||||
CommonAPI.post(user_two, %{
|
||||
"status" => "reply",
|
||||
"visibility" => "direct",
|
||||
"in_reply_to_status_id" => direct.id
|
||||
status: "reply",
|
||||
visibility: "direct",
|
||||
in_reply_to_status_id: direct.id
|
||||
})
|
||||
|
||||
[%{"last_status" => res_last_status}] =
|
||||
|
|
@ -136,8 +136,8 @@ defmodule Pleroma.Web.MastodonAPI.ConversationControllerTest do
|
|||
|
||||
{:ok, direct} =
|
||||
CommonAPI.post(user_one, %{
|
||||
"status" => "Hi @#{user_two.nickname}",
|
||||
"visibility" => "direct"
|
||||
status: "Hi @#{user_two.nickname}",
|
||||
visibility: "direct"
|
||||
})
|
||||
|
||||
assert User.get_cached_by_id(user_one.id).unread_conversation_count == 0
|
||||
|
|
@ -167,9 +167,9 @@ defmodule Pleroma.Web.MastodonAPI.ConversationControllerTest do
|
|||
# The conversation is marked as unread on reply
|
||||
{:ok, _} =
|
||||
CommonAPI.post(user_two, %{
|
||||
"status" => "reply",
|
||||
"visibility" => "direct",
|
||||
"in_reply_to_status_id" => direct.id
|
||||
status: "reply",
|
||||
visibility: "direct",
|
||||
in_reply_to_status_id: direct.id
|
||||
})
|
||||
|
||||
[%{"unread" => true}] =
|
||||
|
|
@ -183,9 +183,9 @@ defmodule Pleroma.Web.MastodonAPI.ConversationControllerTest do
|
|||
# A reply doesn't increment the user's unread_conversation_count if the conversation is unread
|
||||
{:ok, _} =
|
||||
CommonAPI.post(user_two, %{
|
||||
"status" => "reply",
|
||||
"visibility" => "direct",
|
||||
"in_reply_to_status_id" => direct.id
|
||||
status: "reply",
|
||||
visibility: "direct",
|
||||
in_reply_to_status_id: direct.id
|
||||
})
|
||||
|
||||
assert User.get_cached_by_id(user_one.id).unread_conversation_count == 1
|
||||
|
|
@ -197,8 +197,8 @@ defmodule Pleroma.Web.MastodonAPI.ConversationControllerTest do
|
|||
|
||||
{:ok, direct} =
|
||||
CommonAPI.post(user_one, %{
|
||||
"status" => "Hi @#{user_two.nickname}!",
|
||||
"visibility" => "direct"
|
||||
status: "Hi @#{user_two.nickname}!",
|
||||
visibility: "direct"
|
||||
})
|
||||
|
||||
res_conn = get(conn, "/api/v1/statuses/#{direct.id}/context")
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ defmodule Pleroma.Web.MastodonAPI.InstanceControllerTest do
|
|||
insert(:user, %{local: false, nickname: "u@peer1.com"})
|
||||
insert(:user, %{local: false, nickname: "u@peer2.com"})
|
||||
|
||||
{:ok, _} = Pleroma.Web.CommonAPI.post(user, %{"status" => "cofe"})
|
||||
{:ok, _} = Pleroma.Web.CommonAPI.post(user, %{status: "cofe"})
|
||||
|
||||
Pleroma.Stats.force_update()
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ defmodule Pleroma.Web.MastodonAPI.NotificationControllerTest do
|
|||
%{user: user, conn: conn} = oauth_access(["read:notifications"])
|
||||
other_user = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(other_user, %{"status" => "hi @#{user.nickname}"})
|
||||
{:ok, activity} = CommonAPI.post(other_user, %{status: "hi @#{user.nickname}"})
|
||||
{:ok, [_notification]} = Notification.create_notifications(activity)
|
||||
|
||||
response =
|
||||
|
|
@ -36,7 +36,7 @@ defmodule Pleroma.Web.MastodonAPI.NotificationControllerTest do
|
|||
%{user: user, conn: conn} = oauth_access(["read:notifications"])
|
||||
other_user = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(other_user, %{"status" => "hi @#{user.nickname}"})
|
||||
{:ok, activity} = CommonAPI.post(other_user, %{status: "hi @#{user.nickname}"})
|
||||
|
||||
{:ok, [_notification]} = Notification.create_notifications(activity)
|
||||
|
||||
|
|
@ -60,7 +60,7 @@ defmodule Pleroma.Web.MastodonAPI.NotificationControllerTest do
|
|||
%{user: user, conn: conn} = oauth_access(["read:notifications"])
|
||||
other_user = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(other_user, %{"status" => "hi @#{user.nickname}"})
|
||||
{:ok, activity} = CommonAPI.post(other_user, %{status: "hi @#{user.nickname}"})
|
||||
|
||||
{:ok, [notification]} = Notification.create_notifications(activity)
|
||||
|
||||
|
|
@ -79,7 +79,7 @@ defmodule Pleroma.Web.MastodonAPI.NotificationControllerTest do
|
|||
%{user: user, conn: conn} = oauth_access(["write:notifications"])
|
||||
other_user = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(other_user, %{"status" => "hi @#{user.nickname}"})
|
||||
{:ok, activity} = CommonAPI.post(other_user, %{status: "hi @#{user.nickname}"})
|
||||
|
||||
{:ok, [notification]} = Notification.create_notifications(activity)
|
||||
|
||||
|
|
@ -96,7 +96,7 @@ defmodule Pleroma.Web.MastodonAPI.NotificationControllerTest do
|
|||
%{user: user, conn: conn} = oauth_access(["write:notifications"])
|
||||
other_user = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(other_user, %{"status" => "hi @#{user.nickname}"})
|
||||
{:ok, activity} = CommonAPI.post(other_user, %{status: "hi @#{user.nickname}"})
|
||||
|
||||
{:ok, [notification]} = Notification.create_notifications(activity)
|
||||
|
||||
|
|
@ -112,7 +112,7 @@ defmodule Pleroma.Web.MastodonAPI.NotificationControllerTest do
|
|||
%{user: user, conn: conn} = oauth_access(["write:notifications", "read:notifications"])
|
||||
other_user = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(other_user, %{"status" => "hi @#{user.nickname}"})
|
||||
{:ok, activity} = CommonAPI.post(other_user, %{status: "hi @#{user.nickname}"})
|
||||
|
||||
{:ok, [_notification]} = Notification.create_notifications(activity)
|
||||
|
||||
|
|
@ -130,10 +130,10 @@ defmodule Pleroma.Web.MastodonAPI.NotificationControllerTest do
|
|||
%{user: user, conn: conn} = oauth_access(["read:notifications"])
|
||||
other_user = insert(:user)
|
||||
|
||||
{:ok, activity1} = CommonAPI.post(other_user, %{"status" => "hi @#{user.nickname}"})
|
||||
{:ok, activity2} = CommonAPI.post(other_user, %{"status" => "hi @#{user.nickname}"})
|
||||
{:ok, activity3} = CommonAPI.post(other_user, %{"status" => "hi @#{user.nickname}"})
|
||||
{:ok, activity4} = CommonAPI.post(other_user, %{"status" => "hi @#{user.nickname}"})
|
||||
{:ok, activity1} = CommonAPI.post(other_user, %{status: "hi @#{user.nickname}"})
|
||||
{:ok, activity2} = CommonAPI.post(other_user, %{status: "hi @#{user.nickname}"})
|
||||
{:ok, activity3} = CommonAPI.post(other_user, %{status: "hi @#{user.nickname}"})
|
||||
{:ok, activity4} = CommonAPI.post(other_user, %{status: "hi @#{user.nickname}"})
|
||||
|
||||
notification1_id = get_notification_id_by_activity(activity1)
|
||||
notification2_id = get_notification_id_by_activity(activity2)
|
||||
|
|
@ -173,16 +173,16 @@ defmodule Pleroma.Web.MastodonAPI.NotificationControllerTest do
|
|||
other_user = insert(:user)
|
||||
|
||||
{:ok, public_activity} =
|
||||
CommonAPI.post(other_user, %{"status" => "@#{user.nickname}", "visibility" => "public"})
|
||||
CommonAPI.post(other_user, %{status: "@#{user.nickname}", visibility: "public"})
|
||||
|
||||
{:ok, direct_activity} =
|
||||
CommonAPI.post(other_user, %{"status" => "@#{user.nickname}", "visibility" => "direct"})
|
||||
CommonAPI.post(other_user, %{status: "@#{user.nickname}", visibility: "direct"})
|
||||
|
||||
{:ok, unlisted_activity} =
|
||||
CommonAPI.post(other_user, %{"status" => "@#{user.nickname}", "visibility" => "unlisted"})
|
||||
CommonAPI.post(other_user, %{status: "@#{user.nickname}", visibility: "unlisted"})
|
||||
|
||||
{:ok, private_activity} =
|
||||
CommonAPI.post(other_user, %{"status" => "@#{user.nickname}", "visibility" => "private"})
|
||||
CommonAPI.post(other_user, %{status: "@#{user.nickname}", visibility: "private"})
|
||||
|
||||
query = params_to_query(%{exclude_visibilities: ["public", "unlisted", "private"]})
|
||||
conn_res = get(conn, "/api/v1/notifications?" <> query)
|
||||
|
|
@ -213,17 +213,15 @@ defmodule Pleroma.Web.MastodonAPI.NotificationControllerTest do
|
|||
user = insert(:user)
|
||||
%{user: other_user, conn: conn} = oauth_access(["read:notifications"])
|
||||
|
||||
{:ok, public_activity} =
|
||||
CommonAPI.post(other_user, %{"status" => ".", "visibility" => "public"})
|
||||
{:ok, public_activity} = CommonAPI.post(other_user, %{status: ".", visibility: "public"})
|
||||
|
||||
{:ok, direct_activity} =
|
||||
CommonAPI.post(other_user, %{"status" => "@#{user.nickname}", "visibility" => "direct"})
|
||||
CommonAPI.post(other_user, %{status: "@#{user.nickname}", visibility: "direct"})
|
||||
|
||||
{:ok, unlisted_activity} =
|
||||
CommonAPI.post(other_user, %{"status" => ".", "visibility" => "unlisted"})
|
||||
CommonAPI.post(other_user, %{status: ".", visibility: "unlisted"})
|
||||
|
||||
{:ok, private_activity} =
|
||||
CommonAPI.post(other_user, %{"status" => ".", "visibility" => "private"})
|
||||
{:ok, private_activity} = CommonAPI.post(other_user, %{status: ".", visibility: "private"})
|
||||
|
||||
{:ok, _} = CommonAPI.favorite(user, public_activity.id)
|
||||
{:ok, _} = CommonAPI.favorite(user, direct_activity.id)
|
||||
|
|
@ -279,11 +277,10 @@ defmodule Pleroma.Web.MastodonAPI.NotificationControllerTest do
|
|||
user = insert(:user)
|
||||
%{user: other_user, conn: conn} = oauth_access(["read:notifications"])
|
||||
|
||||
{:ok, public_activity} =
|
||||
CommonAPI.post(other_user, %{"status" => ".", "visibility" => "public"})
|
||||
{:ok, public_activity} = CommonAPI.post(other_user, %{status: ".", visibility: "public"})
|
||||
|
||||
{:ok, unlisted_activity} =
|
||||
CommonAPI.post(other_user, %{"status" => ".", "visibility" => "unlisted"})
|
||||
CommonAPI.post(other_user, %{status: ".", visibility: "unlisted"})
|
||||
|
||||
{:ok, _, _} = CommonAPI.repeat(public_activity.id, user)
|
||||
{:ok, _, _} = CommonAPI.repeat(unlisted_activity.id, user)
|
||||
|
|
@ -303,8 +300,8 @@ defmodule Pleroma.Web.MastodonAPI.NotificationControllerTest do
|
|||
%{user: user, conn: conn} = oauth_access(["read:notifications"])
|
||||
other_user = insert(:user)
|
||||
|
||||
{:ok, mention_activity} = CommonAPI.post(other_user, %{"status" => "hey @#{user.nickname}"})
|
||||
{:ok, create_activity} = CommonAPI.post(user, %{"status" => "hey"})
|
||||
{: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, reblog_activity, _} = CommonAPI.repeat(create_activity.id, other_user)
|
||||
{:ok, _, _, follow_activity} = CommonAPI.follow(other_user, user)
|
||||
|
|
@ -341,8 +338,8 @@ defmodule Pleroma.Web.MastodonAPI.NotificationControllerTest do
|
|||
%{user: user, conn: conn} = oauth_access(["read:notifications"])
|
||||
other_user = insert(:user)
|
||||
|
||||
{:ok, mention_activity} = CommonAPI.post(other_user, %{"status" => "hey @#{user.nickname}"})
|
||||
{:ok, create_activity} = CommonAPI.post(user, %{"status" => "hey"})
|
||||
{: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, reblog_activity, _} = CommonAPI.repeat(create_activity.id, other_user)
|
||||
{:ok, _, _, follow_activity} = CommonAPI.follow(other_user, user)
|
||||
|
|
@ -388,10 +385,10 @@ defmodule Pleroma.Web.MastodonAPI.NotificationControllerTest do
|
|||
%{user: user, conn: conn} = oauth_access(["read:notifications", "write:notifications"])
|
||||
other_user = insert(:user)
|
||||
|
||||
{:ok, activity1} = CommonAPI.post(other_user, %{"status" => "hi @#{user.nickname}"})
|
||||
{:ok, activity2} = CommonAPI.post(other_user, %{"status" => "hi @#{user.nickname}"})
|
||||
{:ok, activity3} = CommonAPI.post(user, %{"status" => "hi @#{other_user.nickname}"})
|
||||
{:ok, activity4} = CommonAPI.post(user, %{"status" => "hi @#{other_user.nickname}"})
|
||||
{:ok, activity1} = CommonAPI.post(other_user, %{status: "hi @#{user.nickname}"})
|
||||
{:ok, activity2} = CommonAPI.post(other_user, %{status: "hi @#{user.nickname}"})
|
||||
{:ok, activity3} = CommonAPI.post(user, %{status: "hi @#{other_user.nickname}"})
|
||||
{:ok, activity4} = CommonAPI.post(user, %{status: "hi @#{other_user.nickname}"})
|
||||
|
||||
notification1_id = get_notification_id_by_activity(activity1)
|
||||
notification2_id = get_notification_id_by_activity(activity2)
|
||||
|
|
@ -435,7 +432,7 @@ defmodule Pleroma.Web.MastodonAPI.NotificationControllerTest do
|
|||
user2 = insert(:user)
|
||||
|
||||
{:ok, _, _, _} = CommonAPI.follow(user, user2)
|
||||
{:ok, _} = CommonAPI.post(user2, %{"status" => "hey @#{user.nickname}"})
|
||||
{:ok, _} = CommonAPI.post(user2, %{status: "hey @#{user.nickname}"})
|
||||
|
||||
ret_conn = get(conn, "/api/v1/notifications")
|
||||
|
||||
|
|
@ -453,7 +450,7 @@ defmodule Pleroma.Web.MastodonAPI.NotificationControllerTest do
|
|||
user2 = insert(:user)
|
||||
|
||||
{:ok, _, _, _} = CommonAPI.follow(user, user2)
|
||||
{:ok, _} = CommonAPI.post(user2, %{"status" => "hey @#{user.nickname}"})
|
||||
{:ok, _} = CommonAPI.post(user2, %{status: "hey @#{user.nickname}"})
|
||||
|
||||
ret_conn = get(conn, "/api/v1/notifications")
|
||||
|
||||
|
|
@ -471,7 +468,7 @@ defmodule Pleroma.Web.MastodonAPI.NotificationControllerTest do
|
|||
user2 = insert(:user)
|
||||
|
||||
{:ok, _, _, _} = CommonAPI.follow(user, user2)
|
||||
{:ok, _} = CommonAPI.post(user2, %{"status" => "hey @#{user.nickname}"})
|
||||
{:ok, _} = CommonAPI.post(user2, %{status: "hey @#{user.nickname}"})
|
||||
|
||||
ret_conn = get(conn, "/api/v1/notifications")
|
||||
|
||||
|
|
@ -518,14 +515,14 @@ defmodule Pleroma.Web.MastodonAPI.NotificationControllerTest do
|
|||
|
||||
{:ok, activity1} =
|
||||
CommonAPI.post(other_user, %{
|
||||
"status" => "hi @#{user.nickname}",
|
||||
"visibility" => "public"
|
||||
status: "hi @#{user.nickname}",
|
||||
visibility: "public"
|
||||
})
|
||||
|
||||
{:ok, activity2} =
|
||||
CommonAPI.post(other_user, %{
|
||||
"status" => "hi @#{user.nickname}",
|
||||
"visibility" => "public"
|
||||
status: "hi @#{user.nickname}",
|
||||
visibility: "public"
|
||||
})
|
||||
|
||||
notification1 = Repo.get_by(Notification, activity_id: activity1.id)
|
||||
|
|
@ -550,8 +547,8 @@ defmodule Pleroma.Web.MastodonAPI.NotificationControllerTest do
|
|||
%{id: account_id} = other_user1 = insert(:user)
|
||||
other_user2 = insert(:user)
|
||||
|
||||
{:ok, _activity} = CommonAPI.post(other_user1, %{"status" => "hi @#{user.nickname}"})
|
||||
{:ok, _activity} = CommonAPI.post(other_user2, %{"status" => "bye @#{user.nickname}"})
|
||||
{:ok, _activity} = CommonAPI.post(other_user1, %{status: "hi @#{user.nickname}"})
|
||||
{:ok, _activity} = CommonAPI.post(other_user2, %{status: "bye @#{user.nickname}"})
|
||||
|
||||
assert [%{"account" => %{"id" => ^account_id}}] =
|
||||
conn
|
||||
|
|
|
|||
|
|
@ -16,8 +16,8 @@ defmodule Pleroma.Web.MastodonAPI.PollControllerTest do
|
|||
test "returns poll entity for object id", %{user: user, conn: conn} do
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(user, %{
|
||||
"status" => "Pleroma does",
|
||||
"poll" => %{"options" => ["what Mastodon't", "n't what Mastodoes"], "expires_in" => 20}
|
||||
status: "Pleroma does",
|
||||
poll: %{options: ["what Mastodon't", "n't what Mastodoes"], expires_in: 20}
|
||||
})
|
||||
|
||||
object = Object.normalize(activity)
|
||||
|
|
@ -34,9 +34,9 @@ defmodule Pleroma.Web.MastodonAPI.PollControllerTest do
|
|||
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(other_user, %{
|
||||
"status" => "Pleroma does",
|
||||
"poll" => %{"options" => ["what Mastodon't", "n't what Mastodoes"], "expires_in" => 20},
|
||||
"visibility" => "private"
|
||||
status: "Pleroma does",
|
||||
poll: %{options: ["what Mastodon't", "n't what Mastodoes"], expires_in: 20},
|
||||
visibility: "private"
|
||||
})
|
||||
|
||||
object = Object.normalize(activity)
|
||||
|
|
@ -55,11 +55,11 @@ defmodule Pleroma.Web.MastodonAPI.PollControllerTest do
|
|||
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(other_user, %{
|
||||
"status" => "A very delicious sandwich",
|
||||
"poll" => %{
|
||||
"options" => ["Lettuce", "Grilled Bacon", "Tomato"],
|
||||
"expires_in" => 20,
|
||||
"multiple" => true
|
||||
status: "A very delicious sandwich",
|
||||
poll: %{
|
||||
options: ["Lettuce", "Grilled Bacon", "Tomato"],
|
||||
expires_in: 20,
|
||||
multiple: true
|
||||
}
|
||||
})
|
||||
|
||||
|
|
@ -81,8 +81,8 @@ defmodule Pleroma.Web.MastodonAPI.PollControllerTest do
|
|||
test "author can't vote", %{user: user, conn: conn} 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)
|
||||
|
|
@ -102,8 +102,8 @@ defmodule Pleroma.Web.MastodonAPI.PollControllerTest do
|
|||
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(other_user, %{
|
||||
"status" => "The glass is",
|
||||
"poll" => %{"options" => ["half empty", "half full"], "expires_in" => 20}
|
||||
status: "The glass is",
|
||||
poll: %{options: ["half empty", "half full"], expires_in: 20}
|
||||
})
|
||||
|
||||
object = Object.normalize(activity)
|
||||
|
|
@ -125,8 +125,8 @@ defmodule Pleroma.Web.MastodonAPI.PollControllerTest do
|
|||
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(other_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)
|
||||
|
|
@ -153,9 +153,9 @@ defmodule Pleroma.Web.MastodonAPI.PollControllerTest do
|
|||
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(other_user, %{
|
||||
"status" => "Am I cute?",
|
||||
"poll" => %{"options" => ["Yes", "No"], "expires_in" => 20},
|
||||
"visibility" => "private"
|
||||
status: "Am I cute?",
|
||||
poll: %{options: ["Yes", "No"], expires_in: 20},
|
||||
visibility: "private"
|
||||
})
|
||||
|
||||
object = Object.normalize(activity)
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ defmodule Pleroma.Web.MastodonAPI.ReportControllerTest do
|
|||
setup do
|
||||
target_user = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(target_user, %{"status" => "foobar"})
|
||||
{:ok, activity} = CommonAPI.post(target_user, %{status: "foobar"})
|
||||
|
||||
[target_user: target_user, activity: activity]
|
||||
end
|
||||
|
|
|
|||
|
|
@ -42,15 +42,15 @@ defmodule Pleroma.Web.MastodonAPI.SearchControllerTest do
|
|||
user_two = insert(:user, %{nickname: "shp@shitposter.club"})
|
||||
user_three = insert(:user, %{nickname: "shp@heldscal.la", name: "I love 2hu"})
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "This is about 2hu private 天子"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "This is about 2hu private 天子"})
|
||||
|
||||
{:ok, _activity} =
|
||||
CommonAPI.post(user, %{
|
||||
"status" => "This is about 2hu, but private",
|
||||
"visibility" => "private"
|
||||
status: "This is about 2hu, but private",
|
||||
visibility: "private"
|
||||
})
|
||||
|
||||
{:ok, _} = CommonAPI.post(user_two, %{"status" => "This isn't"})
|
||||
{:ok, _} = CommonAPI.post(user_two, %{status: "This isn't"})
|
||||
|
||||
results =
|
||||
conn
|
||||
|
|
@ -80,9 +80,9 @@ defmodule Pleroma.Web.MastodonAPI.SearchControllerTest do
|
|||
user_smith = insert(:user, %{nickname: "Agent", name: "I love 2hu"})
|
||||
user_neo = insert(:user, %{nickname: "Agent Neo", name: "Agent"})
|
||||
|
||||
{:ok, act1} = CommonAPI.post(user, %{"status" => "This is about 2hu private 天子"})
|
||||
{:ok, act2} = CommonAPI.post(user_smith, %{"status" => "Agent Smith"})
|
||||
{:ok, act3} = CommonAPI.post(user_neo, %{"status" => "Agent Smith"})
|
||||
{:ok, act1} = CommonAPI.post(user, %{status: "This is about 2hu private 天子"})
|
||||
{:ok, act2} = CommonAPI.post(user_smith, %{status: "Agent Smith"})
|
||||
{:ok, act3} = CommonAPI.post(user_neo, %{status: "Agent Smith"})
|
||||
Pleroma.User.block(user, user_smith)
|
||||
|
||||
results =
|
||||
|
|
@ -161,15 +161,15 @@ defmodule Pleroma.Web.MastodonAPI.SearchControllerTest do
|
|||
user_two = insert(:user, %{nickname: "shp@shitposter.club"})
|
||||
user_three = insert(:user, %{nickname: "shp@heldscal.la", name: "I love 2hu"})
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "This is about 2hu"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "This is about 2hu"})
|
||||
|
||||
{:ok, _activity} =
|
||||
CommonAPI.post(user, %{
|
||||
"status" => "This is about 2hu, but private",
|
||||
"visibility" => "private"
|
||||
status: "This is about 2hu, but private",
|
||||
visibility: "private"
|
||||
})
|
||||
|
||||
{:ok, _} = CommonAPI.post(user_two, %{"status" => "This isn't"})
|
||||
{:ok, _} = CommonAPI.post(user_two, %{status: "This isn't"})
|
||||
|
||||
results =
|
||||
conn
|
||||
|
|
@ -189,7 +189,7 @@ defmodule Pleroma.Web.MastodonAPI.SearchControllerTest do
|
|||
capture_log(fn ->
|
||||
{:ok, %{id: activity_id}} =
|
||||
CommonAPI.post(insert(:user), %{
|
||||
"status" => "check out https://shitposter.club/notice/2827873"
|
||||
status: "check out https://shitposter.club/notice/2827873"
|
||||
})
|
||||
|
||||
results =
|
||||
|
|
@ -207,8 +207,8 @@ defmodule Pleroma.Web.MastodonAPI.SearchControllerTest do
|
|||
test "search doesn't show statuses that it shouldn't", %{conn: conn} do
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(insert(:user), %{
|
||||
"status" => "This is about 2hu, but private",
|
||||
"visibility" => "private"
|
||||
status: "This is about 2hu, but private",
|
||||
visibility: "private"
|
||||
})
|
||||
|
||||
capture_log(fn ->
|
||||
|
|
@ -251,8 +251,8 @@ defmodule Pleroma.Web.MastodonAPI.SearchControllerTest do
|
|||
_user_two = insert(:user, %{nickname: "shp@shitposter.club"})
|
||||
_user_three = insert(:user, %{nickname: "shp@heldscal.la", name: "I love 2hu"})
|
||||
|
||||
{:ok, _activity1} = CommonAPI.post(user, %{"status" => "This is about 2hu"})
|
||||
{:ok, _activity2} = CommonAPI.post(user, %{"status" => "This is also about 2hu"})
|
||||
{:ok, _activity1} = CommonAPI.post(user, %{status: "This is about 2hu"})
|
||||
{:ok, _activity2} = CommonAPI.post(user, %{status: "This is also about 2hu"})
|
||||
|
||||
result =
|
||||
conn
|
||||
|
|
@ -277,7 +277,7 @@ defmodule Pleroma.Web.MastodonAPI.SearchControllerTest do
|
|||
user = insert(:user)
|
||||
_user_two = insert(:user, %{nickname: "shp@heldscal.la", name: "I love 2hu"})
|
||||
|
||||
{:ok, _activity} = CommonAPI.post(user, %{"status" => "This is about 2hu"})
|
||||
{:ok, _activity} = CommonAPI.post(user, %{status: "This is about 2hu"})
|
||||
|
||||
assert %{"statuses" => [_activity], "accounts" => [], "hashtags" => []} =
|
||||
conn
|
||||
|
|
@ -294,8 +294,8 @@ defmodule Pleroma.Web.MastodonAPI.SearchControllerTest do
|
|||
user = insert(:user, %{nickname: "shp@shitposter.club"})
|
||||
user_two = insert(:user, %{nickname: "shp@heldscal.la", name: "I love 2hu"})
|
||||
|
||||
{:ok, activity1} = CommonAPI.post(user, %{"status" => "This is about 2hu"})
|
||||
{:ok, activity2} = CommonAPI.post(user_two, %{"status" => "This is also about 2hu"})
|
||||
{:ok, activity1} = CommonAPI.post(user, %{status: "This is about 2hu"})
|
||||
{:ok, activity2} = CommonAPI.post(user_two, %{status: "This is also about 2hu"})
|
||||
|
||||
results =
|
||||
conn
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -28,7 +28,7 @@ defmodule Pleroma.Web.MastodonAPI.TimelineControllerTest do
|
|||
|
||||
other_user = insert(:user)
|
||||
|
||||
{:ok, _} = CommonAPI.post(other_user, %{"status" => "hi @#{user.nickname}"})
|
||||
{:ok, _} = CommonAPI.post(other_user, %{status: "hi @#{user.nickname}"})
|
||||
|
||||
response =
|
||||
conn
|
||||
|
|
@ -47,8 +47,8 @@ defmodule Pleroma.Web.MastodonAPI.TimelineControllerTest do
|
|||
following = insert(:user, nickname: "followed")
|
||||
third_user = insert(:user, nickname: "repeated")
|
||||
|
||||
{:ok, _activity} = CommonAPI.post(following, %{"status" => "post"})
|
||||
{:ok, activity} = CommonAPI.post(third_user, %{"status" => "repeated post"})
|
||||
{:ok, _activity} = CommonAPI.post(following, %{status: "post"})
|
||||
{:ok, activity} = CommonAPI.post(third_user, %{status: "repeated post"})
|
||||
{:ok, _, _} = CommonAPI.repeat(activity.id, following)
|
||||
|
||||
ret_conn = get(conn, uri)
|
||||
|
|
@ -108,14 +108,12 @@ defmodule Pleroma.Web.MastodonAPI.TimelineControllerTest do
|
|||
end
|
||||
|
||||
test "the home timeline when the direct messages are excluded", %{user: user, conn: conn} do
|
||||
{:ok, public_activity} = CommonAPI.post(user, %{"status" => ".", "visibility" => "public"})
|
||||
{:ok, direct_activity} = CommonAPI.post(user, %{"status" => ".", "visibility" => "direct"})
|
||||
{:ok, public_activity} = CommonAPI.post(user, %{status: ".", visibility: "public"})
|
||||
{:ok, direct_activity} = CommonAPI.post(user, %{status: ".", visibility: "direct"})
|
||||
|
||||
{:ok, unlisted_activity} =
|
||||
CommonAPI.post(user, %{"status" => ".", "visibility" => "unlisted"})
|
||||
{:ok, unlisted_activity} = CommonAPI.post(user, %{status: ".", visibility: "unlisted"})
|
||||
|
||||
{:ok, private_activity} =
|
||||
CommonAPI.post(user, %{"status" => ".", "visibility" => "private"})
|
||||
{:ok, private_activity} = CommonAPI.post(user, %{status: ".", visibility: "private"})
|
||||
|
||||
conn = get(conn, "/api/v1/timelines/home?exclude_visibilities[]=direct")
|
||||
|
||||
|
|
@ -132,7 +130,7 @@ defmodule Pleroma.Web.MastodonAPI.TimelineControllerTest do
|
|||
test "the public timeline", %{conn: conn} do
|
||||
following = insert(:user)
|
||||
|
||||
{:ok, _activity} = CommonAPI.post(following, %{"status" => "test"})
|
||||
{:ok, _activity} = CommonAPI.post(following, %{status: "test"})
|
||||
|
||||
_activity = insert(:note_activity, local: false)
|
||||
|
||||
|
|
@ -152,10 +150,10 @@ defmodule Pleroma.Web.MastodonAPI.TimelineControllerTest do
|
|||
test "the public timeline includes only public statuses for an authenticated user" do
|
||||
%{user: user, conn: conn} = oauth_access(["read:statuses"])
|
||||
|
||||
{:ok, _activity} = CommonAPI.post(user, %{"status" => "test"})
|
||||
{:ok, _activity} = CommonAPI.post(user, %{"status" => "test", "visibility" => "private"})
|
||||
{:ok, _activity} = CommonAPI.post(user, %{"status" => "test", "visibility" => "unlisted"})
|
||||
{:ok, _activity} = CommonAPI.post(user, %{"status" => "test", "visibility" => "direct"})
|
||||
{:ok, _activity} = CommonAPI.post(user, %{status: "test"})
|
||||
{:ok, _activity} = CommonAPI.post(user, %{status: "test", visibility: "private"})
|
||||
{:ok, _activity} = CommonAPI.post(user, %{status: "test", visibility: "unlisted"})
|
||||
{:ok, _activity} = CommonAPI.post(user, %{status: "test", visibility: "direct"})
|
||||
|
||||
res_conn = get(conn, "/api/v1/timelines/public")
|
||||
assert length(json_response_and_validate_schema(res_conn, 200)) == 1
|
||||
|
|
@ -263,14 +261,14 @@ defmodule Pleroma.Web.MastodonAPI.TimelineControllerTest do
|
|||
|
||||
{:ok, direct} =
|
||||
CommonAPI.post(user_one, %{
|
||||
"status" => "Hi @#{user_two.nickname}!",
|
||||
"visibility" => "direct"
|
||||
status: "Hi @#{user_two.nickname}!",
|
||||
visibility: "direct"
|
||||
})
|
||||
|
||||
{:ok, _follower_only} =
|
||||
CommonAPI.post(user_one, %{
|
||||
"status" => "Hi @#{user_two.nickname}!",
|
||||
"visibility" => "private"
|
||||
status: "Hi @#{user_two.nickname}!",
|
||||
visibility: "private"
|
||||
})
|
||||
|
||||
conn_user_two =
|
||||
|
|
@ -306,8 +304,8 @@ defmodule Pleroma.Web.MastodonAPI.TimelineControllerTest do
|
|||
Enum.each(1..20, fn _ ->
|
||||
{:ok, _} =
|
||||
CommonAPI.post(user_one, %{
|
||||
"status" => "Hi @#{user_two.nickname}!",
|
||||
"visibility" => "direct"
|
||||
status: "Hi @#{user_two.nickname}!",
|
||||
visibility: "direct"
|
||||
})
|
||||
end)
|
||||
|
||||
|
|
@ -333,14 +331,14 @@ defmodule Pleroma.Web.MastodonAPI.TimelineControllerTest do
|
|||
|
||||
{:ok, _blocked_direct} =
|
||||
CommonAPI.post(blocked, %{
|
||||
"status" => "Hi @#{blocker.nickname}!",
|
||||
"visibility" => "direct"
|
||||
status: "Hi @#{blocker.nickname}!",
|
||||
visibility: "direct"
|
||||
})
|
||||
|
||||
{:ok, direct} =
|
||||
CommonAPI.post(other_user, %{
|
||||
"status" => "Hi @#{blocker.nickname}!",
|
||||
"visibility" => "direct"
|
||||
status: "Hi @#{blocker.nickname}!",
|
||||
visibility: "direct"
|
||||
})
|
||||
|
||||
res_conn = get(conn, "api/v1/timelines/direct")
|
||||
|
|
@ -355,8 +353,8 @@ defmodule Pleroma.Web.MastodonAPI.TimelineControllerTest do
|
|||
|
||||
test "list timeline", %{user: user, conn: conn} do
|
||||
other_user = insert(:user)
|
||||
{:ok, _activity_one} = CommonAPI.post(user, %{"status" => "Marisa is cute."})
|
||||
{:ok, activity_two} = CommonAPI.post(other_user, %{"status" => "Marisa is cute."})
|
||||
{:ok, _activity_one} = CommonAPI.post(user, %{status: "Marisa is cute."})
|
||||
{:ok, activity_two} = CommonAPI.post(other_user, %{status: "Marisa is cute."})
|
||||
{:ok, list} = Pleroma.List.create("name", user)
|
||||
{:ok, list} = Pleroma.List.follow(list, other_user)
|
||||
|
||||
|
|
@ -372,12 +370,12 @@ defmodule Pleroma.Web.MastodonAPI.TimelineControllerTest do
|
|||
conn: conn
|
||||
} do
|
||||
other_user = insert(:user)
|
||||
{:ok, activity_one} = CommonAPI.post(other_user, %{"status" => "Marisa is cute."})
|
||||
{:ok, activity_one} = CommonAPI.post(other_user, %{status: "Marisa is cute."})
|
||||
|
||||
{:ok, _activity_two} =
|
||||
CommonAPI.post(other_user, %{
|
||||
"status" => "Marisa is cute.",
|
||||
"visibility" => "private"
|
||||
status: "Marisa is cute.",
|
||||
visibility: "private"
|
||||
})
|
||||
|
||||
{:ok, list} = Pleroma.List.create("name", user)
|
||||
|
|
@ -398,7 +396,7 @@ defmodule Pleroma.Web.MastodonAPI.TimelineControllerTest do
|
|||
test "hashtag timeline", %{conn: conn} do
|
||||
following = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(following, %{"status" => "test #2hu"})
|
||||
{:ok, activity} = CommonAPI.post(following, %{status: "test #2hu"})
|
||||
|
||||
nconn = get(conn, "/api/v1/timelines/tag/2hu")
|
||||
|
||||
|
|
@ -417,9 +415,9 @@ defmodule Pleroma.Web.MastodonAPI.TimelineControllerTest do
|
|||
test "multi-hashtag timeline", %{conn: conn} do
|
||||
user = insert(:user)
|
||||
|
||||
{:ok, activity_test} = CommonAPI.post(user, %{"status" => "#test"})
|
||||
{:ok, activity_test1} = CommonAPI.post(user, %{"status" => "#test #test1"})
|
||||
{:ok, activity_none} = CommonAPI.post(user, %{"status" => "#test #none"})
|
||||
{:ok, activity_test} = CommonAPI.post(user, %{status: "#test"})
|
||||
{:ok, activity_test1} = CommonAPI.post(user, %{status: "#test #test1"})
|
||||
{:ok, activity_none} = CommonAPI.post(user, %{status: "#test #none"})
|
||||
|
||||
any_test = get(conn, "/api/v1/timelines/tag/test?any[]=test1")
|
||||
|
||||
|
|
|
|||
|
|
@ -75,9 +75,9 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPITest do
|
|||
|
||||
User.subscribe(subscriber, user)
|
||||
|
||||
{:ok, status} = CommonAPI.post(user, %{"status" => "Akariiiin"})
|
||||
{:ok, status} = CommonAPI.post(user, %{status: "Akariiiin"})
|
||||
|
||||
{:ok, status1} = CommonAPI.post(user, %{"status" => "Magi"})
|
||||
{:ok, status1} = CommonAPI.post(user, %{status: "Magi"})
|
||||
{:ok, [notification]} = Notification.create_notifications(status)
|
||||
{:ok, [notification1]} = Notification.create_notifications(status1)
|
||||
res = MastodonAPI.get_notifications(subscriber)
|
||||
|
|
|
|||
|
|
@ -93,7 +93,14 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
|
|||
test "Represent the user account for the account owner" do
|
||||
user = insert(:user)
|
||||
|
||||
notification_settings = %Pleroma.User.NotificationSetting{}
|
||||
notification_settings = %{
|
||||
followers: true,
|
||||
follows: true,
|
||||
non_followers: true,
|
||||
non_follows: true,
|
||||
privacy_option: false
|
||||
}
|
||||
|
||||
privacy = user.default_scope
|
||||
|
||||
assert %{
|
||||
|
|
@ -452,8 +459,8 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
|
|||
|
||||
{:ok, _activity} =
|
||||
CommonAPI.post(other_user, %{
|
||||
"status" => "Hey @#{user.nickname}.",
|
||||
"visibility" => "direct"
|
||||
status: "Hey @#{user.nickname}.",
|
||||
visibility: "direct"
|
||||
})
|
||||
|
||||
user = User.get_cached_by_ap_id(user.ap_id)
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ defmodule Pleroma.Web.MastodonAPI.ConversationViewTest do
|
|||
other_user = insert(:user)
|
||||
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(user, %{"status" => "hey @#{other_user.nickname}", "visibility" => "direct"})
|
||||
CommonAPI.post(user, %{status: "hey @#{other_user.nickname}", visibility: "direct"})
|
||||
|
||||
[participation] = Participation.for_user_with_last_activity_id(user)
|
||||
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ defmodule Pleroma.Web.MastodonAPI.NotificationViewTest do
|
|||
test "Mention notification" do
|
||||
user = insert(:user)
|
||||
mentioned_user = insert(:user)
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "hey @#{mentioned_user.nickname}"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "hey @#{mentioned_user.nickname}"})
|
||||
{:ok, [notification]} = Notification.create_notifications(activity)
|
||||
user = User.get_cached_by_id(user.id)
|
||||
|
||||
|
|
@ -53,7 +53,7 @@ defmodule Pleroma.Web.MastodonAPI.NotificationViewTest do
|
|||
test "Favourite notification" do
|
||||
user = insert(:user)
|
||||
another_user = insert(:user)
|
||||
{:ok, create_activity} = CommonAPI.post(user, %{"status" => "hey"})
|
||||
{:ok, create_activity} = CommonAPI.post(user, %{status: "hey"})
|
||||
{:ok, favorite_activity} = CommonAPI.favorite(another_user, create_activity.id)
|
||||
{:ok, [notification]} = Notification.create_notifications(favorite_activity)
|
||||
create_activity = Activity.get_by_id(create_activity.id)
|
||||
|
|
@ -73,7 +73,7 @@ defmodule Pleroma.Web.MastodonAPI.NotificationViewTest do
|
|||
test "Reblog notification" do
|
||||
user = insert(:user)
|
||||
another_user = insert(:user)
|
||||
{:ok, create_activity} = CommonAPI.post(user, %{"status" => "hey"})
|
||||
{:ok, create_activity} = CommonAPI.post(user, %{status: "hey"})
|
||||
{:ok, reblog_activity, _object} = CommonAPI.repeat(create_activity.id, another_user)
|
||||
{:ok, [notification]} = Notification.create_notifications(reblog_activity)
|
||||
reblog_activity = Activity.get_by_id(create_activity.id)
|
||||
|
|
@ -155,7 +155,7 @@ defmodule Pleroma.Web.MastodonAPI.NotificationViewTest do
|
|||
user = insert(:user)
|
||||
other_user = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "#cofe"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "#cofe"})
|
||||
{:ok, _activity} = CommonAPI.react_with_emoji(activity.id, other_user, "☕")
|
||||
|
||||
activity = Repo.get(Activity, activity.id)
|
||||
|
|
|
|||
|
|
@ -22,10 +22,10 @@ defmodule Pleroma.Web.MastodonAPI.PollViewTest do
|
|||
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(user, %{
|
||||
"status" => "Is Tenshi eating a corndog cute?",
|
||||
"poll" => %{
|
||||
"options" => ["absolutely!", "sure", "yes", "why are you even asking?"],
|
||||
"expires_in" => 20
|
||||
status: "Is Tenshi eating a corndog cute?",
|
||||
poll: %{
|
||||
options: ["absolutely!", "sure", "yes", "why are you even asking?"],
|
||||
expires_in: 20
|
||||
}
|
||||
})
|
||||
|
||||
|
|
@ -62,11 +62,11 @@ defmodule Pleroma.Web.MastodonAPI.PollViewTest do
|
|||
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(user, %{
|
||||
"status" => "Which Mastodon developer is your favourite?",
|
||||
"poll" => %{
|
||||
"options" => ["Gargron", "Eugen"],
|
||||
"expires_in" => 20,
|
||||
"multiple" => true
|
||||
status: "Which Mastodon developer is your favourite?",
|
||||
poll: %{
|
||||
options: ["Gargron", "Eugen"],
|
||||
expires_in: 20,
|
||||
multiple: true
|
||||
}
|
||||
})
|
||||
|
||||
|
|
@ -91,10 +91,10 @@ defmodule Pleroma.Web.MastodonAPI.PollViewTest do
|
|||
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(user, %{
|
||||
"status" => "What's with the smug face?",
|
||||
"poll" => %{
|
||||
"options" => [":blank: sip", ":blank::blank: sip", ":blank::blank::blank: sip"],
|
||||
"expires_in" => 20
|
||||
status: "What's with the smug face?",
|
||||
poll: %{
|
||||
options: [":blank: sip", ":blank::blank: sip", ":blank::blank::blank: sip"],
|
||||
expires_in: 20
|
||||
}
|
||||
})
|
||||
|
||||
|
|
@ -109,11 +109,11 @@ defmodule Pleroma.Web.MastodonAPI.PollViewTest do
|
|||
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(user, %{
|
||||
"status" => "Which input devices do you use?",
|
||||
"poll" => %{
|
||||
"options" => ["mouse", "trackball", "trackpoint"],
|
||||
"multiple" => true,
|
||||
"expires_in" => 20
|
||||
status: "Which input devices do you use?",
|
||||
poll: %{
|
||||
options: ["mouse", "trackball", "trackpoint"],
|
||||
multiple: true,
|
||||
expires_in: 20
|
||||
}
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ defmodule Pleroma.Web.MastodonAPI.ScheduledActivityViewTest do
|
|||
|
||||
test "A scheduled activity with a media attachment" do
|
||||
user = insert(:user)
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "hi"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "hi"})
|
||||
|
||||
scheduled_at =
|
||||
NaiveDateTime.utc_now()
|
||||
|
|
@ -47,7 +47,7 @@ defmodule Pleroma.Web.MastodonAPI.ScheduledActivityViewTest do
|
|||
expected = %{
|
||||
id: to_string(scheduled_activity.id),
|
||||
media_attachments:
|
||||
%{"media_ids" => [upload.id]}
|
||||
%{media_ids: [upload.id]}
|
||||
|> Utils.attachments_from_ids()
|
||||
|> Enum.map(&StatusView.render("attachment.json", %{attachment: &1})),
|
||||
params: %{
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
|
|||
|
||||
import Pleroma.Factory
|
||||
import Tesla.Mock
|
||||
import OpenApiSpex.TestAssertions
|
||||
|
||||
setup do
|
||||
mock(fn env -> apply(HttpRequestMock, :request, [env]) end)
|
||||
|
|
@ -30,7 +31,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
|
|||
user = insert(:user)
|
||||
other_user = insert(:user)
|
||||
third_user = insert(:user)
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "dae cofe??"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "dae cofe??"})
|
||||
|
||||
{:ok, _} = CommonAPI.react_with_emoji(activity.id, user, "☕")
|
||||
{:ok, _} = CommonAPI.react_with_emoji(activity.id, third_user, "🍵")
|
||||
|
|
@ -38,6 +39,8 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
|
|||
activity = Repo.get(Activity, activity.id)
|
||||
status = StatusView.render("show.json", activity: activity)
|
||||
|
||||
assert_schema(status, "Status", Pleroma.Web.ApiSpec.spec())
|
||||
|
||||
assert status[:pleroma][:emoji_reactions] == [
|
||||
%{name: "☕", count: 2, me: false},
|
||||
%{name: "🍵", count: 1, me: false}
|
||||
|
|
@ -45,6 +48,8 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
|
|||
|
||||
status = StatusView.render("show.json", activity: activity, for: user)
|
||||
|
||||
assert_schema(status, "Status", Pleroma.Web.ApiSpec.spec())
|
||||
|
||||
assert status[:pleroma][:emoji_reactions] == [
|
||||
%{name: "☕", count: 2, me: true},
|
||||
%{name: "🍵", count: 1, me: false}
|
||||
|
|
@ -54,7 +59,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
|
|||
test "loads and returns the direct conversation id when given the `with_direct_conversation_id` option" do
|
||||
user = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "Hey @shp!", "visibility" => "direct"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "Hey @shp!", visibility: "direct"})
|
||||
[participation] = Participation.for_user(user)
|
||||
|
||||
status =
|
||||
|
|
@ -68,12 +73,13 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
|
|||
|
||||
status = StatusView.render("show.json", activity: activity, for: user)
|
||||
assert status[:pleroma][:direct_conversation_id] == nil
|
||||
assert_schema(status, "Status", Pleroma.Web.ApiSpec.spec())
|
||||
end
|
||||
|
||||
test "returns the direct conversation id when given the `direct_conversation_id` option" do
|
||||
user = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "Hey @shp!", "visibility" => "direct"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "Hey @shp!", visibility: "direct"})
|
||||
[participation] = Participation.for_user(user)
|
||||
|
||||
status =
|
||||
|
|
@ -84,12 +90,13 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
|
|||
)
|
||||
|
||||
assert status[:pleroma][:direct_conversation_id] == participation.id
|
||||
assert_schema(status, "Status", Pleroma.Web.ApiSpec.spec())
|
||||
end
|
||||
|
||||
test "returns a temporary ap_id based user for activities missing db users" do
|
||||
user = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "Hey @shp!", "visibility" => "direct"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "Hey @shp!", visibility: "direct"})
|
||||
|
||||
Repo.delete(user)
|
||||
Cachex.clear(:user_cache)
|
||||
|
|
@ -119,7 +126,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
|
|||
test "tries to get a user by nickname if fetching by ap_id doesn't work" do
|
||||
user = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "Hey @shp!", "visibility" => "direct"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "Hey @shp!", visibility: "direct"})
|
||||
|
||||
{:ok, user} =
|
||||
user
|
||||
|
|
@ -131,6 +138,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
|
|||
result = StatusView.render("show.json", activity: activity)
|
||||
|
||||
assert result[:account][:id] == to_string(user.id)
|
||||
assert_schema(result, "Status", Pleroma.Web.ApiSpec.spec())
|
||||
end
|
||||
|
||||
test "a note with null content" do
|
||||
|
|
@ -149,6 +157,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
|
|||
status = StatusView.render("show.json", %{activity: note})
|
||||
|
||||
assert status.content == ""
|
||||
assert_schema(status, "Status", Pleroma.Web.ApiSpec.spec())
|
||||
end
|
||||
|
||||
test "a note activity" do
|
||||
|
|
@ -222,6 +231,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
|
|||
}
|
||||
|
||||
assert status == expected
|
||||
assert_schema(status, "Status", Pleroma.Web.ApiSpec.spec())
|
||||
end
|
||||
|
||||
test "tells if the message is muted for some reason" do
|
||||
|
|
@ -230,13 +240,14 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
|
|||
|
||||
{:ok, _user_relationships} = User.mute(user, other_user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(other_user, %{"status" => "test"})
|
||||
{:ok, activity} = CommonAPI.post(other_user, %{status: "test"})
|
||||
|
||||
relationships_opt = UserRelationship.view_relationships_option(user, [other_user])
|
||||
|
||||
opts = %{activity: activity}
|
||||
status = StatusView.render("show.json", opts)
|
||||
assert status.muted == false
|
||||
assert_schema(status, "Status", Pleroma.Web.ApiSpec.spec())
|
||||
|
||||
status = StatusView.render("show.json", Map.put(opts, :relationships, relationships_opt))
|
||||
assert status.muted == false
|
||||
|
|
@ -247,6 +258,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
|
|||
|
||||
status = StatusView.render("show.json", Map.put(for_opts, :relationships, relationships_opt))
|
||||
assert status.muted == true
|
||||
assert_schema(status, "Status", Pleroma.Web.ApiSpec.spec())
|
||||
end
|
||||
|
||||
test "tells if the message is thread muted" do
|
||||
|
|
@ -255,7 +267,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
|
|||
|
||||
{:ok, _user_relationships} = User.mute(user, other_user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(other_user, %{"status" => "test"})
|
||||
{:ok, activity} = CommonAPI.post(other_user, %{status: "test"})
|
||||
status = StatusView.render("show.json", %{activity: activity, for: user})
|
||||
|
||||
assert status.pleroma.thread_muted == false
|
||||
|
|
@ -270,7 +282,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
|
|||
test "tells if the status is bookmarked" do
|
||||
user = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "Cute girls doing cute things"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "Cute girls doing cute things"})
|
||||
status = StatusView.render("show.json", %{activity: activity})
|
||||
|
||||
assert status.bookmarked == false
|
||||
|
|
@ -292,8 +304,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
|
|||
note = insert(:note_activity)
|
||||
user = insert(:user)
|
||||
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(user, %{"status" => "he", "in_reply_to_status_id" => note.id})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "he", in_reply_to_status_id: note.id})
|
||||
|
||||
status = StatusView.render("show.json", %{activity: activity})
|
||||
|
||||
|
|
@ -308,12 +319,14 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
|
|||
user = insert(:user)
|
||||
mentioned = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "hi @#{mentioned.nickname}"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "hi @#{mentioned.nickname}"})
|
||||
|
||||
status = StatusView.render("show.json", %{activity: activity})
|
||||
|
||||
assert status.mentions ==
|
||||
Enum.map([mentioned], fn u -> AccountView.render("mention.json", %{user: u}) end)
|
||||
|
||||
assert_schema(status, "Status", Pleroma.Web.ApiSpec.spec())
|
||||
end
|
||||
|
||||
test "create mentions from the 'to' field" do
|
||||
|
|
@ -405,14 +418,14 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
|
|||
api_spec = Pleroma.Web.ApiSpec.spec()
|
||||
|
||||
assert expected == StatusView.render("attachment.json", %{attachment: object})
|
||||
OpenApiSpex.TestAssertions.assert_schema(expected, "Attachment", api_spec)
|
||||
assert_schema(expected, "Attachment", api_spec)
|
||||
|
||||
# If theres a "id", use that instead of the generated one
|
||||
object = Map.put(object, "id", 2)
|
||||
result = StatusView.render("attachment.json", %{attachment: object})
|
||||
|
||||
assert %{id: "2"} = result
|
||||
OpenApiSpex.TestAssertions.assert_schema(result, "Attachment", api_spec)
|
||||
assert_schema(result, "Attachment", api_spec)
|
||||
end
|
||||
|
||||
test "put the url advertised in the Activity in to the url attribute" do
|
||||
|
|
@ -436,6 +449,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
|
|||
assert represented[:id] == to_string(reblog.id)
|
||||
assert represented[:reblog][:id] == to_string(activity.id)
|
||||
assert represented[:emojis] == []
|
||||
assert_schema(represented, "Status", Pleroma.Web.ApiSpec.spec())
|
||||
end
|
||||
|
||||
test "a peertube video" do
|
||||
|
|
@ -452,6 +466,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
|
|||
|
||||
assert represented[:id] == to_string(activity.id)
|
||||
assert length(represented[:media_attachments]) == 1
|
||||
assert_schema(represented, "Status", Pleroma.Web.ApiSpec.spec())
|
||||
end
|
||||
|
||||
test "funkwhale audio" do
|
||||
|
|
@ -567,13 +582,15 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
|
|||
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(user, %{
|
||||
"status" => "drink more water"
|
||||
status: "drink more water"
|
||||
})
|
||||
|
||||
result = StatusView.render("show.json", %{activity: activity, for: other_user})
|
||||
|
||||
assert result[:account][:pleroma][:relationship] ==
|
||||
AccountView.render("relationship.json", %{user: other_user, target: user})
|
||||
|
||||
assert_schema(result, "Status", Pleroma.Web.ApiSpec.spec())
|
||||
end
|
||||
|
||||
test "embeds a relationship in the account in reposts" do
|
||||
|
|
@ -582,7 +599,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
|
|||
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(user, %{
|
||||
"status" => "˙˙ɐʎns"
|
||||
status: "˙˙ɐʎns"
|
||||
})
|
||||
|
||||
{:ok, activity, _object} = CommonAPI.repeat(activity.id, other_user)
|
||||
|
|
@ -594,6 +611,8 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
|
|||
|
||||
assert result[:reblog][:account][:pleroma][:relationship] ==
|
||||
AccountView.render("relationship.json", %{user: user, target: user})
|
||||
|
||||
assert_schema(result, "Status", Pleroma.Web.ApiSpec.spec())
|
||||
end
|
||||
|
||||
test "visibility/list" do
|
||||
|
|
@ -601,8 +620,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
|
|||
|
||||
{: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}"})
|
||||
|
||||
status = StatusView.render("show.json", activity: activity)
|
||||
|
||||
|
|
@ -616,5 +634,6 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
|
|||
|
||||
assert status.length == listen_activity.data["object"]["length"]
|
||||
assert status.title == listen_activity.data["object"]["title"]
|
||||
assert_schema(status, "Status", Pleroma.Web.ApiSpec.spec())
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ defmodule Pleroma.Web.Metadata.Providers.TwitterCardTest do
|
|||
|
||||
test "it uses summary twittercard if post has no attachment" do
|
||||
user = insert(:user, name: "Jimmy Hendriks", bio: "born 19 March 1994")
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "HI"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "HI"})
|
||||
|
||||
note =
|
||||
insert(:note, %{
|
||||
|
|
@ -56,7 +56,7 @@ defmodule Pleroma.Web.Metadata.Providers.TwitterCardTest do
|
|||
test "it renders avatar not attachment if post is nsfw and unfurl_nsfw is disabled" do
|
||||
Pleroma.Config.put([Pleroma.Web.Metadata, :unfurl_nsfw], false)
|
||||
user = insert(:user, name: "Jimmy Hendriks", bio: "born 19 March 1994")
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "HI"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "HI"})
|
||||
|
||||
note =
|
||||
insert(:note, %{
|
||||
|
|
@ -100,7 +100,7 @@ defmodule Pleroma.Web.Metadata.Providers.TwitterCardTest do
|
|||
|
||||
test "it renders supported types of attachments and skips unknown types" do
|
||||
user = insert(:user, name: "Jimmy Hendriks", bio: "born 19 March 1994")
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "HI"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "HI"})
|
||||
|
||||
note =
|
||||
insert(:note, %{
|
||||
|
|
|
|||
|
|
@ -171,8 +171,8 @@ defmodule Pleroma.Web.PleromaAPI.AccountControllerTest do
|
|||
} do
|
||||
{:ok, direct} =
|
||||
CommonAPI.post(current_user, %{
|
||||
"status" => "Hi @#{user.nickname}!",
|
||||
"visibility" => "direct"
|
||||
status: "Hi @#{user.nickname}!",
|
||||
visibility: "direct"
|
||||
})
|
||||
|
||||
CommonAPI.favorite(user, direct.id)
|
||||
|
|
@ -204,8 +204,8 @@ defmodule Pleroma.Web.PleromaAPI.AccountControllerTest do
|
|||
|
||||
{:ok, direct} =
|
||||
CommonAPI.post(user_two, %{
|
||||
"status" => "Hi @#{user.nickname}!",
|
||||
"visibility" => "direct"
|
||||
status: "Hi @#{user.nickname}!",
|
||||
visibility: "direct"
|
||||
})
|
||||
|
||||
CommonAPI.favorite(user, direct.id)
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ defmodule Pleroma.Web.PleromaAPI.PleromaAPIControllerTest do
|
|||
user = insert(:user)
|
||||
other_user = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "#cofe"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "#cofe"})
|
||||
|
||||
result =
|
||||
conn
|
||||
|
|
@ -42,7 +42,7 @@ defmodule Pleroma.Web.PleromaAPI.PleromaAPIControllerTest do
|
|||
user = insert(:user)
|
||||
other_user = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "#cofe"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "#cofe"})
|
||||
{:ok, _reaction_activity} = CommonAPI.react_with_emoji(activity.id, other_user, "☕")
|
||||
|
||||
ObanHelpers.perform_all()
|
||||
|
|
@ -68,7 +68,7 @@ defmodule Pleroma.Web.PleromaAPI.PleromaAPIControllerTest do
|
|||
other_user = insert(:user)
|
||||
doomed_user = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "#cofe"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "#cofe"})
|
||||
|
||||
result =
|
||||
conn
|
||||
|
|
@ -106,7 +106,7 @@ defmodule Pleroma.Web.PleromaAPI.PleromaAPIControllerTest do
|
|||
user = insert(:user)
|
||||
other_user = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "#cofe"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "#cofe"})
|
||||
|
||||
result =
|
||||
conn
|
||||
|
|
@ -133,7 +133,7 @@ defmodule Pleroma.Web.PleromaAPI.PleromaAPIControllerTest do
|
|||
%{user: other_user, conn: conn} = oauth_access(["read:statuses"])
|
||||
|
||||
{:ok, _activity} =
|
||||
CommonAPI.post(user, %{"status" => "Hi @#{other_user.nickname}!", "visibility" => "direct"})
|
||||
CommonAPI.post(user, %{status: "Hi @#{other_user.nickname}!", visibility: "direct"})
|
||||
|
||||
[participation] = Participation.for_user(other_user)
|
||||
|
||||
|
|
@ -151,18 +151,18 @@ defmodule Pleroma.Web.PleromaAPI.PleromaAPIControllerTest do
|
|||
third_user = insert(:user)
|
||||
|
||||
{:ok, _activity} =
|
||||
CommonAPI.post(user, %{"status" => "Hi @#{third_user.nickname}!", "visibility" => "direct"})
|
||||
CommonAPI.post(user, %{status: "Hi @#{third_user.nickname}!", visibility: "direct"})
|
||||
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(user, %{"status" => "Hi @#{other_user.nickname}!", "visibility" => "direct"})
|
||||
CommonAPI.post(user, %{status: "Hi @#{other_user.nickname}!", visibility: "direct"})
|
||||
|
||||
[participation] = Participation.for_user(other_user)
|
||||
|
||||
{:ok, activity_two} =
|
||||
CommonAPI.post(other_user, %{
|
||||
"status" => "Hi!",
|
||||
"in_reply_to_status_id" => activity.id,
|
||||
"in_reply_to_conversation_id" => participation.id
|
||||
status: "Hi!",
|
||||
in_reply_to_status_id: activity.id,
|
||||
in_reply_to_conversation_id: participation.id
|
||||
})
|
||||
|
||||
result =
|
||||
|
|
@ -178,9 +178,9 @@ defmodule Pleroma.Web.PleromaAPI.PleromaAPIControllerTest do
|
|||
|
||||
{:ok, %{id: id_three}} =
|
||||
CommonAPI.post(other_user, %{
|
||||
"status" => "Bye!",
|
||||
"in_reply_to_status_id" => activity.id,
|
||||
"in_reply_to_conversation_id" => participation.id
|
||||
status: "Bye!",
|
||||
in_reply_to_status_id: activity.id,
|
||||
in_reply_to_conversation_id: participation.id
|
||||
})
|
||||
|
||||
assert [%{"id" => ^id_two}, %{"id" => ^id_three}] =
|
||||
|
|
@ -198,7 +198,7 @@ defmodule Pleroma.Web.PleromaAPI.PleromaAPIControllerTest do
|
|||
%{user: user, conn: conn} = oauth_access(["write:conversations"])
|
||||
other_user = insert(:user)
|
||||
|
||||
{:ok, _activity} = CommonAPI.post(user, %{"status" => "Hi", "visibility" => "direct"})
|
||||
{:ok, _activity} = CommonAPI.post(user, %{status: "Hi", visibility: "direct"})
|
||||
|
||||
[participation] = Participation.for_user(user)
|
||||
|
||||
|
|
@ -229,10 +229,10 @@ defmodule Pleroma.Web.PleromaAPI.PleromaAPIControllerTest do
|
|||
%{user: other_user, conn: conn} = oauth_access(["write:conversations"])
|
||||
|
||||
{:ok, _activity} =
|
||||
CommonAPI.post(user, %{"status" => "Hi @#{other_user.nickname}", "visibility" => "direct"})
|
||||
CommonAPI.post(user, %{status: "Hi @#{other_user.nickname}", visibility: "direct"})
|
||||
|
||||
{:ok, _activity} =
|
||||
CommonAPI.post(user, %{"status" => "Hi @#{other_user.nickname}", "visibility" => "direct"})
|
||||
CommonAPI.post(user, %{status: "Hi @#{other_user.nickname}", visibility: "direct"})
|
||||
|
||||
[participation2, participation1] = Participation.for_user(other_user)
|
||||
assert Participation.get(participation2.id).read == false
|
||||
|
|
@ -255,8 +255,8 @@ defmodule Pleroma.Web.PleromaAPI.PleromaAPIControllerTest do
|
|||
|
||||
test "it marks a single notification as read", %{user: user1, conn: conn} do
|
||||
user2 = insert(:user)
|
||||
{:ok, activity1} = CommonAPI.post(user2, %{"status" => "hi @#{user1.nickname}"})
|
||||
{:ok, activity2} = CommonAPI.post(user2, %{"status" => "hi @#{user1.nickname}"})
|
||||
{:ok, activity1} = CommonAPI.post(user2, %{status: "hi @#{user1.nickname}"})
|
||||
{:ok, activity2} = CommonAPI.post(user2, %{status: "hi @#{user1.nickname}"})
|
||||
{:ok, [notification1]} = Notification.create_notifications(activity1)
|
||||
{:ok, [notification2]} = Notification.create_notifications(activity2)
|
||||
|
||||
|
|
@ -272,9 +272,9 @@ defmodule Pleroma.Web.PleromaAPI.PleromaAPIControllerTest do
|
|||
|
||||
test "it marks multiple notifications as read", %{user: user1, conn: conn} do
|
||||
user2 = insert(:user)
|
||||
{:ok, _activity1} = CommonAPI.post(user2, %{"status" => "hi @#{user1.nickname}"})
|
||||
{:ok, _activity2} = CommonAPI.post(user2, %{"status" => "hi @#{user1.nickname}"})
|
||||
{:ok, _activity3} = CommonAPI.post(user2, %{"status" => "HIE @#{user1.nickname}"})
|
||||
{:ok, _activity1} = CommonAPI.post(user2, %{status: "hi @#{user1.nickname}"})
|
||||
{:ok, _activity2} = CommonAPI.post(user2, %{status: "hi @#{user1.nickname}"})
|
||||
{:ok, _activity3} = CommonAPI.post(user2, %{status: "HIE @#{user1.nickname}"})
|
||||
|
||||
[notification3, notification2, notification1] = Notification.for_user(user1, %{limit: 3})
|
||||
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ defmodule Pleroma.Web.Push.ImplTest do
|
|||
data: %{alerts: %{"follow" => true, "mention" => false}}
|
||||
)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "<Lorem ipsum dolor sit amet."})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "<Lorem ipsum dolor sit amet."})
|
||||
|
||||
notif =
|
||||
insert(:notification,
|
||||
|
|
@ -111,7 +111,7 @@ defmodule Pleroma.Web.Push.ImplTest do
|
|||
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(user, %{
|
||||
"status" =>
|
||||
status:
|
||||
"<span>Lorem ipsum dolor sit amet</span>, consectetur :firefox: adipiscing elit. Fusce sagittis finibus turpis."
|
||||
})
|
||||
|
||||
|
|
@ -147,7 +147,7 @@ defmodule Pleroma.Web.Push.ImplTest do
|
|||
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(user, %{
|
||||
"status" =>
|
||||
status:
|
||||
"<span>Lorem ipsum dolor sit amet</span>, consectetur :firefox: adipiscing elit. Fusce sagittis finibus turpis."
|
||||
})
|
||||
|
||||
|
|
@ -166,7 +166,7 @@ defmodule Pleroma.Web.Push.ImplTest do
|
|||
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(user, %{
|
||||
"status" =>
|
||||
status:
|
||||
"<span>Lorem ipsum dolor sit amet</span>, consectetur :firefox: adipiscing elit. Fusce sagittis finibus turpis."
|
||||
})
|
||||
|
||||
|
|
@ -184,8 +184,8 @@ defmodule Pleroma.Web.Push.ImplTest do
|
|||
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(user, %{
|
||||
"visibility" => "direct",
|
||||
"status" => "This is just between you and me, pal"
|
||||
visibility: "direct",
|
||||
status: "This is just between you and me, pal"
|
||||
})
|
||||
|
||||
assert Impl.format_title(%{activity: activity}) ==
|
||||
|
|
@ -199,8 +199,8 @@ defmodule Pleroma.Web.Push.ImplTest do
|
|||
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(user, %{
|
||||
"visibility" => "direct",
|
||||
"status" => "<Lorem ipsum dolor sit amet."
|
||||
visibility: "direct",
|
||||
status: "<Lorem ipsum dolor sit amet."
|
||||
})
|
||||
|
||||
notif = insert(:notification, user: user2, activity: activity)
|
||||
|
|
@ -214,8 +214,8 @@ defmodule Pleroma.Web.Push.ImplTest do
|
|||
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(user, %{
|
||||
"visibility" => "public",
|
||||
"status" => "<Lorem ipsum dolor sit amet."
|
||||
visibility: "public",
|
||||
status: "<Lorem ipsum dolor sit amet."
|
||||
})
|
||||
|
||||
notif = insert(:notification, user: user2, activity: activity)
|
||||
|
|
@ -245,8 +245,8 @@ defmodule Pleroma.Web.Push.ImplTest do
|
|||
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(user, %{
|
||||
"visibility" => "direct",
|
||||
"status" =>
|
||||
visibility: "direct",
|
||||
status:
|
||||
"<span>Lorem ipsum dolor sit amet</span>, consectetur :firefox: adipiscing elit. Fusce sagittis finibus turpis."
|
||||
})
|
||||
|
||||
|
|
@ -263,8 +263,8 @@ defmodule Pleroma.Web.Push.ImplTest do
|
|||
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(user, %{
|
||||
"visibility" => "public",
|
||||
"status" =>
|
||||
visibility: "public",
|
||||
status:
|
||||
"<span>Lorem ipsum dolor sit amet</span>, consectetur :firefox: adipiscing elit. Fusce sagittis finibus turpis."
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -26,8 +26,8 @@ defmodule Pleroma.Web.RichMedia.HelpersTest do
|
|||
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(user, %{
|
||||
"status" => "[test](example.com/ogp)",
|
||||
"content_type" => "text/markdown"
|
||||
status: "[test](example.com/ogp)",
|
||||
content_type: "text/markdown"
|
||||
})
|
||||
|
||||
Config.put([:rich_media, :enabled], true)
|
||||
|
|
@ -40,8 +40,8 @@ defmodule Pleroma.Web.RichMedia.HelpersTest do
|
|||
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(user, %{
|
||||
"status" => "[test](example.com[]/ogp)",
|
||||
"content_type" => "text/markdown"
|
||||
status: "[test](example.com[]/ogp)",
|
||||
content_type: "text/markdown"
|
||||
})
|
||||
|
||||
Config.put([:rich_media, :enabled], true)
|
||||
|
|
@ -54,8 +54,8 @@ defmodule Pleroma.Web.RichMedia.HelpersTest do
|
|||
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(user, %{
|
||||
"status" => "[test](https://example.com/ogp)",
|
||||
"content_type" => "text/markdown"
|
||||
status: "[test](https://example.com/ogp)",
|
||||
content_type: "text/markdown"
|
||||
})
|
||||
|
||||
Config.put([:rich_media, :enabled], true)
|
||||
|
|
@ -69,8 +69,8 @@ defmodule Pleroma.Web.RichMedia.HelpersTest do
|
|||
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(user, %{
|
||||
"status" => "http://example.com/ogp",
|
||||
"sensitive" => true
|
||||
status: "http://example.com/ogp",
|
||||
sensitive: true
|
||||
})
|
||||
|
||||
%Object{} = object = Object.normalize(activity)
|
||||
|
|
@ -87,7 +87,7 @@ defmodule Pleroma.Web.RichMedia.HelpersTest do
|
|||
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(user, %{
|
||||
"status" => "http://example.com/ogp #nsfw"
|
||||
status: "http://example.com/ogp #nsfw"
|
||||
})
|
||||
|
||||
%Object{} = object = Object.normalize(activity)
|
||||
|
|
@ -103,12 +103,12 @@ defmodule Pleroma.Web.RichMedia.HelpersTest do
|
|||
user = insert(:user)
|
||||
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(user, %{"status" => "http://127.0.0.1:4000/notice/9kCP7VNyPJXFOXDrgO"})
|
||||
CommonAPI.post(user, %{status: "http://127.0.0.1:4000/notice/9kCP7VNyPJXFOXDrgO"})
|
||||
|
||||
{:ok, activity2} = CommonAPI.post(user, %{"status" => "https://10.111.10.1/notice/9kCP7V"})
|
||||
{:ok, activity3} = CommonAPI.post(user, %{"status" => "https://172.16.32.40/notice/9kCP7V"})
|
||||
{:ok, activity4} = CommonAPI.post(user, %{"status" => "https://192.168.10.40/notice/9kCP7V"})
|
||||
{:ok, activity5} = CommonAPI.post(user, %{"status" => "https://pleroma.local/notice/9kCP7V"})
|
||||
{:ok, activity2} = CommonAPI.post(user, %{status: "https://10.111.10.1/notice/9kCP7V"})
|
||||
{:ok, activity3} = CommonAPI.post(user, %{status: "https://172.16.32.40/notice/9kCP7V"})
|
||||
{:ok, activity4} = CommonAPI.post(user, %{status: "https://192.168.10.40/notice/9kCP7V"})
|
||||
{:ok, activity5} = CommonAPI.post(user, %{status: "https://pleroma.local/notice/9kCP7V"})
|
||||
|
||||
Config.put([:rich_media, :enabled], true)
|
||||
|
||||
|
|
|
|||
|
|
@ -32,8 +32,8 @@ defmodule Pleroma.Web.StaticFE.StaticFEControllerTest do
|
|||
end
|
||||
|
||||
test "profile does not include private messages", %{conn: conn, user: user} do
|
||||
CommonAPI.post(user, %{"status" => "public"})
|
||||
CommonAPI.post(user, %{"status" => "private", "visibility" => "private"})
|
||||
CommonAPI.post(user, %{status: "public"})
|
||||
CommonAPI.post(user, %{status: "private", visibility: "private"})
|
||||
|
||||
conn = get(conn, "/users/#{user.nickname}")
|
||||
|
||||
|
|
@ -44,7 +44,7 @@ defmodule Pleroma.Web.StaticFE.StaticFEControllerTest do
|
|||
end
|
||||
|
||||
test "pagination", %{conn: conn, user: user} do
|
||||
Enum.map(1..30, fn i -> CommonAPI.post(user, %{"status" => "test#{i}"}) end)
|
||||
Enum.map(1..30, fn i -> CommonAPI.post(user, %{status: "test#{i}"}) end)
|
||||
|
||||
conn = get(conn, "/users/#{user.nickname}")
|
||||
|
||||
|
|
@ -57,7 +57,7 @@ defmodule Pleroma.Web.StaticFE.StaticFEControllerTest do
|
|||
end
|
||||
|
||||
test "pagination, page 2", %{conn: conn, user: user} do
|
||||
activities = Enum.map(1..30, fn i -> CommonAPI.post(user, %{"status" => "test#{i}"}) end)
|
||||
activities = Enum.map(1..30, fn i -> CommonAPI.post(user, %{status: "test#{i}"}) end)
|
||||
{:ok, a11} = Enum.at(activities, 11)
|
||||
|
||||
conn = get(conn, "/users/#{user.nickname}?max_id=#{a11.id}")
|
||||
|
|
@ -77,7 +77,7 @@ defmodule Pleroma.Web.StaticFE.StaticFEControllerTest do
|
|||
|
||||
describe "notice html" do
|
||||
test "single notice page", %{conn: conn, user: user} do
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "testing a thing!"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "testing a thing!"})
|
||||
|
||||
conn = get(conn, "/notice/#{activity.id}")
|
||||
|
||||
|
|
@ -89,7 +89,7 @@ defmodule Pleroma.Web.StaticFE.StaticFEControllerTest do
|
|||
|
||||
test "filters HTML tags", %{conn: conn} do
|
||||
user = insert(:user)
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "<script>alert('xss')</script>"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "<script>alert('xss')</script>"})
|
||||
|
||||
conn =
|
||||
conn
|
||||
|
|
@ -101,11 +101,11 @@ defmodule Pleroma.Web.StaticFE.StaticFEControllerTest do
|
|||
end
|
||||
|
||||
test "shows the whole thread", %{conn: conn, user: user} do
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "space: the final frontier"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "space: the final frontier"})
|
||||
|
||||
CommonAPI.post(user, %{
|
||||
"status" => "these are the voyages or something",
|
||||
"in_reply_to_status_id" => activity.id
|
||||
status: "these are the voyages or something",
|
||||
in_reply_to_status_id: activity.id
|
||||
})
|
||||
|
||||
conn = get(conn, "/notice/#{activity.id}")
|
||||
|
|
@ -117,7 +117,7 @@ defmodule Pleroma.Web.StaticFE.StaticFEControllerTest do
|
|||
|
||||
test "redirect by AP object ID", %{conn: conn, user: user} do
|
||||
{:ok, %Activity{data: %{"object" => object_url}}} =
|
||||
CommonAPI.post(user, %{"status" => "beam me up"})
|
||||
CommonAPI.post(user, %{status: "beam me up"})
|
||||
|
||||
conn = get(conn, URI.parse(object_url).path)
|
||||
|
||||
|
|
@ -126,7 +126,7 @@ defmodule Pleroma.Web.StaticFE.StaticFEControllerTest do
|
|||
|
||||
test "redirect by activity ID", %{conn: conn, user: user} do
|
||||
{:ok, %Activity{data: %{"id" => id}}} =
|
||||
CommonAPI.post(user, %{"status" => "I'm a doctor, not a devops!"})
|
||||
CommonAPI.post(user, %{status: "I'm a doctor, not a devops!"})
|
||||
|
||||
conn = get(conn, URI.parse(id).path)
|
||||
|
||||
|
|
@ -140,8 +140,7 @@ defmodule Pleroma.Web.StaticFE.StaticFEControllerTest do
|
|||
end
|
||||
|
||||
test "404 for private status", %{conn: conn, user: user} do
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(user, %{"status" => "don't show me!", "visibility" => "private"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "don't show me!", visibility: "private"})
|
||||
|
||||
conn = get(conn, "/notice/#{activity.id}")
|
||||
|
||||
|
|
@ -171,7 +170,7 @@ defmodule Pleroma.Web.StaticFE.StaticFEControllerTest do
|
|||
end
|
||||
|
||||
test "it requires authentication if instance is NOT federating", %{conn: conn, user: user} do
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "testing a thing!"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "testing a thing!"})
|
||||
|
||||
ensure_federating_or_authenticated(conn, "/notice/#{activity.id}", user)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ defmodule Pleroma.Web.StreamerTest do
|
|||
|
||||
test "it streams the user's post in the 'user' stream", %{user: user} do
|
||||
Streamer.get_topic_and_add_socket("user", user)
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "hey"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "hey"})
|
||||
assert_receive {:render_with_user, _, _, ^activity}
|
||||
refute Streamer.filtered_by_user?(user, activity)
|
||||
end
|
||||
|
|
@ -105,7 +105,7 @@ defmodule Pleroma.Web.StreamerTest do
|
|||
Streamer.get_topic_and_add_socket("user", user)
|
||||
|
||||
other_user = insert(:user)
|
||||
{:ok, activity} = CommonAPI.post(other_user, %{"status" => "hey"})
|
||||
{:ok, activity} = CommonAPI.post(other_user, %{status: "hey"})
|
||||
{:ok, announce, _} = CommonAPI.repeat(activity.id, user)
|
||||
|
||||
assert_receive {:render_with_user, Pleroma.Web.StreamerView, "update.json", ^announce}
|
||||
|
|
@ -134,7 +134,7 @@ defmodule Pleroma.Web.StreamerTest do
|
|||
|
||||
Streamer.get_topic_and_add_socket("user:notification", user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => ":("})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: ":("})
|
||||
{:ok, _} = CommonAPI.favorite(blocked, activity.id)
|
||||
|
||||
refute_receive _
|
||||
|
|
@ -145,7 +145,7 @@ defmodule Pleroma.Web.StreamerTest do
|
|||
} do
|
||||
user2 = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "super hot take"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "super hot take"})
|
||||
{:ok, _} = CommonAPI.add_mute(user, activity)
|
||||
|
||||
Streamer.get_topic_and_add_socket("user:notification", user)
|
||||
|
|
@ -161,7 +161,7 @@ defmodule Pleroma.Web.StreamerTest do
|
|||
} do
|
||||
user2 = insert(:user, %{ap_id: "https://hecking-lewd-place.com/user/meanie"})
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "super hot take"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "super hot take"})
|
||||
Streamer.get_topic_and_add_socket("user:notification", user)
|
||||
{:ok, favorite_activity} = CommonAPI.favorite(user2, activity.id)
|
||||
|
||||
|
|
@ -176,7 +176,7 @@ defmodule Pleroma.Web.StreamerTest do
|
|||
user2 = insert(:user, %{ap_id: "https://hecking-lewd-place.com/user/meanie"})
|
||||
|
||||
{:ok, user} = User.block_domain(user, "hecking-lewd-place.com")
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "super hot take"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "super hot take"})
|
||||
Streamer.get_topic_and_add_socket("user:notification", user)
|
||||
{:ok, favorite_activity} = CommonAPI.favorite(user2, activity.id)
|
||||
|
||||
|
|
@ -215,7 +215,7 @@ defmodule Pleroma.Web.StreamerTest do
|
|||
|
||||
Streamer.get_topic_and_add_socket("public", other_user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "Test"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "Test"})
|
||||
assert_receive {:render_with_user, _, _, ^activity}
|
||||
refute Streamer.filtered_by_user?(user, activity)
|
||||
end
|
||||
|
|
@ -223,7 +223,7 @@ defmodule Pleroma.Web.StreamerTest do
|
|||
test "works for deletions" do
|
||||
user = insert(:user)
|
||||
other_user = insert(:user)
|
||||
{:ok, activity} = CommonAPI.post(other_user, %{"status" => "Test"})
|
||||
{:ok, activity} = CommonAPI.post(other_user, %{status: "Test"})
|
||||
|
||||
Streamer.get_topic_and_add_socket("public", user)
|
||||
|
||||
|
|
@ -238,7 +238,7 @@ defmodule Pleroma.Web.StreamerTest do
|
|||
|
||||
Streamer.get_topic_and_add_socket("public", nil)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "Test"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "Test"})
|
||||
activity_id = activity.id
|
||||
assert_receive {:text, event}
|
||||
assert %{"event" => "update", "payload" => payload} = Jason.decode!(event)
|
||||
|
|
@ -323,7 +323,7 @@ defmodule Pleroma.Web.StreamerTest do
|
|||
{:ok, _user_relationship} = User.block(user, blocked_user)
|
||||
|
||||
Streamer.get_topic_and_add_socket("public", user)
|
||||
{:ok, activity} = CommonAPI.post(blocked_user, %{"status" => "Test"})
|
||||
{:ok, activity} = CommonAPI.post(blocked_user, %{status: "Test"})
|
||||
assert_receive {:render_with_user, _, _, ^activity}
|
||||
assert Streamer.filtered_by_user?(user, activity)
|
||||
end
|
||||
|
|
@ -337,17 +337,17 @@ defmodule Pleroma.Web.StreamerTest do
|
|||
|
||||
{:ok, _user_relationship} = User.block(blocker, blockee)
|
||||
|
||||
{:ok, activity_one} = CommonAPI.post(friend, %{"status" => "hey! @#{blockee.nickname}"})
|
||||
{:ok, activity_one} = CommonAPI.post(friend, %{status: "hey! @#{blockee.nickname}"})
|
||||
|
||||
assert_receive {:render_with_user, _, _, ^activity_one}
|
||||
assert Streamer.filtered_by_user?(blocker, activity_one)
|
||||
|
||||
{:ok, activity_two} = CommonAPI.post(blockee, %{"status" => "hey! @#{friend.nickname}"})
|
||||
{:ok, activity_two} = CommonAPI.post(blockee, %{status: "hey! @#{friend.nickname}"})
|
||||
|
||||
assert_receive {:render_with_user, _, _, ^activity_two}
|
||||
assert Streamer.filtered_by_user?(blocker, activity_two)
|
||||
|
||||
{:ok, activity_three} = CommonAPI.post(blockee, %{"status" => "hey! @#{blocker.nickname}"})
|
||||
{:ok, activity_three} = CommonAPI.post(blockee, %{status: "hey! @#{blocker.nickname}"})
|
||||
|
||||
assert_receive {:render_with_user, _, _, ^activity_three}
|
||||
assert Streamer.filtered_by_user?(blocker, activity_three)
|
||||
|
|
@ -369,8 +369,8 @@ defmodule Pleroma.Web.StreamerTest do
|
|||
|
||||
{:ok, _activity} =
|
||||
CommonAPI.post(user_b, %{
|
||||
"status" => "@#{user_c.nickname} Test",
|
||||
"visibility" => "direct"
|
||||
status: "@#{user_c.nickname} Test",
|
||||
visibility: "direct"
|
||||
})
|
||||
|
||||
refute_receive _
|
||||
|
|
@ -387,8 +387,8 @@ defmodule Pleroma.Web.StreamerTest do
|
|||
|
||||
{:ok, _activity} =
|
||||
CommonAPI.post(user_b, %{
|
||||
"status" => "Test",
|
||||
"visibility" => "private"
|
||||
status: "Test",
|
||||
visibility: "private"
|
||||
})
|
||||
|
||||
refute_receive _
|
||||
|
|
@ -407,8 +407,8 @@ defmodule Pleroma.Web.StreamerTest do
|
|||
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(user_b, %{
|
||||
"status" => "Test",
|
||||
"visibility" => "private"
|
||||
status: "Test",
|
||||
visibility: "private"
|
||||
})
|
||||
|
||||
assert_receive {:render_with_user, _, _, ^activity}
|
||||
|
|
@ -424,7 +424,7 @@ defmodule Pleroma.Web.StreamerTest do
|
|||
CommonAPI.follow(user1, user2)
|
||||
CommonAPI.hide_reblogs(user1, user2)
|
||||
|
||||
{:ok, create_activity} = CommonAPI.post(user3, %{"status" => "I'm kawen"})
|
||||
{:ok, create_activity} = CommonAPI.post(user3, %{status: "I'm kawen"})
|
||||
|
||||
Streamer.get_topic_and_add_socket("user", user1)
|
||||
{:ok, announce_activity, _} = CommonAPI.repeat(create_activity.id, user2)
|
||||
|
|
@ -438,7 +438,7 @@ defmodule Pleroma.Web.StreamerTest do
|
|||
CommonAPI.follow(user1, user2)
|
||||
CommonAPI.hide_reblogs(user1, user2)
|
||||
|
||||
{:ok, create_activity} = CommonAPI.post(user1, %{"status" => "I'm kawen"})
|
||||
{:ok, create_activity} = CommonAPI.post(user1, %{status: "I'm kawen"})
|
||||
Streamer.get_topic_and_add_socket("user", user1)
|
||||
{:ok, _favorite_activity, _} = CommonAPI.repeat(create_activity.id, user2)
|
||||
|
||||
|
|
@ -452,7 +452,7 @@ defmodule Pleroma.Web.StreamerTest do
|
|||
CommonAPI.follow(user1, user2)
|
||||
CommonAPI.hide_reblogs(user1, user2)
|
||||
|
||||
{:ok, create_activity} = CommonAPI.post(user1, %{"status" => "I'm kawen"})
|
||||
{:ok, create_activity} = CommonAPI.post(user1, %{status: "I'm kawen"})
|
||||
Streamer.get_topic_and_add_socket("user", user1)
|
||||
{:ok, _favorite_activity} = CommonAPI.favorite(user2, create_activity.id)
|
||||
|
||||
|
|
@ -466,7 +466,7 @@ defmodule Pleroma.Web.StreamerTest do
|
|||
user2 = insert(:user)
|
||||
Streamer.get_topic_and_add_socket("user", user2)
|
||||
{:ok, user2, user, _activity} = CommonAPI.follow(user2, user)
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "super hot take"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "super hot take"})
|
||||
{:ok, _} = CommonAPI.add_mute(user2, activity)
|
||||
assert_receive {:render_with_user, _, _, ^activity}
|
||||
assert Streamer.filtered_by_user?(user2, activity)
|
||||
|
|
@ -485,8 +485,8 @@ defmodule Pleroma.Web.StreamerTest do
|
|||
|
||||
{:ok, _create_activity} =
|
||||
CommonAPI.post(another_user, %{
|
||||
"status" => "hey @#{user.nickname}",
|
||||
"visibility" => "direct"
|
||||
status: "hey @#{user.nickname}",
|
||||
visibility: "direct"
|
||||
})
|
||||
|
||||
assert_receive {:text, received_event}
|
||||
|
|
@ -507,8 +507,8 @@ defmodule Pleroma.Web.StreamerTest do
|
|||
|
||||
{:ok, create_activity} =
|
||||
CommonAPI.post(another_user, %{
|
||||
"status" => "hi @#{user.nickname}",
|
||||
"visibility" => "direct"
|
||||
status: "hi @#{user.nickname}",
|
||||
visibility: "direct"
|
||||
})
|
||||
|
||||
create_activity_id = create_activity.id
|
||||
|
|
@ -533,15 +533,15 @@ defmodule Pleroma.Web.StreamerTest do
|
|||
|
||||
{:ok, create_activity} =
|
||||
CommonAPI.post(another_user, %{
|
||||
"status" => "hi @#{user.nickname}",
|
||||
"visibility" => "direct"
|
||||
status: "hi @#{user.nickname}",
|
||||
visibility: "direct"
|
||||
})
|
||||
|
||||
{:ok, create_activity2} =
|
||||
CommonAPI.post(another_user, %{
|
||||
"status" => "hi @#{user.nickname} 2",
|
||||
"in_reply_to_status_id" => create_activity.id,
|
||||
"visibility" => "direct"
|
||||
status: "hi @#{user.nickname} 2",
|
||||
in_reply_to_status_id: create_activity.id,
|
||||
visibility: "direct"
|
||||
})
|
||||
|
||||
assert_receive {:render_with_user, _, _, ^create_activity}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ defmodule Pleroma.Workers.Cron.DigestEmailsWorkerTest do
|
|||
|
||||
user2 = insert(:user, last_digest_emailed_at: date)
|
||||
{:ok, _} = User.switch_email_notifications(user2, "digest", true)
|
||||
CommonAPI.post(user, %{"status" => "hey @#{user2.nickname}!"})
|
||||
CommonAPI.post(user, %{status: "hey @#{user2.nickname}!"})
|
||||
|
||||
{:ok, user2: user2}
|
||||
end
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ defmodule Pleroma.Workers.Cron.NewUsersDigestWorkerTest do
|
|||
admin = insert(:user, %{is_admin: true})
|
||||
user = insert(:user, %{inserted_at: yesterday})
|
||||
user2 = insert(:user, %{inserted_at: yesterday})
|
||||
CommonAPI.post(user, %{"status" => "cofe"})
|
||||
CommonAPI.post(user, %{status: "cofe"})
|
||||
|
||||
NewUsersDigestWorker.perform(nil, nil)
|
||||
ObanHelpers.perform_all()
|
||||
|
|
@ -36,7 +36,7 @@ defmodule Pleroma.Workers.Cron.NewUsersDigestWorkerTest do
|
|||
insert(:user, %{inserted_at: yesterday})
|
||||
user = insert(:user, %{inserted_at: yesterday})
|
||||
|
||||
CommonAPI.post(user, %{"status" => "cofe"})
|
||||
CommonAPI.post(user, %{status: "cofe"})
|
||||
|
||||
NewUsersDigestWorker.perform(nil, nil)
|
||||
ObanHelpers.perform_all()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue