pixelfed/app/Services/InstanceService.php

43 lines
1019 B
PHP
Raw Normal View History

2021-04-21 05:11:43 +00:00
<?php
namespace App\Services;
use Cache;
use App\Instance;
class InstanceService
{
public static function getBannedDomains()
{
return Cache::remember('instances:banned:domains', now()->addHours(12), function() {
return Instance::whereBanned(true)->pluck('domain')->toArray();
});
}
public static function getUnlistedDomains()
{
return Cache::remember('instances:unlisted:domains', now()->addHours(12), function() {
return Instance::whereUnlisted(true)->pluck('domain')->toArray();
});
}
public static function getNsfwDomains()
{
return Cache::remember('instances:auto_cw:domains', now()->addHours(12), function() {
return Instance::whereAutoCw(true)->pluck('domain')->toArray();
});
}
2021-08-31 06:37:28 +00:00
public static function software($domain)
{
$key = 'instances:software:' . strtolower($domain);
return Cache::remember($key, 86400, function() use($domain) {
$instance = Instance::whereDomain($domain)->first();
if(!$instance) {
return;
}
return $instance->software;
});
}
2021-04-21 05:11:43 +00:00
}