Update HomeFeedPipeline jobs, add domain block filtering

This commit is contained in:
Daniel Supernault 2023-12-21 00:17:20 -07:00
parent 0455dd1996
commit 29aa87c282
No known key found for this signature in database
GPG key ID: 23740873EE6F76A1
3 changed files with 56 additions and 6 deletions

View file

@ -11,6 +11,7 @@ use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\Middleware\WithoutOverlapping;
use Illuminate\Contracts\Queue\ShouldBeUniqueUntilProcessing;
use App\UserFilter;
use App\Models\UserDomainBlock;
use App\Services\FollowerService;
use App\Services\HomeTimelineService;
use App\Services\StatusService;
@ -69,7 +70,7 @@ class FeedInsertPipeline implements ShouldQueue, ShouldBeUniqueUntilProcessing
$sid = $this->sid;
$status = StatusService::get($sid, false);
if(!$status || !isset($status['account']) || !isset($status['account']['id'])) {
if(!$status || !isset($status['account']) || !isset($status['account']['id'], $status['url'])) {
return;
}
@ -85,7 +86,24 @@ class FeedInsertPipeline implements ShouldQueue, ShouldBeUniqueUntilProcessing
return;
}
$skipIds = UserFilter::whereFilterableType('App\Profile')->whereFilterableId($status['account']['id'])->whereIn('filter_type', ['mute', 'block'])->pluck('user_id')->toArray();
$domain = strtolower(parse_url($status['url'], PHP_URL_HOST));
$skipIds = [];
if(strtolower(config('pixelfed.domain.app')) !== $domain) {
$skipIds = UserDomainBlock::where('domain', $domain)->pluck('profile_id')->toArray();
}
$filters = UserFilter::whereFilterableType('App\Profile')
->whereFilterableId($status['account']['id'])
->whereIn('filter_type', ['mute', 'block'])
->pluck('user_id')
->toArray();
if($filters && count($filters)) {
$skipIds = array_merge($skipIds, $filters);
}
$skipIds = array_unique(array_values($skipIds));
foreach($ids as $id) {
if(!in_array($id, $skipIds)) {

View file

@ -11,6 +11,7 @@ use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\Middleware\WithoutOverlapping;
use Illuminate\Contracts\Queue\ShouldBeUniqueUntilProcessing;
use App\UserFilter;
use App\Models\UserDomainBlock;
use App\Services\FollowerService;
use App\Services\HomeTimelineService;
use App\Services\StatusService;
@ -69,7 +70,7 @@ class FeedInsertRemotePipeline implements ShouldQueue, ShouldBeUniqueUntilProces
$sid = $this->sid;
$status = StatusService::get($sid, false);
if(!$status || !isset($status['account']) || !isset($status['account']['id'])) {
if(!$status || !isset($status['account']) || !isset($status['account']['id'], $status['url'])) {
return;
}
@ -83,7 +84,24 @@ class FeedInsertRemotePipeline implements ShouldQueue, ShouldBeUniqueUntilProces
return;
}
$skipIds = UserFilter::whereFilterableType('App\Profile')->whereFilterableId($status['account']['id'])->whereIn('filter_type', ['mute', 'block'])->pluck('user_id')->toArray();
$domain = strtolower(parse_url($status['url'], PHP_URL_HOST));
$skipIds = [];
if(strtolower(config('pixelfed.domain.app')) !== $domain) {
$skipIds = UserDomainBlock::where('domain', $domain)->pluck('profile_id')->toArray();
}
$filters = UserFilter::whereFilterableType('App\Profile')
->whereFilterableId($status['account']['id'])
->whereIn('filter_type', ['mute', 'block'])
->pluck('user_id')
->toArray();
if($filters && count($filters)) {
$skipIds = array_merge($skipIds, $filters);
}
$skipIds = array_unique(array_values($skipIds));
foreach($ids as $id) {
if(!in_array($id, $skipIds)) {

View file

@ -11,6 +11,7 @@ use Illuminate\Queue\SerializesModels;
use App\Hashtag;
use App\StatusHashtag;
use App\UserFilter;
use App\Models\UserDomainBlock;
use App\Services\HashtagFollowService;
use App\Services\HomeTimelineService;
use App\Services\StatusService;
@ -77,7 +78,7 @@ class HashtagInsertFanoutPipeline implements ShouldQueue, ShouldBeUniqueUntilPro
$sid = $hashtag->status_id;
$status = StatusService::get($sid, false);
if(!$status || !isset($status['account']) || !isset($status['account']['id'])) {
if(!$status || !isset($status['account']) || !isset($status['account']['id'], $status['url'])) {
return;
}
@ -85,7 +86,20 @@ class HashtagInsertFanoutPipeline implements ShouldQueue, ShouldBeUniqueUntilPro
return;
}
$skipIds = UserFilter::whereFilterableType('App\Profile')->whereFilterableId($status['account']['id'])->whereIn('filter_type', ['mute', 'block'])->pluck('user_id')->toArray();
$domain = strtolower(parse_url($status['url'], PHP_URL_HOST));
$skipIds = [];
if(strtolower(config('pixelfed.domain.app')) !== $domain) {
$skipIds = UserDomainBlock::where('domain', $domain)->pluck('profile_id')->toArray();
}
$filters = UserFilter::whereFilterableType('App\Profile')->whereFilterableId($status['account']['id'])->whereIn('filter_type', ['mute', 'block'])->pluck('user_id')->toArray();
if($filters && count($filters)) {
$skipIds = array_merge($skipIds, $filters);
}
$skipIds = array_unique(array_values($skipIds));
$ids = HashtagFollowService::getPidByHid($hashtag->hashtag_id);