fix: make pushover settings more clear
- Rename User to User Key - Rename Token to API Token - fix: helper and docs links
This commit is contained in:
@@ -18,10 +18,10 @@ class Pushover extends Component
|
|||||||
public bool $pushoverEnabled = false;
|
public bool $pushoverEnabled = false;
|
||||||
|
|
||||||
#[Validate(['string', 'nullable'])]
|
#[Validate(['string', 'nullable'])]
|
||||||
public ?string $pushoverToken = null;
|
public ?string $pushoverUserKey = null;
|
||||||
|
|
||||||
#[Validate(['string', 'nullable'])]
|
#[Validate(['string', 'nullable'])]
|
||||||
public ?string $pushoverUser = null;
|
public ?string $pushoverApiToken = null;
|
||||||
|
|
||||||
#[Validate(['boolean'])]
|
#[Validate(['boolean'])]
|
||||||
public bool $deploymentSuccessPushoverNotifications = false;
|
public bool $deploymentSuccessPushoverNotifications = false;
|
||||||
@@ -59,7 +59,6 @@ class Pushover extends Component
|
|||||||
#[Validate(['boolean'])]
|
#[Validate(['boolean'])]
|
||||||
public bool $serverUnreachablePushoverNotifications = true;
|
public bool $serverUnreachablePushoverNotifications = true;
|
||||||
|
|
||||||
|
|
||||||
public function mount()
|
public function mount()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
@@ -76,8 +75,8 @@ class Pushover extends Component
|
|||||||
if ($toModel) {
|
if ($toModel) {
|
||||||
$this->validate();
|
$this->validate();
|
||||||
$this->settings->pushover_enabled = $this->pushoverEnabled;
|
$this->settings->pushover_enabled = $this->pushoverEnabled;
|
||||||
$this->settings->pushover_user = $this->pushoverUser;
|
$this->settings->pushover_user_key_key = $this->pushoverUserKey;
|
||||||
$this->settings->pushover_token = $this->pushoverToken;
|
$this->settings->pushover_api_token = $this->pushoverApiToken;
|
||||||
|
|
||||||
$this->settings->deployment_success_pushover_notifications = $this->deploymentSuccessPushoverNotifications;
|
$this->settings->deployment_success_pushover_notifications = $this->deploymentSuccessPushoverNotifications;
|
||||||
$this->settings->deployment_failure_pushover_notifications = $this->deploymentFailurePushoverNotifications;
|
$this->settings->deployment_failure_pushover_notifications = $this->deploymentFailurePushoverNotifications;
|
||||||
@@ -96,8 +95,8 @@ class Pushover extends Component
|
|||||||
refreshSession();
|
refreshSession();
|
||||||
} else {
|
} else {
|
||||||
$this->pushoverEnabled = $this->settings->pushover_enabled;
|
$this->pushoverEnabled = $this->settings->pushover_enabled;
|
||||||
$this->pushoverUser = $this->settings->pushover_user;
|
$this->pushoverUserKey = $this->settings->pushover_user_key_key;
|
||||||
$this->pushoverToken = $this->settings->pushover_token;
|
$this->pushoverApiToken = $this->settings->pushover_api_token;
|
||||||
|
|
||||||
$this->deploymentSuccessPushoverNotifications = $this->settings->deployment_success_pushover_notifications;
|
$this->deploymentSuccessPushoverNotifications = $this->settings->deployment_success_pushover_notifications;
|
||||||
$this->deploymentFailurePushoverNotifications = $this->settings->deployment_failure_pushover_notifications;
|
$this->deploymentFailurePushoverNotifications = $this->settings->deployment_failure_pushover_notifications;
|
||||||
@@ -118,11 +117,11 @@ class Pushover extends Component
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$this->validate([
|
$this->validate([
|
||||||
'pushoverUser' => 'required',
|
'pushoverUserKey' => 'required',
|
||||||
'pushoverToken' => 'required',
|
'pushoverApiToken' => 'required',
|
||||||
], [
|
], [
|
||||||
'pushoverUser.required' => 'Pushover User is required.',
|
'pushoverUserKey.required' => 'Pushover User Key is required.',
|
||||||
'pushoverToken.required' => 'Pushover Token is required.',
|
'pushoverApiToken.required' => 'Pushover API Token is required.',
|
||||||
]);
|
]);
|
||||||
$this->saveModel();
|
$this->saveModel();
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
|
@@ -15,8 +15,8 @@ class PushoverNotificationSettings extends Model
|
|||||||
'team_id',
|
'team_id',
|
||||||
|
|
||||||
'pushover_enabled',
|
'pushover_enabled',
|
||||||
'pushover_user',
|
'pushover_user_key_key',
|
||||||
'pushover_token',
|
'pushover_api_token',
|
||||||
|
|
||||||
'deployment_success_pushover_notifications',
|
'deployment_success_pushover_notifications',
|
||||||
'deployment_failure_pushover_notifications',
|
'deployment_failure_pushover_notifications',
|
||||||
@@ -29,12 +29,12 @@ class PushoverNotificationSettings extends Model
|
|||||||
'server_disk_usage_pushover_notifications',
|
'server_disk_usage_pushover_notifications',
|
||||||
'server_reachable_pushover_notifications',
|
'server_reachable_pushover_notifications',
|
||||||
'server_unreachable_pushover_notifications',
|
'server_unreachable_pushover_notifications',
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $casts = [
|
protected $casts = [
|
||||||
'pushover_enabled' => 'boolean',
|
'pushover_enabled' => 'boolean',
|
||||||
'pushover_user' => 'encrypted',
|
'pushover_user_key_key' => 'encrypted',
|
||||||
'pushover_token' => 'encrypted',
|
'pushover_api_token' => 'encrypted',
|
||||||
|
|
||||||
'deployment_success_pushover_notifications' => 'boolean',
|
'deployment_success_pushover_notifications' => 'boolean',
|
||||||
'deployment_failure_pushover_notifications' => 'boolean',
|
'deployment_failure_pushover_notifications' => 'boolean',
|
||||||
|
@@ -4,8 +4,8 @@ namespace App\Models;
|
|||||||
|
|
||||||
use App\Notifications\Channels\SendsDiscord;
|
use App\Notifications\Channels\SendsDiscord;
|
||||||
use App\Notifications\Channels\SendsEmail;
|
use App\Notifications\Channels\SendsEmail;
|
||||||
use App\Notifications\Channels\SendsSlack;
|
|
||||||
use App\Notifications\Channels\SendsPushover;
|
use App\Notifications\Channels\SendsPushover;
|
||||||
|
use App\Notifications\Channels\SendsSlack;
|
||||||
use App\Traits\HasNotificationSettings;
|
use App\Traits\HasNotificationSettings;
|
||||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
@@ -33,7 +33,7 @@ use OpenApi\Attributes as OA;
|
|||||||
]
|
]
|
||||||
)]
|
)]
|
||||||
|
|
||||||
class Team extends Model implements SendsDiscord, SendsEmail, SendsSlack, SendsPushover
|
class Team extends Model implements SendsDiscord, SendsEmail, SendsPushover, SendsSlack
|
||||||
{
|
{
|
||||||
use HasNotificationSettings, Notifiable;
|
use HasNotificationSettings, Notifiable;
|
||||||
|
|
||||||
@@ -156,12 +156,12 @@ class Team extends Model implements SendsDiscord, SendsEmail, SendsSlack, SendsP
|
|||||||
{
|
{
|
||||||
return data_get($this, 'slack_webhook_url', null);
|
return data_get($this, 'slack_webhook_url', null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function routeNotificationForPushover()
|
public function routeNotificationForPushover()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'user' => data_get($this, 'pushover_user', null),
|
'user' => data_get($this, 'pushover_user_key_key', null),
|
||||||
'token' => data_get($this, 'pushover_token', null),
|
'token' => data_get($this, 'pushover_api_token', null),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -287,7 +287,7 @@ class Team extends Model implements SendsDiscord, SendsEmail, SendsSlack, SendsP
|
|||||||
{
|
{
|
||||||
return $this->hasOne(SlackNotificationSettings::class);
|
return $this->hasOne(SlackNotificationSettings::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function pushoverNotificationSettings()
|
public function pushoverNotificationSettings()
|
||||||
{
|
{
|
||||||
return $this->hasOne(PushoverNotificationSettings::class);
|
return $this->hasOne(PushoverNotificationSettings::class);
|
||||||
|
@@ -7,15 +7,15 @@ use Illuminate\Notifications\Notification;
|
|||||||
|
|
||||||
class PushoverChannel
|
class PushoverChannel
|
||||||
{
|
{
|
||||||
public function send(SendsPushover $notifiable, Notification $notification): void
|
public function send(SendsPushover $notifiable, Notification $notification): void
|
||||||
{
|
{
|
||||||
$message = $notification->toPushover();
|
$message = $notification->toPushover();
|
||||||
$pushoverSettings = $notifiable->pushoverNotificationSettings;
|
$pushoverSettings = $notifiable->pushoverNotificationSettings;
|
||||||
|
|
||||||
if (! $pushoverSettings || ! $pushoverSettings->isEnabled() || ! $pushoverSettings->pushover_user || ! $pushoverSettings->pushover_token) {
|
if (! $pushoverSettings || ! $pushoverSettings->isEnabled() || ! $pushoverSettings->pushover_user_key || ! $pushoverSettings->pushover_api_token) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SendMessageToPushoverJob::dispatch($message, $pushoverSettings->pushover_api_token, $pushoverSettings->pushover_user_key);
|
||||||
}
|
}
|
||||||
|
|
||||||
SendMessageToPushoverJob::dispatch($message, $pushoverSettings->pushover_token, $pushoverSettings->pushover_user);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -16,8 +16,8 @@ return new class extends Migration
|
|||||||
$table->foreignId('team_id')->constrained()->cascadeOnDelete();
|
$table->foreignId('team_id')->constrained()->cascadeOnDelete();
|
||||||
|
|
||||||
$table->boolean('pushover_enabled')->default(false);
|
$table->boolean('pushover_enabled')->default(false);
|
||||||
$table->text('pushover_user')->nullable();
|
$table->text('pushover_user_key')->nullable();
|
||||||
$table->text('pushover_token')->nullable();
|
$table->text('pushover_api_token')->nullable();
|
||||||
|
|
||||||
$table->boolean('deployment_success_pushover_notifications')->default(false);
|
$table->boolean('deployment_success_pushover_notifications')->default(false);
|
||||||
$table->boolean('deployment_failure_pushover_notifications')->default(true);
|
$table->boolean('deployment_failure_pushover_notifications')->default(true);
|
||||||
@@ -44,4 +44,3 @@ return new class extends Migration
|
|||||||
Schema::dropIfExists('pushover_notification_settings');
|
Schema::dropIfExists('pushover_notification_settings');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -23,12 +23,12 @@
|
|||||||
<div class="w-32">
|
<div class="w-32">
|
||||||
<x-forms.checkbox instantSave="instantSavePushoverEnabled" id="pushoverEnabled" label="Enabled" />
|
<x-forms.checkbox instantSave="instantSavePushoverEnabled" id="pushoverEnabled" label="Enabled" />
|
||||||
</div>
|
</div>
|
||||||
<x-forms.input type="text"
|
|
||||||
helper="Get your user key in Pushover.<br><a href='https://pushover.net' target='_blank'>Pushover</a>" required
|
|
||||||
id="pushoverUser" label="User" />
|
|
||||||
<x-forms.input type="password"
|
<x-forms.input type="password"
|
||||||
helper="Generate a token in Pushover.<br>Example: https://pushover.net/apps/build/...." required
|
helper="Get your User Key in Pushover. You need to be logged in to Pushover to see your user key in the top right corner. <br><a class='inline-block underline dark:text-white' href='https://pushover.net/' target='_blank'>Pushover Dashboard</a>" required
|
||||||
id="pushoverToken" label="Token" />
|
id="pushoverUserKey" label="User Key" />
|
||||||
|
<x-forms.input type="password"
|
||||||
|
helper="Generate an API Token/Key in Pushover by creating a new application. <br><a class='inline-block underline dark:text-white' href='https://pushover.net/apps/build' target='_blank'>Create Pushover Application</a>" required
|
||||||
|
id="pushoverApiToken" label="API Token" />
|
||||||
</form>
|
</form>
|
||||||
<h2 class="mt-4">Notification Settings</h2>
|
<h2 class="mt-4">Notification Settings</h2>
|
||||||
<p class="mb-4">
|
<p class="mb-4">
|
||||||
|
Reference in New Issue
Block a user