From 33621dd68033b923e59636518da4234ea4ccdd29 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Wed, 18 Sep 2024 02:29:38 -0600 Subject: [PATCH] Add Notify App Gateway support --- .../Controllers/Api/ApiV1Dot1Controller.php | 18 +++++++++++++----- app/Services/NotificationAppGatewayService.php | 11 +++++++++++ config/instance.php | 6 ++++++ 3 files changed, 30 insertions(+), 5 deletions(-) create mode 100644 app/Services/NotificationAppGatewayService.php diff --git a/app/Http/Controllers/Api/ApiV1Dot1Controller.php b/app/Http/Controllers/Api/ApiV1Dot1Controller.php index efd04c60d..ac2c1f55a 100644 --- a/app/Http/Controllers/Api/ApiV1Dot1Controller.php +++ b/app/Http/Controllers/Api/ApiV1Dot1Controller.php @@ -26,6 +26,7 @@ use App\Services\FollowerService; use App\Services\MediaBlocklistService; use App\Services\MediaPathService; use App\Services\NetworkTimelineService; +use App\Services\NotificationAppGatewayService; use App\Services\ProfileStatusService; use App\Services\PublicTimelineService; use App\Services\StatusService; @@ -54,8 +55,8 @@ class ApiV1Dot1Controller extends Controller public function __construct() { - $this->fractal = new Fractal\Manager(); - $this->fractal->setSerializer(new ArraySerializer()); + $this->fractal = new Fractal\Manager; + $this->fractal->setSerializer(new ArraySerializer); } public function json($res, $code = 200, $headers = []) @@ -317,7 +318,7 @@ class ApiV1Dot1Controller extends Controller if (config('pixelfed.bouncer.cloud_ips.ban_signups')) { abort_if(BouncerService::checkIp($request->ip()), 404); } - $agent = new Agent(); + $agent = new Agent; $currentIp = $request->ip(); $activity = AccountLog::whereUserId($user->id) @@ -575,7 +576,7 @@ class ApiV1Dot1Controller extends Controller $rtoken = Str::random(64); - $verify = new EmailVerification(); + $verify = new EmailVerification; $verify->user_id = $user->id; $verify->email = $user->email; $verify->user_token = $user->app_register_token; @@ -1203,7 +1204,7 @@ class ApiV1Dot1Controller extends Controller abort(500, 'An error occured.'); } - $media = new Media(); + $media = new Media; $media->status_id = $status->id; $media->profile_id = $profile->id; $media->user_id = $user->id; @@ -1252,4 +1253,11 @@ class ApiV1Dot1Controller extends Controller return $this->json($res); } + + public function nagState(Request $request) + { + abort_unless((bool) config_cache('pixelfed.oauth_enabled'), 404); + + return NotificationAppGatewayService::config(); + } } diff --git a/app/Services/NotificationAppGatewayService.php b/app/Services/NotificationAppGatewayService.php new file mode 100644 index 000000000..661f1a17a --- /dev/null +++ b/app/Services/NotificationAppGatewayService.php @@ -0,0 +1,11 @@ + env('INSTANCE_NOTIFY_AUTO_GC', false), 'delete_after_days' => env('INSTANCE_NOTIFY_AUTO_GC_DEL_AFTER_DAYS', 365), ], + + 'nag' => [ + 'enabled' => (bool) env('INSTANCE_NOTIFY_APP_GATEWAY', true), + 'endpoint' => 'push.pixelfed.net', + ], ], 'curated_registration' => [ @@ -171,6 +176,7 @@ return [ 'enabled' => env('INSTANCE_CUR_REG_NOTIFY_ADMIN_ON_VERIFY', false), 'bundle' => env('INSTANCE_CUR_REG_NOTIFY_ADMIN_ON_VERIFY_BUNDLE', false), 'max_per_day' => env('INSTANCE_CUR_REG_NOTIFY_ADMIN_ON_VERIFY_MPD', 10), + 'cc_addresses' => env('INSTANCE_CUR_REG_NOTIFY_ADMIN_ON_VERIFY_CC'), ], 'on_user_response' => env('INSTANCE_CUR_REG_NOTIFY_ADMIN_ON_USER_RESPONSE', false), ],