From 4ff2992a031c4b793badd9eebc5d70cb1f8c6d06 Mon Sep 17 00:00:00 2001 From: "Alexander \"PapaTutuWawa" Date: Wed, 7 Jun 2023 21:04:05 +0200 Subject: [PATCH] fix(all): Last minute fixes --- packages/moxxmpp/CHANGELOG.md | 1 + packages/moxxmpp/lib/moxxmpp.dart | 1 + packages/moxxmpp/lib/src/message.dart | 4 ++-- packages/moxxmpp/lib/src/xeps/xep_0085.dart | 7 +++---- packages/moxxmpp/lib/src/xeps/xep_0444.dart | 8 ++++---- packages/moxxmpp/lib/src/xeps/xep_0449.dart | 9 ++++++++- packages/moxxmpp/test/stanzahandler_test.dart | 1 - packages/moxxmpp/test/xeps/xep_0115_test.dart | 1 - packages/moxxmpp/test/xeps/xep_0198_test.dart | 1 - packages/moxxmpp/test/xeps/xep_0334_test.dart | 1 - packages/moxxmpp/test/xeps/xep_0449_test.dart | 1 - packages/moxxmpp/test/xeps/xep_0461_test.dart | 1 - packages/moxxmpp/test/xmpp_test.dart | 1 - 13 files changed, 19 insertions(+), 18 deletions(-) diff --git a/packages/moxxmpp/CHANGELOG.md b/packages/moxxmpp/CHANGELOG.md index 8dc1b96..12185d0 100644 --- a/packages/moxxmpp/CHANGELOG.md +++ b/packages/moxxmpp/CHANGELOG.md @@ -15,6 +15,7 @@ - `MessageManager` now allows registering callbacks for adding data whenever a message is sent. - **BREAKING**: `MessageEvent` now makes use of `TypedMap`. - **BREAKING**: Removed `PresenceReceivedEvent`. Use a manager registering handlers with priority greater than `[PresenceManager.presenceHandlerPriority]` instead. +- **BREAKING**: `ChatState.toString()` is now `ChatState.toName()` ## 0.3.1 diff --git a/packages/moxxmpp/lib/moxxmpp.dart b/packages/moxxmpp/lib/moxxmpp.dart index 944b728..92cd8f5 100644 --- a/packages/moxxmpp/lib/moxxmpp.dart +++ b/packages/moxxmpp/lib/moxxmpp.dart @@ -39,6 +39,7 @@ export 'package:moxxmpp/src/socket.dart'; export 'package:moxxmpp/src/stanza.dart'; export 'package:moxxmpp/src/stringxml.dart'; export 'package:moxxmpp/src/types/result.dart'; +export 'package:moxxmpp/src/util/typed_map.dart'; export 'package:moxxmpp/src/xeps/staging/extensible_file_thumbnails.dart'; export 'package:moxxmpp/src/xeps/staging/fast.dart'; export 'package:moxxmpp/src/xeps/staging/file_upload_notification.dart'; diff --git a/packages/moxxmpp/lib/src/message.dart b/packages/moxxmpp/lib/src/message.dart index 2e36b5c..5f48ca2 100644 --- a/packages/moxxmpp/lib/src/message.dart +++ b/packages/moxxmpp/lib/src/message.dart @@ -21,7 +21,7 @@ typedef MessageSendingCallback = List Function( ); /// The raw content of the element. -class MessageBodyData { +class MessageBodyData implements StanzaHandlerExtension { const MessageBodyData(this.body); /// The content of the element. @@ -36,7 +36,7 @@ class MessageBodyData { } /// The id attribute of the message stanza. -class MessageIdData { +class MessageIdData implements StanzaHandlerExtension { const MessageIdData(this.id); /// The id attribute of the stanza. diff --git a/packages/moxxmpp/lib/src/xeps/xep_0085.dart b/packages/moxxmpp/lib/src/xeps/xep_0085.dart index b186e4f..36a5f2a 100644 --- a/packages/moxxmpp/lib/src/xeps/xep_0085.dart +++ b/packages/moxxmpp/lib/src/xeps/xep_0085.dart @@ -32,8 +32,7 @@ enum ChatState implements StanzaHandlerExtension { throw Exception('Invalid chat state $state'); } - @override - String toString() { + String toName() { switch (this) { case ChatState.active: return 'active'; @@ -50,7 +49,7 @@ enum ChatState implements StanzaHandlerExtension { XMLNode toXML() { return XMLNode.xmlns( - tag: toString(), + tag: toName(), xmlns: chatStateXmlns, ); } @@ -104,7 +103,7 @@ class ChatStateManager extends XmppManagerBase { to: to, type: messageType, children: [ - XMLNode.xmlns(tag: state.toString(), xmlns: chatStateXmlns), + state.toXML(), ], ), awaitable: false, diff --git a/packages/moxxmpp/lib/src/xeps/xep_0444.dart b/packages/moxxmpp/lib/src/xeps/xep_0444.dart index f412bbd..cfa844c 100644 --- a/packages/moxxmpp/lib/src/xeps/xep_0444.dart +++ b/packages/moxxmpp/lib/src/xeps/xep_0444.dart @@ -8,8 +8,8 @@ import 'package:moxxmpp/src/stanza.dart'; import 'package:moxxmpp/src/stringxml.dart'; import 'package:moxxmpp/src/util/typed_map.dart'; -class MessageReactions implements StanzaHandlerExtension { - const MessageReactions(this.messageId, this.emojis); +class MessageReactionsData implements StanzaHandlerExtension { + const MessageReactionsData(this.messageId, this.emojis); final String messageId; final List emojis; @@ -59,7 +59,7 @@ class MessageReactionsManager extends XmppManagerBase { message.firstTag('reactions', xmlns: messageReactionsXmlns)!; return state ..extensions.set( - MessageReactions( + MessageReactionsData( reactionsElement.attributes['id']! as String, reactionsElement.children .where((c) => c.tag == 'reaction') @@ -72,7 +72,7 @@ class MessageReactionsManager extends XmppManagerBase { List _messageSendingCallback( TypedMap extensions, ) { - final data = extensions.get(); + final data = extensions.get(); return data != null ? [ data.toXML(), diff --git a/packages/moxxmpp/lib/src/xeps/xep_0449.dart b/packages/moxxmpp/lib/src/xeps/xep_0449.dart index b37fd76..b32aa3c 100644 --- a/packages/moxxmpp/lib/src/xeps/xep_0449.dart +++ b/packages/moxxmpp/lib/src/xeps/xep_0449.dart @@ -230,13 +230,16 @@ class StickerPack { } class StickersData implements StanzaHandlerExtension { - const StickersData(this.stickerPackId, this.sticker); + const StickersData(this.stickerPackId, this.sticker, {this.addBody = true}); /// The id of the sticker pack the referenced sticker is from. final String stickerPackId; /// The metadata of the sticker. final StatelessFileSharingData sticker; + + /// If true, sets the sticker's metadata desc attribute as the message body. + final bool addBody; } class StickersManager extends XmppManagerBase { @@ -284,6 +287,10 @@ class StickersManager extends XmppManagerBase { }, ), data.sticker.toXML(), + + // Add a body + if (data.addBody && data.sticker.metadata.desc != null) + MessageBodyData(data.sticker.metadata.desc).toXML(), ] : []; } diff --git a/packages/moxxmpp/test/stanzahandler_test.dart b/packages/moxxmpp/test/stanzahandler_test.dart index 1ff4142..cb62eee 100644 --- a/packages/moxxmpp/test/stanzahandler_test.dart +++ b/packages/moxxmpp/test/stanzahandler_test.dart @@ -1,5 +1,4 @@ import 'package:moxxmpp/moxxmpp.dart'; -import 'package:moxxmpp/src/util/typed_map.dart'; import 'package:test/test.dart'; final stanza1 = Stanza.iq( diff --git a/packages/moxxmpp/test/xeps/xep_0115_test.dart b/packages/moxxmpp/test/xeps/xep_0115_test.dart index f4c45ae..10ef205 100644 --- a/packages/moxxmpp/test/xeps/xep_0115_test.dart +++ b/packages/moxxmpp/test/xeps/xep_0115_test.dart @@ -1,5 +1,4 @@ import 'package:moxxmpp/moxxmpp.dart'; -import 'package:moxxmpp/src/util/typed_map.dart'; import 'package:test/test.dart'; import '../helpers/logging.dart'; diff --git a/packages/moxxmpp/test/xeps/xep_0198_test.dart b/packages/moxxmpp/test/xeps/xep_0198_test.dart index 07c118a..24f0c9a 100644 --- a/packages/moxxmpp/test/xeps/xep_0198_test.dart +++ b/packages/moxxmpp/test/xeps/xep_0198_test.dart @@ -1,6 +1,5 @@ import 'dart:async'; import 'package:moxxmpp/moxxmpp.dart'; -import 'package:moxxmpp/src/util/typed_map.dart'; import 'package:test/test.dart'; import '../helpers/logging.dart'; import '../helpers/xmpp.dart'; diff --git a/packages/moxxmpp/test/xeps/xep_0334_test.dart b/packages/moxxmpp/test/xeps/xep_0334_test.dart index f53445c..3bb1a04 100644 --- a/packages/moxxmpp/test/xeps/xep_0334_test.dart +++ b/packages/moxxmpp/test/xeps/xep_0334_test.dart @@ -1,5 +1,4 @@ import 'package:moxxmpp/moxxmpp.dart'; -import 'package:moxxmpp/src/util/typed_map.dart'; import 'package:test/test.dart'; import '../helpers/manager.dart'; diff --git a/packages/moxxmpp/test/xeps/xep_0449_test.dart b/packages/moxxmpp/test/xeps/xep_0449_test.dart index 1e45049..7c90d61 100644 --- a/packages/moxxmpp/test/xeps/xep_0449_test.dart +++ b/packages/moxxmpp/test/xeps/xep_0449_test.dart @@ -1,5 +1,4 @@ import 'package:moxxmpp/moxxmpp.dart'; -import 'package:moxxmpp/src/util/typed_map.dart'; import 'package:test/test.dart'; import '../helpers/logging.dart'; diff --git a/packages/moxxmpp/test/xeps/xep_0461_test.dart b/packages/moxxmpp/test/xeps/xep_0461_test.dart index f3f9574..2b2c26d 100644 --- a/packages/moxxmpp/test/xeps/xep_0461_test.dart +++ b/packages/moxxmpp/test/xeps/xep_0461_test.dart @@ -1,5 +1,4 @@ import 'package:moxxmpp/moxxmpp.dart'; -import 'package:moxxmpp/src/util/typed_map.dart'; import 'package:test/test.dart'; import '../helpers/xmpp.dart'; diff --git a/packages/moxxmpp/test/xmpp_test.dart b/packages/moxxmpp/test/xmpp_test.dart index d7fd9d8..65bf3e1 100644 --- a/packages/moxxmpp/test/xmpp_test.dart +++ b/packages/moxxmpp/test/xmpp_test.dart @@ -1,6 +1,5 @@ import 'dart:async'; import 'package:moxxmpp/moxxmpp.dart'; -import 'package:moxxmpp/src/util/typed_map.dart'; import 'package:test/test.dart'; import 'helpers/logging.dart'; import 'helpers/xmpp.dart';