@extends('layouts.app') @section('title', '跨組織訊息') @section('content')
{{-- 左側:跨組織對話清單 --}}
跨組織對話
  • 載入中…
已隱藏的跨組織聊天 (0)
    {{-- 右側:對話串 --}}
    @if($conversation->isGroup())
    @if($conversation->avatarUrl()) @else @endif
    {{ $conversation->title ?? '未命名群組' }}
    {{ count($groupParticipants) }} 人
    @else
    {{ mb_substr($contact->name ?? '?', 0, 1) }}
    {{ $contact->name ?? $conversation->peer_federated_id }}
    {{ $conversation->peerOrgId() }} @if($contact?->department) {{ $contact->department }} @endif
    @endif
    @if($conversation->isGroup()) @endif
    聊天背景
    @unless($conversation->isGroup()) @endunless
    —
    @php($participantNames = collect($groupParticipants)->keyBy('federated_id')) @forelse($messages as $m) @php($senderName = $conversation->isGroup() ? ($participantNames->get($m->from_federated_id)['name'] ?? $m->from_federated_id) : ($contact->name ?? '對方')) @php($readCount = $conversation->isGroup() ? collect($groupReadStates)->filter(fn ($r) => $r['read_at'] && \Illuminate\Support\Carbon::parse($r['read_at'])->gte($m->created_at))->count() : null)
    recalled_at) data-recalled="1" @endif @if($m->encrypted && !$m->recalled_at) data-encrypted="1" data-body="{{ $m->body }}" data-iv="{{ $m->iv }}" data-key-version="{{ $m->key_version }}" @endif > @if($m->direction !== 'outbound')
    {{ mb_substr($senderName, 0, 1) }}
    @endif
    @if($conversation->isGroup() && $m->direction !== 'outbound')
    {{ $senderName }}
    @endif
    @if($m->recalled_at) 此訊息已收回 @else @if($m->reply_to)
    reply_to['encrypted'] && !$m->reply_to['recalled']) data-reply-encrypted="1" data-reply-type="{{ $m->reply_to['type'] }}" data-reply-body="{{ $m->reply_to['body'] }}" data-reply-iv="{{ $m->reply_to['iv'] }}" data-reply-key-version="{{ $m->reply_to['key_version'] }}" @endif > @php($replySenderName = $m->reply_to['direction'] === 'outbound' ? '你' : ($conversation->isGroup() ? ($participantNames->get($m->reply_to['from_federated_id'])['name'] ?? $m->reply_to['from_federated_id']) : ($contact->name ?? '對方')))
    {{ $replySenderName }}
    @if($m->reply_to['recalled']) 此訊息已收回 @elseif($m->reply_to['encrypted']) 解密中… @else {{ match($m->reply_to['type']) { 'image' => '[圖片]', 'sticker' => '[貼圖]', 'location' => '[位置]', default => \Illuminate\Support\Str::limit($m->reply_to['body'], 60) } }} @endif
    @endif @if($m->encrypted)
    解密中…
    @elseif($m->type === 'image') 圖片 @elseif($m->type === 'sticker') 貼圖 @elseif($m->type === 'location') @php($loc = json_decode($m->body ?? '{}', true)) 查看位置 @else
    {{ $m->body }}
    @endif @endif
    @if($m->direction === 'outbound' && !$m->recalled_at) @if($conversation->isGroup()) @if(count($groupReadStates) > 0) {{ $readCount }}/{{ count($groupReadStates) }} 已讀 · @endif @else {{ ($peerReadAt && $m->created_at->lte($peerReadAt)) ? '已讀' : '未讀' }} · @endif @endif {{ $m->created_at->format('H:i') }} @if($m->edited_at && !$m->recalled_at) · 已編輯 @endif
    @empty
    還沒有訊息,說聲哈囉吧。
    @endforelse
    {{-- 回覆/編輯中的提示條,蓋在輸入框正上方 --}}
    {{-- 跟本地聊天室 index.blade.php 一樣:貼圖/表情共用同一個彈出面板、 同一顆按鈕,靠上面兩個分頁切換,預設打開時停在「貼圖」分頁。 --}}
    @if($conversation->isGroup()) {{-- 群組資訊 Modal:成員清單、邀請/移除成員、更新金鑰、離開群組、改名/換大頭照 ——仿照本地群組 index.blade.php 的 groupInfoModal/addParticipantModal, 但成員來自不同組織,多顯示組織徽章。改名/換照片只有 owner 能做(跟本地 ConversationPolicy::manage() 同一套限制,見 FederatedChatController:: updateGroup()),存好之後會透過訊息通道廣播給其他組織一起更新 (FederationClientService::sendGroupUpdate())。 --}} {{-- 邀請成員 Modal:只能搜尋已加入通訊錄的跨組織聯絡人(跟建群組時同一個限制)。 --}} @endif @endsection