diff --git a/api/v1/database/mastodon/accounts/search/mod.php b/api/v1/database/mastodon/accounts/search/mod.php index 495168a..80f9824 100644 --- a/api/v1/database/mastodon/accounts/search/mod.php +++ b/api/v1/database/mastodon/accounts/search/mod.php @@ -59,20 +59,36 @@ $sql_all = ' '; $instances = null; +$ninstances = null; if (isset($_GET['instances'])) { $instances = []; + $ninstances = []; foreach (explode(',',$_GET['instances']) as $instance) { $instance = trim($instance); - if (valid_domain_name($instance)) - $instances []= "'".$instance."'"; + $not_bool = $instance[0] === '!'; + if ($not_bool) + $instance = substr($instance, 1); + if (valid_domain_name($instance)) { + if ($not_bool) + $ninstances []= "'".$instance."'"; + else $instances []= "'".$instance."'"; + } } if (count($instances) > 0) $instances = implode(',', $instances); else $instances = null; + if (count($ninstances) > 0) + $ninstances = implode(',', $ninstances); + else $ninstances = null; } +$_ = ''; if ($instances !== null) - $sql_all = str_replace('{instanceFilter}', "a.domain IN ($instances) AND", $sql_all); -else $sql_all = str_replace('{instanceFilter}', '', $sql_all); + $_ .= "a.domain IN ($instances) AND "; +if ($ninstances !== null) + $_ .= "NOT a.domain IN ($ninstances) AND "; +$_ = trim($_); +$sql_all = str_replace('{instanceFilter}', $_, $sql_all); +unset($_); $user_filter = 'local'; if (isset($_GET['user_filter'])) {