diff --git a/app/Mod/Names/Controllers/NamesController.php b/app/Mod/Names/Controllers/NamesController.php index ddee12e..164bc18 100644 --- a/app/Mod/Names/Controllers/NamesController.php +++ b/app/Mod/Names/Controllers/NamesController.php @@ -497,6 +497,14 @@ class NamesController extends Controller 'email' => $claim->email, ]); + // Send approval notification email (queued, non-blocking) + try { + \Illuminate\Support\Facades\Mail::to($claim->email) + ->send(new \Mod\Names\Mail\ClaimApproved($claim)); + } catch (\Throwable $e) { + // Email delivery failure shouldn't break approval + } + return response()->json([ 'claim_id' => $claim->claim_id, 'name' => $claim->name, diff --git a/app/Mod/Names/Controllers/OgImageController.php b/app/Mod/Names/Controllers/OgImageController.php new file mode 100644 index 0000000..744869e --- /dev/null +++ b/app/Mod/Names/Controllers/OgImageController.php @@ -0,0 +1,64 @@ +getAliasByName(strtolower(trim($name))); + + $type = 'Available'; + $typeColour = '#34d399'; + + if ($alias) { + $comment = $alias['comment'] ?? ''; + if (str_contains($comment, 'type=reserved')) { + $type = 'Reserved'; + $typeColour = '#fbbf24'; + } elseif (str_contains($comment, 'type=gateway')) { + $type = 'Gateway'; + $typeColour = '#34d399'; + } else { + $type = 'Registered'; + $typeColour = '#818cf8'; + } + } + + $escapedName = htmlspecialchars($name, ENT_XML1); + + $svg = << + SVG; + + return response($svg, 200)->header('Content-Type', 'image/svg+xml') + ->header('Cache-Control', 'public, max-age=3600'); + } +} diff --git a/app/Mod/Names/Mail/ClaimApproved.php b/app/Mod/Names/Mail/ClaimApproved.php new file mode 100644 index 0000000..33a081a --- /dev/null +++ b/app/Mod/Names/Mail/ClaimApproved.php @@ -0,0 +1,66 @@ +email)->send(new ClaimApproved($claim)); + */ +class ClaimApproved extends Mailable +{ + public function __construct( + public readonly NameClaim $claim, + ) {} + + public function envelope(): Envelope + { + return new Envelope( + subject: "{$this->claim->name}.lthn — Your Name Claim Has Been Approved", + ); + } + + public function content(): Content + { + return new Content( + htmlString: $this->buildHtml(), + ); + } + + private function buildHtml(): string + { + $name = e($this->claim->name); + $fqdn = "{$name}.lthn"; + + return << +
Great news — your claim for {$fqdn} has been approved and registered on the Lethean blockchain.
+ +Name
+{$fqdn}
+
+ Lethean CIC — Community Interest Company
+ lthn.io
+