fedi-feed-router/backend/app/Services/RoutingValidationService.php

32 lines
761 B
PHP
Raw Normal View History

2025-07-05 18:26:04 +02:00
<?php
namespace App\Services;
use App\Exceptions\RoutingMismatchException;
use App\Models\Feed;
2025-07-07 00:51:32 +02:00
use App\Models\PlatformChannel;
2025-07-05 18:26:04 +02:00
use Illuminate\Support\Collection;
class RoutingValidationService
{
/**
2025-07-07 00:51:32 +02:00
* @param Collection<int, PlatformChannel> $channels
2025-07-05 18:26:04 +02:00
* @throws RoutingMismatchException
*/
public function validateLanguageCompatibility(Feed $feed, Collection $channels): void
{
if (! $feed->language) {
return;
}
foreach ($channels as $channel) {
if (! $channel->language) {
continue;
}
2025-08-07 21:19:19 +02:00
if ($feed->language->id !== $channel->language->id) {
2025-07-05 18:26:04 +02:00
throw new RoutingMismatchException($feed, $channel);
}
}
}
}