diff --git a/src/components/ChatMessageItem.tsx b/src/components/ChatMessageItem.tsx index 0e2c305..c18bd98 100644 --- a/src/components/ChatMessageItem.tsx +++ b/src/components/ChatMessageItem.tsx @@ -12,7 +12,7 @@ export interface ChatMessage { mac: string; encrypted_message: string; message_count: number; - origin_path_array: Array<[string, string]>; // Array of [origin, path] tuples + origin_key_path_array: Array<[string, string, string]>; // Array of [origin, pubkey, path] tuples } function formatHex(hex: string): string { @@ -65,8 +65,8 @@ export default function ChatMessageItem({ msg, showErrorRow }: { msg: ChatMessag return () => { cancelled = true; }; }, [msg.encrypted_message, msg.mac, msg.channel_hash, knownKeysString, knownKeys]); - const originPathArray = msg.origin_path_array && msg.origin_path_array.length > 0 ? msg.origin_path_array : []; - const originsCount = originPathArray.length; + const originKeyPathArray = msg.origin_key_path_array && msg.origin_key_path_array.length > 0 ? msg.origin_key_path_array : []; + const originsCount = originKeyPathArray.length; const OriginsBox = () => (
@@ -86,15 +86,18 @@ export default function ChatMessageItem({ msg, showErrorRow }: { msg: ChatMessag {originsExpanded && originsCount > 0 && (
- {originPathArray.map(([origin, path], index) => { + {originKeyPathArray.map(([origin, pubkey, path], index: number) => { // Parse path into 2-character slices const pathSlices = path.match(/.{1,2}/g) || []; const formattedPath = pathSlices.join(' '); + // Get first 2 characters of the pubkey + const pubkeyPrefix = pubkey.substring(0, 2); return (
{origin} {formattedPath} + ({pubkeyPrefix})
); })} diff --git a/src/lib/clickhouse/actions.ts b/src/lib/clickhouse/actions.ts index 32e58a0..55638a5 100644 --- a/src/lib/clickhouse/actions.ts +++ b/src/lib/clickhouse/actions.ts @@ -76,7 +76,7 @@ export async function getLatestChatMessages({ limit = 20, before, after, channel } const whereClause = where.length > 0 ? `WHERE ${where.join(' AND ')}` : ''; - const query = `SELECT ingest_timestamp, mesh_timestamp, channel_hash, mac, hex(encrypted_message) AS encrypted_message, message_count, origin_path_array FROM meshcore_public_channel_messages ${whereClause} ORDER BY ingest_timestamp DESC LIMIT {limit:UInt32}`; + const query = `SELECT ingest_timestamp, mesh_timestamp, channel_hash, mac, hex(encrypted_message) AS encrypted_message, message_count, origin_key_path_array FROM meshcore_public_channel_messages ${whereClause} ORDER BY ingest_timestamp DESC LIMIT {limit:UInt32}`; const resultSet = await clickhouse.query({ query, query_params: params, format: 'JSONEachRow' }); const rows = await resultSet.json(); return rows as Array<{ @@ -86,7 +86,7 @@ export async function getLatestChatMessages({ limit = 20, before, after, channel mac: string; encrypted_message: string; message_count: number; - origin_path_array: Array<[string, string]>; // Array of [origin, path] tuples + origin_key_path_array: Array<[string, string, string]>; // Array of [origin, pubkey, path] tuples }>; } catch (error) { console.error('ClickHouse error in getLatestChatMessages:', error);