Revert nsfw posts hidden on local/network timelines by default

This commit is contained in:
Daniel Supernault 2022-11-28 05:13:12 -07:00
parent 0ce484c56f
commit 5cac7fb44f
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7
5 changed files with 26 additions and 8 deletions

View file

@ -307,6 +307,7 @@ class PublicApiController extends Controller
$user = $request->user();
$filtered = $user ? UserFilterService::filters($user->profile_id) : [];
$hideNsfw = config('instance.hide_nsfw_on_public_feeds');
if(config('exp.cached_public_timeline') == false) {
if($min || $max) {
$dir = $min ? '>' : '<';
@ -322,7 +323,9 @@ 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)
->when($hideNsfw, function($q, $hideNsfw) {
return $q->where('is_nsfw', false);
})
->whereScope('public')
->orderBy('id', 'desc')
->limit($limit)
@ -366,7 +369,9 @@ 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)
->when($hideNsfw, function($q, $hideNsfw) {
return $q->where('is_nsfw', false);
})
->whereScope('public')
->orderBy('id', 'desc')
->limit($limit)
@ -610,6 +615,7 @@ class PublicApiController extends Controller
$amin = SnowflakeService::byDate(now()->subDays(config('federation.network_timeline_days_falloff')));
$filtered = $user ? UserFilterService::filters($user->profile_id) : [];
$hideNsfw = config('instance.hide_nsfw_on_public_feeds');
if(config('instance.timeline.network.cached') == false) {
if($min || $max) {
@ -623,7 +629,9 @@ class PublicApiController extends Controller
'created_at',
)
->where('id', $dir, $id)
->where('is_nsfw', false)
->when($hideNsfw, function($q, $hideNsfw) {
return $q->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'])
@ -651,7 +659,9 @@ class PublicApiController extends Controller
)
->whereNull(['in_reply_to_id', 'reblog_of_id'])
->whereNotIn('profile_id', $filtered)
->where('is_nsfw', false)
->when($hideNsfw, function($q, $hideNsfw) {
return $q->where('is_nsfw', false);
})
->whereIn('type', ['photo', 'photo:album', 'video', 'video:album', 'photo:video:album'])
->whereNotNull('uri')
->whereScope('public')

View file

@ -166,13 +166,13 @@ class StatusEntityLexer implements ShouldQueue
if(config_cache('pixelfed.bouncer.enabled')) {
Bouncer::get($status);
}
$hideNsfw = config('instance.hide_nsfw_on_public_feeds');
if( $status->uri == null &&
$status->scope == 'public' &&
in_array($status->type, $types) &&
$status->in_reply_to_id === null &&
$status->reblog_of_id === null &&
$status->is_nsfw == false
($hideNsfw ? $status->is_nsfw == false : true)
) {
PublicTimelineService::add($status->id);
}

View file

@ -75,10 +75,13 @@ class NetworkTimelineService
public static function warmCache($force = false, $limit = 100)
{
if(self::count() == 0 || $force == true) {
$hideNsfw = config('instance.hide_nsfw_on_public_feeds');
Redis::del(self::CACHE_KEY);
$ids = Status::whereNotNull('uri')
->whereScope('public')
->where('is_nsfw', false)
->when($hideNsfw, function($q, $hideNsfw) {
return $q->where('is_nsfw', false);
})
->whereNull('in_reply_to_id')
->whereNull('reblog_of_id')
->whereIn('type', ['photo', 'photo:album', 'video', 'video:album', 'photo:video:album'])

View file

@ -75,10 +75,13 @@ class PublicTimelineService {
public static function warmCache($force = false, $limit = 100)
{
if(self::count() == 0 || $force == true) {
$hideNsfw = config('instance.hide_nsfw_on_public_feeds');
Redis::del(self::CACHE_KEY);
$ids = Status::whereNull('uri')
->whereNull('in_reply_to_id')
->where('is_nsfw', false)
->when($hideNsfw, function($q, $hideNsfw) {
return $q->where('is_nsfw', false);
})
->whereNull('reblog_of_id')
->whereIn('type', ['photo', 'photo:album', 'video', 'video:album', 'photo:video:album'])
->whereScope('public')

View file

@ -91,4 +91,6 @@ return [
'profile' => env('INSTANCE_PROFILE_EMBEDS', true),
'post' => env('INSTANCE_POST_EMBEDS', true),
],
'hide_nsfw_on_public_feeds' => env('PF_HIDE_NSFW_ON_PUBLIC_FEEDS', false),
];