fix(xep): Fix replies in the context of Gajim

This commit is contained in:
PapaTutuWawa 2024-06-16 14:56:07 +02:00
parent b3c8a6cd2f
commit 365ff2f238
3 changed files with 35 additions and 34 deletions

View File

@ -166,7 +166,6 @@ const stickersXmlns = 'urn:xmpp:stickers:0';
// XEP-0461
const replyXmlns = 'urn:xmpp:reply:0';
const fallbackXmlns = 'urn:xmpp:feature-fallback:0';
// ???
const urlDataXmlns = 'http://jabber.org/protocol/url-data';

View File

@ -107,8 +107,10 @@ class MessageRepliesManager extends XmppManagerBase {
TypedMap<StanzaHandlerExtension> extensions,
) {
final data = extensions.get<ReplyData>();
return data != null
? [
if (data == null) {
return [];
}
return [
XMLNode.xmlns(
tag: 'reply',
xmlns: replyXmlns,
@ -127,7 +129,7 @@ class MessageRepliesManager extends XmppManagerBase {
if (data.body != null)
XMLNode.xmlns(
tag: 'fallback',
xmlns: fallbackXmlns,
xmlns: fallbackIndicationXmlns,
attributes: {'for': replyXmlns},
children: [
XMLNode(
@ -139,8 +141,7 @@ class MessageRepliesManager extends XmppManagerBase {
),
],
),
]
: [];
];
}
Future<StanzaHandlerData> _onMessage(
@ -154,7 +155,8 @@ class MessageRepliesManager extends XmppManagerBase {
int? end;
// TODO(Unknown): Maybe extend firstTag to also look for attributes
final fallback = stanza.firstTag('fallback', xmlns: fallbackXmlns);
final fallback =
stanza.firstTag('fallback', xmlns: fallbackIndicationXmlns);
if (fallback != null) {
final body = fallback.firstTag('body')!;
start = int.parse(body.attributes['start']! as String);

View File

@ -253,7 +253,7 @@ void main() {
<message id="aaaaaaaaa" from="user@example.org" to="polynomdivision@test.server/abc123" type="chat">
<body>> Anna wrote:\n> We should bake a cake\nGreat idea!</body>
<reply to='anna@example.com/laptop' id='message-id1' xmlns='urn:xmpp:reply:0' />
<fallback xmlns='urn:xmpp:feature-fallback:0' for='urn:xmpp:reply:0'>
<fallback xmlns='urn:xmpp:fallback:0' for='urn:xmpp:reply:0'>
<body start="0" end="38" />
</fallback>
</message>