Skip to content

Commit 33152de

Browse files
authored
Merge pull request #121 from SynclyProject/fix/#120
πŸ› fix: νƒˆν‡΄ν•œ μ‚¬μš©μž μž¬μ΄ˆλŒ€ μ‹œ 쀑볡 μ΄ˆλŒ€ 쑰회 였λ₯˜ μˆ˜μ •
2 parents e779353 + 8d7f276 commit 33152de

2 files changed

Lines changed: 11 additions & 10 deletions

File tree

β€Žsrc/main/java/com/project/syncly/domain/workspace/repository/WorkspaceInvitationRepository.javaβ€Ž

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ public interface WorkspaceInvitationRepository extends JpaRepository<WorkspaceIn
1717
//이미 λ³΄λŒ„ μ΄ˆλŒ€κ°€ μžˆλ‹€λ©΄, 쑰회
1818
Optional<WorkspaceInvitation> findByWorkspaceIdAndInviteeIdAndExpiredAtAfter(Long workspaceId, Long inviteeId, LocalDateTime now);
1919

20+
//PENDING μƒνƒœμ˜ μ΄ˆλŒ€λ§Œ 쑰회 (νƒˆν‡΄ ν›„ μž¬μ΄ˆλŒ€ μ‹œ 쀑볡 λ°©μ§€)
21+
Optional<WorkspaceInvitation> findByWorkspaceIdAndInviteeIdAndTypeAndExpiredAtAfter(Long workspaceId, Long inviteeId, InvitationType type, LocalDateTime now);
22+
2023
//ν† ν°μœΌλ‘œ μ΄ˆλŒ€ 쑰회
2124
Optional<WorkspaceInvitation> findByToken(String token);
2225

β€Žsrc/main/java/com/project/syncly/domain/workspace/service/WorkspaceServiceImpl.javaβ€Ž

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
import java.time.LocalDateTime;
2929
import java.util.List;
30+
import java.util.Optional;
3031

3132
@Service
3233
@Transactional
@@ -137,16 +138,13 @@ public WorkspaceResponseDto.InviteWorkspaceResponseDto inviteTeamWorkspace(Long
137138
throw new CustomException(WorkspaceErrorCode.ALREADY_WORKSPACE_MEMBER);
138139
}
139140

140-
// 아직 λ§Œλ£Œλ˜μ§€ μ•Šμ€ μ΄ˆλŒ€κ°€ μžˆλŠ”μ§€ 확인
141-
boolean hasActiveInvite = workspaceInvitationRepository.existsByWorkspaceIdAndInviteeIdAndExpiredAtAfter(
142-
workspaceId, invitee.getId(), LocalDateTime.now());
143-
if (hasActiveInvite) {
144-
//μ΄ˆλŒ€ 만료 μ „ μ΄ˆλŒ€κ°€ μ‘΄μž¬ν•˜λ‚˜, 멀버가 그룹에 ν¬ν•¨λ˜μ–΄ μžˆμ§€ μ•ŠμœΌλ©΄μ„œ ACCEPT or REJECT μƒνƒœλΌλ©΄ μž¬μ „μ†‘ κ°€λŠ₯
145-
WorkspaceInvitation invited = workspaceInvitationRepository.findByWorkspaceIdAndInviteeIdAndExpiredAtAfter(workspaceId, invitee.getId(), LocalDateTime.now())
146-
.orElseThrow(() -> new CustomException(WorkspaceErrorCode.INVITATION_NOT_FOUND));
147-
if (invited.getType() == InvitationType.PENDING) {
148-
throw new CustomException(WorkspaceErrorCode.ALREADY_INVITED);
149-
}
141+
// PENDING μƒνƒœμ΄λ©΄μ„œ 아직 λ§Œλ£Œλ˜μ§€ μ•Šμ€ μ΄ˆλŒ€κ°€ μžˆλŠ”μ§€ 확인
142+
Optional<WorkspaceInvitation> pendingInvitation = workspaceInvitationRepository
143+
.findByWorkspaceIdAndInviteeIdAndTypeAndExpiredAtAfter(
144+
workspaceId, invitee.getId(), InvitationType.PENDING, LocalDateTime.now());
145+
146+
if (pendingInvitation.isPresent()) {
147+
throw new CustomException(WorkspaceErrorCode.ALREADY_INVITED);
150148
}
151149

152150
// μ΄ˆλŒ€ 토큰 생성 (invitationMailService μ—μ„œ 쀑볡 μ—¬λΆ€ 확인)

0 commit comments

Comments
Β (0)