mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-05-03 05:33:06 +03:00
Use NodeInfo to detect features if available
For Mastodon <=4.3 (all current stable releases of Mastodon), the NodeInfo request will always fail due to mastodon/mastodon#23135 and fall back to the existing behavior. For other server software, this will allow for more accurate checking of feature availability. Fixes #808: adds support for exclusive lists with GoToSocial 0.17+.
This commit is contained in:
parent
4a09740ae9
commit
839023cefc
4 changed files with 88 additions and 40 deletions
src/utils
|
@ -80,7 +80,6 @@ export async function initInstance(client, instance) {
|
|||
}
|
||||
__BENCHMARK.end('fetch-instance');
|
||||
if (!info) return;
|
||||
console.log(info);
|
||||
const {
|
||||
// v1
|
||||
uri,
|
||||
|
@ -89,6 +88,32 @@ export async function initInstance(client, instance) {
|
|||
domain,
|
||||
configuration: { urls: { streaming } = {} } = {},
|
||||
} = info;
|
||||
|
||||
let nodeInfo;
|
||||
try {
|
||||
if (uri || domain) {
|
||||
let urlBase = uri || `https://${domain}`;
|
||||
const wellKnownResponse = await fetch(`${urlBase}/.well-known/nodeinfo`);
|
||||
if (wellKnownResponse.ok) {
|
||||
const wellKnown = await wellKnownResponse.json();
|
||||
if (wellKnown && Array.isArray(wellKnown.links)) {
|
||||
const nodeInfoUrl = wellKnown.links.find(
|
||||
(link) => typeof link.rel === 'string' &&
|
||||
link.rel.startsWith('http://nodeinfo.diaspora.software/ns/schema/')
|
||||
)?.href;
|
||||
if (nodeInfoUrl && nodeInfoUrl.startsWith(urlBase)) {
|
||||
const nodeInfoResponse = await fetch(nodeInfoUrl);
|
||||
nodeInfo = await nodeInfoResponse.json();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) {}
|
||||
if (nodeInfo) {
|
||||
info.nodeInfo = nodeInfo;
|
||||
}
|
||||
console.log(info);
|
||||
|
||||
const instances = store.local.getJSON('instances') || {};
|
||||
if (uri || domain) {
|
||||
instances[
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue