DiscordWebhooks (#1355)

Co-authored-by: notCharles <charles@pelican.dev>
Co-authored-by: Lance Pioch <lancepioch@gmail.com>
Co-authored-by: Boy132 <mail@boy132.de>
Co-authored-by: RMartinOscar <40749467+RMartinOscar@users.noreply.github.com>
This commit is contained in:
JoanFo
2025-07-05 18:42:34 +02:00
committed by GitHub
parent 21ac75efae
commit c5aa8a3980
15 changed files with 1057 additions and 32 deletions

View File

@@ -0,0 +1,41 @@
<?php
use App\Enums\WebhookType;
use App\Models\WebhookConfiguration;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('webhook_configurations', function (Blueprint $table) {
$table->string('type')->nullable()->after('id');
$table->json('payload')->nullable()->after('type');
});
foreach (WebhookConfiguration::all() as $webhookConfig) {
$type = str($webhookConfig->endpoint)->contains('discord.com') ? WebhookType::Discord->value : WebhookType::Regular->value;
DB::table('webhook_configurations')
->where('id', $webhookConfig->id)
->update(['type' => $type]);
}
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('webhook_configurations', function (Blueprint $table) {
$table->dropColumn('type');
$table->dropColumn('payload');
});
}
};

View File

@@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('webhook_configurations', function (Blueprint $table) {
$table->json('headers')->nullable()->after('payload');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('webhook_configurations', function (Blueprint $table) {
$table->dropColumn('headers');
});
}
};