DM 목록 조회 결과, 마지막으로 수신한 메시지에 대한 읽음 처리만 생성
이전 메시지에 대한 읽음 처리가 생성되지 않아, 여전히 프론트엔드에서 빨간 점이 확인
마지막으로 수신한 메시지를 기준으로 그 이전 메시지들에 대한 읽음 처리를 일괄로 생성하는 쿼리 메서드 구현
// DM 읽음 처리: 마지막으로 수신한 메시지를 포함한 그 이전의 메시지 일괄 읽음 처리
@Modifying(clearAutomatically = true)
@Query("UPDATE DirectMessage m SET m.read = true, m.readAt = :now "
+ "WHERE m.conversation.id = :conversationId "
+ "AND m.receiver.id = :receiverId "
+ "AND m.read = false "
+ "AND m.createdAt <= :createdAt")
int markAllAsRead(
@Param("conversationId") UUID conversationId,
@Param("receiverId") UUID receiverId,
@Param("createdAt") Instant createdAt,
@Param("now") Instant now
);