fix(notifications): build api token expiry notification link from the instance url

This commit is contained in:
peaklabs-dev 2026-09-04 14:43:07 +02:00
parent 986ece457d
commit 6abbf84520
No known key found for this signature in database
2 changed files with 14 additions and 1 deletions

View file

@ -21,7 +21,7 @@ public function __construct(public PersonalAccessToken $token)
$this->onQueue('high');
$this->tokenName = $token->name;
$this->expiresAt = $token->expires_at?->format('Y-m-d H:i:s') ?? '';
$this->manageUrl = route('security.api-tokens');
$this->manageUrl = base_url().'/security/api-tokens';
}
public function via(object $notifiable): array

View file

@ -1,6 +1,7 @@
<?php
use App\Jobs\ApiTokenExpirationWarningJob;
use App\Models\InstanceSettings;
use App\Models\PersonalAccessToken;
use App\Models\Team;
use App\Models\User;
@ -14,6 +15,7 @@
uses(RefreshDatabase::class);
beforeEach(function () {
InstanceSettings::forceCreate(['id' => 0]);
$this->team = Team::factory()->create();
$this->user = User::factory()->create();
$this->team->members()->attach($this->user->id, ['role' => 'owner']);
@ -137,4 +139,15 @@ function createTokenExpiring(User $user, Team $team, ?Carbon $expiresAt, ?Carbon
Notification::assertNothingSent();
expect($token->fresh()->api_token_expiration_warning_sent_at)->toBeNull();
});
test('manage url uses the instance fqdn when configured', function () {
InstanceSettings::query()->update(['fqdn' => 'https://coolify.example.com']);
$token = createTokenExpiring($this->user, $this->team, Carbon::now()->addHours(12));
$notification = new ApiTokenExpiringNotification($token);
expect($notification->toSlack()->description)
->toContain('https://coolify.example.com/security/api-tokens')
->not->toContain('localhost');
});
});