Added the document ID in document controller firebase data notification

This commit is contained in:
ashutosh.nehete 2025-09-18 15:04:41 +05:30
parent 3f8024421a
commit ac672d0cc2
3 changed files with 16 additions and 14 deletions

View File

@ -861,7 +861,7 @@ namespace Marco.Pms.Services.Controllers
Body = $"Document added to your profile of type \"{documentType.Name}\" by {name}" 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) if (ProjectEntity == entityType)
{ {
@ -871,7 +871,7 @@ namespace Marco.Pms.Services.Controllers
Body = $"Document added to your Project of type \"{documentType.Name}\" by {name}" 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}" 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) 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}" 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}" 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) if (ProjectEntity == entityType)
{ {
@ -1386,7 +1386,7 @@ namespace Marco.Pms.Services.Controllers
Body = $"Your Project Document of type \"{documentType?.Name}\" is updated by {name}" 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}" 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) if (ProjectEntity == entityType)
{ {
@ -1505,7 +1505,7 @@ namespace Marco.Pms.Services.Controllers
Body = $"Your Project Document of type \"{documentType?.Name}\" is {message} by {name}" 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);
} }
}); });

View File

@ -1785,7 +1785,7 @@ namespace Marco.Pms.Services.Service
} }
//Document Controller //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(); await using var _context = await _dbContextFactory.CreateDbContextAsync();
using var scope = _serviceScopeFactory.CreateScope(); using var scope = _serviceScopeFactory.CreateScope();
@ -1804,14 +1804,15 @@ namespace Marco.Pms.Services.Service
var data = new Dictionary<string, string>() var data = new Dictionary<string, string>()
{ {
{ "Keyword", "Employee_Document_Modified" }, { "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(); 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); 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(); await using var _context = await _dbContextFactory.CreateDbContextAsync();
using var scope = _serviceScopeFactory.CreateScope(); using var scope = _serviceScopeFactory.CreateScope();
@ -1872,7 +1873,8 @@ namespace Marco.Pms.Services.Service
var data = new Dictionary<string, string>() var data = new Dictionary<string, string>()
{ {
{ "Keyword", "Project_Document_Modified" }, { "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(); var registrationTokensForNotification = await _context.FCMTokenMappings.Where(ft => finalEmployeeIds.Contains(ft.EmployeeId) && ft.ExpiredAt >= DateTime.UtcNow).Select(ft => ft.FcmToken).ToListAsync();

View File

@ -29,7 +29,7 @@ namespace Marco.Pms.Services.Service.ServiceInterfaces
Task SendBucketAsync(Guid bucketId, Notification notification, Guid tenantId); Task SendBucketAsync(Guid bucketId, Notification notification, Guid tenantId);
Task SendAssignBucketAsync(List<Guid> employeeIds, Notification notification, Guid tenantId); Task SendAssignBucketAsync(List<Guid> employeeIds, Notification notification, Guid tenantId);
Task SendEmployeeDocumentMessageAsync(Guid employeeId, Notification notification, Guid tenantId); Task SendEmployeeDocumentMessageAsync(Guid documentId, Guid employeeId, Notification notification, Guid tenantId);
Task SendProjectDocumentMessageAsync(Guid projectId, Notification notification, Guid tenantId); Task SendProjectDocumentMessageAsync(Guid documentId, Guid projectId, Notification notification, Guid tenantId);
} }
} }