mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-22 06:21:27 +00:00
Update HomeFeedPipeline jobs, add domain block filtering
This commit is contained in:
parent
0455dd1996
commit
29aa87c282
3 changed files with 56 additions and 6 deletions
|
@ -11,6 +11,7 @@ use Illuminate\Queue\SerializesModels;
|
||||||
use Illuminate\Queue\Middleware\WithoutOverlapping;
|
use Illuminate\Queue\Middleware\WithoutOverlapping;
|
||||||
use Illuminate\Contracts\Queue\ShouldBeUniqueUntilProcessing;
|
use Illuminate\Contracts\Queue\ShouldBeUniqueUntilProcessing;
|
||||||
use App\UserFilter;
|
use App\UserFilter;
|
||||||
|
use App\Models\UserDomainBlock;
|
||||||
use App\Services\FollowerService;
|
use App\Services\FollowerService;
|
||||||
use App\Services\HomeTimelineService;
|
use App\Services\HomeTimelineService;
|
||||||
use App\Services\StatusService;
|
use App\Services\StatusService;
|
||||||
|
@ -69,7 +70,7 @@ class FeedInsertPipeline implements ShouldQueue, ShouldBeUniqueUntilProcessing
|
||||||
$sid = $this->sid;
|
$sid = $this->sid;
|
||||||
$status = StatusService::get($sid, false);
|
$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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,7 +86,24 @@ class FeedInsertPipeline implements ShouldQueue, ShouldBeUniqueUntilProcessing
|
||||||
return;
|
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) {
|
foreach($ids as $id) {
|
||||||
if(!in_array($id, $skipIds)) {
|
if(!in_array($id, $skipIds)) {
|
||||||
|
|
|
@ -11,6 +11,7 @@ use Illuminate\Queue\SerializesModels;
|
||||||
use Illuminate\Queue\Middleware\WithoutOverlapping;
|
use Illuminate\Queue\Middleware\WithoutOverlapping;
|
||||||
use Illuminate\Contracts\Queue\ShouldBeUniqueUntilProcessing;
|
use Illuminate\Contracts\Queue\ShouldBeUniqueUntilProcessing;
|
||||||
use App\UserFilter;
|
use App\UserFilter;
|
||||||
|
use App\Models\UserDomainBlock;
|
||||||
use App\Services\FollowerService;
|
use App\Services\FollowerService;
|
||||||
use App\Services\HomeTimelineService;
|
use App\Services\HomeTimelineService;
|
||||||
use App\Services\StatusService;
|
use App\Services\StatusService;
|
||||||
|
@ -69,7 +70,7 @@ class FeedInsertRemotePipeline implements ShouldQueue, ShouldBeUniqueUntilProces
|
||||||
$sid = $this->sid;
|
$sid = $this->sid;
|
||||||
$status = StatusService::get($sid, false);
|
$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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,7 +84,24 @@ class FeedInsertRemotePipeline implements ShouldQueue, ShouldBeUniqueUntilProces
|
||||||
return;
|
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) {
|
foreach($ids as $id) {
|
||||||
if(!in_array($id, $skipIds)) {
|
if(!in_array($id, $skipIds)) {
|
||||||
|
|
|
@ -11,6 +11,7 @@ use Illuminate\Queue\SerializesModels;
|
||||||
use App\Hashtag;
|
use App\Hashtag;
|
||||||
use App\StatusHashtag;
|
use App\StatusHashtag;
|
||||||
use App\UserFilter;
|
use App\UserFilter;
|
||||||
|
use App\Models\UserDomainBlock;
|
||||||
use App\Services\HashtagFollowService;
|
use App\Services\HashtagFollowService;
|
||||||
use App\Services\HomeTimelineService;
|
use App\Services\HomeTimelineService;
|
||||||
use App\Services\StatusService;
|
use App\Services\StatusService;
|
||||||
|
@ -77,7 +78,7 @@ class HashtagInsertFanoutPipeline implements ShouldQueue, ShouldBeUniqueUntilPro
|
||||||
$sid = $hashtag->status_id;
|
$sid = $hashtag->status_id;
|
||||||
$status = StatusService::get($sid, false);
|
$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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,7 +86,20 @@ class HashtagInsertFanoutPipeline implements ShouldQueue, ShouldBeUniqueUntilPro
|
||||||
return;
|
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);
|
$ids = HashtagFollowService::getPidByHid($hashtag->hashtag_id);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue