From ac672d0cc2a5e2b5fb19be9587c591b4ccecb7b1 Mon Sep 17 00:00:00 2001 From: "ashutosh.nehete" Date: Thu, 18 Sep 2025 15:04:41 +0530 Subject: [PATCH] Added the document ID in document controller firebase data notification --- .../Controllers/DocumentController.cs | 16 ++++++++-------- Marco.Pms.Services/Service/FirebaseService.cs | 10 ++++++---- .../ServiceInterfaces/IFirebaseService.cs | 4 ++-- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/Marco.Pms.Services/Controllers/DocumentController.cs b/Marco.Pms.Services/Controllers/DocumentController.cs index f145e7b..f450c41 100644 --- a/Marco.Pms.Services/Controllers/DocumentController.cs +++ b/Marco.Pms.Services/Controllers/DocumentController.cs @@ -861,7 +861,7 @@ namespace Marco.Pms.Services.Controllers Body = $"Document added to your profile of type \"{documentType.Name}\" by {name}" }; - await _firebase.SendEmployeeDocumentMessageAsync(model.EntityId, notification, tenantId); + await _firebase.SendEmployeeDocumentMessageAsync(attachment.Id, model.EntityId, notification, tenantId); } if (ProjectEntity == entityType) { @@ -871,7 +871,7 @@ namespace Marco.Pms.Services.Controllers Body = $"Document added to your Project of type \"{documentType.Name}\" by {name}" }; - await _firebase.SendProjectDocumentMessageAsync(model.EntityId, notification, tenantId); + await _firebase.SendProjectDocumentMessageAsync(attachment.Id, model.EntityId, notification, tenantId); } }); @@ -988,7 +988,7 @@ namespace Marco.Pms.Services.Controllers Body = $"Your Document of type \"{documentType?.Name}\" is Verified by {name}" }; - await _firebase.SendEmployeeDocumentMessageAsync(documentAttachment.EntityId, notification, tenantId); + await _firebase.SendEmployeeDocumentMessageAsync(documentAttachment.Id, documentAttachment.EntityId, notification, tenantId); } if (ProjectEntity == entityType) { @@ -998,7 +998,7 @@ namespace Marco.Pms.Services.Controllers Body = $"Document for your Project of type \"{documentType?.Name}\" is Verified by {name}" }; - await _firebase.SendProjectDocumentMessageAsync(documentAttachment.EntityId, notification, tenantId); + await _firebase.SendProjectDocumentMessageAsync(documentAttachment.Id, documentAttachment.EntityId, notification, tenantId); } }); @@ -1376,7 +1376,7 @@ namespace Marco.Pms.Services.Controllers Body = $"Your Document of type \"{documentType?.Name}\" is updated by {name}" }; - await _firebase.SendEmployeeDocumentMessageAsync(newAttachment.EntityId, notification, tenantId); + await _firebase.SendEmployeeDocumentMessageAsync(newAttachment.Id, newAttachment.EntityId, notification, tenantId); } if (ProjectEntity == entityType) { @@ -1386,7 +1386,7 @@ namespace Marco.Pms.Services.Controllers Body = $"Your Project Document of type \"{documentType?.Name}\" is updated by {name}" }; - await _firebase.SendProjectDocumentMessageAsync(newAttachment.EntityId, notification, tenantId); + await _firebase.SendProjectDocumentMessageAsync(newAttachment.Id, newAttachment.EntityId, notification, tenantId); } }); @@ -1495,7 +1495,7 @@ namespace Marco.Pms.Services.Controllers Body = $"Your Document of type \"{documentType?.Name}\" is {message} by {name}" }; - await _firebase.SendEmployeeDocumentMessageAsync(documentAttachment.EntityId, notification, tenantId); + await _firebase.SendEmployeeDocumentMessageAsync(documentAttachment.Id, documentAttachment.EntityId, notification, tenantId); } if (ProjectEntity == entityType) { @@ -1505,7 +1505,7 @@ namespace Marco.Pms.Services.Controllers Body = $"Your Project Document of type \"{documentType?.Name}\" is {message} by {name}" }; - await _firebase.SendProjectDocumentMessageAsync(documentAttachment.EntityId, notification, tenantId); + await _firebase.SendProjectDocumentMessageAsync(documentAttachment.Id, documentAttachment.EntityId, notification, tenantId); } }); diff --git a/Marco.Pms.Services/Service/FirebaseService.cs b/Marco.Pms.Services/Service/FirebaseService.cs index edd3cfe..36299b3 100644 --- a/Marco.Pms.Services/Service/FirebaseService.cs +++ b/Marco.Pms.Services/Service/FirebaseService.cs @@ -1785,7 +1785,7 @@ namespace Marco.Pms.Services.Service } //Document Controller - public async Task SendEmployeeDocumentMessageAsync(Guid employeeId, Notification notification, Guid tenantId) + public async Task SendEmployeeDocumentMessageAsync(Guid documentId, Guid employeeId, Notification notification, Guid tenantId) { await using var _context = await _dbContextFactory.CreateDbContextAsync(); using var scope = _serviceScopeFactory.CreateScope(); @@ -1804,14 +1804,15 @@ namespace Marco.Pms.Services.Service var data = new Dictionary() { { "Keyword", "Employee_Document_Modified" }, - { "EmployeeId", employeeId.ToString() } + { "EmployeeId", employeeId.ToString() }, + { "DocumentId", documentId.ToString() } }; var registrationTokensForNotification = await _context.FCMTokenMappings.Where(ft => employeeIds.Contains(ft.EmployeeId) && ft.ExpiredAt >= DateTime.UtcNow).Select(ft => ft.FcmToken).ToListAsync(); await SendMessageToMultipleDevicesWithDataAsync(registrationTokensForNotification, notification, data); } - public async Task SendProjectDocumentMessageAsync(Guid projectId, Notification notification, Guid tenantId) + public async Task SendProjectDocumentMessageAsync(Guid documentId, Guid projectId, Notification notification, Guid tenantId) { await using var _context = await _dbContextFactory.CreateDbContextAsync(); using var scope = _serviceScopeFactory.CreateScope(); @@ -1872,7 +1873,8 @@ namespace Marco.Pms.Services.Service var data = new Dictionary() { { "Keyword", "Project_Document_Modified" }, - { "ProjectId", projectId.ToString() } + { "ProjectId", projectId.ToString() }, + { "DocumentId", documentId.ToString() } }; var registrationTokensForNotification = await _context.FCMTokenMappings.Where(ft => finalEmployeeIds.Contains(ft.EmployeeId) && ft.ExpiredAt >= DateTime.UtcNow).Select(ft => ft.FcmToken).ToListAsync(); diff --git a/Marco.Pms.Services/Service/ServiceInterfaces/IFirebaseService.cs b/Marco.Pms.Services/Service/ServiceInterfaces/IFirebaseService.cs index 64aaa9a..5bc2360 100644 --- a/Marco.Pms.Services/Service/ServiceInterfaces/IFirebaseService.cs +++ b/Marco.Pms.Services/Service/ServiceInterfaces/IFirebaseService.cs @@ -29,7 +29,7 @@ namespace Marco.Pms.Services.Service.ServiceInterfaces Task SendBucketAsync(Guid bucketId, Notification notification, Guid tenantId); Task SendAssignBucketAsync(List employeeIds, Notification notification, Guid tenantId); - Task SendEmployeeDocumentMessageAsync(Guid employeeId, Notification notification, Guid tenantId); - Task SendProjectDocumentMessageAsync(Guid projectId, Notification notification, Guid tenantId); + Task SendEmployeeDocumentMessageAsync(Guid documentId, Guid employeeId, Notification notification, Guid tenantId); + Task SendProjectDocumentMessageAsync(Guid documentId, Guid projectId, Notification notification, Guid tenantId); } }