gdpr audit implemented, email log, vollmachten, pdf delete cancel data privacy and vollmachten, removed message no id card in engergy car, and other contracts that are not telecom contracts, added insert counter for engery

This commit is contained in:
2026-03-21 11:59:53 +01:00
parent 89cf92eaf5
commit f2876f877e
1491 changed files with 265550 additions and 1292 deletions
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"appSetting.service.d.ts","sourceRoot":"","sources":["../../src/services/appSetting.service.ts"],"names":[],"mappings":"AAaA,wBAAsB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAWpE;AAED,wBAAsB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAGlE;AAED,wBAAsB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAM1E;AAED,wBAAsB,cAAc,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAWtE;AAED,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAazE"}
{"version":3,"file":"appSetting.service.d.ts","sourceRoot":"","sources":["../../src/services/appSetting.service.ts"],"names":[],"mappings":"AAgBA,wBAAsB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAWpE;AAED,wBAAsB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAGlE;AAED,wBAAsB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAM1E;AAED,wBAAsB,cAAc,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAWtE;AAED,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAazE"}
+3
View File
@@ -14,6 +14,9 @@ const DEFAULT_SETTINGS = {
deadlineCriticalDays: '14', // Rot: Kritisch
deadlineWarningDays: '42', // Gelb: Warnung (6 Wochen)
deadlineOkDays: '90', // Grün: OK (3 Monate)
// Ausweis-Ablauf: Fristenschwellen (in Tagen)
documentExpiryCriticalDays: '30', // Rot: Kritisch (Standard 30 Tage)
documentExpiryWarningDays: '90', // Gelb: Warnung (Standard 90 Tage)
};
async function getSetting(key) {
const setting = await prisma.appSetting.findUnique({
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"appSetting.service.js","sourceRoot":"","sources":["../../src/services/appSetting.service.ts"],"names":[],"mappings":";;AAaA,gCAWC;AAED,wCAGC;AAED,gCAMC;AAED,wCAWC;AAED,8CAaC;AAjED,2CAA8C;AAE9C,MAAM,MAAM,GAAG,IAAI,qBAAY,EAAE,CAAC;AAElC,mBAAmB;AACnB,MAAM,gBAAgB,GAA2B;IAC/C,6BAA6B,EAAE,OAAO;IACtC,gDAAgD;IAChD,oBAAoB,EAAE,IAAI,EAAO,gBAAgB;IACjD,mBAAmB,EAAE,IAAI,EAAQ,2BAA2B;IAC5D,cAAc,EAAE,IAAI,EAAa,sBAAsB;CACxD,CAAC;AAEK,KAAK,UAAU,UAAU,CAAC,GAAW;IAC1C,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC;QACjD,KAAK,EAAE,EAAE,GAAG,EAAE;KACf,CAAC,CAAC;IAEH,IAAI,OAAO,EAAE,CAAC;QACZ,OAAO,OAAO,CAAC,KAAK,CAAC;IACvB,CAAC;IAED,2BAA2B;IAC3B,OAAO,gBAAgB,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC;AACvC,CAAC;AAEM,KAAK,UAAU,cAAc,CAAC,GAAW;IAC9C,MAAM,KAAK,GAAG,MAAM,UAAU,CAAC,GAAG,CAAC,CAAC;IACpC,OAAO,KAAK,KAAK,MAAM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,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC;IACtC,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAEM,KAAK,UAAU,iBAAiB;IACrC,qFAAqF;IACrF,MAAM,UAAU,GAAG,CAAC,+BAA+B,CAAC,CAAC;IACrD,MAAM,WAAW,GAAG,MAAM,cAAc,EAAE,CAAC;IAE3C,MAAM,MAAM,GAA2B,EAAE,CAAC;IAC1C,KAAK,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;QAC7B,IAAI,GAAG,IAAI,WAAW,EAAE,CAAC;YACvB,MAAM,CAAC,GAAG,CAAC,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC;QACjC,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
+3
View File
@@ -53,6 +53,9 @@ export declare function getUserById(id: number): Promise<{
lastName: string;
isActive: boolean;
customerId: number | null;
whatsappNumber: string | null;
telegramUsername: string | null;
signalNumber: string | null;
roles: string[];
permissions: string[];
isCustomerPortal: boolean;
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"auth.service.d.ts","sourceRoot":"","sources":["../../src/services/auth.service.ts"],"names":[],"mappings":"AASA,wBAAsB,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;;;;;;;;;;;GA+D1D;AAGD,wBAAsB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;;;;;;;;;;;;;;;;;;;GAwFlE;AAGD,wBAAsB,yBAAyB,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,iBAiBnF;AAGD,wBAAsB,yBAAyB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAgB1F;AAED,wBAAsB,UAAU,CAAC,IAAI,EAAE;IACrC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;;;;;;GA8BA;AAED,wBAAsB,WAAW,CAAC,EAAE,EAAE,MAAM;;;;;;;;;;UA8C3C;AAGD,wBAAsB,qBAAqB,CAAC,UAAU,EAAE,MAAM;;;;;;;;;;;;;;;;;UA+C7D"}
{"version":3,"file":"auth.service.d.ts","sourceRoot":"","sources":["../../src/services/auth.service.ts"],"names":[],"mappings":"AASA,wBAAsB,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;;;;;;;;;;;GA+D1D;AAGD,wBAAsB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;;;;;;;;;;;;;;;;;;;GAwFlE;AAGD,wBAAsB,yBAAyB,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,iBAiBnF;AAGD,wBAAsB,yBAAyB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAgB1F;AAED,wBAAsB,UAAU,CAAC,IAAI,EAAE;IACrC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;;;;;;GA8BA;AAED,wBAAsB,WAAW,CAAC,EAAE,EAAE,MAAM;;;;;;;;;;;;;UAiD3C;AAGD,wBAAsB,qBAAqB,CAAC,UAAU,EAAE,MAAM;;;;;;;;;;;;;;;;;UA+C7D"}
+3
View File
@@ -246,6 +246,9 @@ async function getUserById(id) {
lastName: user.lastName,
isActive: user.isActive,
customerId: user.customerId,
whatsappNumber: user.whatsappNumber,
telegramUsername: user.telegramUsername,
signalNumber: user.signalNumber,
roles: user.roles.map((ur) => ur.role.name),
permissions: Array.from(permissions),
isCustomerPortal: false,
File diff suppressed because one or more lines are too long
+20
View File
@@ -157,6 +157,7 @@ export declare function getContractById(id: number, decryptPassword?: boolean):
createdAt: Date;
updatedAt: Date;
customerNumber: string;
consentHash: string | null;
portalEmail: string | null;
type: import(".prisma/client").$Enums.CustomerType;
salutation: string | null;
@@ -235,6 +236,10 @@ export declare function getContractById(id: number, decryptPassword?: boolean):
readingDate: Date;
value: number;
unit: string;
reportedBy: string | null;
status: import(".prisma/client").$Enums.MeterReadingStatus;
transferredAt: Date | null;
transferredBy: string | null;
meterId: number;
}[];
} & {
@@ -424,6 +429,10 @@ export declare function getContractById(id: number, decryptPassword?: boolean):
readingDate: Date;
value: number;
unit: string;
reportedBy: string | null;
status: import(".prisma/client").$Enums.MeterReadingStatus;
transferredAt: Date | null;
transferredBy: string | null;
meterId: number;
}[];
} & {
@@ -742,6 +751,7 @@ export declare function createContract(data: ContractCreateData): Promise<{
createdAt: Date;
updatedAt: Date;
customerNumber: string;
consentHash: string | null;
portalEmail: string | null;
type: import(".prisma/client").$Enums.CustomerType;
salutation: string | null;
@@ -934,6 +944,7 @@ export declare function updateContract(id: number, data: Partial<ContractCreateD
createdAt: Date;
updatedAt: Date;
customerNumber: string;
consentHash: string | null;
portalEmail: string | null;
type: import(".prisma/client").$Enums.CustomerType;
salutation: string | null;
@@ -1012,6 +1023,10 @@ export declare function updateContract(id: number, data: Partial<ContractCreateD
readingDate: Date;
value: number;
unit: string;
reportedBy: string | null;
status: import(".prisma/client").$Enums.MeterReadingStatus;
transferredAt: Date | null;
transferredBy: string | null;
meterId: number;
}[];
} & {
@@ -1201,6 +1216,10 @@ export declare function updateContract(id: number, data: Partial<ContractCreateD
readingDate: Date;
value: number;
unit: string;
reportedBy: string | null;
status: import(".prisma/client").$Enums.MeterReadingStatus;
transferredAt: Date | null;
transferredBy: string | null;
meterId: number;
}[];
} & {
@@ -1466,6 +1485,7 @@ export declare function createFollowUpContract(previousContractId: number): Prom
createdAt: Date;
updatedAt: Date;
customerNumber: string;
consentHash: string | null;
portalEmail: string | null;
type: import(".prisma/client").$Enums.CustomerType;
salutation: string | null;
File diff suppressed because one or more lines are too long
+40
View File
@@ -44,10 +44,50 @@ export interface CockpitSummary {
openTasks: number;
pendingContracts: number;
reviewDue: number;
missingConsents: number;
};
}
export interface DocumentAlert {
id: number;
type: string;
documentNumber: string;
expiryDate: string;
daysUntilExpiry: number;
urgency: UrgencyLevel;
customer: {
id: number;
customerNumber: string;
name: string;
};
}
export interface ReportedMeterReading {
id: number;
readingDate: string;
value: number;
unit: string;
notes?: string;
reportedBy?: string;
createdAt: string;
meter: {
id: number;
meterNumber: string;
type: string;
};
customer: {
id: number;
customerNumber: string;
name: string;
};
providerPortal?: {
providerName: string;
portalUrl: string;
portalUsername?: string;
};
}
export interface CockpitResult {
contracts: CockpitContract[];
documentAlerts: DocumentAlert[];
reportedReadings: ReportedMeterReading[];
summary: CockpitSummary;
thresholds: {
criticalDays: number;
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"contractCockpit.service.d.ts","sourceRoot":"","sources":["../../src/services/contractCockpit.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,cAAc,EACpC,MAAM,gBAAgB,CAAC;AAMxB,MAAM,MAAM,YAAY,GAAG,UAAU,GAAG,SAAS,GAAG,IAAI,GAAG,MAAM,CAAC;AAElE,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,YAAY,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,cAAc,EAAE,MAAM,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,cAAc,CAAC;IACvB,QAAQ,EAAE;QACR,EAAE,EAAE,MAAM,CAAC;QACX,cAAc,EAAE,MAAM,CAAC;QACvB,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;IACF,QAAQ,CAAC,EAAE;QACT,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;IACF,MAAM,CAAC,EAAE;QACP,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;IACF,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,YAAY,EAAE,CAAC;IACvB,cAAc,EAAE,YAAY,CAAC;CAC9B;AAED,MAAM,WAAW,cAAc;IAC7B,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE;QACV,qBAAqB,EAAE,MAAM,CAAC;QAC9B,cAAc,EAAE,MAAM,CAAC;QACvB,kBAAkB,EAAE,MAAM,CAAC;QAC3B,WAAW,EAAE,MAAM,CAAC;QACpB,eAAe,EAAE,MAAM,CAAC;QACxB,SAAS,EAAE,MAAM,CAAC;QAClB,gBAAgB,EAAE,MAAM,CAAC;QACzB,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;CACH;AAED,MAAM,WAAW,aAAa;IAC5B,SAAS,EAAE,eAAe,EAAE,CAAC;IAC7B,OAAO,EAAE,cAAc,CAAC;IACxB,UAAU,EAAE;QACV,YAAY,EAAE,MAAM,CAAC;QACrB,WAAW,EAAE,MAAM,CAAC;QACpB,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;CACH;AAyED,wBAAsB,cAAc,IAAI,OAAO,CAAC,aAAa,CAAC,CAod7D"}
{"version":3,"file":"contractCockpit.service.d.ts","sourceRoot":"","sources":["../../src/services/contractCockpit.service.ts"],"names":[],"mappings":"AAAA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CAAC;IACxB,UAAU,EAAE;QACV,YAAY,EAAE,MAAM,CAAC;QACrB,WAAW,EAAE,MAAM,CAAC;QACpB,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;CACH;AAyED,wBAAsB,cAAc,IAAI,OAAO,CAAC,aAAa,CAAC,CAsjB7D"}
+195 -3
View File
@@ -105,6 +105,8 @@ async function getCockpitData() {
const criticalDays = parseInt(settings.deadlineCriticalDays) || 14;
const warningDays = parseInt(settings.deadlineWarningDays) || 42;
const okDays = parseInt(settings.deadlineOkDays) || 90;
const docExpiryCriticalDays = parseInt(settings.documentExpiryCriticalDays) || 30;
const docExpiryWarningDays = parseInt(settings.documentExpiryWarningDays) || 90;
// Lade alle relevanten Verträge (inkl. CANCELLED/DEACTIVATED für Schlussrechnung-Check)
const contracts = await prisma.contract.findMany({
where: {
@@ -191,8 +193,36 @@ async function getCockpitData() {
openTasks: 0,
pendingContracts: 0,
reviewDue: 0,
missingConsents: 0,
},
};
// Consent-Daten batch-laden für alle Kunden
const allConsents = await prisma.customerConsent.findMany({
where: { status: 'GRANTED' },
select: { customerId: true, consentType: true },
});
// Map: customerId → Set<consentType>
const grantedConsentsMap = new Map();
for (const c of allConsents) {
if (!grantedConsentsMap.has(c.customerId)) {
grantedConsentsMap.set(c.customerId, new Set());
}
grantedConsentsMap.get(c.customerId).add(c.consentType);
}
// Widerrufene Consents laden
const withdrawnConsents = await prisma.customerConsent.findMany({
where: { status: 'WITHDRAWN' },
select: { customerId: true, consentType: true },
});
const withdrawnConsentsMap = new Map();
for (const c of withdrawnConsents) {
if (!withdrawnConsentsMap.has(c.customerId)) {
withdrawnConsentsMap.set(c.customerId, new Set());
}
withdrawnConsentsMap.get(c.customerId).add(c.consentType);
}
// Track welche Kunden bereits eine Consent-Warnung bekommen haben (nur einmal pro Kunde)
const customerConsentWarned = new Set();
for (const contract of contracts) {
const issues = [];
// SNOOZE-LOGIK: Prüfen ob Snooze aktiv ist (für Fristen-Unterdrückung)
@@ -349,16 +379,41 @@ async function getCockpitData() {
});
summary.byCategory.missingData++;
}
// 7b. KEIN AUSWEIS (für DSL, FIBER, CABLE, MOBILE ist dies ein kritisches Problem)
if (!contract.identityDocumentId) {
// 7b. KEIN AUSWEIS (nur für Telekommunikationsprodukte relevant)
const requiresIdentityDocument = ['DSL', 'FIBER', 'CABLE', 'MOBILE'].includes(contract.type);
if (requiresIdentityDocument && !contract.identityDocumentId) {
issues.push({
type: 'missing_identity_document',
label: 'Ausweis fehlt',
urgency: requiresBankAndId ? 'critical' : 'warning',
urgency: 'critical',
details: 'Kein Ausweisdokument verknüpft',
});
summary.byCategory.missingData++;
}
// 7c. AUSWEIS LÄUFT AB (nur aktive Ausweise prüfen)
if (contract.identityDocument && contract.identityDocument.isActive && contract.identityDocument.expiryDate) {
const expiryDate = new Date(contract.identityDocument.expiryDate);
const today = new Date();
const daysUntilExpiry = Math.ceil((expiryDate.getTime() - today.getTime()) / (1000 * 60 * 60 * 24));
if (daysUntilExpiry < 0) {
issues.push({
type: 'identity_document_expired',
label: 'Ausweis abgelaufen',
urgency: 'critical',
details: `Ausweis seit ${Math.abs(daysUntilExpiry)} Tagen abgelaufen (${expiryDate.toLocaleDateString('de-DE')})`,
});
summary.byCategory.missingData++;
}
else if (daysUntilExpiry <= docExpiryWarningDays) {
issues.push({
type: 'identity_document_expiring',
label: 'Ausweis läuft ab',
urgency: daysUntilExpiry <= docExpiryCriticalDays ? 'critical' : 'warning',
details: `Ausweis läuft in ${daysUntilExpiry} Tagen ab (${expiryDate.toLocaleDateString('de-DE')})`,
});
summary.byCategory.cancellationDeadlines++;
}
}
// 8. ENERGIE-SPEZIFISCH: KEIN ZÄHLER
if (['ELECTRICITY', 'GAS'].includes(contract.type) && contract.energyDetails) {
if (!contract.energyDetails.meterId) {
@@ -475,6 +530,35 @@ async function getCockpitData() {
}
}
}
// #14 - Consent-Prüfung (nur für aktive Verträge, einmal pro Kunde)
if (['ACTIVE', 'PENDING', 'DRAFT'].includes(contract.status) && !customerConsentWarned.has(contract.customer.id)) {
const granted = grantedConsentsMap.get(contract.customer.id);
const withdrawn = withdrawnConsentsMap.get(contract.customer.id);
const requiredTypes = ['DATA_PROCESSING', 'MARKETING_EMAIL', 'MARKETING_PHONE', 'DATA_SHARING_PARTNER'];
if (withdrawn && withdrawn.size > 0) {
// Mindestens eine Einwilligung widerrufen
issues.push({
type: 'consent_withdrawn',
label: 'Einwilligung widerrufen',
urgency: 'critical',
details: `${withdrawn.size} Einwilligung(en) widerrufen`,
});
summary.byCategory.missingConsents++;
customerConsentWarned.add(contract.customer.id);
}
else if (!granted || granted.size < requiredTypes.length) {
// Nicht alle 4 Einwilligungen erteilt
const missing = requiredTypes.length - (granted?.size || 0);
issues.push({
type: 'missing_consents',
label: 'Fehlende Einwilligungen',
urgency: 'critical',
details: `${missing} von ${requiredTypes.length} Einwilligungen fehlen`,
});
summary.byCategory.missingConsents++;
customerConsentWarned.add(contract.customer.id);
}
}
// Nur Verträge mit Issues hinzufügen
if (issues.length > 0) {
const highestUrgency = getHighestUrgency(issues);
@@ -523,8 +607,14 @@ async function getCockpitData() {
};
return urgencyOrder[a.highestUrgency] - urgencyOrder[b.highestUrgency];
});
// Vertragsunabhängige Ausweis-Warnungen
const documentAlerts = await getDocumentExpiryAlerts(docExpiryCriticalDays, docExpiryWarningDays);
// Gemeldete Zählerstände (REPORTED Status)
const reportedReadings = await getReportedMeterReadings();
return {
contracts: cockpitContracts,
documentAlerts,
reportedReadings,
summary,
thresholds: {
criticalDays,
@@ -533,4 +623,106 @@ async function getCockpitData() {
},
};
}
/**
* Alle aktiven Ausweise die ablaufen oder abgelaufen sind (vertragsunabhängig)
*/
async function getDocumentExpiryAlerts(criticalDays, warningDays) {
const now = new Date();
const inWarningDays = new Date(now.getTime() + warningDays * 24 * 60 * 60 * 1000);
const documents = await prisma.identityDocument.findMany({
where: {
isActive: true,
expiryDate: { lte: inWarningDays },
},
include: {
customer: {
select: { id: true, customerNumber: true, firstName: true, lastName: true },
},
},
orderBy: { expiryDate: 'asc' },
});
return documents.map((doc) => {
const expiryDate = new Date(doc.expiryDate);
const daysUntilExpiry = Math.ceil((expiryDate.getTime() - now.getTime()) / (1000 * 60 * 60 * 24));
let urgency = 'warning';
if (daysUntilExpiry < 0)
urgency = 'critical';
else if (daysUntilExpiry <= criticalDays)
urgency = 'critical';
return {
id: doc.id,
type: doc.type,
documentNumber: doc.documentNumber,
expiryDate: expiryDate.toISOString(),
daysUntilExpiry,
urgency,
customer: {
id: doc.customer.id,
customerNumber: doc.customer.customerNumber,
name: `${doc.customer.firstName} ${doc.customer.lastName}`,
},
};
});
}
/**
* Vom Kunden gemeldete Zählerstände die noch nicht übertragen wurden
*/
async function getReportedMeterReadings() {
const readings = await prisma.meterReading.findMany({
where: { status: 'REPORTED' },
include: {
meter: {
include: {
customer: {
select: { id: true, customerNumber: true, firstName: true, lastName: true },
},
// Energie-Verträge für diesen Zähler (um Provider-Portal-Daten zu bekommen)
energyDetails: {
include: {
contract: {
select: {
id: true,
portalUsername: true,
provider: {
select: { id: true, name: true, portalUrl: true },
},
},
},
},
take: 1,
},
},
},
},
orderBy: { createdAt: 'asc' },
});
return readings.map((r) => {
const contract = r.meter.energyDetails?.[0]?.contract;
const provider = contract?.provider;
return {
id: r.id,
readingDate: r.readingDate.toISOString(),
value: r.value,
unit: r.unit,
notes: r.notes ?? undefined,
reportedBy: r.reportedBy ?? undefined,
createdAt: r.createdAt.toISOString(),
meter: {
id: r.meter.id,
meterNumber: r.meter.meterNumber,
type: r.meter.type,
},
customer: {
id: r.meter.customer.id,
customerNumber: r.meter.customer.customerNumber,
name: `${r.meter.customer.firstName} ${r.meter.customer.lastName}`,
},
providerPortal: provider?.portalUrl ? {
providerName: provider.name,
portalUrl: provider.portalUrl,
portalUsername: contract?.portalUsername ?? undefined,
} : undefined,
};
});
}
//# sourceMappingURL=contractCockpit.service.js.map
File diff suppressed because one or more lines are too long
+17 -17
View File
@@ -11,8 +11,8 @@ export declare function getTasksByContract(filters: ContractTaskFilters): Promis
createdAt: Date;
updatedAt: Date;
status: import(".prisma/client").$Enums.ContractTaskStatus;
title: string;
createdBy: string | null;
title: string;
completedAt: Date | null;
taskId: number;
}[];
@@ -23,9 +23,9 @@ export declare function getTasksByContract(filters: ContractTaskFilters): Promis
description: string | null;
status: import(".prisma/client").$Enums.ContractTaskStatus;
contractId: number;
createdBy: string | null;
title: string;
visibleInPortal: boolean;
createdBy: string | null;
completedAt: Date | null;
})[]>;
export declare function getTaskById(id: number): Promise<{
@@ -35,9 +35,9 @@ export declare function getTaskById(id: number): Promise<{
description: string | null;
status: import(".prisma/client").$Enums.ContractTaskStatus;
contractId: number;
createdBy: string | null;
title: string;
visibleInPortal: boolean;
createdBy: string | null;
completedAt: Date | null;
} | null>;
export declare function createTask(data: {
@@ -53,9 +53,9 @@ export declare function createTask(data: {
description: string | null;
status: import(".prisma/client").$Enums.ContractTaskStatus;
contractId: number;
createdBy: string | null;
title: string;
visibleInPortal: boolean;
createdBy: string | null;
completedAt: Date | null;
}>;
export declare function updateTask(id: number, data: {
@@ -69,9 +69,9 @@ export declare function updateTask(id: number, data: {
description: string | null;
status: import(".prisma/client").$Enums.ContractTaskStatus;
contractId: number;
createdBy: string | null;
title: string;
visibleInPortal: boolean;
createdBy: string | null;
completedAt: Date | null;
}>;
export declare function completeTask(id: number): Promise<{
@@ -81,9 +81,9 @@ export declare function completeTask(id: number): Promise<{
description: string | null;
status: import(".prisma/client").$Enums.ContractTaskStatus;
contractId: number;
createdBy: string | null;
title: string;
visibleInPortal: boolean;
createdBy: string | null;
completedAt: Date | null;
}>;
export declare function reopenTask(id: number): Promise<{
@@ -93,9 +93,9 @@ export declare function reopenTask(id: number): Promise<{
description: string | null;
status: import(".prisma/client").$Enums.ContractTaskStatus;
contractId: number;
createdBy: string | null;
title: string;
visibleInPortal: boolean;
createdBy: string | null;
completedAt: Date | null;
}>;
export declare function deleteTask(id: number): Promise<{
@@ -105,9 +105,9 @@ export declare function deleteTask(id: number): Promise<{
description: string | null;
status: import(".prisma/client").$Enums.ContractTaskStatus;
contractId: number;
createdBy: string | null;
title: string;
visibleInPortal: boolean;
createdBy: string | null;
completedAt: Date | null;
}>;
export declare function createSubtask(data: {
@@ -119,8 +119,8 @@ export declare function createSubtask(data: {
createdAt: Date;
updatedAt: Date;
status: import(".prisma/client").$Enums.ContractTaskStatus;
title: string;
createdBy: string | null;
title: string;
completedAt: Date | null;
taskId: number;
}>;
@@ -131,8 +131,8 @@ export declare function updateSubtask(id: number, data: {
createdAt: Date;
updatedAt: Date;
status: import(".prisma/client").$Enums.ContractTaskStatus;
title: string;
createdBy: string | null;
title: string;
completedAt: Date | null;
taskId: number;
}>;
@@ -141,8 +141,8 @@ export declare function completeSubtask(id: number): Promise<{
createdAt: Date;
updatedAt: Date;
status: import(".prisma/client").$Enums.ContractTaskStatus;
title: string;
createdBy: string | null;
title: string;
completedAt: Date | null;
taskId: number;
}>;
@@ -151,8 +151,8 @@ export declare function reopenSubtask(id: number): Promise<{
createdAt: Date;
updatedAt: Date;
status: import(".prisma/client").$Enums.ContractTaskStatus;
title: string;
createdBy: string | null;
title: string;
completedAt: Date | null;
taskId: number;
}>;
@@ -161,8 +161,8 @@ export declare function deleteSubtask(id: number): Promise<{
createdAt: Date;
updatedAt: Date;
status: import(".prisma/client").$Enums.ContractTaskStatus;
title: string;
createdBy: string | null;
title: string;
completedAt: Date | null;
taskId: number;
}>;
@@ -174,9 +174,9 @@ export declare function getSubtaskById(id: number): Promise<({
description: string | null;
status: import(".prisma/client").$Enums.ContractTaskStatus;
contractId: number;
createdBy: string | null;
title: string;
visibleInPortal: boolean;
createdBy: string | null;
completedAt: Date | null;
};
} & {
@@ -184,8 +184,8 @@ export declare function getSubtaskById(id: number): Promise<({
createdAt: Date;
updatedAt: Date;
status: import(".prisma/client").$Enums.ContractTaskStatus;
title: string;
createdBy: string | null;
title: string;
completedAt: Date | null;
taskId: number;
}) | null>;
@@ -223,8 +223,8 @@ export declare function getAllTasks(filters: AllTasksFilters): Promise<({
createdAt: Date;
updatedAt: Date;
status: import(".prisma/client").$Enums.ContractTaskStatus;
title: string;
createdBy: string | null;
title: string;
completedAt: Date | null;
taskId: number;
}[];
@@ -235,9 +235,9 @@ export declare function getAllTasks(filters: AllTasksFilters): Promise<({
description: string | null;
status: import(".prisma/client").$Enums.ContractTaskStatus;
contractId: number;
createdBy: string | null;
title: string;
visibleInPortal: boolean;
createdBy: string | null;
completedAt: Date | null;
})[]>;
export declare function getTaskStats(filters: AllTasksFilters): Promise<{
+29
View File
@@ -31,6 +31,7 @@ export declare function getAllCustomers(filters: CustomerFilters): Promise<{
createdAt: Date;
updatedAt: Date;
customerNumber: string;
consentHash: string | null;
portalEmail: string | null;
type: import(".prisma/client").$Enums.CustomerType;
salutation: string | null;
@@ -108,6 +109,10 @@ export declare function getCustomerById(id: number): Promise<({
readingDate: Date;
value: number;
unit: string;
reportedBy: string | null;
status: import(".prisma/client").$Enums.MeterReadingStatus;
transferredAt: Date | null;
transferredBy: string | null;
meterId: number;
}[];
} & {
@@ -210,6 +215,7 @@ export declare function getCustomerById(id: number): Promise<({
createdAt: Date;
updatedAt: Date;
customerNumber: string;
consentHash: string | null;
portalEmail: string | null;
type: import(".prisma/client").$Enums.CustomerType;
salutation: string | null;
@@ -257,6 +263,7 @@ export declare function createCustomer(data: {
createdAt: Date;
updatedAt: Date;
customerNumber: string;
consentHash: string | null;
portalEmail: string | null;
type: import(".prisma/client").$Enums.CustomerType;
salutation: string | null;
@@ -300,6 +307,7 @@ export declare function updateCustomer(id: number, data: {
createdAt: Date;
updatedAt: Date;
customerNumber: string;
consentHash: string | null;
portalEmail: string | null;
type: import(".prisma/client").$Enums.CustomerType;
salutation: string | null;
@@ -328,6 +336,7 @@ export declare function deleteCustomer(id: number): Promise<{
createdAt: Date;
updatedAt: Date;
customerNumber: string;
consentHash: string | null;
portalEmail: string | null;
type: import(".prisma/client").$Enums.CustomerType;
salutation: string | null;
@@ -566,6 +575,10 @@ export declare function getCustomerMeters(customerId: number, showInactive?: boo
readingDate: Date;
value: number;
unit: string;
reportedBy: string | null;
status: import(".prisma/client").$Enums.MeterReadingStatus;
transferredAt: Date | null;
transferredBy: string | null;
meterId: number;
}[];
} & {
@@ -629,6 +642,10 @@ export declare function addMeterReading(meterId: number, data: {
readingDate: Date;
value: number;
unit: string;
reportedBy: string | null;
status: import(".prisma/client").$Enums.MeterReadingStatus;
transferredAt: Date | null;
transferredBy: string | null;
meterId: number;
}>;
export declare function getMeterReadings(meterId: number): Promise<{
@@ -638,6 +655,10 @@ export declare function getMeterReadings(meterId: number): Promise<{
readingDate: Date;
value: number;
unit: string;
reportedBy: string | null;
status: import(".prisma/client").$Enums.MeterReadingStatus;
transferredAt: Date | null;
transferredBy: string | null;
meterId: number;
}[]>;
export declare function updateMeterReading(meterId: number, readingId: number, data: {
@@ -652,6 +673,10 @@ export declare function updateMeterReading(meterId: number, readingId: number, d
readingDate: Date;
value: number;
unit: string;
reportedBy: string | null;
status: import(".prisma/client").$Enums.MeterReadingStatus;
transferredAt: Date | null;
transferredBy: string | null;
meterId: number;
}>;
export declare function deleteMeterReading(meterId: number, readingId: number): Promise<{
@@ -661,6 +686,10 @@ export declare function deleteMeterReading(meterId: number, readingId: number):
readingDate: Date;
value: number;
unit: string;
reportedBy: string | null;
status: import(".prisma/client").$Enums.MeterReadingStatus;
transferredAt: Date | null;
transferredBy: string | null;
meterId: number;
}>;
export declare function updatePortalSettings(customerId: number, data: {
File diff suppressed because one or more lines are too long
@@ -20,6 +20,8 @@ export declare function getAllProviderConfigs(): Promise<{
imapEncryption: import(".prisma/client").$Enums.MailEncryption;
smtpEncryption: import(".prisma/client").$Enums.MailEncryption;
allowSelfSignedCerts: boolean;
systemEmailAddress: string | null;
systemEmailPasswordEncrypted: string | null;
}[]>;
export declare function getProviderConfigById(id: number): Promise<{
id: number;
@@ -42,6 +44,8 @@ export declare function getProviderConfigById(id: number): Promise<{
imapEncryption: import(".prisma/client").$Enums.MailEncryption;
smtpEncryption: import(".prisma/client").$Enums.MailEncryption;
allowSelfSignedCerts: boolean;
systemEmailAddress: string | null;
systemEmailPasswordEncrypted: string | null;
} | null>;
export declare function getDefaultProviderConfig(): Promise<{
id: number;
@@ -64,6 +68,8 @@ export declare function getDefaultProviderConfig(): Promise<{
imapEncryption: import(".prisma/client").$Enums.MailEncryption;
smtpEncryption: import(".prisma/client").$Enums.MailEncryption;
allowSelfSignedCerts: boolean;
systemEmailAddress: string | null;
systemEmailPasswordEncrypted: string | null;
} | null>;
export declare function getActiveProviderConfig(): Promise<{
id: number;
@@ -86,6 +92,8 @@ export declare function getActiveProviderConfig(): Promise<{
imapEncryption: import(".prisma/client").$Enums.MailEncryption;
smtpEncryption: import(".prisma/client").$Enums.MailEncryption;
allowSelfSignedCerts: boolean;
systemEmailAddress: string | null;
systemEmailPasswordEncrypted: string | null;
} | null>;
export interface CreateProviderConfigData {
name: string;
@@ -99,6 +107,8 @@ export interface CreateProviderConfigData {
imapEncryption?: MailEncryption;
smtpEncryption?: MailEncryption;
allowSelfSignedCerts?: boolean;
systemEmailAddress?: string;
systemEmailPassword?: string;
isActive?: boolean;
isDefault?: boolean;
}
@@ -123,6 +133,8 @@ export declare function createProviderConfig(data: CreateProviderConfigData): Pr
imapEncryption: import(".prisma/client").$Enums.MailEncryption;
smtpEncryption: import(".prisma/client").$Enums.MailEncryption;
allowSelfSignedCerts: boolean;
systemEmailAddress: string | null;
systemEmailPasswordEncrypted: string | null;
}>;
export declare function updateProviderConfig(id: number, data: Partial<CreateProviderConfigData>): Promise<{
id: number;
@@ -145,6 +157,8 @@ export declare function updateProviderConfig(id: number, data: Partial<CreatePro
imapEncryption: import(".prisma/client").$Enums.MailEncryption;
smtpEncryption: import(".prisma/client").$Enums.MailEncryption;
allowSelfSignedCerts: boolean;
systemEmailAddress: string | null;
systemEmailPasswordEncrypted: string | null;
}>;
export declare function deleteProviderConfig(id: number): Promise<{
id: number;
@@ -167,6 +181,8 @@ export declare function deleteProviderConfig(id: number): Promise<{
imapEncryption: import(".prisma/client").$Enums.MailEncryption;
smtpEncryption: import(".prisma/client").$Enums.MailEncryption;
allowSelfSignedCerts: boolean;
systemEmailAddress: string | null;
systemEmailPasswordEncrypted: string | null;
}>;
export declare function checkEmailExists(localPart: string): Promise<EmailExistsResult>;
export declare function provisionEmail(localPart: string, customerEmail: string): Promise<EmailOperationResult>;
@@ -200,4 +216,17 @@ export declare function testProviderConnection(options?: {
domain: string;
};
}): Promise<EmailOperationResult>;
export interface SystemEmailCredentials {
emailAddress: string;
password: string;
smtpServer: string;
smtpPort: number;
smtpEncryption: MailEncryption;
allowSelfSignedCerts: boolean;
}
/**
* System-E-Mail-Credentials vom aktiven Provider holen.
* Wird für automatisierten Versand (DSGVO, Benachrichtigungen etc.) verwendet.
*/
export declare function getSystemEmailCredentials(): Promise<SystemEmailCredentials | null>;
//# sourceMappingURL=emailProviderService.d.ts.map
@@ -1 +1 @@
{"version":3,"file":"emailProviderService.d.ts","sourceRoot":"","sources":["../../../src/services/emailProvider/emailProviderService.ts"],"names":[],"mappings":"AAIA,OAAO,EAGL,iBAAiB,EACjB,oBAAoB,EAEpB,cAAc,EACf,MAAM,YAAY,CAAC;AAuBpB,wBAAsB,qBAAqB;;;;;;;;;;;;;;;;;;;;;KAI1C;AAED,wBAAsB,qBAAqB,CAAC,EAAE,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;UAIrD;AAED,wBAAsB,wBAAwB;;;;;;;;;;;;;;;;;;;;;UAI7C;AAED,wBAAsB,uBAAuB;;;;;;;;;;;;;;;;;;;;;UAQ5C;AAED,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,OAAO,GAAG,QAAQ,GAAG,aAAa,CAAC;IACzC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAA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AAc,EAAE,cAAc,CAAC;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,cAAc,CAAC;IAC/B,oBAAoB,EAAE,OAAO,CAAC;IAC9B,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CA0D5E;AAGD,wBAAsB,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAWvF;AAGD,wBAAsB,sBAAsB,CAC1C,YAAY,EAAE,MAAM,EACpB,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,oBAAoB,CAAC,CAW/B;AAGD,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAGhE;AAqED,wBAAsB,sBAAsB,CAAC,OAAO,CAAC,EAAE;IACrD,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE;QACT,IAAI,EAAE,OAAO,GAAG,QAAQ,GAAG,aAAa,CAAC;QACzC,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;CACH,GAAG,OAAO,CAAC,oBAAoB,CAAC,CA6BhC"}
{"version":3,"file":"emailProviderService.d.ts","sourceRoot":"","sources":["../../../src/services/emailProvider/emailProviderService.ts"],"names":[],"mappings":"AAIA,OAAO,EAGL,iBAAiB,EACjB,oBAAoB,EAEpB,cAAc,EACf,MAAM,YAAY,CAAC;AAuBpB,wBAAsB,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;KAI1C;AAED,wBAAsB,qBAAqB,CAAC,EAAE,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;UAIrD;AAED,wBA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,MAAM,CAAC;QAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;CACH,GAAG,OAAO,CAAC,oBAAoB,CAAC,CA6BhC;AAID,MAAM,WAAW,sBAAsB;IACrC,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,cAAc,CAAC;IAC/B,oBAAoB,EAAE,OAAO,CAAC;CAC/B;AAED;;;GAGG;AACH,wBAAsB,yBAAyB,IAAI,OAAO,CAAC,sBAAsB,GAAG,IAAI,CAAC,CAyBxF"}
+45 -2
View File
@@ -18,6 +18,7 @@ exports.deprovisionEmail = deprovisionEmail;
exports.renameProvisionedEmail = renameProvisionedEmail;
exports.getProviderDomain = getProviderDomain;
exports.testProviderConnection = testProviderConnection;
exports.getSystemEmailCredentials = getSystemEmailCredentials;
const client_1 = require("@prisma/client");
const encryption_js_1 = require("../../utils/encryption.js");
const pleskProvider_js_1 = require("./pleskProvider.js");
@@ -70,9 +71,10 @@ async function createProviderConfig(data) {
data: { isDefault: false },
});
}
// Passwort verschlüsseln falls vorhanden
// Passwörter verschlüsseln falls vorhanden
const { encrypt } = await import('../../utils/encryption.js');
const passwordEncrypted = data.password ? encrypt(data.password) : null;
const systemEmailPasswordEncrypted = data.systemEmailPassword ? encrypt(data.systemEmailPassword) : null;
return prisma.emailProviderConfig.create({
data: {
name: data.name,
@@ -86,6 +88,8 @@ async function createProviderConfig(data) {
imapEncryption: data.imapEncryption ?? 'SSL',
smtpEncryption: data.smtpEncryption ?? 'SSL',
allowSelfSignedCerts: data.allowSelfSignedCerts ?? false,
systemEmailAddress: data.systemEmailAddress || null,
systemEmailPasswordEncrypted,
isActive: data.isActive ?? true,
isDefault: data.isDefault ?? false,
},
@@ -120,21 +124,31 @@ async function updateProviderConfig(id, data) {
updateData.smtpEncryption = data.smtpEncryption;
if (data.allowSelfSignedCerts !== undefined)
updateData.allowSelfSignedCerts = data.allowSelfSignedCerts;
if (data.systemEmailAddress !== undefined)
updateData.systemEmailAddress = data.systemEmailAddress || null;
if (data.isActive !== undefined)
updateData.isActive = data.isActive;
if (data.isDefault !== undefined)
updateData.isDefault = data.isDefault;
const { encrypt } = await import('../../utils/encryption.js');
// Passwort-Logik:
// - Wenn neues Passwort übergeben → verschlüsseln und speichern
// - Wenn Benutzername gelöscht wird → Passwort auch löschen (gehören zusammen)
if (data.password) {
const { encrypt } = await import('../../utils/encryption.js');
updateData.passwordEncrypted = encrypt(data.password);
}
else if (data.username !== undefined && !data.username) {
// Benutzername wird gelöscht → Passwort auch löschen
updateData.passwordEncrypted = null;
}
// System-E-Mail-Passwort
if (data.systemEmailPassword) {
updateData.systemEmailPasswordEncrypted = encrypt(data.systemEmailPassword);
}
else if (data.systemEmailAddress !== undefined && !data.systemEmailAddress) {
// System-E-Mail wird gelöscht → Passwort auch löschen
updateData.systemEmailPasswordEncrypted = null;
}
return prisma.emailProviderConfig.update({
where: { id },
data: updateData,
@@ -477,4 +491,33 @@ async function testProviderConnection(options) {
};
}
}
/**
* System-E-Mail-Credentials vom aktiven Provider holen.
* Wird für automatisierten Versand (DSGVO, Benachrichtigungen etc.) verwendet.
*/
async function getSystemEmailCredentials() {
const config = await getActiveProviderConfig();
if (!config?.systemEmailAddress || !config?.systemEmailPasswordEncrypted) {
return null;
}
let password;
try {
password = (0, encryption_js_1.decrypt)(config.systemEmailPasswordEncrypted);
}
catch {
console.error('System-E-Mail-Passwort konnte nicht entschlüsselt werden');
return null;
}
const settings = await getImapSmtpSettings();
if (!settings)
return null;
return {
emailAddress: config.systemEmailAddress,
password,
smtpServer: settings.smtpServer,
smtpPort: settings.smtpPort,
smtpEncryption: settings.smtpEncryption,
allowSelfSignedCerts: settings.allowSelfSignedCerts,
};
}
//# sourceMappingURL=emailProviderService.js.map
File diff suppressed because one or more lines are too long
+21
View File
@@ -20,12 +20,16 @@ export declare function getAllUsers(filters: UserFilters): Promise<{
description: string | null;
})[];
hasDeveloperAccess: boolean;
hasGdprAccess: boolean;
id: number;
email: string;
customerId: number | null;
firstName: string;
lastName: string;
isActive: boolean;
whatsappNumber: string | null;
telegramUsername: string | null;
signalNumber: string | null;
createdAt: Date;
}[];
pagination: {
@@ -61,6 +65,9 @@ export declare function getUserById(id: number): Promise<{
firstName: string;
lastName: string;
isActive: boolean;
whatsappNumber: string | null;
telegramUsername: string | null;
signalNumber: string | null;
createdAt: Date;
updatedAt: Date;
} | null>;
@@ -72,6 +79,10 @@ export declare function createUser(data: {
roleIds: number[];
customerId?: number;
hasDeveloperAccess?: boolean;
hasGdprAccess?: boolean;
whatsappNumber?: string;
telegramUsername?: string;
signalNumber?: string;
}): Promise<{
id: number;
email: string;
@@ -101,6 +112,10 @@ export declare function updateUser(id: number, data: {
roleIds?: number[];
customerId?: number;
hasDeveloperAccess?: boolean;
hasGdprAccess?: boolean;
whatsappNumber?: string;
telegramUsername?: string;
signalNumber?: string;
}): Promise<{
roles: ({
permissions: ({
@@ -127,6 +142,9 @@ export declare function updateUser(id: number, data: {
firstName: string;
lastName: string;
isActive: boolean;
whatsappNumber: string | null;
telegramUsername: string | null;
signalNumber: string | null;
createdAt: Date;
updatedAt: Date;
} | null>;
@@ -139,6 +157,9 @@ export declare function deleteUser(id: number): Promise<{
lastName: string;
isActive: boolean;
tokenInvalidatedAt: Date | null;
whatsappNumber: string | null;
telegramUsername: string | null;
signalNumber: string | null;
createdAt: Date;
updatedAt: Date;
}>;
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"user.service.d.ts","sourceRoot":"","sources":["../../src/services/user.service.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,WAAW;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC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;;;;KAItC"}
+72 -15
View File
@@ -48,6 +48,9 @@ async function getAllUsers(filters) {
lastName: true,
isActive: true,
customerId: true,
whatsappNumber: true,
telegramUsername: true,
signalNumber: true,
createdAt: true,
roles: {
include: {
@@ -62,20 +65,24 @@ async function getAllUsers(filters) {
}),
prisma.user.count({ where }),
]);
// Get Developer role ID
const developerRole = await prisma.role.findFirst({
where: { name: 'Developer' },
});
// Get hidden role IDs
const [developerRole, gdprRole] = await Promise.all([
prisma.role.findFirst({ where: { name: 'Developer' } }),
prisma.role.findFirst({ where: { name: 'DSGVO' } }),
]);
return {
users: users.map((u) => {
// Check if user has developer role assigned
const hasDeveloperAccess = developerRole
? u.roles.some((ur) => ur.roleId === developerRole.id)
: false;
const hasGdprAccess = gdprRole
? u.roles.some((ur) => ur.roleId === gdprRole.id)
: false;
return {
...u,
roles: u.roles.map((r) => r.role),
hasDeveloperAccess,
hasGdprAccess,
};
}),
pagination: (0, helpers_js_1.buildPaginationResponse)(page, limit, total),
@@ -91,6 +98,9 @@ async function getUserById(id) {
lastName: true,
isActive: true,
customerId: true,
whatsappNumber: true,
telegramUsername: true,
signalNumber: true,
createdAt: true,
updatedAt: true,
roles: {
@@ -129,6 +139,9 @@ async function createUser(data) {
firstName: data.firstName,
lastName: data.lastName,
customerId: data.customerId,
whatsappNumber: data.whatsappNumber || null,
telegramUsername: data.telegramUsername || null,
signalNumber: data.signalNumber || null,
roles: {
create: data.roleIds.map((roleId) => ({ roleId })),
},
@@ -149,10 +162,14 @@ async function createUser(data) {
if (data.hasDeveloperAccess) {
await setUserDeveloperAccess(user.id, true);
}
// DSGVO-Zugriff setzen falls aktiviert
if (data.hasGdprAccess) {
await setUserGdprAccess(user.id, true);
}
return user;
}
async function updateUser(id, data) {
const { roleIds, password, hasDeveloperAccess, ...userData } = data;
const { roleIds, password, hasDeveloperAccess, hasGdprAccess, ...userData } = data;
// Check if this would remove the last admin
const isBeingDeactivated = userData.isActive === false;
const rolesAreBeingChanged = roleIds !== undefined;
@@ -259,15 +276,17 @@ async function updateUser(id, data) {
});
}
// Handle developer access
console.log('updateUser - hasDeveloperAccess:', hasDeveloperAccess);
if (hasDeveloperAccess !== undefined) {
await setUserDeveloperAccess(id, hasDeveloperAccess);
}
// Handle GDPR access
if (hasGdprAccess !== undefined) {
await setUserGdprAccess(id, hasGdprAccess);
}
return getUserById(id);
}
// Helper to set developer access for a user
async function setUserDeveloperAccess(userId, enabled) {
console.log('setUserDeveloperAccess called - userId:', userId, 'enabled:', enabled);
// Get or create developer:access permission
let developerPerm = await prisma.permission.findFirst({
where: { resource: 'developer', action: 'access' },
@@ -296,10 +315,7 @@ async function setUserDeveloperAccess(userId, enabled) {
const hasRole = await prisma.userRole.findFirst({
where: { userId, roleId: developerRole.id },
});
console.log('setUserDeveloperAccess - developerRole.id:', developerRole.id, 'hasRole:', hasRole);
if (enabled && !hasRole) {
// Add Developer role
console.log('Adding Developer role');
await prisma.userRole.create({
data: { userId, roleId: developerRole.id },
});
@@ -310,8 +326,6 @@ async function setUserDeveloperAccess(userId, enabled) {
});
}
else if (!enabled && hasRole) {
// Remove Developer role
console.log('Removing Developer role');
await prisma.userRole.delete({
where: { userId_roleId: { userId, roleId: developerRole.id } },
});
@@ -321,8 +335,51 @@ async function setUserDeveloperAccess(userId, enabled) {
data: { tokenInvalidatedAt: new Date() },
});
}
else {
console.log('No action needed - enabled:', enabled, 'hasRole:', !!hasRole);
}
// Helper to set GDPR access for a user
async function setUserGdprAccess(userId, enabled) {
// Get or create DSGVO role
let gdprRole = await prisma.role.findFirst({
where: { name: 'DSGVO' },
});
if (!gdprRole) {
// Create DSGVO role with all audit:* and gdpr:* permissions
const gdprPermissions = await prisma.permission.findMany({
where: {
OR: [{ resource: 'audit' }, { resource: 'gdpr' }],
},
});
gdprRole = await prisma.role.create({
data: {
name: 'DSGVO',
description: 'DSGVO-Zugriff: Audit-Logs und Datenschutz-Verwaltung',
permissions: {
create: gdprPermissions.map((p) => ({ permissionId: p.id })),
},
},
});
}
// Check if user already has DSGVO role
const hasRole = await prisma.userRole.findFirst({
where: { userId, roleId: gdprRole.id },
});
if (enabled && !hasRole) {
await prisma.userRole.create({
data: { userId, roleId: gdprRole.id },
});
await prisma.user.update({
where: { id: userId },
data: { tokenInvalidatedAt: new Date() },
});
}
else if (!enabled && hasRole) {
await prisma.userRole.delete({
where: { userId_roleId: { userId, roleId: gdprRole.id } },
});
await prisma.user.update({
where: { id: userId },
data: { tokenInvalidatedAt: new Date() },
});
}
}
async function deleteUser(id) {
File diff suppressed because one or more lines are too long