{{-- Connected WABA + Twilio channel rows. Lives in its own partial because #devices-list is REPLACED wholesale by the AJAX refresh (user-devices-index.js: list.innerHTML = data.cards). Rendering these rows only in index.blade meant every refresh wiped them — the page showed 3 channels, then dropped to 1. DevicesController appends this partial to `cards` so a refresh rebuilds all three, and card view (which clones source.children) keeps seeing them. Needs: $multiEngine, $connectedChannels. --}} @if ($multiEngine) {{-- Connected WABA + Twilio accounts appended as rows in the SAME table (same columns as the Baileys device rows above). --}} @foreach ($connectedChannels->where('engine', '!=', 'baileys') as $ch) @php $b = $chBadge[$ch['engine']] ?? ['label' => $ch['engine'], 'cls' => 'bg-paper-100 text-ink-700']; @endphp
{{ $ch['label'] }}
{{ $b['label'] }}
{{ $ch['phone'] ? mask_phone('+' . $ch['phone']) : '—' }}
—
{{ __('live') }}
—
@php // A row can hold valid credentials while Meta has the number on the // RETIRED On-Premises API — every send then dies with 133010 while // this badge says "Connected". Trust Meta's platform_type over our // own row state. COEXISTENCE / SMB_APP are supported, so only the // one Meta can no longer deliver for is called out. $chPlatform = $ch['engine'] === 'waba' ? ($wabaPlatform[$ch['id']] ?? '') : ''; $chDead = $chPlatform === 'ON_PREMISE'; @endphp
@if ($chDead) {{ __('Not on Cloud API') }} {{ __('On-Premises (retired) — cannot send. Migrate in WhatsApp Manager.') }} @else {{ __('Connected') }} @if ($ch['engine'] === 'waba') @include('user.devices._inbound_badge', ['wired' => ($wabaInbound[$ch['id']] ?? null)]) @endif @endif
@if ($ch['engine'] === 'waba') {{-- Icon actions (match the device-row icon style): Health · Manage · Disconnect · Remove. $ch['id'] is the WaProviderConfig id. --}} {{-- Fix inbound = re-apply the webhook override + verify incoming messages route here. --}}
@csrf
{{-- Register button — HIDDEN. POST /{phone_number_id}/register is rejected for SMB numbers: Meta answers "(#100) Register endpoint is not available for SMB businesses". So for those the button can only ever fail, and it surfaced a red "WhatsApp connection could not be completed" banner that reads like OUR bug when it is Meta's account state. The route + WabaNumberRegistrar are left intact — un-comment this block if Meta ever opens /register to SMB numbers.
@csrf
--}} {{-- Disconnect = wipe credentials, keep the row. --}}
@csrf @method('DELETE')
{{-- Remove = permanently delete this WABA number from the workspace. --}}
@csrf @method('DELETE')
@elseif ($ch['engine'] === 'twilio') {{-- Remove = permanently delete this Twilio account from the workspace. --}}
@csrf @method('DELETE')
@endif
@endforeach @endif {{-- Instagram accounts linked from the Instaflow install. Rendered whenever this workspace has linked IG accounts (independent of the WA engine count) — the account itself lives on Instaflow; this row is its mirror. Needs: $instagramAccounts, $instaflowUrl. --}} @foreach (($instagramAccounts ?? collect()) as $ig) @php $igHandle = '@' . ltrim((string) ($ig->username ?: $ig->name), '@'); $igLive = ($ig->status ?? 'connected') === 'connected'; // Instagram tokens live 60 days and CANNOT be // refreshed once lapsed — a silent expiry means // sends fail with no visible cause. Warn while // there is still time to act. Null expiry (legacy // rows, remote Instaflow) shows nothing. // Whole CALENDAR days, not a fractional diff. floor() on // a fraction got both edges wrong: a token 8.0 days out // read as 7 (warned a day early), and one expiring TODAY // came out -1 and showed nothing at all — the single case // the warning exists for. $igExpiresAt = $ig->token_expires_at ?? null; $igDaysLeft = $igExpiresAt ? (int) now()->startOfDay()->diffInDays($igExpiresAt->copy()->startOfDay(), false) : null; $igExpiring = $igDaysLeft !== null && $igDaysLeft >= 0 && $igDaysLeft <= 7; @endphp
@if (!empty($ig->avatar)) {{-- Instagram profile-pic URLs are signed and expire (403 "URL signature expired"). When that happens, hide the broken image and reveal an initials chip instead of a broken-image icon. --}} @else @endif
{{ $ig->name ?: $igHandle }}
{{ __('Instagram') }}
{{ $igHandle }}
—
{{ $ig->synced_at ? $ig->synced_at->diffForHumans() : __('live') }}
—
@if ($igLive) {{ __('Connected') }} {{-- Countdown only inside the last week. Earlier than that it is noise; later than that the account is already retired above. --}} @if ($igExpiring)
{{ $igDaysLeft <= 0 ? __('expires today') : trans_choice('expires in :count day|expires in :count days', $igDaysLeft, ['count' => $igDaysLeft]) }}
@endif @else {{ __('Needs re-auth') }} @endif
@if (!empty($ig->native)) {{-- Native add-on account — actions hit the local /instagram/* routes. --}} {{-- Health — webhook diagnostics + inbound status + Fix inbound. --}} {{-- Refresh — re-pull the account profile from the Graph API. --}}
@csrf
{{-- Disconnect — remove the local account. Routes through the core unlink so BOTH the native row AND the dashboard mirror (workspace_ig_accounts) are cleared — otherwise the account kept showing on the dashboard with an empty @handle. --}}
@csrf @method('DELETE')
@else {{-- Manage — open the account on the Instaflow app (new tab). --}} @if (!empty($instaflowUrl)) @endif {{-- Refresh — re-sync the mirror's profile from Instaflow. --}}
@csrf
{{-- Disconnect — drop this workspace's link AND, when it's the last account, purge the mirrored inbox so no Instagram data lingers. --}}
@csrf @method('DELETE')
@endif
@endforeach {{-- Facebook Pages (core channel). Woven into the SAME table as rows — exactly like the Instagram accounts above — instead of a separate card. Rendered whenever the workspace has connected Pages, independent of the WA engine count. Actions hit the local /facebook/* routes. The device cell uses the Facebook-blue glyph; the "Mobile number" column shows @username or the Page category. Needs: $hasFacebook, $facebookPages. --}} @if (! empty($hasFacebook)) @foreach (($facebookPages ?? collect()) as $fp) @php $fbLive = $fp->isLive(); $fbSub = $fp->username ? '@' . ltrim((string) $fp->username, '@') : ($fp->category ?: __('Facebook Page')); @endphp
@if ($fp->picture_url) {{-- Page picture URLs are signed and can expire; on error hide the broken image and reveal the Facebook glyph chip instead. --}} @else @endif
{{ $fp->name ?: $fp->page_id }}
{{ __('Facebook') }}
{{ $fbSub }}
—
{{ $fp->fan_count ? number_format($fp->fan_count) . ' ' . __('followers') : __('live') }}
—
@if ($fbLive) {{ __('Live') }} @else {{ __('Reconnect') }} @endif
{{-- Reconnect — only when the Page token has expired / disconnected. --}} @unless ($fbLive) @endunless {{-- Check integration — asks Meta whether this Page is subscribed to the `messages` webhook field (the usual reason DMs never arrive). Read-only. --}}
@csrf
{{-- Re-subscribe — re-apply the Page webhook fields (adds `messages`). --}}
@csrf
{{-- Refresh — re-pull the Page profile from the Graph API. --}}
@csrf
{{-- Remove — disconnect this Page (its inbox threads stay). --}}
@csrf @method('DELETE')
@endforeach @endif {{-- SMS numbers (Twilio / MSG91) — same table, own rows, like Facebook/Instagram/TikTok. Actions go to /sms. Needs: $smsSenders. --}} @foreach (($smsSenders ?? collect()) as $sm) @php $smMeta = is_array($sm->meta_json) ? $sm->meta_json : []; $smProv = strtolower($smMeta['sms_provider'] ?? 'twilio'); $smLive = $sm->status === \App\Models\WaProviderConfig::STATUS_CONNECTED; @endphp
{{ $sm->display_label ?: $sm->phone_number }}
{{ $smProv === 'msg91' ? 'SMS · MSG91' : 'SMS · Twilio' }}
{{ $sm->phone_number }}
—
{{ __('live') }}
—
@if ($smLive) {{ __('Connected') }} @else {{ __('Inactive') }} @endif
@csrf @method('DELETE')
@endforeach {{-- Linked email mailboxes (via the connected MailTrixy install). Same table, own rows, like SMS/Facebook/Instagram/TikTok — the mailbox lives on MailTrixy and this is the workspace's mirror row, so "Refresh" re-pulls its details and "Unlink" only drops the mirror (the mailbox itself is untouched). Needs: $emailAccounts (computed in index.blade.php). --}} @foreach (($emailAccounts ?? collect()) as $ea) @php $eaLive = strtolower((string) $ea->status) === 'connected'; $eaProv = strtolower((string) $ea->provider); $eaLabel = $eaProv === '' ? __('Email') : __('Email') . ' · ' . ucfirst($eaProv); @endphp
{{ $ea->name ?: $ea->email }}
{{ $eaLabel }}
{{ $ea->email }}
—
{{ $ea->synced_at ? $ea->synced_at->diffForHumans() : __('live') }}
—
@if ($eaLive) {{ __('Connected') }} @else {{ __('Inactive') }} @endif
{{-- Sync pulls this mailbox's mail from the email server. The live push only announces NEW messages and gives up after 8s with no retry, so this is how history arrives and how a dropped message is recovered. Safe to press twice — import dedupes on the remote message id. --}}
@csrf
@csrf @method('DELETE')
@endforeach {{-- Native email mailboxes (own IMAP/SMTP — email_accounts). Own rows in the same table. Check / pause / remove happen in the connect modal, opened by Manage (data-email-connect-open). Needs: $nativeEmailAccounts. --}} @foreach (($nativeEmailAccounts ?? collect()) as $nea) @php $neaStatus = ! $nea->active ? 'paused' : (trim((string) $nea->last_error) !== '' ? 'error' : 'connected'); $neaProv = strtolower((string) $nea->provider); $neaLabel = __('Email') . ($neaProv && $neaProv !== 'other' ? ' · ' . ucfirst($neaProv) : ' · IMAP'); @endphp
{{ $nea->display_name ?: $nea->email_address }}
{{ $neaLabel }}
{{ $nea->email_address }}
—
{{ $nea->last_inbound_at ? $nea->last_inbound_at->diffForHumans() : __('—') }}
—
@if ($neaStatus === 'connected') {{ __('Connected') }} @elseif ($neaStatus === 'error') {{ __('Error') }} @else {{ __('Paused') }} @endif
@endforeach {{-- TikTok accounts (core channel). Woven into the SAME table as rows — exactly like Facebook/Instagram — when the workspace has connected accounts. Actions hit the local /tiktok/* routes. Needs: $hasTiktok, $tiktokAccounts. --}} @if (! empty($hasTiktok)) @foreach (($tiktokAccounts ?? collect()) as $ta) @php $ttLive = $ta->isLive(); $ttSub = $ta->username ? '@' . ltrim((string) $ta->username, '@') : __('TikTok account'); @endphp
@if ($ta->avatar_url) @else @endif
{{ $ta->display_name ?: $ttSub }}
{{ __('TikTok') }}
{{ $ttSub }}
—
{{ $ta->follower_count ? number_format($ta->follower_count) . ' ' . __('followers') : __('live') }}
—
@if ($ttLive) {{ __('Live') }} @else {{ __('Reconnect') }} @endif
@unless ($ttLive) @endunless
@csrf
@csrf @method('DELETE')
@endforeach @endif {{-- Threads (Meta) accounts (core channel). Woven into the SAME table as rows — exactly like TikTok/Facebook/Instagram — when the workspace has connected accounts. Actions hit the /threads routes. Needs: $hasThreads, $threadsAccounts. --}} @if (! empty($hasThreads)) @foreach (($threadsAccounts ?? collect()) as $tha) @php $thLive = method_exists($tha, 'isLive') ? $tha->isLive() : (($tha->status ?? '') === 'connected'); $thHandle = $tha->username ? '@' . ltrim((string) $tha->username, '@') : __('Threads account'); $thIcon = 'M12.19 2c5.52 0 9.3 3.6 9.55 9.02.01.26.01.52.01.98s0 .72-.01.98C21.49 18.4 17.71 22 12.19 22h-.01C6.6 22 2.75 18.3 2.5 12.76 2.49 12.5 2.49 12.25 2.49 12s0-.26.01-.52C2.75 5.6 6.6 2 12.18 2h.01Zm.02 3.45h-.03c-1.9 0-3.49.8-4.47 2.26l1.37.95c.73-1.09 1.88-1.32 2.72-1.32h.03c1.05.01 1.84.3 2.36.89.37.42.62 1.01.75 1.75a13.7 13.7 0 0 0-3.02-.14c-1.46.08-2.7.53-3.58 1.29-.93.8-1.4 1.9-1.33 3.08.07 1.23.69 2.28 1.75 2.97.9.58 2.06.86 3.26.8 1.59-.09 2.84-.69 3.73-1.79.66-.83 1.09-1.92 1.28-3.27.76.45 1.32 1.04 1.63 1.75.53 1.2.56 3.18-1.09 4.8-1.44 1.41-3.17 2.02-5.8 2.04-2.9-.02-5.1-.93-6.54-2.72C4.31 17.5 3.62 15.08 3.6 12c.03-3.09.72-5.5 2.06-7.16 1.43-1.78 3.63-2.7 6.54-2.72h.01Zm.46 6.86-.4-.01c-1.37 0-2.3.63-2.3 1.57 0 .62.5 1.3 1.72 1.3h.07c1.3-.07 2.2-.95 2.33-2.66a6.2 6.2 0 0 0-1.42-.19Z'; @endphp
@if ($tha->profile_pic_url) @else @endif
{{ $tha->name ?: $thHandle }}
{{ __('Threads') }}
{{ $thHandle }}
—
{{ __('live') }}
—
@if ($thLive) {{ __('Connected') }} @else {{ __('Reconnect') }} @endif
@unless ($thLive) @endunless
@csrf @method('DELETE')
@endforeach @endif {{-- LinkedIn accounts (core publishing channel). Same rows as Threads. Actions hit the /linkedin routes. Needs: $hasLinkedin, $linkedinAccounts. --}} @if (! empty($hasLinkedin)) @foreach (($linkedinAccounts ?? collect()) as $lia) @php $liLive = method_exists($lia, 'isLive') ? $lia->isLive() : (($lia->status ?? '') === 'connected'); $liLabel = method_exists($lia, 'label') ? $lia->label() : ($lia->name ?: 'LinkedIn'); $liKind = ($lia->type ?? 'person') === 'organization' ? __('Company Page') : __('Profile'); @endphp
@if ($lia->profile_pic_url) @else @endif
{{ $liLabel }}
{{ __('LinkedIn') }}
{{ $liKind }}
—
{{ __('publishing') }}
—
@if ($liLive) {{ __('Connected') }} @else {{ __('Reconnect') }} @endif
@unless ($liLive) @endunless
@csrf @method('DELETE')
@endforeach @endif {{-- X (Twitter) accounts (core publishing channel). Needs: $hasX, $xAccounts. --}} @if (! empty($hasX)) @foreach (($xAccounts ?? collect()) as $xa) @php $xLive = method_exists($xa, 'isLive') ? $xa->isLive() : (($xa->status ?? '') === 'connected'); $xHandle = $xa->username ? '@' . ltrim((string) $xa->username, '@') : __('X account'); @endphp
@if ($xa->profile_image_url) @else @endif
{{ $xa->name ?: $xHandle }}
{{ __('X (Twitter)') }}
{{ $xHandle }}
—
{{ __('publishing') }}
—
@if ($xLive) {{ __('Connected') }} @else {{ __('Reconnect') }} @endif
@unless ($xLive) @endunless
@csrf @method('DELETE')
@endforeach @endif