Added writing server rules in the db
This commit is contained in:
parent
337eb32f51
commit
5312aea0cc
1 changed files with 12 additions and 4 deletions
|
@ -359,8 +359,8 @@ if ($idata['IsMastodon'] && $idata['Version']>='4.0.0') {
|
|||
$idata['languages']=$buf['languages'];
|
||||
if (isset($buf['rules']) && is_array($buf['rules']))
|
||||
foreach ($buf['rules'] as $rule)
|
||||
if (isset($rule['text']) && is_string($rule['text']) && !isempty($rule['text']))
|
||||
$idata['rules'][]=$rule['text'];
|
||||
if (isset($rule['id']) && is_string($rule['id']) && !isempty($rule['id']) && isset($rule['text']) && is_string($rule['text']) && !isempty($rule['text']))
|
||||
$idata['rules'][$rule['id']]=$rule['text'];
|
||||
} else {
|
||||
eecho(2,'«'.$opts['hostname'].'»: instance info fetched from API v2 were not good JSON.'.N);
|
||||
}
|
||||
|
@ -440,8 +440,8 @@ if ($idata['IsMastodon'] && $idata['Version']>='4.0.0') {
|
|||
$idata['languages']=$buf['languages'];
|
||||
if (isset($buf['rules']) && is_array($buf['rules']))
|
||||
foreach ($buf['rules'] as $rule)
|
||||
if (isset($rule['text']) && is_string($rule['text']) && !isempty($rule['text']))
|
||||
$idata['rules'][]=$rule['text'];
|
||||
if (isset($rule['id']) && is_string($rule['id']) && !isempty($rule['id']) && isset($rule['text']) && is_string($rule['text']) && !isempty($rule['text']))
|
||||
$idata['rules'][$rule['id']]=$rule['text'];
|
||||
// some falsing
|
||||
if (isset($buf['pleroma'])) $idata['IsMastodon']=false;
|
||||
if (isset($buf['version']) && is_string($buf['version']) && preg_match('#(pleroma|pixelfed)#i',$buf['version'])===1) $idata['IsMastodon']=false;
|
||||
|
@ -694,6 +694,14 @@ if (isset($idata['trends']) && is_array($idata['trends'])) {
|
|||
}
|
||||
}
|
||||
|
||||
if (isset($idata['rules']) && is_array($idata['rules'])) {
|
||||
if (!$opts['dryrun']) myq($link,'DELETE FROM InstRules WHERE InstID='.$instid,__LINE__);
|
||||
ksort($idata['rules']);
|
||||
foreach ($idata['rules'] as $rule)
|
||||
if (!$opts['dryrun'])
|
||||
myq($link,'INSERT INTO InstRules SET InstID='.$instid.', Text=\''.myesc($link, truncs($rule, 'InstRules', 'Text', '«'.$opts['hostname'].'»')).'\'',__LINE__);
|
||||
}
|
||||
|
||||
if ($opts['fetchusers'] && $idata['IsMastodon'] && !is_null($idata['Version']) && $idata['Version']>='4.0.0') {
|
||||
eecho(0,'«'.$opts['hostname'].'»: trying to fetch users info from directory API...'.N);
|
||||
$users=[];// array of users in this instance's directory
|
||||
|
|
Loading…
Reference in a new issue