Support latest retract/moderate xeps too

(cherry picked from commit e5200409731d37971bf2c8823fd0b23fccef3558)
This commit is contained in:
Stephen Paul Weber 2024-09-17 21:21:40 -05:00 committed by Arne
parent 58542a8ffe
commit 30b567ea6c
2 changed files with 9 additions and 5 deletions

View file

@ -485,11 +485,14 @@ public class MessageParser extends AbstractParser implements Consumer<im.convers
if (fasten != null) {
replaceElement = fasten.findChild("retract", "urn:xmpp:message-retract:0");
if (replaceElement == null) replaceElement = fasten.findChild("moderated", "urn:xmpp:message-moderate:0");
if (replaceElement != null) {
final String reason = replaceElement.findChildContent("reason", "urn:xmpp:message-moderate:0");
replacementId = fasten.getAttribute("id");
packet.setBody(reason == null ? "" : reason);
}
if (replaceElement == null) replaceElement = packet.findChild("retract", "urn:xmpp:message-retract:1");
if (replaceElement == null) replaceElement = packet.findChild("moderate", "urn:xmpp:message-moderate:1");
if (replaceElement != null) {
var reason = replaceElement.findChildContent("reason", "urn:xmpp:message-moderate:0");
if (reason == null) reason = replaceElement.findChildContent("reason", "urn:xmpp:message-moderate:1");
replacementId = (fasten == null ? replaceElement : fasten).getAttribute("id");
packet.setBody(reason == null ? "" : reason);
}
}
LocalizedContent body = packet.getBody();

View file

@ -46,6 +46,7 @@ public class Message extends Stanza {
}
public void setBody(final String text) {
removeChild(findChild("body"));
this.addExtension(new Body(text));
}