diff --git a/packages/moxxmpp/lib/src/namespaces.dart b/packages/moxxmpp/lib/src/namespaces.dart index b610e58..f5e973c 100644 --- a/packages/moxxmpp/lib/src/namespaces.dart +++ b/packages/moxxmpp/lib/src/namespaces.dart @@ -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'; diff --git a/packages/moxxmpp/lib/src/xeps/xep_0461.dart b/packages/moxxmpp/lib/src/xeps/xep_0461.dart index ebe5c4e..689d08b 100644 --- a/packages/moxxmpp/lib/src/xeps/xep_0461.dart +++ b/packages/moxxmpp/lib/src/xeps/xep_0461.dart @@ -107,40 +107,41 @@ class MessageRepliesManager extends XmppManagerBase { TypedMap extensions, ) { final data = extensions.get(); - return data != null - ? [ - XMLNode.xmlns( - tag: 'reply', - xmlns: replyXmlns, - attributes: { - // The to attribute is optional - if (data.jid != null) 'to': data.jid!.toString(), + if (data == null) { + return []; + } + return [ + XMLNode.xmlns( + tag: 'reply', + xmlns: replyXmlns, + attributes: { + // The to attribute is optional + if (data.jid != null) 'to': data.jid!.toString(), - 'id': data.id, + 'id': data.id, + }, + ), + if (data.body != null) + XMLNode( + tag: 'body', + text: data.body, + ), + if (data.body != null) + XMLNode.xmlns( + tag: 'fallback', + xmlns: fallbackIndicationXmlns, + attributes: {'for': replyXmlns}, + children: [ + XMLNode( + tag: 'body', + attributes: { + 'start': data.start!.toString(), + 'end': data.end!.toString(), }, ), - if (data.body != null) - XMLNode( - tag: 'body', - text: data.body, - ), - if (data.body != null) - XMLNode.xmlns( - tag: 'fallback', - xmlns: fallbackXmlns, - attributes: {'for': replyXmlns}, - children: [ - XMLNode( - tag: 'body', - attributes: { - 'start': data.start!.toString(), - 'end': data.end!.toString(), - }, - ), - ], - ), - ] - : []; + ], + ), + ]; } Future _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); diff --git a/packages/moxxmpp/test/xeps/xep_0461_test.dart b/packages/moxxmpp/test/xeps/xep_0461_test.dart index 2b2c26d..add86e0 100644 --- a/packages/moxxmpp/test/xeps/xep_0461_test.dart +++ b/packages/moxxmpp/test/xeps/xep_0461_test.dart @@ -253,7 +253,7 @@ void main() { > Anna wrote:\n> We should bake a cake\nGreat idea! - +