Added “PublicBlocksList” column management; minor changes
This commit is contained in:
parent
c93d6cb820
commit
ba0397cb35
1 changed files with 12 additions and 5 deletions
|
@ -225,7 +225,7 @@ $mastodons=implode('|',$mastodons);
|
|||
$tables=tables($link);
|
||||
//print_r($tables);
|
||||
|
||||
$instints=['ID', 'FirstSeen', 'IsMastodon', 'Priority', 'Visible', 'Noxious', 'NoxLastModTS', 'LocalityID', 'OurLangsLock', 'UserCount', 'StatusCount', 'DomainCount', 'ActiveUsersMonth', 'ActiveUsersHalfYear', 'RegOpen', 'RegReqApproval', 'MaxTootChars', 'AdmCreatedAt', 'WasLastCheckOk', 'LastOkCheckTS', 'GuestID', 'LastGuestEdit', 'InsertTS', 'RPos'];
|
||||
$instints=['ID', 'FirstSeen', 'IsMastodon', 'Priority', 'Visible', 'Noxious', 'NoxLastModTS', 'LocalityID', 'OurLangsLock', 'UserCount', 'StatusCount', 'DomainCount', 'ActiveUsersMonth', 'ActiveUsersHalfYear', 'RegOpen', 'RegReqApproval', 'MaxTootChars', 'AdmCreatedAt', 'PublicBlocksList', 'TotChecks', 'OkChecks', 'WasLastCheckOk', 'LastOkCheckTS', 'GuestID', 'LastGuestEdit', 'InsertTS', 'RPos'];
|
||||
|
||||
$idata=[];
|
||||
$res=myq($link,'SHOW COLUMNS FROM Instances',__FILE__);
|
||||
|
@ -420,10 +420,17 @@ if ($idata['IsMastodon'] && !is_null($idata['Version']) && $idata['Version']>='4
|
|||
if (is_array($buf)) {
|
||||
eecho(1,'«'.$opts['hostname'].'»: got instance domain blocks from API v1 :-)'.N);
|
||||
$idata['blocks']=[];
|
||||
$idata['PublicBlocksList']=1;
|
||||
$idata['Threads']='accessible';
|
||||
foreach ($buf as $key=>$block) {
|
||||
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;
|
||||
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_string($block['comment'])) {
|
||||
$block['comment']=trim($block['comment']);
|
||||
if ($block['comment']=='')
|
||||
$block['comment']=null;
|
||||
} else {
|
||||
$block['comment']=null;
|
||||
}
|
||||
$idata['blocks'][]=['dom'=>$block['domain'], 'sev'=>$block['severity'], 'comm'=>$block['comment']];
|
||||
if (preg_match('#^(threads.net|.*\.threads.net)$#i',$block['domain'])===1) {
|
||||
if ($block['severity']=='suspend')
|
||||
|
@ -621,6 +628,7 @@ if (is_null($oidata)) {
|
|||
$idata['AdmURL']=$oidata['AdmURL'];
|
||||
$idata['AdmAvatar']='unavailable';
|
||||
$idata['AdmHeader']=$oidata['AdmHeader'];
|
||||
$idata['PublicBlocksList']=$oidata['PublicBlocksList'];
|
||||
$idata['Threads']=$oidata['Threads'];
|
||||
}
|
||||
}
|
||||
|
@ -777,9 +785,8 @@ if (isset($idata['rules']) && is_array($idata['rules'])) {
|
|||
}
|
||||
}
|
||||
|
||||
if ($instanswered && !$opts['dryrun'])
|
||||
if ($instanswered && !$opts['dryrun'] && isset($idata['blocks'])) {
|
||||
myq($link,'DELETE FROM InstBlocks WHERE InstID='.$instid,__LINE__);
|
||||
if (isset($idata['blocks']) && is_array($idata['blocks'])) {
|
||||
foreach ($idata['blocks'] as $block) {
|
||||
(is_null($block['comm'])) ? $block['comm']='NULL' : $block['comm']="'".myesc($link, truncs($block['comm'], 'InstBlocks', 'Comment', '«'.$opts['hostname'].'»'))."'";
|
||||
if (!$opts['dryrun'])
|
||||
|
|
Loading…
Reference in a new issue