Skip to content

Commit

Permalink
Fix styling
Browse files Browse the repository at this point in the history
  • Loading branch information
zaosoula authored and github-actions[bot] committed Jul 16, 2024
1 parent 923be7f commit 7a79efa
Show file tree
Hide file tree
Showing 21 changed files with 100 additions and 99 deletions.
15 changes: 7 additions & 8 deletions app/Jobs/SendMessageToPushoverJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Str;

class SendMessageToPushoverJob implements ShouldQueue, ShouldBeEncrypted
class SendMessageToPushoverJob implements ShouldBeEncrypted, ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

Expand All @@ -32,34 +32,33 @@ public function __construct(
public array $buttons,
public string $token,
public string $user,
) {
}
) {}

/**
* Execute the job.
*/
public function handle(): void
{
$message = "<p>".$this->text."</p>";
$message = '<p>'.$this->text.'</p>';

if (!empty($this->buttons)) {
if (! empty($this->buttons)) {
foreach ($this->buttons as $button) {
$buttonUrl = data_get($button, 'url');
$text = data_get($button, 'text', 'Click here');
if ($buttonUrl && Str::contains($buttonUrl, 'http://localhost')) {
$buttonUrl = str_replace('http://localhost', config('app.url'), $buttonUrl);
}
$message .= "&nbsp;<a href='".$buttonUrl."'>".$text."</a>";
$message .= "&nbsp;<a href='".$buttonUrl."'>".$text.'</a>';
}
}

$payload = [
'token' => $this->token,
'user' => $this->user,
'message' => $message,
'html' => 1
'html' => 1,
];
ray($payload);
Http::post("https://api.pushover.net/1/messages.json", $payload);
Http::post('https://api.pushover.net/1/messages.json', $payload);
}
}
6 changes: 4 additions & 2 deletions app/Livewire/Notifications/Pushover.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
use App\Models\Team;
use App\Notifications\Test;
use Livewire\Component;
use Illuminate\Support\Facades\Log;

