🛠️ Add German portal domain and refactor URL handling for Nostr publishing

- Introduce `portal.einundzwanzig.space` with locale settings in `DomainMiddleware`.
- Replace verbose if‑chain in `NostrTrait::getUrl()` with a concise match expression.
- Add `DOMAIN_MAP` constant to `PublishUnpublishedItems` and force URL generation to use the correct domain per country.
- Update command flow: set domain before configuring timezone/locale.
This commit is contained in:
HolgerHatGarKeineNode
2025-12-09 22:45:26 +01:00
parent 2a70537fcb
commit d263eaf92d
3 changed files with 33 additions and 13 deletions

View File

@@ -9,6 +9,7 @@ use App\Models\MeetupEvent;
use App\Traits\NostrTrait; use App\Traits\NostrTrait;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\URL;
class PublishUnpublishedItems extends Command class PublishUnpublishedItems extends Command
{ {
@@ -26,6 +27,15 @@ class PublishUnpublishedItems extends Command
'pt' => 'Europe/Lisbon', 'pt' => 'Europe/Lisbon',
]; ];
private const DOMAIN_MAP = [
'de' => 'portal.einundzwanzig.space',
'nl' => 'portal.eenentwintig.net',
'hu' => 'portal.huszonegy.world',
'pl' => 'portal.dwadziesciajeden.pl',
// Default for other countries (e.g., 'es', 'pt') if added later
'default' => 'portal.einundzwanzig.space',
];
public function handle(): void public function handle(): void
{ {
$modelName = $this->option('model'); $modelName = $this->option('model');
@@ -59,8 +69,14 @@ class PublishUnpublishedItems extends Command
return; return;
} }
// Get country code and configure timezone/locale if applicable // Get country code
$countryCode = $this->getCountryCode($model); $countryCode = $this->getCountryCode($model);
// Set the domain based on country code for URL generation
$domain = self::DOMAIN_MAP[$countryCode] ?? self::DOMAIN_MAP['default'];
URL::useOrigin('https://'.$domain); // Forces URL generation to use this domain
// Configure timezone and locale
$this->configureForCountry($countryCode); $this->configureForCountry($countryCode);
$text = $this->getText($model, $countryCode); $text = $this->getText($model, $countryCode);

View File

@@ -15,6 +15,11 @@ class DomainMiddleware
// domains // domains
$domainArray = [ $domainArray = [
'portal.einundzwanzig.space' => [
'locale' => 'de',
'lang_country' => 'de-DE',
'app_name' => 'EINUNDZWANZIG Portal',
],
'portal.eenentwintig.net' => [ 'portal.eenentwintig.net' => [
'locale' => 'nl', 'locale' => 'nl',
'lang_country' => 'nl-NL', 'lang_country' => 'nl-NL',

View File

@@ -85,17 +85,16 @@ trait NostrTrait
private function getUrl(Model $model, string $countryCode): string private function getUrl(Model $model, string $countryCode): string
{ {
if ($model instanceof Course) { return match (true) {
return route('courses.landingpage', ['country' => $countryCode, 'course' => $model]); $model instanceof Course => url()->route('courses.landingpage',
} elseif ($model instanceof CourseEvent) { ['country' => $countryCode, 'course' => $model]),
return route('courses.landingpage', ['country' => $countryCode, 'course' => $model->course]); $model instanceof CourseEvent => url()->route('courses.landingpage',
} elseif ($model instanceof Meetup) { ['country' => $countryCode, 'course' => $model->course]),
return route('meetups.landingpage', ['country' => $countryCode, 'meetup' => $model]); $model instanceof Meetup => url()->route('meetups.landingpage',
} elseif ($model instanceof MeetupEvent) { ['country' => $countryCode, 'meetup' => $model]),
return route('meetups.landingpage-event', $model instanceof MeetupEvent => url()->route('meetups.landingpage-event',
['country' => $countryCode, 'meetup' => $model->meetup, 'event' => $model]); ['country' => $countryCode, 'meetup' => $model->meetup, 'event' => $model]),
} default => '',
};
return '';
} }
} }