Update config() to config_cache()

This commit is contained in:
Daniel Supernault 2021-05-11 18:17:03 -06:00
parent 27b722e7a7
commit 53134208fe
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7
9 changed files with 889 additions and 884 deletions

View file

@ -79,7 +79,7 @@ class FederationController extends Controller
public function userOutbox(Request $request, $username)
{
abort_if(!config('federation.activitypub.enabled'), 404);
abort_if(!config_cache('federation.activitypub.enabled'), 404);
abort_if(!config('federation.activitypub.outbox'), 404);
$profile = Profile::whereNull('domain')
@ -99,7 +99,7 @@ class FederationController extends Controller
public function userInbox(Request $request, $username)
{
abort_if(!config('federation.activitypub.enabled'), 404);
abort_if(!config_cache('federation.activitypub.enabled'), 404);
abort_if(!config('federation.activitypub.inbox'), 404);
$headers = $request->headers->all();
@ -110,7 +110,7 @@ class FederationController extends Controller
public function sharedInbox(Request $request)
{
abort_if(!config('federation.activitypub.enabled'), 404);
abort_if(!config_cache('federation.activitypub.enabled'), 404);
abort_if(!config('federation.activitypub.sharedInbox'), 404);
$headers = $request->headers->all();
@ -121,7 +121,7 @@ class FederationController extends Controller
public function userFollowing(Request $request, $username)
{
abort_if(!config('federation.activitypub.enabled'), 404);
abort_if(!config_cache('federation.activitypub.enabled'), 404);
$profile = Profile::whereNull('remote_url')
->whereUsername($username)
@ -144,7 +144,7 @@ class FederationController extends Controller
public function userFollowers(Request $request, $username)
{
abort_if(!config('federation.activitypub.enabled'), 404);
abort_if(!config_cache('federation.activitypub.enabled'), 404);
$profile = Profile::whereNull('remote_url')
->whereUsername($username)

View file

@ -27,7 +27,7 @@ class ProfileController extends Controller
->whereUsername($username)
->firstOrFail();
if($request->wantsJson() && config('federation.activitypub.enabled')) {
if($request->wantsJson() && config_cache('federation.activitypub.enabled')) {
return $this->showActivityPub($request, $user);
}
return $this->buildProfile($request, $user);
@ -114,7 +114,7 @@ class ProfileController extends Controller
{
$user = Profile::whereNull('domain')->whereUsername($username)->firstOrFail();
if ($request->wantsJson() && config('federation.activitypub.enabled')) {
if ($request->wantsJson() && config_cache('federation.activitypub.enabled')) {
return $this->showActivityPub($request, $user);
}
@ -172,7 +172,7 @@ class ProfileController extends Controller
public function showActivityPub(Request $request, $user)
{
abort_if(!config('federation.activitypub.enabled'), 404);
abort_if(!config_cache('federation.activitypub.enabled'), 404);
abort_if($user->domain, 404);
$fractal = new Fractal\Manager();

View file

@ -84,7 +84,7 @@ class SearchController extends Controller
$hash = hash('sha256', $tag);
if( Helpers::validateUrl($tag) != false &&
Helpers::validateLocalUrl($tag) != true &&
config('federation.activitypub.enabled') == true &&
config_cache('federation.activitypub.enabled') == true &&
config('federation.activitypub.remoteFollow') == true
) {
$remote = Helpers::fetchFromUrl($tag);
@ -203,7 +203,7 @@ class SearchController extends Controller
$ttl = now()->addHours(2);
if( Helpers::validateUrl($tag) != false &&
Helpers::validateLocalUrl($tag) != true &&
config('federation.activitypub.enabled') == true &&
config_cache('federation.activitypub.enabled') == true &&
config('federation.activitypub.remoteFollow') == true
) {
$remote = Helpers::fetchFromUrl($tag);

View file

@ -70,11 +70,16 @@ class StatusController extends Controller
]);
}
if ($request->wantsJson() && config('federation.activitypub.enabled')) {
if ($request->wantsJson() && config_cache('federation.activitypub.enabled')) {
return $this->showActivityPub($request, $status);
}
$template = $status->in_reply_to_id ? 'status.reply' : 'status.show';
// $template = $status->type === 'video' &&
// $request->has('video_beta') &&
// $request->video_beta == 1 &&
// $request->user() ?
// 'status.show_video' : 'status.show';
return view($template, compact('user', 'status'));
}
@ -340,7 +345,7 @@ class StatusController extends Controller
public static function mimeTypeCheck($mimes)
{
$allowed = explode(',', config('pixelfed.media_types'));
$allowed = explode(',', config_cache('pixelfed.media_types'));
$count = count($mimes);
$photos = 0;
$videos = 0;

View file

@ -94,7 +94,7 @@ class SharePipeline implements ShouldQueue
public function remoteAnnounceDeliver()
{
if(config('federation.activitypub.enabled') == false) {
if(config_cache('federation.activitypub.enabled') == false) {
return true;
}
$status = $this->status;

View file

@ -11,6 +11,7 @@ use App\{
Status,
StatusHashtag,
};
use App\Models\StatusVideo;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
@ -72,7 +73,7 @@ class StatusDelete implements ShouldQueue
$profile->status_count = ($count - 1);
$profile->save();
if(config('federation.activitypub.enabled') == true) {
if(config_cache('federation.activitypub.enabled') == true) {
$this->fanoutDelete($status);
} else {
$this->unlinkRemoveMedia($status);
@ -110,7 +111,6 @@ class StatusDelete implements ShouldQueue
Report::whereObjectType('App\Status')
->whereObjectId($status->id)
->delete();
MediaTag::where('status_id', $status->id)
->cursor()
->each(function($tag) {
@ -119,7 +119,7 @@ class StatusDelete implements ShouldQueue
->forceDelete();
$tag->delete();
});
StatusVideo::whereStatusId($status->id)->delete();
AccountInterstitial::where('item_type', 'App\Status')
->where('item_id', $status->id)
->delete();

View file

@ -159,7 +159,7 @@ class StatusEntityLexer implements ShouldQueue
PublicTimelineService::add($status->id);
}
if(config('federation.activitypub.enabled') == true && config('app.env') == 'production') {
if(config_cache('federation.activitypub.enabled') == true && config('app.env') == 'production') {
StatusActivityPubDeliver::dispatch($this->status);
}
}

View file

@ -13,7 +13,7 @@ class Outbox {
public static function get($profile)
{
abort_if(!config('federation.activitypub.enabled'), 404);
abort_if(!config_cache('federation.activitypub.enabled'), 404);
abort_if(!config('federation.activitypub.outbox'), 404);
if($profile->status != null) {

View file

@ -27,7 +27,7 @@ class Config {
],
'activitypub' => [
'enabled' => config('federation.activitypub.enabled'),
'enabled' => config_cache('federation.activitypub.enabled'),
'remote_follow' => config('federation.activitypub.remoteFollow')
],