FIX: Adiciona logging detalhado no sync e corrige conflito de nome no import
This commit is contained in:
parent
7617480242
commit
263840674d
@ -130,14 +130,19 @@ export class WhatsappTemplateService {
|
|||||||
return { synced: 0, imported: 0, error: data?.error?.message || 'Erro ao sincronizar' };
|
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 synced = 0;
|
||||||
let imported = 0;
|
let imported = 0;
|
||||||
|
|
||||||
for (const t of data.data) {
|
for (const t of data.data) {
|
||||||
const metaId = String(t.id);
|
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);
|
const updated = await this.repo.updateMetaStatusByName(t.name, t.status, metaId);
|
||||||
if (updated > 0) {
|
if (updated > 0) {
|
||||||
synced++;
|
synced++;
|
||||||
|
this.logger.log(`[Meta Templates] Status atualizado: "${t.name}" → ${t.status}`);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,12 +164,15 @@ export class WhatsappTemplateService {
|
|||||||
if (wasInserted) {
|
if (wasInserted) {
|
||||||
imported++;
|
imported++;
|
||||||
this.logger.log(`[Meta Templates] Importado: "${t.name}" (${t.status})`);
|
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) {
|
} catch (importErr: any) {
|
||||||
this.logger.warn(`[Meta Templates] Falha ao importar "${t.name}": ${importErr.message}`);
|
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 };
|
return { synced, imported };
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
this.logger.error('[Meta Templates] Falha na sincronização:', err?.message);
|
this.logger.error('[Meta Templates] Falha na sincronização:', err?.message);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user