Updated code.

This commit is contained in:
piyushkag
2024-12-13 22:09:23 +05:30
parent d8e51f3a70
commit 91ec063327
2 changed files with 20 additions and 18 deletions

View File

@@ -119,9 +119,6 @@ public class CallDao {
@Autowired
private NotificationTypeRepository notificationTypeRepository;
@Autowired
private UserWithCompanyRepository userWithCompanyRepository;
public CallResponse createCallStep1(CreateCallRequestStep1 createCallRequest, UserEntity userEntity) {
createCallRequest.setRegionId(userEntity.getRoleEntity().getRegion().getId());
CallEntity callEntity = convertToCallEntity(createCallRequest, userEntity);
@@ -848,9 +845,7 @@ public class CallDao {
Map<String, String> placeholders = new HashMap<>();
placeholders.put("{{call_name}}", callEntity.getName());
userIds.forEach(userId -> {
NotificationReq notificationReq = createNotificationReq(NotificationTypeEnum.CALL_CREATED.getValue(), placeholders, userId);
List<Long> companyIds = userWithCompanyRepository.findActiveCompanyIdsByUserId(notificationReq.getUserId());
notificationReq.setCompanyIds(companyIds);
NotificationReq notificationReq = notificationDao.createNotificationReq(NotificationTypeEnum.CALL_CREATED.getValue(), placeholders, userId);
notificationDao.sendNotification(notificationReq);
});
@@ -860,18 +855,6 @@ public class CallDao {
return convertToCallResponseBean(callEntity);
}
public NotificationReq createNotificationReq(String notificationType, Map<String, String> placeholders, Long userId) {
// Create NotificationReq object
NotificationReq notificationReq = new NotificationReq();
NotificationTypeEntity notificationTypeEntity = notificationTypeRepository.findByNotificationNameAndIsDeletedFalse(notificationType);
notificationReq.setNotificationType(notificationType);
String message = Utils.replacePlaceholders(notificationTypeEntity.getJsonTemplate(), placeholders);
notificationReq.setMessage(message);
notificationReq.setUserId(userId);
return notificationReq;
}
private void validateStatusChange(CallStatusEnum currentStatus, CallStatusEnum newStatus) {
if (currentStatus == newStatus) {
throw new CustomValidationException(Status.VALIDATION_ERROR,