Use organization logo in Meet outbound emails.
Deploy Ladill Meet / deploy (push) Successful in 1m28s
Deploy Ladill Meet / deploy (push) Successful in 1m28s
Replace the product email mark with company logo or name in contact-message mail. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -17,6 +17,8 @@ class ContactMessageMail extends Mailable
|
||||
public string $bodyText,
|
||||
public ?string $fromName = null,
|
||||
public ?string $replyToAddress = null,
|
||||
public ?string $logoUrl = null,
|
||||
public ?string $companyName = null,
|
||||
) {}
|
||||
|
||||
public function envelope(): Envelope
|
||||
@@ -34,6 +36,8 @@ class ContactMessageMail extends Mailable
|
||||
with: [
|
||||
'bodyText' => $this->bodyText,
|
||||
'fromName' => $this->fromName,
|
||||
'logoUrl' => $this->logoUrl,
|
||||
'companyName' => $this->companyName,
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
namespace App\Services\Comms;
|
||||
|
||||
use App\Mail\ContactMessageMail;
|
||||
use App\Models\Organization;
|
||||
use App\Support\OrganizationBranding;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
@@ -13,14 +15,21 @@ use Illuminate\Support\Facades\Mail;
|
||||
*/
|
||||
class EmailService
|
||||
{
|
||||
public function send(string $to, string $subject, string $body, ?string $fromName = null, ?string $replyTo = null): bool
|
||||
public function send(string $to, string $subject, string $body, ?string $fromName = null, ?string $replyTo = null, ?Organization $organization = null): bool
|
||||
{
|
||||
if (! filter_var($to, FILTER_VALIDATE_EMAIL)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$logoUrl = null;
|
||||
$companyName = null;
|
||||
if ($organization) {
|
||||
$logoUrl = OrganizationBranding::emailLogoUrl($organization);
|
||||
$companyName = $organization->name;
|
||||
}
|
||||
|
||||
try {
|
||||
Mail::to($to)->send(new ContactMessageMail($subject, $body, $fromName, $replyTo));
|
||||
Mail::to($to)->send(new ContactMessageMail($subject, $body, $fromName, $replyTo, $logoUrl, $companyName));
|
||||
|
||||
return true;
|
||||
} catch (\Throwable $e) {
|
||||
|
||||
@@ -56,6 +56,9 @@ class MeetNotificationService
|
||||
$invitation->email,
|
||||
'Invitation: '.$room->title,
|
||||
$this->invitationBody($room, $host, $invitation),
|
||||
null,
|
||||
null,
|
||||
$room->organization,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -83,6 +86,9 @@ class MeetNotificationService
|
||||
$host->email,
|
||||
'Recording ready: '.$recording->session->room->title,
|
||||
'Your meeting recording is ready to view at '.route('meet.recordings.show', $recording),
|
||||
null,
|
||||
null,
|
||||
$recording->session->room->organization,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -101,6 +107,9 @@ class MeetNotificationService
|
||||
$host->email,
|
||||
'Reminder: '.$room->title.' starts soon',
|
||||
'Your meeting starts at '.$room->scheduled_at?->timezone($room->timezone)->format('M j, Y g:i A T')."\n\nJoin: ".$room->joinUrl(),
|
||||
null,
|
||||
null,
|
||||
$room->organization,
|
||||
);
|
||||
|
||||
$host->notify(new MeetingReminderNotification($room));
|
||||
@@ -113,6 +122,9 @@ class MeetNotificationService
|
||||
$invitation->email,
|
||||
'Reminder: '.$room->title.' starts soon',
|
||||
'You are invited to a meeting starting at '.$room->scheduled_at?->timezone($room->timezone)->format('M j, Y g:i A T')."\n\nJoin: ".$room->joinUrl(),
|
||||
null,
|
||||
null,
|
||||
$room->organization,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,4 +47,27 @@ class OrganizationBranding
|
||||
Storage::disk('public')->delete($organization->logo_path);
|
||||
}
|
||||
}
|
||||
|
||||
public static function emailLogoUrl(Organization $organization): ?string
|
||||
{
|
||||
if (! self::hasCustomLogo($organization)) {
|
||||
return null;
|
||||
}
|
||||
$ext = strtolower(pathinfo($organization->logo_path, PATHINFO_EXTENSION));
|
||||
if ($ext === 'svg') {
|
||||
return null;
|
||||
}
|
||||
$version = $organization->updated_at?->getTimestamp() ?? time();
|
||||
|
||||
return Storage::disk('public')->url($organization->logo_path).'?v='.$version;
|
||||
}
|
||||
|
||||
public static function wrapEmailHtml(string $bodyHtml, Organization $organization): string
|
||||
{
|
||||
return view('email.customer-branded', [
|
||||
'logoUrl' => self::emailLogoUrl($organization),
|
||||
'companyName' => $organization->name,
|
||||
'bodyHtml' => $bodyHtml,
|
||||
])->render();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,16 +6,24 @@
|
||||
</head>
|
||||
<body style="margin:0;background:#f8fafc;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Helvetica,Arial,sans-serif;color:#0f172a;">
|
||||
<div style="max-width:600px;margin:0 auto;padding:48px 16px;">
|
||||
<div style="text-align:center;padding:0 0 24px;">
|
||||
<img src="{{ asset('images/logo/ladillmeet-logo-email.png') }}" alt="Ladill Meet" style="height:38px;max-height:38px;width:auto;">
|
||||
</div>
|
||||
@if (! empty($logoUrl) || ! empty($companyName))
|
||||
<div style="text-align:center;padding:0 0 24px;">
|
||||
@if (! empty($logoUrl))
|
||||
<img src="{{ $logoUrl }}" alt="{{ $companyName }}" style="height:42px;max-height:42px;width:auto;">
|
||||
@else
|
||||
<div style="font-size:22px;font-weight:700;letter-spacing:-0.02em;color:#0f172a;">{{ $companyName }}</div>
|
||||
@endif
|
||||
</div>
|
||||
@endif
|
||||
<div style="background:#ffffff;border-radius:16px;padding:40px;border:1px solid #e2e8f0;box-shadow:0 4px 6px -1px rgba(0,0,0,0.1);">
|
||||
<div style="white-space:pre-wrap;font-size:16px;line-height:1.7;color:#475569;">{{ $bodyText }}</div>
|
||||
@if (! empty($fromName))
|
||||
<p style="margin-top:24px;font-size:14px;color:#64748b;">— {{ $fromName }}</p>
|
||||
@endif
|
||||
</div>
|
||||
<p style="margin-top:20px;text-align:center;font-size:13px;color:#94a3b8;">Sent via Ladill Meet</p>
|
||||
@if (! empty($companyName))
|
||||
<p style="margin-top:20px;text-align:center;font-size:13px;color:#94a3b8;">{{ $companyName }}</p>
|
||||
@endif
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
</head>
|
||||
<body style="margin:0;background:#f8fafc;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Helvetica,Arial,sans-serif;color:#0f172a;">
|
||||
<div style="max-width:600px;margin:0 auto;padding:48px 16px;">
|
||||
<div style="text-align:center;padding:0 0 24px;">
|
||||
@if (! empty($logoUrl))
|
||||
<img src="{{ $logoUrl }}" alt="{{ $companyName }}" style="height:42px;max-height:42px;width:auto;">
|
||||
@else
|
||||
<div style="font-size:22px;font-weight:700;letter-spacing:-0.02em;color:#0f172a;">{{ $companyName }}</div>
|
||||
@endif
|
||||
</div>
|
||||
<div style="background:#ffffff;border-radius:16px;padding:40px;border:1px solid #e2e8f0;box-shadow:0 4px 6px -1px rgba(0,0,0,0.1);">
|
||||
{!! $bodyHtml !!}
|
||||
</div>
|
||||
<p style="margin-top:20px;text-align:center;font-size:13px;color:#94a3b8;">{{ $companyName }}</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -30,11 +30,19 @@
|
||||
|
||||
@if ($canManage)
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-slate-700">Logo</label>
|
||||
<input type="file" name="logo" accept="image/png,image/jpeg,image/webp,image/svg+xml" class="mt-2 block w-full text-sm">
|
||||
<label class="block text-sm font-medium text-slate-700">Company logo</label>
|
||||
<p class="mt-1 text-xs text-slate-500">PNG, JPG, WebP, or SVG up to 2 MB. Shown in meeting emails.</p>
|
||||
@if (\App\Support\OrganizationBranding::hasCustomLogo($organization))
|
||||
<label class="mt-2 flex items-center gap-2 text-sm"><input type="checkbox" name="remove_logo" value="1"> Remove current logo</label>
|
||||
<img src="{{ \App\Support\OrganizationBranding::logoUrl($organization) }}"
|
||||
alt="{{ $organization->name }}"
|
||||
class="mt-3 h-12 w-auto max-w-xs rounded-lg border border-slate-200 bg-white object-contain p-2">
|
||||
<label class="mt-3 flex items-center gap-2 text-sm text-slate-600">
|
||||
<input type="checkbox" name="remove_logo" value="1" @checked(old('remove_logo'))>
|
||||
Remove custom logo
|
||||
</label>
|
||||
@endif
|
||||
<input type="file" name="logo" accept="image/png,image/jpeg,image/webp,image/svg+xml"
|
||||
class="mt-3 block w-full text-sm text-slate-600 file:mr-3 file:rounded-lg file:border-0 file:bg-indigo-50 file:px-3 file:py-2 file:text-sm file:font-medium file:text-indigo-700">
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn-primary">Save settings</button>
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Http\Middleware\EnsurePlatformSession;
|
||||
use App\Mail\ContactMessageMail;
|
||||
use App\Models\Invitation;
|
||||
use App\Models\Member;
|
||||
use App\Models\Organization;
|
||||
use App\Models\Room;
|
||||
use App\Models\User;
|
||||
use App\Services\Meet\MeetNotificationService;
|
||||
use App\Support\OrganizationBranding;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Tests\TestCase;
|
||||
|
||||
class MeetEmailBrandingTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
protected User $user;
|
||||
|
||||
protected Organization $organization;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->withoutMiddleware(EnsurePlatformSession::class);
|
||||
|
||||
$this->user = User::create([
|
||||
'public_id' => 'meet-brand-001',
|
||||
'name' => 'Test User',
|
||||
'email' => 'meet@example.com',
|
||||
]);
|
||||
|
||||
$this->organization = Organization::create([
|
||||
'owner_ref' => $this->user->public_id,
|
||||
'name' => 'Meet Corp',
|
||||
'slug' => 'meet-corp',
|
||||
'timezone' => 'UTC',
|
||||
'settings' => ['onboarded' => true],
|
||||
]);
|
||||
|
||||
Member::create([
|
||||
'owner_ref' => $this->user->public_id,
|
||||
'organization_id' => $this->organization->id,
|
||||
'user_ref' => $this->user->public_id,
|
||||
'role' => 'owner',
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_invitation_email_contains_organization_branding(): void
|
||||
{
|
||||
Storage::fake('public');
|
||||
Mail::fake();
|
||||
|
||||
$path = UploadedFile::fake()->image('meet-logo.png', 400, 120)
|
||||
->store('meet/organizations/'.$this->organization->id, 'public');
|
||||
$this->organization->update(['logo_path' => $path, 'name' => 'Meet Corp']);
|
||||
|
||||
$room = Room::create([
|
||||
'owner_ref' => $this->user->public_id,
|
||||
'organization_id' => $this->organization->id,
|
||||
'host_user_ref' => $this->user->public_id,
|
||||
'title' => 'Quarterly Review',
|
||||
'type' => 'scheduled',
|
||||
'status' => 'scheduled',
|
||||
'scheduled_at' => now()->addDay(),
|
||||
'timezone' => 'UTC',
|
||||
'settings' => config('meet.default_settings'),
|
||||
]);
|
||||
|
||||
$invitation = Invitation::create([
|
||||
'owner_ref' => $this->user->public_id,
|
||||
'room_id' => $room->id,
|
||||
'email' => 'guest@example.com',
|
||||
'role' => 'participant',
|
||||
'status' => 'pending',
|
||||
'sent_at' => now(),
|
||||
]);
|
||||
|
||||
app(MeetNotificationService::class)->sendInvitationEmail($room, $invitation, $this->user);
|
||||
|
||||
$logoUrl = OrganizationBranding::emailLogoUrl($this->organization->fresh());
|
||||
|
||||
Mail::assertSent(ContactMessageMail::class, function (ContactMessageMail $mail) use ($logoUrl) {
|
||||
$html = $mail->render();
|
||||
|
||||
return $mail->companyName === 'Meet Corp'
|
||||
&& $mail->logoUrl === $logoUrl
|
||||
&& str_contains($html, 'Meet Corp')
|
||||
&& str_contains($html, $logoUrl)
|
||||
&& ! str_contains($html, 'ladillmeet-logo-email')
|
||||
&& ! str_contains($html, 'Sent via Ladill Meet');
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user