diff --git a/moring-domain/src/main/java/org/depromeet/sambad/moring/domain/event/application/EventService.java b/moring-domain/src/main/java/org/depromeet/sambad/moring/domain/event/application/EventService.java index 3b98b850..91bf9d68 100644 --- a/moring-domain/src/main/java/org/depromeet/sambad/moring/domain/event/application/EventService.java +++ b/moring-domain/src/main/java/org/depromeet/sambad/moring/domain/event/application/EventService.java @@ -42,7 +42,7 @@ public void publishHandWavingEvent( handWaving.mapEvent(event); } - private Event publish(Long userId, Long meetingId, EventType type, Map contentsMap) { + public Event publish(Long userId, Long meetingId, EventType type, Map contentsMap) { if (meetingMemberValidator.isNotUserOfMeeting(userId, meetingId)) { log.warn("User is not member of meeting. userId: {}, meetingId: {}", userId, meetingId); return null; diff --git a/moring-domain/src/main/java/org/depromeet/sambad/moring/domain/event/domain/EventType.java b/moring-domain/src/main/java/org/depromeet/sambad/moring/domain/event/domain/EventType.java index 80074655..87734896 100644 --- a/moring-domain/src/main/java/org/depromeet/sambad/moring/domain/event/domain/EventType.java +++ b/moring-domain/src/main/java/org/depromeet/sambad/moring/domain/event/domain/EventType.java @@ -4,5 +4,7 @@ public enum EventType { QUESTION_REGISTERED, TARGET_MEMBER, HAND_WAVING_REQUESTED, + HAND_WAVING_ACCEPTED, + HAND_WAVING_REJECTED, ; } diff --git a/moring-domain/src/main/java/org/depromeet/sambad/moring/domain/meeting/handwaving/application/HandWavingService.java b/moring-domain/src/main/java/org/depromeet/sambad/moring/domain/meeting/handwaving/application/HandWavingService.java index f61404b2..095c100f 100644 --- a/moring-domain/src/main/java/org/depromeet/sambad/moring/domain/meeting/handwaving/application/HandWavingService.java +++ b/moring-domain/src/main/java/org/depromeet/sambad/moring/domain/meeting/handwaving/application/HandWavingService.java @@ -1,5 +1,6 @@ package org.depromeet.sambad.moring.domain.meeting.handwaving.application; +import static org.depromeet.sambad.moring.domain.event.domain.EventType.*; import static org.depromeet.sambad.moring.domain.meeting.handwaving.domain.HandWavingStatus.*; import java.util.List; @@ -57,7 +58,9 @@ public void acceptHandWaving(Long userId, Long meetingId, Long handWavingId) { HandWaving handWaving = getHandWavingById(handWavingId); handWaving.validateIsReceiver(userId); handWaving.accept(); + inactiveHandWavingEvent(handWaving); + publishAcceptedEvent(handWaving); } @Transactional @@ -66,7 +69,9 @@ public void ignoreHandWaving(Long userId, Long meetingId, Long handWavingId) { HandWaving handWaving = getHandWavingById(handWavingId); handWaving.validateIsReceiver(userId); handWaving.reject(); + inactiveHandWavingEvent(handWaving); + publishRejectedEvent(handWaving); } public List getHandWavingSummariesBy(List events) { @@ -101,7 +106,8 @@ private void publishRequestedEvent(HandWaving handWaving) { Long userId = receiver.getUser().getId(); Long meetingId = receiver.getMeeting().getId(); - eventService.publishHandWavingEvent(userId, meetingId, EventType.HAND_WAVING_REQUESTED, contentsMap, handWaving); + eventService.publishHandWavingEvent(userId, meetingId, EventType.HAND_WAVING_REQUESTED, contentsMap, + handWaving); } private void inactiveHandWavingEvent(HandWaving handWaving) { @@ -110,4 +116,36 @@ private void inactiveHandWavingEvent(HandWaving handWaving) { eventService.inactivate(eventId); } } + + private void publishAcceptedEvent(HandWaving handWaving) { + publishAcceptedEventToSender(handWaving); + publishAcceptedEventToReceiver(handWaving); + } + + private void publishRejectedEvent(HandWaving handWaving) { + // 내가 거절했으므로, 거절한 상대방의 이름이 메시지에 포함되어야 함 + Map contentsMap = Map.of("member", handWaving.getSender().getName()); + + // 이벤트의 대상은 본인이므로, Receiver의 정보를 사용함 + Long userId = handWaving.getReceiver().getUser().getId(); + Long meetingId = handWaving.getReceiver().getMeeting().getId(); + + eventService.publish(userId, meetingId, HAND_WAVING_REJECTED, contentsMap); + } + + private void publishAcceptedEventToSender(HandWaving handWaving) { + Map contentsMap = Map.of("member", handWaving.getReceiver().getName()); + Long userId = handWaving.getSender().getUser().getId(); + Long meetingId = handWaving.getSender().getMeeting().getId(); + + eventService.publish(userId, meetingId, HAND_WAVING_ACCEPTED, contentsMap); + } + + private void publishAcceptedEventToReceiver(HandWaving handWaving) { + Map contentsMap = Map.of("member", handWaving.getSender().getName()); + Long userId = handWaving.getReceiver().getUser().getId(); + Long meetingId = handWaving.getReceiver().getMeeting().getId(); + + eventService.publish(userId, meetingId, HAND_WAVING_ACCEPTED, contentsMap); + } }