Skip to content

Commit

Permalink
fix(meeting): fix credits being consumed incorrectly when accept meet…
Browse files Browse the repository at this point in the history
…ing request
  • Loading branch information
KAispread committed Sep 28, 2023
1 parent 0d2429e commit 76757b4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import static com.e2i.wemeet.service.sns.SnsMessageFormat.getMeetingRequestMessage;
import static com.e2i.wemeet.util.validator.CustomExpirationValidator.isExpiredOfDays;

import com.e2i.wemeet.domain.cost.Spent;
import com.e2i.wemeet.domain.meeting.Meeting;
import com.e2i.wemeet.domain.meeting.MeetingRepository;
import com.e2i.wemeet.domain.meeting.MeetingRequest;
Expand Down Expand Up @@ -65,7 +66,7 @@ public Long sendRequest(final SendMeetingRequestDto requestDto, final Long membe
MeetingRequest request = meetingRequestRepository.save(meetingRequest);

// 이벤트 발행
publishMeetingEvent(getMeetingRequestMessage(), memberLeaderId, partnerTeam);
publishMeetingEvent(getMeetingRequestMessage(), memberLeaderId, partnerTeam, MEETING_REQUEST);
return request.getMeetingRequestId();
}

Expand All @@ -87,7 +88,8 @@ public Long sendRequestWithMessage(final SendMeetingWithMessageRequestDto reques
MeetingRequest request = meetingRequestRepository.save(meetingRequest);

// 이벤트 발행
publishMeetingWithMessageEvent(getMeetingRequestMessage(), memberLeaderId, partnerTeam);
publishMeetingEvent(getMeetingRequestMessage(), memberLeaderId, partnerTeam,
MEETING_REQUEST_WITH_MESSAGE);
return request.getMeetingRequestId();
}

Expand All @@ -108,7 +110,7 @@ public Long acceptRequest(final Long memberLeaderId, final Long meetingRequestId
// 미팅 성사 이벤트 발행
Team myTeam = meetingRequest.getTeam();
String leaderNickname = meetingRequest.getPartnerTeam().getTeamLeader().getNickname();
publishMeetingEvent(getMeetingAcceptMessage(leaderNickname), memberLeaderId, myTeam);
publishMeetingEvent(getMeetingAcceptMessage(leaderNickname), memberLeaderId, myTeam, MEETING_ACCEPT);

return saveMeeting(meetingRequest).getMeetingId();
}
Expand Down Expand Up @@ -176,26 +178,14 @@ private void validateHasAuthorizationToChangeStatus(Long memberLeaderId,

// 미팅 이벤트 발행
private void publishMeetingEvent(final String message, final Long memberLeaderId,
final Team targetTeam) {
final Team targetTeam, final Spent spent) {
String leaderPhoneNumber = meetingRepository.findLeaderPhoneNumberById(
targetTeam.getTeamId());
eventPublisher.publishEvent(
MeetingEvent.of(leaderPhoneNumber, message, MEETING_REQUEST, memberLeaderId)
MeetingEvent.of(leaderPhoneNumber, message, spent, memberLeaderId)
);
}

// 미팅 이벤트 발행
private void publishMeetingWithMessageEvent(final String message, final Long memberLeaderId,
final Team targetTeam) {
String leaderPhoneNumber = meetingRepository.findLeaderPhoneNumberById(
targetTeam.getTeamId());
eventPublisher.publishEvent(
MeetingEvent.of(leaderPhoneNumber, message, MEETING_REQUEST_WITH_MESSAGE,
memberLeaderId)
);
}


// 중복된 미팅 요청인지 검증
private void checkDuplicateMeetingRequest(Team team, Team partnerTeam,
LocalDateTime meetingRequestTime) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ void handleRequestToAccept() {
.extracting("team", "partnerTeam", "isOver")
.contains(kaiTeam, rimTeam, false));

assertThat(rim.getCredit()).isLessThan(rimCredit);
assertThat(rim.getCredit()).isEqualTo(rimCredit - 5);
}

@DisplayName("받았던 미팅 신청을 여러번 수락할 수 없다.")
Expand Down

0 comments on commit 76757b4

Please sign in to comment.