Feat: Agregar sistema de alias para chats
All checks were successful
build-and-deploy / build-and-deploy (push) Successful in 1m10s
All checks were successful
build-and-deploy / build-and-deploy (push) Successful in 1m10s
- Agregar campo alias a tabla chats con migración 003 - Crear endpoint PUT /api/messages/:instanceId/:chatId/alias - Modificar MCP para priorizar alias sobre nombres automáticos - Crear modal ChatAliasModal para editar alias desde UI - Agregar botón de editar alias en ChatItem - Integrar modal en página de mensajes El alias permite asignar nombres personalizados a chats que tienen prioridad sobre los nombres de WhatsApp tanto en la interfaz como en el MCP para agentes IA.
This commit is contained in:
@@ -688,10 +688,10 @@ export async function handleToolCall(toolName: string, args: Record<string, any>
|
||||
|
||||
const result = await query(
|
||||
`SELECT
|
||||
c.id, c.jid, c.is_group, c.unread_count, c.last_message_at, c.last_message_type,
|
||||
c.id, c.jid, c.is_group, c.unread_count, c.last_message_at, c.last_message_type, c.alias,
|
||||
CASE
|
||||
WHEN c.is_group THEN COALESCE(gm.subject, c.name, c.jid)
|
||||
ELSE COALESCE(ct.name, ct.push_name, c.name, SPLIT_PART(c.jid, '@', 1))
|
||||
WHEN c.is_group THEN COALESCE(c.alias, gm.subject, c.name, c.jid)
|
||||
ELSE COALESCE(c.alias, ct.name, ct.push_name, c.name, SPLIT_PART(c.jid, '@', 1))
|
||||
END as name
|
||||
FROM chats c
|
||||
LEFT JOIN contacts ct ON c.instance_id = ct.instance_id AND c.jid = ct.jid
|
||||
@@ -708,6 +708,7 @@ export async function handleToolCall(toolName: string, args: Record<string, any>
|
||||
id: row.id,
|
||||
jid: row.jid,
|
||||
name: row.name,
|
||||
alias: row.alias,
|
||||
isGroup: row.is_group,
|
||||
unreadCount: row.unread_count || 0,
|
||||
lastMessageAt: row.last_message_at,
|
||||
@@ -725,10 +726,10 @@ export async function handleToolCall(toolName: string, args: Record<string, any>
|
||||
|
||||
const result = await query(
|
||||
`SELECT
|
||||
c.id, c.jid, c.is_group, c.unread_count, c.last_message_at, c.last_message_type,
|
||||
c.id, c.jid, c.is_group, c.unread_count, c.last_message_at, c.last_message_type, c.alias,
|
||||
CASE
|
||||
WHEN c.is_group THEN COALESCE(gm.subject, c.name, c.jid)
|
||||
ELSE COALESCE(ct.name, ct.push_name, c.name, SPLIT_PART(c.jid, '@', 1))
|
||||
WHEN c.is_group THEN COALESCE(c.alias, gm.subject, c.name, c.jid)
|
||||
ELSE COALESCE(c.alias, ct.name, ct.push_name, c.name, SPLIT_PART(c.jid, '@', 1))
|
||||
END as name,
|
||||
gm.participants as group_participants
|
||||
FROM chats c
|
||||
@@ -747,6 +748,7 @@ export async function handleToolCall(toolName: string, args: Record<string, any>
|
||||
id: chat.id,
|
||||
jid: chat.jid,
|
||||
name: chat.name,
|
||||
alias: chat.alias,
|
||||
isGroup: chat.is_group,
|
||||
unreadCount: chat.unread_count || 0,
|
||||
lastMessageAt: chat.last_message_at,
|
||||
@@ -773,16 +775,16 @@ export async function handleToolCall(toolName: string, args: Record<string, any>
|
||||
|
||||
const result = await query(
|
||||
`SELECT
|
||||
c.id, c.jid, c.is_group, c.unread_count, c.last_message_at,
|
||||
c.id, c.jid, c.is_group, c.unread_count, c.last_message_at, c.alias,
|
||||
CASE
|
||||
WHEN c.is_group THEN COALESCE(gm.subject, c.name, c.jid)
|
||||
ELSE COALESCE(ct.name, ct.push_name, c.name, SPLIT_PART(c.jid, '@', 1))
|
||||
WHEN c.is_group THEN COALESCE(c.alias, gm.subject, c.name, c.jid)
|
||||
ELSE COALESCE(c.alias, ct.name, ct.push_name, c.name, SPLIT_PART(c.jid, '@', 1))
|
||||
END as name
|
||||
FROM chats c
|
||||
LEFT JOIN contacts ct ON c.instance_id = ct.instance_id AND c.jid = ct.jid
|
||||
LEFT JOIN group_metadata gm ON c.instance_id = gm.instance_id AND c.jid = gm.jid
|
||||
WHERE c.instance_id = $1
|
||||
AND (c.name ILIKE $2 OR c.jid ILIKE $2 OR ct.name ILIKE $2 OR ct.push_name ILIKE $2 OR gm.subject ILIKE $2)
|
||||
AND (c.alias ILIKE $2 OR c.name ILIKE $2 OR c.jid ILIKE $2 OR ct.name ILIKE $2 OR ct.push_name ILIKE $2 OR gm.subject ILIKE $2)
|
||||
ORDER BY c.last_message_at DESC NULLS LAST
|
||||
LIMIT $3`,
|
||||
[instanceId, `%${searchQuery}%`, Math.min(limit, 50)]
|
||||
@@ -794,6 +796,7 @@ export async function handleToolCall(toolName: string, args: Record<string, any>
|
||||
id: row.id,
|
||||
jid: row.jid,
|
||||
name: row.name,
|
||||
alias: row.alias,
|
||||
isGroup: row.is_group,
|
||||
unreadCount: row.unread_count || 0,
|
||||
lastMessageAt: row.last_message_at
|
||||
|
||||
Reference in New Issue
Block a user