Merge pull request 'codex/v0.5-webhook-notification/02-project-notification-settings-ui' (#48) from codex/v0.5-webhook-notification/02-project-notification-settings-ui into main
Reviewed-on: OpenSource/KanbanGit#48
This commit was merged in pull request #48.
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\NotificationChannel;
|
||||
use App\Enums\NotificationEventType;
|
||||
use Database\Factories\NotificationActionFactory;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Attributes\Hidden;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
#[Fillable([
|
||||
'channel',
|
||||
'channel_configuration',
|
||||
'delivery_url',
|
||||
'enabled',
|
||||
'event_type',
|
||||
'message_template',
|
||||
'name',
|
||||
'project_id',
|
||||
])]
|
||||
#[Hidden(['delivery_url'])]
|
||||
class NotificationAction extends Model
|
||||
{
|
||||
/** @use HasFactory<NotificationActionFactory> */
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'channel' => NotificationChannel::class,
|
||||
'channel_configuration' => 'array',
|
||||
'delivery_url' => 'encrypted',
|
||||
'enabled' => 'boolean',
|
||||
'event_type' => NotificationEventType::class,
|
||||
];
|
||||
}
|
||||
|
||||
public function scopeEnabled(Builder $query): Builder
|
||||
{
|
||||
return $query->where('enabled', true);
|
||||
}
|
||||
|
||||
public function deliveryLogs(): HasMany
|
||||
{
|
||||
return $this->hasMany(NotificationDeliveryLog::class)
|
||||
->orderByDesc('created_at')
|
||||
->orderByDesc('id');
|
||||
}
|
||||
|
||||
public function project(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Project::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\NotificationChannel;
|
||||
use App\Enums\NotificationDeliveryStatus;
|
||||
use App\Enums\NotificationEventType;
|
||||
use Database\Factories\NotificationDeliveryLogFactory;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
#[Fillable([
|
||||
'attempt_count',
|
||||
'channel',
|
||||
'delivered_at',
|
||||
'delivery_status',
|
||||
'error_excerpt',
|
||||
'event_type',
|
||||
'http_status',
|
||||
'last_attempted_at',
|
||||
'notification_action_id',
|
||||
'payload_metadata',
|
||||
'response_excerpt',
|
||||
])]
|
||||
class NotificationDeliveryLog extends Model
|
||||
{
|
||||
/** @use HasFactory<NotificationDeliveryLogFactory> */
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'attempt_count' => 'integer',
|
||||
'channel' => NotificationChannel::class,
|
||||
'delivered_at' => 'datetime',
|
||||
'delivery_status' => NotificationDeliveryStatus::class,
|
||||
'event_type' => NotificationEventType::class,
|
||||
'http_status' => 'integer',
|
||||
'last_attempted_at' => 'datetime',
|
||||
'payload_metadata' => 'array',
|
||||
];
|
||||
}
|
||||
|
||||
public function notificationAction(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(NotificationAction::class);
|
||||
}
|
||||
}
|
||||
@@ -88,6 +88,13 @@ class Project extends Model
|
||||
->orderBy('repository_full_name');
|
||||
}
|
||||
|
||||
public function notificationActions(): HasMany
|
||||
{
|
||||
return $this->hasMany(NotificationAction::class)
|
||||
->orderBy('name')
|
||||
->orderBy('id');
|
||||
}
|
||||
|
||||
public function tickets(): HasMany
|
||||
{
|
||||
return $this->hasMany(Ticket::class)
|
||||
|
||||
Reference in New Issue
Block a user