Wrap Vultr server creation in DB transactions and delete the remote instance when local persistence fails (API and Livewire). Scope plus/dot email normalization to gmail.com/googlemail.com only. Use throw:false on DigitalOcean/Vultr HTTP retries, and normalize service log line counts via normalizeLogLines.
23 lines
546 B
PHP
23 lines
546 B
PHP
<?php
|
|
|
|
use Illuminate\Support\Str;
|
|
|
|
function normalize_email_identity(?string $email): ?string
|
|
{
|
|
if (blank($email) || ! str_contains($email, '@')) {
|
|
return null;
|
|
}
|
|
|
|
[$localPart, $domain] = explode('@', Str::lower(trim($email)), 2);
|
|
|
|
if (in_array($domain, ['gmail.com', 'googlemail.com'], true)) {
|
|
$localPart = Str::before($localPart, '+');
|
|
$localPart = str_replace('.', '', $localPart);
|
|
}
|
|
|
|
if (blank($localPart) || blank($domain)) {
|
|
return null;
|
|
}
|
|
|
|
return $localPart.'@'.$domain;
|
|
}
|