Improve speaker invites and redesign roster add flow.
Deploy Ladill Events / deploy (push) Successful in 41s
Deploy Ladill Events / deploy (push) Successful in 41s
Surface specific send failures, allow resend, use ladl.link portal URLs, and replace stacked speaker forms with a single add-to-list pattern. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -90,10 +90,13 @@ class SpeakerController extends Controller
|
||||
'email' => ['required', 'email', 'max:190'],
|
||||
]);
|
||||
|
||||
$sent = $this->invites->sendManualInvite($event, $event->user, $validated['email']);
|
||||
$owner = ladill_account() ?? $event->user;
|
||||
abort_unless($owner, 500);
|
||||
|
||||
if (! $sent) {
|
||||
return back()->with('error', 'Could not send invitation. Check the email address or whether this speaker was already invited from the programme.');
|
||||
$result = $this->invites->sendManualInvite($event, $owner, $validated['email']);
|
||||
|
||||
if (! $result['ok']) {
|
||||
return back()->with('error', $result['error']);
|
||||
}
|
||||
|
||||
return back()->with('success', 'Speaker invitation sent.');
|
||||
|
||||
@@ -19,7 +19,7 @@ class PlatformEmailClient
|
||||
|
||||
public function send(string $ownerPublicId, string $to, string $subject, string $html, ?string $text = null): bool
|
||||
{
|
||||
if ($this->token() === '') {
|
||||
if (! $this->isConfigured()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -54,4 +54,9 @@ class PlatformEmailClient
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function isConfigured(): bool
|
||||
{
|
||||
return $this->token() !== '';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,34 +30,28 @@ class EventSpeakerInviteService
|
||||
|
||||
public function canSendManualInvite(QrCode $event, array $speaker): bool
|
||||
{
|
||||
if (($speaker['email'] ?? '') === '') {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (! $this->speakers->linkedProgramme($event)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (empty($speaker['invited_at'])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return ($speaker['invite_source'] ?? '') === self::SOURCE_MANUAL;
|
||||
return ($speaker['email'] ?? '') !== '';
|
||||
}
|
||||
|
||||
public function sendManualInvite(QrCode $event, User $owner, string $email): bool
|
||||
/** @return array{ok: true}|array{ok: false, error: string} */
|
||||
public function sendManualInvite(QrCode $event, User $owner, string $email): array
|
||||
{
|
||||
$email = strtolower(trim($email));
|
||||
$speakers = $this->rosterWithInviteState($event);
|
||||
$index = collect($speakers)->search(fn ($row) => strcasecmp((string) ($row['email'] ?? ''), $email) === 0);
|
||||
$event = $event->fresh() ?? $event;
|
||||
$speaker = $this->findSpeakerByEmail($event, $email);
|
||||
|
||||
if ($index === false) {
|
||||
return false;
|
||||
if ($speaker === null) {
|
||||
return [
|
||||
'ok' => false,
|
||||
'error' => 'That speaker is not on the saved roster. Click Save speakers first, then send the invitation.',
|
||||
];
|
||||
}
|
||||
|
||||
$speaker = $speakers[$index];
|
||||
if (! $this->canSendManualInvite($event, $speaker)) {
|
||||
return false;
|
||||
return [
|
||||
'ok' => false,
|
||||
'error' => 'Add a valid email address for this speaker before sending an invitation.',
|
||||
];
|
||||
}
|
||||
|
||||
return $this->deliverInvite($event, $owner, $speaker, self::SOURCE_MANUAL);
|
||||
@@ -103,7 +97,7 @@ class EventSpeakerInviteService
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($this->deliverInvite($event, $owner, $speaker, self::SOURCE_PROGRAMME)) {
|
||||
if ($this->deliverInvite($event, $owner, $speaker, self::SOURCE_PROGRAMME)['ok']) {
|
||||
$sent++;
|
||||
}
|
||||
}
|
||||
@@ -161,10 +155,7 @@ class EventSpeakerInviteService
|
||||
|
||||
public function portalUrl(QrCode $event, string $token): string
|
||||
{
|
||||
return route('qr.public.speaker.portal', [
|
||||
'shortCode' => $event->short_code,
|
||||
'token' => $token,
|
||||
]);
|
||||
return $event->publicPath('speaker/'.$token);
|
||||
}
|
||||
|
||||
/** @param array<string, mixed> $session */
|
||||
@@ -222,12 +213,21 @@ class EventSpeakerInviteService
|
||||
return $assignments;
|
||||
}
|
||||
|
||||
/** @param array<string, mixed> $speaker */
|
||||
private function deliverInvite(QrCode $event, User $owner, array $speaker, string $source): bool
|
||||
/** @return array{ok: true}|array{ok: false, error: string} */
|
||||
private function deliverInvite(QrCode $event, User $owner, array $speaker, string $source): array
|
||||
{
|
||||
$email = trim((string) ($speaker['email'] ?? ''));
|
||||
if ($email === '') {
|
||||
return false;
|
||||
return ['ok' => false, 'error' => 'Add a valid email address for this speaker before sending an invitation.'];
|
||||
}
|
||||
|
||||
$ownerRef = trim((string) ($owner->public_id ?? ''));
|
||||
if ($ownerRef === '') {
|
||||
return ['ok' => false, 'error' => 'Could not resolve the event owner account for sending email.'];
|
||||
}
|
||||
|
||||
if (! app(\App\Services\Billing\PlatformEmailClient::class)->isConfigured()) {
|
||||
return ['ok' => false, 'error' => 'Outbound email is not configured on this Events instance.'];
|
||||
}
|
||||
|
||||
$token = (string) ($speaker['invite_token'] ?? '');
|
||||
@@ -239,7 +239,7 @@ class EventSpeakerInviteService
|
||||
$portalUrl = $this->portalUrl($event, $token);
|
||||
|
||||
$sent = $this->email->sendSpeakerInvite(
|
||||
$owner->public_id,
|
||||
$ownerRef,
|
||||
$email,
|
||||
$eventName,
|
||||
$portalUrl,
|
||||
@@ -247,12 +247,27 @@ class EventSpeakerInviteService
|
||||
);
|
||||
|
||||
if (! $sent) {
|
||||
return false;
|
||||
return [
|
||||
'ok' => false,
|
||||
'error' => 'The invitation email could not be sent. Check your Ladill wallet balance and try again.',
|
||||
];
|
||||
}
|
||||
|
||||
$this->persistSpeakerInviteMeta($event, $email, $token, $source);
|
||||
|
||||
return true;
|
||||
return ['ok' => true];
|
||||
}
|
||||
|
||||
/** @return array<string, mixed>|null */
|
||||
private function findSpeakerByEmail(QrCode $event, string $email): ?array
|
||||
{
|
||||
foreach ($this->rosterWithInviteState($event) as $speaker) {
|
||||
if (strcasecmp((string) ($speaker['email'] ?? ''), $email) === 0) {
|
||||
return $speaker;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private function persistSpeakerInviteMeta(QrCode $event, string $email, string $token, string $source): void
|
||||
|
||||
Reference in New Issue
Block a user