fix(all): Last minute fixes

This commit is contained in:
PapaTutuWawa 2023-06-07 21:04:05 +02:00
parent 09fd5845aa
commit 4ff2992a03
13 changed files with 19 additions and 18 deletions

View File

@ -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

View File

@ -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';

View File

@ -21,7 +21,7 @@ typedef MessageSendingCallback = List<XMLNode> Function(
);
/// The raw content of the <body /> element.
class MessageBodyData {
class MessageBodyData implements StanzaHandlerExtension {
const MessageBodyData(this.body);
/// The content of the <body /> 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.

View File

@ -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,

View File

@ -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<String> 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<XMLNode> _messageSendingCallback(
TypedMap<StanzaHandlerExtension> extensions,
) {
final data = extensions.get<MessageReactions>();
final data = extensions.get<MessageReactionsData>();
return data != null
? [
data.toXML(),

View File

@ -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(),
]
: [];
}

View File

@ -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(

View File

@ -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';

View File

@ -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';

View File

@ -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';

View File

@ -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';

View File

@ -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';

View File

@ -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';