Skip to content

Commit

Permalink
fix: 뒤늦게 신청한 상대의 친구 선택 상태가 변경되지 않는 버그 수정 (#153)
Browse files Browse the repository at this point in the history
  • Loading branch information
zionhann committed Mar 17, 2024
1 parent f551a14 commit 7c0bcbd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public static StudyApplicant of(
return applicant;
}

public void changeStatusIfPartnerRequested(
public void changeStatusIfReceivedBy(
User user, Function<StudyPartnerRequest, RequestStatus> changeStatus) {
this.partnerRequests.stream()
.filter(request -> request.isReceivedBy(user))
Expand Down
20 changes: 13 additions & 7 deletions src/main/java/edu/handong/csee/histudy/service/UserService.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,12 @@ public ApplyFormDto apply(ApplyForm form, String email) {
studyApplicantRepository
.findByUserAndTerm(partner, currentTerm)
.ifPresent(
partnerApplication ->
partnerApplication.changeStatusIfPartnerRequested(
user, StudyPartnerRequest::accept)));
partnerApplication -> {
partnerApplication.changeStatusIfReceivedBy(
user, StudyPartnerRequest::accept);

applicant.changeStatusIfReceivedBy(partner, StudyPartnerRequest::accept);
}));
studyApplicantRepository.save(applicant);
return new ApplyFormDto(applicant);
}
Expand Down Expand Up @@ -88,9 +91,12 @@ public StudyApplicant apply(List<Long> friendsIds, List<Long> courseIds, String
studyApplicantRepository
.findByUserAndTerm(partner, currentTerm)
.ifPresent(
partnerApplication ->
partnerApplication.changeStatusIfPartnerRequested(
user, StudyPartnerRequest::accept)));
partnerApplication -> {
partnerApplication.changeStatusIfReceivedBy(
user, StudyPartnerRequest::accept);

applicant.changeStatusIfReceivedBy(partner, StudyPartnerRequest::accept);
}));
return studyApplicantRepository.save(applicant);
}

Expand All @@ -109,7 +115,7 @@ private void removeFormHistoryIfExists(User user, AcademicTerm currentTerm) {
.findByUserAndTerm(receiver, currentTerm)
.ifPresent(
partnerApplication ->
partnerApplication.changeStatusIfPartnerRequested(
partnerApplication.changeStatusIfReceivedBy(
user, StudyPartnerRequest::unfriend));
}
studyApplicantRepository.delete(applicant);
Expand Down

0 comments on commit 7c0bcbd

Please sign in to comment.