Delete or Edit messages in MamManager

I am using smack 4.4.6 and writing an application on spring boot 3.0.5
I tried changing the messages by sending the message again, only to have the stanzaId like the old one, example:

MessageBuilder messageBuilder = StanzaBuilder.buildMessage(stanzaId)
                    .setBody(newMessage);
chat.send(messageBuilder.build());

but as it is clear, this does not work.
I have seen many in the implementation that they change in the database, or make their own storage, so far we are considering this method, but if there is an implementation inside smack, I wanted to use it, help - if you know!

I also looked at the documentation, there is such an extension, but I did not understand how to use it, whether it has a manager, or it is not used in my case
https://xmpp.org/extensions/xep-0308.html

Note that XEP-0308 does not cause a message to be modified. Instead, it sends a new message, that is expected to be used instead of the original. You will not see the original message being modified in storage. Instead, you’ll see two messages:

  1. the original one.
  2. the replacement message.

I have never tried this with Openfire. I assume, but I am not sure, that this functionality does not need specific server-sided support (and that it can be completely implemented by clients).

thanks for the quick reply

Only I have encountered a difficulty when I get a list of messages. I’m using this code to get the messages:

public MamManager.MamQueryArgs buildMamArgs(boolean firstPage, int size, String beforeId, Jid jid) {
        MamManager.MamQueryArgs.Builder builder = MamManager.MamQueryArgs.builder()
                .setResultPageSize(size).limitResultsToJid(jid);
        return firstPage ? builder.queryLastPage().build() : builder.beforeUid(beforeId).build();
    }

And there is such a case that the message will be included in this list after the change, you can exclude it, but then the list will output size-1 elements, and so I think it’s resource-intensive to filter, what would you suggest?

This topic was automatically closed 62 days after the last reply. New replies are no longer allowed.