Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,20 @@ SELECT AVG(ac.confidence)
""")
void deleteByDecisionId(@Param("decisionId") Long decisionId);

@Modifying(clearAutomatically = true, flushAutomatically = true)
@Query("""
DELETE FROM ApplicationCommits ac
WHERE ac.application.decision.meeting.team.id = :teamId
""")
void deleteByTeamId(@Param("teamId") Long teamId);

@Modifying(clearAutomatically = true, flushAutomatically = true)
@Query("""
DELETE FROM ApplicationCommits ac
WHERE ac.application.decision.meeting.id = :meetingId
""")
void deleteByMeetingId(@Param("meetingId") Long meetingId);

@Modifying(clearAutomatically = true, flushAutomatically = true)
@Query("""
DELETE FROM ApplicationCommits ac
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,20 @@ public interface DecisionCommitsRepository extends JpaRepository<DecisionCommits
""")
void deleteByDecisionId(@Param("decisionId") Long decisionId);

@Modifying(clearAutomatically = true, flushAutomatically = true)
@Query("""
DELETE FROM DecisionCommits dc
WHERE dc.decision.meeting.team.id = :teamId
""")
void deleteByTeamId(@Param("teamId") Long teamId);

@Modifying(clearAutomatically = true, flushAutomatically = true)
@Query("""
DELETE FROM DecisionCommits dc
WHERE dc.decision.meeting.id = :meetingId
""")
void deleteByMeetingId(@Param("meetingId") Long meetingId);

@Query("""
SELECT dc.id
FROM DecisionCommits dc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import com.whylog.server.domain.decision.repository.ApplicationRepository;
import com.whylog.server.domain.decision.repository.ApplicationBaseRepository;
import com.whylog.server.domain.decision.repository.ApplicationCommitsRepository;
import com.whylog.server.domain.decision.repository.ApplicationTimelineRepository;
import com.whylog.server.domain.decision.repository.DecisionBaseRepository;
import com.whylog.server.domain.decision.repository.DecisionCommitsRepository;
import com.whylog.server.domain.decision.repository.DecisionRepository;
import com.whylog.server.domain.decision.repository.DecisionTimelineRepository;
import com.whylog.server.domain.meeting.repository.DialogueRepository;
Expand All @@ -21,8 +23,10 @@ public class MeetingCleanupService {

private final ApplicationRepository applicationRepository;
private final ApplicationBaseRepository applicationBaseRepository;
private final ApplicationCommitsRepository applicationCommitsRepository;
private final ApplicationTimelineRepository applicationTimelineRepository;
private final DecisionBaseRepository decisionBaseRepository;
private final DecisionCommitsRepository decisionCommitsRepository;
private final DecisionRepository decisionRepository;
private final DecisionTimelineRepository decisionTimelineRepository;
private final MeetingAnalysisRepository meetingAnalysisRepository;
Expand All @@ -45,8 +49,10 @@ public void deleteByMeetingId(Long meetingId) {
}

private void deleteChildrenByTeamId(Long teamId, List<Long> meetingIds) {
applicationCommitsRepository.deleteByTeamId(teamId);
applicationTimelineRepository.deleteByTeamId(teamId);
applicationBaseRepository.deleteByTeamId(teamId);
decisionCommitsRepository.deleteByTeamId(teamId);
decisionTimelineRepository.deleteByTeamId(teamId);
decisionBaseRepository.deleteByTeamId(teamId);
applicationRepository.deleteByTeamId(teamId);
Expand All @@ -57,8 +63,10 @@ private void deleteChildrenByTeamId(Long teamId, List<Long> meetingIds) {
}

private void deleteChildrenByMeetingId(Long meetingId) {
applicationCommitsRepository.deleteByMeetingId(meetingId);
applicationTimelineRepository.deleteByMeetingId(meetingId);
applicationBaseRepository.deleteByMeetingId(meetingId);
decisionCommitsRepository.deleteByMeetingId(meetingId);
decisionTimelineRepository.deleteByMeetingId(meetingId);
decisionBaseRepository.deleteByMeetingId(meetingId);
applicationRepository.deleteByMeetingId(meetingId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public MeetingResponse.MeetingDeleteResponseDTO deleteMeeting(Long memberId, Lon
meetingMemberRepository.findOwnerMeetingMember(memberId, meetingId, MeetingRole.OWNER)
.orElseThrow(() -> new ErrorHandler(MeetingErrorCode.MEETING_NOT_OWNER));

stopRecording(meeting);
stopRecordingForDelete(meeting);
meetingCleanupService.deleteByMeetingId(meetingId);
meetingLiveMessageRepository.clear(meetingId);
scheduleAfterCommit(() -> meetingSocketRoomService.closeRoom(meetingId));
Expand Down Expand Up @@ -171,6 +171,15 @@ private void stopRecording(Meeting meeting) {
liveKitEgressClient.stopEgress(egressToken, meeting.getAudioEgressId());
}

private void stopRecordingForDelete(Meeting meeting) {
try {
stopRecording(meeting);
} catch (Exception exception) {
log.warn("Failed to stop meeting recording before delete: meetingId={}, egressId={}",
meeting.getId(), meeting.getAudioEgressId(), exception);
}
}

private MeetingResponse.MeetingEndResponseDTO finishMeeting(Meeting meeting, boolean broadcastEnded) {
LocalDateTime endDateTime = meeting.endMeeting();
meetingRepository.save(meeting);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
Expand Down Expand Up @@ -70,7 +71,23 @@ public void createRoom(String roomCreateToken, String roomName) {

public void stopEgress(String egressToken, String egressId) {
Map<String, Object> request = Map.of("egress_id", egressId);
post("/twirp/livekit.Egress/StopEgress", egressToken, request);
try {
post("/twirp/livekit.Egress/StopEgress", egressToken, request);
} catch (HttpClientErrorException e) {
if (isAlreadyCompletedEgress(e)) {
log.info("LiveKit egress already completed: egressId={}", egressId);
return;
}

throw e;
}
}

private boolean isAlreadyCompletedEgress(HttpClientErrorException e) {
String responseBody = e.getResponseBodyAsString();
return e.getStatusCode().value() == HttpStatus.PRECONDITION_FAILED.value()
&& responseBody.contains("EGRESS_COMPLETE")
&& responseBody.contains("cannot be stopped");
}

public void removeParticipant(String roomAdminToken, String roomName, String identity) {
Expand Down
Loading