Merge branch 'bugfix/activitypub-totalitems-removal' into 'develop'
activitypub: user inbox/outbox: `totalItems` removal See merge request pleroma/pleroma!827
This commit is contained in:
commit
6652389e80
|
@ -105,7 +105,14 @@ def render("following.json", %{user: user, page: page}) do
|
||||||
query = from(user in query, select: [:ap_id])
|
query = from(user in query, select: [:ap_id])
|
||||||
following = Repo.all(query)
|
following = Repo.all(query)
|
||||||
|
|
||||||
collection(following, "#{user.ap_id}/following", page, !user.info.hide_follows)
|
total =
|
||||||
|
if !user.info.hide_follows do
|
||||||
|
length(following)
|
||||||
|
else
|
||||||
|
0
|
||||||
|
end
|
||||||
|
|
||||||
|
collection(following, "#{user.ap_id}/following", page, !user.info.hide_follows, total)
|
||||||
|> Map.merge(Utils.make_json_ld_header())
|
|> Map.merge(Utils.make_json_ld_header())
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -114,10 +121,17 @@ def render("following.json", %{user: user}) do
|
||||||
query = from(user in query, select: [:ap_id])
|
query = from(user in query, select: [:ap_id])
|
||||||
following = Repo.all(query)
|
following = Repo.all(query)
|
||||||
|
|
||||||
|
total =
|
||||||
|
if !user.info.hide_follows do
|
||||||
|
length(following)
|
||||||
|
else
|
||||||
|
0
|
||||||
|
end
|
||||||
|
|
||||||
%{
|
%{
|
||||||
"id" => "#{user.ap_id}/following",
|
"id" => "#{user.ap_id}/following",
|
||||||
"type" => "OrderedCollection",
|
"type" => "OrderedCollection",
|
||||||
"totalItems" => length(following),
|
"totalItems" => total,
|
||||||
"first" => collection(following, "#{user.ap_id}/following", 1, !user.info.hide_follows)
|
"first" => collection(following, "#{user.ap_id}/following", 1, !user.info.hide_follows)
|
||||||
}
|
}
|
||||||
|> Map.merge(Utils.make_json_ld_header())
|
|> Map.merge(Utils.make_json_ld_header())
|
||||||
|
@ -128,7 +142,14 @@ def render("followers.json", %{user: user, page: page}) do
|
||||||
query = from(user in query, select: [:ap_id])
|
query = from(user in query, select: [:ap_id])
|
||||||
followers = Repo.all(query)
|
followers = Repo.all(query)
|
||||||
|
|
||||||
collection(followers, "#{user.ap_id}/followers", page, !user.info.hide_followers)
|
total =
|
||||||
|
if !user.info.hide_followers do
|
||||||
|
length(followers)
|
||||||
|
else
|
||||||
|
0
|
||||||
|
end
|
||||||
|
|
||||||
|
collection(followers, "#{user.ap_id}/followers", page, !user.info.hide_followers, total)
|
||||||
|> Map.merge(Utils.make_json_ld_header())
|
|> Map.merge(Utils.make_json_ld_header())
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -137,19 +158,24 @@ def render("followers.json", %{user: user}) do
|
||||||
query = from(user in query, select: [:ap_id])
|
query = from(user in query, select: [:ap_id])
|
||||||
followers = Repo.all(query)
|
followers = Repo.all(query)
|
||||||
|
|
||||||
|
total =
|
||||||
|
if !user.info.hide_followers do
|
||||||
|
length(followers)
|
||||||
|
else
|
||||||
|
0
|
||||||
|
end
|
||||||
|
|
||||||
%{
|
%{
|
||||||
"id" => "#{user.ap_id}/followers",
|
"id" => "#{user.ap_id}/followers",
|
||||||
"type" => "OrderedCollection",
|
"type" => "OrderedCollection",
|
||||||
"totalItems" => length(followers),
|
"totalItems" => total,
|
||||||
"first" => collection(followers, "#{user.ap_id}/followers", 1, !user.info.hide_followers)
|
"first" =>
|
||||||
|
collection(followers, "#{user.ap_id}/followers", 1, !user.info.hide_followers, total)
|
||||||
}
|
}
|
||||||
|> Map.merge(Utils.make_json_ld_header())
|
|> Map.merge(Utils.make_json_ld_header())
|
||||||
end
|
end
|
||||||
|
|
||||||
def render("outbox.json", %{user: user, max_id: max_qid}) do
|
def render("outbox.json", %{user: user, max_id: max_qid}) do
|
||||||
# XXX: technically note_count is wrong for this, but it's better than nothing
|
|
||||||
info = User.user_info(user)
|
|
||||||
|
|
||||||
params = %{
|
params = %{
|
||||||
"limit" => "10"
|
"limit" => "10"
|
||||||
}
|
}
|
||||||
|
@ -177,7 +203,6 @@ def render("outbox.json", %{user: user, max_id: max_qid}) do
|
||||||
"id" => "#{iri}?max_id=#{max_id}",
|
"id" => "#{iri}?max_id=#{max_id}",
|
||||||
"type" => "OrderedCollectionPage",
|
"type" => "OrderedCollectionPage",
|
||||||
"partOf" => iri,
|
"partOf" => iri,
|
||||||
"totalItems" => info.note_count,
|
|
||||||
"orderedItems" => collection,
|
"orderedItems" => collection,
|
||||||
"next" => "#{iri}?max_id=#{min_id}"
|
"next" => "#{iri}?max_id=#{min_id}"
|
||||||
}
|
}
|
||||||
|
@ -186,7 +211,6 @@ def render("outbox.json", %{user: user, max_id: max_qid}) do
|
||||||
%{
|
%{
|
||||||
"id" => iri,
|
"id" => iri,
|
||||||
"type" => "OrderedCollection",
|
"type" => "OrderedCollection",
|
||||||
"totalItems" => info.note_count,
|
|
||||||
"first" => page
|
"first" => page
|
||||||
}
|
}
|
||||||
|> Map.merge(Utils.make_json_ld_header())
|
|> Map.merge(Utils.make_json_ld_header())
|
||||||
|
@ -224,7 +248,6 @@ def render("inbox.json", %{user: user, max_id: max_qid}) do
|
||||||
"id" => "#{iri}?max_id=#{max_id}",
|
"id" => "#{iri}?max_id=#{max_id}",
|
||||||
"type" => "OrderedCollectionPage",
|
"type" => "OrderedCollectionPage",
|
||||||
"partOf" => iri,
|
"partOf" => iri,
|
||||||
"totalItems" => -1,
|
|
||||||
"orderedItems" => collection,
|
"orderedItems" => collection,
|
||||||
"next" => "#{iri}?max_id=#{min_id}"
|
"next" => "#{iri}?max_id=#{min_id}"
|
||||||
}
|
}
|
||||||
|
@ -233,7 +256,6 @@ def render("inbox.json", %{user: user, max_id: max_qid}) do
|
||||||
%{
|
%{
|
||||||
"id" => iri,
|
"id" => iri,
|
||||||
"type" => "OrderedCollection",
|
"type" => "OrderedCollection",
|
||||||
"totalItems" => -1,
|
|
||||||
"first" => page
|
"first" => page
|
||||||
}
|
}
|
||||||
|> Map.merge(Utils.make_json_ld_header())
|
|> Map.merge(Utils.make_json_ld_header())
|
||||||
|
|
|
@ -397,7 +397,7 @@ test "it returns returns empty if the user has 'hide_followers' set", %{conn: co
|
||||||
|> json_response(200)
|
|> json_response(200)
|
||||||
|
|
||||||
assert result["first"]["orderedItems"] == []
|
assert result["first"]["orderedItems"] == []
|
||||||
assert result["totalItems"] == 1
|
assert result["totalItems"] == 0
|
||||||
end
|
end
|
||||||
|
|
||||||
test "it works for more than 10 users", %{conn: conn} do
|
test "it works for more than 10 users", %{conn: conn} do
|
||||||
|
@ -452,7 +452,7 @@ test "it returns returns empty if the user has 'hide_follows' set", %{conn: conn
|
||||||
|> json_response(200)
|
|> json_response(200)
|
||||||
|
|
||||||
assert result["first"]["orderedItems"] == []
|
assert result["first"]["orderedItems"] == []
|
||||||
assert result["totalItems"] == 1
|
assert result["totalItems"] == 0
|
||||||
end
|
end
|
||||||
|
|
||||||
test "it works for more than 10 users", %{conn: conn} do
|
test "it works for more than 10 users", %{conn: conn} do
|
||||||
|
|
Loading…
Reference in New Issue