Update AP Helpers, use instance filtering

This commit is contained in:
Daniel Supernault 2021-04-20 23:18:07 -06:00
parent c20a9dfefe
commit 66b4f8c773
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7
2 changed files with 13 additions and 3 deletions

View file

@ -127,6 +127,8 @@ trait AdminInstanceController
}
Cache::forget('instances:banned:domains');
Cache::forget('instances:unlisted:domains');
Cache::forget('instances:auto_cw:domains');
return response()->json([]);
}

View file

@ -26,6 +26,7 @@ use App\Util\ActivityPub\HttpSignature;
use Illuminate\Support\Str;
use App\Services\ActivityPubFetchService;
use App\Services\ActivityPubDeliveryService;
use App\Services\InstanceService;
use App\Services\MediaPathService;
use App\Services\MediaStorageService;
use App\Jobs\MediaPipeline\MediaStoragePipeline;
@ -175,9 +176,7 @@ class Helpers {
}
}
$bannedInstances = Cache::remember('instances:banned:domains', now()->addHours(12), function() {
return Instance::whereBanned(true)->pluck('domain')->toArray();
});
$bannedInstances = InstanceService::getBannedDomains();
if(in_array($host, $bannedInstances)) {
return false;
@ -328,6 +327,7 @@ class Helpers {
$idDomain = parse_url($id, PHP_URL_HOST);
$urlDomain = parse_url($url, PHP_URL_HOST);
if(!self::validateUrl($id)) {
return;
}
@ -356,6 +356,14 @@ class Helpers {
}
$ts = is_array($res['published']) ? $res['published'][0] : $res['published'];
if($scope == 'public' && in_array($urlDomain, InstanceService::getUnlistedDomains())) {
$scope = 'unlisted';
}
if(in_array($urlDomain, InstanceService::getNsfwDomains())) {
$cw = true;
}
$statusLockKey = 'helpers:status-lock:' . hash('sha256', $res['id']);
$status = Cache::lock($statusLockKey)
->get(function () use(