|
|
|
|
@ -2642,6 +2642,16 @@ class ApiV1Controller extends Controller
|
|
|
|
|
$inTypes = $includeReblogs ?
|
|
|
|
|
['photo', 'photo:album', 'video', 'video:album', 'photo:video:album', 'share'] :
|
|
|
|
|
['photo', 'photo:album', 'video', 'video:album', 'photo:video:album'];
|
|
|
|
|
|
|
|
|
|
// "Photo reblogs only"
|
|
|
|
|
$photosReblogsOnly = $request->filled('photos_reblogs_only')
|
|
|
|
|
? $request->boolean('photos_reblogs_only')
|
|
|
|
|
: data_get($other, 'photo_reblogs_only', false);
|
|
|
|
|
$reblogTargetTypes = array_diff($inTypes, ['share']);
|
|
|
|
|
|
|
|
|
|
// Filtering happens after the fetch, so fetch deeper to fill a page
|
|
|
|
|
$fetchLimit = $photosReblogsOnly ? $limit * 6 : $limit * 2;
|
|
|
|
|
|
|
|
|
|
AccountService::setLastActive($request->user()->id);
|
|
|
|
|
|
|
|
|
|
$cachedFilters = CustomFilter::getCachedFiltersForAccount($pid);
|
|
|
|
|
@ -2770,7 +2780,7 @@ class ApiV1Controller extends Controller
|
|
|
|
|
->whereIn('type', $inTypes)
|
|
|
|
|
->whereIn('visibility', ['public', 'unlisted', 'private'])
|
|
|
|
|
->orderByDesc('id')
|
|
|
|
|
->take(($limit * 2))
|
|
|
|
|
->take($fetchLimit)
|
|
|
|
|
->get()
|
|
|
|
|
->map(function ($s) use ($pid, $napi) {
|
|
|
|
|
try {
|
|
|
|
|
@ -2796,8 +2806,15 @@ class ApiV1Controller extends Controller
|
|
|
|
|
|
|
|
|
|
return $status;
|
|
|
|
|
})
|
|
|
|
|
->filter(function ($status) {
|
|
|
|
|
return $status && isset($status['account']);
|
|
|
|
|
->filter(function ($status) use ($photosReblogsOnly, $reblogTargetTypes) {
|
|
|
|
|
if (! $status || ! isset($status['account'])) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// direct posts pass; a boost must share a photo or video
|
|
|
|
|
return ! $photosReblogsOnly
|
|
|
|
|
|| empty($status['reblog'])
|
|
|
|
|
|| in_array(data_get($status['reblog'], 'pf_type'), $reblogTargetTypes);
|
|
|
|
|
})
|
|
|
|
|
->map(function ($status) use ($pid) {
|
|
|
|
|
if (! empty($status['reblog'])) {
|
|
|
|
|
@ -2841,7 +2858,7 @@ class ApiV1Controller extends Controller
|
|
|
|
|
->whereIn('type', $inTypes)
|
|
|
|
|
->whereIn('visibility', ['public', 'unlisted', 'private'])
|
|
|
|
|
->orderByDesc('id')
|
|
|
|
|
->take(($limit * 2))
|
|
|
|
|
->take($fetchLimit)
|
|
|
|
|
->get()
|
|
|
|
|
->map(function ($s) use ($pid, $napi) {
|
|
|
|
|
try {
|
|
|
|
|
@ -2867,8 +2884,15 @@ class ApiV1Controller extends Controller
|
|
|
|
|
|
|
|
|
|
return $status;
|
|
|
|
|
})
|
|
|
|
|
->filter(function ($status) {
|
|
|
|
|
return $status && isset($status['account']);
|
|
|
|
|
->filter(function ($status) use ($photosReblogsOnly, $reblogTargetTypes) {
|
|
|
|
|
if (! $status || ! isset($status['account'])) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// direct posts pass; a boost must share a photo or video
|
|
|
|
|
return ! $photosReblogsOnly
|
|
|
|
|
|| empty($status['reblog'])
|
|
|
|
|
|| in_array(data_get($status['reblog'], 'pf_type'), $reblogTargetTypes);
|
|
|
|
|
})
|
|
|
|
|
->map(function ($status) use ($pid) {
|
|
|
|
|
if (! empty($status['reblog'])) {
|
|
|
|
|
|