Add Notify App Gateway support

This commit is contained in:
Daniel Supernault 2024-09-18 02:29:38 -06:00
parent 0ddab939ad
commit 33621dd680
No known key found for this signature in database
GPG key ID: 23740873EE6F76A1
3 changed files with 30 additions and 5 deletions

View file

@ -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();
}
}

View file

@ -0,0 +1,11 @@
<?php
namespace App\Services;
class NotificationAppGatewayService
{
public static function config()
{
return config('instance.notifications.nag');
}
}

View file

@ -151,6 +151,11 @@ return [
'enabled' => 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),
],