Now Threads blocking status gets set for each instance into “Threads” column in “Instances” table

This commit is contained in:
pezcurrel 2023-12-26 23:11:01 +01:00
parent 142f991948
commit 3ae455a459

View file

@ -371,7 +371,6 @@ if ($idata['IsMastodon'] && $idata['Version']>='4.0.0') {
eecho(2,'«'.$opts['hostname'].'»: could not fetch instance extended description from API v1: '.$buf['emsg'].'.'.N);
}
eecho(0,'«'.$opts['hostname'].'»: trying to fetch instance domain blocks from API v1...'.N);
$idata['BlockListAvailable']=0;
$buf=@gurl('https://'.$opts['hostname'].'/api/v1/instance/domain_blocks',$opts['timeout']);
if ($buf['cont']!==false) {
ckratelimit($buf['headers']);
@ -383,7 +382,14 @@ if ($idata['IsMastodon'] && $idata['Version']>='4.0.0') {
if (make(['domain', 'digest', 'severity', 'comment'],$block) && is_string($block['domain']) && !isempty($block['domain']) && is_string($block['digest']) && preg_match('/^[a-f0-9]{64}$/',$block['digest'])===1 && is_string($block['severity']) && in_array($block['severity'], ['silence','suspend']) && (is_null($block['comment']) || is_string($block['comment']))) {
if (!is_null($block['comment']) && trim($block['comment'])=='') $block['comment']=null;
$idata['blocks'][]=['dom'=>$block['domain'], 'sev'=>$block['severity'], 'comm'=>$block['comment']];
$idata['BlockListAvailable']=1;
if (preg_match('#^(threads.net|.*\.threads.net)$#i',$block['domain'])===1) {
if ($block['severity']=='suspend')
$idata['Threads']='suspended';
elseif ($rrow['Severity']=='silence')
$idata['Threads']='limited';
else
$idata['Threads']=$block['severity'];
}
} else {
eecho(2,'«'.$opts['hostname'].'»: domain block '.$key.' has unexpected format.'.N);
}
@ -570,7 +576,7 @@ if (is_null($oidata)) {
$idata['AdmURL']=$oidata['AdmURL'];
$idata['AdmAvatar']='unavailable';
$idata['AdmHeader']=$oidata['AdmHeader'];
$idata['BlockListAvailable']=$oidata['BlockListAvailable'];
$idata['Threads']=$oidata['Threads'];
}
}