瀏覽代碼

Hide nsfw posts from public/network timelines by default

Daniel Supernault 2 年之前
父節點
當前提交
3ebae614ce

+ 5 - 1
app/Http/Controllers/PublicApiController.php

@@ -322,6 +322,7 @@ class PublicApiController extends Controller
                           ->whereNull(['in_reply_to_id', 'reblog_of_id'])
                           ->whereIn('type', ['photo', 'photo:album', 'video', 'video:album', 'photo:video:album'])
                           ->whereLocal(true)
+                          ->where('is_nsfw', false)
                           ->whereScope('public')
                           ->orderBy('id', 'desc')
                           ->limit($limit)
@@ -365,6 +366,7 @@ class PublicApiController extends Controller
                           ->whereNull(['in_reply_to_id', 'reblog_of_id'])
                           ->whereIn('type', ['photo', 'photo:album', 'video', 'video:album', 'photo:video:album'])
                           ->whereLocal(true)
+                          ->where('is_nsfw', false)
                           ->whereScope('public')
                           ->orderBy('id', 'desc')
                           ->limit($limit)
@@ -620,7 +622,8 @@ class PublicApiController extends Controller
 	                        'scope',
 	                        'created_at',
 	                      )
-	                      ->where('id', $dir, $id)
+                          ->where('id', $dir, $id)
+                          ->where('is_nsfw', false)
 	                      ->whereNull(['in_reply_to_id', 'reblog_of_id'])
 	                      ->whereNotIn('profile_id', $filtered)
 	                      ->whereIn('type', ['photo', 'photo:album', 'video', 'video:album', 'photo:video:album'])
@@ -648,6 +651,7 @@ class PublicApiController extends Controller
 	                          )
 	                      	  ->whereNull(['in_reply_to_id', 'reblog_of_id'])
 	                          ->whereNotIn('profile_id', $filtered)
+                              ->where('is_nsfw', false)
 	                          ->whereIn('type', ['photo', 'photo:album', 'video', 'video:album', 'photo:video:album'])
 	                          ->whereNotNull('uri')
 	                          ->whereScope('public')

+ 2 - 1
app/Jobs/StatusPipeline/StatusEntityLexer.php

@@ -171,7 +171,8 @@ class StatusEntityLexer implements ShouldQueue
 			$status->scope == 'public' &&
 			in_array($status->type, $types) &&
 			$status->in_reply_to_id === null &&
-			$status->reblog_of_id === null
+			$status->reblog_of_id === null &&
+			$status->is_nsfw == false
 		) {
 			PublicTimelineService::add($status->id);
 		}

+ 1 - 0
app/Services/NetworkTimelineService.php

@@ -78,6 +78,7 @@ class NetworkTimelineService
 			Redis::del(self::CACHE_KEY);
 			$ids = Status::whereNotNull('uri')
 				->whereScope('public')
+				->where('is_nsfw', false)
 				->whereNull('in_reply_to_id')
 				->whereNull('reblog_of_id')
 				->whereIn('type', ['photo', 'photo:album', 'video', 'video:album', 'photo:video:album'])

+ 1 - 0
app/Services/PublicTimelineService.php

@@ -78,6 +78,7 @@ class PublicTimelineService {
 			Redis::del(self::CACHE_KEY);
 			$ids = Status::whereNull('uri')
 				->whereNull('in_reply_to_id')
+				->where('is_nsfw', false)
 				->whereNull('reblog_of_id')
 				->whereIn('type', ['photo', 'photo:album', 'video', 'video:album', 'photo:video:album'])
 				->whereScope('public')