Update HomeFeedPipeline, fix tag filtering

This commit is contained in:
Daniel Supernault 2023-11-16 00:47:49 -07:00
parent e5401f8558
commit f105f4e8f6
No known key found for this signature in database
GPG key ID: 23740873EE6F76A1
6 changed files with 267 additions and 242 deletions

View file

@ -1,8 +1,8 @@
root = true root = true
[*] [*]
indent_style = space
indent_size = 4 indent_size = 4
indent_style = tab
end_of_line = lf end_of_line = lf
charset = utf-8 charset = utf-8
trim_trailing_whitespace = true trim_trailing_whitespace = true

View file

@ -12,6 +12,7 @@ use App\Hashtag;
use App\StatusHashtag; use App\StatusHashtag;
use App\Services\HashtagFollowService; use App\Services\HashtagFollowService;
use App\Services\HomeTimelineService; use App\Services\HomeTimelineService;
use App\Services\StatusService;
use Illuminate\Queue\Middleware\WithoutOverlapping; use Illuminate\Queue\Middleware\WithoutOverlapping;
use Illuminate\Contracts\Queue\ShouldBeUniqueUntilProcessing; use Illuminate\Contracts\Queue\ShouldBeUniqueUntilProcessing;
@ -72,6 +73,16 @@ class HashtagInsertFanoutPipeline implements ShouldQueue, ShouldBeUniqueUntilPro
public function handle(): void public function handle(): void
{ {
$hashtag = $this->hashtag; $hashtag = $this->hashtag;
$sid = $hashtag->status_id;
$status = StatusService::get($sid, false);
if(!$status) {
return;
}
if(!in_array($status['pf_type'], ['photo', 'photo:album', 'video', 'video:album', 'photo:video:album'])) {
return;
}
$ids = HashtagFollowService::getPidByHid($hashtag->hashtag_id); $ids = HashtagFollowService::getPidByHid($hashtag->hashtag_id);

View file

@ -12,6 +12,7 @@ use App\Hashtag;
use App\StatusHashtag; use App\StatusHashtag;
use App\Services\HashtagFollowService; use App\Services\HashtagFollowService;
use App\Services\HomeTimelineService; use App\Services\HomeTimelineService;
use App\Services\StatusService;
use Illuminate\Queue\Middleware\WithoutOverlapping; use Illuminate\Queue\Middleware\WithoutOverlapping;
use Illuminate\Contracts\Queue\ShouldBeUniqueUntilProcessing; use Illuminate\Contracts\Queue\ShouldBeUniqueUntilProcessing;
@ -68,6 +69,15 @@ class HashtagRemoveFanoutPipeline implements ShouldQueue, ShouldBeUniqueUntilPro
{ {
$sid = $this->sid; $sid = $this->sid;
$hid = $this->hid; $hid = $this->hid;
$status = StatusService::get($sid, false);
if(!$status) {
return;
}
if(!in_array($status['pf_type'], ['photo', 'photo:album', 'video', 'video:album', 'photo:video:album'])) {
return;
}
$ids = HashtagFollowService::getPidByHid($hid); $ids = HashtagFollowService::getPidByHid($hid);

View file

@ -48,7 +48,7 @@ class HashtagUnfollowPipeline implements ShouldQueue
{ {
$hid = $this->hid; $hid = $this->hid;
$pid = $this->pid; $pid = $this->pid;
$slug = $this->slug; $slug = strtolower($this->slug);
$statusIds = HomeTimelineService::get($pid, 0, -1); $statusIds = HomeTimelineService::get($pid, 0, -1);
@ -59,17 +59,17 @@ class HashtagUnfollowPipeline implements ShouldQueue
foreach($statusIds as $id) { foreach($statusIds as $id) {
$status = StatusService::get($id, false); $status = StatusService::get($id, false);
if(!$status) { if(!$status || empty($status['tags'])) {
HomeTimelineService::rem($pid, $id); HomeTimelineService::rem($pid, $id);
continue; continue;
} }
$following = in_array($status['account']['id'], $followingIds); $following = in_array((int) $status['account']['id'], $followingIds);
if($following || !isset($status['tags'])) { if($following === true) {
continue; continue;
} }
$tags = collect($status['tags'])->map(function($tag) { $tags = collect($status['tags'])->map(function($tag) {
return $tag['name']; return strtolower($tag['name']);
})->filter()->values()->toArray(); })->filter()->values()->toArray();
if(in_array($slug, $tags)) { if(in_array($slug, $tags)) {

View file

@ -19,6 +19,7 @@ use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels; use Illuminate\Queue\SerializesModels;
use App\Services\StatusService;
use App\Services\UserFilterService; use App\Services\UserFilterService;
use App\Services\AdminShadowFilterService; use App\Services\AdminShadowFilterService;
use App\Jobs\HomeFeedPipeline\FeedInsertPipeline; use App\Jobs\HomeFeedPipeline\FeedInsertPipeline;
@ -158,6 +159,7 @@ class StatusEntityLexer implements ShouldQueue
public function fanout() public function fanout()
{ {
$status = $this->status; $status = $this->status;
StatusService::refresh($status->id);
if(config('exp.cached_home_timeline')) { if(config('exp.cached_home_timeline')) {
if( $status->in_reply_to_id === null && if( $status->in_reply_to_id === null &&

View file

@ -132,5 +132,7 @@ class StatusTagsPipeline implements ShouldQueue
$mention->save(); $mention->save();
MentionPipeline::dispatch($status, $mention); MentionPipeline::dispatch($status, $mention);
}); });
StatusService::refresh($status->id);
} }
} }