web/ap/view/user: don't dupe collection patterns
Some checks failed
ci/woodpecker/pr/test/2 Pipeline failed
ci/woodpecker/pr/test/1 Pipeline was successful
ci/woodpecker/push/docs Pipeline was successful
ci/woodpecker/push/publish/4 Pipeline failed
ci/woodpecker/push/publish/1 Pipeline was successful
ci/woodpecker/push/publish/2 Pipeline was successful
Some checks failed
ci/woodpecker/pr/test/2 Pipeline failed
ci/woodpecker/pr/test/1 Pipeline was successful
ci/woodpecker/push/docs Pipeline was successful
ci/woodpecker/push/publish/4 Pipeline failed
ci/woodpecker/push/publish/1 Pipeline was successful
ci/woodpecker/push/publish/2 Pipeline was successful
With the preceeding two commits we can now be sure there will always be usable values. So no need for copy-paste error and desync-prone duping anymore.
This commit is contained in:
parent
057d977f5a
commit
d5c2ee6023
3 changed files with 34 additions and 28 deletions
|
|
@ -39,8 +39,8 @@ defmodule Pleroma.Web.ActivityPub.UserView do
|
|||
%{
|
||||
"id" => user.ap_id,
|
||||
"type" => "Application",
|
||||
"inbox" => "#{user.ap_id}/inbox",
|
||||
"outbox" => "#{user.ap_id}/outbox",
|
||||
"inbox" => user.inbox,
|
||||
"outbox" => user.outbox,
|
||||
"name" => "Akkoma",
|
||||
"summary" =>
|
||||
"An internal service actor for this Akkoma instance. No user-serviceable parts inside.",
|
||||
|
|
@ -84,11 +84,11 @@ defmodule Pleroma.Web.ActivityPub.UserView do
|
|||
%{
|
||||
"id" => user.ap_id,
|
||||
"type" => user.actor_type,
|
||||
"following" => "#{user.ap_id}/following",
|
||||
"followers" => "#{user.ap_id}/followers",
|
||||
"inbox" => "#{user.ap_id}/inbox",
|
||||
"outbox" => "#{user.ap_id}/outbox",
|
||||
"featured" => "#{user.ap_id}/collections/featured",
|
||||
"following" => user.following_address,
|
||||
"followers" => user.follower_address,
|
||||
"inbox" => user.inbox,
|
||||
"outbox" => user.outbox,
|
||||
"featured" => user.featured_address,
|
||||
"preferredUsername" => user.nickname,
|
||||
"name" => user.name,
|
||||
"summary" => user.bio,
|
||||
|
|
@ -139,8 +139,8 @@ defmodule Pleroma.Web.ActivityPub.UserView do
|
|||
"publicKeyPem" => public_key
|
||||
},
|
||||
# REQUIRED fields per AP spec
|
||||
"inbox" => "#{user.ap_id}/inbox",
|
||||
"outbox" => "#{user.ap_id}/outbox",
|
||||
"inbox" => user.inbox,
|
||||
"outbox" => user.outbox,
|
||||
# allow type-based processing
|
||||
"type" => user.actor_type,
|
||||
# since Mastodon requires a WebFinger address for all users, this seems like a good idea
|
||||
|
|
@ -172,7 +172,7 @@ defmodule Pleroma.Web.ActivityPub.UserView do
|
|||
|
||||
CollectionViewHelper.collection_page_offset(
|
||||
following,
|
||||
"#{user.ap_id}/following",
|
||||
user.following_address,
|
||||
page,
|
||||
showing_items,
|
||||
total
|
||||
|
|
@ -199,13 +199,13 @@ defmodule Pleroma.Web.ActivityPub.UserView do
|
|||
showing_items &&
|
||||
CollectionViewHelper.collection_page_offset(
|
||||
following,
|
||||
"#{user.ap_id}/following",
|
||||
user.following_address,
|
||||
1,
|
||||
!user.hide_follows
|
||||
)
|
||||
|
||||
CollectionViewHelper.collection_root_ordered(
|
||||
"#{user.ap_id}/following",
|
||||
user.following_address,
|
||||
total,
|
||||
first_page
|
||||
)
|
||||
|
|
@ -234,7 +234,7 @@ defmodule Pleroma.Web.ActivityPub.UserView do
|
|||
|
||||
CollectionViewHelper.collection_page_offset(
|
||||
followers,
|
||||
"#{user.ap_id}/followers",
|
||||
user.follower_address,
|
||||
page,
|
||||
showing_items,
|
||||
total
|
||||
|
|
@ -261,14 +261,14 @@ defmodule Pleroma.Web.ActivityPub.UserView do
|
|||
showing_items &&
|
||||
CollectionViewHelper.collection_page_offset(
|
||||
followers,
|
||||
"#{user.ap_id}/followers",
|
||||
user.follower_address,
|
||||
1,
|
||||
showing_items,
|
||||
total
|
||||
)
|
||||
|
||||
CollectionViewHelper.collection_root_ordered(
|
||||
"#{user.ap_id}/followers",
|
||||
user.follower_address,
|
||||
total,
|
||||
first_page
|
||||
)
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ defmodule Pleroma.User.BackupTest do
|
|||
end
|
||||
|
||||
test "it creates a zip archive with user data" do
|
||||
user = insert(:user, %{nickname: "cofe", name: "Cofe", ap_id: "http://cofe.io/users/cofe"})
|
||||
user = insert(:user, %{nickname: "cofe", name: "Cofe"})
|
||||
|
||||
{:ok, %{object: %{data: %{"id" => id1}}} = status1} =
|
||||
CommonAPI.post(user, %{status: "status1"})
|
||||
|
|
@ -153,6 +153,12 @@ defmodule Pleroma.User.BackupTest do
|
|||
assert {:ok, zipfile} = :zip.zip_open(String.to_charlist(path), [:memory])
|
||||
assert {:ok, {~c"actor.json", json}} = :zip.zip_get(~c"actor.json", zipfile)
|
||||
|
||||
ap_id = user.ap_id
|
||||
inbox_ap = user.inbox
|
||||
outbox_ap = user.outbox
|
||||
followers_ap = user.follower_address
|
||||
following_ap = user.following_address
|
||||
|
||||
assert %{
|
||||
"@context" => [
|
||||
"https://www.w3.org/ns/activitystreams",
|
||||
|
|
@ -161,20 +167,20 @@ defmodule Pleroma.User.BackupTest do
|
|||
%{"@language" => "und"}
|
||||
],
|
||||
"bookmarks" => "bookmarks.json",
|
||||
"followers" => "http://cofe.io/users/cofe/followers",
|
||||
"following" => "http://cofe.io/users/cofe/following",
|
||||
"id" => "http://cofe.io/users/cofe",
|
||||
"inbox" => "http://cofe.io/users/cofe/inbox",
|
||||
"followers" => ^followers_ap,
|
||||
"following" => ^following_ap,
|
||||
"id" => ^ap_id,
|
||||
"inbox" => ^inbox_ap,
|
||||
"likes" => "likes.json",
|
||||
"name" => "Cofe",
|
||||
"outbox" => "http://cofe.io/users/cofe/outbox",
|
||||
"outbox" => ^outbox_ap,
|
||||
"preferredUsername" => "cofe",
|
||||
"publicKey" => %{
|
||||
"id" => "http://cofe.io/users/cofe#main-key",
|
||||
"owner" => "http://cofe.io/users/cofe"
|
||||
"id" => ^ap_id <> "#main-key",
|
||||
"owner" => ^ap_id
|
||||
},
|
||||
"type" => "Person",
|
||||
"url" => "http://cofe.io/users/cofe"
|
||||
"url" => ^ap_id
|
||||
} = Jason.decode!(json)
|
||||
|
||||
assert {:ok, {~c"outbox.json", json}} = :zip.zip_get(~c"outbox.json", zipfile)
|
||||
|
|
@ -185,7 +191,7 @@ defmodule Pleroma.User.BackupTest do
|
|||
"orderedItems" => [
|
||||
%{
|
||||
"object" => %{
|
||||
"actor" => "http://cofe.io/users/cofe",
|
||||
"actor" => ^ap_id,
|
||||
"content" => "status1",
|
||||
"type" => "Note"
|
||||
},
|
||||
|
|
@ -193,12 +199,12 @@ defmodule Pleroma.User.BackupTest do
|
|||
},
|
||||
%{
|
||||
"object" => %{
|
||||
"actor" => "http://cofe.io/users/cofe",
|
||||
"actor" => ^ap_id,
|
||||
"content" => "status2"
|
||||
}
|
||||
},
|
||||
%{
|
||||
"actor" => "http://cofe.io/users/cofe",
|
||||
"actor" => ^ap_id,
|
||||
"object" => %{
|
||||
"content" => "status3"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ defmodule Pleroma.Factory do
|
|||
if attrs[:local] == false do
|
||||
base_domain = attrs[:domain] || Enum.random(["domain1.com", "domain2.com", "domain3.com"])
|
||||
|
||||
ap_id = "https://#{base_domain}/users/#{user.nickname}"
|
||||
ap_id = attrs[:ap_id] || "https://#{base_domain}/users/#{user.nickname}"
|
||||
|
||||
%{
|
||||
ap_id: ap_id,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue