From 9a1c29484b9a750ddbb924b3aa971fd983b48955 Mon Sep 17 00:00:00 2001
From: Phillip <phillip.wirth@dataport.de>
Date: Wed, 18 Dec 2024 14:22:51 +0100
Subject: [PATCH] BC-8592 add externalId to GroupProvisioningInfoLoggable
 (#5404)

---
 .../loggable/group-provisioning-info.loggable.spec.ts      | 3 ++-
 .../loggable/group-provisioning-info.loggable.ts           | 7 ++++++-
 .../strategy/schulconnex/schulconnex.strategy.ts           | 4 +++-
 3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/apps/server/src/modules/provisioning/loggable/group-provisioning-info.loggable.spec.ts b/apps/server/src/modules/provisioning/loggable/group-provisioning-info.loggable.spec.ts
index fb67f57ea0..3e880155d4 100644
--- a/apps/server/src/modules/provisioning/loggable/group-provisioning-info.loggable.spec.ts
+++ b/apps/server/src/modules/provisioning/loggable/group-provisioning-info.loggable.spec.ts
@@ -11,7 +11,7 @@ describe(GroupProvisioningInfoLoggable.name, () => {
 				otherUsers: externalGroupUserDtoFactory.buildList(otherUserCount),
 			});
 
-			const loggable = new GroupProvisioningInfoLoggable(externalGroups, 100);
+			const loggable = new GroupProvisioningInfoLoggable(externalGroups, 100, 'igorHatGesagt');
 
 			return {
 				loggable,
@@ -31,6 +31,7 @@ describe(GroupProvisioningInfoLoggable.name, () => {
 					groupCount,
 					userCount: totalUserCount,
 					durationMs: 100,
+					externalUserId: 'igorHatGesagt',
 				},
 			});
 		});
diff --git a/apps/server/src/modules/provisioning/loggable/group-provisioning-info.loggable.ts b/apps/server/src/modules/provisioning/loggable/group-provisioning-info.loggable.ts
index 537a31e785..57819c4538 100644
--- a/apps/server/src/modules/provisioning/loggable/group-provisioning-info.loggable.ts
+++ b/apps/server/src/modules/provisioning/loggable/group-provisioning-info.loggable.ts
@@ -2,7 +2,11 @@ import { ErrorLogMessage, Loggable, LogMessage, ValidationErrorLogMessage } from
 import { ExternalGroupDto } from '../dto';
 
 export class GroupProvisioningInfoLoggable implements Loggable {
-	constructor(private readonly groups: ExternalGroupDto[], private readonly durationMs: number) {}
+	constructor(
+		private readonly groups: ExternalGroupDto[],
+		private readonly durationMs: number,
+		private readonly externalUserId: string
+	) {}
 
 	public getLogMessage(): LogMessage | ErrorLogMessage | ValidationErrorLogMessage {
 		const userCount = this.groups.reduce(
@@ -16,6 +20,7 @@ export class GroupProvisioningInfoLoggable implements Loggable {
 				groupCount: this.groups.length,
 				userCount,
 				durationMs: this.durationMs,
+				externalUserId: this.externalUserId,
 			},
 		};
 	}
diff --git a/apps/server/src/modules/provisioning/strategy/schulconnex/schulconnex.strategy.ts b/apps/server/src/modules/provisioning/strategy/schulconnex/schulconnex.strategy.ts
index 1c3737a687..24f53bbf12 100644
--- a/apps/server/src/modules/provisioning/strategy/schulconnex/schulconnex.strategy.ts
+++ b/apps/server/src/modules/provisioning/strategy/schulconnex/schulconnex.strategy.ts
@@ -103,7 +103,9 @@ export abstract class SchulconnexProvisioningStrategy extends ProvisioningStrate
 		}
 
 		const endTime = performance.now();
-		this.logger.warning(new GroupProvisioningInfoLoggable(data.externalGroups ?? [], endTime - startTime));
+		this.logger.warning(
+			new GroupProvisioningInfoLoggable(data.externalGroups ?? [], endTime - startTime, data.externalUser.externalId)
+		);
 	}
 
 	private async removeUserFromGroups(data: OauthDataDto): Promise<void> {