# Pleroma: A lightweight social networking server
-# Copyright © 2019 Pleroma Authors <https://pleroma.social/>
+# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.ActivityPub.PublisherTest do
:ok
end
+ setup_all do: clear_config([:instance, :federating], true)
+
+ describe "gather_webfinger_links/1" do
+ test "it returns links" do
+ user = insert(:user)
+
+ expected_links = [
+ %{"href" => user.ap_id, "rel" => "self", "type" => "application/activity+json"},
+ %{
+ "href" => user.ap_id,
+ "rel" => "self",
+ "type" => "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\""
+ },
+ %{
+ "rel" => "http://ostatus.org/schema/1.0/subscribe",
+ "template" => "#{Pleroma.Web.base_url()}/ostatus_subscribe?acct={uri}"
+ }
+ ]
+
+ assert expected_links == Publisher.gather_webfinger_links(user)
+ end
+ end
+
describe "determine_inbox/2" do
test "it returns sharedInbox for messages involving as:Public in to" do
- user =
- insert(:user, %{
- info: %{source_data: %{"endpoints" => %{"sharedInbox" => "http://example.com/inbox"}}}
- })
+ user = insert(:user, %{shared_inbox: "http://example.com/inbox"})
activity = %Activity{
data: %{"to" => [@as_public], "cc" => [user.follower_address]}
end
test "it returns sharedInbox for messages involving as:Public in cc" do
- user =
- insert(:user, %{
- info: %{source_data: %{"endpoints" => %{"sharedInbox" => "http://example.com/inbox"}}}
- })
+ user = insert(:user, %{shared_inbox: "http://example.com/inbox"})
activity = %Activity{
data: %{"cc" => [@as_public], "to" => [user.follower_address]}
end
test "it returns sharedInbox for messages involving multiple recipients in to" do
- user =
- insert(:user, %{
- info: %{source_data: %{"endpoints" => %{"sharedInbox" => "http://example.com/inbox"}}}
- })
-
+ user = insert(:user, %{shared_inbox: "http://example.com/inbox"})
user_two = insert(:user)
user_three = insert(:user)
end
test "it returns sharedInbox for messages involving multiple recipients in cc" do
- user =
- insert(:user, %{
- info: %{source_data: %{"endpoints" => %{"sharedInbox" => "http://example.com/inbox"}}}
- })
-
+ user = insert(:user, %{shared_inbox: "http://example.com/inbox"})
user_two = insert(:user)
user_three = insert(:user)
test "it returns sharedInbox for messages involving multiple recipients in total" do
user =
insert(:user, %{
- info: %{
- source_data: %{
- "inbox" => "http://example.com/personal-inbox",
- "endpoints" => %{"sharedInbox" => "http://example.com/inbox"}
- }
- }
+ shared_inbox: "http://example.com/inbox",
+ inbox: "http://example.com/personal-inbox"
})
user_two = insert(:user)
test "it returns inbox for messages involving single recipients in total" do
user =
insert(:user, %{
- info: %{
- source_data: %{
- "inbox" => "http://example.com/personal-inbox",
- "endpoints" => %{"sharedInbox" => "http://example.com/inbox"}
- }
- }
+ shared_inbox: "http://example.com/inbox",
+ inbox: "http://example.com/personal-inbox"
})
activity = %Activity{
[:passthrough],
[] do
follower =
- insert(:user,
+ insert(:user, %{
local: false,
- info: %{
- ap_enabled: true,
- source_data: %{"inbox" => "https://domain.com/users/nick1/inbox"}
- }
- )
+ inbox: "https://domain.com/users/nick1/inbox",
+ ap_enabled: true
+ })
actor = insert(:user, follower_address: follower.ap_id)
user = insert(:user)
fetcher =
insert(:user,
local: false,
- info: %{
- ap_enabled: true,
- source_data: %{"inbox" => "https://domain.com/users/nick1/inbox"}
- }
+ inbox: "https://domain.com/users/nick1/inbox",
+ ap_enabled: true
)
another_fetcher =
insert(:user,
local: false,
- info: %{
- ap_enabled: true,
- source_data: %{"inbox" => "https://domain2.com/users/nick1/inbox"}
- }
+ inbox: "https://domain2.com/users/nick1/inbox",
+ ap_enabled: true
)
actor = insert(:user)
assert called(
Pleroma.Web.Federator.Publisher.enqueue_one(Publisher, %{
inbox: "https://domain.com/users/nick1/inbox",
- actor: actor,
+ actor_id: actor.id,
id: delete.data["id"]
})
)
assert called(
Pleroma.Web.Federator.Publisher.enqueue_one(Publisher, %{
inbox: "https://domain2.com/users/nick1/inbox",
- actor: actor,
+ actor_id: actor.id,
id: delete.data["id"]
})
)