Add per-customer SMS and Bird Integrations for event messaging.
Deploy Ladill Events / deploy (push) Successful in 28s
Deploy Ladill Events / deploy (push) Successful in 28s
Attendee and speaker comms use encrypted tenant relay credentials and skip platform-key fallback and Bird wallet double-debit. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -182,8 +182,8 @@ class AttendeeController extends Controller
|
||||
]);
|
||||
|
||||
$preview = $this->comms->preview($event, $validated['mode']);
|
||||
if (! $preview['affordable']) {
|
||||
return back()->with('error', 'Insufficient wallet balance. Add funds in Billing before sending.');
|
||||
if ($preview['integrations_error'] ?? null) {
|
||||
return back()->with('error', $preview['integrations_error']);
|
||||
}
|
||||
|
||||
if ($preview['recipients'] === 0) {
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Qr;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\Messaging\CustomerSmsClient;
|
||||
use App\Services\Messaging\MessagingCredentialsService;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class IntegrationsController extends Controller
|
||||
{
|
||||
public function edit(MessagingCredentialsService $credentials): View
|
||||
{
|
||||
$account = ladill_account();
|
||||
|
||||
return view('qr.account.integrations', [
|
||||
'account' => $account,
|
||||
'credential' => $credentials->forOwner((string) $account->public_id),
|
||||
]);
|
||||
}
|
||||
|
||||
public function saveSms(Request $request, MessagingCredentialsService $credentials): RedirectResponse
|
||||
{
|
||||
$account = ladill_account();
|
||||
$ownerRef = (string) $account->public_id;
|
||||
|
||||
$data = $request->validate([
|
||||
'sms_api_key' => ['required', 'string', 'max:200'],
|
||||
'sms_sender_id' => ['required', 'string', 'max:11'],
|
||||
]);
|
||||
|
||||
$result = $credentials->validateAndSaveSms(
|
||||
$ownerRef,
|
||||
$data['sms_api_key'],
|
||||
$data['sms_sender_id'],
|
||||
);
|
||||
|
||||
if (! ($result['ok'] ?? false)) {
|
||||
return back()->withInput()->with('error', $result['error'] ?? 'Could not save SMS credentials.');
|
||||
}
|
||||
|
||||
return back()->with('success', 'Ladill SMS connected. Outbound attendee SMS will use your key and sender ID.');
|
||||
}
|
||||
|
||||
public function disconnectSms(MessagingCredentialsService $credentials): RedirectResponse
|
||||
{
|
||||
$account = ladill_account();
|
||||
$credentials->disconnectSms((string) $account->public_id);
|
||||
|
||||
return back()->with('success', 'Ladill SMS disconnected.');
|
||||
}
|
||||
|
||||
public function saveBird(Request $request, MessagingCredentialsService $credentials): RedirectResponse
|
||||
{
|
||||
$account = ladill_account();
|
||||
$ownerRef = (string) $account->public_id;
|
||||
|
||||
$data = $request->validate([
|
||||
'bird_api_key' => ['required', 'string', 'max:200'],
|
||||
'bird_from_email' => ['required', 'email', 'max:255'],
|
||||
'bird_from_name' => ['nullable', 'string', 'max:100'],
|
||||
]);
|
||||
|
||||
$result = $credentials->validateAndSaveBird(
|
||||
$ownerRef,
|
||||
$data['bird_api_key'],
|
||||
$data['bird_from_email'],
|
||||
$data['bird_from_name'] ?? null,
|
||||
);
|
||||
|
||||
if (! ($result['ok'] ?? false)) {
|
||||
return back()->withInput()->with('error', $result['error'] ?? 'Could not save Bird credentials.');
|
||||
}
|
||||
|
||||
return back()->with('success', 'Ladill Bird connected. Outbound attendee email will use your key and from address.');
|
||||
}
|
||||
|
||||
public function disconnectBird(MessagingCredentialsService $credentials): RedirectResponse
|
||||
{
|
||||
$account = ladill_account();
|
||||
$credentials->disconnectBird((string) $account->public_id);
|
||||
|
||||
return back()->with('success', 'Ladill Bird disconnected.');
|
||||
}
|
||||
|
||||
public function previewSenders(Request $request, CustomerSmsClient $sms): JsonResponse
|
||||
{
|
||||
$data = $request->validate([
|
||||
'sms_api_key' => ['required', 'string', 'max:200'],
|
||||
]);
|
||||
|
||||
$result = $sms->senders(trim($data['sms_api_key']));
|
||||
if (! ($result['ok'] ?? false)) {
|
||||
return response()->json(['error' => $result['error'] ?? 'Could not load senders.'], 422);
|
||||
}
|
||||
|
||||
return response()->json($result['data'] ?? []);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user