fix: Add x node to MUC PM stanza (#1462)

Add <x/> tag in MUC-PMs to support better Carbon delivery in
compliance with XEP-0045 v1.28 and above.

Fixes #1306
This commit is contained in:
mesonium 2023-07-29 14:02:38 +02:00 committed by GitHub
parent d0fca291ac
commit bc5a1d35cb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 0 deletions

View file

@ -54,6 +54,7 @@ public class MucManager : StreamInteractionModule, Object {
}
return true;
});
stream_interactor.get_module(MessageProcessor.IDENTITY).build_message_stanza.connect(on_build_message_stanza);
}
// already_autojoin: Without this flag we'd be retrieving bookmarks (to check for autojoin) from the sender on every join
@ -651,6 +652,12 @@ public class MucManager : StreamInteractionModule, Object {
conference_removed(account, jid);
}
private void on_build_message_stanza(Entities.Message message, Xmpp.MessageStanza message_stanza, Conversation conversation) {
if (conversation.type_ == Conversation.Type.GROUPCHAT_PM) {
Xmpp.Xep.Muc.add_muc_pm_message_stanza_x_node(message_stanza);
}
}
private void self_ping(Account account) {
XmppStream? stream = stream_interactor.get_stream(account);
if (stream == null) return;

View file

@ -54,6 +54,11 @@ public enum Feature {
UNSECURED
}
public static void add_muc_pm_message_stanza_x_node(MessageStanza message_stanza) {
StanzaNode x_node = new StanzaNode.build("x", "http://jabber.org/protocol/muc#user").add_self_xmlns();
message_stanza.stanza.put_node(x_node);
}
public class JoinResult {
public MucEnterError? muc_error;
public string? stanza_error;