Skip to content

Commit

Permalink
[feat] : 자동거절 시 알림 생성 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
dudxo committed Nov 28, 2024
1 parent 741a63f commit 29cdcff
Showing 1 changed file with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import com.dnd.gongmuin.chat_inquiry.dto.ChatInquiryResponse;
import com.dnd.gongmuin.chat_inquiry.dto.CreateChatInquiryRequest;
import com.dnd.gongmuin.chat_inquiry.dto.CreateChatInquiryResponse;
import com.dnd.gongmuin.chat_inquiry.dto.RejectChatInquiryDto;
import com.dnd.gongmuin.chat_inquiry.dto.RejectChatResponse;
import com.dnd.gongmuin.chat_inquiry.exception.ChatInquiryErrorCode;
import com.dnd.gongmuin.chat_inquiry.repository.ChatInquiryRepository;
Expand Down Expand Up @@ -129,11 +130,33 @@ public RejectChatResponse rejectChat(Long chatInquiryId, Member answerer) {
@Transactional
public void rejectChatAuto() {
List<Long> rejectedInquirerIds = chatInquiryRepository.getAutoRejectedInquirerIds();
List<RejectChatInquiryDto> rejectChatInquiryDtos = chatInquiryRepository.getAutoRejectedChatInquiry();
chatInquiryRepository.updateChatInquiryStatusRejected();
memberRepository.refundInMemberIds(rejectedInquirerIds, CHAT_REWARD);
creditHistoryService.saveCreditHistoryInMemberIds(
rejectedInquirerIds, CreditType.CHAT_REFUND, CHAT_REWARD
);

autoRejectedChatInquiryNotification(rejectChatInquiryDtos);
}

private void autoRejectedChatInquiryNotification(List<RejectChatInquiryDto> rejectChatInquiryDtos) {
for (RejectChatInquiryDto rejectChatInquiry : rejectChatInquiryDtos) {
eventPublisher.publishEvent( // 채팅 요청자 알림
new NotificationEvent(
NotificationType.AUTO_CHAT_REJECT,
rejectChatInquiry.chatInquiryId(),
rejectChatInquiry.inquirer().getId(),
rejectChatInquiry.inquirer())
);
eventPublisher.publishEvent(
new NotificationEvent( // 채팅 답변자 알림
NotificationType.AUTO_CHAT_REJECT,
rejectChatInquiry.chatInquiryId(),
rejectChatInquiry.answer().getId(),
rejectChatInquiry.answer())
);
}
}

private ChatInquiry getChatInquiryById(Long id) {
Expand Down

0 comments on commit 29cdcff

Please sign in to comment.