diff --git a/packages/moxxmpp/lib/src/events.dart b/packages/moxxmpp/lib/src/events.dart index 2905d44..2eaec7b 100644 --- a/packages/moxxmpp/lib/src/events.dart +++ b/packages/moxxmpp/lib/src/events.dart @@ -79,12 +79,13 @@ class MessageEvent extends XmppEvent { required this.fromJid, required this.toJid, required this.sid, - required this.stanzaId, required this.isCarbon, required this.deliveryReceiptRequested, required this.isMarkable, required this.encrypted, required this.other, + this.originId, + this.stanzaIds, this.error, this.type, this.oob, @@ -107,7 +108,8 @@ class MessageEvent extends XmppEvent { final JID toJid; final String sid; final String? type; - final StableStanzaId stanzaId; + final String? originId; + final List? stanzaIds; final bool isCarbon; final bool deliveryReceiptRequested; final bool isMarkable; diff --git a/packages/moxxmpp/lib/src/managers/data.dart b/packages/moxxmpp/lib/src/managers/data.dart index 4bb1cc1..cbc2f85 100644 --- a/packages/moxxmpp/lib/src/managers/data.dart +++ b/packages/moxxmpp/lib/src/managers/data.dart @@ -34,7 +34,12 @@ class StanzaHandlerData with _$StanzaHandlerData { StatelessMediaSharingData? sims, StatelessFileSharingData? sfs, OOBData? oob, - StableStanzaId? stableId, + + // XEP-0359 's id attribute, if available. + String? originId, + + // XEP-0359 elements, if available. + List? stanzaIds, ReplyData? reply, ChatState? chatState, @Default(false) bool isCarbon, diff --git a/packages/moxxmpp/lib/src/managers/data.freezed.dart b/packages/moxxmpp/lib/src/managers/data.freezed.dart index d5a1c2b..cca8e46 100644 --- a/packages/moxxmpp/lib/src/managers/data.freezed.dart +++ b/packages/moxxmpp/lib/src/managers/data.freezed.dart @@ -1,7 +1,7 @@ // coverage:ignore-file // GENERATED CODE - DO NOT MODIFY BY HAND // ignore_for_file: type=lint -// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark part of 'data.dart'; @@ -32,8 +32,11 @@ mixin _$StanzaHandlerData { bool get retransmitted => throw _privateConstructorUsedError; StatelessMediaSharingData? get sims => throw _privateConstructorUsedError; StatelessFileSharingData? get sfs => throw _privateConstructorUsedError; - OOBData? get oob => throw _privateConstructorUsedError; - StableStanzaId? get stableId => throw _privateConstructorUsedError; + OOBData? get oob => + throw _privateConstructorUsedError; // XEP-0359 's id attribute, if available. + String? get originId => + throw _privateConstructorUsedError; // XEP-0359 elements, if available. + List? get stanzaIds => throw _privateConstructorUsedError; ReplyData? get reply => throw _privateConstructorUsedError; ChatState? get chatState => throw _privateConstructorUsedError; bool get isCarbon => throw _privateConstructorUsedError; @@ -79,7 +82,8 @@ mixin _$StanzaHandlerData { abstract class $StanzaHandlerDataCopyWith<$Res> { factory $StanzaHandlerDataCopyWith( StanzaHandlerData value, $Res Function(StanzaHandlerData) then) = - _$StanzaHandlerDataCopyWithImpl<$Res>; + _$StanzaHandlerDataCopyWithImpl<$Res, StanzaHandlerData>; + @useResult $Res call( {bool done, bool cancel, @@ -89,7 +93,8 @@ abstract class $StanzaHandlerDataCopyWith<$Res> { StatelessMediaSharingData? sims, StatelessFileSharingData? sfs, OOBData? oob, - StableStanzaId? stableId, + String? originId, + List? stanzaIds, ReplyData? reply, ChatState? chatState, bool isCarbon, @@ -110,149 +115,156 @@ abstract class $StanzaHandlerDataCopyWith<$Res> { } /// @nodoc -class _$StanzaHandlerDataCopyWithImpl<$Res> +class _$StanzaHandlerDataCopyWithImpl<$Res, $Val extends StanzaHandlerData> implements $StanzaHandlerDataCopyWith<$Res> { _$StanzaHandlerDataCopyWithImpl(this._value, this._then); - final StanzaHandlerData _value; // ignore: unused_field - final $Res Function(StanzaHandlerData) _then; + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + @pragma('vm:prefer-inline') @override $Res call({ - Object? done = freezed, - Object? cancel = freezed, + Object? done = null, + Object? cancel = null, Object? cancelReason = freezed, - Object? stanza = freezed, - Object? retransmitted = freezed, + Object? stanza = null, + Object? retransmitted = null, Object? sims = freezed, Object? sfs = freezed, Object? oob = freezed, - Object? stableId = freezed, + Object? originId = freezed, + Object? stanzaIds = freezed, Object? reply = freezed, Object? chatState = freezed, - Object? isCarbon = freezed, - Object? deliveryReceiptRequested = freezed, - Object? isMarkable = freezed, + Object? isCarbon = null, + Object? deliveryReceiptRequested = null, + Object? isMarkable = null, Object? fun = freezed, Object? funReplacement = freezed, Object? funCancellation = freezed, - Object? encrypted = freezed, - Object? forceEncryption = freezed, + Object? encrypted = null, + Object? forceEncryption = null, Object? encryptionType = freezed, Object? delayedDelivery = freezed, - Object? other = freezed, + Object? other = null, Object? messageRetraction = freezed, Object? lastMessageCorrectionSid = freezed, Object? messageReactions = freezed, Object? stickerPackId = freezed, }) { return _then(_value.copyWith( - done: done == freezed + done: null == done ? _value.done : done // ignore: cast_nullable_to_non_nullable as bool, - cancel: cancel == freezed + cancel: null == cancel ? _value.cancel : cancel // ignore: cast_nullable_to_non_nullable as bool, - cancelReason: cancelReason == freezed + cancelReason: freezed == cancelReason ? _value.cancelReason : cancelReason // ignore: cast_nullable_to_non_nullable as dynamic, - stanza: stanza == freezed + stanza: null == stanza ? _value.stanza : stanza // ignore: cast_nullable_to_non_nullable as Stanza, - retransmitted: retransmitted == freezed + retransmitted: null == retransmitted ? _value.retransmitted : retransmitted // ignore: cast_nullable_to_non_nullable as bool, - sims: sims == freezed + sims: freezed == sims ? _value.sims : sims // ignore: cast_nullable_to_non_nullable as StatelessMediaSharingData?, - sfs: sfs == freezed + sfs: freezed == sfs ? _value.sfs : sfs // ignore: cast_nullable_to_non_nullable as StatelessFileSharingData?, - oob: oob == freezed + oob: freezed == oob ? _value.oob : oob // ignore: cast_nullable_to_non_nullable as OOBData?, - stableId: stableId == freezed - ? _value.stableId - : stableId // ignore: cast_nullable_to_non_nullable - as StableStanzaId?, - reply: reply == freezed + originId: freezed == originId + ? _value.originId + : originId // ignore: cast_nullable_to_non_nullable + as String?, + stanzaIds: freezed == stanzaIds + ? _value.stanzaIds + : stanzaIds // ignore: cast_nullable_to_non_nullable + as List?, + reply: freezed == reply ? _value.reply : reply // ignore: cast_nullable_to_non_nullable as ReplyData?, - chatState: chatState == freezed + chatState: freezed == chatState ? _value.chatState : chatState // ignore: cast_nullable_to_non_nullable as ChatState?, - isCarbon: isCarbon == freezed + isCarbon: null == isCarbon ? _value.isCarbon : isCarbon // ignore: cast_nullable_to_non_nullable as bool, - deliveryReceiptRequested: deliveryReceiptRequested == freezed + deliveryReceiptRequested: null == deliveryReceiptRequested ? _value.deliveryReceiptRequested : deliveryReceiptRequested // ignore: cast_nullable_to_non_nullable as bool, - isMarkable: isMarkable == freezed + isMarkable: null == isMarkable ? _value.isMarkable : isMarkable // ignore: cast_nullable_to_non_nullable as bool, - fun: fun == freezed + fun: freezed == fun ? _value.fun : fun // ignore: cast_nullable_to_non_nullable as FileMetadataData?, - funReplacement: funReplacement == freezed + funReplacement: freezed == funReplacement ? _value.funReplacement : funReplacement // ignore: cast_nullable_to_non_nullable as String?, - funCancellation: funCancellation == freezed + funCancellation: freezed == funCancellation ? _value.funCancellation : funCancellation // ignore: cast_nullable_to_non_nullable as String?, - encrypted: encrypted == freezed + encrypted: null == encrypted ? _value.encrypted : encrypted // ignore: cast_nullable_to_non_nullable as bool, - forceEncryption: forceEncryption == freezed + forceEncryption: null == forceEncryption ? _value.forceEncryption : forceEncryption // ignore: cast_nullable_to_non_nullable as bool, - encryptionType: encryptionType == freezed + encryptionType: freezed == encryptionType ? _value.encryptionType : encryptionType // ignore: cast_nullable_to_non_nullable as ExplicitEncryptionType?, - delayedDelivery: delayedDelivery == freezed + delayedDelivery: freezed == delayedDelivery ? _value.delayedDelivery : delayedDelivery // ignore: cast_nullable_to_non_nullable as DelayedDelivery?, - other: other == freezed + other: null == other ? _value.other : other // ignore: cast_nullable_to_non_nullable as Map, - messageRetraction: messageRetraction == freezed + messageRetraction: freezed == messageRetraction ? _value.messageRetraction : messageRetraction // ignore: cast_nullable_to_non_nullable as MessageRetractionData?, - lastMessageCorrectionSid: lastMessageCorrectionSid == freezed + lastMessageCorrectionSid: freezed == lastMessageCorrectionSid ? _value.lastMessageCorrectionSid : lastMessageCorrectionSid // ignore: cast_nullable_to_non_nullable as String?, - messageReactions: messageReactions == freezed + messageReactions: freezed == messageReactions ? _value.messageReactions : messageReactions // ignore: cast_nullable_to_non_nullable as MessageReactions?, - stickerPackId: stickerPackId == freezed + stickerPackId: freezed == stickerPackId ? _value.stickerPackId : stickerPackId // ignore: cast_nullable_to_non_nullable as String?, - )); + ) as $Val); } } @@ -263,6 +275,7 @@ abstract class _$$_StanzaHandlerDataCopyWith<$Res> $Res Function(_$_StanzaHandlerData) then) = __$$_StanzaHandlerDataCopyWithImpl<$Res>; @override + @useResult $Res call( {bool done, bool cancel, @@ -272,7 +285,8 @@ abstract class _$$_StanzaHandlerDataCopyWith<$Res> StatelessMediaSharingData? sims, StatelessFileSharingData? sfs, OOBData? oob, - StableStanzaId? stableId, + String? originId, + List? stanzaIds, ReplyData? reply, ChatState? chatState, bool isCarbon, @@ -294,146 +308,149 @@ abstract class _$$_StanzaHandlerDataCopyWith<$Res> /// @nodoc class __$$_StanzaHandlerDataCopyWithImpl<$Res> - extends _$StanzaHandlerDataCopyWithImpl<$Res> + extends _$StanzaHandlerDataCopyWithImpl<$Res, _$_StanzaHandlerData> implements _$$_StanzaHandlerDataCopyWith<$Res> { __$$_StanzaHandlerDataCopyWithImpl( _$_StanzaHandlerData _value, $Res Function(_$_StanzaHandlerData) _then) - : super(_value, (v) => _then(v as _$_StanzaHandlerData)); - - @override - _$_StanzaHandlerData get _value => super._value as _$_StanzaHandlerData; + : super(_value, _then); + @pragma('vm:prefer-inline') @override $Res call({ - Object? done = freezed, - Object? cancel = freezed, + Object? done = null, + Object? cancel = null, Object? cancelReason = freezed, - Object? stanza = freezed, - Object? retransmitted = freezed, + Object? stanza = null, + Object? retransmitted = null, Object? sims = freezed, Object? sfs = freezed, Object? oob = freezed, - Object? stableId = freezed, + Object? originId = freezed, + Object? stanzaIds = freezed, Object? reply = freezed, Object? chatState = freezed, - Object? isCarbon = freezed, - Object? deliveryReceiptRequested = freezed, - Object? isMarkable = freezed, + Object? isCarbon = null, + Object? deliveryReceiptRequested = null, + Object? isMarkable = null, Object? fun = freezed, Object? funReplacement = freezed, Object? funCancellation = freezed, - Object? encrypted = freezed, - Object? forceEncryption = freezed, + Object? encrypted = null, + Object? forceEncryption = null, Object? encryptionType = freezed, Object? delayedDelivery = freezed, - Object? other = freezed, + Object? other = null, Object? messageRetraction = freezed, Object? lastMessageCorrectionSid = freezed, Object? messageReactions = freezed, Object? stickerPackId = freezed, }) { return _then(_$_StanzaHandlerData( - done == freezed + null == done ? _value.done : done // ignore: cast_nullable_to_non_nullable as bool, - cancel == freezed + null == cancel ? _value.cancel : cancel // ignore: cast_nullable_to_non_nullable as bool, - cancelReason == freezed + freezed == cancelReason ? _value.cancelReason : cancelReason // ignore: cast_nullable_to_non_nullable as dynamic, - stanza == freezed + null == stanza ? _value.stanza : stanza // ignore: cast_nullable_to_non_nullable as Stanza, - retransmitted: retransmitted == freezed + retransmitted: null == retransmitted ? _value.retransmitted : retransmitted // ignore: cast_nullable_to_non_nullable as bool, - sims: sims == freezed + sims: freezed == sims ? _value.sims : sims // ignore: cast_nullable_to_non_nullable as StatelessMediaSharingData?, - sfs: sfs == freezed + sfs: freezed == sfs ? _value.sfs : sfs // ignore: cast_nullable_to_non_nullable as StatelessFileSharingData?, - oob: oob == freezed + oob: freezed == oob ? _value.oob : oob // ignore: cast_nullable_to_non_nullable as OOBData?, - stableId: stableId == freezed - ? _value.stableId - : stableId // ignore: cast_nullable_to_non_nullable - as StableStanzaId?, - reply: reply == freezed + originId: freezed == originId + ? _value.originId + : originId // ignore: cast_nullable_to_non_nullable + as String?, + stanzaIds: freezed == stanzaIds + ? _value._stanzaIds + : stanzaIds // ignore: cast_nullable_to_non_nullable + as List?, + reply: freezed == reply ? _value.reply : reply // ignore: cast_nullable_to_non_nullable as ReplyData?, - chatState: chatState == freezed + chatState: freezed == chatState ? _value.chatState : chatState // ignore: cast_nullable_to_non_nullable as ChatState?, - isCarbon: isCarbon == freezed + isCarbon: null == isCarbon ? _value.isCarbon : isCarbon // ignore: cast_nullable_to_non_nullable as bool, - deliveryReceiptRequested: deliveryReceiptRequested == freezed + deliveryReceiptRequested: null == deliveryReceiptRequested ? _value.deliveryReceiptRequested : deliveryReceiptRequested // ignore: cast_nullable_to_non_nullable as bool, - isMarkable: isMarkable == freezed + isMarkable: null == isMarkable ? _value.isMarkable : isMarkable // ignore: cast_nullable_to_non_nullable as bool, - fun: fun == freezed + fun: freezed == fun ? _value.fun : fun // ignore: cast_nullable_to_non_nullable as FileMetadataData?, - funReplacement: funReplacement == freezed + funReplacement: freezed == funReplacement ? _value.funReplacement : funReplacement // ignore: cast_nullable_to_non_nullable as String?, - funCancellation: funCancellation == freezed + funCancellation: freezed == funCancellation ? _value.funCancellation : funCancellation // ignore: cast_nullable_to_non_nullable as String?, - encrypted: encrypted == freezed + encrypted: null == encrypted ? _value.encrypted : encrypted // ignore: cast_nullable_to_non_nullable as bool, - forceEncryption: forceEncryption == freezed + forceEncryption: null == forceEncryption ? _value.forceEncryption : forceEncryption // ignore: cast_nullable_to_non_nullable as bool, - encryptionType: encryptionType == freezed + encryptionType: freezed == encryptionType ? _value.encryptionType : encryptionType // ignore: cast_nullable_to_non_nullable as ExplicitEncryptionType?, - delayedDelivery: delayedDelivery == freezed + delayedDelivery: freezed == delayedDelivery ? _value.delayedDelivery : delayedDelivery // ignore: cast_nullable_to_non_nullable as DelayedDelivery?, - other: other == freezed + other: null == other ? _value._other : other // ignore: cast_nullable_to_non_nullable as Map, - messageRetraction: messageRetraction == freezed + messageRetraction: freezed == messageRetraction ? _value.messageRetraction : messageRetraction // ignore: cast_nullable_to_non_nullable as MessageRetractionData?, - lastMessageCorrectionSid: lastMessageCorrectionSid == freezed + lastMessageCorrectionSid: freezed == lastMessageCorrectionSid ? _value.lastMessageCorrectionSid : lastMessageCorrectionSid // ignore: cast_nullable_to_non_nullable as String?, - messageReactions: messageReactions == freezed + messageReactions: freezed == messageReactions ? _value.messageReactions : messageReactions // ignore: cast_nullable_to_non_nullable as MessageReactions?, - stickerPackId: stickerPackId == freezed + stickerPackId: freezed == stickerPackId ? _value.stickerPackId : stickerPackId // ignore: cast_nullable_to_non_nullable as String?, @@ -449,7 +466,8 @@ class _$_StanzaHandlerData implements _StanzaHandlerData { this.sims, this.sfs, this.oob, - this.stableId, + this.originId, + final List? stanzaIds, this.reply, this.chatState, this.isCarbon = false, @@ -467,7 +485,8 @@ class _$_StanzaHandlerData implements _StanzaHandlerData { this.lastMessageCorrectionSid, this.messageReactions, this.stickerPackId}) - : _other = other; + : _stanzaIds = stanzaIds, + _other = other; // Indicates to the runner that processing is now done. This means that all // pre-processing is done and no other handlers should be consulted. @@ -495,8 +514,21 @@ class _$_StanzaHandlerData implements _StanzaHandlerData { final StatelessFileSharingData? sfs; @override final OOBData? oob; +// XEP-0359 's id attribute, if available. @override - final StableStanzaId? stableId; + final String? originId; +// XEP-0359 elements, if available. + final List? _stanzaIds; +// XEP-0359 elements, if available. + @override + List? get stanzaIds { + final value = _stanzaIds; + if (value == null) return null; + if (_stanzaIds is EqualUnmodifiableListView) return _stanzaIds; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(value); + } + @override final ReplyData? reply; @override @@ -545,6 +577,7 @@ class _$_StanzaHandlerData implements _StanzaHandlerData { @override @JsonKey() Map get other { + if (_other is EqualUnmodifiableMapView) return _other; // ignore: implicit_dynamic_type return EqualUnmodifiableMapView(_other); } @@ -565,7 +598,7 @@ class _$_StanzaHandlerData implements _StanzaHandlerData { @override String toString() { - return 'StanzaHandlerData(done: $done, cancel: $cancel, cancelReason: $cancelReason, stanza: $stanza, retransmitted: $retransmitted, sims: $sims, sfs: $sfs, oob: $oob, stableId: $stableId, reply: $reply, chatState: $chatState, isCarbon: $isCarbon, deliveryReceiptRequested: $deliveryReceiptRequested, isMarkable: $isMarkable, fun: $fun, funReplacement: $funReplacement, funCancellation: $funCancellation, encrypted: $encrypted, forceEncryption: $forceEncryption, encryptionType: $encryptionType, delayedDelivery: $delayedDelivery, other: $other, messageRetraction: $messageRetraction, lastMessageCorrectionSid: $lastMessageCorrectionSid, messageReactions: $messageReactions, stickerPackId: $stickerPackId)'; + return 'StanzaHandlerData(done: $done, cancel: $cancel, cancelReason: $cancelReason, stanza: $stanza, retransmitted: $retransmitted, sims: $sims, sfs: $sfs, oob: $oob, originId: $originId, stanzaIds: $stanzaIds, reply: $reply, chatState: $chatState, isCarbon: $isCarbon, deliveryReceiptRequested: $deliveryReceiptRequested, isMarkable: $isMarkable, fun: $fun, funReplacement: $funReplacement, funCancellation: $funCancellation, encrypted: $encrypted, forceEncryption: $forceEncryption, encryptionType: $encryptionType, delayedDelivery: $delayedDelivery, other: $other, messageRetraction: $messageRetraction, lastMessageCorrectionSid: $lastMessageCorrectionSid, messageReactions: $messageReactions, stickerPackId: $stickerPackId)'; } @override @@ -573,80 +606,90 @@ class _$_StanzaHandlerData implements _StanzaHandlerData { return identical(this, other) || (other.runtimeType == runtimeType && other is _$_StanzaHandlerData && - const DeepCollectionEquality().equals(other.done, done) && - const DeepCollectionEquality().equals(other.cancel, cancel) && + (identical(other.done, done) || other.done == done) && + (identical(other.cancel, cancel) || other.cancel == cancel) && const DeepCollectionEquality() .equals(other.cancelReason, cancelReason) && - const DeepCollectionEquality().equals(other.stanza, stanza) && + (identical(other.stanza, stanza) || other.stanza == stanza) && + (identical(other.retransmitted, retransmitted) || + other.retransmitted == retransmitted) && + (identical(other.sims, sims) || other.sims == sims) && + (identical(other.sfs, sfs) || other.sfs == sfs) && + (identical(other.oob, oob) || other.oob == oob) && + (identical(other.originId, originId) || + other.originId == originId) && const DeepCollectionEquality() - .equals(other.retransmitted, retransmitted) && - const DeepCollectionEquality().equals(other.sims, sims) && - const DeepCollectionEquality().equals(other.sfs, sfs) && - const DeepCollectionEquality().equals(other.oob, oob) && - const DeepCollectionEquality().equals(other.stableId, stableId) && - const DeepCollectionEquality().equals(other.reply, reply) && - const DeepCollectionEquality().equals(other.chatState, chatState) && - const DeepCollectionEquality().equals(other.isCarbon, isCarbon) && - const DeepCollectionEquality().equals( - other.deliveryReceiptRequested, deliveryReceiptRequested) && - const DeepCollectionEquality() - .equals(other.isMarkable, isMarkable) && - const DeepCollectionEquality().equals(other.fun, fun) && - const DeepCollectionEquality() - .equals(other.funReplacement, funReplacement) && - const DeepCollectionEquality() - .equals(other.funCancellation, funCancellation) && - const DeepCollectionEquality().equals(other.encrypted, encrypted) && - const DeepCollectionEquality() - .equals(other.forceEncryption, forceEncryption) && - const DeepCollectionEquality() - .equals(other.encryptionType, encryptionType) && - const DeepCollectionEquality() - .equals(other.delayedDelivery, delayedDelivery) && + .equals(other._stanzaIds, _stanzaIds) && + (identical(other.reply, reply) || other.reply == reply) && + (identical(other.chatState, chatState) || + other.chatState == chatState) && + (identical(other.isCarbon, isCarbon) || + other.isCarbon == isCarbon) && + (identical( + other.deliveryReceiptRequested, deliveryReceiptRequested) || + other.deliveryReceiptRequested == deliveryReceiptRequested) && + (identical(other.isMarkable, isMarkable) || + other.isMarkable == isMarkable) && + (identical(other.fun, fun) || other.fun == fun) && + (identical(other.funReplacement, funReplacement) || + other.funReplacement == funReplacement) && + (identical(other.funCancellation, funCancellation) || + other.funCancellation == funCancellation) && + (identical(other.encrypted, encrypted) || + other.encrypted == encrypted) && + (identical(other.forceEncryption, forceEncryption) || + other.forceEncryption == forceEncryption) && + (identical(other.encryptionType, encryptionType) || + other.encryptionType == encryptionType) && + (identical(other.delayedDelivery, delayedDelivery) || + other.delayedDelivery == delayedDelivery) && const DeepCollectionEquality().equals(other._other, this._other) && - const DeepCollectionEquality() - .equals(other.messageRetraction, messageRetraction) && - const DeepCollectionEquality().equals( - other.lastMessageCorrectionSid, lastMessageCorrectionSid) && - const DeepCollectionEquality() - .equals(other.messageReactions, messageReactions) && - const DeepCollectionEquality() - .equals(other.stickerPackId, stickerPackId)); + (identical(other.messageRetraction, messageRetraction) || + other.messageRetraction == messageRetraction) && + (identical( + other.lastMessageCorrectionSid, lastMessageCorrectionSid) || + other.lastMessageCorrectionSid == lastMessageCorrectionSid) && + (identical(other.messageReactions, messageReactions) || + other.messageReactions == messageReactions) && + (identical(other.stickerPackId, stickerPackId) || + other.stickerPackId == stickerPackId)); } @override int get hashCode => Object.hashAll([ runtimeType, - const DeepCollectionEquality().hash(done), - const DeepCollectionEquality().hash(cancel), + done, + cancel, const DeepCollectionEquality().hash(cancelReason), - const DeepCollectionEquality().hash(stanza), - const DeepCollectionEquality().hash(retransmitted), - const DeepCollectionEquality().hash(sims), - const DeepCollectionEquality().hash(sfs), - const DeepCollectionEquality().hash(oob), - const DeepCollectionEquality().hash(stableId), - const DeepCollectionEquality().hash(reply), - const DeepCollectionEquality().hash(chatState), - const DeepCollectionEquality().hash(isCarbon), - const DeepCollectionEquality().hash(deliveryReceiptRequested), - const DeepCollectionEquality().hash(isMarkable), - const DeepCollectionEquality().hash(fun), - const DeepCollectionEquality().hash(funReplacement), - const DeepCollectionEquality().hash(funCancellation), - const DeepCollectionEquality().hash(encrypted), - const DeepCollectionEquality().hash(forceEncryption), - const DeepCollectionEquality().hash(encryptionType), - const DeepCollectionEquality().hash(delayedDelivery), + stanza, + retransmitted, + sims, + sfs, + oob, + originId, + const DeepCollectionEquality().hash(_stanzaIds), + reply, + chatState, + isCarbon, + deliveryReceiptRequested, + isMarkable, + fun, + funReplacement, + funCancellation, + encrypted, + forceEncryption, + encryptionType, + delayedDelivery, const DeepCollectionEquality().hash(_other), - const DeepCollectionEquality().hash(messageRetraction), - const DeepCollectionEquality().hash(lastMessageCorrectionSid), - const DeepCollectionEquality().hash(messageReactions), - const DeepCollectionEquality().hash(stickerPackId) + messageRetraction, + lastMessageCorrectionSid, + messageReactions, + stickerPackId ]); @JsonKey(ignore: true) @override + @pragma('vm:prefer-inline') _$$_StanzaHandlerDataCopyWith<_$_StanzaHandlerData> get copyWith => __$$_StanzaHandlerDataCopyWithImpl<_$_StanzaHandlerData>( this, _$identity); @@ -659,7 +702,8 @@ abstract class _StanzaHandlerData implements StanzaHandlerData { final StatelessMediaSharingData? sims, final StatelessFileSharingData? sfs, final OOBData? oob, - final StableStanzaId? stableId, + final String? originId, + final List? stanzaIds, final ReplyData? reply, final ChatState? chatState, final bool isCarbon, @@ -698,8 +742,10 @@ abstract class _StanzaHandlerData implements StanzaHandlerData { StatelessFileSharingData? get sfs; @override OOBData? get oob; - @override - StableStanzaId? get stableId; + @override // XEP-0359 's id attribute, if available. + String? get originId; + @override // XEP-0359 elements, if available. + List? get stanzaIds; @override ReplyData? get reply; @override diff --git a/packages/moxxmpp/lib/src/message.dart b/packages/moxxmpp/lib/src/message.dart index 7b78b28..ae3ea31 100644 --- a/packages/moxxmpp/lib/src/message.dart +++ b/packages/moxxmpp/lib/src/message.dart @@ -109,7 +109,8 @@ class MessageManager extends XmppManagerBase { fromJid: JID.fromString(message.attributes['from']! as String), toJid: JID.fromString(message.attributes['to']! as String), sid: message.attributes['id']! as String, - stanzaId: state.stableId ?? const StableStanzaId(), + originId: state.originId, + stanzaIds: state.stanzaIds, isCarbon: state.isCarbon, deliveryReceiptRequested: state.deliveryReceiptRequested, isMarkable: state.isMarkable, diff --git a/packages/moxxmpp/lib/src/xeps/xep_0198/state.freezed.dart b/packages/moxxmpp/lib/src/xeps/xep_0198/state.freezed.dart index ce92658..dedf565 100644 --- a/packages/moxxmpp/lib/src/xeps/xep_0198/state.freezed.dart +++ b/packages/moxxmpp/lib/src/xeps/xep_0198/state.freezed.dart @@ -1,7 +1,7 @@ // coverage:ignore-file // GENERATED CODE - DO NOT MODIFY BY HAND // ignore_for_file: type=lint -// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark part of 'state.dart'; @@ -36,7 +36,8 @@ mixin _$StreamManagementState { abstract class $StreamManagementStateCopyWith<$Res> { factory $StreamManagementStateCopyWith(StreamManagementState value, $Res Function(StreamManagementState) then) = - _$StreamManagementStateCopyWithImpl<$Res>; + _$StreamManagementStateCopyWithImpl<$Res, StreamManagementState>; + @useResult $Res call( {int c2s, int s2c, @@ -45,39 +46,42 @@ abstract class $StreamManagementStateCopyWith<$Res> { } /// @nodoc -class _$StreamManagementStateCopyWithImpl<$Res> +class _$StreamManagementStateCopyWithImpl<$Res, + $Val extends StreamManagementState> implements $StreamManagementStateCopyWith<$Res> { _$StreamManagementStateCopyWithImpl(this._value, this._then); - final StreamManagementState _value; // ignore: unused_field - final $Res Function(StreamManagementState) _then; + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + @pragma('vm:prefer-inline') @override $Res call({ - Object? c2s = freezed, - Object? s2c = freezed, + Object? c2s = null, + Object? s2c = null, Object? streamResumptionLocation = freezed, Object? streamResumptionId = freezed, }) { return _then(_value.copyWith( - c2s: c2s == freezed + c2s: null == c2s ? _value.c2s : c2s // ignore: cast_nullable_to_non_nullable as int, - s2c: s2c == freezed + s2c: null == s2c ? _value.s2c : s2c // ignore: cast_nullable_to_non_nullable as int, - streamResumptionLocation: streamResumptionLocation == freezed + streamResumptionLocation: freezed == streamResumptionLocation ? _value.streamResumptionLocation : streamResumptionLocation // ignore: cast_nullable_to_non_nullable as String?, - streamResumptionId: streamResumptionId == freezed + streamResumptionId: freezed == streamResumptionId ? _value.streamResumptionId : streamResumptionId // ignore: cast_nullable_to_non_nullable as String?, - )); + ) as $Val); } } @@ -88,6 +92,7 @@ abstract class _$$_StreamManagementStateCopyWith<$Res> $Res Function(_$_StreamManagementState) then) = __$$_StreamManagementStateCopyWithImpl<$Res>; @override + @useResult $Res call( {int c2s, int s2c, @@ -97,37 +102,34 @@ abstract class _$$_StreamManagementStateCopyWith<$Res> /// @nodoc class __$$_StreamManagementStateCopyWithImpl<$Res> - extends _$StreamManagementStateCopyWithImpl<$Res> + extends _$StreamManagementStateCopyWithImpl<$Res, _$_StreamManagementState> implements _$$_StreamManagementStateCopyWith<$Res> { __$$_StreamManagementStateCopyWithImpl(_$_StreamManagementState _value, $Res Function(_$_StreamManagementState) _then) - : super(_value, (v) => _then(v as _$_StreamManagementState)); - - @override - _$_StreamManagementState get _value => - super._value as _$_StreamManagementState; + : super(_value, _then); + @pragma('vm:prefer-inline') @override $Res call({ - Object? c2s = freezed, - Object? s2c = freezed, + Object? c2s = null, + Object? s2c = null, Object? streamResumptionLocation = freezed, Object? streamResumptionId = freezed, }) { return _then(_$_StreamManagementState( - c2s == freezed + null == c2s ? _value.c2s : c2s // ignore: cast_nullable_to_non_nullable as int, - s2c == freezed + null == s2c ? _value.s2c : s2c // ignore: cast_nullable_to_non_nullable as int, - streamResumptionLocation: streamResumptionLocation == freezed + streamResumptionLocation: freezed == streamResumptionLocation ? _value.streamResumptionLocation : streamResumptionLocation // ignore: cast_nullable_to_non_nullable as String?, - streamResumptionId: streamResumptionId == freezed + streamResumptionId: freezed == streamResumptionId ? _value.streamResumptionId : streamResumptionId // ignore: cast_nullable_to_non_nullable as String?, @@ -163,25 +165,23 @@ class _$_StreamManagementState implements _StreamManagementState { return identical(this, other) || (other.runtimeType == runtimeType && other is _$_StreamManagementState && - const DeepCollectionEquality().equals(other.c2s, c2s) && - const DeepCollectionEquality().equals(other.s2c, s2c) && - const DeepCollectionEquality().equals( - other.streamResumptionLocation, streamResumptionLocation) && - const DeepCollectionEquality() - .equals(other.streamResumptionId, streamResumptionId)); + (identical(other.c2s, c2s) || other.c2s == c2s) && + (identical(other.s2c, s2c) || other.s2c == s2c) && + (identical( + other.streamResumptionLocation, streamResumptionLocation) || + other.streamResumptionLocation == streamResumptionLocation) && + (identical(other.streamResumptionId, streamResumptionId) || + other.streamResumptionId == streamResumptionId)); } @JsonKey(ignore: true) @override int get hashCode => Object.hash( - runtimeType, - const DeepCollectionEquality().hash(c2s), - const DeepCollectionEquality().hash(s2c), - const DeepCollectionEquality().hash(streamResumptionLocation), - const DeepCollectionEquality().hash(streamResumptionId)); + runtimeType, c2s, s2c, streamResumptionLocation, streamResumptionId); @JsonKey(ignore: true) @override + @pragma('vm:prefer-inline') _$$_StreamManagementStateCopyWith<_$_StreamManagementState> get copyWith => __$$_StreamManagementStateCopyWithImpl<_$_StreamManagementState>( this, _$identity); diff --git a/packages/moxxmpp/lib/src/xeps/xep_0359.dart b/packages/moxxmpp/lib/src/xeps/xep_0359.dart index 3033b21..649edbe 100644 --- a/packages/moxxmpp/lib/src/xeps/xep_0359.dart +++ b/packages/moxxmpp/lib/src/xeps/xep_0359.dart @@ -6,17 +6,30 @@ import 'package:moxxmpp/src/managers/namespaces.dart'; import 'package:moxxmpp/src/namespaces.dart'; import 'package:moxxmpp/src/stanza.dart'; import 'package:moxxmpp/src/stringxml.dart'; -import 'package:moxxmpp/src/xeps/xep_0030/types.dart'; -import 'package:moxxmpp/src/xeps/xep_0030/xep_0030.dart'; -/// Represents data provided by XEP-0359. -/// NOTE: [StableStanzaId.stanzaId] must not be confused with the actual id attribute of -/// the message stanza. -class StableStanzaId { - const StableStanzaId({this.originId, this.stanzaId, this.stanzaIdBy}); - final String? originId; - final String? stanzaId; - final String? stanzaIdBy; +/// Representation of a element. +class StanzaId { + const StanzaId( + this.id, + this.by, + ); + + /// The unique stanza id. + final String id; + + /// The JID the id was generated by. + final JID by; + + XMLNode toXml() { + return XMLNode.xmlns( + tag: 'stanza-id', + xmlns: stableIdXmlns, + attributes: { + 'id': id, + 'by': by.toString(), + }, + ); + } } XMLNode makeOriginIdElement(String id) { @@ -50,50 +63,32 @@ class StableIdManager extends XmppManagerBase { Stanza message, StanzaHandlerData state, ) async { - final from = JID.fromString(message.attributes['from']! as String); String? originId; - String? stanzaId; - String? stanzaIdBy; - final originIdTag = message.firstTag('origin-id', xmlns: stableIdXmlns); - final stanzaIdTag = message.firstTag('stanza-id', xmlns: stableIdXmlns); + List? stanzaIds; + final originIdElement = message.firstTag('origin-id', xmlns: stableIdXmlns); + final stanzaIdElements = + message.findTags('stanza-id', xmlns: stableIdXmlns); // Process the origin id - if (originIdTag != null) { - logger.finest('Found origin Id tag'); - originId = originIdTag.attributes['id']! as String; + if (originIdElement != null) { + originId = originIdElement.attributes['id']! as String; } // Process the stanza id tag - if (stanzaIdTag != null) { - logger.finest('Found stanza Id tag'); - final attrs = getAttributes(); - final disco = attrs.getManagerById(discoManager)!; - final result = await disco.discoInfoQuery(from); - if (result.isType()) { - final info = result.get(); - logger.finest('Got info for ${from.toString()}'); - if (info.features.contains(stableIdXmlns)) { - logger.finest('${from.toString()} supports $stableIdXmlns.'); - stanzaId = stanzaIdTag.attributes['id']! as String; - stanzaIdBy = stanzaIdTag.attributes['by']! as String; - } else { - logger.finest( - '${from.toString()} does not support $stableIdXmlns. Ignoring stanza id... ', - ); - } - } else { - logger.finest( - 'Failed to find out if ${from.toString()} supports $stableIdXmlns. Ignoring... ', - ); - } + if (stanzaIdElements.isNotEmpty) { + stanzaIds = stanzaIdElements + .map( + (element) => StanzaId( + element.attributes['id']! as String, + JID.fromString(element.attributes['by']! as String), + ), + ) + .toList(); } return state.copyWith( - stableId: StableStanzaId( - originId: originId, - stanzaId: stanzaId, - stanzaIdBy: stanzaIdBy, - ), + originId: originId, + stanzaIds: stanzaIds, ); } }