mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-09 16:24:51 +00:00
Revert nsfw posts hidden on local/network timelines by default
This commit is contained in:
parent
0ce484c56f
commit
5cac7fb44f
5 changed files with 26 additions and 8 deletions
|
@ -307,6 +307,7 @@ class PublicApiController extends Controller
|
||||||
$user = $request->user();
|
$user = $request->user();
|
||||||
$filtered = $user ? UserFilterService::filters($user->profile_id) : [];
|
$filtered = $user ? UserFilterService::filters($user->profile_id) : [];
|
||||||
|
|
||||||
|
$hideNsfw = config('instance.hide_nsfw_on_public_feeds');
|
||||||
if(config('exp.cached_public_timeline') == false) {
|
if(config('exp.cached_public_timeline') == false) {
|
||||||
if($min || $max) {
|
if($min || $max) {
|
||||||
$dir = $min ? '>' : '<';
|
$dir = $min ? '>' : '<';
|
||||||
|
@ -322,7 +323,9 @@ class PublicApiController extends Controller
|
||||||
->whereNull(['in_reply_to_id', 'reblog_of_id'])
|
->whereNull(['in_reply_to_id', 'reblog_of_id'])
|
||||||
->whereIn('type', ['photo', 'photo:album', 'video', 'video:album', 'photo:video:album'])
|
->whereIn('type', ['photo', 'photo:album', 'video', 'video:album', 'photo:video:album'])
|
||||||
->whereLocal(true)
|
->whereLocal(true)
|
||||||
->where('is_nsfw', false)
|
->when($hideNsfw, function($q, $hideNsfw) {
|
||||||
|
return $q->where('is_nsfw', false);
|
||||||
|
})
|
||||||
->whereScope('public')
|
->whereScope('public')
|
||||||
->orderBy('id', 'desc')
|
->orderBy('id', 'desc')
|
||||||
->limit($limit)
|
->limit($limit)
|
||||||
|
@ -366,7 +369,9 @@ class PublicApiController extends Controller
|
||||||
->whereNull(['in_reply_to_id', 'reblog_of_id'])
|
->whereNull(['in_reply_to_id', 'reblog_of_id'])
|
||||||
->whereIn('type', ['photo', 'photo:album', 'video', 'video:album', 'photo:video:album'])
|
->whereIn('type', ['photo', 'photo:album', 'video', 'video:album', 'photo:video:album'])
|
||||||
->whereLocal(true)
|
->whereLocal(true)
|
||||||
->where('is_nsfw', false)
|
->when($hideNsfw, function($q, $hideNsfw) {
|
||||||
|
return $q->where('is_nsfw', false);
|
||||||
|
})
|
||||||
->whereScope('public')
|
->whereScope('public')
|
||||||
->orderBy('id', 'desc')
|
->orderBy('id', 'desc')
|
||||||
->limit($limit)
|
->limit($limit)
|
||||||
|
@ -610,6 +615,7 @@ class PublicApiController extends Controller
|
||||||
$amin = SnowflakeService::byDate(now()->subDays(config('federation.network_timeline_days_falloff')));
|
$amin = SnowflakeService::byDate(now()->subDays(config('federation.network_timeline_days_falloff')));
|
||||||
|
|
||||||
$filtered = $user ? UserFilterService::filters($user->profile_id) : [];
|
$filtered = $user ? UserFilterService::filters($user->profile_id) : [];
|
||||||
|
$hideNsfw = config('instance.hide_nsfw_on_public_feeds');
|
||||||
|
|
||||||
if(config('instance.timeline.network.cached') == false) {
|
if(config('instance.timeline.network.cached') == false) {
|
||||||
if($min || $max) {
|
if($min || $max) {
|
||||||
|
@ -623,7 +629,9 @@ class PublicApiController extends Controller
|
||||||
'created_at',
|
'created_at',
|
||||||
)
|
)
|
||||||
->where('id', $dir, $id)
|
->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'])
|
->whereNull(['in_reply_to_id', 'reblog_of_id'])
|
||||||
->whereNotIn('profile_id', $filtered)
|
->whereNotIn('profile_id', $filtered)
|
||||||
->whereIn('type', ['photo', 'photo:album', 'video', 'video:album', 'photo:video:album'])
|
->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'])
|
->whereNull(['in_reply_to_id', 'reblog_of_id'])
|
||||||
->whereNotIn('profile_id', $filtered)
|
->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'])
|
->whereIn('type', ['photo', 'photo:album', 'video', 'video:album', 'photo:video:album'])
|
||||||
->whereNotNull('uri')
|
->whereNotNull('uri')
|
||||||
->whereScope('public')
|
->whereScope('public')
|
||||||
|
|
|
@ -166,13 +166,13 @@ class StatusEntityLexer implements ShouldQueue
|
||||||
if(config_cache('pixelfed.bouncer.enabled')) {
|
if(config_cache('pixelfed.bouncer.enabled')) {
|
||||||
Bouncer::get($status);
|
Bouncer::get($status);
|
||||||
}
|
}
|
||||||
|
$hideNsfw = config('instance.hide_nsfw_on_public_feeds');
|
||||||
if( $status->uri == null &&
|
if( $status->uri == null &&
|
||||||
$status->scope == 'public' &&
|
$status->scope == 'public' &&
|
||||||
in_array($status->type, $types) &&
|
in_array($status->type, $types) &&
|
||||||
$status->in_reply_to_id === null &&
|
$status->in_reply_to_id === null &&
|
||||||
$status->reblog_of_id === null &&
|
$status->reblog_of_id === null &&
|
||||||
$status->is_nsfw == false
|
($hideNsfw ? $status->is_nsfw == false : true)
|
||||||
) {
|
) {
|
||||||
PublicTimelineService::add($status->id);
|
PublicTimelineService::add($status->id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,10 +75,13 @@ class NetworkTimelineService
|
||||||
public static function warmCache($force = false, $limit = 100)
|
public static function warmCache($force = false, $limit = 100)
|
||||||
{
|
{
|
||||||
if(self::count() == 0 || $force == true) {
|
if(self::count() == 0 || $force == true) {
|
||||||
|
$hideNsfw = config('instance.hide_nsfw_on_public_feeds');
|
||||||
Redis::del(self::CACHE_KEY);
|
Redis::del(self::CACHE_KEY);
|
||||||
$ids = Status::whereNotNull('uri')
|
$ids = Status::whereNotNull('uri')
|
||||||
->whereScope('public')
|
->whereScope('public')
|
||||||
->where('is_nsfw', false)
|
->when($hideNsfw, function($q, $hideNsfw) {
|
||||||
|
return $q->where('is_nsfw', false);
|
||||||
|
})
|
||||||
->whereNull('in_reply_to_id')
|
->whereNull('in_reply_to_id')
|
||||||
->whereNull('reblog_of_id')
|
->whereNull('reblog_of_id')
|
||||||
->whereIn('type', ['photo', 'photo:album', 'video', 'video:album', 'photo:video:album'])
|
->whereIn('type', ['photo', 'photo:album', 'video', 'video:album', 'photo:video:album'])
|
||||||
|
|
|
@ -75,10 +75,13 @@ class PublicTimelineService {
|
||||||
public static function warmCache($force = false, $limit = 100)
|
public static function warmCache($force = false, $limit = 100)
|
||||||
{
|
{
|
||||||
if(self::count() == 0 || $force == true) {
|
if(self::count() == 0 || $force == true) {
|
||||||
|
$hideNsfw = config('instance.hide_nsfw_on_public_feeds');
|
||||||
Redis::del(self::CACHE_KEY);
|
Redis::del(self::CACHE_KEY);
|
||||||
$ids = Status::whereNull('uri')
|
$ids = Status::whereNull('uri')
|
||||||
->whereNull('in_reply_to_id')
|
->whereNull('in_reply_to_id')
|
||||||
->where('is_nsfw', false)
|
->when($hideNsfw, function($q, $hideNsfw) {
|
||||||
|
return $q->where('is_nsfw', false);
|
||||||
|
})
|
||||||
->whereNull('reblog_of_id')
|
->whereNull('reblog_of_id')
|
||||||
->whereIn('type', ['photo', 'photo:album', 'video', 'video:album', 'photo:video:album'])
|
->whereIn('type', ['photo', 'photo:album', 'video', 'video:album', 'photo:video:album'])
|
||||||
->whereScope('public')
|
->whereScope('public')
|
||||||
|
|
|
@ -91,4 +91,6 @@ return [
|
||||||
'profile' => env('INSTANCE_PROFILE_EMBEDS', true),
|
'profile' => env('INSTANCE_PROFILE_EMBEDS', true),
|
||||||
'post' => env('INSTANCE_POST_EMBEDS', true),
|
'post' => env('INSTANCE_POST_EMBEDS', true),
|
||||||
],
|
],
|
||||||
|
|
||||||
|
'hide_nsfw_on_public_feeds' => env('PF_HIDE_NSFW_ON_PUBLIC_FEEDS', false),
|
||||||
];
|
];
|
||||||
|
|
Loading…
Reference in a new issue