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.
class ReplyData {
const ReplyData({
required this.to,
required this.id,
this.to,
this.start,
this.end,
});
/// 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
final String id;
@ -72,6 +72,11 @@ class MessageRepliesManager extends XmppManagerBase {
@override
String getId() => messageRepliesManager;
@override
List<String> getDiscoFeatures() => [
replyXmlns,
];
@override
List<StanzaHandler> getIncomingStanzaHandlers() => [
StanzaHandler(
@ -90,7 +95,7 @@ class MessageRepliesManager extends XmppManagerBase {
Future<StanzaHandlerData> _onMessage(Stanza stanza, StanzaHandlerData state) async {
final reply = stanza.firstTag('reply', xmlns: replyXmlns)!;
final id = reply.attributes['id']! as String;
final to = reply.attributes['to']! as String;
final to = reply.attributes['to'] as String?;
int? start;
int? end;
@ -102,11 +107,13 @@ class MessageRepliesManager extends XmppManagerBase {
end = int.parse(body.attributes['end']! as String);
}
return state.copyWith(reply: ReplyData(
return state.copyWith(
reply: ReplyData(
id: id,
to: to,
start: start,
end: end,
),);
),
);
}
}