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)) { if (is_array($buf)) {
eecho(1,'«'.$opts['hostname'].'»: got instance extended description from API v1 :-)'.N); eecho(1,'«'.$opts['hostname'].'»: got instance extended description from API v1 :-)'.N);
//print_r($buf); //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']); $idata['LongDesc']=trim($buf['content']);
} else { } else {
eecho(2,'«'.$opts['hostname'].'»: instance extended description fetched from API v1 was not good JSON.'.N); 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['PublicBlocksList']=1;
$idata['Threads']='accessible'; $idata['Threads']='accessible';
foreach ($buf as $key=>$block) { 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'])) { if (is_string($block['comment'])) {
$block['comment']=trim($block['comment']); $block['comment']=trim($block['comment']);
if ($block['comment']=='') if ($block['comment']=='')
@ -465,7 +465,8 @@ if ($idata['IsMastodon'] && !is_null($idata['Version']) && $idata['Version']>='4
$idata['Threads']=$block['severity']; $idata['Threads']=$block['severity'];
} }
} else { } 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 { } 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'])) if (isset($buf['contact_account']['header']) && is_string($buf['contact_account']['header']) && !isempty($buf['contact_account']['header']))
$idata['AdmHeader']=trim($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']; $idata['languages']=$buf['languages'];
if (isset($buf['rules']) && is_array($buf['rules'])) if (isset($buf['rules']) && is_array($buf['rules']))
foreach ($buf['rules'] as $rule) 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']; (is_null($idata['Title'])) ? $toot.='unspecified' : $toot.=$idata['Title'];
$toot.=N.N.'Languages: '; $toot.=N.N.'Languages: ';
if (array_key_exists('languages',$idata) && is_array($idata['languages']) && count($idata['languages'])>0 && $idata['languages'][0]!='en') 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) elseif (array_key_exists('ourlanguages',$idata) && is_array($idata['ourlanguages']) && count($idata['ourlanguages'])>0)
$toot.=implode($idata['ourlanguages']); $toot.=implode(', ',$idata['ourlanguages']);
else else
$toot.='unspecified/undetectable'; $toot.='unspecified/undetectable';
$toot.=N.N.'Users: '; $toot.=N.N.'Users: ';