Skip to content

[fix] 사용자 탈퇴 API 내에서 채팅방 탈퇴 로직 오류 #53

@codeTravelerLee

Description

@codeTravelerLee

코파일럿이 코드리뷰때 남겨준 아래의 의견을 바탕으로
수정이 필요함.

When a user is removed from rooms using $pull, rooms might end up with zero participants or orphaned private chats. Additionally, if the deleted user was the admin of a group chat, the admin field becomes invalid. Consider handling these edge cases: 1) Delete rooms that have no participants left, 2) Reassign admin role to another participant if the admin is being deleted, or 3) Add validation to prevent these invalid states.

await Room.updateMany(
      { "participants.userId": toBeDeletedUserId },
      { $pull: { participants: { userId: toBeDeletedUserId } } },
    );

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions