refactor: simplify architecture and remove unused dependencies

main
borja (aider) 3 months ago
parent cfe389dd00
commit c38d996e50

@ -1,8 +1,6 @@
import { sendMessage } from '../utils/messaging.ts'; import { sendMessage } from '../utils/messaging.ts';
import { createTask, assignTask, completeTask, getPendingTasks } from '../../services/taskService'; import { createTask, assignTask, completeTask, getPendingTasks } from '../../services/taskService';
import { setRemindersEnabled } from '../../services/userService'; import { normalizePhone } from '../utils/phoneUtils';
import { normalizeUserIdentifier, extractUserFromJid, formatUserMention } from '../../utils/userUtils';
import { isUserInCommunity } from '../../utils/communityUtils';
function formatTaskList(tasks: any[]) { function formatTaskList(tasks: any[]) {
if (tasks.length === 0) { if (tasks.length === 0) {
@ -15,7 +13,7 @@ function formatTaskList(tasks: any[]) {
} }
export async function handleTaskCommand(body: string, sender: string, groupId: string, linkedGroups: Set<string>) { export async function handleTaskCommand(body: string, sender: string, groupId: string, linkedGroups: Set<string>) {
if (groupId && linkedGroups.has(groupId)) { if (body.startsWith('/tarea')) {
if (body.startsWith('/tarea')) { if (body.startsWith('/tarea')) {
const command = body.replace('/tarea', '').trim(); const command = body.replace('/tarea', '').trim();
const [action, ...args] = command.split(' '); const [action, ...args] = command.split(' ');

@ -1,6 +1,6 @@
import { query, execute } from '../database/db'; import { query, execute } from '../database/db';
import { normalizeUserIdentifier } from '../utils/userUtils'; import { normalizeUserIdentifier } from '../utils/userUtils';
import { notifyTaskCreation, notifyTaskAssignment, notifyTaskCompletion } from './notificationService'; // Notifications handled directly in this file now
// Create a new task // Create a new task
export function createTask(sender: string, params: CreateTaskParams) { export function createTask(sender: string, params: CreateTaskParams) {

@ -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}`;
}
Loading…
Cancel
Save