Generische iCal-Kanäle mit Bestandsklärung und sicheren Exporten bereitstellen
Deploy FeWo mit PipelineManager / deploy (push) Successful in 2m33s

This commit is contained in:
Lars committed 2026-10-27 17:14:45 +01:00
1 parent 6fe5bbc6e3
commit 783068501c
42 files changed
+2646 -248

No files matched your search

+39 -4
View File
@@ -4,6 +4,10 @@
use App\Channels\ChannelRegistry;
use App\Channels\Contracts\ChannelConnector;
use App\Enums\ChannelBookingModel;
use App\Enums\ChannelEchoBehavior;
use App\Enums\ChannelExportMode;
use App\Enums\ChannelStatus;
use App\Enums\TenantServiceKey;
use App\Models\Concerns\BelongsToTenant;
use App\Tenancy\TenantFeatures;
@@ -22,18 +26,31 @@
* A sales channel (portal) of a property. Our system leads: occupations are imported from the
* channel and every channel gets its own export feed without its own occupations.
*/
#[Fillable(['property_id', 'name', 'connector', 'settings', 'is_active', 'requires_manual_blocking', 'manage_url'])]
#[Hidden(['export_token'])]
#[Fillable(['property_id', 'name', 'connector', 'settings', 'is_active', 'requires_manual_blocking', 'manage_url', 'status', 'booking_model', 'import_enabled', 'export_enabled', 'export_mode', 'external_poll_minutes', 'echo_behavior', 'echo_notes', 'operating_notes', 'portal_verified_at'])]
#[Hidden(['export_token', 'previous_export_token', 'export_snapshot', 'settings'])]
class Channel extends Model
{
/** @use HasFactory<ChannelFactory> */
use BelongsToTenant, HasFactory;
protected $attributes = [
'status' => 'setup', 'booking_model' => 'mixed', 'import_enabled' => false,
'export_enabled' => false, 'export_mode' => 'test',
'echo_behavior' => 'unverified',
];
protected static function booted(): void
{
static::creating(function (Channel $channel): void {
$channel->export_token ??= Str::random(48);
});
static::saving(function (Channel $channel): void {
if ($channel->isDirty('status')) {
$channel->is_active = $channel->status === ChannelStatus::Active;
} elseif ($channel->isDirty('is_active')) {
$channel->status = $channel->is_active ? ChannelStatus::Active : ChannelStatus::Paused;
}
});
}
/**
@@ -45,6 +62,18 @@ protected function casts(): array
{
return [
'settings' => 'array',
'status' => ChannelStatus::class,
'booking_model' => ChannelBookingModel::class,
'echo_behavior' => ChannelEchoBehavior::class,
'portal_verified_at' => 'immutable_datetime',
'export_mode' => ChannelExportMode::class,
'import_enabled' => 'boolean',
'export_enabled' => 'boolean',
'sync_warnings' => 'array',
'last_error_at' => 'immutable_datetime',
'export_snapshot_at' => 'immutable_datetime',
'last_export_requested_at' => 'immutable_datetime',
'previous_export_token_expires_at' => 'immutable_datetime',
'is_active' => 'boolean',
'requires_manual_blocking' => 'boolean',
'last_synced_at' => 'immutable_datetime',
@@ -92,7 +121,7 @@ public function tasks(): HasMany
#[Scope]
protected function active(Builder $query): Builder
{
return $query->where('is_active', true);
return $query->where('is_active', true)->where('status', ChannelStatus::Active);
}
public function connector(): ChannelConnector
@@ -102,7 +131,13 @@ public function connector(): ChannelConnector
public function importsOccupations(): bool
{
return $this->is_active && $this->servesItsLandlord() && $this->connector()->canImport($this);
return $this->is_active && $this->status === ChannelStatus::Active && $this->import_enabled
&& $this->servesItsLandlord() && $this->connector()->canImport($this);
}
public function exportsOccupations(): bool
{
return $this->is_active && $this->status === ChannelStatus::Active && $this->export_enabled && $this->servesItsLandlord();
}
/**