Message displayed status

Every client generally must be able to show what peer read what message and get how many unread messages there is.

For this, the daemon provides some APIs:

Set a message displayed

The Configuration manager provides:

<method name="setMessageDisplayed" tp:name-for-bindings="setMessageDisplayed">
    <tp:added version="8.1.0"/>
        <p>Informs that a message have been read</p>
    <arg type="s" name="accountId" direction="in">
        The account ID
    <arg type="s" name="conversationUri" direction="in">
        A conversation uri (swarm:xxxx or jami:xxxx)
    <arg type="s" name="messageId" direction="in">
        The message ID
    <arg type="i" name="status" direction="in">
        The message status, 3 for displayed
    <arg type="b" name="success" direction="out">
        True if the message status was set, false if account, contact or message is unknown.

to set a message as displayed. Should be done when the interaction is shown and the conversation selected.

This sends a SIP messages to connected peers with the following format:

getDisplayed(const std::string& conversationId, const std::string& messageId)
    // implementing
    return fmt::format(
        "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n"
        conversationId.empty() ? "" : "<conversation>" + conversationId + "</conversation>");

Then the peer will know this via onMessageDisplayed and emit a signal to the client (libjami::ConfigurationSignal::AccountMessageStatusChanged with status 3 (libjami::Account::MessageStates::DISPLAYED))

Get unread messages

By knowing the lastDisplayedMessage for our account, we can use this informations and ConfigrationManager::countInteractionsSince which count interaction since last message to a given message (typically last displayed interaction)

To get last displayed message for a member, in Configuration::getConversationMembers each member will have the last displayed interaction available via memberInfo["lastDisplayed"]

How this information is stored

In src/jamidht/conversation.cpp each conversation store the last displayed messages in a map<string, string> (uri, interactionId) and this structure is serialized in fileutils::get_data_dir()/getAccountID()/conversation_data/repository_->id()/lastDisplayed