diff --git a/src/bot/commands/task.ts b/src/bot/commands/task.ts index 1c130c1..f20c0cf 100644 --- a/src/bot/commands/task.ts +++ b/src/bot/commands/task.ts @@ -1,8 +1,6 @@ import { sendMessage } from '../utils/messaging.ts'; import { createTask, assignTask, completeTask, getPendingTasks } from '../../services/taskService'; -import { setRemindersEnabled } from '../../services/userService'; -import { normalizeUserIdentifier, extractUserFromJid, formatUserMention } from '../../utils/userUtils'; -import { isUserInCommunity } from '../../utils/communityUtils'; +import { normalizePhone } from '../utils/phoneUtils'; function formatTaskList(tasks: any[]) { if (tasks.length === 0) { @@ -15,7 +13,7 @@ function formatTaskList(tasks: any[]) { } export async function handleTaskCommand(body: string, sender: string, groupId: string, linkedGroups: Set) { - if (groupId && linkedGroups.has(groupId)) { + if (body.startsWith('/tarea')) { if (body.startsWith('/tarea')) { const command = body.replace('/tarea', '').trim(); const [action, ...args] = command.split(' '); diff --git a/src/services/taskService.ts b/src/services/taskService.ts index a049615..6021f6b 100644 --- a/src/services/taskService.ts +++ b/src/services/taskService.ts @@ -1,6 +1,6 @@ import { query, execute } from '../database/db'; import { normalizeUserIdentifier } from '../utils/userUtils'; -import { notifyTaskCreation, notifyTaskAssignment, notifyTaskCompletion } from './notificationService'; +// Notifications handled directly in this file now // Create a new task export function createTask(sender: string, params: CreateTaskParams) { diff --git a/src/utils/phoneUtils.ts b/src/utils/phoneUtils.ts new file mode 100644 index 0000000..d208409 --- /dev/null +++ b/src/utils/phoneUtils.ts @@ -0,0 +1,12 @@ +// Simple phone number normalization +export function normalizePhone(input: string): string { + // Remove all non-digit characters + let digits = input.replace(/\D/g, ''); + + // Ensure country code (default to +34 for Spain) + if (!digits.startsWith('34') && digits.length === 9) { + digits = '34' + digits; + } + + return `+${digits}`; +}