Interface AiChatMessageService

All Known Implementing Classes:
AiChatMessageDataService, AiChatMessageEmptyService

public interface AiChatMessageService
Provides access to the messages of the current user's AI conversations.

Operates purely on the AiChatMessage model and is implicitly scoped to the current user.

  • Method Details

    • createMessage

      AiChatMessage createMessage(AiConversation conversation, AiChatMessageType type, String message)
      Creates a new message of the given type in the conversation.
      Parameters:
      conversation - conversation the message belongs to
      type - message type
      message - message text
      Returns:
      the created message
    • loadLatestMessage

      @Nullable AiChatMessage loadLatestMessage(AiConversation conversation, @Nullable AiChatMessageType type)
      Loads the most recent message of the conversation, optionally restricted to a type.
      Parameters:
      conversation - conversation whose latest message is loaded
      type - message type to match, or null for any type
      Returns:
      the latest matching message, or null if there is none
    • loadLatestMessages

      Map<AiConversation,AiChatMessage> loadLatestMessages(Collection<AiConversation> conversations, @Nullable AiChatMessageType type)
      Loads the latest message of each of the given conversations, keyed by the conversation instances passed in. A conversation with no matching message, or one not accessible to the current user, is absent from the result.
      Parameters:
      conversations - conversations whose latest messages are loaded
      type - message type to match, or null for any type
      Returns:
      the latest matching message by conversation; empty if none of them has a matching message
    • loadMessages

      Collection<AiChatMessage> loadMessages(AiConversation conversation)
      Loads all messages of the conversation, oldest first.
      Parameters:
      conversation - conversation whose messages are loaded
      Returns:
      the conversation's messages, oldest first; empty if there are none