false, 'ERROR' => 'method_not_allowed'], 405); } $channelId = (int) ($_GET['ChannelID'] ?? 0); if ($channelId <= 0) { jsonResponse(['OK' => false, 'ERROR' => 'channel_id_required']); } // Verify channel exists $channel = queryOne("SELECT ID FROM Hub_Channels WHERE ID = ?", [$channelId]); if (!$channel) { jsonResponse(['OK' => false, 'ERROR' => 'channel_not_found'], 404); } $members = queryTimed( "SELECT m.AgentAddress, m.Role, m.JoinedAt, m.LastViewedAt, a.AgentName, a.AgentType, a.Role AS AgentRole, a.IsActive FROM Hub_ChannelMembers m LEFT JOIN Sprinter_Agents a ON a.FullAddress = m.AgentAddress WHERE m.ChannelID = ? ORDER BY m.JoinedAt ASC", [$channelId] ); $list = []; foreach ($members as $m) { $list[] = [ 'AgentAddress' => $m['AgentAddress'], 'AgentName' => $m['AgentName'] ?? '', 'AgentType' => $m['AgentType'] ?? '', 'AgentRole' => $m['AgentRole'] ?? '', 'IsActive' => isset($m['IsActive']) ? (bool) $m['IsActive'] : null, 'ChannelRole' => $m['Role'], 'JoinedAt' => toISO8601($m['JoinedAt']), 'LastViewedAt' => $m['LastViewedAt'] ? toISO8601($m['LastViewedAt']) : null, ]; } jsonResponse(['OK' => true, 'Members' => $list, 'Total' => count($list)]);