Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: 타겟편지 작성 시, 대상에게 알림 전송 #170

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@
import postman.bottler.mapletter.exception.LetterAlreadyReplyException;
import postman.bottler.mapletter.exception.MapLetterAlreadyArchivedException;
import postman.bottler.mapletter.exception.PageRequestException;
import postman.bottler.notification.domain.NotificationType;
import postman.bottler.notification.dto.request.NotificationLabelRequestDTO;
import postman.bottler.notification.service.NotificationService;
import postman.bottler.reply.dto.ReplyType;
import postman.bottler.user.service.UserService;

Expand All @@ -50,6 +52,7 @@ public class MapLetterService {
private final ReplyMapLetterRepository replyMapLetterRepository;
private final MapLetterArchiveRepository mapLetterArchiveRepository;
private final UserService userService;
private final NotificationService notificationService;
private final RedisTemplate<String, Object> redisTemplate;

private static final double VIEW_DISTANCE = 15;
Expand All @@ -67,7 +70,9 @@ public MapLetter createTargetMapLetter(CreateTargetMapLetterRequestDTO createTar
Long userId) {
Long targetUserId = userService.getUserIdByNickname(createTargetMapLetterRequestDTO.target());
MapLetter mapLetter = MapLetter.createTargetMapLetter(createTargetMapLetterRequestDTO, userId, targetUserId);
return mapLetterRepository.save(mapLetter);
MapLetter save = mapLetterRepository.save(mapLetter);
notificationService.sendNotification(NotificationType.TARGET_LETTER, targetUserId, save.getId());
return save;
}

@Transactional(readOnly = true)
Expand Down
Loading