class Pushover extends Component
{

public Team $team;

protected $rules = [
'team.pushover_enabled' => 'nullable|boolean',
'team.pushover_token' => 'required|string',
Expand All @@ -20,6 +19,7 @@ class Pushover extends Component
'team.pushover_notifications_status_changes' => 'nullable|boolean',
'team.pushover_notifications_database_backups' => 'nullable|boolean',
];

protected $validationAttributes = [
'team.pushover_token' => 'Token',
'team.pushover_user' => 'User Key',
Expand All @@ -29,6 +29,7 @@ public function mount()
{
$this->team = auth()->user()->currentTeam();
}

public function instantSave()
{
try {
Expand Down Expand Up @@ -59,6 +60,7 @@ public function sendTestNotification()
$this->team?->notify(new Test());
$this->dispatch('success', 'Test notification sent.');
}

public function render()
{
return view('livewire.notifications.pushover');
Expand Down
15 changes: 8 additions & 7 deletions app/Notifications/Application/DeploymentFailed.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,18 +108,19 @@ public function toTelegram(): array
public function toPushover(): array
{
if ($this->preview) {
$message = 'Coolify: Pull request #' . $this->preview->pull_request_id . ' of **' . $this->application_name . '** (' . $this->preview->fqdn . ') deployment failed: ';
$message = 'Coolify: Pull request #'.$this->preview->pull_request_id.' of **'.$this->application_name.'** ('.$this->preview->fqdn.') deployment failed: ';
} else {
$message = 'Coolify: Deployment failed of **' . $this->application_name . '** (' . $this->fqdn . '): ';
$message = 'Coolify: Deployment failed of **'.$this->application_name.'** ('.$this->fqdn.'): ';
}
$buttons[] = [
"text" => "Deployment logs",
"url" => $this->deployment_url
'text' => 'Deployment logs',
'url' => $this->deployment_url,
];

return [
"message" => $message,
"buttons" => [
...$buttons
'message' => $message,
'buttons' => [
...$buttons,
],
];
}
Expand Down
23 changes: 12 additions & 11 deletions app/Notifications/Application/DeploymentSuccess.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,30 +136,31 @@ public function toTelegram(): array
public function toPushover(): array
{
if ($this->preview) {
$message = 'Coolify: New PR' . $this->preview->pull_request_id . ' version successfully deployed of ' . $this->application_name . '';
$message = 'Coolify: New PR'.$this->preview->pull_request_id.' version successfully deployed of '.$this->application_name.'';
if ($this->preview->fqdn) {
$buttons[] = [
"text" => "Open Application",
"url" => $this->preview->fqdn
'text' => 'Open Application',
'url' => $this->preview->fqdn,
];
}
} else {
$message = '✅ New version successfully deployed of ' . $this->application_name . '';
$message = '✅ New version successfully deployed of '.$this->application_name.'';
if ($this->fqdn) {
$buttons[] = [
"text" => "Open Application",
"url" => $this->fqdn
'text' => 'Open Application',
'url' => $this->fqdn,
];
}
}
$buttons[] = [
"text" => "Deployment logs",
"url" => $this->deployment_url
'text' => 'Deployment logs',
'url' => $this->deployment_url,
];

return [
"message" => $message,
"buttons" => [
...$buttons
'message' => $message,
'buttons' => [
...$buttons,
],
];
}
Expand Down
13 changes: 7 additions & 6 deletions app/Notifications/Application/StatusChanged.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,15 @@ public function toTelegram(): array

public function toPushover(): array
{
$message = 'Coolify: ' . $this->resource_name . ' has been stopped.';
$message = 'Coolify: '.$this->resource_name.' has been stopped.';

return [
"message" => $message,
"buttons" => [
'message' => $message,
'buttons' => [
[
"text" => "Open Application in Coolify",
"url" => $this->resource_url
]
'text' => 'Open Application in Coolify',
'url' => $this->resource_url,
],
],
];
}
Expand Down
2 changes: 1 addition & 1 deletion app/Notifications/Channels/PushoverChannel.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function send(SendsDiscord $notifiable, Notification $notification): void
$pushoverToken = data_get($pushoverData, 'token');
$pushoverUser = data_get($pushoverData, 'user');

if (!$pushoverToken || !$pushoverUser || !$message) {
if (! $pushoverToken || ! $pushoverUser || ! $message) {
return;
}
dispatch(new SendMessageToPushoverJob($message, $buttons, $pushoverToken, $pushoverUser));
Expand Down
13 changes: 7 additions & 6 deletions app/Notifications/Container/ContainerRestarted.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,19 @@ public function toPushover(): array
{
$message = "Coolify: A resource ({$this->name}) has been restarted automatically on {$this->server->name}";
$payload = [
"message" => $message,
'message' => $message,
];
if ($this->url) {
$payload['buttons'] = [
[
[
"text" => "Check Proxy in Coolify",
"url" => $this->url
]
]
'text' => 'Check Proxy in Coolify',
'url' => $this->url,
],
],
];
};
}

return $payload;
}
}
11 changes: 6 additions & 5 deletions app/Notifications/Container/ContainerStopped.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,19 @@ public function toPushover(): array
{
$message = "Coolify: A resource ($this->name) has been stopped unexpectedly on {$this->server->name}";
$payload = [
"message" => $message,
'message' => $message,
];
if ($this->url) {
$payload['buttons'] = [
[
[
"text" => "Open Application in Coolify",
"url" => $this->url
]
]
'text' => 'Open Application in Coolify',
'url' => $this->url,
],
],
];
}

return $payload;
}
}
2 changes: 1 addition & 1 deletion app/Notifications/Database/BackupFailed.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function toTelegram(): array
public function toPushover(): array
{
return [
"message" => "Coolify: Database backup for {$this->name} with frequency of {$this->frequency} was FAILED.\n\nReason: {$this->output}",
'message' => "Coolify: Database backup for {$this->name} with frequency of {$this->frequency} was FAILED.\n\nReason: {$this->output}",
];
}
}
2 changes: 1 addition & 1 deletion app/Notifications/Database/BackupSuccess.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function toTelegram(): array
public function toPushover(): array
{
return [
"message" => "Coolify: Database backup for {$this->name} with frequency of {$this->frequency} was successful.",
'message' => "Coolify: Database backup for {$this->name} with frequency of {$this->frequency} was successful.",
];
}
}
2 changes: 1 addition & 1 deletion app/Notifications/Database/DailyBackup.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function toTelegram(): array
public function toPushover(): array
{
return [
"message" => "Coolify: Daily backup statuses",
'message' => 'Coolify: Daily backup statuses',
];
}
}
3 changes: 2 additions & 1 deletion app/Notifications/Internal/GeneralNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public function via(object $notifiable): array
if ($isPushoverEnabled) {
$channels[] = PushoverChannel::class;
}

return $channels;
}

Expand All @@ -51,7 +52,7 @@ public function toTelegram(): array
public function toPushover(): array
{
return [
"message" => $this->message,
'message' => $this->message,
];
}
}
6 changes: 3 additions & 3 deletions app/Notifications/Server/DockerCleanup.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
namespace App\Notifications\Server;

