@@ -4,7 +4,7 @@ import lombok.Getter;
|
|||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
public enum NotificationMessage {
|
public enum NotificationMessage {
|
||||||
FILE_SEARCH("notification-file-search");
|
FILE_SEARCH("notification.file.search");
|
||||||
|
|
||||||
private final String messageKey;
|
private final String messageKey;
|
||||||
|
|
||||||
|
|||||||
@@ -4,24 +4,24 @@ import lombok.Getter;
|
|||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
public enum NotificationType {
|
public enum NotificationType {
|
||||||
SEARCH_RESULT("notification-search-result"),
|
SEARCH_RESULT("notification.search.result"),
|
||||||
MONITORING_RESULT("notification-monitoring-result"),
|
MONITORING_RESULT("notification.monitoring.result"),
|
||||||
OPERATION_IMPOSSIBLE("notification-operation-impossible"),
|
OPERATION_IMPOSSIBLE("notification.operation.impossible"),
|
||||||
START_FAILED_NOW("notification-start-failed-now"),
|
START_FAILED_NOW("notification.start.failed.now"),
|
||||||
START_FAILED_NEXT("notification-start-failed-next"),
|
START_FAILED_NEXT("notification.start.failed.next"),
|
||||||
PAYOUT_RESULT("notification-payout-result"),
|
PAYOUT_RESULT("notification.payout.result"),
|
||||||
PAYMENT_RESULT("notification-payment-result"),
|
PAYMENT_RESULT("notification.payment.result"),
|
||||||
REFERRAL_DEPOSIT("notification-referral-deposit"),
|
REFERRAL_DEPOSIT("notification.referral.deposit"),
|
||||||
REFERRAL_REGISTERED("notification-referral-registered"),
|
REFERRAL_REGISTERED("notification.referral.registered"),
|
||||||
REFERRAL_ACTIVATED("notification-referral-activated"),
|
REFERRAL_ACTIVATED("notification.referral.activated"),
|
||||||
COMPLAINT_STATUS_CHANGED("notification-complaint-status"),
|
COMPLAINT_STATUS_CHANGED("notification.complaint.status"),
|
||||||
CASE_STATUS_CHANGED("notification-case-status"),
|
CASE_STATUS_CHANGED("notification.case.status"),
|
||||||
INCOMING_MESSAGE("notification-incoming-message"),
|
INCOMING_MESSAGE("notification.incoming.message"),
|
||||||
TARIFF_EXPIRING("notification-tariff-expiring"),
|
TARIFF_EXPIRING("notification.tariff.expiring"),
|
||||||
TOKEN_NOT_FOUND("notification-token-not-found"),
|
TOKEN_NOT_FOUND("notification.token.not.found"),
|
||||||
FILE_MODERATION_EVENT("notification-file-moderation"),
|
FILE_MODERATION_EVENT("notification.file.moderation"),
|
||||||
FILE_ADDED_TO_SYSTEM("notification-file-added"),
|
FILE_ADDED_TO_SYSTEM("notification.file.added"),
|
||||||
SEARCH_OPERATION_FAILED("notification-search-operation-filed");
|
SEARCH_OPERATION_FAILED("notification.search.operation.filed");
|
||||||
|
|
||||||
private final String messageKey;
|
private final String messageKey;
|
||||||
|
|
||||||
|
|||||||
@@ -34,16 +34,12 @@ public class NotificationService {
|
|||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public void addNotification(NotificationType notificationType, long userId, Object... args) {
|
public void addNotification(NotificationType notificationType, long userId, Object... args) {
|
||||||
Locale locale = Locale.forLanguageTag("ru");
|
|
||||||
|
|
||||||
String message = messageSource.getMessage(notificationType.getMessageKey(), args, locale);
|
|
||||||
|
|
||||||
Notification notification = Notification.builder()
|
Notification notification = Notification.builder()
|
||||||
.notificationType(notificationType)
|
.notificationType(notificationType)
|
||||||
.createdAt(LocalDateTime.now())
|
.createdAt(LocalDateTime.now())
|
||||||
.user(userRepository.findById(userId).orElseThrow())
|
.user(userRepository.findById(userId).orElseThrow())
|
||||||
.status(NotificationStatus.NEW)
|
.status(NotificationStatus.NEW)
|
||||||
.message(message)
|
.message(notificationType.getMessageKey())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
notificationRepository.save(notification);
|
notificationRepository.save(notification);
|
||||||
|
|||||||
Reference in New Issue
Block a user