Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop relying on downloading from Fediverse Observer #471

Open
palant opened this issue Jan 12, 2025 · 2 comments
Open

Stop relying on downloading from Fediverse Observer #471

palant opened this issue Jan 12, 2025 · 2 comments

Comments

@palant
Copy link
Collaborator

palant commented Jan 12, 2025

This needs some consideration @reuixiy.

Back when I introduced “Share to Fediverse”, downloading the list of instances from Fediverse Observer was necessary to determine software name in some cases. This can now be done more reliably by downloading nodeinfo file, we can remove the Fediverse Observer fallback here.

We still need a list of instances for autocomplete. But since this isn’t essential functionality, maybe we can stop downloading the data dynamically (slow and error-prone) and instead bundle the list with MemE. It’s 210 KiB that can be generated with the following command:

curl https://api.fediverse.observer/ -d '{"query": "{nodes(softwarename: \"\"){softwarename domain}}"}'   \
    | jq -c '
        .data.nodes
        | map(select(.softwarename | in({
            "calckey":1,
            "diaspora":1,
            "fedibird":1,
            "firefish":1,
            "foundkey":1,
            "friendica":1,
            "glitchcafe":1,
            "gnusocial":1,
            "hometown":1,
            "hubzilla":1,
            "kbin":1,
            "lemmy":1,
            "mastodon":1,
            "meisskey":1,
            "microdotblog":1,
            "misskey":1,
        })))
        | map(.domain)
    ' > data/fedi_instances.json

But then this list would need occasional updating in this repository. Is that feasible?

@palant
Copy link
Collaborator Author

palant commented Jan 12, 2025

It probably makes sense to filter out instances with barely any users:

curl https://api.fediverse.observer/ -d '{"query": "{nodes(softwarename: \"\"){softwarename domain active_users_monthly}}"}'   \
    | jq -c '
        .data.nodes
        | map(select(.active_users_monthly >= 5))
        | map(select(.softwarename | in({
            "calckey":1,
            "diaspora":1,
            "fedibird":1,
            "firefish":1,
            "foundkey":1,
            "friendica":1,
            "glitchcafe":1,
            "gnusocial":1,
            "hometown":1,
            "hubzilla":1,
            "kbin":1,
            "lemmy":1,
            "mastodon":1,
            "meisskey":1,
            "microdotblog":1,
            "misskey":1,
        })))
        | map(.domain)
    ' > data/fedi_instances.json

This reduces the size of the data file to 45 KiB.

@reuixiy
Copy link
Owner

reuixiy commented Jan 17, 2025

I think if we need the fedi_instances.json file, instead of bundling it with MemE, it would be better to generate it independently and provide it as a third-party file. That makes sense to me, since users may not update MemE frequently.

Also, do we need this getSoftwareName() function on the front-end side anymore?

function getSoftwareName(instance) {
for (let option of document.querySelectorAll("#fediverse-domains > option"))
if (option.value == instance)
return Promise.resolve(option.getAttribute("data-project"));
const SUPPORTED_SCHEMAS = [
"http://nodeinfo.diaspora.software/ns/schema/2.0",
"http://nodeinfo.diaspora.software/ns/schema/2.1",
];
return fetch(`https://${instance}/.well-known/nodeinfo`).then(response => response.json()).then(response => {
if (response && Array.isArray(response.links))
for (let link of response.links)
if (SUPPORTED_SCHEMAS.includes(link.rel) && typeof link.href == "string")
return fetch(link.href);
throw new Exception(".well-known/nodeinfo file does not contain a nodeinfo link");
}).then(response => response.json()).then(response => {
if (response && response.software && typeof response.software.name == "string")
return response.software.name;
throw new Exception("nodeinfo link does not contain a software name");
}).catch(error => {
console.error(error);
// Download probably failed due to CORS error, assume Mastodon or compatible
return "mastodon";
});
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants