Merge branch 'develop' into 'bookmark-folders'
# Conflicts: # docs/development/API/differences_in_mastoapi_responses.md
This commit is contained in:
commit
2b71f4897f
47 changed files with 485 additions and 81 deletions
|
|
@ -166,6 +166,7 @@ defmodule Pleroma.User.BackupTest do
|
|||
|
||||
test "it creates a zip archive with user data" do
|
||||
user = insert(:user, %{nickname: "cofe", name: "Cofe", ap_id: "http://cofe.io/users/cofe"})
|
||||
%{ap_id: other_ap_id} = other_user = insert(:user)
|
||||
|
||||
{:ok, %{object: %{data: %{"id" => id1}}} = status1} =
|
||||
CommonAPI.post(user, %{status: "status1"})
|
||||
|
|
@ -182,6 +183,8 @@ defmodule Pleroma.User.BackupTest do
|
|||
Bookmark.create(user.id, status2.id)
|
||||
Bookmark.create(user.id, status3.id)
|
||||
|
||||
CommonAPI.follow(user, other_user)
|
||||
|
||||
assert {:ok, backup} = user |> Backup.new() |> Repo.insert()
|
||||
assert {:ok, path} = Backup.export(backup, self())
|
||||
assert {:ok, zipfile} = :zip.zip_open(String.to_charlist(path), [:memory])
|
||||
|
|
@ -261,6 +264,16 @@ defmodule Pleroma.User.BackupTest do
|
|||
"type" => "OrderedCollection"
|
||||
} = Jason.decode!(json)
|
||||
|
||||
assert {:ok, {'following.json', json}} = :zip.zip_get('following.json', zipfile)
|
||||
|
||||
assert %{
|
||||
"@context" => "https://www.w3.org/ns/activitystreams",
|
||||
"id" => "following.json",
|
||||
"orderedItems" => [^other_ap_id],
|
||||
"totalItems" => 1,
|
||||
"type" => "OrderedCollection"
|
||||
} = Jason.decode!(json)
|
||||
|
||||
:zip.zip_close(zipfile)
|
||||
File.rm!(path)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -2928,4 +2928,51 @@ defmodule Pleroma.UserTest do
|
|||
refute User.endorses?(user, pinned_user)
|
||||
end
|
||||
end
|
||||
|
||||
test "it checks fields links for a backlink" do
|
||||
user = insert(:user, ap_id: "https://social.example.org/users/lain")
|
||||
|
||||
fields = [
|
||||
%{"name" => "Link", "value" => "http://example.com/rel_me/null"},
|
||||
%{"name" => "Verified link", "value" => "http://example.com/rel_me/link"},
|
||||
%{"name" => "Not a link", "value" => "i'm not a link"}
|
||||
]
|
||||
|
||||
user
|
||||
|> User.update_and_set_cache(%{raw_fields: fields})
|
||||
|
||||
ObanHelpers.perform_all()
|
||||
|
||||
user = User.get_cached_by_id(user.id)
|
||||
|
||||
assert [
|
||||
%{"verified_at" => nil},
|
||||
%{"verified_at" => verified_at},
|
||||
%{"verified_at" => nil}
|
||||
] = user.fields
|
||||
|
||||
assert is_binary(verified_at)
|
||||
end
|
||||
|
||||
test "updating fields does not invalidate previously validated links" do
|
||||
user = insert(:user, ap_id: "https://social.example.org/users/lain")
|
||||
|
||||
user
|
||||
|> User.update_and_set_cache(%{
|
||||
raw_fields: [%{"name" => "verified link", "value" => "http://example.com/rel_me/link"}]
|
||||
})
|
||||
|
||||
ObanHelpers.perform_all()
|
||||
|
||||
%User{fields: [%{"verified_at" => verified_at}]} = user = User.get_cached_by_id(user.id)
|
||||
|
||||
user
|
||||
|> User.update_and_set_cache(%{
|
||||
raw_fields: [%{"name" => "Verified link", "value" => "http://example.com/rel_me/link"}]
|
||||
})
|
||||
|
||||
user = User.get_cached_by_id(user.id)
|
||||
|
||||
assert [%{"verified_at" => ^verified_at}] = user.fields
|
||||
end
|
||||
end
|
||||
|
|
|
|||
73
test/pleroma/web/activity_pub/mrf/force_mention_test.exs
Normal file
73
test/pleroma/web/activity_pub/mrf/force_mention_test.exs
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2024 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Web.ActivityPub.MRF.ForceMentionTest do
|
||||
use Pleroma.DataCase
|
||||
require Pleroma.Constants
|
||||
|
||||
alias Pleroma.Web.ActivityPub.MRF.ForceMention
|
||||
|
||||
import Pleroma.Factory
|
||||
|
||||
test "adds mention to a reply" do
|
||||
lain =
|
||||
insert(:user, ap_id: "https://lain.com/users/lain", nickname: "lain@lain.com", local: false)
|
||||
|
||||
niobleoum =
|
||||
insert(:user,
|
||||
ap_id: "https://www.minds.com/api/activitypub/users/1198929502760083472",
|
||||
nickname: "niobleoum@minds.com",
|
||||
local: false
|
||||
)
|
||||
|
||||
status = File.read!("test/fixtures/minds-pleroma-mentioned-post.json") |> Jason.decode!()
|
||||
|
||||
status_activity = %{
|
||||
"type" => "Create",
|
||||
"actor" => lain.ap_id,
|
||||
"object" => status
|
||||
}
|
||||
|
||||
Pleroma.Web.ActivityPub.Transmogrifier.handle_incoming(status_activity)
|
||||
|
||||
reply = File.read!("test/fixtures/minds-invalid-mention-post.json") |> Jason.decode!()
|
||||
|
||||
reply_activity = %{
|
||||
"type" => "Create",
|
||||
"actor" => niobleoum.ap_id,
|
||||
"object" => reply
|
||||
}
|
||||
|
||||
{:ok, %{"object" => %{"tag" => tag}}} = ForceMention.filter(reply_activity)
|
||||
|
||||
assert Enum.find(tag, fn %{"href" => href} -> href == lain.ap_id end)
|
||||
end
|
||||
|
||||
test "adds mention to a quote" do
|
||||
user1 = insert(:user, ap_id: "https://misskey.io/users/83ssedkv53")
|
||||
user2 = insert(:user, ap_id: "https://misskey.io/users/7rkrarq81i")
|
||||
|
||||
status = File.read!("test/fixtures/tesla_mock/misskey.io_8vs6wxufd0.json") |> Jason.decode!()
|
||||
|
||||
status_activity = %{
|
||||
"type" => "Create",
|
||||
"actor" => user1.ap_id,
|
||||
"object" => status
|
||||
}
|
||||
|
||||
Pleroma.Web.ActivityPub.Transmogrifier.handle_incoming(status_activity)
|
||||
|
||||
quote_post = File.read!("test/fixtures/quote_post/misskey_quote_post.json") |> Jason.decode!()
|
||||
|
||||
quote_activity = %{
|
||||
"type" => "Create",
|
||||
"actor" => user2.ap_id,
|
||||
"object" => quote_post
|
||||
}
|
||||
|
||||
{:ok, %{"object" => %{"tag" => tag}}} = ForceMention.filter(quote_activity)
|
||||
|
||||
assert Enum.find(tag, fn %{"href" => href} -> href == user1.ap_id end)
|
||||
end
|
||||
end
|
||||
|
|
@ -25,6 +25,17 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do
|
|||
|
||||
setup_all do: clear_config([:instance, :federating], true)
|
||||
|
||||
describe "should_federate?/1" do
|
||||
test "it returns false when the inbox is nil" do
|
||||
refute Publisher.should_federate?(nil, false)
|
||||
refute Publisher.should_federate?(nil, true)
|
||||
end
|
||||
|
||||
test "it returns true when public is true" do
|
||||
assert Publisher.should_federate?(false, true)
|
||||
end
|
||||
end
|
||||
|
||||
describe "gather_webfinger_links/1" do
|
||||
test "it returns links" do
|
||||
user = insert(:user)
|
||||
|
|
@ -205,6 +216,7 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do
|
|||
refute called(Instances.set_reachable(inbox))
|
||||
end
|
||||
|
||||
@tag capture_log: true
|
||||
test_with_mock "calls `Instances.set_unreachable` on target inbox on non-2xx HTTP response code",
|
||||
Instances,
|
||||
[:passthrough],
|
||||
|
|
|
|||
|
|
@ -107,6 +107,18 @@ defmodule Pleroma.Web.MastodonAPI.InstanceControllerTest do
|
|||
|> json_response_and_validate_schema(200)
|
||||
end
|
||||
|
||||
test "get instance contact information", %{conn: conn} do
|
||||
user = insert(:user, %{local: true})
|
||||
|
||||
clear_config([:instance, :contact_username], user.nickname)
|
||||
|
||||
conn = get(conn, "/api/v1/instance")
|
||||
|
||||
assert result = json_response_and_validate_schema(conn, 200)
|
||||
|
||||
assert result["contact_account"]["id"] == user.id
|
||||
end
|
||||
|
||||
test "get instance information v2", %{conn: conn} do
|
||||
clear_config([:auth, :oauth_consumer_strategies], [])
|
||||
|
||||
|
|
|
|||
|
|
@ -511,10 +511,15 @@ defmodule Pleroma.Web.MastodonAPI.UpdateCredentialsTest do
|
|||
|> json_response_and_validate_schema(200)
|
||||
|
||||
assert account_data["fields"] == [
|
||||
%{"name" => "<a href=\"http://google.com\">foo</a>", "value" => "bar"},
|
||||
%{
|
||||
"name" => "<a href=\"http://google.com\">foo</a>",
|
||||
"value" => "bar",
|
||||
"verified_at" => nil
|
||||
},
|
||||
%{
|
||||
"name" => "link.io",
|
||||
"value" => ~S(<a href="http://cofe.io" rel="ugc">cofe.io</a>)
|
||||
"value" => ~S(<a href="http://cofe.io" rel="ugc">cofe.io</a>),
|
||||
"verified_at" => nil
|
||||
}
|
||||
]
|
||||
|
||||
|
|
@ -573,8 +578,8 @@ defmodule Pleroma.Web.MastodonAPI.UpdateCredentialsTest do
|
|||
|> json_response_and_validate_schema(200)
|
||||
|
||||
assert account_data["fields"] == [
|
||||
%{"name" => ":firefox:", "value" => "is best 2hu"},
|
||||
%{"name" => "they wins", "value" => ":blank:"}
|
||||
%{"name" => ":firefox:", "value" => "is best 2hu", "verified_at" => nil},
|
||||
%{"name" => "they wins", "value" => ":blank:", "verified_at" => nil}
|
||||
]
|
||||
|
||||
assert account_data["source"]["fields"] == [
|
||||
|
|
@ -602,10 +607,11 @@ defmodule Pleroma.Web.MastodonAPI.UpdateCredentialsTest do
|
|||
|> json_response_and_validate_schema(200)
|
||||
|
||||
assert account["fields"] == [
|
||||
%{"name" => "foo", "value" => "bar"},
|
||||
%{"name" => "foo", "value" => "bar", "verified_at" => nil},
|
||||
%{
|
||||
"name" => "link",
|
||||
"value" => ~S(<a href="http://cofe.io" rel="ugc">http://cofe.io</a>)
|
||||
"value" => ~S(<a href="http://cofe.io" rel="ugc">http://cofe.io</a>),
|
||||
"verified_at" => nil
|
||||
}
|
||||
]
|
||||
|
||||
|
|
@ -627,7 +633,7 @@ defmodule Pleroma.Web.MastodonAPI.UpdateCredentialsTest do
|
|||
|> json_response_and_validate_schema(200)
|
||||
|
||||
assert account["fields"] == [
|
||||
%{"name" => "foo", "value" => ""}
|
||||
%{"name" => "foo", "value" => "", "verified_at" => nil}
|
||||
]
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -43,7 +43,8 @@ defmodule Pleroma.Web.MastodonAPI.PollViewTest do
|
|||
%{title: "why are you even asking?", votes_count: 0}
|
||||
],
|
||||
votes_count: 0,
|
||||
voters_count: 0
|
||||
voters_count: 0,
|
||||
pleroma: %{non_anonymous: false}
|
||||
}
|
||||
|
||||
result = PollView.render("show.json", %{object: object})
|
||||
|
|
@ -165,4 +166,11 @@ defmodule Pleroma.Web.MastodonAPI.PollViewTest do
|
|||
]
|
||||
} = PollView.render("show.json", %{object: object})
|
||||
end
|
||||
|
||||
test "that poll is non anonymous" do
|
||||
object = Object.normalize("https://friends.grishka.me/posts/54642", fetch: true)
|
||||
result = PollView.render("show.json", %{object: object})
|
||||
|
||||
assert result[:pleroma][:non_anonymous] == true
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue