This commit is contained in:
Andras Bacsai
2024-12-06 14:33:22 +01:00
parent f7eccefda3
commit 08d992a1c2
4 changed files with 22 additions and 20 deletions

View File

@@ -18,6 +18,7 @@ class SendMessageToSlackJob implements ShouldQueue
private SlackMessage $message,
private string $webhookUrl
) {
$this->onQueue('high');
}
public function handle(): void
@@ -28,7 +29,7 @@ class SendMessageToSlackJob implements ShouldQueue
'type' => 'section',
'text' => [
'type' => 'plain_text',
'text' => "Coolify Notification",
'text' => 'Coolify Notification',
],
],
],
@@ -47,12 +48,12 @@ class SendMessageToSlackJob implements ShouldQueue
'type' => 'section',
'text' => [
'type' => 'mrkdwn',
'text' => $this->message->description
]
]
]
]
]
'text' => $this->message->description,
],
],
],
],
],
]);
}
}
}

View File

@@ -14,9 +14,9 @@ class SlackChannel
{
$message = $notification->toSlack();
$webhookUrl = $notifiable->routeNotificationForSlack();
if (!$webhookUrl) {
if (! $webhookUrl) {
return;
}
dispatch(new SendMessageToSlackJob($message, $webhookUrl))->onQueue('high');
SendMessageToSlackJob::dispatch($message, $webhookUrl);
}
}
}

View File

@@ -51,7 +51,7 @@ class Test extends Notification implements ShouldQueue
color: DiscordMessage::successColor(),
);
$message->addField(name: 'Dashboard', value: '[Link](' . base_url() . ')', inline: true);
$message->addField(name: 'Dashboard', value: '[Link]('.base_url().')', inline: true);
return $message;
}

View File

@@ -4,18 +4,19 @@ use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
return new class extends Migration
{
public function up(): void
{
Schema::table('teams', function (Blueprint $table) {
$table->boolean('slack_enabled')->default(false);
$table->string('slack_webhook_url')->nullable();
$table->boolean('slack_notifications_test')->default(false);
$table->boolean('slack_notifications_deployments')->default(false);
$table->boolean('slack_notifications_status_changes')->default(false);
$table->boolean('slack_notifications_database_backups')->default(false);
$table->boolean('slack_notifications_scheduled_tasks')->default(false);
$table->boolean('slack_notifications_server_disk_usage')->default(false);
$table->boolean('slack_notifications_test')->default(true);
$table->boolean('slack_notifications_deployments')->default(true);
$table->boolean('slack_notifications_status_changes')->default(true);
$table->boolean('slack_notifications_database_backups')->default(true);
$table->boolean('slack_notifications_scheduled_tasks')->default(true);
$table->boolean('slack_notifications_server_disk_usage')->default(true);
});
}
@@ -34,4 +35,4 @@ return new class extends Migration {
]);
});
}
};
};