FIX: Correção dos Templates quebrados #8
@ -130,14 +130,19 @@ export class WhatsappTemplateService {
|
||||
return { synced: 0, imported: 0, error: data?.error?.message || 'Erro ao sincronizar' };
|
||||
}
|
||||
|
||||
this.logger.log(`[Meta Templates] Meta retornou ${data.data.length} template(s)`);
|
||||
|
||||
let synced = 0;
|
||||
let imported = 0;
|
||||
|
||||
for (const t of data.data) {
|
||||
const metaId = String(t.id);
|
||||
this.logger.log(`[Meta Templates] Processando: "${t.name}" status="${t.status}"`);
|
||||
|
||||
const updated = await this.repo.updateMetaStatusByName(t.name, t.status, metaId);
|
||||
if (updated > 0) {
|
||||
synced++;
|
||||
this.logger.log(`[Meta Templates] Status atualizado: "${t.name}" → ${t.status}`);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -159,12 +164,15 @@ export class WhatsappTemplateService {
|
||||
if (wasInserted) {
|
||||
imported++;
|
||||
this.logger.log(`[Meta Templates] Importado: "${t.name}" (${t.status})`);
|
||||
} else {
|
||||
this.logger.log(`[Meta Templates] Ignorado (já existe ou sem alteração): "${t.name}"`);
|
||||
}
|
||||
} catch (importErr: any) {
|
||||
this.logger.warn(`[Meta Templates] Falha ao importar "${t.name}": ${importErr.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
this.logger.log(`[Meta Templates] Sync concluído: ${synced} atualizado(s), ${imported} importado(s)`);
|
||||
return { synced, imported };
|
||||
} catch (err: any) {
|
||||
this.logger.error('[Meta Templates] Falha na sincronização:', err?.message);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user