Fixed some flaws and a bug

This commit is contained in:
pezcurrel 2024-08-23 22:03:21 +02:00
parent f9a31449fb
commit 17fc617a80

View file

@ -428,7 +428,7 @@ if ($idata['IsMastodon'] && !is_null($idata['Version']) && $idata['Version']>='4
if (is_array($buf)) {
eecho(1,'«'.$opts['hostname'].'»: got instance extended description from API v1 :-)'.N);
//print_r($buf);
if (!is_null($buf['content']) && is_string($buf['content']) && !isempty($buf['content']))
if (isset($buf['content']) && is_string($buf['content']) && !isempty($buf['content']))
$idata['LongDesc']=trim($buf['content']);
} else {
eecho(2,'«'.$opts['hostname'].'»: instance extended description fetched from API v1 was not good JSON.'.N);
@ -447,7 +447,7 @@ if ($idata['IsMastodon'] && !is_null($idata['Version']) && $idata['Version']>='4
$idata['PublicBlocksList']=1;
$idata['Threads']='accessible';
foreach ($buf as $key=>$block) {
if (make(['domain', 'severity', 'comment'],$block) && is_string($block['domain']) && !isempty($block['domain']) && is_string($block['severity']) && in_array($block['severity'], ['silence','suspend']) && (is_null($block['comment']) || is_string($block['comment']))) {
if (is_array($block) && make(['domain', 'severity', 'comment'],$block) && is_string($block['domain']) && !isempty($block['domain']) && is_string($block['severity']) && in_array($block['severity'], ['silence','suspend']) && (is_null($block['comment']) || is_string($block['comment']))) {
if (is_string($block['comment'])) {
$block['comment']=trim($block['comment']);
if ($block['comment']=='')
@ -465,7 +465,8 @@ if ($idata['IsMastodon'] && !is_null($idata['Version']) && $idata['Version']>='4
$idata['Threads']=$block['severity'];
}
} else {
eecho(2,'«'.$opts['hostname'].'»: domain block '.$key.' has unexpected format.'.N);
eecho(2,'«'.$opts['hostname'].'»: domain blocks array has an unexpected format.'.N);
break;
}
}
} else {
@ -534,7 +535,8 @@ if ($idata['IsMastodon'] && !is_null($idata['Version']) && $idata['Version']>='4
}
if (isset($buf['contact_account']['header']) && is_string($buf['contact_account']['header']) && !isempty($buf['contact_account']['header']))
$idata['AdmHeader']=trim($buf['contact_account']['header']);
if (isset($buf['languages']) && is_array($buf['languages']))
// next line: isset and is_string because it can be pleroma, that has a different format for "languages"
if (isset($buf['languages']) && is_array($buf['languages']) && isset($buf['languages'][0]) && is_string($buf['languages'][0]))
$idata['languages']=$buf['languages'];
if (isset($buf['rules']) && is_array($buf['rules']))
foreach ($buf['rules'] as $rule)
@ -816,9 +818,9 @@ if ($opts['_sendtoot'] && $instanswered && $idata['IsMastodon'] && $idata['First
(is_null($idata['Title'])) ? $toot.='unspecified' : $toot.=$idata['Title'];
$toot.=N.N.'Languages: ';
if (array_key_exists('languages',$idata) && is_array($idata['languages']) && count($idata['languages'])>0 && $idata['languages'][0]!='en')
$toot.=implode($idata['languages']);
$toot.=implode(', ',$idata['languages']);
elseif (array_key_exists('ourlanguages',$idata) && is_array($idata['ourlanguages']) && count($idata['ourlanguages'])>0)
$toot.=implode($idata['ourlanguages']);
$toot.=implode(', ',$idata['ourlanguages']);
else
$toot.='unspecified/undetectable';
$toot.=N.N.'Users: ';