feat: Update Message Replies to 0.2.0

Fixes #22.
This commit is contained in:
PapaTutuWawa 2023-01-27 19:07:43 +01:00
parent c77cfc4dcd
commit c7c6c9dae4

View File

@ -9,14 +9,14 @@ import 'package:moxxmpp/src/stanza.dart';
/// Data summarizing the XEP-0461 data. /// Data summarizing the XEP-0461 data.
class ReplyData { class ReplyData {
const ReplyData({ const ReplyData({
required this.to,
required this.id, required this.id,
this.to,
this.start, this.start,
this.end, this.end,
}); });
/// The bare JID to whom the reply applies to /// The bare JID to whom the reply applies to
final String to; final String? to;
/// The stanza ID of the message that is replied to /// The stanza ID of the message that is replied to
final String id; final String id;
@ -72,6 +72,11 @@ class MessageRepliesManager extends XmppManagerBase {
@override @override
String getId() => messageRepliesManager; String getId() => messageRepliesManager;
@override
List<String> getDiscoFeatures() => [
replyXmlns,
];
@override @override
List<StanzaHandler> getIncomingStanzaHandlers() => [ List<StanzaHandler> getIncomingStanzaHandlers() => [
StanzaHandler( StanzaHandler(
@ -90,7 +95,7 @@ class MessageRepliesManager extends XmppManagerBase {
Future<StanzaHandlerData> _onMessage(Stanza stanza, StanzaHandlerData state) async { Future<StanzaHandlerData> _onMessage(Stanza stanza, StanzaHandlerData state) async {
final reply = stanza.firstTag('reply', xmlns: replyXmlns)!; final reply = stanza.firstTag('reply', xmlns: replyXmlns)!;
final id = reply.attributes['id']! as String; final id = reply.attributes['id']! as String;
final to = reply.attributes['to']! as String; final to = reply.attributes['to'] as String?;
int? start; int? start;
int? end; int? end;
@ -102,11 +107,13 @@ class MessageRepliesManager extends XmppManagerBase {
end = int.parse(body.attributes['end']! as String); end = int.parse(body.attributes['end']! as String);
} }
return state.copyWith(reply: ReplyData( return state.copyWith(
reply: ReplyData(
id: id, id: id,
to: to, to: to,
start: start, start: start,
end: end, end: end,
),); ),
);
} }
} }