use App\Models\Server;
use App\Notifications\Channels\PushoverChannel;
use App\Notifications\Channels\DiscordChannel;
use App\Notifications\Channels\PushoverChannel;
use App\Notifications\Channels\TelegramChannel;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
Expand Down Expand Up @@ -38,7 +38,7 @@ public function via(object $notifiable): array
if ($isPushoverEnabled) {
$channels[] = PushoverChannel::class;
}

return $channels;
}

Expand Down Expand Up @@ -71,7 +71,7 @@ public function toTelegram(): array
public function toPushover(): array
{
return [
"message" => "Coolify: Server '{$this->server->name}' cleanup job done!\n\n{$this->message}"
'message' => "Coolify: Server '{$this->server->name}' cleanup job done!\n\n{$this->message}",
];
}
}
6 changes: 3 additions & 3 deletions app/Notifications/Server/ForceDisabled.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
namespace App\Notifications\Server;

use App\Models\Server;
use App\Notifications\Channels\PushoverChannel;
use App\Notifications\Channels\DiscordChannel;
use App\Notifications\Channels\EmailChannel;
use App\Notifications\Channels\PushoverChannel;
use App\Notifications\Channels\TelegramChannel;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
Expand Down Expand Up @@ -40,7 +40,7 @@ public function via(object $notifiable): array
if ($isPushoverEnabled) {
$channels[] = PushoverChannel::class;
}

return $channels;
}

Expand Down Expand Up @@ -72,7 +72,7 @@ public function toTelegram(): array
public function toPushover(): array
{
return [
"message" => "Coolify: Server ({$this->server->name}) disabled because it is not paid!\n All automations and integrations are stopped.\nPlease update your subscription to enable the server again [here](https://app.coolify.io/subsciprtions)."
'message' => "Coolify: Server ({$this->server->name}) disabled because it is not paid!\n All automations and integrations are stopped.\nPlease update your subscription to enable the server again [here](https://app.coolify.io/subsciprtions).",
];
}
}
6 changes: 3 additions & 3 deletions app/Notifications/Server/ForceEnabled.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
namespace App\Notifications\Server;

use App\Models\Server;
use App\Notifications\Channels\PushoverChannel;
use App\Notifications\Channels\DiscordChannel;
use App\Notifications\Channels\EmailChannel;
use App\Notifications\Channels\PushoverChannel;
use App\Notifications\Channels\TelegramChannel;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
Expand Down Expand Up @@ -40,7 +40,7 @@ public function via(object $notifiable): array
if ($isPushoverEnabled) {
$channels[] = PushoverChannel::class;
}

return $channels;
}

Expand Down Expand Up @@ -72,7 +72,7 @@ public function toTelegram(): array
public function toPushover(): array
{
return [
"message" => "Coolify: Server ({$this->server->name}) enabled again!"
'message' => "Coolify: Server ({$this->server->name}) enabled again!",
];
}
}
6 changes: 3 additions & 3 deletions app/Notifications/Server/HighDiskUsage.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
namespace App\Notifications\Server;

use App\Models\Server;
use App\Notifications\Channels\PushoverChannel;
use App\Notifications\Channels\DiscordChannel;
use App\Notifications\Channels\EmailChannel;
use App\Notifications\Channels\PushoverChannel;
use App\Notifications\Channels\TelegramChannel;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
Expand Down Expand Up @@ -40,7 +40,7 @@ public function via(object $notifiable): array
if ($isPushoverEnabled) {
$channels[] = PushoverChannel::class;
}

return $channels;
}

Expand Down Expand Up @@ -74,7 +74,7 @@ public function toTelegram(): array
public function toPushover(): array
{
return [
"message" => "Coolify: Server '{$this->server->name}' high disk usage detected!\nDisk usage: {$this->disk_usage}%. Threshold: {$this->cleanup_after_percentage}%.\nPlease cleanup your disk to prevent data-loss.\nHere are some tips: https://coolify.io/docs/knowledge-base/server/automated-cleanup."
'message' => "Coolify: Server '{$this->server->name}' high disk usage detected!\nDisk usage: {$this->disk_usage}%. Threshold: {$this->cleanup_after_percentage}%.\nPlease cleanup your disk to prevent data-loss.\nHere are some tips: https://coolify.io/docs/knowledge-base/server/automated-cleanup.",
];
}
}
Loading

0 comments on commit 7a79efa

Please sign in to comment.