Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Message Archive Management handling remote messages by inferring direction instead. Adds MAM 2 support. #1229

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

Teglgaard
Copy link

We are using MAM 2 but would not be able to process the messages since all incoming messages are tagged with isOutgoing = false even though the message originally came from ourself.
To solve that issue we instead infer the direction.

public var mam = XMPPMessageArchiveManagement()

        let jid = _SOME JID_
  
        var fields: [DDXMLElement]? = nil
        let resultSet = XMPPResultSet(max: 100)
        mam.retrieveMessageArchive(withFields: fields, with: resultSet)

By using above we then process the necessary answer below:

public func xmppStream(_ sender: XMPPStream, willReceive message: XMPPMessage) -> XMPPMessage? {
        // Check if the message has a MAM result
        if let xmppMessage = message.mamResult?.forwardedMessage {
           
            return xmppMessage
        }
        
        // If not a MAM message or some other error, just return the original message
        return message
    }

By doing above combined with the code allows the messages to be stored correctly.

We discussed a couple of developers if they could find use cases for setting the direction manually and we could not.

…er instead so it can be used for MAM XEP-0313
…st commit it seemed that everything was working as inteded but we had a parameter which were not longer used.

(If you want to see the only changes needed please see last commit.)
@Teglgaard Teglgaard changed the title Message Archive Management handling remote messages by inferring direction instead. Message Archive Management handling remote messages by inferring direction instead. Adds MAM 2 support. Oct 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant