pubnub / dart

PubNub Dart SDK
Other
27 stars 15 forks source link

batch.fetchMessages with `includeUUID: false` raises null exception #89

Closed linsdev closed 2 years ago

linsdev commented 2 years ago
final pubnub = PubNub(...);

pubnub.batch.fetchMessages('channelName', includeUUID: false);

batch.fetchMessages with parameter includeUUID: false failed because BatchHistoryResultEntry.fromJson not check includeUUID parameter.

BatchHistoryResultEntry.fromJson constructor from /lib/src/dx/_endpoints/history.dart:

class BatchHistoryResultEntry {
  ...
  /// UUID of the sender.
  String uuid;
  ...
  factory BatchHistoryResultEntry.fromJson(Map<String, dynamic> object,
      {CipherKey? cipherKey, Function? decryptFunction}) {
    return BatchHistoryResultEntry._(
        cipherKey == null
            ? object['message']
            : decryptFunction!(cipherKey, object['message']),
        Timetoken(BigInt.parse(object['timetoken'])),
        object['uuid'],  // <-- the problem here
        MessageTypeExtension.fromInt(object['message_type']),
        object['actions'],
        object['meta'] == '' ? null : object['meta']);
  }
}

object['uuid'] can be null but uuid field cannot.

github-actions[bot] commented 2 years ago

@linsdev this issue is addressed in v4.1.3