Interface OfflineMessageRepository
- All Superinterfaces:
org.springframework.data.repository.CrudRepository<OfflineMessage,,UUID> org.springframework.data.jpa.repository.JpaRepository<OfflineMessage,,UUID> org.springframework.data.repository.ListCrudRepository<OfflineMessage,,UUID> org.springframework.data.repository.ListPagingAndSortingRepository<OfflineMessage,,UUID> org.springframework.data.repository.PagingAndSortingRepository<OfflineMessage,,UUID> org.springframework.data.repository.query.QueryByExampleExecutor<OfflineMessage>,org.springframework.data.repository.Repository<OfflineMessage,UUID>
@Repository
public interface OfflineMessageRepository
extends org.springframework.data.jpa.repository.JpaRepository<OfflineMessage,UUID>
-
Method Summary
Modifier and TypeMethodDescriptionlongcountByRecipientUserIdAndConversationIdAndDeliveredFalse(UUID recipientUserId, UUID conversationId) Count undelivered messages for a user in a specific conversationlongcountByRecipientUserIdAndDeliveredFalse(UUID recipientUserId) Count undelivered messages for a userintdeleteByRecipientUserIdAndConversationIdAndDeliveredFalse(UUID recipientUserId, UUID conversationId) Delete undelivered messages for a specific user in a specific conversation This is used to clean up offline messages when a user marks a conversation as readintdeleteByRecipientUserIdAndConversationIdAndDeliveredFalseAndMessageIdIn(UUID recipientUserId, UUID conversationId, Set<UUID> messageIds) Delete undelivered messages for a specific user in a specific conversation for message ids.intdeleteByRecipientUserIdAndConversationIdAndDeliveredFalseUptoCreatedAt(UUID recipientUserId, UUID conversationId, Instant uptoCreatedAt) Delete undelivered messages for a specific user in a specific conversation upto created at.intdeleteByRecipientUserIdAndConversationIdAndDeliveredTrue(UUID recipientUserId, UUID conversationId) Delete delivered messages for a specific user in a specific conversation This is used to clean up offline messages when a user marks a conversation as readintdeleteDeliveredMessagesOlderThan(Instant cutoffDate) Delete delivered messages older than specified datebooleanexistsByMessageIdAndRecipientUserId(UUID messageId, UUID recipientUserId) Find messages by message ID and recipient (for duplicate prevention)findByRecipientUserIdAndDeliveredFalseOrderByCreatedAtAsc(UUID recipientUserId) Find all undelivered messages for a specific userfindTop1ByRecipientUserIdAndDeliveredFalseOrderByCreatedAtAsc(UUID recipientUserId) Find the earliest undelivered messages for a specific userintmarkMessagesAsDelivered(UUID recipientUserId, Instant deliveredAt) Mark messages as delivered for a specific userintmarkSpecificMessagesAsDelivered(List<Long> messageIds, Instant deliveredAt) Mark specific messages as deliveredMethods inherited from interface org.springframework.data.repository.CrudRepository
count, delete, deleteAll, deleteAll, deleteAllById, deleteById, existsById, findById, saveMethods inherited from interface org.springframework.data.jpa.repository.JpaRepository
deleteAllByIdInBatch, deleteAllInBatch, deleteAllInBatch, deleteInBatch, findAll, findAll, flush, getById, getOne, getReferenceById, saveAllAndFlush, saveAndFlushMethods inherited from interface org.springframework.data.repository.ListCrudRepository
findAll, findAllById, saveAllMethods inherited from interface org.springframework.data.repository.ListPagingAndSortingRepository
findAllMethods inherited from interface org.springframework.data.repository.PagingAndSortingRepository
findAllMethods inherited from interface org.springframework.data.repository.query.QueryByExampleExecutor
count, exists, findAll, findBy, findOne
-
Method Details
-
findByRecipientUserIdAndDeliveredFalseOrderByCreatedAtAsc
List<OfflineMessage> findByRecipientUserIdAndDeliveredFalseOrderByCreatedAtAsc(UUID recipientUserId) Find all undelivered messages for a specific user -
findTop1ByRecipientUserIdAndDeliveredFalseOrderByCreatedAtAsc
Optional<OfflineMessage> findTop1ByRecipientUserIdAndDeliveredFalseOrderByCreatedAtAsc(UUID recipientUserId) Find the earliest undelivered messages for a specific user -
markMessagesAsDelivered
@Modifying @Query("UPDATE OfflineMessage om SET om.delivered = true, om.deliveredAt = :deliveredAt WHERE om.recipientUserId = :recipientUserId AND om.delivered = false") int markMessagesAsDelivered(@Param("recipientUserId") UUID recipientUserId, @Param("deliveredAt") Instant deliveredAt) Mark messages as delivered for a specific user -
markSpecificMessagesAsDelivered
@Modifying @Query("UPDATE OfflineMessage om SET om.delivered = true, om.deliveredAt = :deliveredAt WHERE om.id IN :messageIds") int markSpecificMessagesAsDelivered(@Param("messageIds") List<Long> messageIds, @Param("deliveredAt") Instant deliveredAt) Mark specific messages as delivered -
countByRecipientUserIdAndDeliveredFalse
Count undelivered messages for a user -
countByRecipientUserIdAndConversationIdAndDeliveredFalse
long countByRecipientUserIdAndConversationIdAndDeliveredFalse(UUID recipientUserId, UUID conversationId) Count undelivered messages for a user in a specific conversation -
deleteDeliveredMessagesOlderThan
@Modifying @Query("DELETE FROM OfflineMessage om WHERE om.delivered = true AND om.deliveredAt < :cutoffDate") int deleteDeliveredMessagesOlderThan(@Param("cutoffDate") Instant cutoffDate) Delete delivered messages older than specified date -
existsByMessageIdAndRecipientUserId
Find messages by message ID and recipient (for duplicate prevention) -
deleteByRecipientUserIdAndConversationIdAndDeliveredTrue
@Modifying @Query("DELETE FROM OfflineMessage om WHERE om.recipientUserId = :recipientUserId AND om.conversationId = :conversationId AND om.delivered = true") int deleteByRecipientUserIdAndConversationIdAndDeliveredTrue(@Param("recipientUserId") UUID recipientUserId, @Param("conversationId") UUID conversationId) Delete delivered messages for a specific user in a specific conversation This is used to clean up offline messages when a user marks a conversation as read -
deleteByRecipientUserIdAndConversationIdAndDeliveredFalse
@Modifying @Query("DELETE FROM OfflineMessage om WHERE om.recipientUserId = :recipientUserId AND om.conversationId = :conversationId AND om.delivered = false") int deleteByRecipientUserIdAndConversationIdAndDeliveredFalse(@Param("recipientUserId") UUID recipientUserId, @Param("conversationId") UUID conversationId) Delete undelivered messages for a specific user in a specific conversation This is used to clean up offline messages when a user marks a conversation as read -
deleteByRecipientUserIdAndConversationIdAndDeliveredFalseUptoCreatedAt
@Modifying @Query("DELETE FROM OfflineMessage om WHERE om.recipientUserId = :recipientUserId AND om.conversationId = :conversationId AND om.delivered = false AND om.createdAt <= :uptoCreatedAt") int deleteByRecipientUserIdAndConversationIdAndDeliveredFalseUptoCreatedAt(@Param("recipientUserId") UUID recipientUserId, @Param("conversationId") UUID conversationId, @Param("uptoCreatedAt") Instant uptoCreatedAt) Delete undelivered messages for a specific user in a specific conversation upto created at. This is used to clean up offline messages when a user marks a conversation as read -
deleteByRecipientUserIdAndConversationIdAndDeliveredFalseAndMessageIdIn
@Modifying @Query("DELETE FROM OfflineMessage om WHERE om.recipientUserId = :recipientUserId AND om.conversationId = :conversationId AND om.delivered = false AND om.messageId IN (:messageIds)") int deleteByRecipientUserIdAndConversationIdAndDeliveredFalseAndMessageIdIn(@Param("recipientUserId") UUID recipientUserId, @Param("conversationId") UUID conversationId, @Param("messageIds") Set<UUID> messageIds) Delete undelivered messages for a specific user in a specific conversation for message ids. This is used to clean up offline messages when a user marks a conversation as read
-