mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-22 06:21:27 +00:00
Update public/network timelines, fix non-redis response and fix reblogs in home feed
This commit is contained in:
parent
7b8977e9cc
commit
8b4ac5cc0b
3 changed files with 85 additions and 28 deletions
|
@ -2523,6 +2523,7 @@ class ApiV1Controller extends Controller
|
|||
$napi = $request->has(self::PF_API_ENTITY_KEY);
|
||||
$min = $request->input('min_id');
|
||||
$max = $request->input('max_id');
|
||||
$minOrMax = $request->anyFilled(['max_id', 'min_id']);
|
||||
$limit = $request->input('limit') ?? 20;
|
||||
$user = $request->user();
|
||||
|
||||
|
@ -2535,6 +2536,8 @@ class ApiV1Controller extends Controller
|
|||
$filtered = $user ? UserFilterService::filters($user->profile_id) : [];
|
||||
AccountService::setLastActive($user->id);
|
||||
$domainBlocks = UserFilterService::domainBlocks($user->profile_id);
|
||||
$hideNsfw = config('instance.hide_nsfw_on_public_feeds');
|
||||
$amin = SnowflakeService::byDate(now()->subDays(config('federation.network_timeline_days_falloff')));
|
||||
|
||||
if($remote) {
|
||||
if(config('instance.timeline.network.cached')) {
|
||||
|
@ -2554,23 +2557,36 @@ class ApiV1Controller extends Controller
|
|||
} else {
|
||||
$feed = Status::select(
|
||||
'id',
|
||||
'profile_id',
|
||||
'uri',
|
||||
'type',
|
||||
'visibility',
|
||||
'scope',
|
||||
'local',
|
||||
'created_at',
|
||||
'profile_id',
|
||||
'in_reply_to_id',
|
||||
'reblog_of_id'
|
||||
)
|
||||
->when($minOrMax, function($q, $minOrMax) use($min, $max) {
|
||||
$dir = $min ? '>' : '<';
|
||||
$id = $min ?? $max;
|
||||
return $q->where('id', $dir, $id);
|
||||
})
|
||||
->whereNull(['in_reply_to_id', 'reblog_of_id'])
|
||||
->when($hideNsfw, function($q, $hideNsfw) {
|
||||
return $q->where('is_nsfw', false);
|
||||
})
|
||||
->whereIn('type', ['photo', 'photo:album', 'video', 'video:album', 'photo:video:album'])
|
||||
->where('visibility', 'public')
|
||||
->whereLocal(false)
|
||||
->whereScope('public')
|
||||
->where('id', '>', $amin)
|
||||
->orderByDesc('id')
|
||||
->take(($limit * 2))
|
||||
->pluck('id');
|
||||
->limit(($limit * 2))
|
||||
->pluck('id')
|
||||
->values()
|
||||
->toArray();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if($local || !$remote && !$local) {
|
||||
} else {
|
||||
if(config('instance.timeline.local.cached')) {
|
||||
Cache::remember('api:v1:timelines:public:cache_check', 10368000, function() {
|
||||
if(PublicTimelineService::count() == 0) {
|
||||
PublicTimelineService::warmCache(true, 400);
|
||||
|
@ -2584,6 +2600,37 @@ class ApiV1Controller extends Controller
|
|||
} else {
|
||||
$feed = PublicTimelineService::get(0, $limit + 5);
|
||||
}
|
||||
} else {
|
||||
$feed = Status::select(
|
||||
'id',
|
||||
'uri',
|
||||
'type',
|
||||
'scope',
|
||||
'local',
|
||||
'created_at',
|
||||
'profile_id',
|
||||
'in_reply_to_id',
|
||||
'reblog_of_id'
|
||||
)
|
||||
->when($minOrMax, function($q, $minOrMax) use($min, $max) {
|
||||
$dir = $min ? '>' : '<';
|
||||
$id = $min ?? $max;
|
||||
return $q->where('id', $dir, $id);
|
||||
})
|
||||
->whereNull(['in_reply_to_id', 'reblog_of_id'])
|
||||
->when($hideNsfw, function($q, $hideNsfw) {
|
||||
return $q->where('is_nsfw', false);
|
||||
})
|
||||
->whereIn('type', ['photo', 'photo:album', 'video', 'video:album', 'photo:video:album'])
|
||||
->whereLocal(true)
|
||||
->whereScope('public')
|
||||
->where('id', '>', $amin)
|
||||
->orderByDesc('id')
|
||||
->limit(($limit * 2))
|
||||
->pluck('id')
|
||||
->values()
|
||||
->toArray();
|
||||
}
|
||||
}
|
||||
|
||||
$res = collect($feed)
|
||||
|
|
|
@ -29,6 +29,7 @@ return [
|
|||
],
|
||||
|
||||
'local' => [
|
||||
'cached' => env('INSTANCE_PUBLIC_TIMELINE_CACHED', false),
|
||||
'is_public' => env('INSTANCE_PUBLIC_LOCAL_TIMELINE', false)
|
||||
],
|
||||
|
||||
|
|
|
@ -187,7 +187,7 @@
|
|||
forceUpdateIdx: 0,
|
||||
showReblogBanner: false,
|
||||
enablingReblogs: false,
|
||||
baseApi: '/api/v1/pixelfed/timelines/',
|
||||
baseApi: '/api/v1/timelines/',
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -204,7 +204,7 @@
|
|||
}
|
||||
if(window.App.config.ab.hasOwnProperty('cached_home_timeline')) {
|
||||
const cht = window.App.config.ab.cached_home_timeline == true;
|
||||
this.baseApi = cht ? '/api/v1/timelines/' : '/api/pixelfed/v1/timelines/';
|
||||
this.baseApi = cht ? '/api/v1/timelines/' : '/api/v1/timelines/';
|
||||
}
|
||||
this.fetchSettings();
|
||||
},
|
||||
|
@ -261,12 +261,21 @@
|
|||
}
|
||||
} else {
|
||||
url = this.baseApi + this.getScope();
|
||||
|
||||
if(this.max_id === 0) {
|
||||
params = {
|
||||
min_id: 1,
|
||||
limit: 6,
|
||||
'_pe': 1,
|
||||
}
|
||||
} else {
|
||||
params = {
|
||||
max_id: this.max_id,
|
||||
limit: 6,
|
||||
'_pe': 1,
|
||||
}
|
||||
}
|
||||
}
|
||||
if(this.getScope() === 'network') {
|
||||
params.remote = true;
|
||||
url = this.baseApi + `public`;
|
||||
|
|
Loading…
Reference in a new issue