kopia lustrzana https://github.com/fediversespace/fediverse.space
fix nodeinfo for some pixelfed instances
rodzic
de97f6d843
commit
ed0c28f24e
|
@ -85,7 +85,9 @@ defmodule Backend.Crawler.Crawlers.Nodeinfo do
|
|||
description =
|
||||
[
|
||||
get_in(nodeinfo, ["metadata", "description"]),
|
||||
get_in(nodeinfo, ["metadata", "nodeDescription"])
|
||||
get_in(nodeinfo, ["metadata", "nodeDescription"]),
|
||||
# pixelfed
|
||||
get_in(nodeinfo, ["metadata", "config", "site", "description"])
|
||||
]
|
||||
|> Enum.filter(fn d -> d != nil end)
|
||||
|> Enum.at(0)
|
||||
|
@ -96,8 +98,8 @@ defmodule Backend.Crawler.Crawlers.Nodeinfo do
|
|||
ApiCrawler.get_default(),
|
||||
%{
|
||||
description: description,
|
||||
user_count: user_count,
|
||||
status_count: get_in(nodeinfo, ["usage", "localPosts"]),
|
||||
user_count: handle_count(user_count),
|
||||
status_count: nodeinfo |> get_in(["usage", "localPosts"]) |> handle_count(),
|
||||
instance_type: type,
|
||||
version: get_in(nodeinfo, ["software", "version"]),
|
||||
federation_restrictions: get_federation_restrictions(nodeinfo)
|
||||
|
@ -152,4 +154,14 @@ defmodule Backend.Crawler.Crawlers.Nodeinfo do
|
|||
quarantined_domains
|
||||
end
|
||||
end
|
||||
|
||||
# handle a count that may be formatted as a string or an integer
|
||||
defp handle_count(count) do
|
||||
if is_integer(count) do
|
||||
count
|
||||
else
|
||||
{count, _rem} = Integer.parse(count)
|
||||
count
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -154,5 +154,40 @@ defmodule Backend.Crawler.Crawlers.NodeinfoTest do
|
|||
peers: []
|
||||
}
|
||||
end
|
||||
|
||||
# don't know why some pixelfed instances return numbers as strings
|
||||
# but i've seen it in the wild, so we need to handle it
|
||||
test "handles nodeinfo with some numbers stringified (pixelfed)" do
|
||||
expect(HttpMock, :get_and_decode, fn "https://pixelfed.social/.well-known/nodeinfo" ->
|
||||
{:ok,
|
||||
%{
|
||||
"links" => [
|
||||
%{
|
||||
"rel" => "http://nodeinfo.diaspora.software/ns/schema/2.0",
|
||||
"href" => "https://pixelfed.social/nodeinfo/2.0.json"
|
||||
}
|
||||
]
|
||||
}}
|
||||
end)
|
||||
|
||||
expect(HttpMock, :get_and_decode, fn "https://pixelfed.social/nodeinfo/2.0.json" ->
|
||||
{:ok, TestHelpers.load_json("nodeinfo/pixelfed.json")}
|
||||
end)
|
||||
|
||||
result = Nodeinfo.crawl("pixelfed.social", %{})
|
||||
|
||||
assert result == %{
|
||||
description:
|
||||
"Pixelfed is an image sharing platform, an ethical alternative to centralized platforms.",
|
||||
user_count: 16,
|
||||
status_count: 60,
|
||||
statuses_seen: 0,
|
||||
instance_type: :pixelfed,
|
||||
version: "0.11.2",
|
||||
federation_restrictions: [],
|
||||
interactions: %{},
|
||||
peers: []
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,89 @@
|
|||
{
|
||||
"metadata": {
|
||||
"nodeName": "Pixelfed",
|
||||
"software": {
|
||||
"homepage": "https://pixelfed.org",
|
||||
"repo": "https://github.com/pixelfed/pixelfed"
|
||||
},
|
||||
"config": {
|
||||
"open_registration": true,
|
||||
"uploader": {
|
||||
"max_photo_size": "15000",
|
||||
"max_caption_length": "500",
|
||||
"album_limit": "4",
|
||||
"image_quality": 80,
|
||||
"max_collection_length": 18,
|
||||
"optimize_image": true,
|
||||
"optimize_video": true,
|
||||
"media_types": "image/jpeg,image/png,image/gif",
|
||||
"enforce_account_limit": true
|
||||
},
|
||||
"activitypub": {
|
||||
"enabled": true,
|
||||
"remote_follow": true
|
||||
},
|
||||
"ab": {
|
||||
"lc": false,
|
||||
"rec": false,
|
||||
"loops": false,
|
||||
"top": false,
|
||||
"polls": false,
|
||||
"cached_public_timeline": false,
|
||||
"gps": false,
|
||||
"spa": true,
|
||||
"emc": false
|
||||
},
|
||||
"site": {
|
||||
"name": "Pixelfe",
|
||||
"domain": "pixelfed.example.com",
|
||||
"url": "https://pixelfed.example.com",
|
||||
"description": "Pixelfed is an image sharing platform, an ethical alternative to centralized platforms."
|
||||
},
|
||||
"username": {
|
||||
"remote": {
|
||||
"formats": ["@", "from", "custom"],
|
||||
"format": "@",
|
||||
"custom": null
|
||||
}
|
||||
},
|
||||
"features": {
|
||||
"mobile_apis": true,
|
||||
"circles": false,
|
||||
"stories": false,
|
||||
"video": false,
|
||||
"import": {
|
||||
"instagram": false,
|
||||
"mastodon": false,
|
||||
"pixelfed": false
|
||||
},
|
||||
"label": {
|
||||
"covid": {
|
||||
"enabled": true,
|
||||
"org": "visit the WHO website",
|
||||
"url": "https://www.who.int/emergencies/diseases/novel-coronavirus-2019/advice-for-public"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"protocols": ["activitypub"],
|
||||
"services": {
|
||||
"inbound": [],
|
||||
"outbound": []
|
||||
},
|
||||
"software": {
|
||||
"name": "pixelfed",
|
||||
"version": "0.11.2"
|
||||
},
|
||||
"usage": {
|
||||
"localPosts": "60",
|
||||
"localComments": 0,
|
||||
"users": {
|
||||
"total": "16",
|
||||
"activeHalfyear": 16,
|
||||
"activeMonth": 2
|
||||
}
|
||||
},
|
||||
"version": "2.0",
|
||||
"openRegistrations": true
|
||||
}
|
Ładowanie…
Reference in New Issue