Add speaker invitations with portal page and programme host picker.
Deploy Ladill Events / deploy (push) Successful in 47s
Deploy Ladill Events / deploy (push) Successful in 47s
Speakers require email, get a personal holding page with programme and stage links, auto-invites when programme hosts are saved, and manual send for events without a schedule; also fix wallet copy on event create and anchor attendee comms. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -51,7 +51,16 @@ class QrPayloadValidator
|
||||
$merged['destination_url'] = $merged['url'];
|
||||
}
|
||||
|
||||
return $this->validateForCreate($qrCode->type, $merged);
|
||||
$result = $this->validateForCreate($qrCode->type, $merged);
|
||||
|
||||
if ($qrCode->type === QrCode::TYPE_EVENT && isset($result['content']['speakers'])) {
|
||||
$result['content']['speakers'] = $this->mergeSpeakerInviteMeta(
|
||||
(array) ($qrCode->content()['speakers'] ?? []),
|
||||
$result['content']['speakers'],
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/** @param array<string, mixed> $input */
|
||||
@@ -354,7 +363,7 @@ class QrPayloadValidator
|
||||
return array_values($normalized);
|
||||
}
|
||||
|
||||
/** @return list<array{name: string, email: string, role: string, bio: string}> */
|
||||
/** @return list<array{name: string, email: string, role: string, bio: string, invite_token?: string, invited_at?: string, invite_source?: string}> */
|
||||
private function normalizeSpeakers(mixed $speakers, array $input): array
|
||||
{
|
||||
$rows = is_array($speakers) ? $speakers : (array) ($input['speakers'] ?? []);
|
||||
@@ -371,17 +380,57 @@ class QrPayloadValidator
|
||||
}
|
||||
|
||||
$email = trim((string) ($speaker['email'] ?? ''));
|
||||
$normalized[] = [
|
||||
if ($email === '' || ! filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
||||
throw new RuntimeException('Each speaker must have a valid email address.');
|
||||
}
|
||||
|
||||
$row = [
|
||||
'name' => mb_substr($name, 0, 120),
|
||||
'email' => filter_var($email, FILTER_VALIDATE_EMAIL) ? $email : '',
|
||||
'email' => $email,
|
||||
'role' => mb_substr(trim((string) ($speaker['role'] ?? '')), 0, 80),
|
||||
'bio' => mb_substr(trim((string) ($speaker['bio'] ?? '')), 0, 500),
|
||||
];
|
||||
|
||||
foreach (['invite_token', 'invited_at', 'invite_source'] as $key) {
|
||||
if (! empty($speaker[$key])) {
|
||||
$row[$key] = $speaker[$key];
|
||||
}
|
||||
}
|
||||
|
||||
$normalized[] = $row;
|
||||
}
|
||||
|
||||
return array_values($normalized);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<array<string, mixed>> $previous
|
||||
* @param list<array<string, mixed>> $current
|
||||
* @return list<array<string, mixed>>
|
||||
*/
|
||||
private function mergeSpeakerInviteMeta(array $previous, array $current): array
|
||||
{
|
||||
$byEmail = collect($previous)
|
||||
->filter(fn ($row) => is_array($row) && filled($row['email'] ?? null))
|
||||
->keyBy(fn ($row) => strtolower((string) $row['email']));
|
||||
|
||||
return collect($current)->map(function (array $speaker) use ($byEmail) {
|
||||
$email = strtolower((string) ($speaker['email'] ?? ''));
|
||||
$prev = $byEmail->get($email);
|
||||
if (! $prev) {
|
||||
return $speaker;
|
||||
}
|
||||
|
||||
foreach (['invite_token', 'invited_at', 'invite_source'] as $key) {
|
||||
if (! empty($prev[$key]) && empty($speaker[$key])) {
|
||||
$speaker[$key] = $prev[$key];
|
||||
}
|
||||
}
|
||||
|
||||
return $speaker;
|
||||
})->values()->all();
|
||||
}
|
||||
|
||||
/** @param array<int, array{price: float}> $tiers */
|
||||
private function eventHasPaidTier(array $tiers): bool
|
||||
{
|
||||
@@ -417,13 +466,24 @@ class QrPayloadValidator
|
||||
if ($itemTitle === '') {
|
||||
continue;
|
||||
}
|
||||
$hostSpeakerEmail = strtolower(trim((string) ($item['host_speaker_email'] ?? '')));
|
||||
if ($hostSpeakerEmail !== '' && ! filter_var($hostSpeakerEmail, FILTER_VALIDATE_EMAIL)) {
|
||||
$hostSpeakerEmail = '';
|
||||
}
|
||||
|
||||
$host = mb_substr(trim((string) ($item['host'] ?? '')), 0, 120);
|
||||
if ($host === '' && $hostSpeakerEmail !== '') {
|
||||
$host = mb_substr(strtok($hostSpeakerEmail, '@') ?: $hostSpeakerEmail, 0, 120);
|
||||
}
|
||||
|
||||
$items[] = [
|
||||
'ref' => 'day'.$dayIndex.'-item'.$itemIndex,
|
||||
'time' => mb_substr(trim((string) ($item['time'] ?? '')), 0, 40),
|
||||
'title' => mb_substr($itemTitle, 0, 140),
|
||||
'description' => mb_substr(trim((string) ($item['description'] ?? '')), 0, 400),
|
||||
'location' => mb_substr(trim((string) ($item['location'] ?? '')), 0, 120),
|
||||
'host' => mb_substr(trim((string) ($item['host'] ?? '')), 0, 120),
|
||||
'ref' => 'day'.$dayIndex.'-item'.$itemIndex,
|
||||
'time' => mb_substr(trim((string) ($item['time'] ?? '')), 0, 40),
|
||||
'title' => mb_substr($itemTitle, 0, 140),
|
||||
'description' => mb_substr(trim((string) ($item['description'] ?? '')), 0, 400),
|
||||
'location' => mb_substr(trim((string) ($item['location'] ?? '')), 0, 120),
|
||||
'host' => $host,
|
||||
'host_speaker_email' => $hostSpeakerEmail,
|
||||
];
|
||||
}
|
||||
if (empty($items) && trim((string) ($day['label'] ?? '')) === '') {
|
||||
|
||||
Reference in New Issue
Block a user