diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d2e02309..eca20cc63 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -61,6 +61,8 @@ - Update HashtagService, reduce cached_count cache ttl ([15f29f7d](https://github.com/pixelfed/pixelfed/commit/15f29f7d)) - Update ApiV1Controller, fix include_reblogs param on timelines/home endpoint, and improve limit pagination logic ([287f903b](https://github.com/pixelfed/pixelfed/commit/287f903b)) - Update StoryApiV1Controller, add self-carousel endpoint. Fixes ([#4352](https://github.com/pixelfed/pixelfed/issues/4352)) ([bcb88d5b](https://github.com/pixelfed/pixelfed/commit/bcb88d5b)) +- Update FollowServiceWarmCache, use more efficient query ([fe9b4c5a](https://github.com/pixelfed/pixelfed/commit/fe9b4c5a)) +- Update HomeFeedPipeline, observe mutes/blocks during fanout ([8548294c](https://github.com/pixelfed/pixelfed/commit/8548294c)) - ([](https://github.com/pixelfed/pixelfed/commit/)) ## [v0.11.9 (2023-08-21)](https://github.com/pixelfed/pixelfed/compare/v0.11.8...v0.11.9) diff --git a/app/Jobs/FollowPipeline/FollowServiceWarmCache.php b/app/Jobs/FollowPipeline/FollowServiceWarmCache.php index 990236f69..0d3cca7ac 100644 --- a/app/Jobs/FollowPipeline/FollowServiceWarmCache.php +++ b/app/Jobs/FollowPipeline/FollowServiceWarmCache.php @@ -73,7 +73,7 @@ class FollowServiceWarmCache implements ShouldQueue if(Follower::whereProfileId($id)->orWhere('following_id', $id)->count()) { $following = []; $followers = []; - foreach(Follower::lazy() as $follow) { + foreach(Follower::where('following_id', $id)->orWhere('profile_id', $id)->lazyById(500) as $follow) { if($follow->following_id != $id && $follow->profile_id != $id) { continue; } diff --git a/app/Jobs/HomeFeedPipeline/FeedFollowPipeline.php b/app/Jobs/HomeFeedPipeline/FeedFollowPipeline.php index 64d646354..e386329ca 100644 --- a/app/Jobs/HomeFeedPipeline/FeedFollowPipeline.php +++ b/app/Jobs/HomeFeedPipeline/FeedFollowPipeline.php @@ -69,7 +69,7 @@ class FeedFollowPipeline implements ShouldQueue, ShouldBeUniqueUntilProcessing $actorId = $this->actorId; $followingId = $this->followingId; - $minId = SnowflakeService::byDate(now()->subMonths(6)); + $minId = SnowflakeService::byDate(now()->subWeeks(6)); $ids = Status::where('id', '>', $minId) ->where('profile_id', $followingId) diff --git a/app/Jobs/HomeFeedPipeline/FeedInsertPipeline.php b/app/Jobs/HomeFeedPipeline/FeedInsertPipeline.php index bf9c849a5..2456d2aa7 100644 --- a/app/Jobs/HomeFeedPipeline/FeedInsertPipeline.php +++ b/app/Jobs/HomeFeedPipeline/FeedInsertPipeline.php @@ -10,8 +10,10 @@ use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\SerializesModels; use Illuminate\Queue\Middleware\WithoutOverlapping; use Illuminate\Contracts\Queue\ShouldBeUniqueUntilProcessing; +use App\UserFilter; use App\Services\FollowerService; use App\Services\HomeTimelineService; +use App\Services\StatusService; class FeedInsertPipeline implements ShouldQueue, ShouldBeUniqueUntilProcessing { @@ -64,11 +66,32 @@ class FeedInsertPipeline implements ShouldQueue, ShouldBeUniqueUntilProcessing */ public function handle(): void { - $ids = FollowerService::localFollowerIds($this->pid); + $sid = $this->sid; + $status = StatusService::get($sid, false); + + if(!$status) { + return; + } + + if(!in_array($status['pf_type'], ['photo', 'photo:album', 'video', 'video:album', 'photo:video:album'])) { + return; + } HomeTimelineService::add($this->pid, $this->sid); + + + $ids = FollowerService::localFollowerIds($this->pid); + + if(!$ids || !count($ids)) { + return; + } + + $skipIds = UserFilter::whereFilterableType('App\Profile')->whereFilterableId($status['account']['id'])->whereIn('filter_type', ['mute', 'block'])->pluck('user_id')->toArray(); + foreach($ids as $id) { - HomeTimelineService::add($id, $this->sid); + if(!in_array($id, $skipIds)) { + HomeTimelineService::add($id, $this->sid); + } } } } diff --git a/app/Jobs/HomeFeedPipeline/FeedInsertRemotePipeline.php b/app/Jobs/HomeFeedPipeline/FeedInsertRemotePipeline.php index 579c290a7..738c09699 100644 --- a/app/Jobs/HomeFeedPipeline/FeedInsertRemotePipeline.php +++ b/app/Jobs/HomeFeedPipeline/FeedInsertRemotePipeline.php @@ -10,8 +10,10 @@ use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\SerializesModels; use Illuminate\Queue\Middleware\WithoutOverlapping; use Illuminate\Contracts\Queue\ShouldBeUniqueUntilProcessing; +use App\UserFilter; use App\Services\FollowerService; use App\Services\HomeTimelineService; +use App\Services\StatusService; class FeedInsertRemotePipeline implements ShouldQueue, ShouldBeUniqueUntilProcessing { @@ -64,10 +66,29 @@ class FeedInsertRemotePipeline implements ShouldQueue, ShouldBeUniqueUntilProces */ public function handle(): void { + $sid = $this->sid; + $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 = FollowerService::localFollowerIds($this->pid); + if(!$ids || !count($ids)) { + return; + } + + $skipIds = UserFilter::whereFilterableType('App\Profile')->whereFilterableId($status['account']['id'])->whereIn('filter_type', ['mute', 'block'])->pluck('user_id')->toArray(); + foreach($ids as $id) { - HomeTimelineService::add($id, $this->sid); + if(!in_array($id, $skipIds)) { + HomeTimelineService::add($id, $this->sid); + } } } } diff --git a/app/Jobs/HomeFeedPipeline/HashtagInsertFanoutPipeline.php b/app/Jobs/HomeFeedPipeline/HashtagInsertFanoutPipeline.php index 581b8784f..2e6bf4758 100644 --- a/app/Jobs/HomeFeedPipeline/HashtagInsertFanoutPipeline.php +++ b/app/Jobs/HomeFeedPipeline/HashtagInsertFanoutPipeline.php @@ -10,6 +10,7 @@ use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\SerializesModels; use App\Hashtag; use App\StatusHashtag; +use App\UserFilter; use App\Services\HashtagFollowService; use App\Services\HomeTimelineService; use App\Services\StatusService; @@ -84,6 +85,8 @@ class HashtagInsertFanoutPipeline implements ShouldQueue, ShouldBeUniqueUntilPro return; } + $skipIds = UserFilter::whereFilterableType('App\Profile')->whereFilterableId($status['account']['id'])->whereIn('filter_type', ['mute', 'block'])->pluck('user_id')->toArray(); + $ids = HashtagFollowService::getPidByHid($hashtag->hashtag_id); if(!$ids || !count($ids)) { @@ -91,7 +94,9 @@ class HashtagInsertFanoutPipeline implements ShouldQueue, ShouldBeUniqueUntilPro } foreach($ids as $id) { - HomeTimelineService::add($id, $hashtag->status_id); + if(!in_array($id, $skipIds)) { + HomeTimelineService::add($id, $hashtag->status_id); + } } } } diff --git a/database/migrations/2023_11_26_082439_add_state_and_score_to_places_table.php b/database/migrations/2023_11_26_082439_add_state_and_score_to_places_table.php new file mode 100644 index 000000000..d7f95aa3f --- /dev/null +++ b/database/migrations/2023_11_26_082439_add_state_and_score_to_places_table.php @@ -0,0 +1,34 @@ +string('state')->nullable()->index()->after('name'); + $table->tinyInteger('score')->default(0)->index()->after('long'); + $table->unsignedBigInteger('cached_post_count')->nullable(); + $table->timestamp('last_checked_at')->nullable()->index(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('places', function (Blueprint $table) { + $table->dropColumn('state'); + $table->dropColumn('score'); + $table->dropColumn('cached_post_count'); + $table->dropColumn('last_checked_at'); + }); + } +};