Update GroupsFeedController

pull/6699/head
Daniel Supernault 1 month ago
parent 5f397f9135
commit 40aef7a212
No known key found for this signature in database
GPG Key ID: 23740873EE6F76A1

@ -252,7 +252,7 @@ class ApiV1Controller extends Controller
if (str_starts_with($acct, '@')) {
$acct = substr($acct, 1);
} else {
$acct = '@'.$acct;
$acct = '@' . $acct;
}
}
if ($count > 2) {
@ -292,7 +292,7 @@ class ApiV1Controller extends Controller
}
$this->validate($request, [
'avatar' => 'sometimes|mimetypes:image/jpeg,image/jpg,image/png|max:'.config('pixelfed.max_avatar_size'),
'avatar' => 'sometimes|mimetypes:image/jpeg,image/jpg,image/png|max:' . config('pixelfed.max_avatar_size'),
'display_name' => 'nullable|string|max:30',
'note' => 'nullable|string|max:200',
'locked' => 'nullable',
@ -302,7 +302,7 @@ class ApiV1Controller extends Controller
], [
'required' => 'The :attribute field is required.',
'avatar.mimetypes' => 'The file must be in jpeg or png format',
'avatar.max' => 'The :attribute exceeds the file size limit of '.PrettyNumber::size(config('pixelfed.max_avatar_size'), true, false),
'avatar.max' => 'The :attribute exceeds the file size limit of ' . PrettyNumber::size(config('pixelfed.max_avatar_size'), true, false),
]);
$user = $request->user();
@ -319,15 +319,15 @@ class ApiV1Controller extends Controller
if ($request->has('avatar')) {
$av = Avatar::whereProfileId($profile->id)->first();
if ($av) {
$currentAvatar = storage_path('app/'.$av->media_path);
$currentAvatar = storage_path('app/' . $av->media_path);
$file = $request->file('avatar');
$path = "public/avatars/{$profile->id}";
$name = strtolower(str_random(6)).'.'.$file->guessExtension();
$name = strtolower(str_random(6)) . '.' . $file->guessExtension();
$request->file('avatar')->storePubliclyAs($path, $name);
$av->media_path = "{$path}/{$name}";
$av->save();
Cache::forget("avatar:{$profile->id}");
Cache::forget('user:account:id:'.$user->id);
Cache::forget('user:account:id:' . $user->id);
AvatarOptimize::dispatch($user->profile, $currentAvatar);
}
$changes = true;
@ -420,7 +420,7 @@ class ApiV1Controller extends Controller
$license = $request->input('license');
abort_if(! in_array($license, License::keys()), 422, 'Invalid media license id');
$syncLicenses = $request->input('sync_licenses') == true;
abort_if($syncLicenses && Cache::get('pf:settings:mls_recently:'.$user->id) == 2, 422, 'You can only sync licenses twice per 24 hours');
abort_if($syncLicenses && Cache::get('pf:settings:mls_recently:' . $user->id) == 2, 422, 'You can only sync licenses twice per 24 hours');
if ($composeSettings['default_license'] != $license) {
$composeSettings['default_license'] = $license;
$licenseChanged = true;
@ -449,7 +449,7 @@ class ApiV1Controller extends Controller
if ($settings->show_profile_follower_count != $show_profile_follower_count) {
$settings->show_profile_follower_count = $show_profile_follower_count;
$changes = true;
Cache::forget('pf:acct-trans:hideFollowers:'.$profile->id);
Cache::forget('pf:acct-trans:hideFollowers:' . $profile->id);
}
}
@ -458,7 +458,7 @@ class ApiV1Controller extends Controller
if ($settings->show_profile_following_count != $show_profile_following_count) {
$settings->show_profile_following_count = $show_profile_following_count;
$changes = true;
Cache::forget('pf:acct-trans:hideFollowing:'.$profile->id);
Cache::forget('pf:acct-trans:hideFollowing:' . $profile->id);
}
}
@ -494,26 +494,26 @@ class ApiV1Controller extends Controller
$settings->save();
$user->save();
$profile->save();
Cache::forget('profile:settings:'.$profile->id);
Cache::forget('user:account:id:'.$profile->user_id);
Cache::forget('profile:follower_count:'.$profile->id);
Cache::forget('profile:following_count:'.$profile->id);
Cache::forget('profile:embed:'.$profile->id);
Cache::forget('profile:compose:settings:'.$user->id);
Cache::forget('profile:view:'.$profile->username);
Cache::forget('profile:atom:enabled:'.$profile->id);
Cache::forget('pfc:cached-user:wt:'.strtolower($profile->username));
Cache::forget('pfc:cached-user:wot:'.strtolower($profile->username));
Cache::forget('pf:acct:settings:hidden-followers:'.$profile->id);
Cache::forget('pf:acct:settings:hidden-following:'.$profile->id);
Cache::forget('pf:acct-trans:hideFollowing:'.$profile->id);
Cache::forget('pf:acct-trans:hideFollowers:'.$profile->id);
Cache::forget('profile:settings:' . $profile->id);
Cache::forget('user:account:id:' . $profile->user_id);
Cache::forget('profile:follower_count:' . $profile->id);
Cache::forget('profile:following_count:' . $profile->id);
Cache::forget('profile:embed:' . $profile->id);
Cache::forget('profile:compose:settings:' . $user->id);
Cache::forget('profile:view:' . $profile->username);
Cache::forget('profile:atom:enabled:' . $profile->id);
Cache::forget('pfc:cached-user:wt:' . strtolower($profile->username));
Cache::forget('pfc:cached-user:wot:' . strtolower($profile->username));
Cache::forget('pf:acct:settings:hidden-followers:' . $profile->id);
Cache::forget('pf:acct:settings:hidden-following:' . $profile->id);
Cache::forget('pf:acct-trans:hideFollowing:' . $profile->id);
Cache::forget('pf:acct-trans:hideFollowers:' . $profile->id);
AccountService::del($user->profile_id);
AccountService::forgetAccountSettings($profile->id);
}
if ($syncLicenses && $licenseChanged) {
$key = 'pf:settings:mls_recently:'.$user->id;
$key = 'pf:settings:mls_recently:' . $user->id;
$val = Cache::has($key) ? 2 : 1;
Cache::put($key, $val, 86400);
MediaSyncLicensePipeline::dispatch($user->id, $request->input('license'));
@ -547,8 +547,8 @@ class ApiV1Controller extends Controller
$pid = $request->user()->profile_id;
$this->validate($request, [
'limit' => 'sometimes|integer|min:1',
'max_id' => 'nullable|integer|min:0|max:'.PHP_INT_MAX,
'min_id' => 'nullable|integer|min:0|max:'.PHP_INT_MAX,
'max_id' => 'nullable|integer|min:0|max:' . PHP_INT_MAX,
'min_id' => 'nullable|integer|min:0|max:' . PHP_INT_MAX,
]);
$limit = $request->input('limit', 10);
if ($limit > 80) {
@ -618,15 +618,15 @@ class ApiV1Controller extends Controller
if ($paginator->onFirstPage()) {
if ($paginator->hasMorePages()) {
$link = '<'.$paginator->nextPageUrl().'>; rel="prev"';
$link = '<' . $paginator->nextPageUrl() . '>; rel="prev"';
}
} else {
if ($paginator->previousPageUrl()) {
$link = '<'.$paginator->previousPageUrl().'>; rel="next"';
$link = '<' . $paginator->previousPageUrl() . '>; rel="next"';
}
if ($paginator->hasMorePages()) {
$link .= ($link ? ', ' : '').'<'.$paginator->nextPageUrl().'>; rel="prev"';
$link .= ($link ? ', ' : '') . '<' . $paginator->nextPageUrl() . '>; rel="prev"';
}
}
@ -661,8 +661,8 @@ class ApiV1Controller extends Controller
$pid = $request->user()->profile_id;
$this->validate($request, [
'limit' => 'sometimes|integer|min:1',
'max_id' => 'nullable|integer|min:0|max:'.PHP_INT_MAX,
'min_id' => 'nullable|integer|min:0|max:'.PHP_INT_MAX,
'max_id' => 'nullable|integer|min:0|max:' . PHP_INT_MAX,
'min_id' => 'nullable|integer|min:0|max:' . PHP_INT_MAX,
]);
$limit = $request->input('limit', 10);
if ($limit > 80) {
@ -734,15 +734,15 @@ class ApiV1Controller extends Controller
if ($paginator->onFirstPage()) {
if ($paginator->hasMorePages()) {
$link = '<'.$paginator->nextPageUrl().'>; rel="prev"';
$link = '<' . $paginator->nextPageUrl() . '>; rel="prev"';
}
} else {
if ($paginator->previousPageUrl()) {
$link = '<'.$paginator->previousPageUrl().'>; rel="next"';
$link = '<' . $paginator->previousPageUrl() . '>; rel="next"';
}
if ($paginator->hasMorePages()) {
$link .= ($link ? ', ' : '').'<'.$paginator->nextPageUrl().'>; rel="prev"';
$link .= ($link ? ', ' : '') . '<' . $paginator->nextPageUrl() . '>; rel="prev"';
}
}
@ -778,9 +778,9 @@ class ApiV1Controller extends Controller
'media_type' => 'sometimes|string|in:photo,video',
'pinned' => 'nullable',
'exclude_replies' => 'nullable',
'max_id' => 'nullable|integer|min:0|max:'.PHP_INT_MAX,
'since_id' => 'nullable|integer|min:0|max:'.PHP_INT_MAX,
'min_id' => 'nullable|integer|min:0|max:'.PHP_INT_MAX,
'max_id' => 'nullable|integer|min:0|max:' . PHP_INT_MAX,
'since_id' => 'nullable|integer|min:0|max:' . PHP_INT_MAX,
'min_id' => 'nullable|integer|min:0|max:' . PHP_INT_MAX,
'limit' => 'nullable|integer|min:1',
]);
@ -931,7 +931,7 @@ class ApiV1Controller extends Controller
// Rate limits, max 7500 followers per account
if ($user->profile->following_count && $user->profile->following_count >= Follower::MAX_FOLLOWING) {
abort(400, 'You cannot follow more than '.Follower::MAX_FOLLOWING.' accounts');
abort(400, 'You cannot follow more than ' . Follower::MAX_FOLLOWING . ' accounts');
}
if ($private == true) {
@ -960,17 +960,17 @@ class ApiV1Controller extends Controller
}
RelationshipService::refresh($user->profile_id, $target->id);
Cache::forget('profile:following:'.$target->id);
Cache::forget('profile:followers:'.$target->id);
Cache::forget('profile:following:'.$user->profile_id);
Cache::forget('profile:followers:'.$user->profile_id);
Cache::forget('api:local:exp:rec:'.$user->profile_id);
Cache::forget('user:account:id:'.$target->user_id);
Cache::forget('user:account:id:'.$user->id);
Cache::forget('profile:follower_count:'.$target->id);
Cache::forget('profile:follower_count:'.$user->profile_id);
Cache::forget('profile:following_count:'.$target->id);
Cache::forget('profile:following_count:'.$user->profile_id);
Cache::forget('profile:following:' . $target->id);
Cache::forget('profile:followers:' . $target->id);
Cache::forget('profile:following:' . $user->profile_id);
Cache::forget('profile:followers:' . $user->profile_id);
Cache::forget('api:local:exp:rec:' . $user->profile_id);
Cache::forget('user:account:id:' . $target->user_id);
Cache::forget('user:account:id:' . $user->id);
Cache::forget('profile:follower_count:' . $target->id);
Cache::forget('profile:follower_count:' . $user->profile_id);
Cache::forget('profile:following_count:' . $target->id);
Cache::forget('profile:following_count:' . $user->profile_id);
AccountService::del($user->profile_id);
AccountService::del($target->id);
@ -1034,17 +1034,17 @@ class ApiV1Controller extends Controller
}
RelationshipService::refresh($user->profile_id, $target->id);
Cache::forget('profile:following:'.$target->id);
Cache::forget('profile:followers:'.$target->id);
Cache::forget('profile:following:'.$user->profile_id);
Cache::forget('profile:followers:'.$user->profile_id);
Cache::forget('api:local:exp:rec:'.$user->profile_id);
Cache::forget('user:account:id:'.$target->user_id);
Cache::forget('user:account:id:'.$user->id);
Cache::forget('profile:follower_count:'.$target->id);
Cache::forget('profile:follower_count:'.$user->profile_id);
Cache::forget('profile:following_count:'.$target->id);
Cache::forget('profile:following_count:'.$user->profile_id);
Cache::forget('profile:following:' . $target->id);
Cache::forget('profile:followers:' . $target->id);
Cache::forget('profile:following:' . $user->profile_id);
Cache::forget('profile:followers:' . $user->profile_id);
Cache::forget('api:local:exp:rec:' . $user->profile_id);
Cache::forget('user:account:id:' . $target->user_id);
Cache::forget('user:account:id:' . $user->id);
Cache::forget('profile:follower_count:' . $target->id);
Cache::forget('profile:follower_count:' . $user->profile_id);
Cache::forget('profile:following_count:' . $target->id);
Cache::forget('profile:following_count:' . $user->profile_id);
AccountService::del($user->profile_id);
AccountService::del($target->id);
@ -1065,7 +1065,7 @@ class ApiV1Controller extends Controller
$this->validate($request, [
'id' => 'required|array|min:1',
'id.*' => 'required|integer|min:1|max:'.PHP_INT_MAX,
'id.*' => 'required|integer|min:1|max:' . PHP_INT_MAX,
]);
$ids = $request->input('id');
if (count($ids) > 20) {
@ -1091,8 +1091,8 @@ class ApiV1Controller extends Controller
}
return $napi ?
RelationshipService::getWithDate($pid, $id) :
RelationshipService::get($pid, $id);
RelationshipService::getWithDate($pid, $id) :
RelationshipService::get($pid, $id);
});
return $this->json($res);
@ -1126,7 +1126,7 @@ class ApiV1Controller extends Controller
$limit = 20;
}
$resolve = $request->boolean('resolve', false);
$q = $query.'%';
$q = $query . '%';
$profiles = Profile::where('username', 'like', $q)
->orderByDesc('followers_count')
@ -1183,20 +1183,20 @@ class ApiV1Controller extends Controller
})
->values();
$baseUrl = config('app.url').'/api/v1/blocks?limit='.$limit.'&';
$baseUrl = config('app.url') . '/api/v1/blocks?limit=' . $limit . '&';
$next = $blocks->nextPageUrl();
$prev = $blocks->previousPageUrl();
if ($next && ! $prev) {
$link = '<'.$next.'>; rel="next"';
$link = '<' . $next . '>; rel="next"';
}
if (! $next && $prev) {
$link = '<'.$prev.'>; rel="prev"';
$link = '<' . $prev . '>; rel="prev"';
}
if ($next && $prev) {
$link = '<'.$next.'>; rel="next",<'.$prev.'>; rel="prev"';
$link = '<' . $next . '>; rel="next",<' . $prev . '>; rel="prev"';
}
$headers = isset($link) ? ['Link' => $link] : [];
@ -1244,9 +1244,9 @@ class ApiV1Controller extends Controller
})
->values()
->count();
abort_if($filterCount >= $maxLimit, 422, AccountController::FILTER_LIMIT_BLOCK_TEXT.$maxLimit.' accounts');
abort_if($filterCount >= $maxLimit, 422, AccountController::FILTER_LIMIT_BLOCK_TEXT . $maxLimit . ' accounts');
} else {
abort_if($count >= $maxLimit, 422, AccountController::FILTER_LIMIT_BLOCK_TEXT.$maxLimit.' accounts');
abort_if($count >= $maxLimit, 422, AccountController::FILTER_LIMIT_BLOCK_TEXT . $maxLimit . ' accounts');
}
$followed = Follower::whereProfileId($profile->id)->whereFollowingId($pid)->first();
@ -1436,11 +1436,11 @@ class ApiV1Controller extends Controller
$max = $ids->min() - 1;
$min = $ids->max();
$baseUrl = config('app.url').'/api/v1/favourites?limit='.$limit.'&';
$baseUrl = config('app.url') . '/api/v1/favourites?limit=' . $limit . '&';
if ($maxId) {
$link = '<'.$baseUrl.'max_id='.$max.'>; rel="next",<'.$baseUrl.'min_id='.$min.'>; rel="prev"';
$link = '<' . $baseUrl . 'max_id=' . $max . '>; rel="next",<' . $baseUrl . 'min_id=' . $min . '>; rel="prev"';
} else {
$link = '<'.$baseUrl.'max_id='.$max.'>; rel="next"';
$link = '<' . $baseUrl . 'max_id=' . $max . '>; rel="next"';
}
return $this->json($res, 200, ['Link' => $link]);
@ -1817,15 +1817,15 @@ class ApiV1Controller extends Controller
$rules = Cache::remember('api:v1:instance-data:rules', 604800, function () {
return config_cache('app.rules') ?
collect(json_decode(config_cache('app.rules'), true))
->map(function ($rule, $key) {
$id = $key + 1;
return [
'id' => "{$id}",
'text' => $rule,
];
})
->toArray() : [];
->map(function ($rule, $key) {
$id = $key + 1;
return [
'id' => "{$id}",
'text' => $rule,
];
})
->toArray() : [];
});
return [
@ -1834,7 +1834,7 @@ class ApiV1Controller extends Controller
'short_description' => config_cache('app.short_description'),
'description' => config_cache('app.description'),
'email' => config('instance.email'),
'version' => '3.5.3 (compatible; Pixelfed '.config('pixelfed.version').')',
'version' => '3.5.3 (compatible; Pixelfed ' . config('pixelfed.version') . ')',
'urls' => [
'streaming_api' => null,
],
@ -1916,17 +1916,17 @@ class ApiV1Controller extends Controller
$this->validate($request, [
'file.*' => [
'required_without:file',
'mimetypes:'.config_cache('pixelfed.media_types'),
'max:'.config_cache('pixelfed.max_photo_size'),
'mimetypes:' . config_cache('pixelfed.media_types'),
'max:' . config_cache('pixelfed.max_photo_size'),
],
'file' => [
'required_without:file.*',
'mimetypes:'.config_cache('pixelfed.media_types'),
'max:'.config_cache('pixelfed.max_photo_size'),
'mimetypes:' . config_cache('pixelfed.media_types'),
'max:' . config_cache('pixelfed.max_photo_size'),
],
'filter_name' => 'nullable|string|max:24',
'filter_class' => 'nullable|alpha_dash|max:24',
'description' => 'nullable|string|max:'.config_cache('pixelfed.max_altext_length'),
'description' => 'nullable|string|max:' . config_cache('pixelfed.max_altext_length'),
]);
$user = $request->user();
@ -1942,7 +1942,7 @@ class ApiV1Controller extends Controller
return response('', 422);
}
$limitKey = 'compose:rate-limit:media-upload:'.$user->id;
$limitKey = 'compose:rate-limit:media-upload:' . $user->id;
$limitTtl = now()->addMinutes(15);
$limitReached = Cache::remember($limitKey, $limitTtl, function () use ($user) {
$dailyLimit = Media::whereUserId($user->id)->where('created_at', '>', now()->subDays(1))->count();
@ -2043,8 +2043,8 @@ class ApiV1Controller extends Controller
Cache::forget($limitKey);
$resource = new Fractal\Resource\Item($media, new MediaTransformer);
$res = $this->fractal->createData($resource)->toArray();
$res['preview_url'] = $media->url().'?v='.time();
$res['url'] = $media->url().'?v='.time();
$res['preview_url'] = $media->url() . '?v=' . time();
$res['url'] = $media->url() . '?v=' . time();
return $this->json($res);
}
@ -2061,7 +2061,7 @@ class ApiV1Controller extends Controller
abort_unless($request->user()->tokenCan('write'), 403);
$this->validate($request, [
'description' => 'nullable|string|max:'.config_cache('pixelfed.max_altext_length'),
'description' => 'nullable|string|max:' . config_cache('pixelfed.max_altext_length'),
]);
$user = $request->user();
@ -2074,7 +2074,7 @@ class ApiV1Controller extends Controller
->findOrFail($id);
$executed = RateLimiter::attempt(
'media:update:'.$user->id,
'media:update:' . $user->id,
10,
function () use ($media, $request) {
$caption = app(SanitizeService::class)->html($request->input('description'));
@ -2088,7 +2088,8 @@ class ApiV1Controller extends Controller
StatusService::del($media->status_id);
}
}
});
}
);
if (! $executed) {
return response()->json([
@ -2142,17 +2143,17 @@ class ApiV1Controller extends Controller
$this->validate($request, [
'file.*' => [
'required_without:file',
'mimetypes:'.config_cache('pixelfed.media_types'),
'max:'.config_cache('pixelfed.max_photo_size'),
'mimetypes:' . config_cache('pixelfed.media_types'),
'max:' . config_cache('pixelfed.max_photo_size'),
],
'file' => [
'required_without:file.*',
'mimetypes:'.config_cache('pixelfed.media_types'),
'max:'.config_cache('pixelfed.max_photo_size'),
'mimetypes:' . config_cache('pixelfed.media_types'),
'max:' . config_cache('pixelfed.max_photo_size'),
],
'filter_name' => 'nullable|string|max:24',
'filter_class' => 'nullable|alpha_dash|max:24',
'description' => 'nullable|string|max:'.config_cache('pixelfed.max_altext_length'),
'description' => 'nullable|string|max:' . config_cache('pixelfed.max_altext_length'),
'replace_id' => 'sometimes',
]);
@ -2169,7 +2170,7 @@ class ApiV1Controller extends Controller
return response('', 422);
}
$limitKey = 'compose:rate-limit:media-upload:'.$user->id;
$limitKey = 'compose:rate-limit:media-upload:' . $user->id;
$limitTtl = now()->addMinutes(15);
$limitReached = Cache::remember($limitKey, $limitTtl, function () use ($user) {
$dailyLimit = Media::whereUserId($user->id)->where('created_at', '>', now()->subDays(1))->count();
@ -2275,7 +2276,7 @@ class ApiV1Controller extends Controller
Cache::forget($limitKey);
$resource = new Fractal\Resource\Item($media, new MediaTransformer);
$res = $this->fractal->createData($resource)->toArray();
$res['preview_url'] = $media->url().'?v='.time();
$res['preview_url'] = $media->url() . '?v=' . time();
$res['url'] = null;
return $this->json($res, 202);
@ -2318,20 +2319,20 @@ class ApiV1Controller extends Controller
})
->values();
$baseUrl = config('app.url').'/api/v1/mutes?limit='.$limit.'&';
$baseUrl = config('app.url') . '/api/v1/mutes?limit=' . $limit . '&';
$next = $mutes->nextPageUrl();
$prev = $mutes->previousPageUrl();
if ($next && ! $prev) {
$link = '<'.$next.'>; rel="next"';
$link = '<' . $next . '>; rel="next"';
}
if (! $next && $prev) {
$link = '<'.$prev.'>; rel="prev"';
$link = '<' . $prev . '>; rel="prev"';
}
if ($next && $prev) {
$link = '<'.$next.'>; rel="next",<'.$prev.'>; rel="prev"';
$link = '<' . $next . '>; rel="next",<' . $prev . '>; rel="prev"';
}
$headers = isset($link) ? ['Link' => $link] : [];
@ -2379,9 +2380,9 @@ class ApiV1Controller extends Controller
})
->values()
->count();
abort_if($filterCount >= $maxLimit, 422, AccountController::FILTER_LIMIT_MUTE_TEXT.$maxLimit.' accounts');
abort_if($filterCount >= $maxLimit, 422, AccountController::FILTER_LIMIT_MUTE_TEXT . $maxLimit . ' accounts');
} else {
abort_if($count >= $maxLimit, 422, AccountController::FILTER_LIMIT_MUTE_TEXT.$maxLimit.' accounts');
abort_if($count >= $maxLimit, 422, AccountController::FILTER_LIMIT_MUTE_TEXT . $maxLimit . ' accounts');
}
$filter = UserFilter::firstOrCreate([
@ -2453,9 +2454,9 @@ class ApiV1Controller extends Controller
$this->validate($request, [
'limit' => 'sometimes|integer|min:1',
'min_id' => 'nullable|integer|min:1|max:'.PHP_INT_MAX,
'max_id' => 'nullable|integer|min:1|max:'.PHP_INT_MAX,
'since_id' => 'nullable|integer|min:1|max:'.PHP_INT_MAX,
'min_id' => 'nullable|integer|min:1|max:' . PHP_INT_MAX,
'max_id' => 'nullable|integer|min:1|max:' . PHP_INT_MAX,
'since_id' => 'nullable|integer|min:1|max:' . PHP_INT_MAX,
'types[]' => 'sometimes|array',
'types[].*' => 'string|in:mention,reblog,follow,favourite',
'type' => 'sometimes|string|in:mention,reblog,follow,favourite',
@ -2505,17 +2506,17 @@ class ApiV1Controller extends Controller
}
if (empty($res)) {
if (! Cache::has('pf:services:notifications:hasSynced:'.$pid)) {
Cache::put('pf:services:notifications:hasSynced:'.$pid, 1, 1209600);
if (! Cache::has('pf:services:notifications:hasSynced:' . $pid)) {
Cache::put('pf:services:notifications:hasSynced:' . $pid, 1, 1209600);
NotificationWarmUserCache::dispatch($pid);
}
}
if ($request->has('types')) {
$typesParams = collect($types)->implode('&types[]=');
$baseUrl = config('app.url').'/api/v1/notifications?types[]='.$typesParams.'&limit='.$ogLimit.'&';
$baseUrl = config('app.url') . '/api/v1/notifications?types[]=' . $typesParams . '&limit=' . $ogLimit . '&';
} else {
$baseUrl = config('app.url').'/api/v1/notifications?limit='.$ogLimit.'&';
$baseUrl = config('app.url') . '/api/v1/notifications?limit=' . $ogLimit . '&';
}
if ($minId == $maxId) {
@ -2579,15 +2580,15 @@ class ApiV1Controller extends Controller
->values();
if ($maxId) {
$link = '<'.$baseUrl.'max_id='.$minId.'>; rel="next"';
$link = '<' . $baseUrl . 'max_id=' . $minId . '>; rel="next"';
}
if ($minId) {
$link = '<'.$baseUrl.'min_id='.$maxId.'>; rel="prev"';
$link = '<' . $baseUrl . 'min_id=' . $maxId . '>; rel="prev"';
}
if ($maxId && $minId) {
$link = '<'.$baseUrl.'max_id='.$minId.'>; rel="next",<'.$baseUrl.'min_id='.$maxId.'>; rel="prev"';
$link = '<' . $baseUrl . 'max_id=' . $minId . '>; rel="next",<' . $baseUrl . 'min_id=' . $maxId . '>; rel="prev"';
}
$headers = isset($link) ? ['Link' => $link] : [];
@ -2608,8 +2609,8 @@ class ApiV1Controller extends Controller
$this->validate($request, [
'page' => 'sometimes|integer|max:40',
'min_id' => 'nullable|integer|min:0|max:'.PHP_INT_MAX,
'max_id' => 'nullable|integer|min:0|max:'.PHP_INT_MAX,
'min_id' => 'nullable|integer|min:0|max:' . PHP_INT_MAX,
'max_id' => 'nullable|integer|min:0|max:' . PHP_INT_MAX,
'limit' => 'sometimes|integer|min:1',
'include_reblogs' => 'sometimes',
]);
@ -2630,11 +2631,11 @@ class ApiV1Controller extends Controller
$includeReblogs = $request->filled('include_reblogs') ? $request->boolean('include_reblogs') : $userEnableReblogs;
$nullFields = $includeReblogs ?
['in_reply_to_id'] :
['in_reply_to_id', 'reblog_of_id'];
['in_reply_to_id'] :
['in_reply_to_id', 'reblog_of_id'];
$inTypes = $includeReblogs ?
['photo', 'photo:album', 'video', 'video:album', 'photo:video:album', 'share'] :
['photo', 'photo:album', 'video', 'video:album', 'photo:video:album'];
['photo', 'photo:album', 'video', 'video:album', 'photo:video:album', 'share'] :
['photo', 'photo:album', 'video', 'video:album', 'photo:video:album'];
AccountService::setLastActive($request->user()->id);
$cachedFilters = CustomFilter::getCachedFiltersForAccount($pid);
@ -2658,14 +2659,14 @@ class ApiV1Controller extends Controller
}
if (! $res) {
$res = Cache::has('pf:services:apiv1:home:cached:coldbootcheck:'.$pid);
$res = Cache::has('pf:services:apiv1:home:cached:coldbootcheck:' . $pid);
if (! $res) {
Cache::set('pf:services:apiv1:home:cached:coldbootcheck:'.$pid, 1, 86400);
Cache::set('pf:services:apiv1:home:cached:coldbootcheck:' . $pid, 1, 86400);
FeedWarmCachePipeline::dispatchSync($pid);
return response()->json([], 206);
} else {
Cache::set('pf:services:apiv1:home:cached:coldbootcheck:'.$pid, 1, 86400);
Cache::set('pf:services:apiv1:home:cached:coldbootcheck:' . $pid, 1, 86400);
return response()->json([], 206);
}
@ -2710,7 +2711,7 @@ class ApiV1Controller extends Controller
})
->values();
$baseUrl = config('app.url').'/api/v1/timelines/home?limit='.$limit.'&';
$baseUrl = config('app.url') . '/api/v1/timelines/home?limit=' . $limit . '&';
$minId = $res->map(function ($s) {
return ['id' => $s['id']];
})->min('id');
@ -2723,15 +2724,15 @@ class ApiV1Controller extends Controller
}
if ($maxId && $res->count() >= $limit) {
$link = '<'.$baseUrl.'max_id='.$minId.'>; rel="next"';
$link = '<' . $baseUrl . 'max_id=' . $minId . '>; rel="next"';
}
if ($minId) {
$link = '<'.$baseUrl.'min_id='.$maxId.'>; rel="prev"';
$link = '<' . $baseUrl . 'min_id=' . $maxId . '>; rel="prev"';
}
if ($maxId && $minId) {
$link = '<'.$baseUrl.'max_id='.$minId.'>; rel="next",<'.$baseUrl.'min_id='.$maxId.'>; rel="prev"';
$link = '<' . $baseUrl . 'max_id=' . $minId . '>; rel="next",<' . $baseUrl . 'min_id=' . $maxId . '>; rel="prev"';
}
$headers = isset($link) ? ['Link' => $link] : [];
@ -2739,7 +2740,7 @@ class ApiV1Controller extends Controller
return $this->json($res->toArray(), 200, $headers);
}
$following = Cache::remember('profile:following:'.$pid, 1209600, function () use ($pid) {
$following = Cache::remember('profile:following:' . $pid, 1209600, function () use ($pid) {
$following = Follower::whereProfileId($pid)->pluck('following_id');
return $following->push($pid)->toArray();
@ -2898,7 +2899,7 @@ class ApiV1Controller extends Controller
->values();
}
$baseUrl = config('app.url').'/api/v1/timelines/home?limit='.$limit.'&';
$baseUrl = config('app.url') . '/api/v1/timelines/home?limit=' . $limit . '&';
$minId = $res->map(function ($s) {
return ['id' => $s['id']];
})->min('id');
@ -2911,15 +2912,15 @@ class ApiV1Controller extends Controller
}
if ($maxId) {
$link = '<'.$baseUrl.'max_id='.$minId.'>; rel="next"';
$link = '<' . $baseUrl . 'max_id=' . $minId . '>; rel="next"';
}
if ($minId) {
$link = '<'.$baseUrl.'min_id='.$maxId.'>; rel="prev"';
$link = '<' . $baseUrl . 'min_id=' . $maxId . '>; rel="prev"';
}
if ($maxId && $minId) {
$link = '<'.$baseUrl.'max_id='.$minId.'>; rel="next",<'.$baseUrl.'min_id='.$maxId.'>; rel="prev"';
$link = '<' . $baseUrl . 'max_id=' . $minId . '>; rel="next",<' . $baseUrl . 'min_id=' . $maxId . '>; rel="prev"';
}
$headers = isset($link) ? ['Link' => $link] : [];
@ -2936,8 +2937,8 @@ class ApiV1Controller extends Controller
public function timelinePublic(Request $request)
{
$this->validate($request, [
'min_id' => 'nullable|integer|min:0|max:'.PHP_INT_MAX,
'max_id' => 'nullable|integer|min:0|max:'.PHP_INT_MAX,
'min_id' => 'nullable|integer|min:0|max:' . PHP_INT_MAX,
'max_id' => 'nullable|integer|min:0|max:' . PHP_INT_MAX,
'limit' => 'sometimes|integer|min:1',
'remote' => 'sometimes',
'local' => 'sometimes',
@ -3186,7 +3187,7 @@ class ApiV1Controller extends Controller
->take($limit)
->values();
$baseUrl = config('app.url').'/api/v1/timelines/public?limit='.$limit.'&';
$baseUrl = config('app.url') . '/api/v1/timelines/public?limit=' . $limit . '&';
if ($remote) {
$baseUrl .= 'remote=1&';
}
@ -3205,15 +3206,15 @@ class ApiV1Controller extends Controller
}
if ($maxId && $res->count() >= $limit) {
$link = '<'.$baseUrl.'max_id='.$minId.'>; rel="next"';
$link = '<' . $baseUrl . 'max_id=' . $minId . '>; rel="next"';
}
if ($minId) {
$link = '<'.$baseUrl.'min_id='.$maxId.'>; rel="prev"';
$link = '<' . $baseUrl . 'min_id=' . $maxId . '>; rel="prev"';
}
if ($maxId && $minId) {
$link = '<'.$baseUrl.'max_id='.$minId.'>; rel="next",<'.$baseUrl.'min_id='.$maxId.'>; rel="prev"';
$link = '<' . $baseUrl . 'max_id=' . $minId . '>; rel="next",<' . $baseUrl . 'min_id=' . $maxId . '>; rel="prev"';
}
$headers = isset($link) ? ['Link' => $link] : [];
@ -3343,7 +3344,7 @@ class ApiV1Controller extends Controller
$links = [];
if (! $transformedDms->isEmpty()) {
$baseUrl = url()->current().'?'.http_build_query(array_merge(
$baseUrl = url()->current() . '?' . http_build_query(array_merge(
$request->except(['min_id', 'max_id', 'since_id']),
['limit' => $limit]
));
@ -3352,16 +3353,16 @@ class ApiV1Controller extends Controller
$lastId = $transformedDms->last()['id'];
$firstLink = $baseUrl;
$links[] = '<'.$firstLink.'>; rel="first"';
$links[] = '<' . $firstLink . '>; rel="first"';
if ($hasNextPage) {
$nextLink = $baseUrl.'&max_id='.$lastId;
$links[] = '<'.$nextLink.'>; rel="next"';
$nextLink = $baseUrl . '&max_id=' . $lastId;
$links[] = '<' . $nextLink . '>; rel="next"';
}
if ($max_id || $since_id) {
$prevLink = $baseUrl.'&min_id='.$firstId;
$links[] = '<'.$prevLink.'>; rel="prev"';
$prevLink = $baseUrl . '&min_id=' . $firstId;
$links[] = '<' . $prevLink . '>; rel="prev"';
}
}
@ -3463,8 +3464,8 @@ class ApiV1Controller extends Controller
if ($status['in_reply_to_id']) {
$ancestors[] = $pe ?
StatusService::get($status['in_reply_to_id'], false) :
StatusService::getMastodon($status['in_reply_to_id'], false);
StatusService::get($status['in_reply_to_id'], false) :
StatusService::getMastodon($status['in_reply_to_id'], false);
}
if ($status['replies_count']) {
@ -3476,8 +3477,8 @@ class ApiV1Controller extends Controller
->pluck('id')
->map(function ($sid) use ($pe) {
return $pe ?
StatusService::get($sid, false) :
StatusService::getMastodon($sid, false);
StatusService::get($sid, false) :
StatusService::getMastodon($sid, false);
})
->filter(function ($post) use ($filters) {
return $post && isset($post['account'], $post['account']['id']) && ! in_array($post['account']['id'], $filters);
@ -3546,7 +3547,7 @@ class ApiV1Controller extends Controller
abort_if(
! $status->type ||
! in_array($status->type, ['photo', 'photo:album', 'photo:video:album', 'reply', 'text', 'video', 'video:album']),
! in_array($status->type, ['photo', 'photo:album', 'photo:video:album', 'reply', 'text', 'video', 'video:album']),
404,
);
@ -3576,18 +3577,18 @@ class ApiV1Controller extends Controller
$links = '';
if ($res->onFirstPage()) {
if ($res->nextPageUrl()) {
$links = '<'.$res->nextPageUrl().'>; rel="prev"';
$links = '<' . $res->nextPageUrl() . '>; rel="prev"';
}
} else {
if ($res->previousPageUrl()) {
$links = '<'.$res->previousPageUrl().'>; rel="next"';
$links = '<' . $res->previousPageUrl() . '>; rel="next"';
}
if ($res->nextPageUrl()) {
if (! empty($links)) {
$links .= ', ';
}
$links .= '<'.$res->nextPageUrl().'>; rel="prev"';
$links .= '<' . $res->nextPageUrl() . '>; rel="prev"';
}
}
@ -3647,7 +3648,7 @@ class ApiV1Controller extends Controller
abort_if(
! $status->type ||
! in_array($status->type, ['photo', 'photo:album', 'photo:video:album', 'reply', 'text', 'video', 'video:album']),
! in_array($status->type, ['photo', 'photo:album', 'photo:video:album', 'reply', 'text', 'video', 'video:album']),
404,
);
@ -3678,18 +3679,18 @@ class ApiV1Controller extends Controller
if ($res->onFirstPage()) {
if ($res->nextPageUrl()) {
$links = '<'.$res->nextPageUrl().'>; rel="prev"';
$links = '<' . $res->nextPageUrl() . '>; rel="prev"';
}
} else {
if ($res->previousPageUrl()) {
$links = '<'.$res->previousPageUrl().'>; rel="next"';
$links = '<' . $res->previousPageUrl() . '>; rel="next"';
}
if ($res->nextPageUrl()) {
if (! empty($links)) {
$links .= ', ';
}
$links .= '<'.$res->nextPageUrl().'>; rel="prev"';
$links .= '<' . $res->nextPageUrl() . '>; rel="prev"';
}
}
@ -3728,9 +3729,9 @@ class ApiV1Controller extends Controller
abort_unless($request->user()->tokenCan('write'), 403);
$this->validate($request, [
'status' => 'nullable|string|max:'.(int) config_cache('pixelfed.max_caption_length'),
'status' => 'nullable|string|max:' . (int) config_cache('pixelfed.max_caption_length'),
'in_reply_to_id' => 'nullable',
'media_ids' => 'sometimes|array|max:'.(int) config_cache('pixelfed.max_album_length'),
'media_ids' => 'sometimes|array|max:' . (int) config_cache('pixelfed.max_album_length'),
'sensitive' => 'nullable',
'visibility' => 'string|in:private,unlisted,public,direct',
'spoiler_text' => 'sometimes|max:140',
@ -3746,7 +3747,7 @@ class ApiV1Controller extends Controller
}
if ($request->hasHeader('idempotency-key')) {
$key = 'pf:api:v1:status:idempotency-key:'.$request->user()->id.':'.hash('sha1', $request->header('idempotency-key'));
$key = 'pf:api:v1:status:idempotency-key:' . $request->user()->id . ':' . hash('sha1', $request->header('idempotency-key'));
$exists = Cache::has($key);
abort_if($exists, 400, 'Duplicate idempotency key.');
Cache::put($key, 1, 3600);
@ -3783,7 +3784,7 @@ class ApiV1Controller extends Controller
$profile = $user->profile;
$limitKey = 'compose:rate-limit:store:'.$user->id;
$limitKey = 'compose:rate-limit:store:' . $user->id;
$limitTtl = now()->addMinutes(15);
$limitReached = Cache::remember($limitKey, $limitTtl, function () use ($user) {
$minId = SnowflakeService::byDate(now()->subDays(1));
@ -3831,11 +3832,12 @@ class ApiV1Controller extends Controller
$status->in_reply_to_profile_id = $parent->profile_id;
$status->save();
StatusService::del($parent->id);
Cache::forget('status:replies:all:'.$parent->id);
Cache::forget('status:replies:all:' . $parent->id);
}
if ($ids) {
if (Media::whereUserId($user->id)
if (
Media::whereUserId($user->id)
->whereNull('status_id')
->find($ids)
->count() == 0
@ -3893,13 +3895,13 @@ class ApiV1Controller extends Controller
abort(500, 'An error occured.');
}
Cache::forget('pf:status:ap:v1:sid:'.$status->id);
Cache::forget('status:transformer:media:attachments:'.$status->id);
Cache::forget('user:account:id:'.$user->id);
Cache::forget('_api:statuses:recent_9:'.$user->profile_id);
Cache::forget('profile:status_count:'.$user->profile_id);
Cache::forget('pf:status:ap:v1:sid:' . $status->id);
Cache::forget('status:transformer:media:attachments:' . $status->id);
Cache::forget('user:account:id:' . $user->id);
Cache::forget('_api:statuses:recent_9:' . $user->profile_id);
Cache::forget('profile:status_count:' . $user->profile_id);
Cache::forget($user->storageUsedKey());
Cache::forget('profile:embed:'.$status->profile_id);
Cache::forget('profile:embed:' . $status->profile_id);
Cache::forget($limitKey);
NewStatusPipeline::dispatch($status);
@ -3957,7 +3959,7 @@ class ApiV1Controller extends Controller
$resource = new Fractal\Resource\Item($status, new StatusTransformer);
Cache::forget('profile:status_count:'.$status->profile_id);
Cache::forget('profile:status_count:' . $status->profile_id);
StatusDelete::dispatch($status);
$res = $this->fractal->createData($resource)->toArray();
@ -4087,8 +4089,8 @@ class ApiV1Controller extends Controller
$this->validate($request, [
'page' => 'nullable|integer|max:40',
'min_id' => 'nullable|integer|min:0|max:'.PHP_INT_MAX,
'max_id' => 'nullable|integer|min:0|max:'.PHP_INT_MAX,
'min_id' => 'nullable|integer|min:0|max:' . PHP_INT_MAX,
'max_id' => 'nullable|integer|min:0|max:' . PHP_INT_MAX,
'limit' => 'sometimes|integer|min:1',
'only_media' => 'sometimes',
'_pe' => 'sometimes',
@ -4272,14 +4274,14 @@ class ApiV1Controller extends Controller
$headers = [];
if ($bookmarkQuery->nextCursor()) {
$links .= '<'.$bookmarkQuery->nextPageUrl().'&limit='.$limit.'>; rel="next"';
$links .= '<' . $bookmarkQuery->nextPageUrl() . '&limit=' . $limit . '>; rel="next"';
}
if ($bookmarkQuery->previousCursor()) {
if ($links != null) {
$links .= ', ';
}
$links .= '<'.$bookmarkQuery->previousPageUrl().'&limit='.$limit.'>; rel="prev"';
$links .= '<' . $bookmarkQuery->previousPageUrl() . '&limit=' . $limit . '>; rel="prev"';
}
if ($links) {
@ -4434,14 +4436,14 @@ class ApiV1Controller extends Controller
$sortBy = $request->input('sort', 'all');
if ($sortBy == 'all' && isset($status['replies_count']) && $status['replies_count'] && $request->has('refresh_cache')) {
if (! Cache::has('status:replies:all-rc:'.$id)) {
Cache::forget('status:replies:all:'.$id);
Cache::put('status:replies:all-rc:'.$id, true, 300);
if (! Cache::has('status:replies:all-rc:' . $id)) {
Cache::forget('status:replies:all:' . $id);
Cache::put('status:replies:all-rc:' . $id, true, 300);
}
}
if ($sortBy == 'all' && ! $request->has('cursor')) {
$ids = Cache::remember('status:replies:all:'.$id, 3600, function () use ($id) {
$ids = Cache::remember('status:replies:all:' . $id, 3600, function () use ($id) {
return DB::table('statuses')
->where('in_reply_to_id', $id)
->orderBy('id')
@ -4691,6 +4693,7 @@ class ApiV1Controller extends Controller
public function accountRemoveFollowById(Request $request, $id)
{
abort_if(! $request->user(), 403);
abort_unless($request->user()->tokenCan('follow'), 403);
$pid = $request->user()->profile_id;
@ -4711,17 +4714,17 @@ class ApiV1Controller extends Controller
UnfollowPipeline::dispatch($id, $pid)->onQueue('high');
Cache::forget('profile:following:'.$id);
Cache::forget('profile:followers:'.$id);
Cache::forget('profile:following:'.$pid);
Cache::forget('profile:followers:'.$pid);
Cache::forget('api:local:exp:rec:'.$pid);
Cache::forget('user:account:id:'.$id);
Cache::forget('user:account:id:'.$pid);
Cache::forget('profile:follower_count:'.$id);
Cache::forget('profile:follower_count:'.$pid);
Cache::forget('profile:following_count:'.$id);
Cache::forget('profile:following_count:'.$pid);
Cache::forget('profile:following:' . $id);
Cache::forget('profile:followers:' . $id);
Cache::forget('profile:following:' . $pid);
Cache::forget('profile:followers:' . $pid);
Cache::forget('api:local:exp:rec:' . $pid);
Cache::forget('user:account:id:' . $id);
Cache::forget('user:account:id:' . $pid);
Cache::forget('profile:follower_count:' . $id);
Cache::forget('profile:follower_count:' . $pid);
Cache::forget('profile:following_count:' . $id);
Cache::forget('profile:following_count:' . $pid);
AccountService::del($pid);
AccountService::del($id);

@ -30,7 +30,7 @@ class GroupsFeedController extends Controller
$initial = $request->has('initial');
if ($initial) {
$res = Cache::remember('groups:self:feed:'.$pid, 900, function () use ($pid) {
$res = Cache::remember('groups:self:feed:' . $pid, 900, function () use ($pid) {
return $this->getSelfFeedV0($pid, 5, null);
});
} else {
@ -76,6 +76,7 @@ class GroupsFeedController extends Controller
$cid = $request->user()->profile_id;
$group = Group::findOrFail($id);
abort_if(! $group->isMember($cid), 404);
abort_if(! $group->isMember($pid), 404);
$feed = GroupPost::whereGroupId($id)

@ -31,26 +31,25 @@ class StatusController extends Controller
if ($request->user()) {
// unless they force static view
if (! $request->has('fs') || $request->input('fs') != '1') {
return redirect('/i/web/post/'.$id);
return redirect('/i/web/post/' . $id);
}
}
$status = StatusService::get($id, false);
$statusData = StatusService::get($id, false);
abort_if(
! $status ||
! isset($status['account'], $status['account']['username']) ||
$status['account']['username'] != $username ||
isset($status['reblog']), 404);
abort_if(! in_array($status['visibility'], ['public', 'unlisted']) && ! $request->user(), 403, 'Invalid permission');
if ($request->wantsJson() && (bool) config_cache('federation.activitypub.enabled')) {
return $this->showActivityPub($request, $status);
}
$user = Profile::whereNull('domain')->whereUsername($username)->firstOrFail();
if ($user->status != null) {
! $statusData ||
! isset($statusData['account'], $statusData['account']['username']) ||
$statusData['account']['username'] !== $username ||
isset($statusData['reblog']),
404
);
$user = Profile::whereNull('domain')
->whereUsername($username)
->firstOrFail();
if ($user->status !== null) {
return ProfileController::accountCheck($user);
}
@ -59,32 +58,52 @@ class StatusController extends Controller
->whereIn('scope', ['public', 'unlisted', 'private'])
->findOrFail($id);
if ($status->uri || $status->url) {
$url = $status->uri ?? $status->url;
if (ends_with($url, '/activity')) {
$url = str_replace('/activity', '', $url);
if ($status->visibility === 'private' || $user->is_private) {
$viewer = $request->user();
if (! $viewer) {
abort(404);
}
return redirect($url);
}
$viewerProfile = $viewer->profile;
if ($status->visibility == 'private' || $user->is_private) {
if (! Auth::check()) {
$isOwner = $viewerProfile->id === $user->id;
$isAdmin = (bool) $viewer->is_admin;
$isFollower = $user->followedBy($viewerProfile);
if (! $isOwner && ! $isAdmin && ! $isFollower) {
abort(404);
}
$pid = Auth::user()->profile;
if ($user->followedBy($pid) == false && $user->id !== $pid->id && Auth::user()->is_admin == false) {
}
if ($status->type === 'archived') {
$viewer = $request->user();
if (! $viewer || $viewer->profile_id !== $status->profile_id) {
abort(404);
}
}
if ($status->type == 'archived') {
if (Auth::user()->profile_id !== $status->profile_id) {
abort(404);
if (
$request->wantsJson() &&
(bool) config_cache('federation.activitypub.enabled')
) {
return $this->showActivityPub($request, $statusData);
}
if ($status->uri || $status->url) {
$url = $status->uri ?? $status->url;
if (ends_with($url, '/activity')) {
$url = str_replace('/activity', '', $url);
}
return redirect($url);
}
$template = $status->in_reply_to_id ? 'status.reply' : 'status.show';
$template = $status->in_reply_to_id
? 'status.reply'
: 'status.show';
return view($template, compact('user', 'status'));
}
@ -94,7 +113,7 @@ class StatusController extends Controller
$hid = HashidService::decode($id);
abort_if(! $hid, 404);
return redirect('/i/web/post/'.$hid);
return redirect('/i/web/post/' . $hid);
}
public function showId(int $id)
@ -145,7 +164,7 @@ class StatusController extends Controller
return response($content)->header('X-Frame-Options', 'ALLOWALL');
}
$aiCheck = Cache::remember('profile:ai-check:spam-login:'.$profile['id'], 3600, function () use ($profile) {
$aiCheck = Cache::remember('profile:ai-check:spam-login:' . $profile['id'], 3600, function () use ($profile) {
$user = Profile::find($profile['id']);
if (! $user) {
return true;
@ -235,7 +254,8 @@ class StatusController extends Controller
$user = Auth::user();
if ($status->profile_id != $user->profile->id &&
if (
$status->profile_id != $user->profile->id &&
$user->is_admin == true &&
$status->uri == null
) {
@ -270,19 +290,19 @@ class StatusController extends Controller
if ($status->in_reply_to_id) {
$parent = Status::find($status->in_reply_to_id);
if ($parent && ($parent->profile_id == $user->profile_id) || ($status->profile_id == $user->profile_id) || $user->is_admin) {
Cache::forget('_api:statuses:recent_9:'.$status->profile_id);
Cache::forget('profile:status_count:'.$status->profile_id);
Cache::forget('profile:embed:'.$status->profile_id);
Cache::forget('_api:statuses:recent_9:' . $status->profile_id);
Cache::forget('profile:status_count:' . $status->profile_id);
Cache::forget('profile:embed:' . $status->profile_id);
StatusService::del($status->id, true);
Cache::forget('profile:status_count:'.$status->profile_id);
Cache::forget('profile:status_count:' . $status->profile_id);
$status->uri ? RemoteStatusDelete::dispatch($status) : StatusDelete::dispatch($status);
}
} elseif ($status->profile_id == $user->profile_id || $user->is_admin == true) {
Cache::forget('_api:statuses:recent_9:'.$status->profile_id);
Cache::forget('profile:status_count:'.$status->profile_id);
Cache::forget('profile:embed:'.$status->profile_id);
Cache::forget('_api:statuses:recent_9:' . $status->profile_id);
Cache::forget('profile:status_count:' . $status->profile_id);
Cache::forget('profile:embed:' . $status->profile_id);
StatusService::del($status->id, true);
Cache::forget('profile:status_count:'.$status->profile_id);
Cache::forget('profile:status_count:' . $status->profile_id);
$status->uri ? RemoteStatusDelete::dispatch($status) : StatusDelete::dispatch($status);
}
@ -336,7 +356,7 @@ class StatusController extends Controller
ReblogService::add($profile->id, $status->id);
}
Cache::forget('status:'.$status->id.':sharedby:userid:'.$user->id);
Cache::forget('status:' . $status->id . ':sharedby:userid:' . $user->id);
StatusService::del($status->id);
if ($request->ajax()) {
@ -350,7 +370,7 @@ class StatusController extends Controller
public function showActivityPub(Request $request, $status)
{
$key = 'pf:status:ap:v1:sid:'.$status['id'];
$key = 'pf:status:ap:v1:sid:' . $status['id'];
return Cache::remember($key, 3600, function () use ($status) {
$status = Status::findOrFail($status['id']);
@ -392,7 +412,7 @@ class StatusController extends Controller
$status->media->each(function ($media) use ($licenseId) {
$media->license = $licenseId;
$media->save();
Cache::forget('status:transformer:media:attachments:'.$media->status_id);
Cache::forget('status:transformer:media:attachments:' . $media->status_id);
});
return redirect($status->url());
@ -486,7 +506,7 @@ class StatusController extends Controller
return response()->json(0);
}
Cache::forget('profile:home-timeline-cursor:'.$request->user()->id);
Cache::forget('profile:home-timeline-cursor:' . $request->user()->id);
foreach ($views as $view) {
if (! isset($view['sid']) || ! isset($view['pid'])) {

@ -36,11 +36,11 @@ use Illuminate\Pagination\Paginator;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\Facades\RateLimiter;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\URL;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\ServiceProvider;
use Laravel\Passport\Passport;
use Laravel\Pulse\Facades\Pulse;
use URL;
class AppServiceProvider extends ServiceProvider
{
@ -116,8 +116,8 @@ class AppServiceProvider extends ServiceProvider
$user = $request->user('web');
$actor = $user
? 'u:'.$user->getAuthIdentifier()
: 'ip:'.$request->ip();
? 'u:' . $user->getAuthIdentifier()
: 'ip:' . $request->ip();
$tooMany = function (Request $request, array $headers) {
return response()->json([
@ -167,6 +167,8 @@ class AppServiceProvider extends ServiceProvider
'follow',
]);
URL::forceRootUrl(config('app.url'));
// Model::preventLazyLoading(true);
}

Loading…
Cancel
Save