|
|
|
|
@ -190,7 +190,7 @@ export class GroupSyncService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Completar labels faltantes en allowed_groups usando todos los grupos devueltos por la API
|
|
|
|
|
try { AllowedGroups.dbInstance = this.dbInstance; this.fillMissingAllowedGroupLabels(groups); } catch {}
|
|
|
|
|
try { this.fillMissingAllowedGroupLabels(groups); } catch {}
|
|
|
|
|
|
|
|
|
|
// Actualizar métricas
|
|
|
|
|
this.cacheActiveGroups();
|
|
|
|
|
@ -270,7 +270,7 @@ export class GroupSyncService {
|
|
|
|
|
if (!id) continue;
|
|
|
|
|
const label = nameById.get(id);
|
|
|
|
|
if (label) {
|
|
|
|
|
try { (AllowedGroups as any).dbInstance = this.dbInstance; AllowedGroups.upsertPending(id, label, null); } catch {}
|
|
|
|
|
try { AllowedGroups.upsertPending(id, label, null); } catch {}
|
|
|
|
|
filled++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -459,7 +459,7 @@ export class GroupSyncService {
|
|
|
|
|
const mode = String(process.env.GROUP_GATING_MODE || 'off').toLowerCase();
|
|
|
|
|
const enforce = mode === 'enforce';
|
|
|
|
|
if (enforce) {
|
|
|
|
|
try { AllowedGroups.dbInstance = this.dbInstance; } catch {}
|
|
|
|
|
// no-op
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let groups = 0, added = 0, updated = 0, deactivated = 0;
|
|
|
|
|
@ -502,7 +502,7 @@ export class GroupSyncService {
|
|
|
|
|
const mode = String(process.env.GROUP_GATING_MODE || 'off').toLowerCase();
|
|
|
|
|
const enforce = mode === 'enforce';
|
|
|
|
|
if (enforce) {
|
|
|
|
|
try { AllowedGroups.dbInstance = this.dbInstance; } catch {}
|
|
|
|
|
// no-op
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let groups = 0, added = 0, updated = 0, deactivated = 0;
|
|
|
|
|
@ -734,7 +734,7 @@ export class GroupSyncService {
|
|
|
|
|
const cached = this.activeGroupsCache.get(groupId);
|
|
|
|
|
if (cached && cached.trim()) {
|
|
|
|
|
try { this.ensureGroupExists(groupId, cached); } catch {}
|
|
|
|
|
try { AllowedGroups.dbInstance = this.dbInstance; AllowedGroups.upsertPending(groupId, cached, null); } catch {}
|
|
|
|
|
try { AllowedGroups.upsertPending(groupId, cached, null); } catch {}
|
|
|
|
|
this.cacheActiveGroups();
|
|
|
|
|
return cached;
|
|
|
|
|
}
|
|
|
|
|
@ -745,7 +745,7 @@ export class GroupSyncService {
|
|
|
|
|
const name = row?.name ? String(row.name).trim() : '';
|
|
|
|
|
if (name) {
|
|
|
|
|
try { this.ensureGroupExists(groupId, name); } catch {}
|
|
|
|
|
try { AllowedGroups.dbInstance = this.dbInstance; AllowedGroups.upsertPending(groupId, name, null); } catch {}
|
|
|
|
|
try { AllowedGroups.upsertPending(groupId, name, null); } catch {}
|
|
|
|
|
this.cacheActiveGroups();
|
|
|
|
|
return name;
|
|
|
|
|
}
|
|
|
|
|
@ -758,7 +758,7 @@ export class GroupSyncService {
|
|
|
|
|
const subject = g?.subject ? String(g.subject).trim() : '';
|
|
|
|
|
if (subject) {
|
|
|
|
|
try { this.ensureGroupExists(groupId, subject); } catch {}
|
|
|
|
|
try { AllowedGroups.dbInstance = this.dbInstance; AllowedGroups.upsertPending(groupId, subject, null); } catch {}
|
|
|
|
|
try { AllowedGroups.upsertPending(groupId, subject, null); } catch {}
|
|
|
|
|
this.cacheActiveGroups();
|
|
|
|
|
return subject;
|
|
|
|
|
}
|
|
|
|
|
@ -779,7 +779,7 @@ export class GroupSyncService {
|
|
|
|
|
const mode = String(process.env.GROUP_GATING_MODE || 'off').toLowerCase();
|
|
|
|
|
if (mode === 'enforce') {
|
|
|
|
|
try {
|
|
|
|
|
(AllowedGroups as any).dbInstance = this.dbInstance;
|
|
|
|
|
// no-op
|
|
|
|
|
if (!AllowedGroups.isAllowed(groupId)) {
|
|
|
|
|
try { Metrics.inc('sync_skipped_group_total'); } catch {}
|
|
|
|
|
return { added: 0, updated: 0, deactivated: 0 };
|
|
|
|
|
|