fix(xep): Fix replies in the context of Gajim
This commit is contained in:
parent
b3c8a6cd2f
commit
365ff2f238
@ -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';
|
||||
|
@ -107,40 +107,41 @@ class MessageRepliesManager extends XmppManagerBase {
|
||||
TypedMap<StanzaHandlerExtension> extensions,
|
||||
) {
|
||||
final data = extensions.get<ReplyData>();
|
||||
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<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);
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user