mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-10 00:34:50 +00:00
commit
c7468f6a38
5 changed files with 25 additions and 8 deletions
|
@ -81,6 +81,8 @@
|
|||
- Updated presenter components, remove video poster attribute. ([4d612dfa](https://github.com/pixelfed/pixelfed/commit/4d612dfa))
|
||||
- Improved reblog api performance ([3ef6c9fe](https://github.com/pixelfed/pixelfed/commit/3ef6c9fe))
|
||||
- Updated ApiV1Controller, fix unlisted replies. ([c13bca76](https://github.com/pixelfed/pixelfed/commit/c13bca76))
|
||||
- Updated SearchApiV2Service, filter banned instances. ([281443d7](https://github.com/pixelfed/pixelfed/commit/281443d7))
|
||||
- Updated DiscoverController, fix favourited state on memories. ([b91747b4](https://github.com/pixelfed/pixelfed/commit/b91747b4))
|
||||
- ([](https://github.com/pixelfed/pixelfed/commit/))
|
||||
|
||||
## [v0.11.2 (2022-01-09)](https://github.com/pixelfed/pixelfed/compare/v0.11.1...v0.11.2)
|
||||
|
|
|
@ -7,6 +7,7 @@ use App\{Instance, Profile};
|
|||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Validation\Rule;
|
||||
use App\Services\InstanceService;
|
||||
|
||||
trait AdminInstanceController
|
||||
{
|
||||
|
@ -126,9 +127,9 @@ trait AdminInstanceController
|
|||
break;
|
||||
}
|
||||
|
||||
Cache::forget('instances:banned:domains');
|
||||
Cache::forget('instances:unlisted:domains');
|
||||
Cache::forget('instances:auto_cw:domains');
|
||||
Cache::forget(InstanceService::CACHE_KEY_BANNED_DOMAINS);
|
||||
Cache::forget(InstanceService::CACHE_KEY_UNLISTED_DOMAINS);
|
||||
Cache::forget(InstanceService::CACHE_KEY_NSFW_DOMAINS);
|
||||
|
||||
return response()->json([]);
|
||||
}
|
||||
|
|
|
@ -214,7 +214,9 @@ class DiscoverController extends Controller
|
|||
->limit(20)
|
||||
->pluck('status_id')
|
||||
->map(function($id) {
|
||||
return StatusService::get($id, false);
|
||||
$status = StatusService::get($id, false);
|
||||
$status['favourited'] = true;
|
||||
return $status;
|
||||
})
|
||||
->filter(function($post) {
|
||||
return $post && isset($post['account']);
|
||||
|
|
|
@ -7,6 +7,10 @@ use App\Instance;
|
|||
|
||||
class InstanceService
|
||||
{
|
||||
const CACHE_KEY_BANNED_DOMAINS = 'instances:banned:domains';
|
||||
const CACHE_KEY_UNLISTED_DOMAINS = 'instances:unlisted:domains';
|
||||
const CACHE_KEY_NSFW_DOMAINS = 'instances:auto_cw:domains';
|
||||
|
||||
public static function getByDomain($domain)
|
||||
{
|
||||
return Cache::remember('pf:services:instance:by_domain:'.$domain, 3600, function() use($domain) {
|
||||
|
@ -16,21 +20,21 @@ class InstanceService
|
|||
|
||||
public static function getBannedDomains()
|
||||
{
|
||||
return Cache::remember('instances:banned:domains', now()->addHours(12), function() {
|
||||
return Cache::remember(self::CACHE_KEY_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 Cache::remember(self::CACHE_KEY_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 Cache::remember(self::CACHE_KEY_NSFW_DOMAINS, now()->addHours(12), function() {
|
||||
return Instance::whereAutoCw(true)->pluck('domain')->toArray();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -85,6 +85,7 @@ class SearchApiV2Service
|
|||
$limit = $this->query->input('limit') ?? 20;
|
||||
$offset = $this->query->input('offset') ?? 0;
|
||||
$query = '%' . $this->query->input('q') . '%';
|
||||
$banned = InstanceService::getBannedDomains();
|
||||
$results = Profile::select('profiles.*', 'followers.profile_id', 'followers.created_at')
|
||||
->whereNull('status')
|
||||
->leftJoin('followers', function($join) use($user) {
|
||||
|
@ -97,9 +98,16 @@ class SearchApiV2Service
|
|||
->offset($offset)
|
||||
->limit($limit)
|
||||
->get()
|
||||
->filter(function($profile) use ($banned) {
|
||||
return in_array($profile->domain, $banned) == false;
|
||||
})
|
||||
->map(function($res) {
|
||||
return AccountService::get($res['id']);
|
||||
});
|
||||
})
|
||||
->filter(function($account) {
|
||||
return $account && isset($account['id']);
|
||||
})
|
||||
->values();
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue