Skip to content

Commit 101b34e

Browse files
committed
refactor: improve lifecycle event handling in LifecycleHooksService
- Enhanced the fireLifecycleEvent method to introduce a lifecycleChanged variable for better readability and maintainability. - Updated the logic to ensure lifecycle change events are processed correctly, including notifying backends of changed identities.
1 parent 8f99651 commit 101b34e

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

apps/api/src/management/lifecycle/lifecycle-hooks.service.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,9 @@ export class LifecycleHooksService extends AbstractLifecycleService {
433433
* // L'identité est automatiquement transitionnée vers MANUAL
434434
*/
435435
private async fireLifecycleEvent(before: Identities, after: Identities): Promise<void> {
436-
if (before.lifecycle !== after.lifecycle) {
436+
const lifecycleChanged = !!before && before.lifecycle !== after.lifecycle
437+
438+
if (lifecycleChanged) {
437439
await this.create({
438440
refId: after._id,
439441
lifecycle: after.lifecycle,
@@ -491,5 +493,10 @@ export class LifecycleHooksService extends AbstractLifecycleService {
491493
return
492494
}
493495
}
496+
497+
if (lifecycleChanged) {
498+
const identities = after._id ? [after._id] : []
499+
await this.backendsService.lifecycleChangedIdentities(identities)
500+
}
494501
}
495502
}

0 commit comments

Comments
 (0)