Class ChatMessageServiceImpl
java.lang.Object
com.finconsgroup.itserr.marketplace.usercommunication.dm.service.impl.ChatMessageServiceImpl
- All Implemented Interfaces:
ChatMessageService
Consumer component that processes messages from Messaging Service and persists/broadcasts them.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclearUserNotifications(UUID userId) Clear notifications for a user (delete notification messages for the user)org.springframework.data.domain.Page<OutputChatMessageDto> getConversationMessages(Conversation conversation, org.springframework.data.domain.Pageable pageable) Get a page of chat messages for the conversationgetConversationMessages(UUID conversationId) Get messages for a specific conversationgetConversationMessageSummary(UUID userId, List<Conversation> conversations) Get message summary for each conversation for the conversationsgetOutputChatMessageDto(ChatMessage chatMessage, boolean loadUserProfiles) Maps the chat message entity to output dtogetUserNotifications(UUID userId) Get notifications for a specific user (messages where receiverId matches userId)voidhandleChatMessage(ChatMessage message) Handles chat messages from the chat queuevoidhandleUserNotification(ChatMessage notification) Handles user notification messages from queueintmarkConversationAsRead(Conversation conversation, UUID userId, Instant readAt) Mark all unread messages in a conversation as read by a specific user.intmarkConversationBulkMessagesAsRead(Conversation conversation, UUID userId, Instant readAt, Set<UUID> messageIds) Mark all unread messages in a conversation as read by a specific user for the passed ids.intmarkConversationMessagesUptoCreatedAtAsRead(Conversation conversation, UUID userId, Instant readAt, Instant uptoCreatedAt) Mark all unread messages in a conversation as read by a specific user for the messages created at or before.org.springframework.data.domain.Page<OutputChatMessageDto> searchMessages(UUID userId, String searchTerm, org.springframework.data.domain.Pageable pageable) Get a page of chat messages matching the search term
-
Constructor Details
-
ChatMessageServiceImpl
public ChatMessageServiceImpl()
-
-
Method Details
-
handleChatMessage
@Transactional(propagation=REQUIRED, rollbackFor=java.lang.Exception.class) public void handleChatMessage(ChatMessage message) Description copied from interface:ChatMessageServiceHandles chat messages from the chat queue- Specified by:
handleChatMessagein interfaceChatMessageService
-
handleUserNotification
@Transactional(propagation=REQUIRED, rollbackFor=java.lang.Exception.class) public void handleUserNotification(ChatMessage notification) Description copied from interface:ChatMessageServiceHandles user notification messages from queue- Specified by:
handleUserNotificationin interfaceChatMessageService
-
getConversationMessages
@Transactional(propagation=REQUIRED, readOnly=true, noRollbackFor=java.lang.Exception.class) public List<ChatMessage> getConversationMessages(UUID conversationId) Description copied from interface:ChatMessageServiceGet messages for a specific conversation- Specified by:
getConversationMessagesin interfaceChatMessageService
-
getConversationMessages
@Transactional(propagation=REQUIRED, readOnly=true, noRollbackFor=java.lang.Exception.class) public org.springframework.data.domain.Page<OutputChatMessageDto> getConversationMessages(Conversation conversation, org.springframework.data.domain.Pageable pageable) Description copied from interface:ChatMessageServiceGet a page of chat messages for the conversation- Specified by:
getConversationMessagesin interfaceChatMessageService
-
markConversationAsRead
Description copied from interface:ChatMessageServiceMark all unread messages in a conversation as read by a specific user.- Specified by:
markConversationAsReadin interfaceChatMessageService
-
markConversationMessagesUptoCreatedAtAsRead
public int markConversationMessagesUptoCreatedAtAsRead(Conversation conversation, UUID userId, Instant readAt, Instant uptoCreatedAt) Description copied from interface:ChatMessageServiceMark all unread messages in a conversation as read by a specific user for the messages created at or before.- Specified by:
markConversationMessagesUptoCreatedAtAsReadin interfaceChatMessageService
-
markConversationBulkMessagesAsRead
public int markConversationBulkMessagesAsRead(Conversation conversation, UUID userId, Instant readAt, Set<UUID> messageIds) Description copied from interface:ChatMessageServiceMark all unread messages in a conversation as read by a specific user for the passed ids.- Specified by:
markConversationBulkMessagesAsReadin interfaceChatMessageService
-
getConversationMessageSummary
@Transactional(propagation=REQUIRED, readOnly=true, noRollbackFor=java.lang.Exception.class) public Map<UUID,OutputConversationMessageSummaryDto> getConversationMessageSummary(UUID userId, List<Conversation> conversations) Description copied from interface:ChatMessageServiceGet message summary for each conversation for the conversations- Specified by:
getConversationMessageSummaryin interfaceChatMessageService
-
getUserNotifications
@Transactional(propagation=REQUIRED, readOnly=true, noRollbackFor=java.lang.Exception.class) public List<ChatMessage> getUserNotifications(UUID userId) Description copied from interface:ChatMessageServiceGet notifications for a specific user (messages where receiverId matches userId)- Specified by:
getUserNotificationsin interfaceChatMessageService
-
clearUserNotifications
@Transactional(propagation=REQUIRED, rollbackFor=java.lang.Exception.class) public void clearUserNotifications(UUID userId) Description copied from interface:ChatMessageServiceClear notifications for a user (delete notification messages for the user)- Specified by:
clearUserNotificationsin interfaceChatMessageService
-
searchMessages
@Transactional(propagation=REQUIRED, readOnly=true, noRollbackFor=java.lang.Exception.class) public org.springframework.data.domain.Page<OutputChatMessageDto> searchMessages(UUID userId, String searchTerm, org.springframework.data.domain.Pageable pageable) Description copied from interface:ChatMessageServiceGet a page of chat messages matching the search term- Specified by:
searchMessagesin interfaceChatMessageService- Parameters:
userId- the user IDsearchTerm- free-text termpageable- the pageable containing requested paging and sorting information- Returns:
- list of matching messages
-
getOutputChatMessageDto
public OutputChatMessageDto getOutputChatMessageDto(@NonNull ChatMessage chatMessage, boolean loadUserProfiles) Description copied from interface:ChatMessageServiceMaps the chat message entity to output dto- Specified by:
getOutputChatMessageDtoin interfaceChatMessageService- Parameters:
chatMessage- the chat message entityloadUserProfiles- flag to indicate if user profiles should be loaded to fetch chat user details e.g. sender- Returns:
- the output chat message dto
-