Instead of fetching “/api/v1/instance/extended_description”, now it fetches “/api/v1/instance” even when “/api/v2/instance” is fetched, to retrieve both extended description and domain count
This commit is contained in:
parent
228610997e
commit
281ca2ab02
1 changed files with 11 additions and 9 deletions
|
@ -404,7 +404,6 @@ if ($idata['IsMastodon'] && !is_null($idata['Version']) && $idata['Version']>='4
|
|||
$idata['AdmAccount']='OPTED OUT';// here we rely on the fact that nobody could set "acct" to "OPTED OUT" since it doesn't allow spaces
|
||||
$idata['AdmAvatar']='unavailable';
|
||||
}
|
||||
// domain_count is gone from api v2, and we won't resort to api v1 just to get it when ver. >= 4.0.0
|
||||
if (isset($buf['languages']) && is_array($buf['languages']))
|
||||
$idata['languages']=$buf['languages'];
|
||||
if (isset($buf['rules']) && is_array($buf['rules']))
|
||||
|
@ -420,21 +419,24 @@ if ($idata['IsMastodon'] && !is_null($idata['Version']) && $idata['Version']>='4
|
|||
} else {
|
||||
eecho(2,'«'.$opts['hostname'].'»: could not fetch instance info from API v2: '.$buf['emsg'].'.'.N);
|
||||
}
|
||||
eecho(0,'«'.$opts['hostname'].'»: trying to fetch instance extended description from API v1...'.N);
|
||||
$buf=@gurl('https://'.$opts['hostname'].'/api/v1/instance/extended_description',$opts['conntimeout'],$opts['functimeout'],['Accept: application/json'],$opts['proxy']);
|
||||
// "domain count" is only listed by /api/v1/instance (extended description is retrievable also from /api/v1/instance/extended_description)
|
||||
eecho(0,'«'.$opts['hostname'].'»: trying to fetch domain count and instance extended description from API v1...'.N);
|
||||
$buf=@gurl('https://'.$opts['hostname'].'/api/v1/instance',$opts['conntimeout'],$opts['functimeout'],['Accept: application/json'],$opts['proxy']);
|
||||
if ($buf['cont']!==false) {
|
||||
ckratelimit($buf['headers'],"«{$opts['hostname']}»");
|
||||
$buf=@json_decode($buf['cont'],true);
|
||||
if (is_array($buf)) {
|
||||
eecho(1,'«'.$opts['hostname'].'»: got instance extended description from API v1 :-)'.N);
|
||||
eecho(1,'«'.$opts['hostname'].'»: got instance info from API v1 :-)'.N);
|
||||
//print_r($buf);
|
||||
if (isset($buf['content']) && is_string($buf['content']) && !isempty($buf['content']))
|
||||
$idata['LongDesc']=trim($buf['content']);
|
||||
if (isset($buf['description']) && is_string($buf['description']) && !isempty($buf['description']))
|
||||
$idata['LongDesc']=trim($buf['description']);
|
||||
if (isset($buf['stats']['domain_count']) && is_int($buf['stats']['domain_count']))
|
||||
$idata['DomainCount']=$buf['stats']['domain_count'];
|
||||
} else {
|
||||
eecho(2,'«'.$opts['hostname'].'»: instance extended description fetched from API v1 was not good JSON.'.N);
|
||||
eecho(2,'«'.$opts['hostname'].'»: instance info fetched from API v1 was not good JSON.'.N);
|
||||
}
|
||||
} else {
|
||||
eecho(2,'«'.$opts['hostname'].'»: could not fetch instance extended description from API v1: '.$buf['emsg'].'.'.N);
|
||||
eecho(2,'«'.$opts['hostname'].'»: could not fetch instance info from API v1: '.$buf['emsg'].'.'.N);
|
||||
}
|
||||
eecho(0,'«'.$opts['hostname'].'»: trying to fetch instance domain blocks from API v1...'.N);
|
||||
$buf=@gurl('https://'.$opts['hostname'].'/api/v1/instance/domain_blocks',$opts['conntimeout'],$opts['functimeout'],['Accept: application/json'],$opts['proxy']);
|
||||
|
@ -485,7 +487,7 @@ if ($idata['IsMastodon'] && !is_null($idata['Version']) && $idata['Version']>='4
|
|||
$buf=@json_decode($buf['cont'],true);
|
||||
if (is_array($buf)) {
|
||||
if (make(['uri', 'title', 'short_description', 'description', 'email', 'version', 'urls', 'stats', 'thumbnail', 'languages', 'registrations', 'approval_required', 'contact_account'],$buf)) {
|
||||
eecho(1,'«'.$opts['hostname'].'»: got good instance info from API v1 :-)'.N);
|
||||
eecho(1,'«'.$opts['hostname'].'»: got instance info from API v1 :-)'.N);
|
||||
//print_r($buf);
|
||||
$instanswered=true;
|
||||
if (isset($buf['title']) && is_string($buf['title']) && !isempty($buf['title']))
|
||||
|
|
Loading…
Reference in a new issue