From af3a793fe8b3ccc4752f49d225215e376d2a4f1b Mon Sep 17 00:00:00 2001
From: Alex <alex.tran1502@gmail.com>
Date: Mon, 19 Aug 2024 15:43:57 -0500
Subject: [PATCH] fix(server): create shared album from the mobile app does not
 trigger send email invite (#11911)

* fix(server): create shared album from the mobile app does not trigger send email invite

* remove unused value
---
 server/src/services/album.service.spec.ts | 4 ++++
 server/src/services/album.service.ts      | 4 ++++
 2 files changed, 8 insertions(+)

diff --git a/server/src/services/album.service.spec.ts b/server/src/services/album.service.spec.ts
index 6db39328df..406302ece9 100644
--- a/server/src/services/album.service.spec.ts
+++ b/server/src/services/album.service.spec.ts
@@ -205,6 +205,10 @@ describe(AlbumService.name, () => {
 
       expect(userMock.get).toHaveBeenCalledWith('user-id', {});
       expect(accessMock.asset.checkOwnerAccess).toHaveBeenCalledWith(authStub.admin.user.id, new Set(['123']));
+      expect(eventMock.emit).toHaveBeenCalledWith('onAlbumInvite', {
+        id: albumStub.empty.id,
+        userId: 'user-id',
+      });
     });
 
     it('should require valid userIds', async () => {
diff --git a/server/src/services/album.service.ts b/server/src/services/album.service.ts
index 71594d20b6..06f2a7a0fb 100644
--- a/server/src/services/album.service.ts
+++ b/server/src/services/album.service.ts
@@ -138,6 +138,10 @@ export class AlbumService {
       albumThumbnailAssetId: assets[0]?.id || null,
     });
 
+    for (const { userId } of albumUsers) {
+      await this.eventRepository.emit('onAlbumInvite', { id: album.id, userId });
+    }
+
     return mapAlbumWithAssets(album);
   }