fix: usar resolvedId en respuestas y añadir display_code en tareas

Co-authored-by: aider (openrouter/openai/gpt-5) <aider@aider.chat>
pull/1/head
brobert 1 month ago
parent 133d7670fb
commit 6031207c6f

@ -230,7 +230,6 @@ export class CommandService {
recipient: context.sender, recipient: context.sender,
message: '_Este comando se usa en grupos. Prueba:_ `/t ver mis`' message: '_Este comando se usa en grupos. Prueba:_ `/t ver mis`'
}]; }];
const task = TaskService.getTaskById(resolvedId)!;
if (!GroupSyncService.isGroupActive(context.groupId)) { if (!GroupSyncService.isGroupActive(context.groupId)) {
return [{ return [{
recipient: context.sender, recipient: context.sender,
@ -537,11 +536,12 @@ export class CommandService {
if (!task) { if (!task) {
return [{ return [{
recipient: context.sender, recipient: context.sender,
message: `⚠️ Tarea ${codeId(id)} no encontrada.` message: `⚠️ Tarea ${codeId(resolvedId)} no encontrada.`
}]; }];
} }
const enforce = String(process.env.GROUP_MEMBERS_ENFORCE || '').toLowerCase() === 'true'; const enforce = String(process.env.GROUP_MEMBERS_ENFORCE || '').toLowerCase() === 'true';
if (task.group_id && GroupSyncService.isSnapshotFresh(task.group_id) && enforce && !GroupSyncService.isUserActiveInGroup(context.sender, task.group_id)) { const task = TaskService.getTaskById(resolvedId);
if (task && task.group_id && GroupSyncService.isSnapshotFresh(task.group_id) && enforce && !GroupSyncService.isUserActiveInGroup(context.sender, task.group_id)) {
return [{ return [{
recipient: context.sender, recipient: context.sender,
message: 'No puedes completar esta tarea porque no apareces como miembro activo del grupo.' message: 'No puedes completar esta tarea porque no apareces como miembro activo del grupo.'
@ -553,7 +553,7 @@ export class CommandService {
if (res.status === 'not_found') { if (res.status === 'not_found') {
return [{ return [{
recipient: context.sender, recipient: context.sender,
message: `⚠️ Tarea ${codeId(id)} no encontrada.` message: `⚠️ Tarea ${codeId(resolvedId)} no encontrada.`
}]; }];
} }
if (res.status === 'already') { if (res.status === 'already') {
@ -588,8 +588,9 @@ export class CommandService {
continue; continue;
} }
if (task.group_id && GroupSyncService.isSnapshotFresh(task.group_id) && enforce && !GroupSyncService.isUserActiveInGroup(context.sender, task.group_id)) { const task = TaskService.getTaskById(resolvedId);
lines.push(`🚫 ${codeId(id)} — no permitido (no eres miembro activo).`); if (task && task.group_id && GroupSyncService.isSnapshotFresh(task.group_id) && enforce && !GroupSyncService.isUserActiveInGroup(context.sender, task.group_id)) {
lines.push(`🚫 ${codeId(resolvedId)} — no permitido (no eres miembro activo).`);
cntBlocked++; cntBlocked++;
continue; continue;
} }
@ -665,7 +666,7 @@ export class CommandService {
if (!task) { if (!task) {
return [{ return [{
recipient: context.sender, recipient: context.sender,
message: `⚠️ Tarea ${codeId(id)} no encontrada.` message: `⚠️ Tarea ${codeId(resolvedId)} no encontrada.`
}]; }];
} }
const enforce = String(process.env.GROUP_MEMBERS_ENFORCE || '').toLowerCase() === 'true'; const enforce = String(process.env.GROUP_MEMBERS_ENFORCE || '').toLowerCase() === 'true';
@ -682,7 +683,7 @@ export class CommandService {
if (res.status === 'not_found') { if (res.status === 'not_found') {
return [{ return [{
recipient: context.sender, recipient: context.sender,
message: `⚠️ Tarea ${codeId(id)} no encontrada.` message: `⚠️ Tarea ${codeId(resolvedId)} no encontrada.`
}]; }];
} }
if (res.status === 'completed') { if (res.status === 'completed') {
@ -727,7 +728,7 @@ export class CommandService {
} }
if (task.group_id && GroupSyncService.isSnapshotFresh(task.group_id) && enforce && !GroupSyncService.isUserActiveInGroup(context.sender, task.group_id)) { if (task.group_id && GroupSyncService.isSnapshotFresh(task.group_id) && enforce && !GroupSyncService.isUserActiveInGroup(context.sender, task.group_id)) {
lines.push(`🚫 ${codeId(id)} — no permitido (no eres miembro activo).`); lines.push(`🚫 ${codeId(resolvedId)} — no permitido (no eres miembro activo).`);
cntBlocked++; cntBlocked++;
continue; continue;
} }
@ -790,7 +791,7 @@ export class CommandService {
if (!task) { if (!task) {
return [{ return [{
recipient: context.sender, recipient: context.sender,
message: `⚠️ Tarea ${codeId(id)} no encontrada.` message: `⚠️ Tarea ${codeId(resolvedId)} no encontrada.`
}]; }];
} }
const enforce = String(process.env.GROUP_MEMBERS_ENFORCE || '').toLowerCase() === 'true'; const enforce = String(process.env.GROUP_MEMBERS_ENFORCE || '').toLowerCase() === 'true';
@ -807,19 +808,19 @@ export class CommandService {
if (res.status === 'not_found') { if (res.status === 'not_found') {
return [{ return [{
recipient: context.sender, recipient: context.sender,
message: `⚠️ Tarea ${codeId(id)} no encontrada.` message: `⚠️ Tarea ${codeId(resolvedId)} no encontrada.`
}]; }];
} }
if (res.status === 'completed') { if (res.status === 'completed') {
return [{ return [{
recipient: context.sender, recipient: context.sender,
message: ` ${codeId(id)} ya estaba completada — ${res.task?.description || '(sin descripción)'}${due}` message: ` ${codeId(resolvedId, res.task?.display_code)} ya estaba completada — ${res.task?.description || '(sin descripción)'}${due}`
}]; }];
} }
if (res.status === 'not_assigned') { if (res.status === 'not_assigned') {
return [{ return [{
recipient: context.sender, recipient: context.sender,
message: ` ${codeId(id)} no la tenías asignada — ${res.task?.description || '(sin descripción)'}${due}` message: ` ${codeId(resolvedId, res.task?.display_code)} no la tenías asignada — ${res.task?.description || '(sin descripción)'}${due}`
}]; }];
} }

@ -368,6 +368,7 @@ export class TaskService {
id: Number(existing.id), id: Number(existing.id),
description: String(existing.description || ''), description: String(existing.description || ''),
due_date: existing.due_date ? String(existing.due_date) : null, due_date: existing.due_date ? String(existing.due_date) : null,
display_code: existing.display_code != null ? Number(existing.display_code) : null,
}, },
}; };
} }
@ -422,6 +423,7 @@ export class TaskService {
id: Number(existing.id), id: Number(existing.id),
description: String(existing.description || ''), description: String(existing.description || ''),
due_date: existing.due_date ? String(existing.due_date) : null, due_date: existing.due_date ? String(existing.due_date) : null,
display_code: existing.display_code != null ? Number(existing.display_code) : null,
}, },
}; };
} }
@ -493,6 +495,7 @@ export class TaskService {
description: String(row.description || ''), description: String(row.description || ''),
due_date: row.due_date ? String(row.due_date) : null, due_date: row.due_date ? String(row.due_date) : null,
group_id: row.group_id ? String(row.group_id) : null, group_id: row.group_id ? String(row.group_id) : null,
display_code: row.display_code != null ? Number(row.display_code) : null,
completed: Number(row.completed || 0), completed: Number(row.completed || 0),
completed_at: row.completed_at ? String(row.completed_at) : null, completed_at: row.completed_at ? String(row.completed_at) : null,
}; };

Loading…
Cancel
Save