diff --git a/CHANGELOG.md b/CHANGELOG.md index 1b572fc5..a7b1f5a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,20 @@ +## v4.2.0 (Jan 31, 2024) + +### Features + +#### Local Caching for Android and iOS (Not supported for Web yet) +> Local caching enables Sendbird Chat SDK for Flutter to cache and retrieve group channel and message data locally. Its benefits include reducing refresh time and allowing a client app to create a channel list or a chat view that can work online as well as offline. +> The local caching feature is enabled by default. + +- Added `useCollectionCaching` in `SendbirdChatOptions` (The default value is `true`) +- Added `getCachedDataSize()`, `clearCachedData()` and `clearCachedMessages()` in `SendbirdChat` +- Added `getFailedMessages()`, `removeFailedMessages()` and `removeAllFailedMessages()` in `MessageCollection` +- Added `markAsRead() in `BaseMessageCollection` + +### Improvements +- Fixed the bugs regarding FeedChannel +- Improved stability + ## v4.1.2 (Dec 12, 2023) ### Features diff --git a/README.md b/README.md index 657dd064..4fac1619 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ Before installing Sendbird Chat SDK, you need to create a Sendbird application o ```yaml dependencies: - sendbird_chat_sdk: ^4.1.2 + sendbird_chat_sdk: ^4.2.0 ``` - Run `flutter pub get` command in your project directory. diff --git a/example/lib/main.dart b/example/lib/main.dart index 1bba49ca..d4ad7701 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -5,7 +5,7 @@ import 'package:sendbird_chat_sdk/sendbird_chat_sdk.dart'; void main() async { runZonedGuarded(() async { // Initialize the SendbirdChat SDK with your Application ID. - SendbirdChat.init(appId: 'APP-ID'); + await SendbirdChat.init(appId: 'APP-ID'); // Connect to the Sendbird server with a User ID. await SendbirdChat.connect('USER-ID'); diff --git a/lib/src/internal/db/db.dart b/lib/src/internal/db/db.dart new file mode 100644 index 00000000..c496bb63 --- /dev/null +++ b/lib/src/internal/db/db.dart @@ -0,0 +1,509 @@ +// Copyright (c) 2023 Sendbird, Inc. All rights reserved. + +import 'package:isar/isar.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/channel/c_feed_channel.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/channel/c_group_channel.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/channel/meta/c_channel_info.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/channel/meta/channel_info.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/chunk/c_channel_chunk.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/chunk/c_message_chunk.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/chunk/channel_chunk.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/chunk/chunk.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/chunk/message_chunk.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/login/c_login.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/login/login.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/message/c_admin_message.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/message/c_file_message.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/message/c_notification_message.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/message/c_user_message.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/message/meta/c_channel_access.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/message/meta/c_channel_message.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/message/meta/c_message_changelog_info.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/message/meta/channel_access.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/message/meta/channel_message.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/message/meta/message_changelog_info.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/user/c_user.dart'; +import 'package:sendbird_chat_sdk/src/internal/main/chat/chat.dart'; +import 'package:sendbird_chat_sdk/src/public/core/channel/feed_channel/feed_channel.dart'; +import 'package:sendbird_chat_sdk/src/public/core/channel/group_channel/group_channel.dart'; +import 'package:sendbird_chat_sdk/src/public/core/message/admin_message.dart'; +import 'package:sendbird_chat_sdk/src/public/core/message/base_message.dart'; +import 'package:sendbird_chat_sdk/src/public/core/message/file_message.dart'; +import 'package:sendbird_chat_sdk/src/public/core/message/notification_message.dart'; +import 'package:sendbird_chat_sdk/src/public/core/message/root_message.dart'; +import 'package:sendbird_chat_sdk/src/public/core/message/user_message.dart'; +import 'package:sendbird_chat_sdk/src/public/core/user/user.dart'; +import 'package:sendbird_chat_sdk/src/public/main/define/enums.dart'; +import 'package:sendbird_chat_sdk/src/public/main/params/message/message_list_params.dart'; +import 'package:sendbird_chat_sdk/src/public/main/query/channel/feed_channel_list_query.dart'; +import 'package:sendbird_chat_sdk/src/public/main/query/channel/group_channel_list_query.dart'; + +class DB { + final Chat _chat; + final Isar _isar; + + DB({ + required Chat chat, + required Isar isar, + }) : _chat = chat, + _isar = isar; + + // DB + Future write(Function writeFunc) async { + await _isar.writeTxn(() async { + await writeFunc(); + }); + } + + Future clear() async { + await _isar.writeTxn(() async { + await _isar.clear(); + }); + } + + // Login + Future upsertLogin(Login login) async { + await CLogin.upsert(_chat, _isar, login); + } + + Future getLogin(String userId) async { + return await CLogin.get(_chat, _isar, userId); + } + + Future deleteLogin(String userId) async { + await CLogin.delete(_chat, _isar, userId); + } + + Future getLoginCount() async { + return await _isar.cLogins.count(); + } + + // ChannelChunk + Future upsertChannelChunk(ChannelChunk chunk) async { + await CChannelChunk.upsert(_chat, _isar, chunk); + } + + Future getChannelChunk(ChannelChunkType chunkType) async { + return await CChannelChunk.get(_chat, _isar, chunkType); + } + + Future deleteChannelChunk(ChannelChunkType chunkType) async { + await CChannelChunk.delete(_chat, _isar, chunkType); + } + + Future getChannelChunkCount() async { + return await _isar.cChannelChunks.count(); + } + + // MessageChunk + Future upsertMessageChunk(MessageChunk chunk) async { + await CMessageChunk.upsert(_chat, _isar, chunk); + } + + Future getMessageChunk(String channelUrl) async { + return await CMessageChunk.get(_chat, _isar, channelUrl); + } + + Future deleteMessageChunk(String channelUrl) async { + await CMessageChunk.delete(_chat, _isar, channelUrl); + } + + Future deleteMessagesInChunk({ + required String channelUrl, + required List rootIds, + }) async { + if (rootIds.isEmpty) { + return; + } + + final messageChunk = await getMessageChunk(channelUrl); + if (messageChunk != null) { + final List chunks = []; + + for (final rootId in rootIds) { + final message = await getChannelMessage(rootId); + + if (message?.createdAt != null) { + final Chunk? chunk = messageChunk.getChunk(message!.createdAt); + if (chunk != null && !chunks.contains(chunk)) { + chunks.add(chunk); + } + } + } + + bool isChanged = false; + for (final chunk in chunks) { + final cChannelMessages = await _isar.cChannelMessages + .where() + .createdAtBetween( + chunk.oldestTs, + chunk.latestTs, + includeLower: true, + includeUpper: true, + ) + .sortByCreatedAt() + .findAll(); + final newCChannelMessages = [...cChannelMessages]; + + if (cChannelMessages.isNotEmpty) { + for (final cChannelMessage in cChannelMessages) { + for (final rootId in rootIds) { + if (cChannelMessage.rootId == rootId) { + newCChannelMessages.remove(cChannelMessage); + isChanged = true; + break; + } + } + } + + messageChunk.removeChunk(chunk); + + if (newCChannelMessages.isNotEmpty) { + messageChunk.add(Chunk( + oldestTs: newCChannelMessages.first.createdAt, + latestTs: newCChannelMessages.last.createdAt, + )); + } + } + } + + if (isChanged) { + await upsertMessageChunk(messageChunk); + } + } + } + + Future getMessageChunkCount() async { + return await _isar.cMessageChunks.count(); + } + + // ChannelChangeLogInfo + Future upsertChannelInfo(ChannelInfo info) async { + await CChannelInfo.upsert(_chat, _isar, info); + } + + Future getChannelInfo() async { + return await CChannelInfo.get(_chat, _isar); + } + + Future deleteChannelInfo() async { + await CChannelInfo.delete(_chat, _isar); + } + + Future getChannelInfoCount() async { + return await _isar.cChannelInfos.count(); + } + + // MessageChangeLogInfo + Future upsertMessageChangeLogInfo(MessageChangeLogInfo info) async { + await CMessageChangeLogInfo.upsert(_chat, _isar, info); + } + + Future getMessageChangeLogInfo( + String channelUrl) async { + return await CMessageChangeLogInfo.get(_chat, _isar, channelUrl); + } + + Future deleteMessageChangeLogInfo(String channelUrl) async { + await CMessageChangeLogInfo.delete(_chat, _isar, channelUrl); + } + + Future getMessageChangeLogInfoCount() async { + return await _isar.cMessageChangeLogInfos.count(); + } + + // ChannelAccess + Future upsertChannelAccess(ChannelAccess channelAccess) async { + await CChannelAccess.upsert(_chat, _isar, channelAccess); + } + + Future> getOrderedChannelUrlsToDelete() async { + final channelUrls = + (await _isar.cChannelAccess.where().sortByLastAccessedAt().findAll()) + .map((cChannelAccess) => cChannelAccess.channelUrl) + .toList(); + return channelUrls; + } + + Future deleteChannelAccess(String channelUrl) async { + await CChannelAccess.delete(_chat, _isar, channelUrl); + } + + Future getChannelAccessCount() async { + return await _isar.cChannelAccess.count(); + } + + // GroupChannel + Future upsertGroupChannel(GroupChannel channel) async { + await CGroupChannel.upsert(_chat, _isar, channel); + } + + Future getGroupChannel(String channelUrl) async { + return await CGroupChannel.get(_chat, _isar, channelUrl); + } + + Future> getGroupChannels( + GroupChannelListQuery query, int? offset) async { + return await CGroupChannel.getChannels(_chat, _isar, query, offset); + } + + Future deleteGroupChannel(String channelUrl) async { + await CGroupChannel.delete(_chat, _isar, channelUrl); + } + + Future getGroupChannelCount() async { + return await _isar.cGroupChannels.count(); + } + + // FeedChannel + Future upsertFeedChannel(FeedChannel channel) async { + await CFeedChannel.upsert(_chat, _isar, channel); + } + + Future getFeedChannel(String channelUrl) async { + return await CFeedChannel.get(_chat, _isar, channelUrl); + } + + Future> getFeedChannels( + FeedChannelListQuery query, int? offset) async { + return await CFeedChannel.getChannels(_chat, _isar, query, offset); + } + + Future deleteFeedChannel(String channelUrl) async { + await CFeedChannel.delete(_chat, _isar, channelUrl); + } + + Future getFeedChannelCount() async { + return await _isar.cFeedChannels.count(); + } + + // ChannelMessage + Future hasMessages(String channelUrl) async { + return await CChannelMessage.hasMessages(_chat, _isar, channelUrl); + } + + Future getChannelMessage(String rootId) async { + return await CChannelMessage.get(_chat, _isar, rootId); + } + + Future> getMessages( + ChannelType channelType, + String channelUrl, + SendingStatus sendingStatus, + int timestamp, + MessageListParams params, + bool isPrevious, + ) async { + return await CChannelMessage.getMessages( + _chat, + _isar, + channelType, + channelUrl, + sendingStatus, + timestamp, + params, + isPrevious, + ); + } + + Future> getPendingMessages({ + required ChannelType channelType, + required String channelUrl, + }) async { + return await CChannelMessage.getPendingMessages( + _chat, + _isar, + channelType, + channelUrl, + ); + } + + Future> getFailedMessages({ + required ChannelType channelType, + required String channelUrl, + required bool reverse, + }) async { + return await CChannelMessage.getFailedMessages( + _chat, + _isar, + channelType, + channelUrl, + reverse, + ); + } + + Future removeFailedMessages({ + required ChannelType channelType, + required String channelUrl, + required List messages, + }) async { + await CChannelMessage.removeFailedMessages( + _chat, + _isar, + channelType, + channelUrl, + messages, + ); + } + + Future removeAllFailedMessages({ + required ChannelType channelType, + required String channelUrl, + }) async { + await CChannelMessage.removeAllFailedMessages( + _chat, + _isar, + channelType, + channelUrl, + ); + } + + Future removeAllPendingMessages({ + required ChannelType channelType, + required String channelUrl, + }) async { + await CChannelMessage.removeAllPendingMessages( + _chat, + _isar, + channelType, + channelUrl, + ); + } + + Future> getStartingPointMessages( + ChannelType channelType, + String channelUrl, + int timestamp, + ) async { + return await CChannelMessage.getStartingPointMessages( + _chat, _isar, channelType, channelUrl, timestamp); + } + + Future deleteChannelMessage(String rootId) async { + await CChannelMessage.delete(_chat, _isar, rootId); + } + + // Message + Future deleteMessages(String channelUrl) async { + // UserMessage + final cUserMessages = await _isar.cUserMessages + .where() + .channelUrlEqualTo(channelUrl) + .findAll(); + for (final cUserMessage in cUserMessages) { + await deleteUserMessage(cUserMessage.rootId); + } + + // FileMessage + final cFileMessages = await _isar.cFileMessages + .where() + .channelUrlEqualTo(channelUrl) + .findAll(); + for (final cFileMessage in cFileMessages) { + await deleteFileMessage(cFileMessage.rootId); + } + + // AdminMessage + final cAdminMessages = await _isar.cAdminMessages + .where() + .channelUrlEqualTo(channelUrl) + .findAll(); + for (final cAdminMessage in cAdminMessages) { + await deleteAdminMessage(cAdminMessage.rootId); + } + + // NotificationMessage + final cNotificationMessages = await _isar.cNotificationMessages + .where() + .channelUrlEqualTo(channelUrl) + .findAll(); + for (final cNotificationMessage in cNotificationMessages) { + await deleteNotificationMessage(cNotificationMessage.rootId); + } + } + + // UserMessage + Future upsertUserMessage(UserMessage message) async { + await CUserMessage.upsert(_chat, _isar, message); + } + + Future getUserMessage(String rootId) async { + return await CUserMessage.get(_chat, _isar, rootId); + } + + Future deleteUserMessage(String rootId) async { + await CUserMessage.delete(_chat, _isar, rootId); + } + + Future getUserMessageCount() async { + return await _isar.cUserMessages.count(); + } + + // FileMessage + Future upsertFileMessage(FileMessage message) async { + await CFileMessage.upsert(_chat, _isar, message); + } + + Future getFileMessage(String rootId) async { + return await CFileMessage.get(_chat, _isar, rootId); + } + + Future deleteFileMessage(String rootId) async { + await CFileMessage.delete(_chat, _isar, rootId); + } + + Future getFileMessageCount() async { + return await _isar.cFileMessages.count(); + } + + // AdminMessage + Future upsertAdminMessage(AdminMessage message) async { + await CAdminMessage.upsert(_chat, _isar, message); + } + + Future getAdminMessage(String rootId) async { + return await CAdminMessage.get(_chat, _isar, rootId); + } + + Future deleteAdminMessage(String rootId) async { + await CAdminMessage.delete(_chat, _isar, rootId); + } + + Future getAdminMessageCount() async { + return await _isar.cAdminMessages.count(); + } + + // NotificationMessage + Future upsertNotificationMessage(NotificationMessage message) async { + await CNotificationMessage.upsert(_chat, _isar, message); + } + + Future getNotificationMessage(String rootId) async { + return await CNotificationMessage.get(_chat, _isar, rootId); + } + + Future deleteNotificationMessage(String rootId) async { + await CNotificationMessage.delete(_chat, _isar, rootId); + } + + Future getNotificationMessageCount() async { + return await _isar.cNotificationMessages.count(); + } + + // User + Future upsertUser(User user) async { + await CUser.upsert(_chat, _isar, user); + } + + Future getUser(String userId) async { + return await CUser.get(_chat, _isar, userId); + } + + Future deleteUser(String userId) async { + await CUser.delete(_chat, _isar, userId); + } + + Future getUserCount() async { + return await _isar.cUsers.count(); + } +} diff --git a/lib/src/internal/db/schema/channel/c_base_channel.dart b/lib/src/internal/db/schema/channel/c_base_channel.dart new file mode 100644 index 00000000..bbe6a8b0 --- /dev/null +++ b/lib/src/internal/db/schema/channel/c_base_channel.dart @@ -0,0 +1,83 @@ +// Copyright (c) 2023 Sendbird, Inc. All rights reserved. + +import 'package:isar/isar.dart'; +import 'package:sendbird_chat_sdk/src/internal/main/chat/chat.dart'; +import 'package:sendbird_chat_sdk/src/public/core/channel/base_channel/base_channel.dart'; +import 'package:sendbird_chat_sdk/src/public/core/channel/feed_channel/feed_channel.dart'; +import 'package:sendbird_chat_sdk/src/public/main/define/enums.dart'; + +class CBaseChannel { + Id id = Isar.autoIncrement; + + @Index(unique: true, replace: true) + late String channelUrl; + + @Index(composite: [CompositeIndex('channelUrl')]) + @enumerated + late ChannelType channelType; + + late String name; + int? createdAt; + + String? coverUrl; + String? data; + String? customType; + bool? isFrozen; + bool? isEphemeral; + + // Internal + late bool fromCache; + late bool dirty; + + CBaseChannel(); + + factory CBaseChannel.fromBaseChannel(BaseChannel channel) { + return CBaseChannel()..setBaseChannel(channel); + } + + void setBaseChannel(BaseChannel channel) { + channelUrl = channel.channelUrl; + channelType = channel.channelType; + name = channel.name; + createdAt = channel.createdAt; + if (channel is! FeedChannel) { + coverUrl = channel.coverUrl; + data = channel.data; + customType = channel.customType; + isFrozen = channel.isFrozen; + isEphemeral = channel.isEphemeral; + } + fromCache = channel.fromCache; + dirty = channel.dirty; + } + + BaseChannel toBaseChannel(Chat chat, Isar isar) { + final baseChannel = BaseChannel( + channelUrl: channelUrl, + )..set(chat); + return setCBaseChannel(chat, isar, baseChannel, this); + } + + static BaseChannel setCBaseChannel( + Chat chat, + Isar isar, + BaseChannel baseChannel, + CBaseChannel cBaseChannel, + ) { + BaseChannel channel = baseChannel + ..name = cBaseChannel.name + ..createdAt = cBaseChannel.createdAt + ..fromCache = cBaseChannel.fromCache + ..dirty = cBaseChannel.dirty; + + if (baseChannel is! FeedChannel) { + channel + ..coverUrl = cBaseChannel.coverUrl + ..data = cBaseChannel.data + ..customType = cBaseChannel.customType + ..isFrozen = cBaseChannel.isFrozen + ..isEphemeral = cBaseChannel.isEphemeral; + } + return channel; + } +} diff --git a/lib/src/internal/db/schema/channel/c_feed_channel.dart b/lib/src/internal/db/schema/channel/c_feed_channel.dart new file mode 100644 index 00000000..62e863d9 --- /dev/null +++ b/lib/src/internal/db/schema/channel/c_feed_channel.dart @@ -0,0 +1,162 @@ +// Copyright (c) 2023 Sendbird, Inc. All rights reserved. + +import 'package:isar/isar.dart'; +import 'package:sendbird_chat_sdk/sendbird_chat_sdk.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/channel/c_base_channel.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/channel/c_group_channel.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/message/c_notification_message.dart'; +import 'package:sendbird_chat_sdk/src/internal/main/chat/chat.dart'; + +part 'c_feed_channel.g.dart'; + +@collection +class CFeedChannel extends CBaseChannel { + String? lastMessageRootId; // lastMessage + bool? isTemplateLabelEnabled; + bool? isCategoryFilterEnabled; + late List notificationCategories; + + CFeedChannel(); + + factory CFeedChannel.fromFeedChannel(FeedChannel channel) { + return CFeedChannel() + // BaseChannel + ..setBaseChannel(channel) + // FeedChannel + ..lastMessageRootId = channel.lastMessage?.rootId + ..isTemplateLabelEnabled = channel.isTemplateLabelEnabled + ..isCategoryFilterEnabled = channel.isCategoryFilterEnabled + ..notificationCategories = channel.notificationCategories + .map((category) => + CNotificationCategory.fromNotificationCategory(category)) + .toList(); + } + + Future toFeedChannel(Chat chat, Isar isar) async { + final groupChannel = await CGroupChannel.get(chat, isar, channelUrl); + if (groupChannel == null) { + return null; + } + + final feedChannel = FeedChannel(groupChannel: groupChannel)..set(chat); + + CBaseChannel.setCBaseChannel(chat, isar, feedChannel, this) as FeedChannel + // FeedChannel + ..lastMessage = lastMessageRootId != null + ? await CNotificationMessage.get(chat, isar, lastMessageRootId!) + : null + ..isTemplateLabelEnabled = isTemplateLabelEnabled + ..isCategoryFilterEnabled = isCategoryFilterEnabled + ..notificationCategories = notificationCategories + .map((category) => category.toNotificationCategory()) + .toList(); + + return feedChannel; + } + + static Future upsert( + Chat chat, Isar isar, FeedChannel channel) async { + final cFeedChannel = CFeedChannel.fromFeedChannel(channel); + final cGroupChannel = CGroupChannel.fromGroupChannel(channel.groupChannel) + ..channelType = ChannelType.feed; // Check + + // GroupChannel + await chat.dbManager.write(() async { + await isar.cGroupChannels.put(cGroupChannel); + }); + + // FeedChannel + await chat.dbManager.write(() async { + await isar.cFeedChannels.put(cFeedChannel); + }); + + // [lastMessage] There are many empty values from server. + // if (channel.lastMessage != null) { + // await CNotificationMessage.upsert(chat, isar, channel.lastMessage!); + // } + + return cFeedChannel; + } + + static Future get( + Chat chat, Isar isar, String channelUrl) async { + final cFeedChannel = await isar.cFeedChannels + .where() + .channelUrlEqualTo(channelUrl) + .findFirst(); + return await cFeedChannel?.toFeedChannel(chat, isar); + } + + static Future> getChannels( + Chat chat, + Isar isar, + FeedChannelListQuery query, + int? offset, + ) async { + final cFeedChannels = await isar.cFeedChannels + .where() + .filter() + + // includeEmpty + .optional(query.includeEmpty == false, (q) { + return q.lastMessageRootIdIsNotNull(); + }) + + // sort + .optional(true, (q) { + return q.sortByCreatedAt(); + }) + + // offset + .optional(offset != null, (q) { + return q.offset(offset!); + }) + + // limit + .limit(query.limit) + .findAll(); + + List channels = []; + for (final cFeedChannel in cFeedChannels) { + final channel = await cFeedChannel.toFeedChannel(chat, isar); + if (channel != null) { + channels.add(channel); + } + } + return channels; + } + + static Future delete(Chat chat, Isar isar, String channelUrl) async { + await chat.dbManager.write(() async { + await isar.cFeedChannels.deleteByChannelUrl(channelUrl); + }); + } +} + +@embedded +class CNotificationCategory { + late int id; + late String customType; + late String name; + late bool isDefault; + + CNotificationCategory(); + + factory CNotificationCategory.fromNotificationCategory( + NotificationCategory category) { + return CNotificationCategory() + ..id = category.id + ..customType = category.customType + ..name = category.name + ..isDefault = category.isDefault; + } + + NotificationCategory toNotificationCategory() { + return NotificationCategory( + id: id, + customType: customType, + name: name, + isDefault: isDefault, + ); + } +} diff --git a/lib/src/internal/db/schema/channel/c_feed_channel.g.dart b/lib/src/internal/db/schema/channel/c_feed_channel.g.dart new file mode 100644 index 00000000..ca657aea --- /dev/null +++ b/lib/src/internal/db/schema/channel/c_feed_channel.g.dart @@ -0,0 +1,2961 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'c_feed_channel.dart'; + +// ************************************************************************** +// IsarCollectionGenerator +// ************************************************************************** + +// coverage:ignore-file +// ignore_for_file: duplicate_ignore, non_constant_identifier_names, constant_identifier_names, invalid_use_of_protected_member, unnecessary_cast, prefer_const_constructors, lines_longer_than_80_chars, require_trailing_commas, inference_failure_on_function_invocation, unnecessary_parenthesis, unnecessary_raw_strings, unnecessary_null_checks, join_return_with_assignment, prefer_final_locals, avoid_js_rounded_ints, avoid_positional_boolean_parameters, always_specify_types + +extension GetCFeedChannelCollection on Isar { + IsarCollection get cFeedChannels => this.collection(); +} + +final CFeedChannelSchema = CollectionSchema( + name: r'CFeedChannel', + id: BigInt.parse('8060769429537757837').toInt(), + properties: { + r'channelType': PropertySchema( + id: 0, + name: r'channelType', + type: IsarType.byte, + enumMap: _CFeedChannelchannelTypeEnumValueMap, + ), + r'channelUrl': PropertySchema( + id: 1, + name: r'channelUrl', + type: IsarType.string, + ), + r'coverUrl': PropertySchema( + id: 2, + name: r'coverUrl', + type: IsarType.string, + ), + r'createdAt': PropertySchema( + id: 3, + name: r'createdAt', + type: IsarType.long, + ), + r'customType': PropertySchema( + id: 4, + name: r'customType', + type: IsarType.string, + ), + r'data': PropertySchema( + id: 5, + name: r'data', + type: IsarType.string, + ), + r'dirty': PropertySchema( + id: 6, + name: r'dirty', + type: IsarType.bool, + ), + r'fromCache': PropertySchema( + id: 7, + name: r'fromCache', + type: IsarType.bool, + ), + r'isCategoryFilterEnabled': PropertySchema( + id: 8, + name: r'isCategoryFilterEnabled', + type: IsarType.bool, + ), + r'isEphemeral': PropertySchema( + id: 9, + name: r'isEphemeral', + type: IsarType.bool, + ), + r'isFrozen': PropertySchema( + id: 10, + name: r'isFrozen', + type: IsarType.bool, + ), + r'isTemplateLabelEnabled': PropertySchema( + id: 11, + name: r'isTemplateLabelEnabled', + type: IsarType.bool, + ), + r'lastMessageRootId': PropertySchema( + id: 12, + name: r'lastMessageRootId', + type: IsarType.string, + ), + r'name': PropertySchema( + id: 13, + name: r'name', + type: IsarType.string, + ), + r'notificationCategories': PropertySchema( + id: 14, + name: r'notificationCategories', + type: IsarType.objectList, + target: r'CNotificationCategory', + ) + }, + estimateSize: _cFeedChannelEstimateSize, + serialize: _cFeedChannelSerialize, + deserialize: _cFeedChannelDeserialize, + deserializeProp: _cFeedChannelDeserializeProp, + idName: r'id', + indexes: { + r'channelUrl': IndexSchema( + id: BigInt.parse('6636052684858767397').toInt(), + name: r'channelUrl', + unique: true, + replace: true, + properties: [ + IndexPropertySchema( + name: r'channelUrl', + type: IndexType.hash, + caseSensitive: true, + ) + ], + ), + r'channelType_channelUrl': IndexSchema( + id: BigInt.parse('-5957547153902522682').toInt(), + name: r'channelType_channelUrl', + unique: false, + replace: false, + properties: [ + IndexPropertySchema( + name: r'channelType', + type: IndexType.value, + caseSensitive: false, + ), + IndexPropertySchema( + name: r'channelUrl', + type: IndexType.hash, + caseSensitive: true, + ) + ], + ) + }, + links: {}, + embeddedSchemas: {r'CNotificationCategory': CNotificationCategorySchema}, + getId: _cFeedChannelGetId, + getLinks: _cFeedChannelGetLinks, + attach: _cFeedChannelAttach, + version: '3.1.0+1', +); + +int _cFeedChannelEstimateSize( + CFeedChannel object, + List offsets, + Map> allOffsets, +) { + var bytesCount = offsets.last; + bytesCount += 3 + object.channelUrl.length * 3; + { + final value = object.coverUrl; + if (value != null) { + bytesCount += 3 + value.length * 3; + } + } + { + final value = object.customType; + if (value != null) { + bytesCount += 3 + value.length * 3; + } + } + { + final value = object.data; + if (value != null) { + bytesCount += 3 + value.length * 3; + } + } + { + final value = object.lastMessageRootId; + if (value != null) { + bytesCount += 3 + value.length * 3; + } + } + bytesCount += 3 + object.name.length * 3; + bytesCount += 3 + object.notificationCategories.length * 3; + { + final offsets = allOffsets[CNotificationCategory]!; + for (var i = 0; i < object.notificationCategories.length; i++) { + final value = object.notificationCategories[i]; + bytesCount += + CNotificationCategorySchema.estimateSize(value, offsets, allOffsets); + } + } + return bytesCount; +} + +void _cFeedChannelSerialize( + CFeedChannel object, + IsarWriter writer, + List offsets, + Map> allOffsets, +) { + writer.writeByte(offsets[0], object.channelType.index); + writer.writeString(offsets[1], object.channelUrl); + writer.writeString(offsets[2], object.coverUrl); + writer.writeLong(offsets[3], object.createdAt); + writer.writeString(offsets[4], object.customType); + writer.writeString(offsets[5], object.data); + writer.writeBool(offsets[6], object.dirty); + writer.writeBool(offsets[7], object.fromCache); + writer.writeBool(offsets[8], object.isCategoryFilterEnabled); + writer.writeBool(offsets[9], object.isEphemeral); + writer.writeBool(offsets[10], object.isFrozen); + writer.writeBool(offsets[11], object.isTemplateLabelEnabled); + writer.writeString(offsets[12], object.lastMessageRootId); + writer.writeString(offsets[13], object.name); + writer.writeObjectList( + offsets[14], + allOffsets, + CNotificationCategorySchema.serialize, + object.notificationCategories, + ); +} + +CFeedChannel _cFeedChannelDeserialize( + Id id, + IsarReader reader, + List offsets, + Map> allOffsets, +) { + final object = CFeedChannel(); + object.channelType = + _CFeedChannelchannelTypeValueEnumMap[reader.readByteOrNull(offsets[0])] ?? + ChannelType.group; + object.channelUrl = reader.readString(offsets[1]); + object.coverUrl = reader.readStringOrNull(offsets[2]); + object.createdAt = reader.readLongOrNull(offsets[3]); + object.customType = reader.readStringOrNull(offsets[4]); + object.data = reader.readStringOrNull(offsets[5]); + object.dirty = reader.readBool(offsets[6]); + object.fromCache = reader.readBool(offsets[7]); + object.id = id; + object.isCategoryFilterEnabled = reader.readBoolOrNull(offsets[8]); + object.isEphemeral = reader.readBoolOrNull(offsets[9]); + object.isFrozen = reader.readBoolOrNull(offsets[10]); + object.isTemplateLabelEnabled = reader.readBoolOrNull(offsets[11]); + object.lastMessageRootId = reader.readStringOrNull(offsets[12]); + object.name = reader.readString(offsets[13]); + object.notificationCategories = reader.readObjectList( + offsets[14], + CNotificationCategorySchema.deserialize, + allOffsets, + CNotificationCategory(), + ) ?? + []; + return object; +} + +P _cFeedChannelDeserializeProp

( + IsarReader reader, + int propertyId, + int offset, + Map> allOffsets, +) { + switch (propertyId) { + case 0: + return (_CFeedChannelchannelTypeValueEnumMap[ + reader.readByteOrNull(offset)] ?? + ChannelType.group) as P; + case 1: + return (reader.readString(offset)) as P; + case 2: + return (reader.readStringOrNull(offset)) as P; + case 3: + return (reader.readLongOrNull(offset)) as P; + case 4: + return (reader.readStringOrNull(offset)) as P; + case 5: + return (reader.readStringOrNull(offset)) as P; + case 6: + return (reader.readBool(offset)) as P; + case 7: + return (reader.readBool(offset)) as P; + case 8: + return (reader.readBoolOrNull(offset)) as P; + case 9: + return (reader.readBoolOrNull(offset)) as P; + case 10: + return (reader.readBoolOrNull(offset)) as P; + case 11: + return (reader.readBoolOrNull(offset)) as P; + case 12: + return (reader.readStringOrNull(offset)) as P; + case 13: + return (reader.readString(offset)) as P; + case 14: + return (reader.readObjectList( + offset, + CNotificationCategorySchema.deserialize, + allOffsets, + CNotificationCategory(), + ) ?? + []) as P; + default: + throw IsarError('Unknown property with id $propertyId'); + } +} + +const _CFeedChannelchannelTypeEnumValueMap = { + 'group': 0, + 'open': 1, + 'feed': 2, +}; +const _CFeedChannelchannelTypeValueEnumMap = { + 0: ChannelType.group, + 1: ChannelType.open, + 2: ChannelType.feed, +}; + +Id _cFeedChannelGetId(CFeedChannel object) { + return object.id; +} + +List> _cFeedChannelGetLinks(CFeedChannel object) { + return []; +} + +void _cFeedChannelAttach( + IsarCollection col, Id id, CFeedChannel object) { + object.id = id; +} + +extension CFeedChannelByIndex on IsarCollection { + Future getByChannelUrl(String channelUrl) { + return getByIndex(r'channelUrl', [channelUrl]); + } + + CFeedChannel? getByChannelUrlSync(String channelUrl) { + return getByIndexSync(r'channelUrl', [channelUrl]); + } + + Future deleteByChannelUrl(String channelUrl) { + return deleteByIndex(r'channelUrl', [channelUrl]); + } + + bool deleteByChannelUrlSync(String channelUrl) { + return deleteByIndexSync(r'channelUrl', [channelUrl]); + } + + Future> getAllByChannelUrl( + List channelUrlValues) { + final values = channelUrlValues.map((e) => [e]).toList(); + return getAllByIndex(r'channelUrl', values); + } + + List getAllByChannelUrlSync(List channelUrlValues) { + final values = channelUrlValues.map((e) => [e]).toList(); + return getAllByIndexSync(r'channelUrl', values); + } + + Future deleteAllByChannelUrl(List channelUrlValues) { + final values = channelUrlValues.map((e) => [e]).toList(); + return deleteAllByIndex(r'channelUrl', values); + } + + int deleteAllByChannelUrlSync(List channelUrlValues) { + final values = channelUrlValues.map((e) => [e]).toList(); + return deleteAllByIndexSync(r'channelUrl', values); + } + + Future putByChannelUrl(CFeedChannel object) { + return putByIndex(r'channelUrl', object); + } + + Id putByChannelUrlSync(CFeedChannel object, {bool saveLinks = true}) { + return putByIndexSync(r'channelUrl', object, saveLinks: saveLinks); + } + + Future> putAllByChannelUrl(List objects) { + return putAllByIndex(r'channelUrl', objects); + } + + List putAllByChannelUrlSync(List objects, + {bool saveLinks = true}) { + return putAllByIndexSync(r'channelUrl', objects, saveLinks: saveLinks); + } +} + +extension CFeedChannelQueryWhereSort + on QueryBuilder { + QueryBuilder anyId() { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(const IdWhereClause.any()); + }); + } +} + +extension CFeedChannelQueryWhere + on QueryBuilder { + QueryBuilder idEqualTo(Id id) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IdWhereClause.between( + lower: id, + upper: id, + )); + }); + } + + QueryBuilder idNotEqualTo( + Id id) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause( + IdWhereClause.lessThan(upper: id, includeUpper: false), + ) + .addWhereClause( + IdWhereClause.greaterThan(lower: id, includeLower: false), + ); + } else { + return query + .addWhereClause( + IdWhereClause.greaterThan(lower: id, includeLower: false), + ) + .addWhereClause( + IdWhereClause.lessThan(upper: id, includeUpper: false), + ); + } + }); + } + + QueryBuilder idGreaterThan( + Id id, + {bool include = false}) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause( + IdWhereClause.greaterThan(lower: id, includeLower: include), + ); + }); + } + + QueryBuilder idLessThan(Id id, + {bool include = false}) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause( + IdWhereClause.lessThan(upper: id, includeUpper: include), + ); + }); + } + + QueryBuilder idBetween( + Id lowerId, + Id upperId, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IdWhereClause.between( + lower: lowerId, + includeLower: includeLower, + upper: upperId, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder channelUrlEqualTo( + String channelUrl) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.equalTo( + indexName: r'channelUrl', + value: [channelUrl], + )); + }); + } + + QueryBuilder + channelUrlNotEqualTo(String channelUrl) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'channelUrl', + lower: [], + upper: [channelUrl], + includeUpper: false, + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'channelUrl', + lower: [channelUrl], + includeLower: false, + upper: [], + )); + } else { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'channelUrl', + lower: [channelUrl], + includeLower: false, + upper: [], + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'channelUrl', + lower: [], + upper: [channelUrl], + includeUpper: false, + )); + } + }); + } + + QueryBuilder + channelTypeEqualToAnyChannelUrl(ChannelType channelType) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.equalTo( + indexName: r'channelType_channelUrl', + value: [channelType], + )); + }); + } + + QueryBuilder + channelTypeNotEqualToAnyChannelUrl(ChannelType channelType) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'channelType_channelUrl', + lower: [], + upper: [channelType], + includeUpper: false, + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'channelType_channelUrl', + lower: [channelType], + includeLower: false, + upper: [], + )); + } else { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'channelType_channelUrl', + lower: [channelType], + includeLower: false, + upper: [], + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'channelType_channelUrl', + lower: [], + upper: [channelType], + includeUpper: false, + )); + } + }); + } + + QueryBuilder + channelTypeGreaterThanAnyChannelUrl( + ChannelType channelType, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.between( + indexName: r'channelType_channelUrl', + lower: [channelType], + includeLower: include, + upper: [], + )); + }); + } + + QueryBuilder + channelTypeLessThanAnyChannelUrl( + ChannelType channelType, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.between( + indexName: r'channelType_channelUrl', + lower: [], + upper: [channelType], + includeUpper: include, + )); + }); + } + + QueryBuilder + channelTypeBetweenAnyChannelUrl( + ChannelType lowerChannelType, + ChannelType upperChannelType, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.between( + indexName: r'channelType_channelUrl', + lower: [lowerChannelType], + includeLower: includeLower, + upper: [upperChannelType], + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + channelTypeChannelUrlEqualTo(ChannelType channelType, String channelUrl) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.equalTo( + indexName: r'channelType_channelUrl', + value: [channelType, channelUrl], + )); + }); + } + + QueryBuilder + channelTypeEqualToChannelUrlNotEqualTo( + ChannelType channelType, String channelUrl) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'channelType_channelUrl', + lower: [channelType], + upper: [channelType, channelUrl], + includeUpper: false, + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'channelType_channelUrl', + lower: [channelType, channelUrl], + includeLower: false, + upper: [channelType], + )); + } else { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'channelType_channelUrl', + lower: [channelType, channelUrl], + includeLower: false, + upper: [channelType], + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'channelType_channelUrl', + lower: [channelType], + upper: [channelType, channelUrl], + includeUpper: false, + )); + } + }); + } +} + +extension CFeedChannelQueryFilter + on QueryBuilder { + QueryBuilder + channelTypeEqualTo(ChannelType value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'channelType', + value: value, + )); + }); + } + + QueryBuilder + channelTypeGreaterThan( + ChannelType value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'channelType', + value: value, + )); + }); + } + + QueryBuilder + channelTypeLessThan( + ChannelType value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'channelType', + value: value, + )); + }); + } + + QueryBuilder + channelTypeBetween( + ChannelType lower, + ChannelType upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'channelType', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + channelUrlEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'channelUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + channelUrlGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'channelUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + channelUrlLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'channelUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + channelUrlBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'channelUrl', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + channelUrlStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'channelUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + channelUrlEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'channelUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + channelUrlContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'channelUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + channelUrlMatches(String pattern, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'channelUrl', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + channelUrlIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'channelUrl', + value: '', + )); + }); + } + + QueryBuilder + channelUrlIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'channelUrl', + value: '', + )); + }); + } + + QueryBuilder + coverUrlIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'coverUrl', + )); + }); + } + + QueryBuilder + coverUrlIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'coverUrl', + )); + }); + } + + QueryBuilder + coverUrlEqualTo( + String? value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'coverUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + coverUrlGreaterThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'coverUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + coverUrlLessThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'coverUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + coverUrlBetween( + String? lower, + String? upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'coverUrl', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + coverUrlStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'coverUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + coverUrlEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'coverUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + coverUrlContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'coverUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + coverUrlMatches(String pattern, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'coverUrl', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + coverUrlIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'coverUrl', + value: '', + )); + }); + } + + QueryBuilder + coverUrlIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'coverUrl', + value: '', + )); + }); + } + + QueryBuilder + createdAtIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'createdAt', + )); + }); + } + + QueryBuilder + createdAtIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'createdAt', + )); + }); + } + + QueryBuilder + createdAtEqualTo(int? value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'createdAt', + value: value, + )); + }); + } + + QueryBuilder + createdAtGreaterThan( + int? value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'createdAt', + value: value, + )); + }); + } + + QueryBuilder + createdAtLessThan( + int? value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'createdAt', + value: value, + )); + }); + } + + QueryBuilder + createdAtBetween( + int? lower, + int? upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'createdAt', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + customTypeIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'customType', + )); + }); + } + + QueryBuilder + customTypeIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'customType', + )); + }); + } + + QueryBuilder + customTypeEqualTo( + String? value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'customType', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + customTypeGreaterThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'customType', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + customTypeLessThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'customType', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + customTypeBetween( + String? lower, + String? upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'customType', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + customTypeStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'customType', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + customTypeEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'customType', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + customTypeContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'customType', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + customTypeMatches(String pattern, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'customType', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + customTypeIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'customType', + value: '', + )); + }); + } + + QueryBuilder + customTypeIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'customType', + value: '', + )); + }); + } + + QueryBuilder dataIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'data', + )); + }); + } + + QueryBuilder + dataIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'data', + )); + }); + } + + QueryBuilder dataEqualTo( + String? value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'data', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + dataGreaterThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'data', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder dataLessThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'data', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder dataBetween( + String? lower, + String? upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'data', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + dataStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'data', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder dataEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'data', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder dataContains( + String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'data', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder dataMatches( + String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'data', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + dataIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'data', + value: '', + )); + }); + } + + QueryBuilder + dataIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'data', + value: '', + )); + }); + } + + QueryBuilder dirtyEqualTo( + bool value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'dirty', + value: value, + )); + }); + } + + QueryBuilder + fromCacheEqualTo(bool value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'fromCache', + value: value, + )); + }); + } + + QueryBuilder idEqualTo( + Id value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'id', + value: value, + )); + }); + } + + QueryBuilder idGreaterThan( + Id value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'id', + value: value, + )); + }); + } + + QueryBuilder idLessThan( + Id value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'id', + value: value, + )); + }); + } + + QueryBuilder idBetween( + Id lower, + Id upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'id', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + isCategoryFilterEnabledIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'isCategoryFilterEnabled', + )); + }); + } + + QueryBuilder + isCategoryFilterEnabledIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'isCategoryFilterEnabled', + )); + }); + } + + QueryBuilder + isCategoryFilterEnabledEqualTo(bool? value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'isCategoryFilterEnabled', + value: value, + )); + }); + } + + QueryBuilder + isEphemeralIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'isEphemeral', + )); + }); + } + + QueryBuilder + isEphemeralIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'isEphemeral', + )); + }); + } + + QueryBuilder + isEphemeralEqualTo(bool? value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'isEphemeral', + value: value, + )); + }); + } + + QueryBuilder + isFrozenIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'isFrozen', + )); + }); + } + + QueryBuilder + isFrozenIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'isFrozen', + )); + }); + } + + QueryBuilder + isFrozenEqualTo(bool? value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'isFrozen', + value: value, + )); + }); + } + + QueryBuilder + isTemplateLabelEnabledIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'isTemplateLabelEnabled', + )); + }); + } + + QueryBuilder + isTemplateLabelEnabledIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'isTemplateLabelEnabled', + )); + }); + } + + QueryBuilder + isTemplateLabelEnabledEqualTo(bool? value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'isTemplateLabelEnabled', + value: value, + )); + }); + } + + QueryBuilder + lastMessageRootIdIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'lastMessageRootId', + )); + }); + } + + QueryBuilder + lastMessageRootIdIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'lastMessageRootId', + )); + }); + } + + QueryBuilder + lastMessageRootIdEqualTo( + String? value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'lastMessageRootId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + lastMessageRootIdGreaterThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'lastMessageRootId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + lastMessageRootIdLessThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'lastMessageRootId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + lastMessageRootIdBetween( + String? lower, + String? upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'lastMessageRootId', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + lastMessageRootIdStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'lastMessageRootId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + lastMessageRootIdEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'lastMessageRootId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + lastMessageRootIdContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'lastMessageRootId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + lastMessageRootIdMatches(String pattern, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'lastMessageRootId', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + lastMessageRootIdIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'lastMessageRootId', + value: '', + )); + }); + } + + QueryBuilder + lastMessageRootIdIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'lastMessageRootId', + value: '', + )); + }); + } + + QueryBuilder nameEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'name', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + nameGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'name', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder nameLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'name', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder nameBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'name', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + nameStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'name', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder nameEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'name', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder nameContains( + String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'name', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder nameMatches( + String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'name', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + nameIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'name', + value: '', + )); + }); + } + + QueryBuilder + nameIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'name', + value: '', + )); + }); + } + + QueryBuilder + notificationCategoriesLengthEqualTo(int length) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'notificationCategories', + length, + true, + length, + true, + ); + }); + } + + QueryBuilder + notificationCategoriesIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'notificationCategories', + 0, + true, + 0, + true, + ); + }); + } + + QueryBuilder + notificationCategoriesIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'notificationCategories', + 0, + false, + 999999, + true, + ); + }); + } + + QueryBuilder + notificationCategoriesLengthLessThan( + int length, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'notificationCategories', + 0, + true, + length, + include, + ); + }); + } + + QueryBuilder + notificationCategoriesLengthGreaterThan( + int length, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'notificationCategories', + length, + include, + 999999, + true, + ); + }); + } + + QueryBuilder + notificationCategoriesLengthBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'notificationCategories', + lower, + includeLower, + upper, + includeUpper, + ); + }); + } +} + +extension CFeedChannelQueryObject + on QueryBuilder { + QueryBuilder + notificationCategoriesElement(FilterQuery q) { + return QueryBuilder.apply(this, (query) { + return query.object(q, r'notificationCategories'); + }); + } +} + +extension CFeedChannelQueryLinks + on QueryBuilder {} + +extension CFeedChannelQuerySortBy + on QueryBuilder { + QueryBuilder sortByChannelType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'channelType', Sort.asc); + }); + } + + QueryBuilder + sortByChannelTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'channelType', Sort.desc); + }); + } + + QueryBuilder sortByChannelUrl() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'channelUrl', Sort.asc); + }); + } + + QueryBuilder + sortByChannelUrlDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'channelUrl', Sort.desc); + }); + } + + QueryBuilder sortByCoverUrl() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'coverUrl', Sort.asc); + }); + } + + QueryBuilder sortByCoverUrlDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'coverUrl', Sort.desc); + }); + } + + QueryBuilder sortByCreatedAt() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'createdAt', Sort.asc); + }); + } + + QueryBuilder sortByCreatedAtDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'createdAt', Sort.desc); + }); + } + + QueryBuilder sortByCustomType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'customType', Sort.asc); + }); + } + + QueryBuilder + sortByCustomTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'customType', Sort.desc); + }); + } + + QueryBuilder sortByData() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'data', Sort.asc); + }); + } + + QueryBuilder sortByDataDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'data', Sort.desc); + }); + } + + QueryBuilder sortByDirty() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'dirty', Sort.asc); + }); + } + + QueryBuilder sortByDirtyDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'dirty', Sort.desc); + }); + } + + QueryBuilder sortByFromCache() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'fromCache', Sort.asc); + }); + } + + QueryBuilder sortByFromCacheDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'fromCache', Sort.desc); + }); + } + + QueryBuilder + sortByIsCategoryFilterEnabled() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isCategoryFilterEnabled', Sort.asc); + }); + } + + QueryBuilder + sortByIsCategoryFilterEnabledDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isCategoryFilterEnabled', Sort.desc); + }); + } + + QueryBuilder sortByIsEphemeral() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isEphemeral', Sort.asc); + }); + } + + QueryBuilder + sortByIsEphemeralDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isEphemeral', Sort.desc); + }); + } + + QueryBuilder sortByIsFrozen() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isFrozen', Sort.asc); + }); + } + + QueryBuilder sortByIsFrozenDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isFrozen', Sort.desc); + }); + } + + QueryBuilder + sortByIsTemplateLabelEnabled() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isTemplateLabelEnabled', Sort.asc); + }); + } + + QueryBuilder + sortByIsTemplateLabelEnabledDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isTemplateLabelEnabled', Sort.desc); + }); + } + + QueryBuilder + sortByLastMessageRootId() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'lastMessageRootId', Sort.asc); + }); + } + + QueryBuilder + sortByLastMessageRootIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'lastMessageRootId', Sort.desc); + }); + } + + QueryBuilder sortByName() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'name', Sort.asc); + }); + } + + QueryBuilder sortByNameDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'name', Sort.desc); + }); + } +} + +extension CFeedChannelQuerySortThenBy + on QueryBuilder { + QueryBuilder thenByChannelType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'channelType', Sort.asc); + }); + } + + QueryBuilder + thenByChannelTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'channelType', Sort.desc); + }); + } + + QueryBuilder thenByChannelUrl() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'channelUrl', Sort.asc); + }); + } + + QueryBuilder + thenByChannelUrlDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'channelUrl', Sort.desc); + }); + } + + QueryBuilder thenByCoverUrl() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'coverUrl', Sort.asc); + }); + } + + QueryBuilder thenByCoverUrlDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'coverUrl', Sort.desc); + }); + } + + QueryBuilder thenByCreatedAt() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'createdAt', Sort.asc); + }); + } + + QueryBuilder thenByCreatedAtDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'createdAt', Sort.desc); + }); + } + + QueryBuilder thenByCustomType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'customType', Sort.asc); + }); + } + + QueryBuilder + thenByCustomTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'customType', Sort.desc); + }); + } + + QueryBuilder thenByData() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'data', Sort.asc); + }); + } + + QueryBuilder thenByDataDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'data', Sort.desc); + }); + } + + QueryBuilder thenByDirty() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'dirty', Sort.asc); + }); + } + + QueryBuilder thenByDirtyDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'dirty', Sort.desc); + }); + } + + QueryBuilder thenByFromCache() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'fromCache', Sort.asc); + }); + } + + QueryBuilder thenByFromCacheDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'fromCache', Sort.desc); + }); + } + + QueryBuilder thenById() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'id', Sort.asc); + }); + } + + QueryBuilder thenByIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'id', Sort.desc); + }); + } + + QueryBuilder + thenByIsCategoryFilterEnabled() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isCategoryFilterEnabled', Sort.asc); + }); + } + + QueryBuilder + thenByIsCategoryFilterEnabledDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isCategoryFilterEnabled', Sort.desc); + }); + } + + QueryBuilder thenByIsEphemeral() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isEphemeral', Sort.asc); + }); + } + + QueryBuilder + thenByIsEphemeralDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isEphemeral', Sort.desc); + }); + } + + QueryBuilder thenByIsFrozen() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isFrozen', Sort.asc); + }); + } + + QueryBuilder thenByIsFrozenDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isFrozen', Sort.desc); + }); + } + + QueryBuilder + thenByIsTemplateLabelEnabled() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isTemplateLabelEnabled', Sort.asc); + }); + } + + QueryBuilder + thenByIsTemplateLabelEnabledDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isTemplateLabelEnabled', Sort.desc); + }); + } + + QueryBuilder + thenByLastMessageRootId() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'lastMessageRootId', Sort.asc); + }); + } + + QueryBuilder + thenByLastMessageRootIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'lastMessageRootId', Sort.desc); + }); + } + + QueryBuilder thenByName() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'name', Sort.asc); + }); + } + + QueryBuilder thenByNameDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'name', Sort.desc); + }); + } +} + +extension CFeedChannelQueryWhereDistinct + on QueryBuilder { + QueryBuilder distinctByChannelType() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'channelType'); + }); + } + + QueryBuilder distinctByChannelUrl( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'channelUrl', caseSensitive: caseSensitive); + }); + } + + QueryBuilder distinctByCoverUrl( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'coverUrl', caseSensitive: caseSensitive); + }); + } + + QueryBuilder distinctByCreatedAt() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'createdAt'); + }); + } + + QueryBuilder distinctByCustomType( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'customType', caseSensitive: caseSensitive); + }); + } + + QueryBuilder distinctByData( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'data', caseSensitive: caseSensitive); + }); + } + + QueryBuilder distinctByDirty() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'dirty'); + }); + } + + QueryBuilder distinctByFromCache() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'fromCache'); + }); + } + + QueryBuilder + distinctByIsCategoryFilterEnabled() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'isCategoryFilterEnabled'); + }); + } + + QueryBuilder distinctByIsEphemeral() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'isEphemeral'); + }); + } + + QueryBuilder distinctByIsFrozen() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'isFrozen'); + }); + } + + QueryBuilder + distinctByIsTemplateLabelEnabled() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'isTemplateLabelEnabled'); + }); + } + + QueryBuilder + distinctByLastMessageRootId({bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'lastMessageRootId', + caseSensitive: caseSensitive); + }); + } + + QueryBuilder distinctByName( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'name', caseSensitive: caseSensitive); + }); + } +} + +extension CFeedChannelQueryProperty + on QueryBuilder { + QueryBuilder idProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'id'); + }); + } + + QueryBuilder + channelTypeProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'channelType'); + }); + } + + QueryBuilder channelUrlProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'channelUrl'); + }); + } + + QueryBuilder coverUrlProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'coverUrl'); + }); + } + + QueryBuilder createdAtProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'createdAt'); + }); + } + + QueryBuilder customTypeProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'customType'); + }); + } + + QueryBuilder dataProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'data'); + }); + } + + QueryBuilder dirtyProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'dirty'); + }); + } + + QueryBuilder fromCacheProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'fromCache'); + }); + } + + QueryBuilder + isCategoryFilterEnabledProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'isCategoryFilterEnabled'); + }); + } + + QueryBuilder isEphemeralProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'isEphemeral'); + }); + } + + QueryBuilder isFrozenProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'isFrozen'); + }); + } + + QueryBuilder + isTemplateLabelEnabledProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'isTemplateLabelEnabled'); + }); + } + + QueryBuilder + lastMessageRootIdProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'lastMessageRootId'); + }); + } + + QueryBuilder nameProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'name'); + }); + } + + QueryBuilder, QQueryOperations> + notificationCategoriesProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'notificationCategories'); + }); + } +} + +// ************************************************************************** +// IsarEmbeddedGenerator +// ************************************************************************** + +// coverage:ignore-file +// ignore_for_file: duplicate_ignore, non_constant_identifier_names, constant_identifier_names, invalid_use_of_protected_member, unnecessary_cast, prefer_const_constructors, lines_longer_than_80_chars, require_trailing_commas, inference_failure_on_function_invocation, unnecessary_parenthesis, unnecessary_raw_strings, unnecessary_null_checks, join_return_with_assignment, prefer_final_locals, avoid_js_rounded_ints, avoid_positional_boolean_parameters, always_specify_types + +final CNotificationCategorySchema = Schema( + name: r'CNotificationCategory', + id: BigInt.parse('-4785915202986038644').toInt(), + properties: { + r'customType': PropertySchema( + id: 0, + name: r'customType', + type: IsarType.string, + ), + r'id': PropertySchema( + id: 1, + name: r'id', + type: IsarType.long, + ), + r'isDefault': PropertySchema( + id: 2, + name: r'isDefault', + type: IsarType.bool, + ), + r'name': PropertySchema( + id: 3, + name: r'name', + type: IsarType.string, + ) + }, + estimateSize: _cNotificationCategoryEstimateSize, + serialize: _cNotificationCategorySerialize, + deserialize: _cNotificationCategoryDeserialize, + deserializeProp: _cNotificationCategoryDeserializeProp, +); + +int _cNotificationCategoryEstimateSize( + CNotificationCategory object, + List offsets, + Map> allOffsets, +) { + var bytesCount = offsets.last; + bytesCount += 3 + object.customType.length * 3; + bytesCount += 3 + object.name.length * 3; + return bytesCount; +} + +void _cNotificationCategorySerialize( + CNotificationCategory object, + IsarWriter writer, + List offsets, + Map> allOffsets, +) { + writer.writeString(offsets[0], object.customType); + writer.writeLong(offsets[1], object.id); + writer.writeBool(offsets[2], object.isDefault); + writer.writeString(offsets[3], object.name); +} + +CNotificationCategory _cNotificationCategoryDeserialize( + Id id, + IsarReader reader, + List offsets, + Map> allOffsets, +) { + final object = CNotificationCategory(); + object.customType = reader.readString(offsets[0]); + object.id = reader.readLong(offsets[1]); + object.isDefault = reader.readBool(offsets[2]); + object.name = reader.readString(offsets[3]); + return object; +} + +P _cNotificationCategoryDeserializeProp

( + IsarReader reader, + int propertyId, + int offset, + Map> allOffsets, +) { + switch (propertyId) { + case 0: + return (reader.readString(offset)) as P; + case 1: + return (reader.readLong(offset)) as P; + case 2: + return (reader.readBool(offset)) as P; + case 3: + return (reader.readString(offset)) as P; + default: + throw IsarError('Unknown property with id $propertyId'); + } +} + +extension CNotificationCategoryQueryFilter on QueryBuilder< + CNotificationCategory, CNotificationCategory, QFilterCondition> { + QueryBuilder customTypeEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'customType', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder customTypeGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'customType', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder customTypeLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'customType', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder customTypeBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'customType', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder customTypeStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'customType', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder customTypeEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'customType', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + customTypeContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'customType', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + customTypeMatches(String pattern, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'customType', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder customTypeIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'customType', + value: '', + )); + }); + } + + QueryBuilder customTypeIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'customType', + value: '', + )); + }); + } + + QueryBuilder idEqualTo(int value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'id', + value: value, + )); + }); + } + + QueryBuilder idGreaterThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'id', + value: value, + )); + }); + } + + QueryBuilder idLessThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'id', + value: value, + )); + }); + } + + QueryBuilder idBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'id', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder isDefaultEqualTo(bool value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'isDefault', + value: value, + )); + }); + } + + QueryBuilder nameEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'name', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder nameGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'name', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder nameLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'name', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder nameBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'name', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder nameStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'name', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder nameEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'name', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + nameContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'name', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + nameMatches(String pattern, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'name', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder nameIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'name', + value: '', + )); + }); + } + + QueryBuilder nameIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'name', + value: '', + )); + }); + } +} + +extension CNotificationCategoryQueryObject on QueryBuilder< + CNotificationCategory, CNotificationCategory, QFilterCondition> {} diff --git a/lib/src/internal/db/schema/channel/c_group_channel.dart b/lib/src/internal/db/schema/channel/c_group_channel.dart new file mode 100644 index 00000000..e3c807ad --- /dev/null +++ b/lib/src/internal/db/schema/channel/c_group_channel.dart @@ -0,0 +1,504 @@ +// Copyright (c) 2023 Sendbird, Inc. All rights reserved. + +import 'package:isar/isar.dart'; +import 'package:sendbird_chat_sdk/sendbird_chat_sdk.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/channel/c_base_channel.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/message/c_base_message.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/user/c_member.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/user/c_user.dart'; +import 'package:sendbird_chat_sdk/src/internal/main/chat/chat.dart'; + +part 'c_group_channel.g.dart'; + +@collection +class CGroupChannel extends CBaseChannel { + @enumerated + late MessageType lastMessageType; // lastMessage + String? lastMessageRootId; // lastMessage + int? lastMessageCreatedAt; // lastMessage for filtering + + late bool isSuper; + late bool isBroadcast; + late bool isPublic; + late bool isDistinct; + late bool isDiscoverable; + late bool isExclusive; + late bool isAccessCodeRequired; + late int unreadMessageCount; + late int unreadMentionCount; + late List members; + late int memberCount; + late int joinedMemberCount; + + @enumerated + late GroupChannelPushTriggerOption myPushTriggerOption; + + late bool isChatNotification; + + @enumerated + late MemberState myMemberState; + + @enumerated + late Role myRole; + + @enumerated + late MuteState myMutedState; + + @enumerated + late CountPreference myCountPreference; + + String? creator; // CUser + CMember? inviter; + late int invitedAt; + late int joinedAt; + late bool isHidden; + + @enumerated + late GroupChannelHiddenState hiddenState; + + late int myLastRead; + int? messageOffsetTimestamp; + late int messageSurvivalSeconds; + late List pinnedMessageIds; + + @enumerated + late MessageType lastPinnedMessageType; // lastPinnedMessage + String? lastPinnedMessageRootId; // lastPinnedMessage + + late int pinnedMessageUpdatedAt; + + CGroupChannel(); + + factory CGroupChannel.fromGroupChannel(GroupChannel channel) { + return CGroupChannel() + // BaseChannel + ..setBaseChannel(channel) + // GroupChannel + ..lastMessageType = channel.lastMessage?.messageType ?? MessageType.user + ..lastMessageRootId = channel.lastMessage?.rootId + ..lastMessageCreatedAt = channel.lastMessage?.createdAt + ..isSuper = channel.isSuper + ..isBroadcast = channel.isBroadcast + ..isSuper = channel.isSuper + ..isPublic = channel.isPublic + ..isDistinct = channel.isDistinct + ..isDiscoverable = channel.isDiscoverable + ..isExclusive = channel.isExclusive + ..isAccessCodeRequired = channel.isAccessCodeRequired + ..unreadMessageCount = channel.unreadMessageCount + ..unreadMentionCount = channel.unreadMentionCount + ..members = + channel.members.map((member) => CMember.fromMember(member)).toList() + ..memberCount = channel.memberCount + ..joinedMemberCount = channel.joinedMemberCount + ..myPushTriggerOption = channel.myPushTriggerOption + ..isChatNotification = channel.isChatNotification + ..myMemberState = channel.myMemberState + ..myRole = channel.myRole + ..myMutedState = channel.myMutedState + ..myCountPreference = channel.myCountPreference + ..creator = channel.creator?.userId + ..inviter = + channel.inviter != null ? CMember.fromMember(channel.inviter!) : null + ..invitedAt = channel.invitedAt + ..joinedAt = channel.joinedAt + ..isHidden = channel.isHidden + ..hiddenState = channel.hiddenState + ..myLastRead = channel.myLastRead + ..messageOffsetTimestamp = channel.messageOffsetTimestamp + ..messageSurvivalSeconds = channel.messageSurvivalSeconds + ..pinnedMessageIds = channel.pinnedMessageIds + ..lastPinnedMessageType = + channel.lastPinnedMessage?.messageType ?? MessageType.user + ..lastPinnedMessageRootId = channel.lastPinnedMessage?.rootId + ..pinnedMessageUpdatedAt = channel.pinnedMessageUpdatedAt; + } + + Future toGroupChannel(Chat chat, Isar isar) async { + final groupChannel = GroupChannel( + // BaseChannel + channelUrl: channelUrl, + )..set(chat); + + CBaseChannel.setCBaseChannel(chat, isar, groupChannel, this) as GroupChannel + // GroupChannel + ..lastMessage = await CBaseMessage.getMessage( + chat, isar, lastMessageType, lastMessageRootId) + ..isBroadcast = isBroadcast + ..isSuper = isSuper + ..isPublic = isPublic + ..isDistinct = isDistinct + ..isDiscoverable = isDiscoverable + ..isExclusive = isExclusive + ..isAccessCodeRequired = isAccessCodeRequired + ..unreadMessageCount = unreadMessageCount + ..unreadMentionCount = unreadMentionCount + ..memberCount = memberCount + ..joinedMemberCount = joinedMemberCount + ..myPushTriggerOption = myPushTriggerOption + ..isChatNotification = isChatNotification + ..myMemberState = myMemberState + ..myRole = myRole + ..myMutedState = myMutedState + ..myCountPreference = myCountPreference + ..creator = creator != null ? await CUser.get(chat, isar, creator!) : null + ..inviter = await inviter?.toMember(chat, isar) + ..invitedAt = invitedAt + ..joinedAt = joinedAt + ..isHidden = isHidden + ..hiddenState = hiddenState + ..myLastRead = myLastRead + ..messageOffsetTimestamp = messageOffsetTimestamp + ..messageSurvivalSeconds = messageSurvivalSeconds + ..pinnedMessageIds = pinnedMessageIds + ..lastPinnedMessage = await CBaseMessage.getMessage( + chat, isar, lastPinnedMessageType, lastPinnedMessageRootId) + ..pinnedMessageUpdatedAt = pinnedMessageUpdatedAt; + + groupChannel.members = []; + for (final cMember in members) { + final member = await cMember.toMember(chat, isar); + if (member != null) { + groupChannel.members.add(member); + } + } + return groupChannel; + } + + static Future upsert( + Chat chat, Isar isar, GroupChannel channel) async { + final cGroupChannel = CGroupChannel.fromGroupChannel(channel); + + // GroupChannel + await chat.dbManager.write(() async { + await isar.cGroupChannels.put(cGroupChannel); + }); + + // lastMessage + if (channel.lastMessage != null) { + await CBaseMessage.upsert(chat, isar, channel.lastMessage!); + } + + // members + for (final member in channel.members) { + await CUser.upsert(chat, isar, member); + } + + // creator + if (channel.creator != null) { + await CUser.upsert(chat, isar, channel.creator!); + } + + // inviter + if (channel.inviter != null) { + await CUser.upsert(chat, isar, channel.inviter!); + } + + // lastPinnedMessage + if (channel.lastPinnedMessage != null) { + await CBaseMessage.upsert(chat, isar, channel.lastPinnedMessage!); + } + + return cGroupChannel; + } + + static Future get( + Chat chat, Isar isar, String channelUrl) async { + final cGroupChannel = await isar.cGroupChannels + .where() + .channelUrlEqualTo(channelUrl) + .findFirst(); + return await cGroupChannel?.toGroupChannel(chat, isar); + } + + static Future> getChannels( + Chat chat, + Isar isar, + GroupChannelListQuery query, + int? offset, + ) async { + // [includeMetaData] + // When calling API, this value have to be `true` to make chunk. + // But we must always call API for GroupChannel, because we must always get `hasNext` value from API. + // So we do not need the chunk for GroupChannel. + + final cGroupChannels = await isar.cGroupChannels + .where() + .channelTypeEqualToAnyChannelUrl(ChannelType.group) // Check + .filter() + + // channelUrlsFilter + .optional(query.channelUrlsFilter.isNotEmpty, (q) { + return q.group((groupQ) { + late QueryBuilder qb; + bool isFirst = true; + for (final channelUrl in query.channelUrlsFilter) { + if (isFirst) { + qb = groupQ.channelUrlEqualTo(channelUrl); + isFirst = false; + } else { + qb = qb.or().channelUrlEqualTo(channelUrl); + } + } + return qb; + }); + }) + + // myMemberStateFilter + .optional(query.myMemberStateFilter == MyMemberStateFilter.invited, + (q) { + return q.myMemberStateEqualTo(MemberState.invited); + }) + .optional(query.myMemberStateFilter == MyMemberStateFilter.invitedByFriend, + (q) { + // Must call API, because this can not be queried with local cache. + return q.myMemberStateEqualTo(MemberState.invited); + }) + .optional(query.myMemberStateFilter == MyMemberStateFilter.invitedByNonFriend, + (q) { + // Must call API, because this can not be queried with local cache. + return q.myMemberStateEqualTo(MemberState.invited); + }) + .optional(query.myMemberStateFilter == MyMemberStateFilter.joined, (q) { + return q.myMemberStateEqualTo(MemberState.joined); + }) + + // superChannelFilter + // [SuperChannelFilter.exclusiveChannelOnly] + // Must call API, because this can not be queried with local cache. + .optional(query.superChannelFilter == SuperChannelFilter.superChannelOnly, + (q) { + return q.isSuperEqualTo(true); + }) + .optional(query.superChannelFilter == SuperChannelFilter.nonsuperChannelOnly, + (q) { + return q.isSuperEqualTo(false); + }) + // [SuperChannelFilter.broadcastChannelOnly] + // Must call API, because this can not be queried with local cache. + + // publicChannelFilter + .optional(query.publicChannelFilter == PublicChannelFilter.public, (q) { + return q.isPublicEqualTo(true); + }) + .optional(query.publicChannelFilter == PublicChannelFilter.private, + (q) { + return q.isPublicEqualTo(false); + }) + + // unreadChannelFilter + .optional(query.unreadChannelFilter == UnreadChannelFilter.unreadMessage, + (q) { + return q.isSuperEqualTo(false).unreadMessageCountGreaterThan(0); + }) + + // hiddenChannelFilter + .optional(query.hiddenChannelFilter == HiddenChannelFilter.unhidden, + (q) { + return q.isHiddenEqualTo(false); + }) + .optional(query.hiddenChannelFilter == HiddenChannelFilter.hidden, (q) { + return q.isHiddenEqualTo(true); + }) + .optional(query.hiddenChannelFilter == HiddenChannelFilter.hiddenAllowAutoUnhide, + (q) { + return q + .isHiddenEqualTo(true) + .hiddenStateEqualTo(GroupChannelHiddenState.allowAutoUnhide); + }) + .optional(query.hiddenChannelFilter == HiddenChannelFilter.hiddenPreventAutoUnhide, + (q) { + return q + .isHiddenEqualTo(true) + .hiddenStateEqualTo(GroupChannelHiddenState.preventAutoUnhide); + }) + + // customTypeStartsWithFilter + .optional( + query.customTypeStartsWithFilter != null && + query.customTypeStartsWithFilter!.isNotEmpty, (q) { + return q.customTypeStartsWith(query.customTypeStartsWithFilter!); + }) + + // customTypesFilter + .optional(query.customTypesFilter.isNotEmpty, (q) { + return q.group((groupQ) { + late QueryBuilder qb; + bool isFirst = true; + for (final customType in query.customTypesFilter) { + if (isFirst) { + qb = groupQ.customTypeEqualTo(customType); + isFirst = false; + } else { + qb = qb.or().customTypeEqualTo(customType); + } + } + return qb; + }); + }) + + // nicknameContainsFilter + .optional(query.nicknameContainsFilter != null && query.nicknameContainsFilter!.isNotEmpty, + (q) { + return q.membersElement((q) { + return q.nicknameContains(query.nicknameContainsFilter!, + caseSensitive: false); + }); + }) + + // userIdsIncludeFilter & queryType + .optional(query.userIdsIncludeFilter.isNotEmpty, (q) { + return q.membersElement((membersQ) { + late QueryBuilder qb; + bool isFirst = true; + for (final userId in query.userIdsIncludeFilter) { + if (isFirst) { + qb = membersQ.userIdEqualTo(userId, caseSensitive: false); + isFirst = false; + } else { + if (query.queryType == GroupChannelListQueryType.and) { + qb = membersQ.userIdEqualTo(userId, caseSensitive: false); + } else if (query.queryType == GroupChannelListQueryType.or) { + qb = qb.or().userIdEqualTo(userId, caseSensitive: false); + } + } + } + return qb; + }); + }) + + // userIdsExactFilter + .optional(query.userIdsExactFilter.isNotEmpty, (q) { + return q + .membersLengthEqualTo(query.userIdsExactFilter.length) + .membersElement((membersQ) { + late QueryBuilder qb; + for (final userId in query.userIdsExactFilter) { + qb = membersQ.userIdEqualTo(userId); + } + return qb; + }); + }) + + // channelNameContainsFilter + .optional( + query.channelNameContainsFilter != null && + query.channelNameContainsFilter!.isNotEmpty, (q) { + return q.nameContains(query.channelNameContainsFilter!, + caseSensitive: false); + }) + + // [metaDataOrderKeyFilter] + // Must call API, because this can not be queried with local cache. + + // [metaDataKey & metaDataValues] + // Must call API, because this can not be queried with local cache. + + // [metaDataKey & metaDataValueStartsWith] + // Must call API, because this can not be queried with local cache. + + // searchQuery & searchFields + .optional(query.searchQuery != null && query.searchQuery!.isNotEmpty, + (q) { + return q.group((groupQ) { + late QueryBuilder qb; + bool isFirst = true; + for (final searchField in query.searchFields) { + if (searchField == + GroupChannelListQuerySearchField.memberNickname) { + if (isFirst) { + qb = groupQ.membersElement((q) { + return q.nicknameContains(query.searchQuery!, + caseSensitive: false); + }); + isFirst = false; + } else { + qb = qb.or().membersElement((q) { + return q.nicknameContains(query.searchQuery!, + caseSensitive: false); + }); + } + } else if (searchField == + GroupChannelListQuerySearchField.channelName) { + if (isFirst) { + qb = groupQ.nameContains(query.searchQuery!, + caseSensitive: false); + isFirst = false; + } else { + qb = qb + .or() + .nameContains(query.searchQuery!, caseSensitive: false); + } + } + } + return qb; + }); + }) + + // includeEmpty + .optional(query.includeEmpty == false, (q) { + return q.lastMessageRootIdIsNotNull(); + }) + + // includeFrozen + .optional(query.includeFrozen == false, (q) { + return q.isFrozenEqualTo(false); + }) + + // includeChatNotification + .optional(query.includeChatNotification == false, (q) { + return q.isChatNotificationEqualTo(false); + }) + + // createdBefore + .optional(query.createdBefore != null, (q) { + return q.createdAtLessThan(query.createdBefore, include: true); + }) + + // createdAfter + .optional(query.createdAfter != null, (q) { + return q.createdAtGreaterThan(query.createdAfter, include: true); + }) + + // order + .optional(query.order == GroupChannelListQueryOrder.chronological, (q) { + return q.sortByCreatedAtDesc(); + }) + .optional(query.order == GroupChannelListQueryOrder.latestLastMessage, + (q) { + return q.thenByLastMessageCreatedAtDesc().thenByCreatedAtDesc(); + }) + .optional(query.order == GroupChannelListQueryOrder.channelNameAlphabetical, + (q) { + return q.thenByName().thenByCreatedAtDesc(); + }) + + // [GroupChannelListQueryOrder.metadataValueAlphabetical] + // Must call API, because this can not be queried with local cache. + + // offset + .optional(offset != null, (q) { + return q.offset(offset!); + }) + + // limit + .limit(query.limit) + .findAll(); + + List channels = []; + for (final cGroupChannel in cGroupChannels) { + final channel = await cGroupChannel.toGroupChannel(chat, isar); + channels.add(channel); + } + return channels; + } + + static Future delete(Chat chat, Isar isar, String channelUrl) async { + await chat.dbManager.write(() async { + await isar.cGroupChannels.deleteByChannelUrl(channelUrl); + }); + } +} diff --git a/lib/src/internal/db/schema/channel/c_group_channel.g.dart b/lib/src/internal/db/schema/channel/c_group_channel.g.dart new file mode 100644 index 00000000..dda3a88d --- /dev/null +++ b/lib/src/internal/db/schema/channel/c_group_channel.g.dart @@ -0,0 +1,5722 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'c_group_channel.dart'; + +// ************************************************************************** +// IsarCollectionGenerator +// ************************************************************************** + +// coverage:ignore-file +// ignore_for_file: duplicate_ignore, non_constant_identifier_names, constant_identifier_names, invalid_use_of_protected_member, unnecessary_cast, prefer_const_constructors, lines_longer_than_80_chars, require_trailing_commas, inference_failure_on_function_invocation, unnecessary_parenthesis, unnecessary_raw_strings, unnecessary_null_checks, join_return_with_assignment, prefer_final_locals, avoid_js_rounded_ints, avoid_positional_boolean_parameters, always_specify_types + +extension GetCGroupChannelCollection on Isar { + IsarCollection get cGroupChannels => this.collection(); +} + +final CGroupChannelSchema = CollectionSchema( + name: r'CGroupChannel', + id: BigInt.parse('-4229950044315142915').toInt(), + properties: { + r'channelType': PropertySchema( + id: 0, + name: r'channelType', + type: IsarType.byte, + enumMap: _CGroupChannelchannelTypeEnumValueMap, + ), + r'channelUrl': PropertySchema( + id: 1, + name: r'channelUrl', + type: IsarType.string, + ), + r'coverUrl': PropertySchema( + id: 2, + name: r'coverUrl', + type: IsarType.string, + ), + r'createdAt': PropertySchema( + id: 3, + name: r'createdAt', + type: IsarType.long, + ), + r'creator': PropertySchema( + id: 4, + name: r'creator', + type: IsarType.string, + ), + r'customType': PropertySchema( + id: 5, + name: r'customType', + type: IsarType.string, + ), + r'data': PropertySchema( + id: 6, + name: r'data', + type: IsarType.string, + ), + r'dirty': PropertySchema( + id: 7, + name: r'dirty', + type: IsarType.bool, + ), + r'fromCache': PropertySchema( + id: 8, + name: r'fromCache', + type: IsarType.bool, + ), + r'hiddenState': PropertySchema( + id: 9, + name: r'hiddenState', + type: IsarType.byte, + enumMap: _CGroupChannelhiddenStateEnumValueMap, + ), + r'invitedAt': PropertySchema( + id: 10, + name: r'invitedAt', + type: IsarType.long, + ), + r'inviter': PropertySchema( + id: 11, + name: r'inviter', + type: IsarType.object, + target: r'CMember', + ), + r'isAccessCodeRequired': PropertySchema( + id: 12, + name: r'isAccessCodeRequired', + type: IsarType.bool, + ), + r'isBroadcast': PropertySchema( + id: 13, + name: r'isBroadcast', + type: IsarType.bool, + ), + r'isChatNotification': PropertySchema( + id: 14, + name: r'isChatNotification', + type: IsarType.bool, + ), + r'isDiscoverable': PropertySchema( + id: 15, + name: r'isDiscoverable', + type: IsarType.bool, + ), + r'isDistinct': PropertySchema( + id: 16, + name: r'isDistinct', + type: IsarType.bool, + ), + r'isEphemeral': PropertySchema( + id: 17, + name: r'isEphemeral', + type: IsarType.bool, + ), + r'isExclusive': PropertySchema( + id: 18, + name: r'isExclusive', + type: IsarType.bool, + ), + r'isFrozen': PropertySchema( + id: 19, + name: r'isFrozen', + type: IsarType.bool, + ), + r'isHidden': PropertySchema( + id: 20, + name: r'isHidden', + type: IsarType.bool, + ), + r'isPublic': PropertySchema( + id: 21, + name: r'isPublic', + type: IsarType.bool, + ), + r'isSuper': PropertySchema( + id: 22, + name: r'isSuper', + type: IsarType.bool, + ), + r'joinedAt': PropertySchema( + id: 23, + name: r'joinedAt', + type: IsarType.long, + ), + r'joinedMemberCount': PropertySchema( + id: 24, + name: r'joinedMemberCount', + type: IsarType.long, + ), + r'lastMessageCreatedAt': PropertySchema( + id: 25, + name: r'lastMessageCreatedAt', + type: IsarType.long, + ), + r'lastMessageRootId': PropertySchema( + id: 26, + name: r'lastMessageRootId', + type: IsarType.string, + ), + r'lastMessageType': PropertySchema( + id: 27, + name: r'lastMessageType', + type: IsarType.byte, + enumMap: _CGroupChannellastMessageTypeEnumValueMap, + ), + r'lastPinnedMessageRootId': PropertySchema( + id: 28, + name: r'lastPinnedMessageRootId', + type: IsarType.string, + ), + r'lastPinnedMessageType': PropertySchema( + id: 29, + name: r'lastPinnedMessageType', + type: IsarType.byte, + enumMap: _CGroupChannellastPinnedMessageTypeEnumValueMap, + ), + r'memberCount': PropertySchema( + id: 30, + name: r'memberCount', + type: IsarType.long, + ), + r'members': PropertySchema( + id: 31, + name: r'members', + type: IsarType.objectList, + target: r'CMember', + ), + r'messageOffsetTimestamp': PropertySchema( + id: 32, + name: r'messageOffsetTimestamp', + type: IsarType.long, + ), + r'messageSurvivalSeconds': PropertySchema( + id: 33, + name: r'messageSurvivalSeconds', + type: IsarType.long, + ), + r'myCountPreference': PropertySchema( + id: 34, + name: r'myCountPreference', + type: IsarType.byte, + enumMap: _CGroupChannelmyCountPreferenceEnumValueMap, + ), + r'myLastRead': PropertySchema( + id: 35, + name: r'myLastRead', + type: IsarType.long, + ), + r'myMemberState': PropertySchema( + id: 36, + name: r'myMemberState', + type: IsarType.byte, + enumMap: _CGroupChannelmyMemberStateEnumValueMap, + ), + r'myMutedState': PropertySchema( + id: 37, + name: r'myMutedState', + type: IsarType.byte, + enumMap: _CGroupChannelmyMutedStateEnumValueMap, + ), + r'myPushTriggerOption': PropertySchema( + id: 38, + name: r'myPushTriggerOption', + type: IsarType.byte, + enumMap: _CGroupChannelmyPushTriggerOptionEnumValueMap, + ), + r'myRole': PropertySchema( + id: 39, + name: r'myRole', + type: IsarType.byte, + enumMap: _CGroupChannelmyRoleEnumValueMap, + ), + r'name': PropertySchema( + id: 40, + name: r'name', + type: IsarType.string, + ), + r'pinnedMessageIds': PropertySchema( + id: 41, + name: r'pinnedMessageIds', + type: IsarType.longList, + ), + r'pinnedMessageUpdatedAt': PropertySchema( + id: 42, + name: r'pinnedMessageUpdatedAt', + type: IsarType.long, + ), + r'unreadMentionCount': PropertySchema( + id: 43, + name: r'unreadMentionCount', + type: IsarType.long, + ), + r'unreadMessageCount': PropertySchema( + id: 44, + name: r'unreadMessageCount', + type: IsarType.long, + ) + }, + estimateSize: _cGroupChannelEstimateSize, + serialize: _cGroupChannelSerialize, + deserialize: _cGroupChannelDeserialize, + deserializeProp: _cGroupChannelDeserializeProp, + idName: r'id', + indexes: { + r'channelUrl': IndexSchema( + id: BigInt.parse('6636052684858767397').toInt(), + name: r'channelUrl', + unique: true, + replace: true, + properties: [ + IndexPropertySchema( + name: r'channelUrl', + type: IndexType.hash, + caseSensitive: true, + ) + ], + ), + r'channelType_channelUrl': IndexSchema( + id: BigInt.parse('-5957547153902522682').toInt(), + name: r'channelType_channelUrl', + unique: false, + replace: false, + properties: [ + IndexPropertySchema( + name: r'channelType', + type: IndexType.value, + caseSensitive: false, + ), + IndexPropertySchema( + name: r'channelUrl', + type: IndexType.hash, + caseSensitive: true, + ) + ], + ) + }, + links: {}, + embeddedSchemas: { + r'CMember': CMemberSchema, + r'CRestrictionInfo': CRestrictionInfoSchema + }, + getId: _cGroupChannelGetId, + getLinks: _cGroupChannelGetLinks, + attach: _cGroupChannelAttach, + version: '3.1.0+1', +); + +int _cGroupChannelEstimateSize( + CGroupChannel object, + List offsets, + Map> allOffsets, +) { + var bytesCount = offsets.last; + bytesCount += 3 + object.channelUrl.length * 3; + { + final value = object.coverUrl; + if (value != null) { + bytesCount += 3 + value.length * 3; + } + } + { + final value = object.creator; + if (value != null) { + bytesCount += 3 + value.length * 3; + } + } + { + final value = object.customType; + if (value != null) { + bytesCount += 3 + value.length * 3; + } + } + { + final value = object.data; + if (value != null) { + bytesCount += 3 + value.length * 3; + } + } + { + final value = object.inviter; + if (value != null) { + bytesCount += 3 + + CMemberSchema.estimateSize(value, allOffsets[CMember]!, allOffsets); + } + } + { + final value = object.lastMessageRootId; + if (value != null) { + bytesCount += 3 + value.length * 3; + } + } + { + final value = object.lastPinnedMessageRootId; + if (value != null) { + bytesCount += 3 + value.length * 3; + } + } + bytesCount += 3 + object.members.length * 3; + { + final offsets = allOffsets[CMember]!; + for (var i = 0; i < object.members.length; i++) { + final value = object.members[i]; + bytesCount += CMemberSchema.estimateSize(value, offsets, allOffsets); + } + } + bytesCount += 3 + object.name.length * 3; + bytesCount += 3 + object.pinnedMessageIds.length * 8; + return bytesCount; +} + +void _cGroupChannelSerialize( + CGroupChannel object, + IsarWriter writer, + List offsets, + Map> allOffsets, +) { + writer.writeByte(offsets[0], object.channelType.index); + writer.writeString(offsets[1], object.channelUrl); + writer.writeString(offsets[2], object.coverUrl); + writer.writeLong(offsets[3], object.createdAt); + writer.writeString(offsets[4], object.creator); + writer.writeString(offsets[5], object.customType); + writer.writeString(offsets[6], object.data); + writer.writeBool(offsets[7], object.dirty); + writer.writeBool(offsets[8], object.fromCache); + writer.writeByte(offsets[9], object.hiddenState.index); + writer.writeLong(offsets[10], object.invitedAt); + writer.writeObject( + offsets[11], + allOffsets, + CMemberSchema.serialize, + object.inviter, + ); + writer.writeBool(offsets[12], object.isAccessCodeRequired); + writer.writeBool(offsets[13], object.isBroadcast); + writer.writeBool(offsets[14], object.isChatNotification); + writer.writeBool(offsets[15], object.isDiscoverable); + writer.writeBool(offsets[16], object.isDistinct); + writer.writeBool(offsets[17], object.isEphemeral); + writer.writeBool(offsets[18], object.isExclusive); + writer.writeBool(offsets[19], object.isFrozen); + writer.writeBool(offsets[20], object.isHidden); + writer.writeBool(offsets[21], object.isPublic); + writer.writeBool(offsets[22], object.isSuper); + writer.writeLong(offsets[23], object.joinedAt); + writer.writeLong(offsets[24], object.joinedMemberCount); + writer.writeLong(offsets[25], object.lastMessageCreatedAt); + writer.writeString(offsets[26], object.lastMessageRootId); + writer.writeByte(offsets[27], object.lastMessageType.index); + writer.writeString(offsets[28], object.lastPinnedMessageRootId); + writer.writeByte(offsets[29], object.lastPinnedMessageType.index); + writer.writeLong(offsets[30], object.memberCount); + writer.writeObjectList( + offsets[31], + allOffsets, + CMemberSchema.serialize, + object.members, + ); + writer.writeLong(offsets[32], object.messageOffsetTimestamp); + writer.writeLong(offsets[33], object.messageSurvivalSeconds); + writer.writeByte(offsets[34], object.myCountPreference.index); + writer.writeLong(offsets[35], object.myLastRead); + writer.writeByte(offsets[36], object.myMemberState.index); + writer.writeByte(offsets[37], object.myMutedState.index); + writer.writeByte(offsets[38], object.myPushTriggerOption.index); + writer.writeByte(offsets[39], object.myRole.index); + writer.writeString(offsets[40], object.name); + writer.writeLongList(offsets[41], object.pinnedMessageIds); + writer.writeLong(offsets[42], object.pinnedMessageUpdatedAt); + writer.writeLong(offsets[43], object.unreadMentionCount); + writer.writeLong(offsets[44], object.unreadMessageCount); +} + +CGroupChannel _cGroupChannelDeserialize( + Id id, + IsarReader reader, + List offsets, + Map> allOffsets, +) { + final object = CGroupChannel(); + object.channelType = _CGroupChannelchannelTypeValueEnumMap[ + reader.readByteOrNull(offsets[0])] ?? + ChannelType.group; + object.channelUrl = reader.readString(offsets[1]); + object.coverUrl = reader.readStringOrNull(offsets[2]); + object.createdAt = reader.readLongOrNull(offsets[3]); + object.creator = reader.readStringOrNull(offsets[4]); + object.customType = reader.readStringOrNull(offsets[5]); + object.data = reader.readStringOrNull(offsets[6]); + object.dirty = reader.readBool(offsets[7]); + object.fromCache = reader.readBool(offsets[8]); + object.hiddenState = _CGroupChannelhiddenStateValueEnumMap[ + reader.readByteOrNull(offsets[9])] ?? + GroupChannelHiddenState.unhidden; + object.id = id; + object.invitedAt = reader.readLong(offsets[10]); + object.inviter = reader.readObjectOrNull( + offsets[11], + CMemberSchema.deserialize, + allOffsets, + ); + object.isAccessCodeRequired = reader.readBool(offsets[12]); + object.isBroadcast = reader.readBool(offsets[13]); + object.isChatNotification = reader.readBool(offsets[14]); + object.isDiscoverable = reader.readBool(offsets[15]); + object.isDistinct = reader.readBool(offsets[16]); + object.isEphemeral = reader.readBoolOrNull(offsets[17]); + object.isExclusive = reader.readBool(offsets[18]); + object.isFrozen = reader.readBoolOrNull(offsets[19]); + object.isHidden = reader.readBool(offsets[20]); + object.isPublic = reader.readBool(offsets[21]); + object.isSuper = reader.readBool(offsets[22]); + object.joinedAt = reader.readLong(offsets[23]); + object.joinedMemberCount = reader.readLong(offsets[24]); + object.lastMessageCreatedAt = reader.readLongOrNull(offsets[25]); + object.lastMessageRootId = reader.readStringOrNull(offsets[26]); + object.lastMessageType = _CGroupChannellastMessageTypeValueEnumMap[ + reader.readByteOrNull(offsets[27])] ?? + MessageType.user; + object.lastPinnedMessageRootId = reader.readStringOrNull(offsets[28]); + object.lastPinnedMessageType = + _CGroupChannellastPinnedMessageTypeValueEnumMap[ + reader.readByteOrNull(offsets[29])] ?? + MessageType.user; + object.memberCount = reader.readLong(offsets[30]); + object.members = reader.readObjectList( + offsets[31], + CMemberSchema.deserialize, + allOffsets, + CMember(), + ) ?? + []; + object.messageOffsetTimestamp = reader.readLongOrNull(offsets[32]); + object.messageSurvivalSeconds = reader.readLong(offsets[33]); + object.myCountPreference = _CGroupChannelmyCountPreferenceValueEnumMap[ + reader.readByteOrNull(offsets[34])] ?? + CountPreference.all; + object.myLastRead = reader.readLong(offsets[35]); + object.myMemberState = _CGroupChannelmyMemberStateValueEnumMap[ + reader.readByteOrNull(offsets[36])] ?? + MemberState.none; + object.myMutedState = _CGroupChannelmyMutedStateValueEnumMap[ + reader.readByteOrNull(offsets[37])] ?? + MuteState.unmuted; + object.myPushTriggerOption = _CGroupChannelmyPushTriggerOptionValueEnumMap[ + reader.readByteOrNull(offsets[38])] ?? + GroupChannelPushTriggerOption.defaultValue; + object.myRole = + _CGroupChannelmyRoleValueEnumMap[reader.readByteOrNull(offsets[39])] ?? + Role.none; + object.name = reader.readString(offsets[40]); + object.pinnedMessageIds = reader.readLongList(offsets[41]) ?? []; + object.pinnedMessageUpdatedAt = reader.readLong(offsets[42]); + object.unreadMentionCount = reader.readLong(offsets[43]); + object.unreadMessageCount = reader.readLong(offsets[44]); + return object; +} + +P _cGroupChannelDeserializeProp

( + IsarReader reader, + int propertyId, + int offset, + Map> allOffsets, +) { + switch (propertyId) { + case 0: + return (_CGroupChannelchannelTypeValueEnumMap[ + reader.readByteOrNull(offset)] ?? + ChannelType.group) as P; + case 1: + return (reader.readString(offset)) as P; + case 2: + return (reader.readStringOrNull(offset)) as P; + case 3: + return (reader.readLongOrNull(offset)) as P; + case 4: + return (reader.readStringOrNull(offset)) as P; + case 5: + return (reader.readStringOrNull(offset)) as P; + case 6: + return (reader.readStringOrNull(offset)) as P; + case 7: + return (reader.readBool(offset)) as P; + case 8: + return (reader.readBool(offset)) as P; + case 9: + return (_CGroupChannelhiddenStateValueEnumMap[ + reader.readByteOrNull(offset)] ?? + GroupChannelHiddenState.unhidden) as P; + case 10: + return (reader.readLong(offset)) as P; + case 11: + return (reader.readObjectOrNull( + offset, + CMemberSchema.deserialize, + allOffsets, + )) as P; + case 12: + return (reader.readBool(offset)) as P; + case 13: + return (reader.readBool(offset)) as P; + case 14: + return (reader.readBool(offset)) as P; + case 15: + return (reader.readBool(offset)) as P; + case 16: + return (reader.readBool(offset)) as P; + case 17: + return (reader.readBoolOrNull(offset)) as P; + case 18: + return (reader.readBool(offset)) as P; + case 19: + return (reader.readBoolOrNull(offset)) as P; + case 20: + return (reader.readBool(offset)) as P; + case 21: + return (reader.readBool(offset)) as P; + case 22: + return (reader.readBool(offset)) as P; + case 23: + return (reader.readLong(offset)) as P; + case 24: + return (reader.readLong(offset)) as P; + case 25: + return (reader.readLongOrNull(offset)) as P; + case 26: + return (reader.readStringOrNull(offset)) as P; + case 27: + return (_CGroupChannellastMessageTypeValueEnumMap[ + reader.readByteOrNull(offset)] ?? + MessageType.user) as P; + case 28: + return (reader.readStringOrNull(offset)) as P; + case 29: + return (_CGroupChannellastPinnedMessageTypeValueEnumMap[ + reader.readByteOrNull(offset)] ?? + MessageType.user) as P; + case 30: + return (reader.readLong(offset)) as P; + case 31: + return (reader.readObjectList( + offset, + CMemberSchema.deserialize, + allOffsets, + CMember(), + ) ?? + []) as P; + case 32: + return (reader.readLongOrNull(offset)) as P; + case 33: + return (reader.readLong(offset)) as P; + case 34: + return (_CGroupChannelmyCountPreferenceValueEnumMap[ + reader.readByteOrNull(offset)] ?? + CountPreference.all) as P; + case 35: + return (reader.readLong(offset)) as P; + case 36: + return (_CGroupChannelmyMemberStateValueEnumMap[ + reader.readByteOrNull(offset)] ?? + MemberState.none) as P; + case 37: + return (_CGroupChannelmyMutedStateValueEnumMap[ + reader.readByteOrNull(offset)] ?? + MuteState.unmuted) as P; + case 38: + return (_CGroupChannelmyPushTriggerOptionValueEnumMap[ + reader.readByteOrNull(offset)] ?? + GroupChannelPushTriggerOption.defaultValue) as P; + case 39: + return (_CGroupChannelmyRoleValueEnumMap[reader.readByteOrNull(offset)] ?? + Role.none) as P; + case 40: + return (reader.readString(offset)) as P; + case 41: + return (reader.readLongList(offset) ?? []) as P; + case 42: + return (reader.readLong(offset)) as P; + case 43: + return (reader.readLong(offset)) as P; + case 44: + return (reader.readLong(offset)) as P; + default: + throw IsarError('Unknown property with id $propertyId'); + } +} + +const _CGroupChannelchannelTypeEnumValueMap = { + 'group': 0, + 'open': 1, + 'feed': 2, +}; +const _CGroupChannelchannelTypeValueEnumMap = { + 0: ChannelType.group, + 1: ChannelType.open, + 2: ChannelType.feed, +}; +const _CGroupChannelhiddenStateEnumValueMap = { + 'unhidden': 0, + 'allowAutoUnhide': 1, + 'preventAutoUnhide': 2, +}; +const _CGroupChannelhiddenStateValueEnumMap = { + 0: GroupChannelHiddenState.unhidden, + 1: GroupChannelHiddenState.allowAutoUnhide, + 2: GroupChannelHiddenState.preventAutoUnhide, +}; +const _CGroupChannellastMessageTypeEnumValueMap = { + 'user': 0, + 'file': 1, + 'admin': 2, + 'notification': 3, +}; +const _CGroupChannellastMessageTypeValueEnumMap = { + 0: MessageType.user, + 1: MessageType.file, + 2: MessageType.admin, + 3: MessageType.notification, +}; +const _CGroupChannellastPinnedMessageTypeEnumValueMap = { + 'user': 0, + 'file': 1, + 'admin': 2, + 'notification': 3, +}; +const _CGroupChannellastPinnedMessageTypeValueEnumMap = { + 0: MessageType.user, + 1: MessageType.file, + 2: MessageType.admin, + 3: MessageType.notification, +}; +const _CGroupChannelmyCountPreferenceEnumValueMap = { + 'all': 0, + 'unreadMessageCountOnly': 1, + 'unrealMentionCountOnly': 2, + 'off': 3, +}; +const _CGroupChannelmyCountPreferenceValueEnumMap = { + 0: CountPreference.all, + 1: CountPreference.unreadMessageCountOnly, + 2: CountPreference.unrealMentionCountOnly, + 3: CountPreference.off, +}; +const _CGroupChannelmyMemberStateEnumValueMap = { + 'none': 0, + 'invited': 1, + 'joined': 2, +}; +const _CGroupChannelmyMemberStateValueEnumMap = { + 0: MemberState.none, + 1: MemberState.invited, + 2: MemberState.joined, +}; +const _CGroupChannelmyMutedStateEnumValueMap = { + 'unmuted': 0, + 'muted': 1, +}; +const _CGroupChannelmyMutedStateValueEnumMap = { + 0: MuteState.unmuted, + 1: MuteState.muted, +}; +const _CGroupChannelmyPushTriggerOptionEnumValueMap = { + 'defaultValue': 0, + 'all': 1, + 'off': 2, + 'mentionOnly': 3, +}; +const _CGroupChannelmyPushTriggerOptionValueEnumMap = { + 0: GroupChannelPushTriggerOption.defaultValue, + 1: GroupChannelPushTriggerOption.all, + 2: GroupChannelPushTriggerOption.off, + 3: GroupChannelPushTriggerOption.mentionOnly, +}; +const _CGroupChannelmyRoleEnumValueMap = { + 'none': 0, + 'operator': 1, +}; +const _CGroupChannelmyRoleValueEnumMap = { + 0: Role.none, + 1: Role.operator, +}; + +Id _cGroupChannelGetId(CGroupChannel object) { + return object.id; +} + +List> _cGroupChannelGetLinks(CGroupChannel object) { + return []; +} + +void _cGroupChannelAttach( + IsarCollection col, Id id, CGroupChannel object) { + object.id = id; +} + +extension CGroupChannelByIndex on IsarCollection { + Future getByChannelUrl(String channelUrl) { + return getByIndex(r'channelUrl', [channelUrl]); + } + + CGroupChannel? getByChannelUrlSync(String channelUrl) { + return getByIndexSync(r'channelUrl', [channelUrl]); + } + + Future deleteByChannelUrl(String channelUrl) { + return deleteByIndex(r'channelUrl', [channelUrl]); + } + + bool deleteByChannelUrlSync(String channelUrl) { + return deleteByIndexSync(r'channelUrl', [channelUrl]); + } + + Future> getAllByChannelUrl( + List channelUrlValues) { + final values = channelUrlValues.map((e) => [e]).toList(); + return getAllByIndex(r'channelUrl', values); + } + + List getAllByChannelUrlSync(List channelUrlValues) { + final values = channelUrlValues.map((e) => [e]).toList(); + return getAllByIndexSync(r'channelUrl', values); + } + + Future deleteAllByChannelUrl(List channelUrlValues) { + final values = channelUrlValues.map((e) => [e]).toList(); + return deleteAllByIndex(r'channelUrl', values); + } + + int deleteAllByChannelUrlSync(List channelUrlValues) { + final values = channelUrlValues.map((e) => [e]).toList(); + return deleteAllByIndexSync(r'channelUrl', values); + } + + Future putByChannelUrl(CGroupChannel object) { + return putByIndex(r'channelUrl', object); + } + + Id putByChannelUrlSync(CGroupChannel object, {bool saveLinks = true}) { + return putByIndexSync(r'channelUrl', object, saveLinks: saveLinks); + } + + Future> putAllByChannelUrl(List objects) { + return putAllByIndex(r'channelUrl', objects); + } + + List putAllByChannelUrlSync(List objects, + {bool saveLinks = true}) { + return putAllByIndexSync(r'channelUrl', objects, saveLinks: saveLinks); + } +} + +extension CGroupChannelQueryWhereSort + on QueryBuilder { + QueryBuilder anyId() { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(const IdWhereClause.any()); + }); + } +} + +extension CGroupChannelQueryWhere + on QueryBuilder { + QueryBuilder idEqualTo( + Id id) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IdWhereClause.between( + lower: id, + upper: id, + )); + }); + } + + QueryBuilder idNotEqualTo( + Id id) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause( + IdWhereClause.lessThan(upper: id, includeUpper: false), + ) + .addWhereClause( + IdWhereClause.greaterThan(lower: id, includeLower: false), + ); + } else { + return query + .addWhereClause( + IdWhereClause.greaterThan(lower: id, includeLower: false), + ) + .addWhereClause( + IdWhereClause.lessThan(upper: id, includeUpper: false), + ); + } + }); + } + + QueryBuilder idGreaterThan( + Id id, + {bool include = false}) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause( + IdWhereClause.greaterThan(lower: id, includeLower: include), + ); + }); + } + + QueryBuilder idLessThan( + Id id, + {bool include = false}) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause( + IdWhereClause.lessThan(upper: id, includeUpper: include), + ); + }); + } + + QueryBuilder idBetween( + Id lowerId, + Id upperId, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IdWhereClause.between( + lower: lowerId, + includeLower: includeLower, + upper: upperId, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + channelUrlEqualTo(String channelUrl) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.equalTo( + indexName: r'channelUrl', + value: [channelUrl], + )); + }); + } + + QueryBuilder + channelUrlNotEqualTo(String channelUrl) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'channelUrl', + lower: [], + upper: [channelUrl], + includeUpper: false, + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'channelUrl', + lower: [channelUrl], + includeLower: false, + upper: [], + )); + } else { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'channelUrl', + lower: [channelUrl], + includeLower: false, + upper: [], + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'channelUrl', + lower: [], + upper: [channelUrl], + includeUpper: false, + )); + } + }); + } + + QueryBuilder + channelTypeEqualToAnyChannelUrl(ChannelType channelType) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.equalTo( + indexName: r'channelType_channelUrl', + value: [channelType], + )); + }); + } + + QueryBuilder + channelTypeNotEqualToAnyChannelUrl(ChannelType channelType) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'channelType_channelUrl', + lower: [], + upper: [channelType], + includeUpper: false, + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'channelType_channelUrl', + lower: [channelType], + includeLower: false, + upper: [], + )); + } else { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'channelType_channelUrl', + lower: [channelType], + includeLower: false, + upper: [], + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'channelType_channelUrl', + lower: [], + upper: [channelType], + includeUpper: false, + )); + } + }); + } + + QueryBuilder + channelTypeGreaterThanAnyChannelUrl( + ChannelType channelType, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.between( + indexName: r'channelType_channelUrl', + lower: [channelType], + includeLower: include, + upper: [], + )); + }); + } + + QueryBuilder + channelTypeLessThanAnyChannelUrl( + ChannelType channelType, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.between( + indexName: r'channelType_channelUrl', + lower: [], + upper: [channelType], + includeUpper: include, + )); + }); + } + + QueryBuilder + channelTypeBetweenAnyChannelUrl( + ChannelType lowerChannelType, + ChannelType upperChannelType, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.between( + indexName: r'channelType_channelUrl', + lower: [lowerChannelType], + includeLower: includeLower, + upper: [upperChannelType], + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + channelTypeChannelUrlEqualTo(ChannelType channelType, String channelUrl) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.equalTo( + indexName: r'channelType_channelUrl', + value: [channelType, channelUrl], + )); + }); + } + + QueryBuilder + channelTypeEqualToChannelUrlNotEqualTo( + ChannelType channelType, String channelUrl) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'channelType_channelUrl', + lower: [channelType], + upper: [channelType, channelUrl], + includeUpper: false, + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'channelType_channelUrl', + lower: [channelType, channelUrl], + includeLower: false, + upper: [channelType], + )); + } else { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'channelType_channelUrl', + lower: [channelType, channelUrl], + includeLower: false, + upper: [channelType], + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'channelType_channelUrl', + lower: [channelType], + upper: [channelType, channelUrl], + includeUpper: false, + )); + } + }); + } +} + +extension CGroupChannelQueryFilter + on QueryBuilder { + QueryBuilder + channelTypeEqualTo(ChannelType value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'channelType', + value: value, + )); + }); + } + + QueryBuilder + channelTypeGreaterThan( + ChannelType value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'channelType', + value: value, + )); + }); + } + + QueryBuilder + channelTypeLessThan( + ChannelType value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'channelType', + value: value, + )); + }); + } + + QueryBuilder + channelTypeBetween( + ChannelType lower, + ChannelType upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'channelType', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + channelUrlEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'channelUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + channelUrlGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'channelUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + channelUrlLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'channelUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + channelUrlBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'channelUrl', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + channelUrlStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'channelUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + channelUrlEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'channelUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + channelUrlContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'channelUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + channelUrlMatches(String pattern, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'channelUrl', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + channelUrlIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'channelUrl', + value: '', + )); + }); + } + + QueryBuilder + channelUrlIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'channelUrl', + value: '', + )); + }); + } + + QueryBuilder + coverUrlIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'coverUrl', + )); + }); + } + + QueryBuilder + coverUrlIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'coverUrl', + )); + }); + } + + QueryBuilder + coverUrlEqualTo( + String? value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'coverUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + coverUrlGreaterThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'coverUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + coverUrlLessThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'coverUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + coverUrlBetween( + String? lower, + String? upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'coverUrl', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + coverUrlStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'coverUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + coverUrlEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'coverUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + coverUrlContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'coverUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + coverUrlMatches(String pattern, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'coverUrl', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + coverUrlIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'coverUrl', + value: '', + )); + }); + } + + QueryBuilder + coverUrlIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'coverUrl', + value: '', + )); + }); + } + + QueryBuilder + createdAtIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'createdAt', + )); + }); + } + + QueryBuilder + createdAtIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'createdAt', + )); + }); + } + + QueryBuilder + createdAtEqualTo(int? value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'createdAt', + value: value, + )); + }); + } + + QueryBuilder + createdAtGreaterThan( + int? value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'createdAt', + value: value, + )); + }); + } + + QueryBuilder + createdAtLessThan( + int? value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'createdAt', + value: value, + )); + }); + } + + QueryBuilder + createdAtBetween( + int? lower, + int? upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'createdAt', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + creatorIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'creator', + )); + }); + } + + QueryBuilder + creatorIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'creator', + )); + }); + } + + QueryBuilder + creatorEqualTo( + String? value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'creator', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + creatorGreaterThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'creator', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + creatorLessThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'creator', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + creatorBetween( + String? lower, + String? upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'creator', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + creatorStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'creator', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + creatorEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'creator', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + creatorContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'creator', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + creatorMatches(String pattern, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'creator', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + creatorIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'creator', + value: '', + )); + }); + } + + QueryBuilder + creatorIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'creator', + value: '', + )); + }); + } + + QueryBuilder + customTypeIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'customType', + )); + }); + } + + QueryBuilder + customTypeIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'customType', + )); + }); + } + + QueryBuilder + customTypeEqualTo( + String? value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'customType', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + customTypeGreaterThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'customType', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + customTypeLessThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'customType', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + customTypeBetween( + String? lower, + String? upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'customType', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + customTypeStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'customType', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + customTypeEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'customType', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + customTypeContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'customType', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + customTypeMatches(String pattern, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'customType', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + customTypeIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'customType', + value: '', + )); + }); + } + + QueryBuilder + customTypeIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'customType', + value: '', + )); + }); + } + + QueryBuilder + dataIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'data', + )); + }); + } + + QueryBuilder + dataIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'data', + )); + }); + } + + QueryBuilder dataEqualTo( + String? value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'data', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + dataGreaterThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'data', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + dataLessThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'data', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder dataBetween( + String? lower, + String? upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'data', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + dataStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'data', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + dataEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'data', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + dataContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'data', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder dataMatches( + String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'data', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + dataIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'data', + value: '', + )); + }); + } + + QueryBuilder + dataIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'data', + value: '', + )); + }); + } + + QueryBuilder + dirtyEqualTo(bool value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'dirty', + value: value, + )); + }); + } + + QueryBuilder + fromCacheEqualTo(bool value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'fromCache', + value: value, + )); + }); + } + + QueryBuilder + hiddenStateEqualTo(GroupChannelHiddenState value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'hiddenState', + value: value, + )); + }); + } + + QueryBuilder + hiddenStateGreaterThan( + GroupChannelHiddenState value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'hiddenState', + value: value, + )); + }); + } + + QueryBuilder + hiddenStateLessThan( + GroupChannelHiddenState value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'hiddenState', + value: value, + )); + }); + } + + QueryBuilder + hiddenStateBetween( + GroupChannelHiddenState lower, + GroupChannelHiddenState upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'hiddenState', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder idEqualTo( + Id value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'id', + value: value, + )); + }); + } + + QueryBuilder + idGreaterThan( + Id value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'id', + value: value, + )); + }); + } + + QueryBuilder idLessThan( + Id value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'id', + value: value, + )); + }); + } + + QueryBuilder idBetween( + Id lower, + Id upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'id', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + invitedAtEqualTo(int value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'invitedAt', + value: value, + )); + }); + } + + QueryBuilder + invitedAtGreaterThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'invitedAt', + value: value, + )); + }); + } + + QueryBuilder + invitedAtLessThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'invitedAt', + value: value, + )); + }); + } + + QueryBuilder + invitedAtBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'invitedAt', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + inviterIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'inviter', + )); + }); + } + + QueryBuilder + inviterIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'inviter', + )); + }); + } + + QueryBuilder + isAccessCodeRequiredEqualTo(bool value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'isAccessCodeRequired', + value: value, + )); + }); + } + + QueryBuilder + isBroadcastEqualTo(bool value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'isBroadcast', + value: value, + )); + }); + } + + QueryBuilder + isChatNotificationEqualTo(bool value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'isChatNotification', + value: value, + )); + }); + } + + QueryBuilder + isDiscoverableEqualTo(bool value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'isDiscoverable', + value: value, + )); + }); + } + + QueryBuilder + isDistinctEqualTo(bool value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'isDistinct', + value: value, + )); + }); + } + + QueryBuilder + isEphemeralIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'isEphemeral', + )); + }); + } + + QueryBuilder + isEphemeralIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'isEphemeral', + )); + }); + } + + QueryBuilder + isEphemeralEqualTo(bool? value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'isEphemeral', + value: value, + )); + }); + } + + QueryBuilder + isExclusiveEqualTo(bool value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'isExclusive', + value: value, + )); + }); + } + + QueryBuilder + isFrozenIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'isFrozen', + )); + }); + } + + QueryBuilder + isFrozenIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'isFrozen', + )); + }); + } + + QueryBuilder + isFrozenEqualTo(bool? value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'isFrozen', + value: value, + )); + }); + } + + QueryBuilder + isHiddenEqualTo(bool value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'isHidden', + value: value, + )); + }); + } + + QueryBuilder + isPublicEqualTo(bool value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'isPublic', + value: value, + )); + }); + } + + QueryBuilder + isSuperEqualTo(bool value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'isSuper', + value: value, + )); + }); + } + + QueryBuilder + joinedAtEqualTo(int value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'joinedAt', + value: value, + )); + }); + } + + QueryBuilder + joinedAtGreaterThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'joinedAt', + value: value, + )); + }); + } + + QueryBuilder + joinedAtLessThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'joinedAt', + value: value, + )); + }); + } + + QueryBuilder + joinedAtBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'joinedAt', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + joinedMemberCountEqualTo(int value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'joinedMemberCount', + value: value, + )); + }); + } + + QueryBuilder + joinedMemberCountGreaterThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'joinedMemberCount', + value: value, + )); + }); + } + + QueryBuilder + joinedMemberCountLessThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'joinedMemberCount', + value: value, + )); + }); + } + + QueryBuilder + joinedMemberCountBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'joinedMemberCount', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + lastMessageCreatedAtIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'lastMessageCreatedAt', + )); + }); + } + + QueryBuilder + lastMessageCreatedAtIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'lastMessageCreatedAt', + )); + }); + } + + QueryBuilder + lastMessageCreatedAtEqualTo(int? value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'lastMessageCreatedAt', + value: value, + )); + }); + } + + QueryBuilder + lastMessageCreatedAtGreaterThan( + int? value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'lastMessageCreatedAt', + value: value, + )); + }); + } + + QueryBuilder + lastMessageCreatedAtLessThan( + int? value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'lastMessageCreatedAt', + value: value, + )); + }); + } + + QueryBuilder + lastMessageCreatedAtBetween( + int? lower, + int? upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'lastMessageCreatedAt', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + lastMessageRootIdIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'lastMessageRootId', + )); + }); + } + + QueryBuilder + lastMessageRootIdIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'lastMessageRootId', + )); + }); + } + + QueryBuilder + lastMessageRootIdEqualTo( + String? value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'lastMessageRootId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + lastMessageRootIdGreaterThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'lastMessageRootId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + lastMessageRootIdLessThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'lastMessageRootId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + lastMessageRootIdBetween( + String? lower, + String? upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'lastMessageRootId', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + lastMessageRootIdStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'lastMessageRootId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + lastMessageRootIdEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'lastMessageRootId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + lastMessageRootIdContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'lastMessageRootId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + lastMessageRootIdMatches(String pattern, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'lastMessageRootId', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + lastMessageRootIdIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'lastMessageRootId', + value: '', + )); + }); + } + + QueryBuilder + lastMessageRootIdIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'lastMessageRootId', + value: '', + )); + }); + } + + QueryBuilder + lastMessageTypeEqualTo(MessageType value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'lastMessageType', + value: value, + )); + }); + } + + QueryBuilder + lastMessageTypeGreaterThan( + MessageType value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'lastMessageType', + value: value, + )); + }); + } + + QueryBuilder + lastMessageTypeLessThan( + MessageType value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'lastMessageType', + value: value, + )); + }); + } + + QueryBuilder + lastMessageTypeBetween( + MessageType lower, + MessageType upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'lastMessageType', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + lastPinnedMessageRootIdIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'lastPinnedMessageRootId', + )); + }); + } + + QueryBuilder + lastPinnedMessageRootIdIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'lastPinnedMessageRootId', + )); + }); + } + + QueryBuilder + lastPinnedMessageRootIdEqualTo( + String? value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'lastPinnedMessageRootId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + lastPinnedMessageRootIdGreaterThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'lastPinnedMessageRootId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + lastPinnedMessageRootIdLessThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'lastPinnedMessageRootId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + lastPinnedMessageRootIdBetween( + String? lower, + String? upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'lastPinnedMessageRootId', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + lastPinnedMessageRootIdStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'lastPinnedMessageRootId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + lastPinnedMessageRootIdEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'lastPinnedMessageRootId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + lastPinnedMessageRootIdContains(String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'lastPinnedMessageRootId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + lastPinnedMessageRootIdMatches(String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'lastPinnedMessageRootId', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + lastPinnedMessageRootIdIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'lastPinnedMessageRootId', + value: '', + )); + }); + } + + QueryBuilder + lastPinnedMessageRootIdIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'lastPinnedMessageRootId', + value: '', + )); + }); + } + + QueryBuilder + lastPinnedMessageTypeEqualTo(MessageType value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'lastPinnedMessageType', + value: value, + )); + }); + } + + QueryBuilder + lastPinnedMessageTypeGreaterThan( + MessageType value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'lastPinnedMessageType', + value: value, + )); + }); + } + + QueryBuilder + lastPinnedMessageTypeLessThan( + MessageType value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'lastPinnedMessageType', + value: value, + )); + }); + } + + QueryBuilder + lastPinnedMessageTypeBetween( + MessageType lower, + MessageType upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'lastPinnedMessageType', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + memberCountEqualTo(int value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'memberCount', + value: value, + )); + }); + } + + QueryBuilder + memberCountGreaterThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'memberCount', + value: value, + )); + }); + } + + QueryBuilder + memberCountLessThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'memberCount', + value: value, + )); + }); + } + + QueryBuilder + memberCountBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'memberCount', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + membersLengthEqualTo(int length) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'members', + length, + true, + length, + true, + ); + }); + } + + QueryBuilder + membersIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'members', + 0, + true, + 0, + true, + ); + }); + } + + QueryBuilder + membersIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'members', + 0, + false, + 999999, + true, + ); + }); + } + + QueryBuilder + membersLengthLessThan( + int length, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'members', + 0, + true, + length, + include, + ); + }); + } + + QueryBuilder + membersLengthGreaterThan( + int length, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'members', + length, + include, + 999999, + true, + ); + }); + } + + QueryBuilder + membersLengthBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'members', + lower, + includeLower, + upper, + includeUpper, + ); + }); + } + + QueryBuilder + messageOffsetTimestampIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'messageOffsetTimestamp', + )); + }); + } + + QueryBuilder + messageOffsetTimestampIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'messageOffsetTimestamp', + )); + }); + } + + QueryBuilder + messageOffsetTimestampEqualTo(int? value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'messageOffsetTimestamp', + value: value, + )); + }); + } + + QueryBuilder + messageOffsetTimestampGreaterThan( + int? value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'messageOffsetTimestamp', + value: value, + )); + }); + } + + QueryBuilder + messageOffsetTimestampLessThan( + int? value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'messageOffsetTimestamp', + value: value, + )); + }); + } + + QueryBuilder + messageOffsetTimestampBetween( + int? lower, + int? upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'messageOffsetTimestamp', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + messageSurvivalSecondsEqualTo(int value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'messageSurvivalSeconds', + value: value, + )); + }); + } + + QueryBuilder + messageSurvivalSecondsGreaterThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'messageSurvivalSeconds', + value: value, + )); + }); + } + + QueryBuilder + messageSurvivalSecondsLessThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'messageSurvivalSeconds', + value: value, + )); + }); + } + + QueryBuilder + messageSurvivalSecondsBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'messageSurvivalSeconds', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + myCountPreferenceEqualTo(CountPreference value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'myCountPreference', + value: value, + )); + }); + } + + QueryBuilder + myCountPreferenceGreaterThan( + CountPreference value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'myCountPreference', + value: value, + )); + }); + } + + QueryBuilder + myCountPreferenceLessThan( + CountPreference value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'myCountPreference', + value: value, + )); + }); + } + + QueryBuilder + myCountPreferenceBetween( + CountPreference lower, + CountPreference upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'myCountPreference', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + myLastReadEqualTo(int value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'myLastRead', + value: value, + )); + }); + } + + QueryBuilder + myLastReadGreaterThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'myLastRead', + value: value, + )); + }); + } + + QueryBuilder + myLastReadLessThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'myLastRead', + value: value, + )); + }); + } + + QueryBuilder + myLastReadBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'myLastRead', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + myMemberStateEqualTo(MemberState value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'myMemberState', + value: value, + )); + }); + } + + QueryBuilder + myMemberStateGreaterThan( + MemberState value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'myMemberState', + value: value, + )); + }); + } + + QueryBuilder + myMemberStateLessThan( + MemberState value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'myMemberState', + value: value, + )); + }); + } + + QueryBuilder + myMemberStateBetween( + MemberState lower, + MemberState upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'myMemberState', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + myMutedStateEqualTo(MuteState value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'myMutedState', + value: value, + )); + }); + } + + QueryBuilder + myMutedStateGreaterThan( + MuteState value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'myMutedState', + value: value, + )); + }); + } + + QueryBuilder + myMutedStateLessThan( + MuteState value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'myMutedState', + value: value, + )); + }); + } + + QueryBuilder + myMutedStateBetween( + MuteState lower, + MuteState upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'myMutedState', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + myPushTriggerOptionEqualTo(GroupChannelPushTriggerOption value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'myPushTriggerOption', + value: value, + )); + }); + } + + QueryBuilder + myPushTriggerOptionGreaterThan( + GroupChannelPushTriggerOption value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'myPushTriggerOption', + value: value, + )); + }); + } + + QueryBuilder + myPushTriggerOptionLessThan( + GroupChannelPushTriggerOption value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'myPushTriggerOption', + value: value, + )); + }); + } + + QueryBuilder + myPushTriggerOptionBetween( + GroupChannelPushTriggerOption lower, + GroupChannelPushTriggerOption upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'myPushTriggerOption', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + myRoleEqualTo(Role value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'myRole', + value: value, + )); + }); + } + + QueryBuilder + myRoleGreaterThan( + Role value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'myRole', + value: value, + )); + }); + } + + QueryBuilder + myRoleLessThan( + Role value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'myRole', + value: value, + )); + }); + } + + QueryBuilder + myRoleBetween( + Role lower, + Role upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'myRole', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder nameEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'name', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + nameGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'name', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + nameLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'name', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder nameBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'name', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + nameStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'name', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + nameEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'name', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + nameContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'name', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder nameMatches( + String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'name', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + nameIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'name', + value: '', + )); + }); + } + + QueryBuilder + nameIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'name', + value: '', + )); + }); + } + + QueryBuilder + pinnedMessageIdsElementEqualTo(int value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'pinnedMessageIds', + value: value, + )); + }); + } + + QueryBuilder + pinnedMessageIdsElementGreaterThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'pinnedMessageIds', + value: value, + )); + }); + } + + QueryBuilder + pinnedMessageIdsElementLessThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'pinnedMessageIds', + value: value, + )); + }); + } + + QueryBuilder + pinnedMessageIdsElementBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'pinnedMessageIds', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + pinnedMessageIdsLengthEqualTo(int length) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'pinnedMessageIds', + length, + true, + length, + true, + ); + }); + } + + QueryBuilder + pinnedMessageIdsIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'pinnedMessageIds', + 0, + true, + 0, + true, + ); + }); + } + + QueryBuilder + pinnedMessageIdsIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'pinnedMessageIds', + 0, + false, + 999999, + true, + ); + }); + } + + QueryBuilder + pinnedMessageIdsLengthLessThan( + int length, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'pinnedMessageIds', + 0, + true, + length, + include, + ); + }); + } + + QueryBuilder + pinnedMessageIdsLengthGreaterThan( + int length, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'pinnedMessageIds', + length, + include, + 999999, + true, + ); + }); + } + + QueryBuilder + pinnedMessageIdsLengthBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'pinnedMessageIds', + lower, + includeLower, + upper, + includeUpper, + ); + }); + } + + QueryBuilder + pinnedMessageUpdatedAtEqualTo(int value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'pinnedMessageUpdatedAt', + value: value, + )); + }); + } + + QueryBuilder + pinnedMessageUpdatedAtGreaterThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'pinnedMessageUpdatedAt', + value: value, + )); + }); + } + + QueryBuilder + pinnedMessageUpdatedAtLessThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'pinnedMessageUpdatedAt', + value: value, + )); + }); + } + + QueryBuilder + pinnedMessageUpdatedAtBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'pinnedMessageUpdatedAt', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + unreadMentionCountEqualTo(int value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'unreadMentionCount', + value: value, + )); + }); + } + + QueryBuilder + unreadMentionCountGreaterThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'unreadMentionCount', + value: value, + )); + }); + } + + QueryBuilder + unreadMentionCountLessThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'unreadMentionCount', + value: value, + )); + }); + } + + QueryBuilder + unreadMentionCountBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'unreadMentionCount', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + unreadMessageCountEqualTo(int value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'unreadMessageCount', + value: value, + )); + }); + } + + QueryBuilder + unreadMessageCountGreaterThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'unreadMessageCount', + value: value, + )); + }); + } + + QueryBuilder + unreadMessageCountLessThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'unreadMessageCount', + value: value, + )); + }); + } + + QueryBuilder + unreadMessageCountBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'unreadMessageCount', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } +} + +extension CGroupChannelQueryObject + on QueryBuilder { + QueryBuilder inviter( + FilterQuery q) { + return QueryBuilder.apply(this, (query) { + return query.object(q, r'inviter'); + }); + } + + QueryBuilder + membersElement(FilterQuery q) { + return QueryBuilder.apply(this, (query) { + return query.object(q, r'members'); + }); + } +} + +extension CGroupChannelQueryLinks + on QueryBuilder {} + +extension CGroupChannelQuerySortBy + on QueryBuilder { + QueryBuilder sortByChannelType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'channelType', Sort.asc); + }); + } + + QueryBuilder + sortByChannelTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'channelType', Sort.desc); + }); + } + + QueryBuilder sortByChannelUrl() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'channelUrl', Sort.asc); + }); + } + + QueryBuilder + sortByChannelUrlDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'channelUrl', Sort.desc); + }); + } + + QueryBuilder sortByCoverUrl() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'coverUrl', Sort.asc); + }); + } + + QueryBuilder + sortByCoverUrlDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'coverUrl', Sort.desc); + }); + } + + QueryBuilder sortByCreatedAt() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'createdAt', Sort.asc); + }); + } + + QueryBuilder + sortByCreatedAtDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'createdAt', Sort.desc); + }); + } + + QueryBuilder sortByCreator() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'creator', Sort.asc); + }); + } + + QueryBuilder sortByCreatorDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'creator', Sort.desc); + }); + } + + QueryBuilder sortByCustomType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'customType', Sort.asc); + }); + } + + QueryBuilder + sortByCustomTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'customType', Sort.desc); + }); + } + + QueryBuilder sortByData() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'data', Sort.asc); + }); + } + + QueryBuilder sortByDataDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'data', Sort.desc); + }); + } + + QueryBuilder sortByDirty() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'dirty', Sort.asc); + }); + } + + QueryBuilder sortByDirtyDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'dirty', Sort.desc); + }); + } + + QueryBuilder sortByFromCache() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'fromCache', Sort.asc); + }); + } + + QueryBuilder + sortByFromCacheDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'fromCache', Sort.desc); + }); + } + + QueryBuilder sortByHiddenState() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'hiddenState', Sort.asc); + }); + } + + QueryBuilder + sortByHiddenStateDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'hiddenState', Sort.desc); + }); + } + + QueryBuilder sortByInvitedAt() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'invitedAt', Sort.asc); + }); + } + + QueryBuilder + sortByInvitedAtDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'invitedAt', Sort.desc); + }); + } + + QueryBuilder + sortByIsAccessCodeRequired() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isAccessCodeRequired', Sort.asc); + }); + } + + QueryBuilder + sortByIsAccessCodeRequiredDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isAccessCodeRequired', Sort.desc); + }); + } + + QueryBuilder sortByIsBroadcast() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isBroadcast', Sort.asc); + }); + } + + QueryBuilder + sortByIsBroadcastDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isBroadcast', Sort.desc); + }); + } + + QueryBuilder + sortByIsChatNotification() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isChatNotification', Sort.asc); + }); + } + + QueryBuilder + sortByIsChatNotificationDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isChatNotification', Sort.desc); + }); + } + + QueryBuilder + sortByIsDiscoverable() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isDiscoverable', Sort.asc); + }); + } + + QueryBuilder + sortByIsDiscoverableDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isDiscoverable', Sort.desc); + }); + } + + QueryBuilder sortByIsDistinct() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isDistinct', Sort.asc); + }); + } + + QueryBuilder + sortByIsDistinctDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isDistinct', Sort.desc); + }); + } + + QueryBuilder sortByIsEphemeral() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isEphemeral', Sort.asc); + }); + } + + QueryBuilder + sortByIsEphemeralDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isEphemeral', Sort.desc); + }); + } + + QueryBuilder sortByIsExclusive() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isExclusive', Sort.asc); + }); + } + + QueryBuilder + sortByIsExclusiveDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isExclusive', Sort.desc); + }); + } + + QueryBuilder sortByIsFrozen() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isFrozen', Sort.asc); + }); + } + + QueryBuilder + sortByIsFrozenDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isFrozen', Sort.desc); + }); + } + + QueryBuilder sortByIsHidden() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isHidden', Sort.asc); + }); + } + + QueryBuilder + sortByIsHiddenDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isHidden', Sort.desc); + }); + } + + QueryBuilder sortByIsPublic() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isPublic', Sort.asc); + }); + } + + QueryBuilder + sortByIsPublicDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isPublic', Sort.desc); + }); + } + + QueryBuilder sortByIsSuper() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isSuper', Sort.asc); + }); + } + + QueryBuilder sortByIsSuperDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isSuper', Sort.desc); + }); + } + + QueryBuilder sortByJoinedAt() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'joinedAt', Sort.asc); + }); + } + + QueryBuilder + sortByJoinedAtDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'joinedAt', Sort.desc); + }); + } + + QueryBuilder + sortByJoinedMemberCount() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'joinedMemberCount', Sort.asc); + }); + } + + QueryBuilder + sortByJoinedMemberCountDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'joinedMemberCount', Sort.desc); + }); + } + + QueryBuilder + sortByLastMessageCreatedAt() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'lastMessageCreatedAt', Sort.asc); + }); + } + + QueryBuilder + sortByLastMessageCreatedAtDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'lastMessageCreatedAt', Sort.desc); + }); + } + + QueryBuilder + sortByLastMessageRootId() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'lastMessageRootId', Sort.asc); + }); + } + + QueryBuilder + sortByLastMessageRootIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'lastMessageRootId', Sort.desc); + }); + } + + QueryBuilder + sortByLastMessageType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'lastMessageType', Sort.asc); + }); + } + + QueryBuilder + sortByLastMessageTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'lastMessageType', Sort.desc); + }); + } + + QueryBuilder + sortByLastPinnedMessageRootId() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'lastPinnedMessageRootId', Sort.asc); + }); + } + + QueryBuilder + sortByLastPinnedMessageRootIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'lastPinnedMessageRootId', Sort.desc); + }); + } + + QueryBuilder + sortByLastPinnedMessageType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'lastPinnedMessageType', Sort.asc); + }); + } + + QueryBuilder + sortByLastPinnedMessageTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'lastPinnedMessageType', Sort.desc); + }); + } + + QueryBuilder sortByMemberCount() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'memberCount', Sort.asc); + }); + } + + QueryBuilder + sortByMemberCountDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'memberCount', Sort.desc); + }); + } + + QueryBuilder + sortByMessageOffsetTimestamp() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'messageOffsetTimestamp', Sort.asc); + }); + } + + QueryBuilder + sortByMessageOffsetTimestampDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'messageOffsetTimestamp', Sort.desc); + }); + } + + QueryBuilder + sortByMessageSurvivalSeconds() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'messageSurvivalSeconds', Sort.asc); + }); + } + + QueryBuilder + sortByMessageSurvivalSecondsDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'messageSurvivalSeconds', Sort.desc); + }); + } + + QueryBuilder + sortByMyCountPreference() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'myCountPreference', Sort.asc); + }); + } + + QueryBuilder + sortByMyCountPreferenceDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'myCountPreference', Sort.desc); + }); + } + + QueryBuilder sortByMyLastRead() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'myLastRead', Sort.asc); + }); + } + + QueryBuilder + sortByMyLastReadDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'myLastRead', Sort.desc); + }); + } + + QueryBuilder + sortByMyMemberState() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'myMemberState', Sort.asc); + }); + } + + QueryBuilder + sortByMyMemberStateDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'myMemberState', Sort.desc); + }); + } + + QueryBuilder + sortByMyMutedState() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'myMutedState', Sort.asc); + }); + } + + QueryBuilder + sortByMyMutedStateDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'myMutedState', Sort.desc); + }); + } + + QueryBuilder + sortByMyPushTriggerOption() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'myPushTriggerOption', Sort.asc); + }); + } + + QueryBuilder + sortByMyPushTriggerOptionDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'myPushTriggerOption', Sort.desc); + }); + } + + QueryBuilder sortByMyRole() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'myRole', Sort.asc); + }); + } + + QueryBuilder sortByMyRoleDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'myRole', Sort.desc); + }); + } + + QueryBuilder sortByName() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'name', Sort.asc); + }); + } + + QueryBuilder sortByNameDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'name', Sort.desc); + }); + } + + QueryBuilder + sortByPinnedMessageUpdatedAt() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'pinnedMessageUpdatedAt', Sort.asc); + }); + } + + QueryBuilder + sortByPinnedMessageUpdatedAtDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'pinnedMessageUpdatedAt', Sort.desc); + }); + } + + QueryBuilder + sortByUnreadMentionCount() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'unreadMentionCount', Sort.asc); + }); + } + + QueryBuilder + sortByUnreadMentionCountDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'unreadMentionCount', Sort.desc); + }); + } + + QueryBuilder + sortByUnreadMessageCount() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'unreadMessageCount', Sort.asc); + }); + } + + QueryBuilder + sortByUnreadMessageCountDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'unreadMessageCount', Sort.desc); + }); + } +} + +extension CGroupChannelQuerySortThenBy + on QueryBuilder { + QueryBuilder thenByChannelType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'channelType', Sort.asc); + }); + } + + QueryBuilder + thenByChannelTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'channelType', Sort.desc); + }); + } + + QueryBuilder thenByChannelUrl() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'channelUrl', Sort.asc); + }); + } + + QueryBuilder + thenByChannelUrlDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'channelUrl', Sort.desc); + }); + } + + QueryBuilder thenByCoverUrl() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'coverUrl', Sort.asc); + }); + } + + QueryBuilder + thenByCoverUrlDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'coverUrl', Sort.desc); + }); + } + + QueryBuilder thenByCreatedAt() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'createdAt', Sort.asc); + }); + } + + QueryBuilder + thenByCreatedAtDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'createdAt', Sort.desc); + }); + } + + QueryBuilder thenByCreator() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'creator', Sort.asc); + }); + } + + QueryBuilder thenByCreatorDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'creator', Sort.desc); + }); + } + + QueryBuilder thenByCustomType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'customType', Sort.asc); + }); + } + + QueryBuilder + thenByCustomTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'customType', Sort.desc); + }); + } + + QueryBuilder thenByData() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'data', Sort.asc); + }); + } + + QueryBuilder thenByDataDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'data', Sort.desc); + }); + } + + QueryBuilder thenByDirty() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'dirty', Sort.asc); + }); + } + + QueryBuilder thenByDirtyDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'dirty', Sort.desc); + }); + } + + QueryBuilder thenByFromCache() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'fromCache', Sort.asc); + }); + } + + QueryBuilder + thenByFromCacheDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'fromCache', Sort.desc); + }); + } + + QueryBuilder thenByHiddenState() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'hiddenState', Sort.asc); + }); + } + + QueryBuilder + thenByHiddenStateDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'hiddenState', Sort.desc); + }); + } + + QueryBuilder thenById() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'id', Sort.asc); + }); + } + + QueryBuilder thenByIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'id', Sort.desc); + }); + } + + QueryBuilder thenByInvitedAt() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'invitedAt', Sort.asc); + }); + } + + QueryBuilder + thenByInvitedAtDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'invitedAt', Sort.desc); + }); + } + + QueryBuilder + thenByIsAccessCodeRequired() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isAccessCodeRequired', Sort.asc); + }); + } + + QueryBuilder + thenByIsAccessCodeRequiredDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isAccessCodeRequired', Sort.desc); + }); + } + + QueryBuilder thenByIsBroadcast() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isBroadcast', Sort.asc); + }); + } + + QueryBuilder + thenByIsBroadcastDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isBroadcast', Sort.desc); + }); + } + + QueryBuilder + thenByIsChatNotification() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isChatNotification', Sort.asc); + }); + } + + QueryBuilder + thenByIsChatNotificationDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isChatNotification', Sort.desc); + }); + } + + QueryBuilder + thenByIsDiscoverable() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isDiscoverable', Sort.asc); + }); + } + + QueryBuilder + thenByIsDiscoverableDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isDiscoverable', Sort.desc); + }); + } + + QueryBuilder thenByIsDistinct() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isDistinct', Sort.asc); + }); + } + + QueryBuilder + thenByIsDistinctDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isDistinct', Sort.desc); + }); + } + + QueryBuilder thenByIsEphemeral() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isEphemeral', Sort.asc); + }); + } + + QueryBuilder + thenByIsEphemeralDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isEphemeral', Sort.desc); + }); + } + + QueryBuilder thenByIsExclusive() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isExclusive', Sort.asc); + }); + } + + QueryBuilder + thenByIsExclusiveDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isExclusive', Sort.desc); + }); + } + + QueryBuilder thenByIsFrozen() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isFrozen', Sort.asc); + }); + } + + QueryBuilder + thenByIsFrozenDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isFrozen', Sort.desc); + }); + } + + QueryBuilder thenByIsHidden() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isHidden', Sort.asc); + }); + } + + QueryBuilder + thenByIsHiddenDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isHidden', Sort.desc); + }); + } + + QueryBuilder thenByIsPublic() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isPublic', Sort.asc); + }); + } + + QueryBuilder + thenByIsPublicDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isPublic', Sort.desc); + }); + } + + QueryBuilder thenByIsSuper() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isSuper', Sort.asc); + }); + } + + QueryBuilder thenByIsSuperDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isSuper', Sort.desc); + }); + } + + QueryBuilder thenByJoinedAt() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'joinedAt', Sort.asc); + }); + } + + QueryBuilder + thenByJoinedAtDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'joinedAt', Sort.desc); + }); + } + + QueryBuilder + thenByJoinedMemberCount() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'joinedMemberCount', Sort.asc); + }); + } + + QueryBuilder + thenByJoinedMemberCountDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'joinedMemberCount', Sort.desc); + }); + } + + QueryBuilder + thenByLastMessageCreatedAt() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'lastMessageCreatedAt', Sort.asc); + }); + } + + QueryBuilder + thenByLastMessageCreatedAtDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'lastMessageCreatedAt', Sort.desc); + }); + } + + QueryBuilder + thenByLastMessageRootId() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'lastMessageRootId', Sort.asc); + }); + } + + QueryBuilder + thenByLastMessageRootIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'lastMessageRootId', Sort.desc); + }); + } + + QueryBuilder + thenByLastMessageType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'lastMessageType', Sort.asc); + }); + } + + QueryBuilder + thenByLastMessageTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'lastMessageType', Sort.desc); + }); + } + + QueryBuilder + thenByLastPinnedMessageRootId() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'lastPinnedMessageRootId', Sort.asc); + }); + } + + QueryBuilder + thenByLastPinnedMessageRootIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'lastPinnedMessageRootId', Sort.desc); + }); + } + + QueryBuilder + thenByLastPinnedMessageType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'lastPinnedMessageType', Sort.asc); + }); + } + + QueryBuilder + thenByLastPinnedMessageTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'lastPinnedMessageType', Sort.desc); + }); + } + + QueryBuilder thenByMemberCount() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'memberCount', Sort.asc); + }); + } + + QueryBuilder + thenByMemberCountDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'memberCount', Sort.desc); + }); + } + + QueryBuilder + thenByMessageOffsetTimestamp() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'messageOffsetTimestamp', Sort.asc); + }); + } + + QueryBuilder + thenByMessageOffsetTimestampDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'messageOffsetTimestamp', Sort.desc); + }); + } + + QueryBuilder + thenByMessageSurvivalSeconds() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'messageSurvivalSeconds', Sort.asc); + }); + } + + QueryBuilder + thenByMessageSurvivalSecondsDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'messageSurvivalSeconds', Sort.desc); + }); + } + + QueryBuilder + thenByMyCountPreference() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'myCountPreference', Sort.asc); + }); + } + + QueryBuilder + thenByMyCountPreferenceDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'myCountPreference', Sort.desc); + }); + } + + QueryBuilder thenByMyLastRead() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'myLastRead', Sort.asc); + }); + } + + QueryBuilder + thenByMyLastReadDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'myLastRead', Sort.desc); + }); + } + + QueryBuilder + thenByMyMemberState() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'myMemberState', Sort.asc); + }); + } + + QueryBuilder + thenByMyMemberStateDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'myMemberState', Sort.desc); + }); + } + + QueryBuilder + thenByMyMutedState() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'myMutedState', Sort.asc); + }); + } + + QueryBuilder + thenByMyMutedStateDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'myMutedState', Sort.desc); + }); + } + + QueryBuilder + thenByMyPushTriggerOption() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'myPushTriggerOption', Sort.asc); + }); + } + + QueryBuilder + thenByMyPushTriggerOptionDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'myPushTriggerOption', Sort.desc); + }); + } + + QueryBuilder thenByMyRole() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'myRole', Sort.asc); + }); + } + + QueryBuilder thenByMyRoleDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'myRole', Sort.desc); + }); + } + + QueryBuilder thenByName() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'name', Sort.asc); + }); + } + + QueryBuilder thenByNameDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'name', Sort.desc); + }); + } + + QueryBuilder + thenByPinnedMessageUpdatedAt() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'pinnedMessageUpdatedAt', Sort.asc); + }); + } + + QueryBuilder + thenByPinnedMessageUpdatedAtDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'pinnedMessageUpdatedAt', Sort.desc); + }); + } + + QueryBuilder + thenByUnreadMentionCount() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'unreadMentionCount', Sort.asc); + }); + } + + QueryBuilder + thenByUnreadMentionCountDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'unreadMentionCount', Sort.desc); + }); + } + + QueryBuilder + thenByUnreadMessageCount() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'unreadMessageCount', Sort.asc); + }); + } + + QueryBuilder + thenByUnreadMessageCountDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'unreadMessageCount', Sort.desc); + }); + } +} + +extension CGroupChannelQueryWhereDistinct + on QueryBuilder { + QueryBuilder + distinctByChannelType() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'channelType'); + }); + } + + QueryBuilder distinctByChannelUrl( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'channelUrl', caseSensitive: caseSensitive); + }); + } + + QueryBuilder distinctByCoverUrl( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'coverUrl', caseSensitive: caseSensitive); + }); + } + + QueryBuilder distinctByCreatedAt() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'createdAt'); + }); + } + + QueryBuilder distinctByCreator( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'creator', caseSensitive: caseSensitive); + }); + } + + QueryBuilder distinctByCustomType( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'customType', caseSensitive: caseSensitive); + }); + } + + QueryBuilder distinctByData( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'data', caseSensitive: caseSensitive); + }); + } + + QueryBuilder distinctByDirty() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'dirty'); + }); + } + + QueryBuilder distinctByFromCache() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'fromCache'); + }); + } + + QueryBuilder + distinctByHiddenState() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'hiddenState'); + }); + } + + QueryBuilder distinctByInvitedAt() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'invitedAt'); + }); + } + + QueryBuilder + distinctByIsAccessCodeRequired() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'isAccessCodeRequired'); + }); + } + + QueryBuilder + distinctByIsBroadcast() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'isBroadcast'); + }); + } + + QueryBuilder + distinctByIsChatNotification() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'isChatNotification'); + }); + } + + QueryBuilder + distinctByIsDiscoverable() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'isDiscoverable'); + }); + } + + QueryBuilder distinctByIsDistinct() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'isDistinct'); + }); + } + + QueryBuilder + distinctByIsEphemeral() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'isEphemeral'); + }); + } + + QueryBuilder + distinctByIsExclusive() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'isExclusive'); + }); + } + + QueryBuilder distinctByIsFrozen() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'isFrozen'); + }); + } + + QueryBuilder distinctByIsHidden() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'isHidden'); + }); + } + + QueryBuilder distinctByIsPublic() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'isPublic'); + }); + } + + QueryBuilder distinctByIsSuper() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'isSuper'); + }); + } + + QueryBuilder distinctByJoinedAt() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'joinedAt'); + }); + } + + QueryBuilder + distinctByJoinedMemberCount() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'joinedMemberCount'); + }); + } + + QueryBuilder + distinctByLastMessageCreatedAt() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'lastMessageCreatedAt'); + }); + } + + QueryBuilder + distinctByLastMessageRootId({bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'lastMessageRootId', + caseSensitive: caseSensitive); + }); + } + + QueryBuilder + distinctByLastMessageType() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'lastMessageType'); + }); + } + + QueryBuilder + distinctByLastPinnedMessageRootId({bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'lastPinnedMessageRootId', + caseSensitive: caseSensitive); + }); + } + + QueryBuilder + distinctByLastPinnedMessageType() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'lastPinnedMessageType'); + }); + } + + QueryBuilder + distinctByMemberCount() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'memberCount'); + }); + } + + QueryBuilder + distinctByMessageOffsetTimestamp() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'messageOffsetTimestamp'); + }); + } + + QueryBuilder + distinctByMessageSurvivalSeconds() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'messageSurvivalSeconds'); + }); + } + + QueryBuilder + distinctByMyCountPreference() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'myCountPreference'); + }); + } + + QueryBuilder distinctByMyLastRead() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'myLastRead'); + }); + } + + QueryBuilder + distinctByMyMemberState() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'myMemberState'); + }); + } + + QueryBuilder + distinctByMyMutedState() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'myMutedState'); + }); + } + + QueryBuilder + distinctByMyPushTriggerOption() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'myPushTriggerOption'); + }); + } + + QueryBuilder distinctByMyRole() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'myRole'); + }); + } + + QueryBuilder distinctByName( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'name', caseSensitive: caseSensitive); + }); + } + + QueryBuilder + distinctByPinnedMessageIds() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'pinnedMessageIds'); + }); + } + + QueryBuilder + distinctByPinnedMessageUpdatedAt() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'pinnedMessageUpdatedAt'); + }); + } + + QueryBuilder + distinctByUnreadMentionCount() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'unreadMentionCount'); + }); + } + + QueryBuilder + distinctByUnreadMessageCount() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'unreadMessageCount'); + }); + } +} + +extension CGroupChannelQueryProperty + on QueryBuilder { + QueryBuilder idProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'id'); + }); + } + + QueryBuilder + channelTypeProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'channelType'); + }); + } + + QueryBuilder channelUrlProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'channelUrl'); + }); + } + + QueryBuilder coverUrlProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'coverUrl'); + }); + } + + QueryBuilder createdAtProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'createdAt'); + }); + } + + QueryBuilder creatorProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'creator'); + }); + } + + QueryBuilder customTypeProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'customType'); + }); + } + + QueryBuilder dataProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'data'); + }); + } + + QueryBuilder dirtyProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'dirty'); + }); + } + + QueryBuilder fromCacheProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'fromCache'); + }); + } + + QueryBuilder + hiddenStateProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'hiddenState'); + }); + } + + QueryBuilder invitedAtProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'invitedAt'); + }); + } + + QueryBuilder inviterProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'inviter'); + }); + } + + QueryBuilder + isAccessCodeRequiredProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'isAccessCodeRequired'); + }); + } + + QueryBuilder isBroadcastProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'isBroadcast'); + }); + } + + QueryBuilder + isChatNotificationProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'isChatNotification'); + }); + } + + QueryBuilder isDiscoverableProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'isDiscoverable'); + }); + } + + QueryBuilder isDistinctProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'isDistinct'); + }); + } + + QueryBuilder isEphemeralProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'isEphemeral'); + }); + } + + QueryBuilder isExclusiveProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'isExclusive'); + }); + } + + QueryBuilder isFrozenProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'isFrozen'); + }); + } + + QueryBuilder isHiddenProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'isHidden'); + }); + } + + QueryBuilder isPublicProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'isPublic'); + }); + } + + QueryBuilder isSuperProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'isSuper'); + }); + } + + QueryBuilder joinedAtProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'joinedAt'); + }); + } + + QueryBuilder + joinedMemberCountProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'joinedMemberCount'); + }); + } + + QueryBuilder + lastMessageCreatedAtProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'lastMessageCreatedAt'); + }); + } + + QueryBuilder + lastMessageRootIdProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'lastMessageRootId'); + }); + } + + QueryBuilder + lastMessageTypeProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'lastMessageType'); + }); + } + + QueryBuilder + lastPinnedMessageRootIdProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'lastPinnedMessageRootId'); + }); + } + + QueryBuilder + lastPinnedMessageTypeProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'lastPinnedMessageType'); + }); + } + + QueryBuilder memberCountProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'memberCount'); + }); + } + + QueryBuilder, QQueryOperations> + membersProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'members'); + }); + } + + QueryBuilder + messageOffsetTimestampProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'messageOffsetTimestamp'); + }); + } + + QueryBuilder + messageSurvivalSecondsProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'messageSurvivalSeconds'); + }); + } + + QueryBuilder + myCountPreferenceProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'myCountPreference'); + }); + } + + QueryBuilder myLastReadProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'myLastRead'); + }); + } + + QueryBuilder + myMemberStateProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'myMemberState'); + }); + } + + QueryBuilder + myMutedStateProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'myMutedState'); + }); + } + + QueryBuilder + myPushTriggerOptionProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'myPushTriggerOption'); + }); + } + + QueryBuilder myRoleProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'myRole'); + }); + } + + QueryBuilder nameProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'name'); + }); + } + + QueryBuilder, QQueryOperations> + pinnedMessageIdsProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'pinnedMessageIds'); + }); + } + + QueryBuilder + pinnedMessageUpdatedAtProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'pinnedMessageUpdatedAt'); + }); + } + + QueryBuilder + unreadMentionCountProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'unreadMentionCount'); + }); + } + + QueryBuilder + unreadMessageCountProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'unreadMessageCount'); + }); + } +} diff --git a/lib/src/internal/db/schema/channel/meta/c_channel_info.dart b/lib/src/internal/db/schema/channel/meta/c_channel_info.dart new file mode 100644 index 00000000..1df52c12 --- /dev/null +++ b/lib/src/internal/db/schema/channel/meta/c_channel_info.dart @@ -0,0 +1,54 @@ +// Copyright (c) 2023 Sendbird, Inc. All rights reserved. + +import 'package:isar/isar.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/channel/meta/channel_info.dart'; +import 'package:sendbird_chat_sdk/src/internal/main/chat/chat.dart'; + +part 'c_channel_info.g.dart'; + +@collection +class CChannelInfo { + Id id = Isar.autoIncrement; + + String? lastChannelToken; + late bool isChannelBackSyncCompleted; + + CChannelInfo(); + + factory CChannelInfo.fromChangeLogInfo(ChannelInfo info) { + return CChannelInfo() + ..lastChannelToken = info.lastChannelToken + ..isChannelBackSyncCompleted = info.isChannelBackSyncCompleted; + } + + Future toChangeLogInfo(Chat chat, Isar isar) async { + return ChannelInfo( + lastChannelToken: lastChannelToken, + isChannelBackSyncCompleted: isChannelBackSyncCompleted, + ); + } + + static Future upsert( + Chat chat, Isar isar, ChannelInfo info) async { + final cChangeLog = CChannelInfo.fromChangeLogInfo(info); + + // ChangeLogInfo + await chat.dbManager.write(() async { + await isar.cChannelInfos.clear(); + await isar.cChannelInfos.put(cChangeLog); + }, force: true); + + return cChangeLog; + } + + static Future get(Chat chat, Isar isar) async { + final cChangeLog = await isar.cChannelInfos.where().findFirst(); + return await cChangeLog?.toChangeLogInfo(chat, isar); + } + + static Future delete(Chat chat, Isar isar) async { + await chat.dbManager.write(() async { + await isar.cChannelInfos.clear(); + }); + } +} diff --git a/lib/src/internal/db/schema/channel/meta/c_channel_info.g.dart b/lib/src/internal/db/schema/channel/meta/c_channel_info.g.dart new file mode 100644 index 00000000..d419b63e --- /dev/null +++ b/lib/src/internal/db/schema/channel/meta/c_channel_info.g.dart @@ -0,0 +1,530 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'c_channel_info.dart'; + +// ************************************************************************** +// IsarCollectionGenerator +// ************************************************************************** + +// coverage:ignore-file +// ignore_for_file: duplicate_ignore, non_constant_identifier_names, constant_identifier_names, invalid_use_of_protected_member, unnecessary_cast, prefer_const_constructors, lines_longer_than_80_chars, require_trailing_commas, inference_failure_on_function_invocation, unnecessary_parenthesis, unnecessary_raw_strings, unnecessary_null_checks, join_return_with_assignment, prefer_final_locals, avoid_js_rounded_ints, avoid_positional_boolean_parameters, always_specify_types + +extension GetCChannelInfoCollection on Isar { + IsarCollection get cChannelInfos => this.collection(); +} + +final CChannelInfoSchema = CollectionSchema( + name: r'CChannelInfo', + id: BigInt.parse('1788819051338150060').toInt(), + properties: { + r'isChannelBackSyncCompleted': PropertySchema( + id: 0, + name: r'isChannelBackSyncCompleted', + type: IsarType.bool, + ), + r'lastChannelToken': PropertySchema( + id: 1, + name: r'lastChannelToken', + type: IsarType.string, + ) + }, + estimateSize: _cChannelInfoEstimateSize, + serialize: _cChannelInfoSerialize, + deserialize: _cChannelInfoDeserialize, + deserializeProp: _cChannelInfoDeserializeProp, + idName: r'id', + indexes: {}, + links: {}, + embeddedSchemas: {}, + getId: _cChannelInfoGetId, + getLinks: _cChannelInfoGetLinks, + attach: _cChannelInfoAttach, + version: '3.1.0+1', +); + +int _cChannelInfoEstimateSize( + CChannelInfo object, + List offsets, + Map> allOffsets, +) { + var bytesCount = offsets.last; + { + final value = object.lastChannelToken; + if (value != null) { + bytesCount += 3 + value.length * 3; + } + } + return bytesCount; +} + +void _cChannelInfoSerialize( + CChannelInfo object, + IsarWriter writer, + List offsets, + Map> allOffsets, +) { + writer.writeBool(offsets[0], object.isChannelBackSyncCompleted); + writer.writeString(offsets[1], object.lastChannelToken); +} + +CChannelInfo _cChannelInfoDeserialize( + Id id, + IsarReader reader, + List offsets, + Map> allOffsets, +) { + final object = CChannelInfo(); + object.id = id; + object.isChannelBackSyncCompleted = reader.readBool(offsets[0]); + object.lastChannelToken = reader.readStringOrNull(offsets[1]); + return object; +} + +P _cChannelInfoDeserializeProp

( + IsarReader reader, + int propertyId, + int offset, + Map> allOffsets, +) { + switch (propertyId) { + case 0: + return (reader.readBool(offset)) as P; + case 1: + return (reader.readStringOrNull(offset)) as P; + default: + throw IsarError('Unknown property with id $propertyId'); + } +} + +Id _cChannelInfoGetId(CChannelInfo object) { + return object.id; +} + +List> _cChannelInfoGetLinks(CChannelInfo object) { + return []; +} + +void _cChannelInfoAttach( + IsarCollection col, Id id, CChannelInfo object) { + object.id = id; +} + +extension CChannelInfoQueryWhereSort + on QueryBuilder { + QueryBuilder anyId() { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(const IdWhereClause.any()); + }); + } +} + +extension CChannelInfoQueryWhere + on QueryBuilder { + QueryBuilder idEqualTo(Id id) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IdWhereClause.between( + lower: id, + upper: id, + )); + }); + } + + QueryBuilder idNotEqualTo( + Id id) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause( + IdWhereClause.lessThan(upper: id, includeUpper: false), + ) + .addWhereClause( + IdWhereClause.greaterThan(lower: id, includeLower: false), + ); + } else { + return query + .addWhereClause( + IdWhereClause.greaterThan(lower: id, includeLower: false), + ) + .addWhereClause( + IdWhereClause.lessThan(upper: id, includeUpper: false), + ); + } + }); + } + + QueryBuilder idGreaterThan( + Id id, + {bool include = false}) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause( + IdWhereClause.greaterThan(lower: id, includeLower: include), + ); + }); + } + + QueryBuilder idLessThan(Id id, + {bool include = false}) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause( + IdWhereClause.lessThan(upper: id, includeUpper: include), + ); + }); + } + + QueryBuilder idBetween( + Id lowerId, + Id upperId, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IdWhereClause.between( + lower: lowerId, + includeLower: includeLower, + upper: upperId, + includeUpper: includeUpper, + )); + }); + } +} + +extension CChannelInfoQueryFilter + on QueryBuilder { + QueryBuilder idEqualTo( + Id value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'id', + value: value, + )); + }); + } + + QueryBuilder idGreaterThan( + Id value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'id', + value: value, + )); + }); + } + + QueryBuilder idLessThan( + Id value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'id', + value: value, + )); + }); + } + + QueryBuilder idBetween( + Id lower, + Id upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'id', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + isChannelBackSyncCompletedEqualTo(bool value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'isChannelBackSyncCompleted', + value: value, + )); + }); + } + + QueryBuilder + lastChannelTokenIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'lastChannelToken', + )); + }); + } + + QueryBuilder + lastChannelTokenIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'lastChannelToken', + )); + }); + } + + QueryBuilder + lastChannelTokenEqualTo( + String? value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'lastChannelToken', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + lastChannelTokenGreaterThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'lastChannelToken', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + lastChannelTokenLessThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'lastChannelToken', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + lastChannelTokenBetween( + String? lower, + String? upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'lastChannelToken', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + lastChannelTokenStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'lastChannelToken', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + lastChannelTokenEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'lastChannelToken', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + lastChannelTokenContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'lastChannelToken', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + lastChannelTokenMatches(String pattern, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'lastChannelToken', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + lastChannelTokenIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'lastChannelToken', + value: '', + )); + }); + } + + QueryBuilder + lastChannelTokenIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'lastChannelToken', + value: '', + )); + }); + } +} + +extension CChannelInfoQueryObject + on QueryBuilder {} + +extension CChannelInfoQueryLinks + on QueryBuilder {} + +extension CChannelInfoQuerySortBy + on QueryBuilder { + QueryBuilder + sortByIsChannelBackSyncCompleted() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isChannelBackSyncCompleted', Sort.asc); + }); + } + + QueryBuilder + sortByIsChannelBackSyncCompletedDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isChannelBackSyncCompleted', Sort.desc); + }); + } + + QueryBuilder + sortByLastChannelToken() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'lastChannelToken', Sort.asc); + }); + } + + QueryBuilder + sortByLastChannelTokenDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'lastChannelToken', Sort.desc); + }); + } +} + +extension CChannelInfoQuerySortThenBy + on QueryBuilder { + QueryBuilder thenById() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'id', Sort.asc); + }); + } + + QueryBuilder thenByIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'id', Sort.desc); + }); + } + + QueryBuilder + thenByIsChannelBackSyncCompleted() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isChannelBackSyncCompleted', Sort.asc); + }); + } + + QueryBuilder + thenByIsChannelBackSyncCompletedDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isChannelBackSyncCompleted', Sort.desc); + }); + } + + QueryBuilder + thenByLastChannelToken() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'lastChannelToken', Sort.asc); + }); + } + + QueryBuilder + thenByLastChannelTokenDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'lastChannelToken', Sort.desc); + }); + } +} + +extension CChannelInfoQueryWhereDistinct + on QueryBuilder { + QueryBuilder + distinctByIsChannelBackSyncCompleted() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'isChannelBackSyncCompleted'); + }); + } + + QueryBuilder + distinctByLastChannelToken({bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'lastChannelToken', + caseSensitive: caseSensitive); + }); + } +} + +extension CChannelInfoQueryProperty + on QueryBuilder { + QueryBuilder idProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'id'); + }); + } + + QueryBuilder + isChannelBackSyncCompletedProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'isChannelBackSyncCompleted'); + }); + } + + QueryBuilder + lastChannelTokenProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'lastChannelToken'); + }); + } +} diff --git a/lib/src/internal/db/schema/channel/meta/channel_changelog_info.dart b/lib/src/internal/db/schema/channel/meta/channel_changelog_info.dart new file mode 100644 index 00000000..7c91d0b4 --- /dev/null +++ b/lib/src/internal/db/schema/channel/meta/channel_changelog_info.dart @@ -0,0 +1,9 @@ +// Copyright (c) 2023 Sendbird, Inc. All rights reserved. + +class ChannelChangeLogInfo { + final String lastChannelToken; + + ChannelChangeLogInfo({ + required this.lastChannelToken, + }); +} diff --git a/lib/src/internal/db/schema/channel/meta/channel_info.dart b/lib/src/internal/db/schema/channel/meta/channel_info.dart new file mode 100644 index 00000000..f3af6d94 --- /dev/null +++ b/lib/src/internal/db/schema/channel/meta/channel_info.dart @@ -0,0 +1,11 @@ +// Copyright (c) 2023 Sendbird, Inc. All rights reserved. + +class ChannelInfo { + String? lastChannelToken; + bool isChannelBackSyncCompleted; + + ChannelInfo({ + this.lastChannelToken, + this.isChannelBackSyncCompleted = false, + }); +} diff --git a/lib/src/internal/db/schema/chunk/base_chunk.dart b/lib/src/internal/db/schema/chunk/base_chunk.dart new file mode 100644 index 00000000..79c4cd23 --- /dev/null +++ b/lib/src/internal/db/schema/chunk/base_chunk.dart @@ -0,0 +1,11 @@ +// Copyright (c) 2023 Sendbird, Inc. All rights reserved. + +import 'package:sendbird_chat_sdk/src/internal/db/schema/chunk/chunk.dart'; + +class BaseChunk { + List chunks; + + BaseChunk({ + List? chunks, + }) : chunks = chunks ?? []; +} diff --git a/lib/src/internal/db/schema/chunk/c_base_chunk.dart b/lib/src/internal/db/schema/chunk/c_base_chunk.dart new file mode 100644 index 00000000..b1c31e91 --- /dev/null +++ b/lib/src/internal/db/schema/chunk/c_base_chunk.dart @@ -0,0 +1,55 @@ +// Copyright (c) 2023 Sendbird, Inc. All rights reserved. + +import 'package:isar/isar.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/chunk/base_chunk.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/chunk/chunk.dart'; +import 'package:sendbird_chat_sdk/src/internal/main/chat/chat.dart'; + +part 'c_base_chunk.g.dart'; + +class CBaseChunk { + Id id = Isar.autoIncrement; + + late List chunks; + + CBaseChunk(); + + factory CBaseChunk.fromChunk(BaseChunk chunk) { + return CBaseChunk()..setChunk(chunk); + } + + void setChunk(BaseChunk chunk) { + chunks = chunk.chunks.map((e) => CChunk.fromChunk(e)).toList(); + } + + Future toChunk(Chat chat, Isar isar) async { + final chunk = BaseChunk(); + return setCChunk(chat, isar, chunk, this); + } + + static BaseChunk setCChunk( + Chat chat, Isar isar, BaseChunk chunk, CBaseChunk cChunk) { + return chunk..chunks = cChunk.chunks.map((e) => e.toChunk()).toList(); + } +} + +@embedded +class CChunk { + late int oldestTs; + late int latestTs; + + CChunk(); + + factory CChunk.fromChunk(Chunk chunk) { + return CChunk() + ..oldestTs = chunk.oldestTs + ..latestTs = chunk.latestTs; + } + + Chunk toChunk() { + return Chunk( + oldestTs: oldestTs, + latestTs: latestTs, + ); + } +} diff --git a/lib/src/internal/db/schema/chunk/c_base_chunk.g.dart b/lib/src/internal/db/schema/chunk/c_base_chunk.g.dart new file mode 100644 index 00000000..e709e90c --- /dev/null +++ b/lib/src/internal/db/schema/chunk/c_base_chunk.g.dart @@ -0,0 +1,188 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'c_base_chunk.dart'; + +// ************************************************************************** +// IsarEmbeddedGenerator +// ************************************************************************** + +// coverage:ignore-file +// ignore_for_file: duplicate_ignore, non_constant_identifier_names, constant_identifier_names, invalid_use_of_protected_member, unnecessary_cast, prefer_const_constructors, lines_longer_than_80_chars, require_trailing_commas, inference_failure_on_function_invocation, unnecessary_parenthesis, unnecessary_raw_strings, unnecessary_null_checks, join_return_with_assignment, prefer_final_locals, avoid_js_rounded_ints, avoid_positional_boolean_parameters, always_specify_types + +final CChunkSchema = Schema( + name: r'CChunk', + id: BigInt.parse('7782930986990862049').toInt(), + properties: { + r'latestTs': PropertySchema( + id: 0, + name: r'latestTs', + type: IsarType.long, + ), + r'oldestTs': PropertySchema( + id: 1, + name: r'oldestTs', + type: IsarType.long, + ) + }, + estimateSize: _cChunkEstimateSize, + serialize: _cChunkSerialize, + deserialize: _cChunkDeserialize, + deserializeProp: _cChunkDeserializeProp, +); + +int _cChunkEstimateSize( + CChunk object, + List offsets, + Map> allOffsets, +) { + var bytesCount = offsets.last; + return bytesCount; +} + +void _cChunkSerialize( + CChunk object, + IsarWriter writer, + List offsets, + Map> allOffsets, +) { + writer.writeLong(offsets[0], object.latestTs); + writer.writeLong(offsets[1], object.oldestTs); +} + +CChunk _cChunkDeserialize( + Id id, + IsarReader reader, + List offsets, + Map> allOffsets, +) { + final object = CChunk(); + object.latestTs = reader.readLong(offsets[0]); + object.oldestTs = reader.readLong(offsets[1]); + return object; +} + +P _cChunkDeserializeProp

( + IsarReader reader, + int propertyId, + int offset, + Map> allOffsets, +) { + switch (propertyId) { + case 0: + return (reader.readLong(offset)) as P; + case 1: + return (reader.readLong(offset)) as P; + default: + throw IsarError('Unknown property with id $propertyId'); + } +} + +extension CChunkQueryFilter on QueryBuilder { + QueryBuilder latestTsEqualTo( + int value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'latestTs', + value: value, + )); + }); + } + + QueryBuilder latestTsGreaterThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'latestTs', + value: value, + )); + }); + } + + QueryBuilder latestTsLessThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'latestTs', + value: value, + )); + }); + } + + QueryBuilder latestTsBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'latestTs', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder oldestTsEqualTo( + int value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'oldestTs', + value: value, + )); + }); + } + + QueryBuilder oldestTsGreaterThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'oldestTs', + value: value, + )); + }); + } + + QueryBuilder oldestTsLessThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'oldestTs', + value: value, + )); + }); + } + + QueryBuilder oldestTsBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'oldestTs', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } +} + +extension CChunkQueryObject on QueryBuilder {} diff --git a/lib/src/internal/db/schema/chunk/c_channel_chunk.dart b/lib/src/internal/db/schema/chunk/c_channel_chunk.dart new file mode 100644 index 00000000..860e1902 --- /dev/null +++ b/lib/src/internal/db/schema/chunk/c_channel_chunk.dart @@ -0,0 +1,60 @@ +// Copyright (c) 2023 Sendbird, Inc. All rights reserved. + +import 'package:isar/isar.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/chunk/c_base_chunk.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/chunk/channel_chunk.dart'; +import 'package:sendbird_chat_sdk/src/internal/main/chat/chat.dart'; + +part 'c_channel_chunk.g.dart'; + +enum ChannelChunkType { + chronologicalGroupChannelChunk, +} + +@collection +class CChannelChunk extends CBaseChunk { + @Index(unique: true, replace: true) + @enumerated + late ChannelChunkType channelChunkType; + + CChannelChunk(); + + factory CChannelChunk.fromChannelChunk(ChannelChunk chunk) { + return CChannelChunk() + ..channelChunkType = chunk.channelChunkType + ..setChunk(chunk); + } + + Future toChannelChunk(Chat chat, Isar isar) async { + final chunk = ChannelChunk(channelChunkType: channelChunkType); + return CBaseChunk.setCChunk(chat, isar, chunk, this) as ChannelChunk; + } + + static Future upsert( + Chat chat, Isar isar, ChannelChunk chunk) async { + final cChannelChunk = CChannelChunk.fromChannelChunk(chunk); + + // ChannelChunk + await chat.dbManager.write(() async { + await isar.cChannelChunks.put(cChannelChunk); + }); + + return cChannelChunk; + } + + static Future get( + Chat chat, Isar isar, ChannelChunkType channelChunkType) async { + final cChannelChunk = await isar.cChannelChunks + .where() + .channelChunkTypeEqualTo(channelChunkType) + .findFirst(); + return await cChannelChunk?.toChannelChunk(chat, isar); + } + + static Future delete( + Chat chat, Isar isar, ChannelChunkType channelChunkType) async { + await chat.dbManager.write(() async { + await isar.cChannelChunks.deleteByChannelChunkType(channelChunkType); + }); + } +} diff --git a/lib/src/internal/db/schema/chunk/c_channel_chunk.g.dart b/lib/src/internal/db/schema/chunk/c_channel_chunk.g.dart new file mode 100644 index 00000000..a8163c0b --- /dev/null +++ b/lib/src/internal/db/schema/chunk/c_channel_chunk.g.dart @@ -0,0 +1,693 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'c_channel_chunk.dart'; + +// ************************************************************************** +// IsarCollectionGenerator +// ************************************************************************** + +// coverage:ignore-file +// ignore_for_file: duplicate_ignore, non_constant_identifier_names, constant_identifier_names, invalid_use_of_protected_member, unnecessary_cast, prefer_const_constructors, lines_longer_than_80_chars, require_trailing_commas, inference_failure_on_function_invocation, unnecessary_parenthesis, unnecessary_raw_strings, unnecessary_null_checks, join_return_with_assignment, prefer_final_locals, avoid_js_rounded_ints, avoid_positional_boolean_parameters, always_specify_types + +extension GetCChannelChunkCollection on Isar { + IsarCollection get cChannelChunks => this.collection(); +} + +final CChannelChunkSchema = CollectionSchema( + name: r'CChannelChunk', + id: BigInt.parse('-5197328800100259982').toInt(), + properties: { + r'channelChunkType': PropertySchema( + id: 0, + name: r'channelChunkType', + type: IsarType.byte, + enumMap: _CChannelChunkchannelChunkTypeEnumValueMap, + ), + r'chunks': PropertySchema( + id: 1, + name: r'chunks', + type: IsarType.objectList, + target: r'CChunk', + ) + }, + estimateSize: _cChannelChunkEstimateSize, + serialize: _cChannelChunkSerialize, + deserialize: _cChannelChunkDeserialize, + deserializeProp: _cChannelChunkDeserializeProp, + idName: r'id', + indexes: { + r'channelChunkType': IndexSchema( + id: BigInt.parse('4843714266287096217').toInt(), + name: r'channelChunkType', + unique: true, + replace: true, + properties: [ + IndexPropertySchema( + name: r'channelChunkType', + type: IndexType.value, + caseSensitive: false, + ) + ], + ) + }, + links: {}, + embeddedSchemas: {r'CChunk': CChunkSchema}, + getId: _cChannelChunkGetId, + getLinks: _cChannelChunkGetLinks, + attach: _cChannelChunkAttach, + version: '3.1.0+1', +); + +int _cChannelChunkEstimateSize( + CChannelChunk object, + List offsets, + Map> allOffsets, +) { + var bytesCount = offsets.last; + bytesCount += 3 + object.chunks.length * 3; + { + final offsets = allOffsets[CChunk]!; + for (var i = 0; i < object.chunks.length; i++) { + final value = object.chunks[i]; + bytesCount += CChunkSchema.estimateSize(value, offsets, allOffsets); + } + } + return bytesCount; +} + +void _cChannelChunkSerialize( + CChannelChunk object, + IsarWriter writer, + List offsets, + Map> allOffsets, +) { + writer.writeByte(offsets[0], object.channelChunkType.index); + writer.writeObjectList( + offsets[1], + allOffsets, + CChunkSchema.serialize, + object.chunks, + ); +} + +CChannelChunk _cChannelChunkDeserialize( + Id id, + IsarReader reader, + List offsets, + Map> allOffsets, +) { + final object = CChannelChunk(); + object.channelChunkType = _CChannelChunkchannelChunkTypeValueEnumMap[ + reader.readByteOrNull(offsets[0])] ?? + ChannelChunkType.chronologicalGroupChannelChunk; + object.chunks = reader.readObjectList( + offsets[1], + CChunkSchema.deserialize, + allOffsets, + CChunk(), + ) ?? + []; + object.id = id; + return object; +} + +P _cChannelChunkDeserializeProp

( + IsarReader reader, + int propertyId, + int offset, + Map> allOffsets, +) { + switch (propertyId) { + case 0: + return (_CChannelChunkchannelChunkTypeValueEnumMap[ + reader.readByteOrNull(offset)] ?? + ChannelChunkType.chronologicalGroupChannelChunk) as P; + case 1: + return (reader.readObjectList( + offset, + CChunkSchema.deserialize, + allOffsets, + CChunk(), + ) ?? + []) as P; + default: + throw IsarError('Unknown property with id $propertyId'); + } +} + +const _CChannelChunkchannelChunkTypeEnumValueMap = { + 'chronologicalGroupChannelChunk': 0, +}; +const _CChannelChunkchannelChunkTypeValueEnumMap = { + 0: ChannelChunkType.chronologicalGroupChannelChunk, +}; + +Id _cChannelChunkGetId(CChannelChunk object) { + return object.id; +} + +List> _cChannelChunkGetLinks(CChannelChunk object) { + return []; +} + +void _cChannelChunkAttach( + IsarCollection col, Id id, CChannelChunk object) { + object.id = id; +} + +extension CChannelChunkByIndex on IsarCollection { + Future getByChannelChunkType( + ChannelChunkType channelChunkType) { + return getByIndex(r'channelChunkType', [channelChunkType]); + } + + CChannelChunk? getByChannelChunkTypeSync(ChannelChunkType channelChunkType) { + return getByIndexSync(r'channelChunkType', [channelChunkType]); + } + + Future deleteByChannelChunkType(ChannelChunkType channelChunkType) { + return deleteByIndex(r'channelChunkType', [channelChunkType]); + } + + bool deleteByChannelChunkTypeSync(ChannelChunkType channelChunkType) { + return deleteByIndexSync(r'channelChunkType', [channelChunkType]); + } + + Future> getAllByChannelChunkType( + List channelChunkTypeValues) { + final values = channelChunkTypeValues.map((e) => [e]).toList(); + return getAllByIndex(r'channelChunkType', values); + } + + List getAllByChannelChunkTypeSync( + List channelChunkTypeValues) { + final values = channelChunkTypeValues.map((e) => [e]).toList(); + return getAllByIndexSync(r'channelChunkType', values); + } + + Future deleteAllByChannelChunkType( + List channelChunkTypeValues) { + final values = channelChunkTypeValues.map((e) => [e]).toList(); + return deleteAllByIndex(r'channelChunkType', values); + } + + int deleteAllByChannelChunkTypeSync( + List channelChunkTypeValues) { + final values = channelChunkTypeValues.map((e) => [e]).toList(); + return deleteAllByIndexSync(r'channelChunkType', values); + } + + Future putByChannelChunkType(CChannelChunk object) { + return putByIndex(r'channelChunkType', object); + } + + Id putByChannelChunkTypeSync(CChannelChunk object, {bool saveLinks = true}) { + return putByIndexSync(r'channelChunkType', object, saveLinks: saveLinks); + } + + Future> putAllByChannelChunkType(List objects) { + return putAllByIndex(r'channelChunkType', objects); + } + + List putAllByChannelChunkTypeSync(List objects, + {bool saveLinks = true}) { + return putAllByIndexSync(r'channelChunkType', objects, + saveLinks: saveLinks); + } +} + +extension CChannelChunkQueryWhereSort + on QueryBuilder { + QueryBuilder anyId() { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(const IdWhereClause.any()); + }); + } + + QueryBuilder + anyChannelChunkType() { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause( + const IndexWhereClause.any(indexName: r'channelChunkType'), + ); + }); + } +} + +extension CChannelChunkQueryWhere + on QueryBuilder { + QueryBuilder idEqualTo( + Id id) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IdWhereClause.between( + lower: id, + upper: id, + )); + }); + } + + QueryBuilder idNotEqualTo( + Id id) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause( + IdWhereClause.lessThan(upper: id, includeUpper: false), + ) + .addWhereClause( + IdWhereClause.greaterThan(lower: id, includeLower: false), + ); + } else { + return query + .addWhereClause( + IdWhereClause.greaterThan(lower: id, includeLower: false), + ) + .addWhereClause( + IdWhereClause.lessThan(upper: id, includeUpper: false), + ); + } + }); + } + + QueryBuilder idGreaterThan( + Id id, + {bool include = false}) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause( + IdWhereClause.greaterThan(lower: id, includeLower: include), + ); + }); + } + + QueryBuilder idLessThan( + Id id, + {bool include = false}) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause( + IdWhereClause.lessThan(upper: id, includeUpper: include), + ); + }); + } + + QueryBuilder idBetween( + Id lowerId, + Id upperId, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IdWhereClause.between( + lower: lowerId, + includeLower: includeLower, + upper: upperId, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + channelChunkTypeEqualTo(ChannelChunkType channelChunkType) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.equalTo( + indexName: r'channelChunkType', + value: [channelChunkType], + )); + }); + } + + QueryBuilder + channelChunkTypeNotEqualTo(ChannelChunkType channelChunkType) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'channelChunkType', + lower: [], + upper: [channelChunkType], + includeUpper: false, + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'channelChunkType', + lower: [channelChunkType], + includeLower: false, + upper: [], + )); + } else { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'channelChunkType', + lower: [channelChunkType], + includeLower: false, + upper: [], + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'channelChunkType', + lower: [], + upper: [channelChunkType], + includeUpper: false, + )); + } + }); + } + + QueryBuilder + channelChunkTypeGreaterThan( + ChannelChunkType channelChunkType, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.between( + indexName: r'channelChunkType', + lower: [channelChunkType], + includeLower: include, + upper: [], + )); + }); + } + + QueryBuilder + channelChunkTypeLessThan( + ChannelChunkType channelChunkType, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.between( + indexName: r'channelChunkType', + lower: [], + upper: [channelChunkType], + includeUpper: include, + )); + }); + } + + QueryBuilder + channelChunkTypeBetween( + ChannelChunkType lowerChannelChunkType, + ChannelChunkType upperChannelChunkType, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.between( + indexName: r'channelChunkType', + lower: [lowerChannelChunkType], + includeLower: includeLower, + upper: [upperChannelChunkType], + includeUpper: includeUpper, + )); + }); + } +} + +extension CChannelChunkQueryFilter + on QueryBuilder { + QueryBuilder + channelChunkTypeEqualTo(ChannelChunkType value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'channelChunkType', + value: value, + )); + }); + } + + QueryBuilder + channelChunkTypeGreaterThan( + ChannelChunkType value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'channelChunkType', + value: value, + )); + }); + } + + QueryBuilder + channelChunkTypeLessThan( + ChannelChunkType value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'channelChunkType', + value: value, + )); + }); + } + + QueryBuilder + channelChunkTypeBetween( + ChannelChunkType lower, + ChannelChunkType upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'channelChunkType', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + chunksLengthEqualTo(int length) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'chunks', + length, + true, + length, + true, + ); + }); + } + + QueryBuilder + chunksIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'chunks', + 0, + true, + 0, + true, + ); + }); + } + + QueryBuilder + chunksIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'chunks', + 0, + false, + 999999, + true, + ); + }); + } + + QueryBuilder + chunksLengthLessThan( + int length, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'chunks', + 0, + true, + length, + include, + ); + }); + } + + QueryBuilder + chunksLengthGreaterThan( + int length, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'chunks', + length, + include, + 999999, + true, + ); + }); + } + + QueryBuilder + chunksLengthBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'chunks', + lower, + includeLower, + upper, + includeUpper, + ); + }); + } + + QueryBuilder idEqualTo( + Id value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'id', + value: value, + )); + }); + } + + QueryBuilder + idGreaterThan( + Id value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'id', + value: value, + )); + }); + } + + QueryBuilder idLessThan( + Id value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'id', + value: value, + )); + }); + } + + QueryBuilder idBetween( + Id lower, + Id upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'id', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } +} + +extension CChannelChunkQueryObject + on QueryBuilder { + QueryBuilder + chunksElement(FilterQuery q) { + return QueryBuilder.apply(this, (query) { + return query.object(q, r'chunks'); + }); + } +} + +extension CChannelChunkQueryLinks + on QueryBuilder {} + +extension CChannelChunkQuerySortBy + on QueryBuilder { + QueryBuilder + sortByChannelChunkType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'channelChunkType', Sort.asc); + }); + } + + QueryBuilder + sortByChannelChunkTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'channelChunkType', Sort.desc); + }); + } +} + +extension CChannelChunkQuerySortThenBy + on QueryBuilder { + QueryBuilder + thenByChannelChunkType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'channelChunkType', Sort.asc); + }); + } + + QueryBuilder + thenByChannelChunkTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'channelChunkType', Sort.desc); + }); + } + + QueryBuilder thenById() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'id', Sort.asc); + }); + } + + QueryBuilder thenByIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'id', Sort.desc); + }); + } +} + +extension CChannelChunkQueryWhereDistinct + on QueryBuilder { + QueryBuilder + distinctByChannelChunkType() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'channelChunkType'); + }); + } +} + +extension CChannelChunkQueryProperty + on QueryBuilder { + QueryBuilder idProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'id'); + }); + } + + QueryBuilder + channelChunkTypeProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'channelChunkType'); + }); + } + + QueryBuilder, QQueryOperations> chunksProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'chunks'); + }); + } +} diff --git a/lib/src/internal/db/schema/chunk/c_message_chunk.dart b/lib/src/internal/db/schema/chunk/c_message_chunk.dart new file mode 100644 index 00000000..38c88774 --- /dev/null +++ b/lib/src/internal/db/schema/chunk/c_message_chunk.dart @@ -0,0 +1,54 @@ +// Copyright (c) 2023 Sendbird, Inc. All rights reserved. + +import 'package:isar/isar.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/chunk/c_base_chunk.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/chunk/message_chunk.dart'; +import 'package:sendbird_chat_sdk/src/internal/main/chat/chat.dart'; + +part 'c_message_chunk.g.dart'; + +@collection +class CMessageChunk extends CBaseChunk { + @Index(unique: true, replace: true) + late String channelUrl; + + CMessageChunk(); + + factory CMessageChunk.fromMessageChunk(MessageChunk chunk) { + return CMessageChunk() + ..channelUrl = chunk.channelUrl + ..setChunk(chunk); + } + + Future toMessageChunk(Chat chat, Isar isar) async { + final chunk = MessageChunk(channelUrl: channelUrl); + return CBaseChunk.setCChunk(chat, isar, chunk, this) as MessageChunk; + } + + static Future upsert( + Chat chat, Isar isar, MessageChunk chunk) async { + final cMessageChunk = CMessageChunk.fromMessageChunk(chunk); + + // MessageChunk + await chat.dbManager.write(() async { + await isar.cMessageChunks.put(cMessageChunk); + }); + + return cMessageChunk; + } + + static Future get( + Chat chat, Isar isar, String channelUrl) async { + final cMessageChunk = await isar.cMessageChunks + .where() + .channelUrlEqualTo(channelUrl) + .findFirst(); + return await cMessageChunk?.toMessageChunk(chat, isar); + } + + static Future delete(Chat chat, Isar isar, String channelUrl) async { + await chat.dbManager.write(() async { + await isar.cMessageChunks.deleteByChannelUrl(channelUrl); + }); + } +} diff --git a/lib/src/internal/db/schema/chunk/c_message_chunk.g.dart b/lib/src/internal/db/schema/chunk/c_message_chunk.g.dart new file mode 100644 index 00000000..f382a1ca --- /dev/null +++ b/lib/src/internal/db/schema/chunk/c_message_chunk.g.dart @@ -0,0 +1,697 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'c_message_chunk.dart'; + +// ************************************************************************** +// IsarCollectionGenerator +// ************************************************************************** + +// coverage:ignore-file +// ignore_for_file: duplicate_ignore, non_constant_identifier_names, constant_identifier_names, invalid_use_of_protected_member, unnecessary_cast, prefer_const_constructors, lines_longer_than_80_chars, require_trailing_commas, inference_failure_on_function_invocation, unnecessary_parenthesis, unnecessary_raw_strings, unnecessary_null_checks, join_return_with_assignment, prefer_final_locals, avoid_js_rounded_ints, avoid_positional_boolean_parameters, always_specify_types + +extension GetCMessageChunkCollection on Isar { + IsarCollection get cMessageChunks => this.collection(); +} + +final CMessageChunkSchema = CollectionSchema( + name: r'CMessageChunk', + id: BigInt.parse('-912749770485576556').toInt(), + properties: { + r'channelUrl': PropertySchema( + id: 0, + name: r'channelUrl', + type: IsarType.string, + ), + r'chunks': PropertySchema( + id: 1, + name: r'chunks', + type: IsarType.objectList, + target: r'CChunk', + ) + }, + estimateSize: _cMessageChunkEstimateSize, + serialize: _cMessageChunkSerialize, + deserialize: _cMessageChunkDeserialize, + deserializeProp: _cMessageChunkDeserializeProp, + idName: r'id', + indexes: { + r'channelUrl': IndexSchema( + id: BigInt.parse('6636052684858767397').toInt(), + name: r'channelUrl', + unique: true, + replace: true, + properties: [ + IndexPropertySchema( + name: r'channelUrl', + type: IndexType.hash, + caseSensitive: true, + ) + ], + ) + }, + links: {}, + embeddedSchemas: {r'CChunk': CChunkSchema}, + getId: _cMessageChunkGetId, + getLinks: _cMessageChunkGetLinks, + attach: _cMessageChunkAttach, + version: '3.1.0+1', +); + +int _cMessageChunkEstimateSize( + CMessageChunk object, + List offsets, + Map> allOffsets, +) { + var bytesCount = offsets.last; + bytesCount += 3 + object.channelUrl.length * 3; + bytesCount += 3 + object.chunks.length * 3; + { + final offsets = allOffsets[CChunk]!; + for (var i = 0; i < object.chunks.length; i++) { + final value = object.chunks[i]; + bytesCount += CChunkSchema.estimateSize(value, offsets, allOffsets); + } + } + return bytesCount; +} + +void _cMessageChunkSerialize( + CMessageChunk object, + IsarWriter writer, + List offsets, + Map> allOffsets, +) { + writer.writeString(offsets[0], object.channelUrl); + writer.writeObjectList( + offsets[1], + allOffsets, + CChunkSchema.serialize, + object.chunks, + ); +} + +CMessageChunk _cMessageChunkDeserialize( + Id id, + IsarReader reader, + List offsets, + Map> allOffsets, +) { + final object = CMessageChunk(); + object.channelUrl = reader.readString(offsets[0]); + object.chunks = reader.readObjectList( + offsets[1], + CChunkSchema.deserialize, + allOffsets, + CChunk(), + ) ?? + []; + object.id = id; + return object; +} + +P _cMessageChunkDeserializeProp

( + IsarReader reader, + int propertyId, + int offset, + Map> allOffsets, +) { + switch (propertyId) { + case 0: + return (reader.readString(offset)) as P; + case 1: + return (reader.readObjectList( + offset, + CChunkSchema.deserialize, + allOffsets, + CChunk(), + ) ?? + []) as P; + default: + throw IsarError('Unknown property with id $propertyId'); + } +} + +Id _cMessageChunkGetId(CMessageChunk object) { + return object.id; +} + +List> _cMessageChunkGetLinks(CMessageChunk object) { + return []; +} + +void _cMessageChunkAttach( + IsarCollection col, Id id, CMessageChunk object) { + object.id = id; +} + +extension CMessageChunkByIndex on IsarCollection { + Future getByChannelUrl(String channelUrl) { + return getByIndex(r'channelUrl', [channelUrl]); + } + + CMessageChunk? getByChannelUrlSync(String channelUrl) { + return getByIndexSync(r'channelUrl', [channelUrl]); + } + + Future deleteByChannelUrl(String channelUrl) { + return deleteByIndex(r'channelUrl', [channelUrl]); + } + + bool deleteByChannelUrlSync(String channelUrl) { + return deleteByIndexSync(r'channelUrl', [channelUrl]); + } + + Future> getAllByChannelUrl( + List channelUrlValues) { + final values = channelUrlValues.map((e) => [e]).toList(); + return getAllByIndex(r'channelUrl', values); + } + + List getAllByChannelUrlSync(List channelUrlValues) { + final values = channelUrlValues.map((e) => [e]).toList(); + return getAllByIndexSync(r'channelUrl', values); + } + + Future deleteAllByChannelUrl(List channelUrlValues) { + final values = channelUrlValues.map((e) => [e]).toList(); + return deleteAllByIndex(r'channelUrl', values); + } + + int deleteAllByChannelUrlSync(List channelUrlValues) { + final values = channelUrlValues.map((e) => [e]).toList(); + return deleteAllByIndexSync(r'channelUrl', values); + } + + Future putByChannelUrl(CMessageChunk object) { + return putByIndex(r'channelUrl', object); + } + + Id putByChannelUrlSync(CMessageChunk object, {bool saveLinks = true}) { + return putByIndexSync(r'channelUrl', object, saveLinks: saveLinks); + } + + Future> putAllByChannelUrl(List objects) { + return putAllByIndex(r'channelUrl', objects); + } + + List putAllByChannelUrlSync(List objects, + {bool saveLinks = true}) { + return putAllByIndexSync(r'channelUrl', objects, saveLinks: saveLinks); + } +} + +extension CMessageChunkQueryWhereSort + on QueryBuilder { + QueryBuilder anyId() { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(const IdWhereClause.any()); + }); + } +} + +extension CMessageChunkQueryWhere + on QueryBuilder { + QueryBuilder idEqualTo( + Id id) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IdWhereClause.between( + lower: id, + upper: id, + )); + }); + } + + QueryBuilder idNotEqualTo( + Id id) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause( + IdWhereClause.lessThan(upper: id, includeUpper: false), + ) + .addWhereClause( + IdWhereClause.greaterThan(lower: id, includeLower: false), + ); + } else { + return query + .addWhereClause( + IdWhereClause.greaterThan(lower: id, includeLower: false), + ) + .addWhereClause( + IdWhereClause.lessThan(upper: id, includeUpper: false), + ); + } + }); + } + + QueryBuilder idGreaterThan( + Id id, + {bool include = false}) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause( + IdWhereClause.greaterThan(lower: id, includeLower: include), + ); + }); + } + + QueryBuilder idLessThan( + Id id, + {bool include = false}) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause( + IdWhereClause.lessThan(upper: id, includeUpper: include), + ); + }); + } + + QueryBuilder idBetween( + Id lowerId, + Id upperId, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IdWhereClause.between( + lower: lowerId, + includeLower: includeLower, + upper: upperId, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + channelUrlEqualTo(String channelUrl) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.equalTo( + indexName: r'channelUrl', + value: [channelUrl], + )); + }); + } + + QueryBuilder + channelUrlNotEqualTo(String channelUrl) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'channelUrl', + lower: [], + upper: [channelUrl], + includeUpper: false, + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'channelUrl', + lower: [channelUrl], + includeLower: false, + upper: [], + )); + } else { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'channelUrl', + lower: [channelUrl], + includeLower: false, + upper: [], + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'channelUrl', + lower: [], + upper: [channelUrl], + includeUpper: false, + )); + } + }); + } +} + +extension CMessageChunkQueryFilter + on QueryBuilder { + QueryBuilder + channelUrlEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'channelUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + channelUrlGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'channelUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + channelUrlLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'channelUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + channelUrlBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'channelUrl', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + channelUrlStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'channelUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + channelUrlEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'channelUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + channelUrlContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'channelUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + channelUrlMatches(String pattern, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'channelUrl', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + channelUrlIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'channelUrl', + value: '', + )); + }); + } + + QueryBuilder + channelUrlIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'channelUrl', + value: '', + )); + }); + } + + QueryBuilder + chunksLengthEqualTo(int length) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'chunks', + length, + true, + length, + true, + ); + }); + } + + QueryBuilder + chunksIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'chunks', + 0, + true, + 0, + true, + ); + }); + } + + QueryBuilder + chunksIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'chunks', + 0, + false, + 999999, + true, + ); + }); + } + + QueryBuilder + chunksLengthLessThan( + int length, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'chunks', + 0, + true, + length, + include, + ); + }); + } + + QueryBuilder + chunksLengthGreaterThan( + int length, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'chunks', + length, + include, + 999999, + true, + ); + }); + } + + QueryBuilder + chunksLengthBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'chunks', + lower, + includeLower, + upper, + includeUpper, + ); + }); + } + + QueryBuilder idEqualTo( + Id value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'id', + value: value, + )); + }); + } + + QueryBuilder + idGreaterThan( + Id value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'id', + value: value, + )); + }); + } + + QueryBuilder idLessThan( + Id value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'id', + value: value, + )); + }); + } + + QueryBuilder idBetween( + Id lower, + Id upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'id', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } +} + +extension CMessageChunkQueryObject + on QueryBuilder { + QueryBuilder + chunksElement(FilterQuery q) { + return QueryBuilder.apply(this, (query) { + return query.object(q, r'chunks'); + }); + } +} + +extension CMessageChunkQueryLinks + on QueryBuilder {} + +extension CMessageChunkQuerySortBy + on QueryBuilder { + QueryBuilder sortByChannelUrl() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'channelUrl', Sort.asc); + }); + } + + QueryBuilder + sortByChannelUrlDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'channelUrl', Sort.desc); + }); + } +} + +extension CMessageChunkQuerySortThenBy + on QueryBuilder { + QueryBuilder thenByChannelUrl() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'channelUrl', Sort.asc); + }); + } + + QueryBuilder + thenByChannelUrlDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'channelUrl', Sort.desc); + }); + } + + QueryBuilder thenById() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'id', Sort.asc); + }); + } + + QueryBuilder thenByIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'id', Sort.desc); + }); + } +} + +extension CMessageChunkQueryWhereDistinct + on QueryBuilder { + QueryBuilder distinctByChannelUrl( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'channelUrl', caseSensitive: caseSensitive); + }); + } +} + +extension CMessageChunkQueryProperty + on QueryBuilder { + QueryBuilder idProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'id'); + }); + } + + QueryBuilder channelUrlProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'channelUrl'); + }); + } + + QueryBuilder, QQueryOperations> chunksProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'chunks'); + }); + } +} diff --git a/lib/src/internal/db/schema/chunk/channel_chunk.dart b/lib/src/internal/db/schema/chunk/channel_chunk.dart new file mode 100644 index 00000000..50f94610 --- /dev/null +++ b/lib/src/internal/db/schema/chunk/channel_chunk.dart @@ -0,0 +1,16 @@ +// Copyright (c) 2023 Sendbird, Inc. All rights reserved. + +import 'package:sendbird_chat_sdk/src/internal/db/schema/chunk/base_chunk.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/chunk/c_channel_chunk.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/chunk/chunk.dart'; + +class ChannelChunk extends BaseChunk { + final ChannelChunkType channelChunkType; + + ChannelChunk({ + required this.channelChunkType, + List? chunks, + }) { + super.chunks = chunks ?? []; + } +} diff --git a/lib/src/internal/db/schema/chunk/chunk.dart b/lib/src/internal/db/schema/chunk/chunk.dart new file mode 100644 index 00000000..a03ce987 --- /dev/null +++ b/lib/src/internal/db/schema/chunk/chunk.dart @@ -0,0 +1,27 @@ +// Copyright (c) 2023 Sendbird, Inc. All rights reserved. + +class Chunk { + int oldestTs; + int latestTs; + + Chunk({ + required this.oldestTs, + required this.latestTs, + }); + + @override + bool operator ==(other) { + if (identical(other, this)) return true; + + return other is Chunk && + other.oldestTs == oldestTs && + other.latestTs == latestTs; + } + + @override + int get hashCode => Object.hash( + super.hashCode, + oldestTs, + latestTs, + ); +} diff --git a/lib/src/internal/db/schema/chunk/message_chunk.dart b/lib/src/internal/db/schema/chunk/message_chunk.dart new file mode 100644 index 00000000..6b5041a5 --- /dev/null +++ b/lib/src/internal/db/schema/chunk/message_chunk.dart @@ -0,0 +1,88 @@ +// Copyright (c) 2023 Sendbird, Inc. All rights reserved. + +import 'dart:math'; + +import 'package:sendbird_chat_sdk/src/internal/db/schema/chunk/base_chunk.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/chunk/chunk.dart'; + +class MessageChunk extends BaseChunk { + final String channelUrl; + + MessageChunk({ + required this.channelUrl, + List? chunks, + }) { + super.chunks = chunks ?? []; + } + + void add(Chunk chunk) { + chunks.add(chunk); + } + + void addNewChunk(Chunk newChunk) { + if (chunks.isNotEmpty) { + for (int i = chunks.length - 1; i >= 0; i--) { + final chunk = chunks.elementAt(i); + if ((newChunk.oldestTs >= chunk.oldestTs && + newChunk.oldestTs <= chunk.latestTs) || + (newChunk.latestTs >= chunk.oldestTs && + newChunk.latestTs <= chunk.latestTs)) { + newChunk.oldestTs = min(newChunk.oldestTs, chunk.oldestTs); + newChunk.latestTs = max(newChunk.latestTs, chunk.latestTs); + chunks.remove(chunk); // Check + } + } + } + chunks.add(newChunk); + } + + bool isInCurrentChunk({ + required int oldestTs, + required int latestTs, + required int? lastSyncedTimeStamp, + }) { + bool result = false; + + if (lastSyncedTimeStamp != null) { + for (final chunk in chunks) { + if (lastSyncedTimeStamp >= chunk.oldestTs && + lastSyncedTimeStamp <= chunk.latestTs) { + if (oldestTs >= chunk.oldestTs && + oldestTs <= chunk.latestTs && + latestTs >= chunk.oldestTs && + latestTs <= chunk.latestTs) { + result = true; + } + break; + } + } + } else { + for (final chunk in chunks) { + if (oldestTs >= chunk.oldestTs && + oldestTs <= chunk.latestTs && + latestTs >= chunk.oldestTs && + latestTs <= chunk.latestTs) { + result = true; + break; + } + } + } + return result; + } + + Chunk? getChunk(int ts) { + Chunk? resultChunk; + for (final chunk in chunks) { + if (ts >= chunk.oldestTs && ts <= chunk.latestTs) { + resultChunk = chunk; + break; + } + } + return resultChunk; + } + + void removeChunk(Chunk chunk) { + chunks.removeWhere( + (c) => (chunk.oldestTs == c.oldestTs && chunk.latestTs == c.latestTs)); + } +} diff --git a/lib/src/internal/db/schema/login/c_login.dart b/lib/src/internal/db/schema/login/c_login.dart new file mode 100644 index 00000000..5fd3937b --- /dev/null +++ b/lib/src/internal/db/schema/login/c_login.dart @@ -0,0 +1,177 @@ +// Copyright (c) 2023 Sendbird, Inc. All rights reserved. + +import 'dart:convert'; + +import 'package:isar/isar.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/login/login.dart'; +import 'package:sendbird_chat_sdk/src/internal/main/chat/chat.dart'; +import 'package:sendbird_chat_sdk/src/internal/main/chat_context/chat_context.dart'; +import 'package:sendbird_chat_sdk/src/internal/main/model/reconnect_configuration.dart'; +import 'package:sendbird_chat_sdk/src/public/main/model/info/app_info.dart'; +import 'package:sendbird_chat_sdk/src/public/main/model/info/notification_info.dart'; + +part 'c_login.g.dart'; + +@collection +class CLogin { + Id id = Isar.autoIncrement; + + @Index(unique: true, replace: true) + late String userId; + + @enumerated + late List services; + + CAppInfo? appInfo; + int? uploadSizeLimit; + int? maxUnreadCountOnSuperGroup; + int? lastConnectedAt; + CReconnectConfiguration? reconnectConfig; + + CLogin(); + + factory CLogin.fromLogin(Login login) { + return CLogin() + ..userId = login.userId + ..services = login.services + ..appInfo = + login.appInfo != null ? CAppInfo.fromAppInfo(login.appInfo!) : null + ..uploadSizeLimit = login.uploadSizeLimit + ..maxUnreadCountOnSuperGroup = login.maxUnreadCountOnSuperGroup + ..lastConnectedAt = login.lastConnectedAt + ..reconnectConfig = login.reconnectConfig != null + ? CReconnectConfiguration.fromReconnectConfiguration( + login.reconnectConfig!) + : null; + } + + Future toLogin(Chat chat, Isar isar) async { + final login = Login( + userId: userId, + services: services, + appInfo: appInfo?.toAppInfo(), + uploadSizeLimit: uploadSizeLimit, + maxUnreadCountOnSuperGroup: maxUnreadCountOnSuperGroup, + lastConnectedAt: lastConnectedAt, + reconnectConfig: reconnectConfig?.toReconnectConfiguration(), + chat: chat, + ); + return login; + } + + static Future upsert(Chat chat, Isar isar, Login login) async { + final cLogin = CLogin.fromLogin(login); + + // Login + await chat.dbManager.write(() async { + await isar.cLogins.put(cLogin); + }); + + return cLogin; + } + + static Future get(Chat chat, Isar isar, String userId) async { + final cLogin = await isar.cLogins.where().userIdEqualTo(userId).findFirst(); + return await cLogin?.toLogin(chat, isar); + } + + static Future delete(Chat chat, Isar isar, String userId) async { + await chat.dbManager.write(() async { + await isar.cLogins.deleteByUserId(userId); + }); + } +} + +@embedded +class CAppInfo { + late List premiumFeatureList; + late int uploadSizeLimit; + late List attributesInUse; + late String emojiHash; + late bool useReaction; + CNotificationInfo? notificationInfo; + late bool allowSdkStatsUpload; + + CAppInfo(); + + factory CAppInfo.fromAppInfo(AppInfo info) { + return CAppInfo() + ..premiumFeatureList = info.premiumFeatureList + ..uploadSizeLimit = info.uploadSizeLimit + ..attributesInUse = info.attributesInUse + ..emojiHash = info.emojiHash + ..useReaction = info.useReaction + ..notificationInfo = info.notificationInfo != null + ? CNotificationInfo.fromNotificationInfo(info.notificationInfo!) + : null + ..allowSdkStatsUpload = info.allowSdkStatsUpload; + } + + AppInfo toAppInfo() { + return AppInfo( + premiumFeatureList: premiumFeatureList, + uploadSizeLimit: uploadSizeLimit, + attributesInUse: attributesInUse, + emojiHash: emojiHash, + useReaction: useReaction, + notificationInfo: notificationInfo?.toNotificationInfo(), + allowSdkStatsUpload: allowSdkStatsUpload, + ); + } +} + +@embedded +class CNotificationInfo { + late bool isEnabled; + late String feedChannels; // Map + late int settingsUpdatedAt; + String? templateListToken; + + CNotificationInfo(); + + factory CNotificationInfo.fromNotificationInfo(NotificationInfo info) { + return CNotificationInfo() + ..isEnabled = info.isEnabled + ..feedChannels = jsonEncode(info.feedChannels) + ..settingsUpdatedAt = info.settingsUpdatedAt + ..templateListToken = info.templateListToken; + } + + NotificationInfo toNotificationInfo() { + return NotificationInfo( + isEnabled: isEnabled, + feedChannels: (jsonDecode(feedChannels) as Map) + .map((key, value) => MapEntry(key, value.toString())), + settingsUpdatedAt: settingsUpdatedAt, + templateListToken: templateListToken, + ); + } +} + +@embedded +class CReconnectConfiguration { + late double interval; + late double maxInterval; + late int multiplier; + late int maximumRetryCount; + + CReconnectConfiguration(); + + factory CReconnectConfiguration.fromReconnectConfiguration( + ReconnectConfiguration configuration) { + return CReconnectConfiguration() + ..interval = configuration.interval + ..maxInterval = configuration.maxInterval + ..multiplier = configuration.multiplier + ..maximumRetryCount = configuration.maximumRetryCount; + } + + ReconnectConfiguration toReconnectConfiguration() { + return ReconnectConfiguration( + interval: interval, + maxInterval: maxInterval, + multiplier: multiplier, + maximumRetryCount: maximumRetryCount, + ); + } +} diff --git a/lib/src/internal/db/schema/login/c_login.g.dart b/lib/src/internal/db/schema/login/c_login.g.dart new file mode 100644 index 00000000..5d44f5cf --- /dev/null +++ b/lib/src/internal/db/schema/login/c_login.g.dart @@ -0,0 +1,2840 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'c_login.dart'; + +// ************************************************************************** +// IsarCollectionGenerator +// ************************************************************************** + +// coverage:ignore-file +// ignore_for_file: duplicate_ignore, non_constant_identifier_names, constant_identifier_names, invalid_use_of_protected_member, unnecessary_cast, prefer_const_constructors, lines_longer_than_80_chars, require_trailing_commas, inference_failure_on_function_invocation, unnecessary_parenthesis, unnecessary_raw_strings, unnecessary_null_checks, join_return_with_assignment, prefer_final_locals, avoid_js_rounded_ints, avoid_positional_boolean_parameters, always_specify_types + +extension GetCLoginCollection on Isar { + IsarCollection get cLogins => this.collection(); +} + +final CLoginSchema = CollectionSchema( + name: r'CLogin', + id: BigInt.parse('-487089198461928861').toInt(), + properties: { + r'appInfo': PropertySchema( + id: 0, + name: r'appInfo', + type: IsarType.object, + target: r'CAppInfo', + ), + r'lastConnectedAt': PropertySchema( + id: 1, + name: r'lastConnectedAt', + type: IsarType.long, + ), + r'maxUnreadCountOnSuperGroup': PropertySchema( + id: 2, + name: r'maxUnreadCountOnSuperGroup', + type: IsarType.long, + ), + r'reconnectConfig': PropertySchema( + id: 3, + name: r'reconnectConfig', + type: IsarType.object, + target: r'CReconnectConfiguration', + ), + r'services': PropertySchema( + id: 4, + name: r'services', + type: IsarType.byteList, + enumMap: _CLoginservicesEnumValueMap, + ), + r'uploadSizeLimit': PropertySchema( + id: 5, + name: r'uploadSizeLimit', + type: IsarType.long, + ), + r'userId': PropertySchema( + id: 6, + name: r'userId', + type: IsarType.string, + ) + }, + estimateSize: _cLoginEstimateSize, + serialize: _cLoginSerialize, + deserialize: _cLoginDeserialize, + deserializeProp: _cLoginDeserializeProp, + idName: r'id', + indexes: { + r'userId': IndexSchema( + id: BigInt.parse('-2005826577402374815').toInt(), + name: r'userId', + unique: true, + replace: true, + properties: [ + IndexPropertySchema( + name: r'userId', + type: IndexType.hash, + caseSensitive: true, + ) + ], + ) + }, + links: {}, + embeddedSchemas: { + r'CAppInfo': CAppInfoSchema, + r'CNotificationInfo': CNotificationInfoSchema, + r'CReconnectConfiguration': CReconnectConfigurationSchema + }, + getId: _cLoginGetId, + getLinks: _cLoginGetLinks, + attach: _cLoginAttach, + version: '3.1.0+1', +); + +int _cLoginEstimateSize( + CLogin object, + List offsets, + Map> allOffsets, +) { + var bytesCount = offsets.last; + { + final value = object.appInfo; + if (value != null) { + bytesCount += 3 + + CAppInfoSchema.estimateSize(value, allOffsets[CAppInfo]!, allOffsets); + } + } + { + final value = object.reconnectConfig; + if (value != null) { + bytesCount += 3 + + CReconnectConfigurationSchema.estimateSize( + value, allOffsets[CReconnectConfiguration]!, allOffsets); + } + } + bytesCount += 3 + object.services.length; + bytesCount += 3 + object.userId.length * 3; + return bytesCount; +} + +void _cLoginSerialize( + CLogin object, + IsarWriter writer, + List offsets, + Map> allOffsets, +) { + writer.writeObject( + offsets[0], + allOffsets, + CAppInfoSchema.serialize, + object.appInfo, + ); + writer.writeLong(offsets[1], object.lastConnectedAt); + writer.writeLong(offsets[2], object.maxUnreadCountOnSuperGroup); + writer.writeObject( + offsets[3], + allOffsets, + CReconnectConfigurationSchema.serialize, + object.reconnectConfig, + ); + writer.writeByteList( + offsets[4], object.services.map((e) => e.index).toList()); + writer.writeLong(offsets[5], object.uploadSizeLimit); + writer.writeString(offsets[6], object.userId); +} + +CLogin _cLoginDeserialize( + Id id, + IsarReader reader, + List offsets, + Map> allOffsets, +) { + final object = CLogin(); + object.appInfo = reader.readObjectOrNull( + offsets[0], + CAppInfoSchema.deserialize, + allOffsets, + ); + object.id = id; + object.lastConnectedAt = reader.readLongOrNull(offsets[1]); + object.maxUnreadCountOnSuperGroup = reader.readLongOrNull(offsets[2]); + object.reconnectConfig = reader.readObjectOrNull( + offsets[3], + CReconnectConfigurationSchema.deserialize, + allOffsets, + ); + object.services = reader + .readByteList(offsets[4]) + ?.map((e) => _CLoginservicesValueEnumMap[e] ?? Service.chat) + .toList() ?? + []; + object.uploadSizeLimit = reader.readLongOrNull(offsets[5]); + object.userId = reader.readString(offsets[6]); + return object; +} + +P _cLoginDeserializeProp

( + IsarReader reader, + int propertyId, + int offset, + Map> allOffsets, +) { + switch (propertyId) { + case 0: + return (reader.readObjectOrNull( + offset, + CAppInfoSchema.deserialize, + allOffsets, + )) as P; + case 1: + return (reader.readLongOrNull(offset)) as P; + case 2: + return (reader.readLongOrNull(offset)) as P; + case 3: + return (reader.readObjectOrNull( + offset, + CReconnectConfigurationSchema.deserialize, + allOffsets, + )) as P; + case 4: + return (reader + .readByteList(offset) + ?.map((e) => _CLoginservicesValueEnumMap[e] ?? Service.chat) + .toList() ?? + []) as P; + case 5: + return (reader.readLongOrNull(offset)) as P; + case 6: + return (reader.readString(offset)) as P; + default: + throw IsarError('Unknown property with id $propertyId'); + } +} + +const _CLoginservicesEnumValueMap = { + 'chat': 0, + 'feed': 1, +}; +const _CLoginservicesValueEnumMap = { + 0: Service.chat, + 1: Service.feed, +}; + +Id _cLoginGetId(CLogin object) { + return object.id; +} + +List> _cLoginGetLinks(CLogin object) { + return []; +} + +void _cLoginAttach(IsarCollection col, Id id, CLogin object) { + object.id = id; +} + +extension CLoginByIndex on IsarCollection { + Future getByUserId(String userId) { + return getByIndex(r'userId', [userId]); + } + + CLogin? getByUserIdSync(String userId) { + return getByIndexSync(r'userId', [userId]); + } + + Future deleteByUserId(String userId) { + return deleteByIndex(r'userId', [userId]); + } + + bool deleteByUserIdSync(String userId) { + return deleteByIndexSync(r'userId', [userId]); + } + + Future> getAllByUserId(List userIdValues) { + final values = userIdValues.map((e) => [e]).toList(); + return getAllByIndex(r'userId', values); + } + + List getAllByUserIdSync(List userIdValues) { + final values = userIdValues.map((e) => [e]).toList(); + return getAllByIndexSync(r'userId', values); + } + + Future deleteAllByUserId(List userIdValues) { + final values = userIdValues.map((e) => [e]).toList(); + return deleteAllByIndex(r'userId', values); + } + + int deleteAllByUserIdSync(List userIdValues) { + final values = userIdValues.map((e) => [e]).toList(); + return deleteAllByIndexSync(r'userId', values); + } + + Future putByUserId(CLogin object) { + return putByIndex(r'userId', object); + } + + Id putByUserIdSync(CLogin object, {bool saveLinks = true}) { + return putByIndexSync(r'userId', object, saveLinks: saveLinks); + } + + Future> putAllByUserId(List objects) { + return putAllByIndex(r'userId', objects); + } + + List putAllByUserIdSync(List objects, {bool saveLinks = true}) { + return putAllByIndexSync(r'userId', objects, saveLinks: saveLinks); + } +} + +extension CLoginQueryWhereSort on QueryBuilder { + QueryBuilder anyId() { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(const IdWhereClause.any()); + }); + } +} + +extension CLoginQueryWhere on QueryBuilder { + QueryBuilder idEqualTo(Id id) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IdWhereClause.between( + lower: id, + upper: id, + )); + }); + } + + QueryBuilder idNotEqualTo(Id id) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause( + IdWhereClause.lessThan(upper: id, includeUpper: false), + ) + .addWhereClause( + IdWhereClause.greaterThan(lower: id, includeLower: false), + ); + } else { + return query + .addWhereClause( + IdWhereClause.greaterThan(lower: id, includeLower: false), + ) + .addWhereClause( + IdWhereClause.lessThan(upper: id, includeUpper: false), + ); + } + }); + } + + QueryBuilder idGreaterThan(Id id, + {bool include = false}) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause( + IdWhereClause.greaterThan(lower: id, includeLower: include), + ); + }); + } + + QueryBuilder idLessThan(Id id, + {bool include = false}) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause( + IdWhereClause.lessThan(upper: id, includeUpper: include), + ); + }); + } + + QueryBuilder idBetween( + Id lowerId, + Id upperId, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IdWhereClause.between( + lower: lowerId, + includeLower: includeLower, + upper: upperId, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder userIdEqualTo(String userId) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.equalTo( + indexName: r'userId', + value: [userId], + )); + }); + } + + QueryBuilder userIdNotEqualTo( + String userId) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'userId', + lower: [], + upper: [userId], + includeUpper: false, + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'userId', + lower: [userId], + includeLower: false, + upper: [], + )); + } else { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'userId', + lower: [userId], + includeLower: false, + upper: [], + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'userId', + lower: [], + upper: [userId], + includeUpper: false, + )); + } + }); + } +} + +extension CLoginQueryFilter on QueryBuilder { + QueryBuilder appInfoIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'appInfo', + )); + }); + } + + QueryBuilder appInfoIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'appInfo', + )); + }); + } + + QueryBuilder idEqualTo(Id value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'id', + value: value, + )); + }); + } + + QueryBuilder idGreaterThan( + Id value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'id', + value: value, + )); + }); + } + + QueryBuilder idLessThan( + Id value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'id', + value: value, + )); + }); + } + + QueryBuilder idBetween( + Id lower, + Id upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'id', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder lastConnectedAtIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'lastConnectedAt', + )); + }); + } + + QueryBuilder + lastConnectedAtIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'lastConnectedAt', + )); + }); + } + + QueryBuilder lastConnectedAtEqualTo( + int? value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'lastConnectedAt', + value: value, + )); + }); + } + + QueryBuilder + lastConnectedAtGreaterThan( + int? value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'lastConnectedAt', + value: value, + )); + }); + } + + QueryBuilder lastConnectedAtLessThan( + int? value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'lastConnectedAt', + value: value, + )); + }); + } + + QueryBuilder lastConnectedAtBetween( + int? lower, + int? upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'lastConnectedAt', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + maxUnreadCountOnSuperGroupIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'maxUnreadCountOnSuperGroup', + )); + }); + } + + QueryBuilder + maxUnreadCountOnSuperGroupIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'maxUnreadCountOnSuperGroup', + )); + }); + } + + QueryBuilder + maxUnreadCountOnSuperGroupEqualTo(int? value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'maxUnreadCountOnSuperGroup', + value: value, + )); + }); + } + + QueryBuilder + maxUnreadCountOnSuperGroupGreaterThan( + int? value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'maxUnreadCountOnSuperGroup', + value: value, + )); + }); + } + + QueryBuilder + maxUnreadCountOnSuperGroupLessThan( + int? value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'maxUnreadCountOnSuperGroup', + value: value, + )); + }); + } + + QueryBuilder + maxUnreadCountOnSuperGroupBetween( + int? lower, + int? upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'maxUnreadCountOnSuperGroup', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder reconnectConfigIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'reconnectConfig', + )); + }); + } + + QueryBuilder + reconnectConfigIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'reconnectConfig', + )); + }); + } + + QueryBuilder servicesElementEqualTo( + Service value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'services', + value: value, + )); + }); + } + + QueryBuilder + servicesElementGreaterThan( + Service value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'services', + value: value, + )); + }); + } + + QueryBuilder servicesElementLessThan( + Service value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'services', + value: value, + )); + }); + } + + QueryBuilder servicesElementBetween( + Service lower, + Service upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'services', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder servicesLengthEqualTo( + int length) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'services', + length, + true, + length, + true, + ); + }); + } + + QueryBuilder servicesIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'services', + 0, + true, + 0, + true, + ); + }); + } + + QueryBuilder servicesIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'services', + 0, + false, + 999999, + true, + ); + }); + } + + QueryBuilder servicesLengthLessThan( + int length, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'services', + 0, + true, + length, + include, + ); + }); + } + + QueryBuilder servicesLengthGreaterThan( + int length, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'services', + length, + include, + 999999, + true, + ); + }); + } + + QueryBuilder servicesLengthBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'services', + lower, + includeLower, + upper, + includeUpper, + ); + }); + } + + QueryBuilder uploadSizeLimitIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'uploadSizeLimit', + )); + }); + } + + QueryBuilder + uploadSizeLimitIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'uploadSizeLimit', + )); + }); + } + + QueryBuilder uploadSizeLimitEqualTo( + int? value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'uploadSizeLimit', + value: value, + )); + }); + } + + QueryBuilder + uploadSizeLimitGreaterThan( + int? value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'uploadSizeLimit', + value: value, + )); + }); + } + + QueryBuilder uploadSizeLimitLessThan( + int? value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'uploadSizeLimit', + value: value, + )); + }); + } + + QueryBuilder uploadSizeLimitBetween( + int? lower, + int? upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'uploadSizeLimit', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder userIdEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'userId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder userIdGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'userId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder userIdLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'userId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder userIdBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'userId', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder userIdStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'userId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder userIdEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'userId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder userIdContains( + String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'userId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder userIdMatches( + String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'userId', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder userIdIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'userId', + value: '', + )); + }); + } + + QueryBuilder userIdIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'userId', + value: '', + )); + }); + } +} + +extension CLoginQueryObject on QueryBuilder { + QueryBuilder appInfo( + FilterQuery q) { + return QueryBuilder.apply(this, (query) { + return query.object(q, r'appInfo'); + }); + } + + QueryBuilder reconnectConfig( + FilterQuery q) { + return QueryBuilder.apply(this, (query) { + return query.object(q, r'reconnectConfig'); + }); + } +} + +extension CLoginQueryLinks on QueryBuilder {} + +extension CLoginQuerySortBy on QueryBuilder { + QueryBuilder sortByLastConnectedAt() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'lastConnectedAt', Sort.asc); + }); + } + + QueryBuilder sortByLastConnectedAtDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'lastConnectedAt', Sort.desc); + }); + } + + QueryBuilder + sortByMaxUnreadCountOnSuperGroup() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'maxUnreadCountOnSuperGroup', Sort.asc); + }); + } + + QueryBuilder + sortByMaxUnreadCountOnSuperGroupDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'maxUnreadCountOnSuperGroup', Sort.desc); + }); + } + + QueryBuilder sortByUploadSizeLimit() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'uploadSizeLimit', Sort.asc); + }); + } + + QueryBuilder sortByUploadSizeLimitDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'uploadSizeLimit', Sort.desc); + }); + } + + QueryBuilder sortByUserId() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'userId', Sort.asc); + }); + } + + QueryBuilder sortByUserIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'userId', Sort.desc); + }); + } +} + +extension CLoginQuerySortThenBy on QueryBuilder { + QueryBuilder thenById() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'id', Sort.asc); + }); + } + + QueryBuilder thenByIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'id', Sort.desc); + }); + } + + QueryBuilder thenByLastConnectedAt() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'lastConnectedAt', Sort.asc); + }); + } + + QueryBuilder thenByLastConnectedAtDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'lastConnectedAt', Sort.desc); + }); + } + + QueryBuilder + thenByMaxUnreadCountOnSuperGroup() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'maxUnreadCountOnSuperGroup', Sort.asc); + }); + } + + QueryBuilder + thenByMaxUnreadCountOnSuperGroupDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'maxUnreadCountOnSuperGroup', Sort.desc); + }); + } + + QueryBuilder thenByUploadSizeLimit() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'uploadSizeLimit', Sort.asc); + }); + } + + QueryBuilder thenByUploadSizeLimitDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'uploadSizeLimit', Sort.desc); + }); + } + + QueryBuilder thenByUserId() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'userId', Sort.asc); + }); + } + + QueryBuilder thenByUserIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'userId', Sort.desc); + }); + } +} + +extension CLoginQueryWhereDistinct on QueryBuilder { + QueryBuilder distinctByLastConnectedAt() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'lastConnectedAt'); + }); + } + + QueryBuilder + distinctByMaxUnreadCountOnSuperGroup() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'maxUnreadCountOnSuperGroup'); + }); + } + + QueryBuilder distinctByServices() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'services'); + }); + } + + QueryBuilder distinctByUploadSizeLimit() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'uploadSizeLimit'); + }); + } + + QueryBuilder distinctByUserId( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'userId', caseSensitive: caseSensitive); + }); + } +} + +extension CLoginQueryProperty on QueryBuilder { + QueryBuilder idProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'id'); + }); + } + + QueryBuilder appInfoProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'appInfo'); + }); + } + + QueryBuilder lastConnectedAtProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'lastConnectedAt'); + }); + } + + QueryBuilder + maxUnreadCountOnSuperGroupProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'maxUnreadCountOnSuperGroup'); + }); + } + + QueryBuilder + reconnectConfigProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'reconnectConfig'); + }); + } + + QueryBuilder, QQueryOperations> servicesProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'services'); + }); + } + + QueryBuilder uploadSizeLimitProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'uploadSizeLimit'); + }); + } + + QueryBuilder userIdProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'userId'); + }); + } +} + +// ************************************************************************** +// IsarEmbeddedGenerator +// ************************************************************************** + +// coverage:ignore-file +// ignore_for_file: duplicate_ignore, non_constant_identifier_names, constant_identifier_names, invalid_use_of_protected_member, unnecessary_cast, prefer_const_constructors, lines_longer_than_80_chars, require_trailing_commas, inference_failure_on_function_invocation, unnecessary_parenthesis, unnecessary_raw_strings, unnecessary_null_checks, join_return_with_assignment, prefer_final_locals, avoid_js_rounded_ints, avoid_positional_boolean_parameters, always_specify_types + +final CAppInfoSchema = Schema( + name: r'CAppInfo', + id: BigInt.parse('-4428982506234657140').toInt(), + properties: { + r'allowSdkStatsUpload': PropertySchema( + id: 0, + name: r'allowSdkStatsUpload', + type: IsarType.bool, + ), + r'attributesInUse': PropertySchema( + id: 1, + name: r'attributesInUse', + type: IsarType.stringList, + ), + r'emojiHash': PropertySchema( + id: 2, + name: r'emojiHash', + type: IsarType.string, + ), + r'notificationInfo': PropertySchema( + id: 3, + name: r'notificationInfo', + type: IsarType.object, + target: r'CNotificationInfo', + ), + r'premiumFeatureList': PropertySchema( + id: 4, + name: r'premiumFeatureList', + type: IsarType.stringList, + ), + r'uploadSizeLimit': PropertySchema( + id: 5, + name: r'uploadSizeLimit', + type: IsarType.long, + ), + r'useReaction': PropertySchema( + id: 6, + name: r'useReaction', + type: IsarType.bool, + ) + }, + estimateSize: _cAppInfoEstimateSize, + serialize: _cAppInfoSerialize, + deserialize: _cAppInfoDeserialize, + deserializeProp: _cAppInfoDeserializeProp, +); + +int _cAppInfoEstimateSize( + CAppInfo object, + List offsets, + Map> allOffsets, +) { + var bytesCount = offsets.last; + bytesCount += 3 + object.attributesInUse.length * 3; + { + for (var i = 0; i < object.attributesInUse.length; i++) { + final value = object.attributesInUse[i]; + bytesCount += value.length * 3; + } + } + bytesCount += 3 + object.emojiHash.length * 3; + { + final value = object.notificationInfo; + if (value != null) { + bytesCount += 3 + + CNotificationInfoSchema.estimateSize( + value, allOffsets[CNotificationInfo]!, allOffsets); + } + } + bytesCount += 3 + object.premiumFeatureList.length * 3; + { + for (var i = 0; i < object.premiumFeatureList.length; i++) { + final value = object.premiumFeatureList[i]; + bytesCount += value.length * 3; + } + } + return bytesCount; +} + +void _cAppInfoSerialize( + CAppInfo object, + IsarWriter writer, + List offsets, + Map> allOffsets, +) { + writer.writeBool(offsets[0], object.allowSdkStatsUpload); + writer.writeStringList(offsets[1], object.attributesInUse); + writer.writeString(offsets[2], object.emojiHash); + writer.writeObject( + offsets[3], + allOffsets, + CNotificationInfoSchema.serialize, + object.notificationInfo, + ); + writer.writeStringList(offsets[4], object.premiumFeatureList); + writer.writeLong(offsets[5], object.uploadSizeLimit); + writer.writeBool(offsets[6], object.useReaction); +} + +CAppInfo _cAppInfoDeserialize( + Id id, + IsarReader reader, + List offsets, + Map> allOffsets, +) { + final object = CAppInfo(); + object.allowSdkStatsUpload = reader.readBool(offsets[0]); + object.attributesInUse = reader.readStringList(offsets[1]) ?? []; + object.emojiHash = reader.readString(offsets[2]); + object.notificationInfo = reader.readObjectOrNull( + offsets[3], + CNotificationInfoSchema.deserialize, + allOffsets, + ); + object.premiumFeatureList = reader.readStringList(offsets[4]) ?? []; + object.uploadSizeLimit = reader.readLong(offsets[5]); + object.useReaction = reader.readBool(offsets[6]); + return object; +} + +P _cAppInfoDeserializeProp

( + IsarReader reader, + int propertyId, + int offset, + Map> allOffsets, +) { + switch (propertyId) { + case 0: + return (reader.readBool(offset)) as P; + case 1: + return (reader.readStringList(offset) ?? []) as P; + case 2: + return (reader.readString(offset)) as P; + case 3: + return (reader.readObjectOrNull( + offset, + CNotificationInfoSchema.deserialize, + allOffsets, + )) as P; + case 4: + return (reader.readStringList(offset) ?? []) as P; + case 5: + return (reader.readLong(offset)) as P; + case 6: + return (reader.readBool(offset)) as P; + default: + throw IsarError('Unknown property with id $propertyId'); + } +} + +extension CAppInfoQueryFilter + on QueryBuilder { + QueryBuilder + allowSdkStatsUploadEqualTo(bool value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'allowSdkStatsUpload', + value: value, + )); + }); + } + + QueryBuilder + attributesInUseElementEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'attributesInUse', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + attributesInUseElementGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'attributesInUse', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + attributesInUseElementLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'attributesInUse', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + attributesInUseElementBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'attributesInUse', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + attributesInUseElementStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'attributesInUse', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + attributesInUseElementEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'attributesInUse', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + attributesInUseElementContains(String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'attributesInUse', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + attributesInUseElementMatches(String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'attributesInUse', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + attributesInUseElementIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'attributesInUse', + value: '', + )); + }); + } + + QueryBuilder + attributesInUseElementIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'attributesInUse', + value: '', + )); + }); + } + + QueryBuilder + attributesInUseLengthEqualTo(int length) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'attributesInUse', + length, + true, + length, + true, + ); + }); + } + + QueryBuilder + attributesInUseIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'attributesInUse', + 0, + true, + 0, + true, + ); + }); + } + + QueryBuilder + attributesInUseIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'attributesInUse', + 0, + false, + 999999, + true, + ); + }); + } + + QueryBuilder + attributesInUseLengthLessThan( + int length, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'attributesInUse', + 0, + true, + length, + include, + ); + }); + } + + QueryBuilder + attributesInUseLengthGreaterThan( + int length, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'attributesInUse', + length, + include, + 999999, + true, + ); + }); + } + + QueryBuilder + attributesInUseLengthBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'attributesInUse', + lower, + includeLower, + upper, + includeUpper, + ); + }); + } + + QueryBuilder emojiHashEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'emojiHash', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder emojiHashGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'emojiHash', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder emojiHashLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'emojiHash', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder emojiHashBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'emojiHash', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder emojiHashStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'emojiHash', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder emojiHashEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'emojiHash', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder emojiHashContains( + String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'emojiHash', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder emojiHashMatches( + String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'emojiHash', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder emojiHashIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'emojiHash', + value: '', + )); + }); + } + + QueryBuilder + emojiHashIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'emojiHash', + value: '', + )); + }); + } + + QueryBuilder + notificationInfoIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'notificationInfo', + )); + }); + } + + QueryBuilder + notificationInfoIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'notificationInfo', + )); + }); + } + + QueryBuilder + premiumFeatureListElementEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'premiumFeatureList', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + premiumFeatureListElementGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'premiumFeatureList', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + premiumFeatureListElementLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'premiumFeatureList', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + premiumFeatureListElementBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'premiumFeatureList', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + premiumFeatureListElementStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'premiumFeatureList', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + premiumFeatureListElementEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'premiumFeatureList', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + premiumFeatureListElementContains(String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'premiumFeatureList', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + premiumFeatureListElementMatches(String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'premiumFeatureList', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + premiumFeatureListElementIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'premiumFeatureList', + value: '', + )); + }); + } + + QueryBuilder + premiumFeatureListElementIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'premiumFeatureList', + value: '', + )); + }); + } + + QueryBuilder + premiumFeatureListLengthEqualTo(int length) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'premiumFeatureList', + length, + true, + length, + true, + ); + }); + } + + QueryBuilder + premiumFeatureListIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'premiumFeatureList', + 0, + true, + 0, + true, + ); + }); + } + + QueryBuilder + premiumFeatureListIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'premiumFeatureList', + 0, + false, + 999999, + true, + ); + }); + } + + QueryBuilder + premiumFeatureListLengthLessThan( + int length, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'premiumFeatureList', + 0, + true, + length, + include, + ); + }); + } + + QueryBuilder + premiumFeatureListLengthGreaterThan( + int length, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'premiumFeatureList', + length, + include, + 999999, + true, + ); + }); + } + + QueryBuilder + premiumFeatureListLengthBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'premiumFeatureList', + lower, + includeLower, + upper, + includeUpper, + ); + }); + } + + QueryBuilder + uploadSizeLimitEqualTo(int value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'uploadSizeLimit', + value: value, + )); + }); + } + + QueryBuilder + uploadSizeLimitGreaterThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'uploadSizeLimit', + value: value, + )); + }); + } + + QueryBuilder + uploadSizeLimitLessThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'uploadSizeLimit', + value: value, + )); + }); + } + + QueryBuilder + uploadSizeLimitBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'uploadSizeLimit', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder useReactionEqualTo( + bool value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'useReaction', + value: value, + )); + }); + } +} + +extension CAppInfoQueryObject + on QueryBuilder { + QueryBuilder notificationInfo( + FilterQuery q) { + return QueryBuilder.apply(this, (query) { + return query.object(q, r'notificationInfo'); + }); + } +} + +// coverage:ignore-file +// ignore_for_file: duplicate_ignore, non_constant_identifier_names, constant_identifier_names, invalid_use_of_protected_member, unnecessary_cast, prefer_const_constructors, lines_longer_than_80_chars, require_trailing_commas, inference_failure_on_function_invocation, unnecessary_parenthesis, unnecessary_raw_strings, unnecessary_null_checks, join_return_with_assignment, prefer_final_locals, avoid_js_rounded_ints, avoid_positional_boolean_parameters, always_specify_types + +final CNotificationInfoSchema = Schema( + name: r'CNotificationInfo', + id: BigInt.parse('2013809996163728336').toInt(), + properties: { + r'feedChannels': PropertySchema( + id: 0, + name: r'feedChannels', + type: IsarType.string, + ), + r'isEnabled': PropertySchema( + id: 1, + name: r'isEnabled', + type: IsarType.bool, + ), + r'settingsUpdatedAt': PropertySchema( + id: 2, + name: r'settingsUpdatedAt', + type: IsarType.long, + ), + r'templateListToken': PropertySchema( + id: 3, + name: r'templateListToken', + type: IsarType.string, + ) + }, + estimateSize: _cNotificationInfoEstimateSize, + serialize: _cNotificationInfoSerialize, + deserialize: _cNotificationInfoDeserialize, + deserializeProp: _cNotificationInfoDeserializeProp, +); + +int _cNotificationInfoEstimateSize( + CNotificationInfo object, + List offsets, + Map> allOffsets, +) { + var bytesCount = offsets.last; + bytesCount += 3 + object.feedChannels.length * 3; + { + final value = object.templateListToken; + if (value != null) { + bytesCount += 3 + value.length * 3; + } + } + return bytesCount; +} + +void _cNotificationInfoSerialize( + CNotificationInfo object, + IsarWriter writer, + List offsets, + Map> allOffsets, +) { + writer.writeString(offsets[0], object.feedChannels); + writer.writeBool(offsets[1], object.isEnabled); + writer.writeLong(offsets[2], object.settingsUpdatedAt); + writer.writeString(offsets[3], object.templateListToken); +} + +CNotificationInfo _cNotificationInfoDeserialize( + Id id, + IsarReader reader, + List offsets, + Map> allOffsets, +) { + final object = CNotificationInfo(); + object.feedChannels = reader.readString(offsets[0]); + object.isEnabled = reader.readBool(offsets[1]); + object.settingsUpdatedAt = reader.readLong(offsets[2]); + object.templateListToken = reader.readStringOrNull(offsets[3]); + return object; +} + +P _cNotificationInfoDeserializeProp

( + IsarReader reader, + int propertyId, + int offset, + Map> allOffsets, +) { + switch (propertyId) { + case 0: + return (reader.readString(offset)) as P; + case 1: + return (reader.readBool(offset)) as P; + case 2: + return (reader.readLong(offset)) as P; + case 3: + return (reader.readStringOrNull(offset)) as P; + default: + throw IsarError('Unknown property with id $propertyId'); + } +} + +extension CNotificationInfoQueryFilter + on QueryBuilder { + QueryBuilder + feedChannelsEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'feedChannels', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + feedChannelsGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'feedChannels', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + feedChannelsLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'feedChannels', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + feedChannelsBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'feedChannels', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + feedChannelsStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'feedChannels', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + feedChannelsEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'feedChannels', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + feedChannelsContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'feedChannels', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + feedChannelsMatches(String pattern, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'feedChannels', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + feedChannelsIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'feedChannels', + value: '', + )); + }); + } + + QueryBuilder + feedChannelsIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'feedChannels', + value: '', + )); + }); + } + + QueryBuilder + isEnabledEqualTo(bool value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'isEnabled', + value: value, + )); + }); + } + + QueryBuilder + settingsUpdatedAtEqualTo(int value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'settingsUpdatedAt', + value: value, + )); + }); + } + + QueryBuilder + settingsUpdatedAtGreaterThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'settingsUpdatedAt', + value: value, + )); + }); + } + + QueryBuilder + settingsUpdatedAtLessThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'settingsUpdatedAt', + value: value, + )); + }); + } + + QueryBuilder + settingsUpdatedAtBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'settingsUpdatedAt', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + templateListTokenIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'templateListToken', + )); + }); + } + + QueryBuilder + templateListTokenIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'templateListToken', + )); + }); + } + + QueryBuilder + templateListTokenEqualTo( + String? value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'templateListToken', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + templateListTokenGreaterThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'templateListToken', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + templateListTokenLessThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'templateListToken', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + templateListTokenBetween( + String? lower, + String? upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'templateListToken', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + templateListTokenStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'templateListToken', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + templateListTokenEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'templateListToken', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + templateListTokenContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'templateListToken', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + templateListTokenMatches(String pattern, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'templateListToken', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + templateListTokenIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'templateListToken', + value: '', + )); + }); + } + + QueryBuilder + templateListTokenIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'templateListToken', + value: '', + )); + }); + } +} + +extension CNotificationInfoQueryObject + on QueryBuilder {} + +// coverage:ignore-file +// ignore_for_file: duplicate_ignore, non_constant_identifier_names, constant_identifier_names, invalid_use_of_protected_member, unnecessary_cast, prefer_const_constructors, lines_longer_than_80_chars, require_trailing_commas, inference_failure_on_function_invocation, unnecessary_parenthesis, unnecessary_raw_strings, unnecessary_null_checks, join_return_with_assignment, prefer_final_locals, avoid_js_rounded_ints, avoid_positional_boolean_parameters, always_specify_types + +final CReconnectConfigurationSchema = Schema( + name: r'CReconnectConfiguration', + id: BigInt.parse('4193108221451927222').toInt(), + properties: { + r'interval': PropertySchema( + id: 0, + name: r'interval', + type: IsarType.double, + ), + r'maxInterval': PropertySchema( + id: 1, + name: r'maxInterval', + type: IsarType.double, + ), + r'maximumRetryCount': PropertySchema( + id: 2, + name: r'maximumRetryCount', + type: IsarType.long, + ), + r'multiplier': PropertySchema( + id: 3, + name: r'multiplier', + type: IsarType.long, + ) + }, + estimateSize: _cReconnectConfigurationEstimateSize, + serialize: _cReconnectConfigurationSerialize, + deserialize: _cReconnectConfigurationDeserialize, + deserializeProp: _cReconnectConfigurationDeserializeProp, +); + +int _cReconnectConfigurationEstimateSize( + CReconnectConfiguration object, + List offsets, + Map> allOffsets, +) { + var bytesCount = offsets.last; + return bytesCount; +} + +void _cReconnectConfigurationSerialize( + CReconnectConfiguration object, + IsarWriter writer, + List offsets, + Map> allOffsets, +) { + writer.writeDouble(offsets[0], object.interval); + writer.writeDouble(offsets[1], object.maxInterval); + writer.writeLong(offsets[2], object.maximumRetryCount); + writer.writeLong(offsets[3], object.multiplier); +} + +CReconnectConfiguration _cReconnectConfigurationDeserialize( + Id id, + IsarReader reader, + List offsets, + Map> allOffsets, +) { + final object = CReconnectConfiguration(); + object.interval = reader.readDouble(offsets[0]); + object.maxInterval = reader.readDouble(offsets[1]); + object.maximumRetryCount = reader.readLong(offsets[2]); + object.multiplier = reader.readLong(offsets[3]); + return object; +} + +P _cReconnectConfigurationDeserializeProp

( + IsarReader reader, + int propertyId, + int offset, + Map> allOffsets, +) { + switch (propertyId) { + case 0: + return (reader.readDouble(offset)) as P; + case 1: + return (reader.readDouble(offset)) as P; + case 2: + return (reader.readLong(offset)) as P; + case 3: + return (reader.readLong(offset)) as P; + default: + throw IsarError('Unknown property with id $propertyId'); + } +} + +extension CReconnectConfigurationQueryFilter on QueryBuilder< + CReconnectConfiguration, CReconnectConfiguration, QFilterCondition> { + QueryBuilder intervalEqualTo( + double value, { + double epsilon = Query.epsilon, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'interval', + value: value, + epsilon: epsilon, + )); + }); + } + + QueryBuilder intervalGreaterThan( + double value, { + bool include = false, + double epsilon = Query.epsilon, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'interval', + value: value, + epsilon: epsilon, + )); + }); + } + + QueryBuilder intervalLessThan( + double value, { + bool include = false, + double epsilon = Query.epsilon, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'interval', + value: value, + epsilon: epsilon, + )); + }); + } + + QueryBuilder intervalBetween( + double lower, + double upper, { + bool includeLower = true, + bool includeUpper = true, + double epsilon = Query.epsilon, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'interval', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + epsilon: epsilon, + )); + }); + } + + QueryBuilder maxIntervalEqualTo( + double value, { + double epsilon = Query.epsilon, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'maxInterval', + value: value, + epsilon: epsilon, + )); + }); + } + + QueryBuilder maxIntervalGreaterThan( + double value, { + bool include = false, + double epsilon = Query.epsilon, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'maxInterval', + value: value, + epsilon: epsilon, + )); + }); + } + + QueryBuilder maxIntervalLessThan( + double value, { + bool include = false, + double epsilon = Query.epsilon, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'maxInterval', + value: value, + epsilon: epsilon, + )); + }); + } + + QueryBuilder maxIntervalBetween( + double lower, + double upper, { + bool includeLower = true, + bool includeUpper = true, + double epsilon = Query.epsilon, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'maxInterval', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + epsilon: epsilon, + )); + }); + } + + QueryBuilder maximumRetryCountEqualTo(int value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'maximumRetryCount', + value: value, + )); + }); + } + + QueryBuilder maximumRetryCountGreaterThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'maximumRetryCount', + value: value, + )); + }); + } + + QueryBuilder maximumRetryCountLessThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'maximumRetryCount', + value: value, + )); + }); + } + + QueryBuilder maximumRetryCountBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'maximumRetryCount', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder multiplierEqualTo(int value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'multiplier', + value: value, + )); + }); + } + + QueryBuilder multiplierGreaterThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'multiplier', + value: value, + )); + }); + } + + QueryBuilder multiplierLessThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'multiplier', + value: value, + )); + }); + } + + QueryBuilder multiplierBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'multiplier', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } +} + +extension CReconnectConfigurationQueryObject on QueryBuilder< + CReconnectConfiguration, CReconnectConfiguration, QFilterCondition> {} diff --git a/lib/src/internal/db/schema/login/login.dart b/lib/src/internal/db/schema/login/login.dart new file mode 100644 index 00000000..44a6b6d1 --- /dev/null +++ b/lib/src/internal/db/schema/login/login.dart @@ -0,0 +1,32 @@ +// Copyright (c) 2023 Sendbird, Inc. All rights reserved. + +import 'package:sendbird_chat_sdk/src/internal/main/chat/chat.dart'; +import 'package:sendbird_chat_sdk/src/internal/main/chat_context/chat_context.dart'; +import 'package:sendbird_chat_sdk/src/internal/main/model/reconnect_configuration.dart'; +import 'package:sendbird_chat_sdk/src/public/main/chat/sendbird_chat.dart'; +import 'package:sendbird_chat_sdk/src/public/main/model/info/app_info.dart'; + +class Login { + final String userId; + final List services; + AppInfo? appInfo; + final int uploadSizeLimit; + int? maxUnreadCountOnSuperGroup; + int? lastConnectedAt; + ReconnectConfiguration? reconnectConfig; + + final Chat chat; + + Login({ + required this.userId, + List? services, + this.appInfo, + int? uploadSizeLimit, + this.maxUnreadCountOnSuperGroup, + this.lastConnectedAt, + this.reconnectConfig, + Chat? chat, + }) : services = services ?? [], + uploadSizeLimit = uploadSizeLimit ?? 0, + chat = chat ?? SendbirdChat().chat; +} diff --git a/lib/src/internal/db/schema/message/c_admin_message.dart b/lib/src/internal/db/schema/message/c_admin_message.dart new file mode 100644 index 00000000..69bf3c4a --- /dev/null +++ b/lib/src/internal/db/schema/message/c_admin_message.dart @@ -0,0 +1,74 @@ +// Copyright (c) 2023 Sendbird, Inc. All rights reserved. + +import 'package:isar/isar.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/message/c_base_message.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/message/c_root_message.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/message/meta/c_channel_message.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/user/c_sender.dart'; +import 'package:sendbird_chat_sdk/src/internal/main/chat/chat.dart'; +import 'package:sendbird_chat_sdk/src/public/core/message/admin_message.dart'; +import 'package:sendbird_chat_sdk/src/public/core/message/root_message.dart'; +import 'package:sendbird_chat_sdk/src/public/main/define/enums.dart'; + +part 'c_admin_message.g.dart'; + +@collection +class CAdminMessage extends CBaseMessage { + CAdminMessage(); + + factory CAdminMessage.fromAdminMessage(AdminMessage message) { + return CAdminMessage() + // BaseMessage + ..setBaseMessage(message); + } + + Future toAdminMessage(Chat chat, Isar isar) async { + final adminMessage = AdminMessage( + // RootMessage + channelUrl: channelUrl, + channelType: channelType, + // BaseMessage + messageId: messageId, + message: message, + )..set(chat); + return await CBaseMessage.setCBaseMessage(chat, isar, adminMessage, this) + as AdminMessage; + } + + static Future upsert( + Chat chat, Isar isar, AdminMessage message) async { + final cAdminMessage = CAdminMessage.fromAdminMessage(message); + + // RootMessage + await CRootMessage.upsert(chat, isar, message); + + // BaseMessage + await CBaseMessage.upsert(chat, isar, message); + + // AdminMessage + await chat.dbManager.write(() async { + await isar.cAdminMessages.put(cAdminMessage); + }); + + // ChannelMessage + await CChannelMessage.upsert(chat, isar, message); + + return cAdminMessage; + } + + static Future get(Chat chat, Isar isar, String rootId) async { + final cAdminMessage = + await isar.cAdminMessages.where().rootIdEqualTo(rootId).findFirst(); + return await cAdminMessage?.toAdminMessage(chat, isar); + } + + static Future delete(Chat chat, Isar isar, String rootId) async { + // AdminMessage + await chat.dbManager.write(() async { + await isar.cAdminMessages.deleteByRootId(rootId); + }); + + // ChannelMessage + await CChannelMessage.delete(chat, isar, rootId); + } +} diff --git a/lib/src/internal/db/schema/message/c_admin_message.g.dart b/lib/src/internal/db/schema/message/c_admin_message.g.dart new file mode 100644 index 00000000..f82d287b --- /dev/null +++ b/lib/src/internal/db/schema/message/c_admin_message.g.dart @@ -0,0 +1,4623 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'c_admin_message.dart'; + +// ************************************************************************** +// IsarCollectionGenerator +// ************************************************************************** + +// coverage:ignore-file +// ignore_for_file: duplicate_ignore, non_constant_identifier_names, constant_identifier_names, invalid_use_of_protected_member, unnecessary_cast, prefer_const_constructors, lines_longer_than_80_chars, require_trailing_commas, inference_failure_on_function_invocation, unnecessary_parenthesis, unnecessary_raw_strings, unnecessary_null_checks, join_return_with_assignment, prefer_final_locals, avoid_js_rounded_ints, avoid_positional_boolean_parameters, always_specify_types + +extension GetCAdminMessageCollection on Isar { + IsarCollection get cAdminMessages => this.collection(); +} + +final CAdminMessageSchema = CollectionSchema( + name: r'CAdminMessage', + id: BigInt.parse('-4690870483801023253').toInt(), + properties: { + r'allMetaArrays': PropertySchema( + id: 0, + name: r'allMetaArrays', + type: IsarType.objectList, + target: r'CMessageMetaArray', + ), + r'channelType': PropertySchema( + id: 1, + name: r'channelType', + type: IsarType.byte, + enumMap: _CAdminMessagechannelTypeEnumValueMap, + ), + r'channelUrl': PropertySchema( + id: 2, + name: r'channelUrl', + type: IsarType.string, + ), + r'createdAt': PropertySchema( + id: 3, + name: r'createdAt', + type: IsarType.long, + ), + r'customType': PropertySchema( + id: 4, + name: r'customType', + type: IsarType.string, + ), + r'data': PropertySchema( + id: 5, + name: r'data', + type: IsarType.string, + ), + r'errorCode': PropertySchema( + id: 6, + name: r'errorCode', + type: IsarType.long, + ), + r'extendedMessage': PropertySchema( + id: 7, + name: r'extendedMessage', + type: IsarType.string, + ), + r'isOperatorMessage': PropertySchema( + id: 8, + name: r'isOperatorMessage', + type: IsarType.bool, + ), + r'isReplyToChannel': PropertySchema( + id: 9, + name: r'isReplyToChannel', + type: IsarType.bool, + ), + r'isSilent': PropertySchema( + id: 10, + name: r'isSilent', + type: IsarType.bool, + ), + r'mentionType': PropertySchema( + id: 11, + name: r'mentionType', + type: IsarType.byte, + enumMap: _CAdminMessagementionTypeEnumValueMap, + ), + r'mentionedUsers': PropertySchema( + id: 12, + name: r'mentionedUsers', + type: IsarType.stringList, + ), + r'message': PropertySchema( + id: 13, + name: r'message', + type: IsarType.string, + ), + r'messageId': PropertySchema( + id: 14, + name: r'messageId', + type: IsarType.long, + ), + r'messageSurvivalSeconds': PropertySchema( + id: 15, + name: r'messageSurvivalSeconds', + type: IsarType.long, + ), + r'messageType': PropertySchema( + id: 16, + name: r'messageType', + type: IsarType.byte, + enumMap: _CAdminMessagemessageTypeEnumValueMap, + ), + r'ogMetaData': PropertySchema( + id: 17, + name: r'ogMetaData', + type: IsarType.object, + target: r'COGMetaData', + ), + r'parentMessageId': PropertySchema( + id: 18, + name: r'parentMessageId', + type: IsarType.long, + ), + r'parentMessageRootId': PropertySchema( + id: 19, + name: r'parentMessageRootId', + type: IsarType.string, + ), + r'parentMessageType': PropertySchema( + id: 20, + name: r'parentMessageType', + type: IsarType.byte, + enumMap: _CAdminMessageparentMessageTypeEnumValueMap, + ), + r'reactions': PropertySchema( + id: 21, + name: r'reactions', + type: IsarType.objectList, + target: r'CReaction', + ), + r'requestId': PropertySchema( + id: 22, + name: r'requestId', + type: IsarType.string, + ), + r'rootId': PropertySchema( + id: 23, + name: r'rootId', + type: IsarType.string, + ), + r'scheduledInfo': PropertySchema( + id: 24, + name: r'scheduledInfo', + type: IsarType.object, + target: r'CScheduledInfo', + ), + r'sender': PropertySchema( + id: 25, + name: r'sender', + type: IsarType.object, + target: r'CSender', + ), + r'sendingStatus': PropertySchema( + id: 26, + name: r'sendingStatus', + type: IsarType.byte, + enumMap: _CAdminMessagesendingStatusEnumValueMap, + ), + r'threadInfo': PropertySchema( + id: 27, + name: r'threadInfo', + type: IsarType.object, + target: r'CThreadInfo', + ), + r'updatedAt': PropertySchema( + id: 28, + name: r'updatedAt', + type: IsarType.long, + ) + }, + estimateSize: _cAdminMessageEstimateSize, + serialize: _cAdminMessageSerialize, + deserialize: _cAdminMessageDeserialize, + deserializeProp: _cAdminMessageDeserializeProp, + idName: r'id', + indexes: { + r'rootId': IndexSchema( + id: BigInt.parse('5087693435549841488').toInt(), + name: r'rootId', + unique: true, + replace: true, + properties: [ + IndexPropertySchema( + name: r'rootId', + type: IndexType.hash, + caseSensitive: true, + ) + ], + ), + r'messageType_rootId': IndexSchema( + id: BigInt.parse('-7060804333380842370').toInt(), + name: r'messageType_rootId', + unique: false, + replace: false, + properties: [ + IndexPropertySchema( + name: r'messageType', + type: IndexType.value, + caseSensitive: false, + ), + IndexPropertySchema( + name: r'rootId', + type: IndexType.hash, + caseSensitive: true, + ) + ], + ), + r'channelUrl': IndexSchema( + id: BigInt.parse('6636052684858767397').toInt(), + name: r'channelUrl', + unique: false, + replace: false, + properties: [ + IndexPropertySchema( + name: r'channelUrl', + type: IndexType.hash, + caseSensitive: true, + ) + ], + ), + r'channelType_channelUrl': IndexSchema( + id: BigInt.parse('-5957547153902522682').toInt(), + name: r'channelType_channelUrl', + unique: false, + replace: false, + properties: [ + IndexPropertySchema( + name: r'channelType', + type: IndexType.value, + caseSensitive: false, + ), + IndexPropertySchema( + name: r'channelUrl', + type: IndexType.hash, + caseSensitive: true, + ) + ], + ) + }, + links: {}, + embeddedSchemas: { + r'CThreadInfo': CThreadInfoSchema, + r'COGMetaData': COGMetaDataSchema, + r'COGImage': COGImageSchema, + r'CReaction': CReactionSchema, + r'CScheduledInfo': CScheduledInfoSchema, + r'CSender': CSenderSchema, + r'CMessageMetaArray': CMessageMetaArraySchema + }, + getId: _cAdminMessageGetId, + getLinks: _cAdminMessageGetLinks, + attach: _cAdminMessageAttach, + version: '3.1.0+1', +); + +int _cAdminMessageEstimateSize( + CAdminMessage object, + List offsets, + Map> allOffsets, +) { + var bytesCount = offsets.last; + { + final list = object.allMetaArrays; + if (list != null) { + bytesCount += 3 + list.length * 3; + { + final offsets = allOffsets[CMessageMetaArray]!; + for (var i = 0; i < list.length; i++) { + final value = list[i]; + bytesCount += + CMessageMetaArraySchema.estimateSize(value, offsets, allOffsets); + } + } + } + } + bytesCount += 3 + object.channelUrl.length * 3; + { + final value = object.customType; + if (value != null) { + bytesCount += 3 + value.length * 3; + } + } + { + final value = object.data; + if (value != null) { + bytesCount += 3 + value.length * 3; + } + } + bytesCount += 3 + object.extendedMessage.length * 3; + bytesCount += 3 + object.mentionedUsers.length * 3; + { + for (var i = 0; i < object.mentionedUsers.length; i++) { + final value = object.mentionedUsers[i]; + bytesCount += value.length * 3; + } + } + bytesCount += 3 + object.message.length * 3; + { + final value = object.ogMetaData; + if (value != null) { + bytesCount += 3 + + COGMetaDataSchema.estimateSize( + value, allOffsets[COGMetaData]!, allOffsets); + } + } + { + final value = object.parentMessageRootId; + if (value != null) { + bytesCount += 3 + value.length * 3; + } + } + { + final list = object.reactions; + if (list != null) { + bytesCount += 3 + list.length * 3; + { + final offsets = allOffsets[CReaction]!; + for (var i = 0; i < list.length; i++) { + final value = list[i]; + bytesCount += + CReactionSchema.estimateSize(value, offsets, allOffsets); + } + } + } + } + { + final value = object.requestId; + if (value != null) { + bytesCount += 3 + value.length * 3; + } + } + bytesCount += 3 + object.rootId.length * 3; + { + final value = object.scheduledInfo; + if (value != null) { + bytesCount += 3 + + CScheduledInfoSchema.estimateSize( + value, allOffsets[CScheduledInfo]!, allOffsets); + } + } + { + final value = object.sender; + if (value != null) { + bytesCount += 3 + + CSenderSchema.estimateSize(value, allOffsets[CSender]!, allOffsets); + } + } + { + final value = object.threadInfo; + if (value != null) { + bytesCount += 3 + + CThreadInfoSchema.estimateSize( + value, allOffsets[CThreadInfo]!, allOffsets); + } + } + return bytesCount; +} + +void _cAdminMessageSerialize( + CAdminMessage object, + IsarWriter writer, + List offsets, + Map> allOffsets, +) { + writer.writeObjectList( + offsets[0], + allOffsets, + CMessageMetaArraySchema.serialize, + object.allMetaArrays, + ); + writer.writeByte(offsets[1], object.channelType.index); + writer.writeString(offsets[2], object.channelUrl); + writer.writeLong(offsets[3], object.createdAt); + writer.writeString(offsets[4], object.customType); + writer.writeString(offsets[5], object.data); + writer.writeLong(offsets[6], object.errorCode); + writer.writeString(offsets[7], object.extendedMessage); + writer.writeBool(offsets[8], object.isOperatorMessage); + writer.writeBool(offsets[9], object.isReplyToChannel); + writer.writeBool(offsets[10], object.isSilent); + writer.writeByte(offsets[11], object.mentionType.index); + writer.writeStringList(offsets[12], object.mentionedUsers); + writer.writeString(offsets[13], object.message); + writer.writeLong(offsets[14], object.messageId); + writer.writeLong(offsets[15], object.messageSurvivalSeconds); + writer.writeByte(offsets[16], object.messageType.index); + writer.writeObject( + offsets[17], + allOffsets, + COGMetaDataSchema.serialize, + object.ogMetaData, + ); + writer.writeLong(offsets[18], object.parentMessageId); + writer.writeString(offsets[19], object.parentMessageRootId); + writer.writeByte(offsets[20], object.parentMessageType.index); + writer.writeObjectList( + offsets[21], + allOffsets, + CReactionSchema.serialize, + object.reactions, + ); + writer.writeString(offsets[22], object.requestId); + writer.writeString(offsets[23], object.rootId); + writer.writeObject( + offsets[24], + allOffsets, + CScheduledInfoSchema.serialize, + object.scheduledInfo, + ); + writer.writeObject( + offsets[25], + allOffsets, + CSenderSchema.serialize, + object.sender, + ); + writer.writeByte(offsets[26], object.sendingStatus.index); + writer.writeObject( + offsets[27], + allOffsets, + CThreadInfoSchema.serialize, + object.threadInfo, + ); + writer.writeLong(offsets[28], object.updatedAt); +} + +CAdminMessage _cAdminMessageDeserialize( + Id id, + IsarReader reader, + List offsets, + Map> allOffsets, +) { + final object = CAdminMessage(); + object.allMetaArrays = reader.readObjectList( + offsets[0], + CMessageMetaArraySchema.deserialize, + allOffsets, + CMessageMetaArray(), + ); + object.channelType = _CAdminMessagechannelTypeValueEnumMap[ + reader.readByteOrNull(offsets[1])] ?? + ChannelType.group; + object.channelUrl = reader.readString(offsets[2]); + object.createdAt = reader.readLong(offsets[3]); + object.customType = reader.readStringOrNull(offsets[4]); + object.data = reader.readStringOrNull(offsets[5]); + object.errorCode = reader.readLongOrNull(offsets[6]); + object.extendedMessage = reader.readString(offsets[7]); + object.id = id; + object.isOperatorMessage = reader.readBool(offsets[8]); + object.isReplyToChannel = reader.readBool(offsets[9]); + object.isSilent = reader.readBool(offsets[10]); + object.mentionType = _CAdminMessagementionTypeValueEnumMap[ + reader.readByteOrNull(offsets[11])] ?? + MentionType.users; + object.mentionedUsers = reader.readStringList(offsets[12]) ?? []; + object.message = reader.readString(offsets[13]); + object.messageId = reader.readLong(offsets[14]); + object.messageSurvivalSeconds = reader.readLongOrNull(offsets[15]); + object.messageType = _CAdminMessagemessageTypeValueEnumMap[ + reader.readByteOrNull(offsets[16])] ?? + MessageType.user; + object.ogMetaData = reader.readObjectOrNull( + offsets[17], + COGMetaDataSchema.deserialize, + allOffsets, + ); + object.parentMessageId = reader.readLongOrNull(offsets[18]); + object.parentMessageRootId = reader.readStringOrNull(offsets[19]); + object.parentMessageType = _CAdminMessageparentMessageTypeValueEnumMap[ + reader.readByteOrNull(offsets[20])] ?? + MessageType.user; + object.reactions = reader.readObjectList( + offsets[21], + CReactionSchema.deserialize, + allOffsets, + CReaction(), + ); + object.requestId = reader.readStringOrNull(offsets[22]); + object.rootId = reader.readString(offsets[23]); + object.scheduledInfo = reader.readObjectOrNull( + offsets[24], + CScheduledInfoSchema.deserialize, + allOffsets, + ); + object.sender = reader.readObjectOrNull( + offsets[25], + CSenderSchema.deserialize, + allOffsets, + ); + object.sendingStatus = _CAdminMessagesendingStatusValueEnumMap[ + reader.readByteOrNull(offsets[26])] ?? + SendingStatus.none; + object.threadInfo = reader.readObjectOrNull( + offsets[27], + CThreadInfoSchema.deserialize, + allOffsets, + ); + object.updatedAt = reader.readLong(offsets[28]); + return object; +} + +P _cAdminMessageDeserializeProp

( + IsarReader reader, + int propertyId, + int offset, + Map> allOffsets, +) { + switch (propertyId) { + case 0: + return (reader.readObjectList( + offset, + CMessageMetaArraySchema.deserialize, + allOffsets, + CMessageMetaArray(), + )) as P; + case 1: + return (_CAdminMessagechannelTypeValueEnumMap[ + reader.readByteOrNull(offset)] ?? + ChannelType.group) as P; + case 2: + return (reader.readString(offset)) as P; + case 3: + return (reader.readLong(offset)) as P; + case 4: + return (reader.readStringOrNull(offset)) as P; + case 5: + return (reader.readStringOrNull(offset)) as P; + case 6: + return (reader.readLongOrNull(offset)) as P; + case 7: + return (reader.readString(offset)) as P; + case 8: + return (reader.readBool(offset)) as P; + case 9: + return (reader.readBool(offset)) as P; + case 10: + return (reader.readBool(offset)) as P; + case 11: + return (_CAdminMessagementionTypeValueEnumMap[ + reader.readByteOrNull(offset)] ?? + MentionType.users) as P; + case 12: + return (reader.readStringList(offset) ?? []) as P; + case 13: + return (reader.readString(offset)) as P; + case 14: + return (reader.readLong(offset)) as P; + case 15: + return (reader.readLongOrNull(offset)) as P; + case 16: + return (_CAdminMessagemessageTypeValueEnumMap[ + reader.readByteOrNull(offset)] ?? + MessageType.user) as P; + case 17: + return (reader.readObjectOrNull( + offset, + COGMetaDataSchema.deserialize, + allOffsets, + )) as P; + case 18: + return (reader.readLongOrNull(offset)) as P; + case 19: + return (reader.readStringOrNull(offset)) as P; + case 20: + return (_CAdminMessageparentMessageTypeValueEnumMap[ + reader.readByteOrNull(offset)] ?? + MessageType.user) as P; + case 21: + return (reader.readObjectList( + offset, + CReactionSchema.deserialize, + allOffsets, + CReaction(), + )) as P; + case 22: + return (reader.readStringOrNull(offset)) as P; + case 23: + return (reader.readString(offset)) as P; + case 24: + return (reader.readObjectOrNull( + offset, + CScheduledInfoSchema.deserialize, + allOffsets, + )) as P; + case 25: + return (reader.readObjectOrNull( + offset, + CSenderSchema.deserialize, + allOffsets, + )) as P; + case 26: + return (_CAdminMessagesendingStatusValueEnumMap[ + reader.readByteOrNull(offset)] ?? + SendingStatus.none) as P; + case 27: + return (reader.readObjectOrNull( + offset, + CThreadInfoSchema.deserialize, + allOffsets, + )) as P; + case 28: + return (reader.readLong(offset)) as P; + default: + throw IsarError('Unknown property with id $propertyId'); + } +} + +const _CAdminMessagechannelTypeEnumValueMap = { + 'group': 0, + 'open': 1, + 'feed': 2, +}; +const _CAdminMessagechannelTypeValueEnumMap = { + 0: ChannelType.group, + 1: ChannelType.open, + 2: ChannelType.feed, +}; +const _CAdminMessagementionTypeEnumValueMap = { + 'users': 0, + 'channel': 1, +}; +const _CAdminMessagementionTypeValueEnumMap = { + 0: MentionType.users, + 1: MentionType.channel, +}; +const _CAdminMessagemessageTypeEnumValueMap = { + 'user': 0, + 'file': 1, + 'admin': 2, + 'notification': 3, +}; +const _CAdminMessagemessageTypeValueEnumMap = { + 0: MessageType.user, + 1: MessageType.file, + 2: MessageType.admin, + 3: MessageType.notification, +}; +const _CAdminMessageparentMessageTypeEnumValueMap = { + 'user': 0, + 'file': 1, + 'admin': 2, + 'notification': 3, +}; +const _CAdminMessageparentMessageTypeValueEnumMap = { + 0: MessageType.user, + 1: MessageType.file, + 2: MessageType.admin, + 3: MessageType.notification, +}; +const _CAdminMessagesendingStatusEnumValueMap = { + 'none': 0, + 'pending': 1, + 'failed': 2, + 'succeeded': 3, + 'canceled': 4, +}; +const _CAdminMessagesendingStatusValueEnumMap = { + 0: SendingStatus.none, + 1: SendingStatus.pending, + 2: SendingStatus.failed, + 3: SendingStatus.succeeded, + 4: SendingStatus.canceled, +}; + +Id _cAdminMessageGetId(CAdminMessage object) { + return object.id; +} + +List> _cAdminMessageGetLinks(CAdminMessage object) { + return []; +} + +void _cAdminMessageAttach( + IsarCollection col, Id id, CAdminMessage object) { + object.id = id; +} + +extension CAdminMessageByIndex on IsarCollection { + Future getByRootId(String rootId) { + return getByIndex(r'rootId', [rootId]); + } + + CAdminMessage? getByRootIdSync(String rootId) { + return getByIndexSync(r'rootId', [rootId]); + } + + Future deleteByRootId(String rootId) { + return deleteByIndex(r'rootId', [rootId]); + } + + bool deleteByRootIdSync(String rootId) { + return deleteByIndexSync(r'rootId', [rootId]); + } + + Future> getAllByRootId(List rootIdValues) { + final values = rootIdValues.map((e) => [e]).toList(); + return getAllByIndex(r'rootId', values); + } + + List getAllByRootIdSync(List rootIdValues) { + final values = rootIdValues.map((e) => [e]).toList(); + return getAllByIndexSync(r'rootId', values); + } + + Future deleteAllByRootId(List rootIdValues) { + final values = rootIdValues.map((e) => [e]).toList(); + return deleteAllByIndex(r'rootId', values); + } + + int deleteAllByRootIdSync(List rootIdValues) { + final values = rootIdValues.map((e) => [e]).toList(); + return deleteAllByIndexSync(r'rootId', values); + } + + Future putByRootId(CAdminMessage object) { + return putByIndex(r'rootId', object); + } + + Id putByRootIdSync(CAdminMessage object, {bool saveLinks = true}) { + return putByIndexSync(r'rootId', object, saveLinks: saveLinks); + } + + Future> putAllByRootId(List objects) { + return putAllByIndex(r'rootId', objects); + } + + List putAllByRootIdSync(List objects, + {bool saveLinks = true}) { + return putAllByIndexSync(r'rootId', objects, saveLinks: saveLinks); + } +} + +extension CAdminMessageQueryWhereSort + on QueryBuilder { + QueryBuilder anyId() { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(const IdWhereClause.any()); + }); + } +} + +extension CAdminMessageQueryWhere + on QueryBuilder { + QueryBuilder idEqualTo( + Id id) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IdWhereClause.between( + lower: id, + upper: id, + )); + }); + } + + QueryBuilder idNotEqualTo( + Id id) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause( + IdWhereClause.lessThan(upper: id, includeUpper: false), + ) + .addWhereClause( + IdWhereClause.greaterThan(lower: id, includeLower: false), + ); + } else { + return query + .addWhereClause( + IdWhereClause.greaterThan(lower: id, includeLower: false), + ) + .addWhereClause( + IdWhereClause.lessThan(upper: id, includeUpper: false), + ); + } + }); + } + + QueryBuilder idGreaterThan( + Id id, + {bool include = false}) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause( + IdWhereClause.greaterThan(lower: id, includeLower: include), + ); + }); + } + + QueryBuilder idLessThan( + Id id, + {bool include = false}) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause( + IdWhereClause.lessThan(upper: id, includeUpper: include), + ); + }); + } + + QueryBuilder idBetween( + Id lowerId, + Id upperId, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IdWhereClause.between( + lower: lowerId, + includeLower: includeLower, + upper: upperId, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder rootIdEqualTo( + String rootId) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.equalTo( + indexName: r'rootId', + value: [rootId], + )); + }); + } + + QueryBuilder + rootIdNotEqualTo(String rootId) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'rootId', + lower: [], + upper: [rootId], + includeUpper: false, + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'rootId', + lower: [rootId], + includeLower: false, + upper: [], + )); + } else { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'rootId', + lower: [rootId], + includeLower: false, + upper: [], + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'rootId', + lower: [], + upper: [rootId], + includeUpper: false, + )); + } + }); + } + + QueryBuilder + messageTypeEqualToAnyRootId(MessageType messageType) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.equalTo( + indexName: r'messageType_rootId', + value: [messageType], + )); + }); + } + + QueryBuilder + messageTypeNotEqualToAnyRootId(MessageType messageType) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'messageType_rootId', + lower: [], + upper: [messageType], + includeUpper: false, + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'messageType_rootId', + lower: [messageType], + includeLower: false, + upper: [], + )); + } else { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'messageType_rootId', + lower: [messageType], + includeLower: false, + upper: [], + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'messageType_rootId', + lower: [], + upper: [messageType], + includeUpper: false, + )); + } + }); + } + + QueryBuilder + messageTypeGreaterThanAnyRootId( + MessageType messageType, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.between( + indexName: r'messageType_rootId', + lower: [messageType], + includeLower: include, + upper: [], + )); + }); + } + + QueryBuilder + messageTypeLessThanAnyRootId( + MessageType messageType, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.between( + indexName: r'messageType_rootId', + lower: [], + upper: [messageType], + includeUpper: include, + )); + }); + } + + QueryBuilder + messageTypeBetweenAnyRootId( + MessageType lowerMessageType, + MessageType upperMessageType, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.between( + indexName: r'messageType_rootId', + lower: [lowerMessageType], + includeLower: includeLower, + upper: [upperMessageType], + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + messageTypeRootIdEqualTo(MessageType messageType, String rootId) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.equalTo( + indexName: r'messageType_rootId', + value: [messageType, rootId], + )); + }); + } + + QueryBuilder + messageTypeEqualToRootIdNotEqualTo( + MessageType messageType, String rootId) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'messageType_rootId', + lower: [messageType], + upper: [messageType, rootId], + includeUpper: false, + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'messageType_rootId', + lower: [messageType, rootId], + includeLower: false, + upper: [messageType], + )); + } else { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'messageType_rootId', + lower: [messageType, rootId], + includeLower: false, + upper: [messageType], + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'messageType_rootId', + lower: [messageType], + upper: [messageType, rootId], + includeUpper: false, + )); + } + }); + } + + QueryBuilder + channelUrlEqualTo(String channelUrl) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.equalTo( + indexName: r'channelUrl', + value: [channelUrl], + )); + }); + } + + QueryBuilder + channelUrlNotEqualTo(String channelUrl) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'channelUrl', + lower: [], + upper: [channelUrl], + includeUpper: false, + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'channelUrl', + lower: [channelUrl], + includeLower: false, + upper: [], + )); + } else { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'channelUrl', + lower: [channelUrl], + includeLower: false, + upper: [], + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'channelUrl', + lower: [], + upper: [channelUrl], + includeUpper: false, + )); + } + }); + } + + QueryBuilder + channelTypeEqualToAnyChannelUrl(ChannelType channelType) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.equalTo( + indexName: r'channelType_channelUrl', + value: [channelType], + )); + }); + } + + QueryBuilder + channelTypeNotEqualToAnyChannelUrl(ChannelType channelType) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'channelType_channelUrl', + lower: [], + upper: [channelType], + includeUpper: false, + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'channelType_channelUrl', + lower: [channelType], + includeLower: false, + upper: [], + )); + } else { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'channelType_channelUrl', + lower: [channelType], + includeLower: false, + upper: [], + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'channelType_channelUrl', + lower: [], + upper: [channelType], + includeUpper: false, + )); + } + }); + } + + QueryBuilder + channelTypeGreaterThanAnyChannelUrl( + ChannelType channelType, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.between( + indexName: r'channelType_channelUrl', + lower: [channelType], + includeLower: include, + upper: [], + )); + }); + } + + QueryBuilder + channelTypeLessThanAnyChannelUrl( + ChannelType channelType, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.between( + indexName: r'channelType_channelUrl', + lower: [], + upper: [channelType], + includeUpper: include, + )); + }); + } + + QueryBuilder + channelTypeBetweenAnyChannelUrl( + ChannelType lowerChannelType, + ChannelType upperChannelType, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.between( + indexName: r'channelType_channelUrl', + lower: [lowerChannelType], + includeLower: includeLower, + upper: [upperChannelType], + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + channelTypeChannelUrlEqualTo(ChannelType channelType, String channelUrl) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.equalTo( + indexName: r'channelType_channelUrl', + value: [channelType, channelUrl], + )); + }); + } + + QueryBuilder + channelTypeEqualToChannelUrlNotEqualTo( + ChannelType channelType, String channelUrl) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'channelType_channelUrl', + lower: [channelType], + upper: [channelType, channelUrl], + includeUpper: false, + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'channelType_channelUrl', + lower: [channelType, channelUrl], + includeLower: false, + upper: [channelType], + )); + } else { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'channelType_channelUrl', + lower: [channelType, channelUrl], + includeLower: false, + upper: [channelType], + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'channelType_channelUrl', + lower: [channelType], + upper: [channelType, channelUrl], + includeUpper: false, + )); + } + }); + } +} + +extension CAdminMessageQueryFilter + on QueryBuilder { + QueryBuilder + allMetaArraysIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'allMetaArrays', + )); + }); + } + + QueryBuilder + allMetaArraysIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'allMetaArrays', + )); + }); + } + + QueryBuilder + allMetaArraysLengthEqualTo(int length) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'allMetaArrays', + length, + true, + length, + true, + ); + }); + } + + QueryBuilder + allMetaArraysIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'allMetaArrays', + 0, + true, + 0, + true, + ); + }); + } + + QueryBuilder + allMetaArraysIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'allMetaArrays', + 0, + false, + 999999, + true, + ); + }); + } + + QueryBuilder + allMetaArraysLengthLessThan( + int length, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'allMetaArrays', + 0, + true, + length, + include, + ); + }); + } + + QueryBuilder + allMetaArraysLengthGreaterThan( + int length, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'allMetaArrays', + length, + include, + 999999, + true, + ); + }); + } + + QueryBuilder + allMetaArraysLengthBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'allMetaArrays', + lower, + includeLower, + upper, + includeUpper, + ); + }); + } + + QueryBuilder + channelTypeEqualTo(ChannelType value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'channelType', + value: value, + )); + }); + } + + QueryBuilder + channelTypeGreaterThan( + ChannelType value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'channelType', + value: value, + )); + }); + } + + QueryBuilder + channelTypeLessThan( + ChannelType value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'channelType', + value: value, + )); + }); + } + + QueryBuilder + channelTypeBetween( + ChannelType lower, + ChannelType upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'channelType', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + channelUrlEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'channelUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + channelUrlGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'channelUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + channelUrlLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'channelUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + channelUrlBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'channelUrl', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + channelUrlStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'channelUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + channelUrlEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'channelUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + channelUrlContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'channelUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + channelUrlMatches(String pattern, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'channelUrl', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + channelUrlIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'channelUrl', + value: '', + )); + }); + } + + QueryBuilder + channelUrlIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'channelUrl', + value: '', + )); + }); + } + + QueryBuilder + createdAtEqualTo(int value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'createdAt', + value: value, + )); + }); + } + + QueryBuilder + createdAtGreaterThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'createdAt', + value: value, + )); + }); + } + + QueryBuilder + createdAtLessThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'createdAt', + value: value, + )); + }); + } + + QueryBuilder + createdAtBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'createdAt', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + customTypeIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'customType', + )); + }); + } + + QueryBuilder + customTypeIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'customType', + )); + }); + } + + QueryBuilder + customTypeEqualTo( + String? value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'customType', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + customTypeGreaterThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'customType', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + customTypeLessThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'customType', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + customTypeBetween( + String? lower, + String? upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'customType', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + customTypeStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'customType', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + customTypeEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'customType', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + customTypeContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'customType', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + customTypeMatches(String pattern, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'customType', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + customTypeIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'customType', + value: '', + )); + }); + } + + QueryBuilder + customTypeIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'customType', + value: '', + )); + }); + } + + QueryBuilder + dataIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'data', + )); + }); + } + + QueryBuilder + dataIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'data', + )); + }); + } + + QueryBuilder dataEqualTo( + String? value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'data', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + dataGreaterThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'data', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + dataLessThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'data', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder dataBetween( + String? lower, + String? upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'data', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + dataStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'data', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + dataEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'data', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + dataContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'data', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder dataMatches( + String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'data', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + dataIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'data', + value: '', + )); + }); + } + + QueryBuilder + dataIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'data', + value: '', + )); + }); + } + + QueryBuilder + errorCodeIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'errorCode', + )); + }); + } + + QueryBuilder + errorCodeIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'errorCode', + )); + }); + } + + QueryBuilder + errorCodeEqualTo(int? value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'errorCode', + value: value, + )); + }); + } + + QueryBuilder + errorCodeGreaterThan( + int? value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'errorCode', + value: value, + )); + }); + } + + QueryBuilder + errorCodeLessThan( + int? value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'errorCode', + value: value, + )); + }); + } + + QueryBuilder + errorCodeBetween( + int? lower, + int? upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'errorCode', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + extendedMessageEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'extendedMessage', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + extendedMessageGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'extendedMessage', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + extendedMessageLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'extendedMessage', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + extendedMessageBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'extendedMessage', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + extendedMessageStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'extendedMessage', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + extendedMessageEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'extendedMessage', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + extendedMessageContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'extendedMessage', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + extendedMessageMatches(String pattern, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'extendedMessage', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + extendedMessageIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'extendedMessage', + value: '', + )); + }); + } + + QueryBuilder + extendedMessageIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'extendedMessage', + value: '', + )); + }); + } + + QueryBuilder idEqualTo( + Id value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'id', + value: value, + )); + }); + } + + QueryBuilder + idGreaterThan( + Id value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'id', + value: value, + )); + }); + } + + QueryBuilder idLessThan( + Id value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'id', + value: value, + )); + }); + } + + QueryBuilder idBetween( + Id lower, + Id upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'id', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + isOperatorMessageEqualTo(bool value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'isOperatorMessage', + value: value, + )); + }); + } + + QueryBuilder + isReplyToChannelEqualTo(bool value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'isReplyToChannel', + value: value, + )); + }); + } + + QueryBuilder + isSilentEqualTo(bool value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'isSilent', + value: value, + )); + }); + } + + QueryBuilder + mentionTypeEqualTo(MentionType value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'mentionType', + value: value, + )); + }); + } + + QueryBuilder + mentionTypeGreaterThan( + MentionType value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'mentionType', + value: value, + )); + }); + } + + QueryBuilder + mentionTypeLessThan( + MentionType value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'mentionType', + value: value, + )); + }); + } + + QueryBuilder + mentionTypeBetween( + MentionType lower, + MentionType upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'mentionType', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + mentionedUsersElementEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'mentionedUsers', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + mentionedUsersElementGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'mentionedUsers', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + mentionedUsersElementLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'mentionedUsers', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + mentionedUsersElementBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'mentionedUsers', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + mentionedUsersElementStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'mentionedUsers', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + mentionedUsersElementEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'mentionedUsers', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + mentionedUsersElementContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'mentionedUsers', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + mentionedUsersElementMatches(String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'mentionedUsers', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + mentionedUsersElementIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'mentionedUsers', + value: '', + )); + }); + } + + QueryBuilder + mentionedUsersElementIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'mentionedUsers', + value: '', + )); + }); + } + + QueryBuilder + mentionedUsersLengthEqualTo(int length) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'mentionedUsers', + length, + true, + length, + true, + ); + }); + } + + QueryBuilder + mentionedUsersIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'mentionedUsers', + 0, + true, + 0, + true, + ); + }); + } + + QueryBuilder + mentionedUsersIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'mentionedUsers', + 0, + false, + 999999, + true, + ); + }); + } + + QueryBuilder + mentionedUsersLengthLessThan( + int length, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'mentionedUsers', + 0, + true, + length, + include, + ); + }); + } + + QueryBuilder + mentionedUsersLengthGreaterThan( + int length, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'mentionedUsers', + length, + include, + 999999, + true, + ); + }); + } + + QueryBuilder + mentionedUsersLengthBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'mentionedUsers', + lower, + includeLower, + upper, + includeUpper, + ); + }); + } + + QueryBuilder + messageEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'message', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + messageGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'message', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + messageLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'message', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + messageBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'message', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + messageStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'message', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + messageEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'message', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + messageContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'message', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + messageMatches(String pattern, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'message', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + messageIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'message', + value: '', + )); + }); + } + + QueryBuilder + messageIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'message', + value: '', + )); + }); + } + + QueryBuilder + messageIdEqualTo(int value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'messageId', + value: value, + )); + }); + } + + QueryBuilder + messageIdGreaterThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'messageId', + value: value, + )); + }); + } + + QueryBuilder + messageIdLessThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'messageId', + value: value, + )); + }); + } + + QueryBuilder + messageIdBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'messageId', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + messageSurvivalSecondsIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'messageSurvivalSeconds', + )); + }); + } + + QueryBuilder + messageSurvivalSecondsIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'messageSurvivalSeconds', + )); + }); + } + + QueryBuilder + messageSurvivalSecondsEqualTo(int? value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'messageSurvivalSeconds', + value: value, + )); + }); + } + + QueryBuilder + messageSurvivalSecondsGreaterThan( + int? value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'messageSurvivalSeconds', + value: value, + )); + }); + } + + QueryBuilder + messageSurvivalSecondsLessThan( + int? value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'messageSurvivalSeconds', + value: value, + )); + }); + } + + QueryBuilder + messageSurvivalSecondsBetween( + int? lower, + int? upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'messageSurvivalSeconds', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + messageTypeEqualTo(MessageType value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'messageType', + value: value, + )); + }); + } + + QueryBuilder + messageTypeGreaterThan( + MessageType value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'messageType', + value: value, + )); + }); + } + + QueryBuilder + messageTypeLessThan( + MessageType value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'messageType', + value: value, + )); + }); + } + + QueryBuilder + messageTypeBetween( + MessageType lower, + MessageType upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'messageType', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + ogMetaDataIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'ogMetaData', + )); + }); + } + + QueryBuilder + ogMetaDataIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'ogMetaData', + )); + }); + } + + QueryBuilder + parentMessageIdIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'parentMessageId', + )); + }); + } + + QueryBuilder + parentMessageIdIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'parentMessageId', + )); + }); + } + + QueryBuilder + parentMessageIdEqualTo(int? value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'parentMessageId', + value: value, + )); + }); + } + + QueryBuilder + parentMessageIdGreaterThan( + int? value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'parentMessageId', + value: value, + )); + }); + } + + QueryBuilder + parentMessageIdLessThan( + int? value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'parentMessageId', + value: value, + )); + }); + } + + QueryBuilder + parentMessageIdBetween( + int? lower, + int? upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'parentMessageId', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + parentMessageRootIdIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'parentMessageRootId', + )); + }); + } + + QueryBuilder + parentMessageRootIdIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'parentMessageRootId', + )); + }); + } + + QueryBuilder + parentMessageRootIdEqualTo( + String? value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'parentMessageRootId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + parentMessageRootIdGreaterThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'parentMessageRootId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + parentMessageRootIdLessThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'parentMessageRootId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + parentMessageRootIdBetween( + String? lower, + String? upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'parentMessageRootId', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + parentMessageRootIdStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'parentMessageRootId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + parentMessageRootIdEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'parentMessageRootId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + parentMessageRootIdContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'parentMessageRootId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + parentMessageRootIdMatches(String pattern, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'parentMessageRootId', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + parentMessageRootIdIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'parentMessageRootId', + value: '', + )); + }); + } + + QueryBuilder + parentMessageRootIdIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'parentMessageRootId', + value: '', + )); + }); + } + + QueryBuilder + parentMessageTypeEqualTo(MessageType value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'parentMessageType', + value: value, + )); + }); + } + + QueryBuilder + parentMessageTypeGreaterThan( + MessageType value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'parentMessageType', + value: value, + )); + }); + } + + QueryBuilder + parentMessageTypeLessThan( + MessageType value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'parentMessageType', + value: value, + )); + }); + } + + QueryBuilder + parentMessageTypeBetween( + MessageType lower, + MessageType upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'parentMessageType', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + reactionsIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'reactions', + )); + }); + } + + QueryBuilder + reactionsIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'reactions', + )); + }); + } + + QueryBuilder + reactionsLengthEqualTo(int length) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'reactions', + length, + true, + length, + true, + ); + }); + } + + QueryBuilder + reactionsIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'reactions', + 0, + true, + 0, + true, + ); + }); + } + + QueryBuilder + reactionsIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'reactions', + 0, + false, + 999999, + true, + ); + }); + } + + QueryBuilder + reactionsLengthLessThan( + int length, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'reactions', + 0, + true, + length, + include, + ); + }); + } + + QueryBuilder + reactionsLengthGreaterThan( + int length, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'reactions', + length, + include, + 999999, + true, + ); + }); + } + + QueryBuilder + reactionsLengthBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'reactions', + lower, + includeLower, + upper, + includeUpper, + ); + }); + } + + QueryBuilder + requestIdIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'requestId', + )); + }); + } + + QueryBuilder + requestIdIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'requestId', + )); + }); + } + + QueryBuilder + requestIdEqualTo( + String? value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'requestId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + requestIdGreaterThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'requestId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + requestIdLessThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'requestId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + requestIdBetween( + String? lower, + String? upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'requestId', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + requestIdStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'requestId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + requestIdEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'requestId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + requestIdContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'requestId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + requestIdMatches(String pattern, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'requestId', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + requestIdIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'requestId', + value: '', + )); + }); + } + + QueryBuilder + requestIdIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'requestId', + value: '', + )); + }); + } + + QueryBuilder + rootIdEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'rootId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + rootIdGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'rootId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + rootIdLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'rootId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + rootIdBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'rootId', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + rootIdStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'rootId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + rootIdEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'rootId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + rootIdContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'rootId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + rootIdMatches(String pattern, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'rootId', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + rootIdIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'rootId', + value: '', + )); + }); + } + + QueryBuilder + rootIdIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'rootId', + value: '', + )); + }); + } + + QueryBuilder + scheduledInfoIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'scheduledInfo', + )); + }); + } + + QueryBuilder + scheduledInfoIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'scheduledInfo', + )); + }); + } + + QueryBuilder + senderIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'sender', + )); + }); + } + + QueryBuilder + senderIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'sender', + )); + }); + } + + QueryBuilder + sendingStatusEqualTo(SendingStatus value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'sendingStatus', + value: value, + )); + }); + } + + QueryBuilder + sendingStatusGreaterThan( + SendingStatus value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'sendingStatus', + value: value, + )); + }); + } + + QueryBuilder + sendingStatusLessThan( + SendingStatus value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'sendingStatus', + value: value, + )); + }); + } + + QueryBuilder + sendingStatusBetween( + SendingStatus lower, + SendingStatus upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'sendingStatus', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + threadInfoIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'threadInfo', + )); + }); + } + + QueryBuilder + threadInfoIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'threadInfo', + )); + }); + } + + QueryBuilder + updatedAtEqualTo(int value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'updatedAt', + value: value, + )); + }); + } + + QueryBuilder + updatedAtGreaterThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'updatedAt', + value: value, + )); + }); + } + + QueryBuilder + updatedAtLessThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'updatedAt', + value: value, + )); + }); + } + + QueryBuilder + updatedAtBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'updatedAt', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } +} + +extension CAdminMessageQueryObject + on QueryBuilder { + QueryBuilder + allMetaArraysElement(FilterQuery q) { + return QueryBuilder.apply(this, (query) { + return query.object(q, r'allMetaArrays'); + }); + } + + QueryBuilder ogMetaData( + FilterQuery q) { + return QueryBuilder.apply(this, (query) { + return query.object(q, r'ogMetaData'); + }); + } + + QueryBuilder + reactionsElement(FilterQuery q) { + return QueryBuilder.apply(this, (query) { + return query.object(q, r'reactions'); + }); + } + + QueryBuilder + scheduledInfo(FilterQuery q) { + return QueryBuilder.apply(this, (query) { + return query.object(q, r'scheduledInfo'); + }); + } + + QueryBuilder sender( + FilterQuery q) { + return QueryBuilder.apply(this, (query) { + return query.object(q, r'sender'); + }); + } + + QueryBuilder threadInfo( + FilterQuery q) { + return QueryBuilder.apply(this, (query) { + return query.object(q, r'threadInfo'); + }); + } +} + +extension CAdminMessageQueryLinks + on QueryBuilder {} + +extension CAdminMessageQuerySortBy + on QueryBuilder { + QueryBuilder sortByChannelType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'channelType', Sort.asc); + }); + } + + QueryBuilder + sortByChannelTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'channelType', Sort.desc); + }); + } + + QueryBuilder sortByChannelUrl() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'channelUrl', Sort.asc); + }); + } + + QueryBuilder + sortByChannelUrlDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'channelUrl', Sort.desc); + }); + } + + QueryBuilder sortByCreatedAt() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'createdAt', Sort.asc); + }); + } + + QueryBuilder + sortByCreatedAtDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'createdAt', Sort.desc); + }); + } + + QueryBuilder sortByCustomType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'customType', Sort.asc); + }); + } + + QueryBuilder + sortByCustomTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'customType', Sort.desc); + }); + } + + QueryBuilder sortByData() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'data', Sort.asc); + }); + } + + QueryBuilder sortByDataDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'data', Sort.desc); + }); + } + + QueryBuilder sortByErrorCode() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'errorCode', Sort.asc); + }); + } + + QueryBuilder + sortByErrorCodeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'errorCode', Sort.desc); + }); + } + + QueryBuilder + sortByExtendedMessage() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'extendedMessage', Sort.asc); + }); + } + + QueryBuilder + sortByExtendedMessageDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'extendedMessage', Sort.desc); + }); + } + + QueryBuilder + sortByIsOperatorMessage() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isOperatorMessage', Sort.asc); + }); + } + + QueryBuilder + sortByIsOperatorMessageDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isOperatorMessage', Sort.desc); + }); + } + + QueryBuilder + sortByIsReplyToChannel() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isReplyToChannel', Sort.asc); + }); + } + + QueryBuilder + sortByIsReplyToChannelDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isReplyToChannel', Sort.desc); + }); + } + + QueryBuilder sortByIsSilent() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isSilent', Sort.asc); + }); + } + + QueryBuilder + sortByIsSilentDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isSilent', Sort.desc); + }); + } + + QueryBuilder sortByMentionType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'mentionType', Sort.asc); + }); + } + + QueryBuilder + sortByMentionTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'mentionType', Sort.desc); + }); + } + + QueryBuilder sortByMessage() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'message', Sort.asc); + }); + } + + QueryBuilder sortByMessageDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'message', Sort.desc); + }); + } + + QueryBuilder sortByMessageId() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'messageId', Sort.asc); + }); + } + + QueryBuilder + sortByMessageIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'messageId', Sort.desc); + }); + } + + QueryBuilder + sortByMessageSurvivalSeconds() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'messageSurvivalSeconds', Sort.asc); + }); + } + + QueryBuilder + sortByMessageSurvivalSecondsDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'messageSurvivalSeconds', Sort.desc); + }); + } + + QueryBuilder sortByMessageType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'messageType', Sort.asc); + }); + } + + QueryBuilder + sortByMessageTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'messageType', Sort.desc); + }); + } + + QueryBuilder + sortByParentMessageId() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'parentMessageId', Sort.asc); + }); + } + + QueryBuilder + sortByParentMessageIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'parentMessageId', Sort.desc); + }); + } + + QueryBuilder + sortByParentMessageRootId() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'parentMessageRootId', Sort.asc); + }); + } + + QueryBuilder + sortByParentMessageRootIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'parentMessageRootId', Sort.desc); + }); + } + + QueryBuilder + sortByParentMessageType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'parentMessageType', Sort.asc); + }); + } + + QueryBuilder + sortByParentMessageTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'parentMessageType', Sort.desc); + }); + } + + QueryBuilder sortByRequestId() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'requestId', Sort.asc); + }); + } + + QueryBuilder + sortByRequestIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'requestId', Sort.desc); + }); + } + + QueryBuilder sortByRootId() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'rootId', Sort.asc); + }); + } + + QueryBuilder sortByRootIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'rootId', Sort.desc); + }); + } + + QueryBuilder + sortBySendingStatus() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'sendingStatus', Sort.asc); + }); + } + + QueryBuilder + sortBySendingStatusDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'sendingStatus', Sort.desc); + }); + } + + QueryBuilder sortByUpdatedAt() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'updatedAt', Sort.asc); + }); + } + + QueryBuilder + sortByUpdatedAtDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'updatedAt', Sort.desc); + }); + } +} + +extension CAdminMessageQuerySortThenBy + on QueryBuilder { + QueryBuilder thenByChannelType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'channelType', Sort.asc); + }); + } + + QueryBuilder + thenByChannelTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'channelType', Sort.desc); + }); + } + + QueryBuilder thenByChannelUrl() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'channelUrl', Sort.asc); + }); + } + + QueryBuilder + thenByChannelUrlDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'channelUrl', Sort.desc); + }); + } + + QueryBuilder thenByCreatedAt() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'createdAt', Sort.asc); + }); + } + + QueryBuilder + thenByCreatedAtDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'createdAt', Sort.desc); + }); + } + + QueryBuilder thenByCustomType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'customType', Sort.asc); + }); + } + + QueryBuilder + thenByCustomTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'customType', Sort.desc); + }); + } + + QueryBuilder thenByData() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'data', Sort.asc); + }); + } + + QueryBuilder thenByDataDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'data', Sort.desc); + }); + } + + QueryBuilder thenByErrorCode() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'errorCode', Sort.asc); + }); + } + + QueryBuilder + thenByErrorCodeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'errorCode', Sort.desc); + }); + } + + QueryBuilder + thenByExtendedMessage() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'extendedMessage', Sort.asc); + }); + } + + QueryBuilder + thenByExtendedMessageDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'extendedMessage', Sort.desc); + }); + } + + QueryBuilder thenById() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'id', Sort.asc); + }); + } + + QueryBuilder thenByIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'id', Sort.desc); + }); + } + + QueryBuilder + thenByIsOperatorMessage() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isOperatorMessage', Sort.asc); + }); + } + + QueryBuilder + thenByIsOperatorMessageDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isOperatorMessage', Sort.desc); + }); + } + + QueryBuilder + thenByIsReplyToChannel() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isReplyToChannel', Sort.asc); + }); + } + + QueryBuilder + thenByIsReplyToChannelDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isReplyToChannel', Sort.desc); + }); + } + + QueryBuilder thenByIsSilent() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isSilent', Sort.asc); + }); + } + + QueryBuilder + thenByIsSilentDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isSilent', Sort.desc); + }); + } + + QueryBuilder thenByMentionType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'mentionType', Sort.asc); + }); + } + + QueryBuilder + thenByMentionTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'mentionType', Sort.desc); + }); + } + + QueryBuilder thenByMessage() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'message', Sort.asc); + }); + } + + QueryBuilder thenByMessageDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'message', Sort.desc); + }); + } + + QueryBuilder thenByMessageId() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'messageId', Sort.asc); + }); + } + + QueryBuilder + thenByMessageIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'messageId', Sort.desc); + }); + } + + QueryBuilder + thenByMessageSurvivalSeconds() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'messageSurvivalSeconds', Sort.asc); + }); + } + + QueryBuilder + thenByMessageSurvivalSecondsDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'messageSurvivalSeconds', Sort.desc); + }); + } + + QueryBuilder thenByMessageType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'messageType', Sort.asc); + }); + } + + QueryBuilder + thenByMessageTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'messageType', Sort.desc); + }); + } + + QueryBuilder + thenByParentMessageId() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'parentMessageId', Sort.asc); + }); + } + + QueryBuilder + thenByParentMessageIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'parentMessageId', Sort.desc); + }); + } + + QueryBuilder + thenByParentMessageRootId() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'parentMessageRootId', Sort.asc); + }); + } + + QueryBuilder + thenByParentMessageRootIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'parentMessageRootId', Sort.desc); + }); + } + + QueryBuilder + thenByParentMessageType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'parentMessageType', Sort.asc); + }); + } + + QueryBuilder + thenByParentMessageTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'parentMessageType', Sort.desc); + }); + } + + QueryBuilder thenByRequestId() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'requestId', Sort.asc); + }); + } + + QueryBuilder + thenByRequestIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'requestId', Sort.desc); + }); + } + + QueryBuilder thenByRootId() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'rootId', Sort.asc); + }); + } + + QueryBuilder thenByRootIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'rootId', Sort.desc); + }); + } + + QueryBuilder + thenBySendingStatus() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'sendingStatus', Sort.asc); + }); + } + + QueryBuilder + thenBySendingStatusDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'sendingStatus', Sort.desc); + }); + } + + QueryBuilder thenByUpdatedAt() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'updatedAt', Sort.asc); + }); + } + + QueryBuilder + thenByUpdatedAtDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'updatedAt', Sort.desc); + }); + } +} + +extension CAdminMessageQueryWhereDistinct + on QueryBuilder { + QueryBuilder + distinctByChannelType() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'channelType'); + }); + } + + QueryBuilder distinctByChannelUrl( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'channelUrl', caseSensitive: caseSensitive); + }); + } + + QueryBuilder distinctByCreatedAt() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'createdAt'); + }); + } + + QueryBuilder distinctByCustomType( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'customType', caseSensitive: caseSensitive); + }); + } + + QueryBuilder distinctByData( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'data', caseSensitive: caseSensitive); + }); + } + + QueryBuilder distinctByErrorCode() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'errorCode'); + }); + } + + QueryBuilder + distinctByExtendedMessage({bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'extendedMessage', + caseSensitive: caseSensitive); + }); + } + + QueryBuilder + distinctByIsOperatorMessage() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'isOperatorMessage'); + }); + } + + QueryBuilder + distinctByIsReplyToChannel() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'isReplyToChannel'); + }); + } + + QueryBuilder distinctByIsSilent() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'isSilent'); + }); + } + + QueryBuilder + distinctByMentionType() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'mentionType'); + }); + } + + QueryBuilder + distinctByMentionedUsers() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'mentionedUsers'); + }); + } + + QueryBuilder distinctByMessage( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'message', caseSensitive: caseSensitive); + }); + } + + QueryBuilder distinctByMessageId() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'messageId'); + }); + } + + QueryBuilder + distinctByMessageSurvivalSeconds() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'messageSurvivalSeconds'); + }); + } + + QueryBuilder + distinctByMessageType() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'messageType'); + }); + } + + QueryBuilder + distinctByParentMessageId() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'parentMessageId'); + }); + } + + QueryBuilder + distinctByParentMessageRootId({bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'parentMessageRootId', + caseSensitive: caseSensitive); + }); + } + + QueryBuilder + distinctByParentMessageType() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'parentMessageType'); + }); + } + + QueryBuilder distinctByRequestId( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'requestId', caseSensitive: caseSensitive); + }); + } + + QueryBuilder distinctByRootId( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'rootId', caseSensitive: caseSensitive); + }); + } + + QueryBuilder + distinctBySendingStatus() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'sendingStatus'); + }); + } + + QueryBuilder distinctByUpdatedAt() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'updatedAt'); + }); + } +} + +extension CAdminMessageQueryProperty + on QueryBuilder { + QueryBuilder idProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'id'); + }); + } + + QueryBuilder?, QQueryOperations> + allMetaArraysProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'allMetaArrays'); + }); + } + + QueryBuilder + channelTypeProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'channelType'); + }); + } + + QueryBuilder channelUrlProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'channelUrl'); + }); + } + + QueryBuilder createdAtProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'createdAt'); + }); + } + + QueryBuilder customTypeProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'customType'); + }); + } + + QueryBuilder dataProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'data'); + }); + } + + QueryBuilder errorCodeProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'errorCode'); + }); + } + + QueryBuilder + extendedMessageProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'extendedMessage'); + }); + } + + QueryBuilder + isOperatorMessageProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'isOperatorMessage'); + }); + } + + QueryBuilder + isReplyToChannelProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'isReplyToChannel'); + }); + } + + QueryBuilder isSilentProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'isSilent'); + }); + } + + QueryBuilder + mentionTypeProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'mentionType'); + }); + } + + QueryBuilder, QQueryOperations> + mentionedUsersProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'mentionedUsers'); + }); + } + + QueryBuilder messageProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'message'); + }); + } + + QueryBuilder messageIdProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'messageId'); + }); + } + + QueryBuilder + messageSurvivalSecondsProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'messageSurvivalSeconds'); + }); + } + + QueryBuilder + messageTypeProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'messageType'); + }); + } + + QueryBuilder + ogMetaDataProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'ogMetaData'); + }); + } + + QueryBuilder + parentMessageIdProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'parentMessageId'); + }); + } + + QueryBuilder + parentMessageRootIdProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'parentMessageRootId'); + }); + } + + QueryBuilder + parentMessageTypeProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'parentMessageType'); + }); + } + + QueryBuilder?, QQueryOperations> + reactionsProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'reactions'); + }); + } + + QueryBuilder requestIdProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'requestId'); + }); + } + + QueryBuilder rootIdProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'rootId'); + }); + } + + QueryBuilder + scheduledInfoProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'scheduledInfo'); + }); + } + + QueryBuilder senderProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'sender'); + }); + } + + QueryBuilder + sendingStatusProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'sendingStatus'); + }); + } + + QueryBuilder + threadInfoProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'threadInfo'); + }); + } + + QueryBuilder updatedAtProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'updatedAt'); + }); + } +} diff --git a/lib/src/internal/db/schema/message/c_base_message.dart b/lib/src/internal/db/schema/message/c_base_message.dart new file mode 100644 index 00000000..10686bf5 --- /dev/null +++ b/lib/src/internal/db/schema/message/c_base_message.dart @@ -0,0 +1,339 @@ +// Copyright (c) 2023 Sendbird, Inc. All rights reserved. + +import 'dart:convert'; + +import 'package:isar/isar.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/message/c_admin_message.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/message/c_file_message.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/message/c_root_message.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/message/c_user_message.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/user/c_sender.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/user/c_user.dart'; +import 'package:sendbird_chat_sdk/src/internal/main/chat/chat.dart'; +import 'package:sendbird_chat_sdk/src/public/core/message/admin_message.dart'; +import 'package:sendbird_chat_sdk/src/public/core/message/base_message.dart'; +import 'package:sendbird_chat_sdk/src/public/core/message/file_message.dart'; +import 'package:sendbird_chat_sdk/src/public/core/message/root_message.dart'; +import 'package:sendbird_chat_sdk/src/public/core/message/user_message.dart'; +import 'package:sendbird_chat_sdk/src/public/main/define/enums.dart'; +import 'package:sendbird_chat_sdk/src/public/main/model/info/scheduled_info.dart'; +import 'package:sendbird_chat_sdk/src/public/main/model/og/og_image.dart'; +import 'package:sendbird_chat_sdk/src/public/main/model/og/og_meta_data.dart'; +import 'package:sendbird_chat_sdk/src/public/main/model/reaction/reaction.dart'; +import 'package:sendbird_chat_sdk/src/public/main/model/thread/thread_info.dart'; + +part 'c_base_message.g.dart'; + +class CBaseMessage extends CRootMessage { + late int messageId; + String? requestId; + late String message; + + @enumerated + late SendingStatus sendingStatus; + + late bool isReplyToChannel; + int? parentMessageId; + + @enumerated + late MessageType parentMessageType; // parentMessage + String? parentMessageRootId; // parentMessage + + CThreadInfo? threadInfo; + int? messageSurvivalSeconds; + late bool isSilent; + int? errorCode; + late bool isOperatorMessage; + COGMetaData? ogMetaData; + List? reactions; + CScheduledInfo? scheduledInfo; + CSender? sender; + + CBaseMessage(); + + factory CBaseMessage.fromBaseMessage(BaseMessage message) { + return CBaseMessage()..setBaseMessage(message); + } + + void setBaseMessage(BaseMessage baseMessage) { + setRootMessage(baseMessage); + + messageId = baseMessage.messageId; + requestId = baseMessage.requestId; + message = baseMessage.message; + sendingStatus = baseMessage.sendingStatus ?? SendingStatus.none; + isReplyToChannel = baseMessage.isReplyToChannel; + parentMessageId = baseMessage.parentMessageId; + parentMessageType = baseMessage.messageType; + parentMessageRootId = parentMessageId?.toString(); + threadInfo = baseMessage.threadInfo != null + ? CThreadInfo.fromThreadInfo(baseMessage.threadInfo!) + : null; + messageSurvivalSeconds = baseMessage.messageSurvivalSeconds; + isSilent = baseMessage.isSilent; + errorCode = baseMessage.errorCode; + isOperatorMessage = baseMessage.isOperatorMessage; + ogMetaData = baseMessage.ogMetaData != null + ? COGMetaData.fromOGMetaData(baseMessage.ogMetaData!) + : null; + reactions = baseMessage.reactions != null + ? baseMessage.reactions! + .map((reaction) => CReaction.fromReaction(reaction)) + .toList() + : null; + scheduledInfo = baseMessage.scheduledInfo != null + ? CScheduledInfo.fromScheduledInfo(baseMessage.scheduledInfo!) + : null; + sender = baseMessage.sender != null + ? CSender.fromSender(baseMessage.sender!) + : null; + } + + Future toBaseMessage(Chat chat, Isar isar) async { + final baseMessage = BaseMessage( + // RootMessage + channelUrl: channelUrl, + channelType: channelType, + // BaseMessage + message: message, + sendingStatus: sendingStatus, + )..set(chat); + return await setCBaseMessage(chat, isar, baseMessage, this); + } + + static Future setCBaseMessage( + Chat chat, + Isar isar, + BaseMessage baseMessage, + CBaseMessage cBaseMessage, + ) async { + await CRootMessage.setCRootMessage(chat, isar, baseMessage, cBaseMessage); + + baseMessage + ..messageId = cBaseMessage.messageId + ..requestId = cBaseMessage.requestId + ..sendingStatus = cBaseMessage.sendingStatus + ..isReplyToChannel = cBaseMessage.isReplyToChannel + ..parentMessageId = cBaseMessage.parentMessageId + ..parentMessage = await getMessage(chat, isar, + cBaseMessage.parentMessageType, cBaseMessage.parentMessageRootId) + ..threadInfo = await cBaseMessage.threadInfo?.toThreadInfo(chat, isar) + ..messageSurvivalSeconds = cBaseMessage.messageSurvivalSeconds + ..isSilent = cBaseMessage.isSilent + ..errorCode = cBaseMessage.errorCode + ..isOperatorMessage = cBaseMessage.isOperatorMessage + ..ogMetaData = cBaseMessage.ogMetaData?.toOGMetaData() + ..reactions = cBaseMessage.reactions + ?.map((reaction) => reaction.toReaction()) + .toList() + ..scheduledInfo = cBaseMessage.scheduledInfo?.toScheduledInfo() + ..sender = cBaseMessage.sender != null + ? await cBaseMessage.sender?.toSender(chat, isar) + : null; + + for (final userId in cBaseMessage.mentionedUsers) { + final user = await CUser.get(chat, isar, userId); + if (user != null) { + baseMessage.mentionedUsers.add(user); + } + } + return baseMessage; + } + + static Future getMessage( + Chat chat, + Isar isar, + MessageType? messageType, + String? rootId, + ) async { + if (messageType == null || rootId == null) return null; + + BaseMessage? message; + if (messageType == MessageType.user) { + message = await CUserMessage.get(chat, isar, rootId); + } else if (messageType == MessageType.file) { + message = await CFileMessage.get(chat, isar, rootId); + } else if (messageType == MessageType.admin) { + message = await CAdminMessage.get(chat, isar, rootId); + } + return message; + } + + static Future upsert(Chat chat, Isar isar, BaseMessage message) async { + // BaseMessage + await chat.dbManager.write(() async { + if (message is UserMessage) { + await isar.cUserMessages.put(CUserMessage.fromUserMessage(message)); + } else if (message is FileMessage) { + await isar.cFileMessages.put(CFileMessage.fromFileMessage(message)); + } else if (message is AdminMessage) { + await isar.cAdminMessages.put(CAdminMessage.fromAdminMessage(message)); + } + + // parentMessage + if (message.parentMessage != null) { + await CBaseMessage.upsert(chat, isar, message.parentMessage!); + } + + // threadInfo + if (message.threadInfo != null) { + for (final user in message.threadInfo!.mostRepliesUsers) { + await isar.cUsers.put(CUser.fromUser(user)); + } + } + + // sender + if (message.sender != null) { + await isar.cUsers.put(CUser.fromUser(message.sender!)); + } + }); + } +} + +@embedded +class CThreadInfo { + late int replyCount; + late List mostRepliesUsers; // List + late int lastRepliedAt; + + // Internal + int? updatedAt; + + CThreadInfo(); + + factory CThreadInfo.fromThreadInfo(ThreadInfo info) { + return CThreadInfo() + ..replyCount = info.replyCount + ..mostRepliesUsers = + info.mostRepliesUsers.map((user) => user.userId).toList() + ..lastRepliedAt = info.lastRepliedAt + ..updatedAt = info.updatedAt; + } + + Future toThreadInfo(Chat chat, Isar isar) async { + final threadInfo = ThreadInfo() + ..replyCount = replyCount + ..lastRepliedAt = lastRepliedAt + ..updatedAt = updatedAt; + + for (final userId in mostRepliesUsers) { + final user = await CUser.get(chat, isar, userId); + if (user != null) { + threadInfo.mostRepliesUsers.add(user); + } + } + + return threadInfo; + } +} + +@embedded +class COGMetaData { + String? title; + String? url; + String? description; + COGImage? ogImage; + + COGMetaData(); + + factory COGMetaData.fromOGMetaData(OGMetaData data) { + return COGMetaData() + ..title = data.title + ..url = data.url + ..description = data.description + ..ogImage = + data.ogImage != null ? COGImage.fromOGImage(data.ogImage!) : null; + } + + OGMetaData toOGMetaData() { + return OGMetaData() + ..title = title + ..url = url + ..description = description + ..ogImage = ogImage?.toOGImage(); + } +} + +@embedded +class COGImage { + String? url; + String? secureUrl; + String? type; + String? alt; + late int width; + late int height; + + COGImage(); + + factory COGImage.fromOGImage(OGImage image) { + return COGImage() + ..url = image.url + ..secureUrl = image.secureUrl + ..type = image.type + ..alt = image.alt + ..width = image.width + ..height = image.height; + } + + OGImage toOGImage() { + return OGImage() + ..url = url + ..secureUrl = secureUrl + ..type = type + ..alt = alt + ..width = width + ..height = height; + } +} + +@embedded +class CReaction { + late String key; + late List userIds; + late int updatedAt; + + // Internal + late String updatedAts; // Map + + CReaction(); + + factory CReaction.fromReaction(Reaction reaction) { + return CReaction() + ..key = reaction.key + ..userIds = reaction.userIds + ..updatedAt = reaction.updatedAt + ..updatedAts = jsonEncode(reaction.updatedAts); + } + + Reaction toReaction() { + return Reaction(key: key, userIds: userIds, updatedAt: updatedAt) + ..updatedAts = (jsonDecode(updatedAts) as Map) + .map((key, value) => MapEntry(key, int.parse(value))); + } +} + +@embedded +class CScheduledInfo { + late int scheduledMessageId; + late int scheduledAt; + + @enumerated + late ScheduledStatus scheduledStatus; + + CScheduledInfo(); + + factory CScheduledInfo.fromScheduledInfo(ScheduledInfo info) { + return CScheduledInfo() + ..scheduledMessageId = info.scheduledMessageId + ..scheduledAt = info.scheduledAt + ..scheduledStatus = info.scheduledStatus; + } + + ScheduledInfo toScheduledInfo() { + return ScheduledInfo( + scheduledMessageId: scheduledMessageId, + scheduledAt: scheduledAt, + scheduledStatus: scheduledStatus, + ); + } +} diff --git a/lib/src/internal/db/schema/message/c_base_message.g.dart b/lib/src/internal/db/schema/message/c_base_message.g.dart new file mode 100644 index 00000000..03d48e66 --- /dev/null +++ b/lib/src/internal/db/schema/message/c_base_message.g.dart @@ -0,0 +1,2881 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'c_base_message.dart'; + +// ************************************************************************** +// IsarEmbeddedGenerator +// ************************************************************************** + +// coverage:ignore-file +// ignore_for_file: duplicate_ignore, non_constant_identifier_names, constant_identifier_names, invalid_use_of_protected_member, unnecessary_cast, prefer_const_constructors, lines_longer_than_80_chars, require_trailing_commas, inference_failure_on_function_invocation, unnecessary_parenthesis, unnecessary_raw_strings, unnecessary_null_checks, join_return_with_assignment, prefer_final_locals, avoid_js_rounded_ints, avoid_positional_boolean_parameters, always_specify_types + +final CThreadInfoSchema = Schema( + name: r'CThreadInfo', + id: BigInt.parse('-5718643002744313917').toInt(), + properties: { + r'lastRepliedAt': PropertySchema( + id: 0, + name: r'lastRepliedAt', + type: IsarType.long, + ), + r'mostRepliesUsers': PropertySchema( + id: 1, + name: r'mostRepliesUsers', + type: IsarType.stringList, + ), + r'replyCount': PropertySchema( + id: 2, + name: r'replyCount', + type: IsarType.long, + ), + r'updatedAt': PropertySchema( + id: 3, + name: r'updatedAt', + type: IsarType.long, + ) + }, + estimateSize: _cThreadInfoEstimateSize, + serialize: _cThreadInfoSerialize, + deserialize: _cThreadInfoDeserialize, + deserializeProp: _cThreadInfoDeserializeProp, +); + +int _cThreadInfoEstimateSize( + CThreadInfo object, + List offsets, + Map> allOffsets, +) { + var bytesCount = offsets.last; + bytesCount += 3 + object.mostRepliesUsers.length * 3; + { + for (var i = 0; i < object.mostRepliesUsers.length; i++) { + final value = object.mostRepliesUsers[i]; + bytesCount += value.length * 3; + } + } + return bytesCount; +} + +void _cThreadInfoSerialize( + CThreadInfo object, + IsarWriter writer, + List offsets, + Map> allOffsets, +) { + writer.writeLong(offsets[0], object.lastRepliedAt); + writer.writeStringList(offsets[1], object.mostRepliesUsers); + writer.writeLong(offsets[2], object.replyCount); + writer.writeLong(offsets[3], object.updatedAt); +} + +CThreadInfo _cThreadInfoDeserialize( + Id id, + IsarReader reader, + List offsets, + Map> allOffsets, +) { + final object = CThreadInfo(); + object.lastRepliedAt = reader.readLong(offsets[0]); + object.mostRepliesUsers = reader.readStringList(offsets[1]) ?? []; + object.replyCount = reader.readLong(offsets[2]); + object.updatedAt = reader.readLongOrNull(offsets[3]); + return object; +} + +P _cThreadInfoDeserializeProp

( + IsarReader reader, + int propertyId, + int offset, + Map> allOffsets, +) { + switch (propertyId) { + case 0: + return (reader.readLong(offset)) as P; + case 1: + return (reader.readStringList(offset) ?? []) as P; + case 2: + return (reader.readLong(offset)) as P; + case 3: + return (reader.readLongOrNull(offset)) as P; + default: + throw IsarError('Unknown property with id $propertyId'); + } +} + +extension CThreadInfoQueryFilter + on QueryBuilder { + QueryBuilder + lastRepliedAtEqualTo(int value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'lastRepliedAt', + value: value, + )); + }); + } + + QueryBuilder + lastRepliedAtGreaterThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'lastRepliedAt', + value: value, + )); + }); + } + + QueryBuilder + lastRepliedAtLessThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'lastRepliedAt', + value: value, + )); + }); + } + + QueryBuilder + lastRepliedAtBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'lastRepliedAt', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + mostRepliesUsersElementEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'mostRepliesUsers', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + mostRepliesUsersElementGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'mostRepliesUsers', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + mostRepliesUsersElementLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'mostRepliesUsers', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + mostRepliesUsersElementBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'mostRepliesUsers', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + mostRepliesUsersElementStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'mostRepliesUsers', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + mostRepliesUsersElementEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'mostRepliesUsers', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + mostRepliesUsersElementContains(String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'mostRepliesUsers', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + mostRepliesUsersElementMatches(String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'mostRepliesUsers', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + mostRepliesUsersElementIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'mostRepliesUsers', + value: '', + )); + }); + } + + QueryBuilder + mostRepliesUsersElementIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'mostRepliesUsers', + value: '', + )); + }); + } + + QueryBuilder + mostRepliesUsersLengthEqualTo(int length) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'mostRepliesUsers', + length, + true, + length, + true, + ); + }); + } + + QueryBuilder + mostRepliesUsersIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'mostRepliesUsers', + 0, + true, + 0, + true, + ); + }); + } + + QueryBuilder + mostRepliesUsersIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'mostRepliesUsers', + 0, + false, + 999999, + true, + ); + }); + } + + QueryBuilder + mostRepliesUsersLengthLessThan( + int length, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'mostRepliesUsers', + 0, + true, + length, + include, + ); + }); + } + + QueryBuilder + mostRepliesUsersLengthGreaterThan( + int length, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'mostRepliesUsers', + length, + include, + 999999, + true, + ); + }); + } + + QueryBuilder + mostRepliesUsersLengthBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'mostRepliesUsers', + lower, + includeLower, + upper, + includeUpper, + ); + }); + } + + QueryBuilder + replyCountEqualTo(int value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'replyCount', + value: value, + )); + }); + } + + QueryBuilder + replyCountGreaterThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'replyCount', + value: value, + )); + }); + } + + QueryBuilder + replyCountLessThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'replyCount', + value: value, + )); + }); + } + + QueryBuilder + replyCountBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'replyCount', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + updatedAtIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'updatedAt', + )); + }); + } + + QueryBuilder + updatedAtIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'updatedAt', + )); + }); + } + + QueryBuilder + updatedAtEqualTo(int? value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'updatedAt', + value: value, + )); + }); + } + + QueryBuilder + updatedAtGreaterThan( + int? value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'updatedAt', + value: value, + )); + }); + } + + QueryBuilder + updatedAtLessThan( + int? value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'updatedAt', + value: value, + )); + }); + } + + QueryBuilder + updatedAtBetween( + int? lower, + int? upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'updatedAt', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } +} + +extension CThreadInfoQueryObject + on QueryBuilder {} + +// coverage:ignore-file +// ignore_for_file: duplicate_ignore, non_constant_identifier_names, constant_identifier_names, invalid_use_of_protected_member, unnecessary_cast, prefer_const_constructors, lines_longer_than_80_chars, require_trailing_commas, inference_failure_on_function_invocation, unnecessary_parenthesis, unnecessary_raw_strings, unnecessary_null_checks, join_return_with_assignment, prefer_final_locals, avoid_js_rounded_ints, avoid_positional_boolean_parameters, always_specify_types + +final COGMetaDataSchema = Schema( + name: r'COGMetaData', + id: BigInt.parse('-7487040563756714992').toInt(), + properties: { + r'description': PropertySchema( + id: 0, + name: r'description', + type: IsarType.string, + ), + r'ogImage': PropertySchema( + id: 1, + name: r'ogImage', + type: IsarType.object, + target: r'COGImage', + ), + r'title': PropertySchema( + id: 2, + name: r'title', + type: IsarType.string, + ), + r'url': PropertySchema( + id: 3, + name: r'url', + type: IsarType.string, + ) + }, + estimateSize: _cOGMetaDataEstimateSize, + serialize: _cOGMetaDataSerialize, + deserialize: _cOGMetaDataDeserialize, + deserializeProp: _cOGMetaDataDeserializeProp, +); + +int _cOGMetaDataEstimateSize( + COGMetaData object, + List offsets, + Map> allOffsets, +) { + var bytesCount = offsets.last; + { + final value = object.description; + if (value != null) { + bytesCount += 3 + value.length * 3; + } + } + { + final value = object.ogImage; + if (value != null) { + bytesCount += 3 + + COGImageSchema.estimateSize(value, allOffsets[COGImage]!, allOffsets); + } + } + { + final value = object.title; + if (value != null) { + bytesCount += 3 + value.length * 3; + } + } + { + final value = object.url; + if (value != null) { + bytesCount += 3 + value.length * 3; + } + } + return bytesCount; +} + +void _cOGMetaDataSerialize( + COGMetaData object, + IsarWriter writer, + List offsets, + Map> allOffsets, +) { + writer.writeString(offsets[0], object.description); + writer.writeObject( + offsets[1], + allOffsets, + COGImageSchema.serialize, + object.ogImage, + ); + writer.writeString(offsets[2], object.title); + writer.writeString(offsets[3], object.url); +} + +COGMetaData _cOGMetaDataDeserialize( + Id id, + IsarReader reader, + List offsets, + Map> allOffsets, +) { + final object = COGMetaData(); + object.description = reader.readStringOrNull(offsets[0]); + object.ogImage = reader.readObjectOrNull( + offsets[1], + COGImageSchema.deserialize, + allOffsets, + ); + object.title = reader.readStringOrNull(offsets[2]); + object.url = reader.readStringOrNull(offsets[3]); + return object; +} + +P _cOGMetaDataDeserializeProp

( + IsarReader reader, + int propertyId, + int offset, + Map> allOffsets, +) { + switch (propertyId) { + case 0: + return (reader.readStringOrNull(offset)) as P; + case 1: + return (reader.readObjectOrNull( + offset, + COGImageSchema.deserialize, + allOffsets, + )) as P; + case 2: + return (reader.readStringOrNull(offset)) as P; + case 3: + return (reader.readStringOrNull(offset)) as P; + default: + throw IsarError('Unknown property with id $propertyId'); + } +} + +extension COGMetaDataQueryFilter + on QueryBuilder { + QueryBuilder + descriptionIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'description', + )); + }); + } + + QueryBuilder + descriptionIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'description', + )); + }); + } + + QueryBuilder + descriptionEqualTo( + String? value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'description', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + descriptionGreaterThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'description', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + descriptionLessThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'description', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + descriptionBetween( + String? lower, + String? upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'description', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + descriptionStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'description', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + descriptionEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'description', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + descriptionContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'description', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + descriptionMatches(String pattern, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'description', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + descriptionIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'description', + value: '', + )); + }); + } + + QueryBuilder + descriptionIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'description', + value: '', + )); + }); + } + + QueryBuilder + ogImageIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'ogImage', + )); + }); + } + + QueryBuilder + ogImageIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'ogImage', + )); + }); + } + + QueryBuilder titleIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'title', + )); + }); + } + + QueryBuilder + titleIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'title', + )); + }); + } + + QueryBuilder titleEqualTo( + String? value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'title', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + titleGreaterThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'title', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder titleLessThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'title', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder titleBetween( + String? lower, + String? upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'title', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder titleStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'title', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder titleEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'title', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder titleContains( + String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'title', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder titleMatches( + String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'title', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder titleIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'title', + value: '', + )); + }); + } + + QueryBuilder + titleIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'title', + value: '', + )); + }); + } + + QueryBuilder urlIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'url', + )); + }); + } + + QueryBuilder urlIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'url', + )); + }); + } + + QueryBuilder urlEqualTo( + String? value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'url', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder urlGreaterThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'url', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder urlLessThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'url', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder urlBetween( + String? lower, + String? upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'url', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder urlStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'url', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder urlEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'url', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder urlContains( + String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'url', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder urlMatches( + String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'url', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder urlIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'url', + value: '', + )); + }); + } + + QueryBuilder + urlIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'url', + value: '', + )); + }); + } +} + +extension COGMetaDataQueryObject + on QueryBuilder { + QueryBuilder ogImage( + FilterQuery q) { + return QueryBuilder.apply(this, (query) { + return query.object(q, r'ogImage'); + }); + } +} + +// coverage:ignore-file +// ignore_for_file: duplicate_ignore, non_constant_identifier_names, constant_identifier_names, invalid_use_of_protected_member, unnecessary_cast, prefer_const_constructors, lines_longer_than_80_chars, require_trailing_commas, inference_failure_on_function_invocation, unnecessary_parenthesis, unnecessary_raw_strings, unnecessary_null_checks, join_return_with_assignment, prefer_final_locals, avoid_js_rounded_ints, avoid_positional_boolean_parameters, always_specify_types + +final COGImageSchema = Schema( + name: r'COGImage', + id: BigInt.parse('4132417177077221336').toInt(), + properties: { + r'alt': PropertySchema( + id: 0, + name: r'alt', + type: IsarType.string, + ), + r'height': PropertySchema( + id: 1, + name: r'height', + type: IsarType.long, + ), + r'secureUrl': PropertySchema( + id: 2, + name: r'secureUrl', + type: IsarType.string, + ), + r'type': PropertySchema( + id: 3, + name: r'type', + type: IsarType.string, + ), + r'url': PropertySchema( + id: 4, + name: r'url', + type: IsarType.string, + ), + r'width': PropertySchema( + id: 5, + name: r'width', + type: IsarType.long, + ) + }, + estimateSize: _cOGImageEstimateSize, + serialize: _cOGImageSerialize, + deserialize: _cOGImageDeserialize, + deserializeProp: _cOGImageDeserializeProp, +); + +int _cOGImageEstimateSize( + COGImage object, + List offsets, + Map> allOffsets, +) { + var bytesCount = offsets.last; + { + final value = object.alt; + if (value != null) { + bytesCount += 3 + value.length * 3; + } + } + { + final value = object.secureUrl; + if (value != null) { + bytesCount += 3 + value.length * 3; + } + } + { + final value = object.type; + if (value != null) { + bytesCount += 3 + value.length * 3; + } + } + { + final value = object.url; + if (value != null) { + bytesCount += 3 + value.length * 3; + } + } + return bytesCount; +} + +void _cOGImageSerialize( + COGImage object, + IsarWriter writer, + List offsets, + Map> allOffsets, +) { + writer.writeString(offsets[0], object.alt); + writer.writeLong(offsets[1], object.height); + writer.writeString(offsets[2], object.secureUrl); + writer.writeString(offsets[3], object.type); + writer.writeString(offsets[4], object.url); + writer.writeLong(offsets[5], object.width); +} + +COGImage _cOGImageDeserialize( + Id id, + IsarReader reader, + List offsets, + Map> allOffsets, +) { + final object = COGImage(); + object.alt = reader.readStringOrNull(offsets[0]); + object.height = reader.readLong(offsets[1]); + object.secureUrl = reader.readStringOrNull(offsets[2]); + object.type = reader.readStringOrNull(offsets[3]); + object.url = reader.readStringOrNull(offsets[4]); + object.width = reader.readLong(offsets[5]); + return object; +} + +P _cOGImageDeserializeProp

( + IsarReader reader, + int propertyId, + int offset, + Map> allOffsets, +) { + switch (propertyId) { + case 0: + return (reader.readStringOrNull(offset)) as P; + case 1: + return (reader.readLong(offset)) as P; + case 2: + return (reader.readStringOrNull(offset)) as P; + case 3: + return (reader.readStringOrNull(offset)) as P; + case 4: + return (reader.readStringOrNull(offset)) as P; + case 5: + return (reader.readLong(offset)) as P; + default: + throw IsarError('Unknown property with id $propertyId'); + } +} + +extension COGImageQueryFilter + on QueryBuilder { + QueryBuilder altIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'alt', + )); + }); + } + + QueryBuilder altIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'alt', + )); + }); + } + + QueryBuilder altEqualTo( + String? value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'alt', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder altGreaterThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'alt', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder altLessThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'alt', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder altBetween( + String? lower, + String? upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'alt', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder altStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'alt', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder altEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'alt', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder altContains( + String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'alt', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder altMatches( + String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'alt', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder altIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'alt', + value: '', + )); + }); + } + + QueryBuilder altIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'alt', + value: '', + )); + }); + } + + QueryBuilder heightEqualTo( + int value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'height', + value: value, + )); + }); + } + + QueryBuilder heightGreaterThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'height', + value: value, + )); + }); + } + + QueryBuilder heightLessThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'height', + value: value, + )); + }); + } + + QueryBuilder heightBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'height', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder secureUrlIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'secureUrl', + )); + }); + } + + QueryBuilder secureUrlIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'secureUrl', + )); + }); + } + + QueryBuilder secureUrlEqualTo( + String? value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'secureUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder secureUrlGreaterThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'secureUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder secureUrlLessThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'secureUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder secureUrlBetween( + String? lower, + String? upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'secureUrl', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder secureUrlStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'secureUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder secureUrlEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'secureUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder secureUrlContains( + String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'secureUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder secureUrlMatches( + String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'secureUrl', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder secureUrlIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'secureUrl', + value: '', + )); + }); + } + + QueryBuilder + secureUrlIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'secureUrl', + value: '', + )); + }); + } + + QueryBuilder typeIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'type', + )); + }); + } + + QueryBuilder typeIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'type', + )); + }); + } + + QueryBuilder typeEqualTo( + String? value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'type', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder typeGreaterThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'type', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder typeLessThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'type', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder typeBetween( + String? lower, + String? upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'type', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder typeStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'type', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder typeEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'type', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder typeContains( + String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'type', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder typeMatches( + String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'type', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder typeIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'type', + value: '', + )); + }); + } + + QueryBuilder typeIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'type', + value: '', + )); + }); + } + + QueryBuilder urlIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'url', + )); + }); + } + + QueryBuilder urlIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'url', + )); + }); + } + + QueryBuilder urlEqualTo( + String? value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'url', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder urlGreaterThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'url', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder urlLessThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'url', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder urlBetween( + String? lower, + String? upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'url', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder urlStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'url', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder urlEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'url', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder urlContains( + String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'url', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder urlMatches( + String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'url', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder urlIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'url', + value: '', + )); + }); + } + + QueryBuilder urlIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'url', + value: '', + )); + }); + } + + QueryBuilder widthEqualTo( + int value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'width', + value: value, + )); + }); + } + + QueryBuilder widthGreaterThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'width', + value: value, + )); + }); + } + + QueryBuilder widthLessThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'width', + value: value, + )); + }); + } + + QueryBuilder widthBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'width', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } +} + +extension COGImageQueryObject + on QueryBuilder {} + +// coverage:ignore-file +// ignore_for_file: duplicate_ignore, non_constant_identifier_names, constant_identifier_names, invalid_use_of_protected_member, unnecessary_cast, prefer_const_constructors, lines_longer_than_80_chars, require_trailing_commas, inference_failure_on_function_invocation, unnecessary_parenthesis, unnecessary_raw_strings, unnecessary_null_checks, join_return_with_assignment, prefer_final_locals, avoid_js_rounded_ints, avoid_positional_boolean_parameters, always_specify_types + +final CReactionSchema = Schema( + name: r'CReaction', + id: BigInt.parse('4688882985774356514').toInt(), + properties: { + r'key': PropertySchema( + id: 0, + name: r'key', + type: IsarType.string, + ), + r'updatedAt': PropertySchema( + id: 1, + name: r'updatedAt', + type: IsarType.long, + ), + r'updatedAts': PropertySchema( + id: 2, + name: r'updatedAts', + type: IsarType.string, + ), + r'userIds': PropertySchema( + id: 3, + name: r'userIds', + type: IsarType.stringList, + ) + }, + estimateSize: _cReactionEstimateSize, + serialize: _cReactionSerialize, + deserialize: _cReactionDeserialize, + deserializeProp: _cReactionDeserializeProp, +); + +int _cReactionEstimateSize( + CReaction object, + List offsets, + Map> allOffsets, +) { + var bytesCount = offsets.last; + bytesCount += 3 + object.key.length * 3; + bytesCount += 3 + object.updatedAts.length * 3; + bytesCount += 3 + object.userIds.length * 3; + { + for (var i = 0; i < object.userIds.length; i++) { + final value = object.userIds[i]; + bytesCount += value.length * 3; + } + } + return bytesCount; +} + +void _cReactionSerialize( + CReaction object, + IsarWriter writer, + List offsets, + Map> allOffsets, +) { + writer.writeString(offsets[0], object.key); + writer.writeLong(offsets[1], object.updatedAt); + writer.writeString(offsets[2], object.updatedAts); + writer.writeStringList(offsets[3], object.userIds); +} + +CReaction _cReactionDeserialize( + Id id, + IsarReader reader, + List offsets, + Map> allOffsets, +) { + final object = CReaction(); + object.key = reader.readString(offsets[0]); + object.updatedAt = reader.readLong(offsets[1]); + object.updatedAts = reader.readString(offsets[2]); + object.userIds = reader.readStringList(offsets[3]) ?? []; + return object; +} + +P _cReactionDeserializeProp

( + IsarReader reader, + int propertyId, + int offset, + Map> allOffsets, +) { + switch (propertyId) { + case 0: + return (reader.readString(offset)) as P; + case 1: + return (reader.readLong(offset)) as P; + case 2: + return (reader.readString(offset)) as P; + case 3: + return (reader.readStringList(offset) ?? []) as P; + default: + throw IsarError('Unknown property with id $propertyId'); + } +} + +extension CReactionQueryFilter + on QueryBuilder { + QueryBuilder keyEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'key', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder keyGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'key', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder keyLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'key', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder keyBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'key', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder keyStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'key', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder keyEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'key', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder keyContains( + String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'key', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder keyMatches( + String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'key', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder keyIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'key', + value: '', + )); + }); + } + + QueryBuilder keyIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'key', + value: '', + )); + }); + } + + QueryBuilder updatedAtEqualTo( + int value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'updatedAt', + value: value, + )); + }); + } + + QueryBuilder + updatedAtGreaterThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'updatedAt', + value: value, + )); + }); + } + + QueryBuilder updatedAtLessThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'updatedAt', + value: value, + )); + }); + } + + QueryBuilder updatedAtBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'updatedAt', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder updatedAtsEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'updatedAts', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + updatedAtsGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'updatedAts', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder updatedAtsLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'updatedAts', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder updatedAtsBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'updatedAts', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + updatedAtsStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'updatedAts', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder updatedAtsEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'updatedAts', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder updatedAtsContains( + String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'updatedAts', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder updatedAtsMatches( + String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'updatedAts', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + updatedAtsIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'updatedAts', + value: '', + )); + }); + } + + QueryBuilder + updatedAtsIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'updatedAts', + value: '', + )); + }); + } + + QueryBuilder + userIdsElementEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'userIds', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + userIdsElementGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'userIds', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + userIdsElementLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'userIds', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + userIdsElementBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'userIds', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + userIdsElementStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'userIds', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + userIdsElementEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'userIds', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + userIdsElementContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'userIds', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + userIdsElementMatches(String pattern, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'userIds', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + userIdsElementIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'userIds', + value: '', + )); + }); + } + + QueryBuilder + userIdsElementIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'userIds', + value: '', + )); + }); + } + + QueryBuilder + userIdsLengthEqualTo(int length) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'userIds', + length, + true, + length, + true, + ); + }); + } + + QueryBuilder userIdsIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'userIds', + 0, + true, + 0, + true, + ); + }); + } + + QueryBuilder + userIdsIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'userIds', + 0, + false, + 999999, + true, + ); + }); + } + + QueryBuilder + userIdsLengthLessThan( + int length, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'userIds', + 0, + true, + length, + include, + ); + }); + } + + QueryBuilder + userIdsLengthGreaterThan( + int length, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'userIds', + length, + include, + 999999, + true, + ); + }); + } + + QueryBuilder + userIdsLengthBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'userIds', + lower, + includeLower, + upper, + includeUpper, + ); + }); + } +} + +extension CReactionQueryObject + on QueryBuilder {} + +// coverage:ignore-file +// ignore_for_file: duplicate_ignore, non_constant_identifier_names, constant_identifier_names, invalid_use_of_protected_member, unnecessary_cast, prefer_const_constructors, lines_longer_than_80_chars, require_trailing_commas, inference_failure_on_function_invocation, unnecessary_parenthesis, unnecessary_raw_strings, unnecessary_null_checks, join_return_with_assignment, prefer_final_locals, avoid_js_rounded_ints, avoid_positional_boolean_parameters, always_specify_types + +final CScheduledInfoSchema = Schema( + name: r'CScheduledInfo', + id: BigInt.parse('-697940854651714003').toInt(), + properties: { + r'scheduledAt': PropertySchema( + id: 0, + name: r'scheduledAt', + type: IsarType.long, + ), + r'scheduledMessageId': PropertySchema( + id: 1, + name: r'scheduledMessageId', + type: IsarType.long, + ), + r'scheduledStatus': PropertySchema( + id: 2, + name: r'scheduledStatus', + type: IsarType.byte, + enumMap: _CScheduledInfoscheduledStatusEnumValueMap, + ) + }, + estimateSize: _cScheduledInfoEstimateSize, + serialize: _cScheduledInfoSerialize, + deserialize: _cScheduledInfoDeserialize, + deserializeProp: _cScheduledInfoDeserializeProp, +); + +int _cScheduledInfoEstimateSize( + CScheduledInfo object, + List offsets, + Map> allOffsets, +) { + var bytesCount = offsets.last; + return bytesCount; +} + +void _cScheduledInfoSerialize( + CScheduledInfo object, + IsarWriter writer, + List offsets, + Map> allOffsets, +) { + writer.writeLong(offsets[0], object.scheduledAt); + writer.writeLong(offsets[1], object.scheduledMessageId); + writer.writeByte(offsets[2], object.scheduledStatus.index); +} + +CScheduledInfo _cScheduledInfoDeserialize( + Id id, + IsarReader reader, + List offsets, + Map> allOffsets, +) { + final object = CScheduledInfo(); + object.scheduledAt = reader.readLong(offsets[0]); + object.scheduledMessageId = reader.readLong(offsets[1]); + object.scheduledStatus = _CScheduledInfoscheduledStatusValueEnumMap[ + reader.readByteOrNull(offsets[2])] ?? + ScheduledStatus.pending; + return object; +} + +P _cScheduledInfoDeserializeProp

( + IsarReader reader, + int propertyId, + int offset, + Map> allOffsets, +) { + switch (propertyId) { + case 0: + return (reader.readLong(offset)) as P; + case 1: + return (reader.readLong(offset)) as P; + case 2: + return (_CScheduledInfoscheduledStatusValueEnumMap[ + reader.readByteOrNull(offset)] ?? + ScheduledStatus.pending) as P; + default: + throw IsarError('Unknown property with id $propertyId'); + } +} + +const _CScheduledInfoscheduledStatusEnumValueMap = { + 'pending': 0, + 'inQueue': 1, + 'sent': 2, + 'failed': 3, + 'canceled': 4, + 'removed': 5, +}; +const _CScheduledInfoscheduledStatusValueEnumMap = { + 0: ScheduledStatus.pending, + 1: ScheduledStatus.inQueue, + 2: ScheduledStatus.sent, + 3: ScheduledStatus.failed, + 4: ScheduledStatus.canceled, + 5: ScheduledStatus.removed, +}; + +extension CScheduledInfoQueryFilter + on QueryBuilder { + QueryBuilder + scheduledAtEqualTo(int value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'scheduledAt', + value: value, + )); + }); + } + + QueryBuilder + scheduledAtGreaterThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'scheduledAt', + value: value, + )); + }); + } + + QueryBuilder + scheduledAtLessThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'scheduledAt', + value: value, + )); + }); + } + + QueryBuilder + scheduledAtBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'scheduledAt', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + scheduledMessageIdEqualTo(int value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'scheduledMessageId', + value: value, + )); + }); + } + + QueryBuilder + scheduledMessageIdGreaterThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'scheduledMessageId', + value: value, + )); + }); + } + + QueryBuilder + scheduledMessageIdLessThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'scheduledMessageId', + value: value, + )); + }); + } + + QueryBuilder + scheduledMessageIdBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'scheduledMessageId', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + scheduledStatusEqualTo(ScheduledStatus value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'scheduledStatus', + value: value, + )); + }); + } + + QueryBuilder + scheduledStatusGreaterThan( + ScheduledStatus value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'scheduledStatus', + value: value, + )); + }); + } + + QueryBuilder + scheduledStatusLessThan( + ScheduledStatus value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'scheduledStatus', + value: value, + )); + }); + } + + QueryBuilder + scheduledStatusBetween( + ScheduledStatus lower, + ScheduledStatus upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'scheduledStatus', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } +} + +extension CScheduledInfoQueryObject + on QueryBuilder {} diff --git a/lib/src/internal/db/schema/message/c_file_message.dart b/lib/src/internal/db/schema/message/c_file_message.dart new file mode 100644 index 00000000..9b4f68ac --- /dev/null +++ b/lib/src/internal/db/schema/message/c_file_message.dart @@ -0,0 +1,304 @@ +// Copyright (c) 2023 Sendbird, Inc. All rights reserved. + +import 'dart:io'; +import 'dart:ui'; + +import 'package:isar/isar.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/message/c_base_message.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/message/c_root_message.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/message/meta/c_channel_message.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/user/c_sender.dart'; +import 'package:sendbird_chat_sdk/src/internal/main/chat/chat.dart'; +import 'package:sendbird_chat_sdk/src/public/core/message/file_message.dart'; +import 'package:sendbird_chat_sdk/src/public/core/message/root_message.dart'; +import 'package:sendbird_chat_sdk/src/public/main/define/enums.dart'; +import 'package:sendbird_chat_sdk/src/public/main/model/info/file_info.dart'; +import 'package:sendbird_chat_sdk/src/public/main/params/message/file_message_create_params.dart'; + +part 'c_file_message.g.dart'; + +@collection +class CFileMessage extends CBaseMessage { + late String url; + String? name; + int? size; + String? type; + List? thumbnails; + CFileMessageCreateParams? messageCreateParams; + late bool requireAuth; + + CFileMessage(); + + factory CFileMessage.fromFileMessage(FileMessage message) { + return CFileMessage() + // BaseMessage + ..setBaseMessage(message) + // FileMessage + ..url = message.url + ..name = message.name + ..size = message.size + ..type = message.type + ..thumbnails = message.thumbnails + ?.map((thumbnail) => CThumbnail.fromThumbnail(thumbnail)) + .toList() + ..messageCreateParams = message.messageCreateParams != null + ? CFileMessageCreateParams.fromFileMessageCreateParams( + message.messageCreateParams!) + : null + ..requireAuth = message.requireAuth; + } + + Future toFileMessage(Chat chat, Isar isar) async { + final fileMessage = FileMessage( + // RootMessage + channelUrl: channelUrl, + channelType: channelType, + // BaseMessage + messageId: messageId, + // FileMessage + url: url, + )..set(chat); + return await CBaseMessage.setCBaseMessage(chat, isar, fileMessage, this) + as FileMessage + // FileMessage + ..name = name + ..size = size + ..type = type + ..thumbnails = + thumbnails?.map((cThumbnail) => cThumbnail.toThumbnail()).toList() + ..messageCreateParams = messageCreateParams?.toFileMessageCreateParams() + ..requireAuth = requireAuth; + } + + static Future upsert( + Chat chat, Isar isar, FileMessage message) async { + final cFileMessage = CFileMessage.fromFileMessage(message); + + // RootMessage + await CRootMessage.upsert(chat, isar, message); + + // BaseMessage + await CBaseMessage.upsert(chat, isar, message); + + // FileMessage + await chat.dbManager.write(() async { + await isar.cFileMessages.put(cFileMessage); + }); + + // ChannelMessage + await CChannelMessage.upsert(chat, isar, message); + + return cFileMessage; + } + + static Future get(Chat chat, Isar isar, String rootId) async { + final cFileMessage = + await isar.cFileMessages.where().rootIdEqualTo(rootId).findFirst(); + return await cFileMessage?.toFileMessage(chat, isar); + } + + static Future delete(Chat chat, Isar isar, String rootId) async { + // FileMessage + await chat.dbManager.write(() async { + await isar.cFileMessages.deleteByRootId(rootId); + }); + + // ChannelMessage + await CChannelMessage.delete(chat, isar, rootId); + } +} + +@embedded +class CThumbnail { + late String url; + String? plainUrl; + double? height; + double? width; + double? realHeight; + double? realWidth; + + CThumbnail(); + + factory CThumbnail.fromThumbnail(Thumbnail thumbnail) { + return CThumbnail() + ..url = thumbnail.url + ..plainUrl = thumbnail.plainUrl + ..height = thumbnail.height + ..width = thumbnail.width + ..realHeight = thumbnail.realHeight + ..realWidth = thumbnail.realWidth; + } + + Thumbnail toThumbnail() { + return Thumbnail( + url, + plainUrl, + height, + width, + realHeight, + realWidth, + ); + } +} + +@embedded +class CFileMessageCreateParams { + // BaseMessageCreateParams + String? data; + String? customType; + + @enumerated + late MentionType mentionType; + + List? mentionedUserIds; + List? metaArrays; + int? parentMessageId; + late bool replyToChannel; + + @enumerated + late PushNotificationDeliveryOption pushNotificationDeliveryOption; + + late bool isPinnedMessage; + + // FileMessageCreateParams + late CFileInfo fileInfo; + List? thumbnailSizes; + + CFileMessageCreateParams(); + + factory CFileMessageCreateParams.fromFileMessageCreateParams( + FileMessageCreateParams params) { + return CFileMessageCreateParams() + // BaseMessageCreateParams + ..data = params.data + ..customType = params.customType + ..mentionType = params.mentionType + ..mentionedUserIds = params.mentionedUserIds + ..metaArrays = params.metaArrays + ?.map( + (metaArray) => CMessageMetaArray.fromMessageMetaArray(metaArray)) + .toList() + ..parentMessageId = params.parentMessageId + ..replyToChannel = params.replyToChannel + ..pushNotificationDeliveryOption = params.pushNotificationDeliveryOption + ..isPinnedMessage = params.isPinnedMessage + + // FileMessageCreateParams + ..fileInfo = CFileInfo.fromFileInfo(params.fileInfo) + ..thumbnailSizes = params.thumbnailSizes + ?.map((thumbnailSize) => CSize.fromSize(thumbnailSize)) + .toList(); + } + + FileMessageCreateParams? toFileMessageCreateParams() { + // withFileBytes() is not supported. + if (fileInfo.fileUrl != null && fileInfo.fileUrl!.isNotEmpty) { + return FileMessageCreateParams.withFileUrl( + // FileMessageCreateParams + fileInfo.fileUrl ?? '', + fileName: fileInfo.fileName, + mimeType: fileInfo.mimeType, + fileSize: fileInfo.fileSize, + + // BaseMessageCreateParams + data: data, + customType: customType, + mentionType: mentionType, + mentionedUserIds: mentionedUserIds, + metaArrays: metaArrays != null + ? metaArrays! + .map((metaArray) => metaArray.toMessageMetaArray()) + .toList() + : null, + parentMessageId: parentMessageId, + replyToChannel: replyToChannel, + pushNotificationDeliveryOption: pushNotificationDeliveryOption, + isPinnedMessage: isPinnedMessage, + ); + } + if (fileInfo.localFilePath != null && fileInfo.localFilePath!.isNotEmpty) { + return FileMessageCreateParams.withFile( + // FileMessageCreateParams + File(fileInfo.localFilePath!), + fileName: fileInfo.fileName, + + // BaseMessageCreateParams + data: data, + customType: customType, + mentionType: mentionType, + mentionedUserIds: mentionedUserIds, + metaArrays: metaArrays != null + ? metaArrays! + .map((metaArray) => metaArray.toMessageMetaArray()) + .toList() + : null, + parentMessageId: parentMessageId, + replyToChannel: replyToChannel, + pushNotificationDeliveryOption: pushNotificationDeliveryOption, + isPinnedMessage: isPinnedMessage, + ); + } + return null; + } +} + +@embedded +class CFileInfo { + // Uint8List? fileBytes; // Not supported + String? fileUrl; + String? fileName; + String? mimeType; + int? fileSize; + String? localFilePath; // Added for File support + + CFileInfo(); + + factory CFileInfo.fromFileInfo(FileInfo info) { + final fileInfo = CFileInfo() + ..fileUrl = info.fileUrl + ..fileName = info.fileName + ..mimeType = info.mimeType + ..fileSize = info.fileSize; + if (info.file != null) { + fileInfo.localFilePath = info.file!.path; + } + return fileInfo; + } + + FileInfo? toFileInfo() { + if (fileUrl != null && fileUrl!.isNotEmpty) { + return FileInfo.fromFileUrl( + fileUrl: fileUrl, + fileName: fileName, + mimeType: mimeType, + fileSize: fileSize, + ); + } + if (localFilePath != null && localFilePath!.isNotEmpty) { + return FileInfo.fromFile( + file: File(localFilePath!), + fileName: fileName, + mimeType: mimeType, + ); + } + return null; + } +} + +@embedded +class CSize { + late double width; + late double height; + + CSize(); + + factory CSize.fromSize(Size size) { + return CSize() + ..width = size.width + ..height = size.height; + } + + Size? toSize() { + return Size(width, height); + } +} diff --git a/lib/src/internal/db/schema/message/c_file_message.g.dart b/lib/src/internal/db/schema/message/c_file_message.g.dart new file mode 100644 index 00000000..abe05490 --- /dev/null +++ b/lib/src/internal/db/schema/message/c_file_message.g.dart @@ -0,0 +1,8598 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'c_file_message.dart'; + +// ************************************************************************** +// IsarCollectionGenerator +// ************************************************************************** + +// coverage:ignore-file +// ignore_for_file: duplicate_ignore, non_constant_identifier_names, constant_identifier_names, invalid_use_of_protected_member, unnecessary_cast, prefer_const_constructors, lines_longer_than_80_chars, require_trailing_commas, inference_failure_on_function_invocation, unnecessary_parenthesis, unnecessary_raw_strings, unnecessary_null_checks, join_return_with_assignment, prefer_final_locals, avoid_js_rounded_ints, avoid_positional_boolean_parameters, always_specify_types + +extension GetCFileMessageCollection on Isar { + IsarCollection get cFileMessages => this.collection(); +} + +final CFileMessageSchema = CollectionSchema( + name: r'CFileMessage', + id: BigInt.parse('5183317174548444251').toInt(), + properties: { + r'allMetaArrays': PropertySchema( + id: 0, + name: r'allMetaArrays', + type: IsarType.objectList, + target: r'CMessageMetaArray', + ), + r'channelType': PropertySchema( + id: 1, + name: r'channelType', + type: IsarType.byte, + enumMap: _CFileMessagechannelTypeEnumValueMap, + ), + r'channelUrl': PropertySchema( + id: 2, + name: r'channelUrl', + type: IsarType.string, + ), + r'createdAt': PropertySchema( + id: 3, + name: r'createdAt', + type: IsarType.long, + ), + r'customType': PropertySchema( + id: 4, + name: r'customType', + type: IsarType.string, + ), + r'data': PropertySchema( + id: 5, + name: r'data', + type: IsarType.string, + ), + r'errorCode': PropertySchema( + id: 6, + name: r'errorCode', + type: IsarType.long, + ), + r'extendedMessage': PropertySchema( + id: 7, + name: r'extendedMessage', + type: IsarType.string, + ), + r'isOperatorMessage': PropertySchema( + id: 8, + name: r'isOperatorMessage', + type: IsarType.bool, + ), + r'isReplyToChannel': PropertySchema( + id: 9, + name: r'isReplyToChannel', + type: IsarType.bool, + ), + r'isSilent': PropertySchema( + id: 10, + name: r'isSilent', + type: IsarType.bool, + ), + r'mentionType': PropertySchema( + id: 11, + name: r'mentionType', + type: IsarType.byte, + enumMap: _CFileMessagementionTypeEnumValueMap, + ), + r'mentionedUsers': PropertySchema( + id: 12, + name: r'mentionedUsers', + type: IsarType.stringList, + ), + r'message': PropertySchema( + id: 13, + name: r'message', + type: IsarType.string, + ), + r'messageCreateParams': PropertySchema( + id: 14, + name: r'messageCreateParams', + type: IsarType.object, + target: r'CFileMessageCreateParams', + ), + r'messageId': PropertySchema( + id: 15, + name: r'messageId', + type: IsarType.long, + ), + r'messageSurvivalSeconds': PropertySchema( + id: 16, + name: r'messageSurvivalSeconds', + type: IsarType.long, + ), + r'messageType': PropertySchema( + id: 17, + name: r'messageType', + type: IsarType.byte, + enumMap: _CFileMessagemessageTypeEnumValueMap, + ), + r'name': PropertySchema( + id: 18, + name: r'name', + type: IsarType.string, + ), + r'ogMetaData': PropertySchema( + id: 19, + name: r'ogMetaData', + type: IsarType.object, + target: r'COGMetaData', + ), + r'parentMessageId': PropertySchema( + id: 20, + name: r'parentMessageId', + type: IsarType.long, + ), + r'parentMessageRootId': PropertySchema( + id: 21, + name: r'parentMessageRootId', + type: IsarType.string, + ), + r'parentMessageType': PropertySchema( + id: 22, + name: r'parentMessageType', + type: IsarType.byte, + enumMap: _CFileMessageparentMessageTypeEnumValueMap, + ), + r'reactions': PropertySchema( + id: 23, + name: r'reactions', + type: IsarType.objectList, + target: r'CReaction', + ), + r'requestId': PropertySchema( + id: 24, + name: r'requestId', + type: IsarType.string, + ), + r'requireAuth': PropertySchema( + id: 25, + name: r'requireAuth', + type: IsarType.bool, + ), + r'rootId': PropertySchema( + id: 26, + name: r'rootId', + type: IsarType.string, + ), + r'scheduledInfo': PropertySchema( + id: 27, + name: r'scheduledInfo', + type: IsarType.object, + target: r'CScheduledInfo', + ), + r'sender': PropertySchema( + id: 28, + name: r'sender', + type: IsarType.object, + target: r'CSender', + ), + r'sendingStatus': PropertySchema( + id: 29, + name: r'sendingStatus', + type: IsarType.byte, + enumMap: _CFileMessagesendingStatusEnumValueMap, + ), + r'size': PropertySchema( + id: 30, + name: r'size', + type: IsarType.long, + ), + r'threadInfo': PropertySchema( + id: 31, + name: r'threadInfo', + type: IsarType.object, + target: r'CThreadInfo', + ), + r'thumbnails': PropertySchema( + id: 32, + name: r'thumbnails', + type: IsarType.objectList, + target: r'CThumbnail', + ), + r'type': PropertySchema( + id: 33, + name: r'type', + type: IsarType.string, + ), + r'updatedAt': PropertySchema( + id: 34, + name: r'updatedAt', + type: IsarType.long, + ), + r'url': PropertySchema( + id: 35, + name: r'url', + type: IsarType.string, + ) + }, + estimateSize: _cFileMessageEstimateSize, + serialize: _cFileMessageSerialize, + deserialize: _cFileMessageDeserialize, + deserializeProp: _cFileMessageDeserializeProp, + idName: r'id', + indexes: { + r'rootId': IndexSchema( + id: BigInt.parse('5087693435549841488').toInt(), + name: r'rootId', + unique: true, + replace: true, + properties: [ + IndexPropertySchema( + name: r'rootId', + type: IndexType.hash, + caseSensitive: true, + ) + ], + ), + r'messageType_rootId': IndexSchema( + id: BigInt.parse('-7060804333380842370').toInt(), + name: r'messageType_rootId', + unique: false, + replace: false, + properties: [ + IndexPropertySchema( + name: r'messageType', + type: IndexType.value, + caseSensitive: false, + ), + IndexPropertySchema( + name: r'rootId', + type: IndexType.hash, + caseSensitive: true, + ) + ], + ), + r'channelUrl': IndexSchema( + id: BigInt.parse('6636052684858767397').toInt(), + name: r'channelUrl', + unique: false, + replace: false, + properties: [ + IndexPropertySchema( + name: r'channelUrl', + type: IndexType.hash, + caseSensitive: true, + ) + ], + ), + r'channelType_channelUrl': IndexSchema( + id: BigInt.parse('-5957547153902522682').toInt(), + name: r'channelType_channelUrl', + unique: false, + replace: false, + properties: [ + IndexPropertySchema( + name: r'channelType', + type: IndexType.value, + caseSensitive: false, + ), + IndexPropertySchema( + name: r'channelUrl', + type: IndexType.hash, + caseSensitive: true, + ) + ], + ) + }, + links: {}, + embeddedSchemas: { + r'CThumbnail': CThumbnailSchema, + r'CFileMessageCreateParams': CFileMessageCreateParamsSchema, + r'CMessageMetaArray': CMessageMetaArraySchema, + r'CFileInfo': CFileInfoSchema, + r'CSize': CSizeSchema, + r'CThreadInfo': CThreadInfoSchema, + r'COGMetaData': COGMetaDataSchema, + r'COGImage': COGImageSchema, + r'CReaction': CReactionSchema, + r'CScheduledInfo': CScheduledInfoSchema, + r'CSender': CSenderSchema + }, + getId: _cFileMessageGetId, + getLinks: _cFileMessageGetLinks, + attach: _cFileMessageAttach, + version: '3.1.0+1', +); + +int _cFileMessageEstimateSize( + CFileMessage object, + List offsets, + Map> allOffsets, +) { + var bytesCount = offsets.last; + { + final list = object.allMetaArrays; + if (list != null) { + bytesCount += 3 + list.length * 3; + { + final offsets = allOffsets[CMessageMetaArray]!; + for (var i = 0; i < list.length; i++) { + final value = list[i]; + bytesCount += + CMessageMetaArraySchema.estimateSize(value, offsets, allOffsets); + } + } + } + } + bytesCount += 3 + object.channelUrl.length * 3; + { + final value = object.customType; + if (value != null) { + bytesCount += 3 + value.length * 3; + } + } + { + final value = object.data; + if (value != null) { + bytesCount += 3 + value.length * 3; + } + } + bytesCount += 3 + object.extendedMessage.length * 3; + bytesCount += 3 + object.mentionedUsers.length * 3; + { + for (var i = 0; i < object.mentionedUsers.length; i++) { + final value = object.mentionedUsers[i]; + bytesCount += value.length * 3; + } + } + bytesCount += 3 + object.message.length * 3; + { + final value = object.messageCreateParams; + if (value != null) { + bytesCount += 3 + + CFileMessageCreateParamsSchema.estimateSize( + value, allOffsets[CFileMessageCreateParams]!, allOffsets); + } + } + { + final value = object.name; + if (value != null) { + bytesCount += 3 + value.length * 3; + } + } + { + final value = object.ogMetaData; + if (value != null) { + bytesCount += 3 + + COGMetaDataSchema.estimateSize( + value, allOffsets[COGMetaData]!, allOffsets); + } + } + { + final value = object.parentMessageRootId; + if (value != null) { + bytesCount += 3 + value.length * 3; + } + } + { + final list = object.reactions; + if (list != null) { + bytesCount += 3 + list.length * 3; + { + final offsets = allOffsets[CReaction]!; + for (var i = 0; i < list.length; i++) { + final value = list[i]; + bytesCount += + CReactionSchema.estimateSize(value, offsets, allOffsets); + } + } + } + } + { + final value = object.requestId; + if (value != null) { + bytesCount += 3 + value.length * 3; + } + } + bytesCount += 3 + object.rootId.length * 3; + { + final value = object.scheduledInfo; + if (value != null) { + bytesCount += 3 + + CScheduledInfoSchema.estimateSize( + value, allOffsets[CScheduledInfo]!, allOffsets); + } + } + { + final value = object.sender; + if (value != null) { + bytesCount += 3 + + CSenderSchema.estimateSize(value, allOffsets[CSender]!, allOffsets); + } + } + { + final value = object.threadInfo; + if (value != null) { + bytesCount += 3 + + CThreadInfoSchema.estimateSize( + value, allOffsets[CThreadInfo]!, allOffsets); + } + } + { + final list = object.thumbnails; + if (list != null) { + bytesCount += 3 + list.length * 3; + { + final offsets = allOffsets[CThumbnail]!; + for (var i = 0; i < list.length; i++) { + final value = list[i]; + bytesCount += + CThumbnailSchema.estimateSize(value, offsets, allOffsets); + } + } + } + } + { + final value = object.type; + if (value != null) { + bytesCount += 3 + value.length * 3; + } + } + bytesCount += 3 + object.url.length * 3; + return bytesCount; +} + +void _cFileMessageSerialize( + CFileMessage object, + IsarWriter writer, + List offsets, + Map> allOffsets, +) { + writer.writeObjectList( + offsets[0], + allOffsets, + CMessageMetaArraySchema.serialize, + object.allMetaArrays, + ); + writer.writeByte(offsets[1], object.channelType.index); + writer.writeString(offsets[2], object.channelUrl); + writer.writeLong(offsets[3], object.createdAt); + writer.writeString(offsets[4], object.customType); + writer.writeString(offsets[5], object.data); + writer.writeLong(offsets[6], object.errorCode); + writer.writeString(offsets[7], object.extendedMessage); + writer.writeBool(offsets[8], object.isOperatorMessage); + writer.writeBool(offsets[9], object.isReplyToChannel); + writer.writeBool(offsets[10], object.isSilent); + writer.writeByte(offsets[11], object.mentionType.index); + writer.writeStringList(offsets[12], object.mentionedUsers); + writer.writeString(offsets[13], object.message); + writer.writeObject( + offsets[14], + allOffsets, + CFileMessageCreateParamsSchema.serialize, + object.messageCreateParams, + ); + writer.writeLong(offsets[15], object.messageId); + writer.writeLong(offsets[16], object.messageSurvivalSeconds); + writer.writeByte(offsets[17], object.messageType.index); + writer.writeString(offsets[18], object.name); + writer.writeObject( + offsets[19], + allOffsets, + COGMetaDataSchema.serialize, + object.ogMetaData, + ); + writer.writeLong(offsets[20], object.parentMessageId); + writer.writeString(offsets[21], object.parentMessageRootId); + writer.writeByte(offsets[22], object.parentMessageType.index); + writer.writeObjectList( + offsets[23], + allOffsets, + CReactionSchema.serialize, + object.reactions, + ); + writer.writeString(offsets[24], object.requestId); + writer.writeBool(offsets[25], object.requireAuth); + writer.writeString(offsets[26], object.rootId); + writer.writeObject( + offsets[27], + allOffsets, + CScheduledInfoSchema.serialize, + object.scheduledInfo, + ); + writer.writeObject( + offsets[28], + allOffsets, + CSenderSchema.serialize, + object.sender, + ); + writer.writeByte(offsets[29], object.sendingStatus.index); + writer.writeLong(offsets[30], object.size); + writer.writeObject( + offsets[31], + allOffsets, + CThreadInfoSchema.serialize, + object.threadInfo, + ); + writer.writeObjectList( + offsets[32], + allOffsets, + CThumbnailSchema.serialize, + object.thumbnails, + ); + writer.writeString(offsets[33], object.type); + writer.writeLong(offsets[34], object.updatedAt); + writer.writeString(offsets[35], object.url); +} + +CFileMessage _cFileMessageDeserialize( + Id id, + IsarReader reader, + List offsets, + Map> allOffsets, +) { + final object = CFileMessage(); + object.allMetaArrays = reader.readObjectList( + offsets[0], + CMessageMetaArraySchema.deserialize, + allOffsets, + CMessageMetaArray(), + ); + object.channelType = + _CFileMessagechannelTypeValueEnumMap[reader.readByteOrNull(offsets[1])] ?? + ChannelType.group; + object.channelUrl = reader.readString(offsets[2]); + object.createdAt = reader.readLong(offsets[3]); + object.customType = reader.readStringOrNull(offsets[4]); + object.data = reader.readStringOrNull(offsets[5]); + object.errorCode = reader.readLongOrNull(offsets[6]); + object.extendedMessage = reader.readString(offsets[7]); + object.id = id; + object.isOperatorMessage = reader.readBool(offsets[8]); + object.isReplyToChannel = reader.readBool(offsets[9]); + object.isSilent = reader.readBool(offsets[10]); + object.mentionType = _CFileMessagementionTypeValueEnumMap[ + reader.readByteOrNull(offsets[11])] ?? + MentionType.users; + object.mentionedUsers = reader.readStringList(offsets[12]) ?? []; + object.message = reader.readString(offsets[13]); + object.messageCreateParams = + reader.readObjectOrNull( + offsets[14], + CFileMessageCreateParamsSchema.deserialize, + allOffsets, + ); + object.messageId = reader.readLong(offsets[15]); + object.messageSurvivalSeconds = reader.readLongOrNull(offsets[16]); + object.messageType = _CFileMessagemessageTypeValueEnumMap[ + reader.readByteOrNull(offsets[17])] ?? + MessageType.user; + object.name = reader.readStringOrNull(offsets[18]); + object.ogMetaData = reader.readObjectOrNull( + offsets[19], + COGMetaDataSchema.deserialize, + allOffsets, + ); + object.parentMessageId = reader.readLongOrNull(offsets[20]); + object.parentMessageRootId = reader.readStringOrNull(offsets[21]); + object.parentMessageType = _CFileMessageparentMessageTypeValueEnumMap[ + reader.readByteOrNull(offsets[22])] ?? + MessageType.user; + object.reactions = reader.readObjectList( + offsets[23], + CReactionSchema.deserialize, + allOffsets, + CReaction(), + ); + object.requestId = reader.readStringOrNull(offsets[24]); + object.requireAuth = reader.readBool(offsets[25]); + object.rootId = reader.readString(offsets[26]); + object.scheduledInfo = reader.readObjectOrNull( + offsets[27], + CScheduledInfoSchema.deserialize, + allOffsets, + ); + object.sender = reader.readObjectOrNull( + offsets[28], + CSenderSchema.deserialize, + allOffsets, + ); + object.sendingStatus = _CFileMessagesendingStatusValueEnumMap[ + reader.readByteOrNull(offsets[29])] ?? + SendingStatus.none; + object.size = reader.readLongOrNull(offsets[30]); + object.threadInfo = reader.readObjectOrNull( + offsets[31], + CThreadInfoSchema.deserialize, + allOffsets, + ); + object.thumbnails = reader.readObjectList( + offsets[32], + CThumbnailSchema.deserialize, + allOffsets, + CThumbnail(), + ); + object.type = reader.readStringOrNull(offsets[33]); + object.updatedAt = reader.readLong(offsets[34]); + object.url = reader.readString(offsets[35]); + return object; +} + +P _cFileMessageDeserializeProp

( + IsarReader reader, + int propertyId, + int offset, + Map> allOffsets, +) { + switch (propertyId) { + case 0: + return (reader.readObjectList( + offset, + CMessageMetaArraySchema.deserialize, + allOffsets, + CMessageMetaArray(), + )) as P; + case 1: + return (_CFileMessagechannelTypeValueEnumMap[ + reader.readByteOrNull(offset)] ?? + ChannelType.group) as P; + case 2: + return (reader.readString(offset)) as P; + case 3: + return (reader.readLong(offset)) as P; + case 4: + return (reader.readStringOrNull(offset)) as P; + case 5: + return (reader.readStringOrNull(offset)) as P; + case 6: + return (reader.readLongOrNull(offset)) as P; + case 7: + return (reader.readString(offset)) as P; + case 8: + return (reader.readBool(offset)) as P; + case 9: + return (reader.readBool(offset)) as P; + case 10: + return (reader.readBool(offset)) as P; + case 11: + return (_CFileMessagementionTypeValueEnumMap[ + reader.readByteOrNull(offset)] ?? + MentionType.users) as P; + case 12: + return (reader.readStringList(offset) ?? []) as P; + case 13: + return (reader.readString(offset)) as P; + case 14: + return (reader.readObjectOrNull( + offset, + CFileMessageCreateParamsSchema.deserialize, + allOffsets, + )) as P; + case 15: + return (reader.readLong(offset)) as P; + case 16: + return (reader.readLongOrNull(offset)) as P; + case 17: + return (_CFileMessagemessageTypeValueEnumMap[ + reader.readByteOrNull(offset)] ?? + MessageType.user) as P; + case 18: + return (reader.readStringOrNull(offset)) as P; + case 19: + return (reader.readObjectOrNull( + offset, + COGMetaDataSchema.deserialize, + allOffsets, + )) as P; + case 20: + return (reader.readLongOrNull(offset)) as P; + case 21: + return (reader.readStringOrNull(offset)) as P; + case 22: + return (_CFileMessageparentMessageTypeValueEnumMap[ + reader.readByteOrNull(offset)] ?? + MessageType.user) as P; + case 23: + return (reader.readObjectList( + offset, + CReactionSchema.deserialize, + allOffsets, + CReaction(), + )) as P; + case 24: + return (reader.readStringOrNull(offset)) as P; + case 25: + return (reader.readBool(offset)) as P; + case 26: + return (reader.readString(offset)) as P; + case 27: + return (reader.readObjectOrNull( + offset, + CScheduledInfoSchema.deserialize, + allOffsets, + )) as P; + case 28: + return (reader.readObjectOrNull( + offset, + CSenderSchema.deserialize, + allOffsets, + )) as P; + case 29: + return (_CFileMessagesendingStatusValueEnumMap[ + reader.readByteOrNull(offset)] ?? + SendingStatus.none) as P; + case 30: + return (reader.readLongOrNull(offset)) as P; + case 31: + return (reader.readObjectOrNull( + offset, + CThreadInfoSchema.deserialize, + allOffsets, + )) as P; + case 32: + return (reader.readObjectList( + offset, + CThumbnailSchema.deserialize, + allOffsets, + CThumbnail(), + )) as P; + case 33: + return (reader.readStringOrNull(offset)) as P; + case 34: + return (reader.readLong(offset)) as P; + case 35: + return (reader.readString(offset)) as P; + default: + throw IsarError('Unknown property with id $propertyId'); + } +} + +const _CFileMessagechannelTypeEnumValueMap = { + 'group': 0, + 'open': 1, + 'feed': 2, +}; +const _CFileMessagechannelTypeValueEnumMap = { + 0: ChannelType.group, + 1: ChannelType.open, + 2: ChannelType.feed, +}; +const _CFileMessagementionTypeEnumValueMap = { + 'users': 0, + 'channel': 1, +}; +const _CFileMessagementionTypeValueEnumMap = { + 0: MentionType.users, + 1: MentionType.channel, +}; +const _CFileMessagemessageTypeEnumValueMap = { + 'user': 0, + 'file': 1, + 'admin': 2, + 'notification': 3, +}; +const _CFileMessagemessageTypeValueEnumMap = { + 0: MessageType.user, + 1: MessageType.file, + 2: MessageType.admin, + 3: MessageType.notification, +}; +const _CFileMessageparentMessageTypeEnumValueMap = { + 'user': 0, + 'file': 1, + 'admin': 2, + 'notification': 3, +}; +const _CFileMessageparentMessageTypeValueEnumMap = { + 0: MessageType.user, + 1: MessageType.file, + 2: MessageType.admin, + 3: MessageType.notification, +}; +const _CFileMessagesendingStatusEnumValueMap = { + 'none': 0, + 'pending': 1, + 'failed': 2, + 'succeeded': 3, + 'canceled': 4, +}; +const _CFileMessagesendingStatusValueEnumMap = { + 0: SendingStatus.none, + 1: SendingStatus.pending, + 2: SendingStatus.failed, + 3: SendingStatus.succeeded, + 4: SendingStatus.canceled, +}; + +Id _cFileMessageGetId(CFileMessage object) { + return object.id; +} + +List> _cFileMessageGetLinks(CFileMessage object) { + return []; +} + +void _cFileMessageAttach( + IsarCollection col, Id id, CFileMessage object) { + object.id = id; +} + +extension CFileMessageByIndex on IsarCollection { + Future getByRootId(String rootId) { + return getByIndex(r'rootId', [rootId]); + } + + CFileMessage? getByRootIdSync(String rootId) { + return getByIndexSync(r'rootId', [rootId]); + } + + Future deleteByRootId(String rootId) { + return deleteByIndex(r'rootId', [rootId]); + } + + bool deleteByRootIdSync(String rootId) { + return deleteByIndexSync(r'rootId', [rootId]); + } + + Future> getAllByRootId(List rootIdValues) { + final values = rootIdValues.map((e) => [e]).toList(); + return getAllByIndex(r'rootId', values); + } + + List getAllByRootIdSync(List rootIdValues) { + final values = rootIdValues.map((e) => [e]).toList(); + return getAllByIndexSync(r'rootId', values); + } + + Future deleteAllByRootId(List rootIdValues) { + final values = rootIdValues.map((e) => [e]).toList(); + return deleteAllByIndex(r'rootId', values); + } + + int deleteAllByRootIdSync(List rootIdValues) { + final values = rootIdValues.map((e) => [e]).toList(); + return deleteAllByIndexSync(r'rootId', values); + } + + Future putByRootId(CFileMessage object) { + return putByIndex(r'rootId', object); + } + + Id putByRootIdSync(CFileMessage object, {bool saveLinks = true}) { + return putByIndexSync(r'rootId', object, saveLinks: saveLinks); + } + + Future> putAllByRootId(List objects) { + return putAllByIndex(r'rootId', objects); + } + + List putAllByRootIdSync(List objects, + {bool saveLinks = true}) { + return putAllByIndexSync(r'rootId', objects, saveLinks: saveLinks); + } +} + +extension CFileMessageQueryWhereSort + on QueryBuilder { + QueryBuilder anyId() { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(const IdWhereClause.any()); + }); + } +} + +extension CFileMessageQueryWhere + on QueryBuilder { + QueryBuilder idEqualTo(Id id) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IdWhereClause.between( + lower: id, + upper: id, + )); + }); + } + + QueryBuilder idNotEqualTo( + Id id) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause( + IdWhereClause.lessThan(upper: id, includeUpper: false), + ) + .addWhereClause( + IdWhereClause.greaterThan(lower: id, includeLower: false), + ); + } else { + return query + .addWhereClause( + IdWhereClause.greaterThan(lower: id, includeLower: false), + ) + .addWhereClause( + IdWhereClause.lessThan(upper: id, includeUpper: false), + ); + } + }); + } + + QueryBuilder idGreaterThan( + Id id, + {bool include = false}) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause( + IdWhereClause.greaterThan(lower: id, includeLower: include), + ); + }); + } + + QueryBuilder idLessThan(Id id, + {bool include = false}) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause( + IdWhereClause.lessThan(upper: id, includeUpper: include), + ); + }); + } + + QueryBuilder idBetween( + Id lowerId, + Id upperId, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IdWhereClause.between( + lower: lowerId, + includeLower: includeLower, + upper: upperId, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder rootIdEqualTo( + String rootId) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.equalTo( + indexName: r'rootId', + value: [rootId], + )); + }); + } + + QueryBuilder rootIdNotEqualTo( + String rootId) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'rootId', + lower: [], + upper: [rootId], + includeUpper: false, + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'rootId', + lower: [rootId], + includeLower: false, + upper: [], + )); + } else { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'rootId', + lower: [rootId], + includeLower: false, + upper: [], + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'rootId', + lower: [], + upper: [rootId], + includeUpper: false, + )); + } + }); + } + + QueryBuilder + messageTypeEqualToAnyRootId(MessageType messageType) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.equalTo( + indexName: r'messageType_rootId', + value: [messageType], + )); + }); + } + + QueryBuilder + messageTypeNotEqualToAnyRootId(MessageType messageType) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'messageType_rootId', + lower: [], + upper: [messageType], + includeUpper: false, + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'messageType_rootId', + lower: [messageType], + includeLower: false, + upper: [], + )); + } else { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'messageType_rootId', + lower: [messageType], + includeLower: false, + upper: [], + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'messageType_rootId', + lower: [], + upper: [messageType], + includeUpper: false, + )); + } + }); + } + + QueryBuilder + messageTypeGreaterThanAnyRootId( + MessageType messageType, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.between( + indexName: r'messageType_rootId', + lower: [messageType], + includeLower: include, + upper: [], + )); + }); + } + + QueryBuilder + messageTypeLessThanAnyRootId( + MessageType messageType, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.between( + indexName: r'messageType_rootId', + lower: [], + upper: [messageType], + includeUpper: include, + )); + }); + } + + QueryBuilder + messageTypeBetweenAnyRootId( + MessageType lowerMessageType, + MessageType upperMessageType, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.between( + indexName: r'messageType_rootId', + lower: [lowerMessageType], + includeLower: includeLower, + upper: [upperMessageType], + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + messageTypeRootIdEqualTo(MessageType messageType, String rootId) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.equalTo( + indexName: r'messageType_rootId', + value: [messageType, rootId], + )); + }); + } + + QueryBuilder + messageTypeEqualToRootIdNotEqualTo( + MessageType messageType, String rootId) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'messageType_rootId', + lower: [messageType], + upper: [messageType, rootId], + includeUpper: false, + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'messageType_rootId', + lower: [messageType, rootId], + includeLower: false, + upper: [messageType], + )); + } else { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'messageType_rootId', + lower: [messageType, rootId], + includeLower: false, + upper: [messageType], + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'messageType_rootId', + lower: [messageType], + upper: [messageType, rootId], + includeUpper: false, + )); + } + }); + } + + QueryBuilder channelUrlEqualTo( + String channelUrl) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.equalTo( + indexName: r'channelUrl', + value: [channelUrl], + )); + }); + } + + QueryBuilder + channelUrlNotEqualTo(String channelUrl) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'channelUrl', + lower: [], + upper: [channelUrl], + includeUpper: false, + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'channelUrl', + lower: [channelUrl], + includeLower: false, + upper: [], + )); + } else { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'channelUrl', + lower: [channelUrl], + includeLower: false, + upper: [], + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'channelUrl', + lower: [], + upper: [channelUrl], + includeUpper: false, + )); + } + }); + } + + QueryBuilder + channelTypeEqualToAnyChannelUrl(ChannelType channelType) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.equalTo( + indexName: r'channelType_channelUrl', + value: [channelType], + )); + }); + } + + QueryBuilder + channelTypeNotEqualToAnyChannelUrl(ChannelType channelType) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'channelType_channelUrl', + lower: [], + upper: [channelType], + includeUpper: false, + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'channelType_channelUrl', + lower: [channelType], + includeLower: false, + upper: [], + )); + } else { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'channelType_channelUrl', + lower: [channelType], + includeLower: false, + upper: [], + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'channelType_channelUrl', + lower: [], + upper: [channelType], + includeUpper: false, + )); + } + }); + } + + QueryBuilder + channelTypeGreaterThanAnyChannelUrl( + ChannelType channelType, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.between( + indexName: r'channelType_channelUrl', + lower: [channelType], + includeLower: include, + upper: [], + )); + }); + } + + QueryBuilder + channelTypeLessThanAnyChannelUrl( + ChannelType channelType, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.between( + indexName: r'channelType_channelUrl', + lower: [], + upper: [channelType], + includeUpper: include, + )); + }); + } + + QueryBuilder + channelTypeBetweenAnyChannelUrl( + ChannelType lowerChannelType, + ChannelType upperChannelType, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.between( + indexName: r'channelType_channelUrl', + lower: [lowerChannelType], + includeLower: includeLower, + upper: [upperChannelType], + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + channelTypeChannelUrlEqualTo(ChannelType channelType, String channelUrl) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.equalTo( + indexName: r'channelType_channelUrl', + value: [channelType, channelUrl], + )); + }); + } + + QueryBuilder + channelTypeEqualToChannelUrlNotEqualTo( + ChannelType channelType, String channelUrl) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'channelType_channelUrl', + lower: [channelType], + upper: [channelType, channelUrl], + includeUpper: false, + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'channelType_channelUrl', + lower: [channelType, channelUrl], + includeLower: false, + upper: [channelType], + )); + } else { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'channelType_channelUrl', + lower: [channelType, channelUrl], + includeLower: false, + upper: [channelType], + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'channelType_channelUrl', + lower: [channelType], + upper: [channelType, channelUrl], + includeUpper: false, + )); + } + }); + } +} + +extension CFileMessageQueryFilter + on QueryBuilder { + QueryBuilder + allMetaArraysIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'allMetaArrays', + )); + }); + } + + QueryBuilder + allMetaArraysIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'allMetaArrays', + )); + }); + } + + QueryBuilder + allMetaArraysLengthEqualTo(int length) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'allMetaArrays', + length, + true, + length, + true, + ); + }); + } + + QueryBuilder + allMetaArraysIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'allMetaArrays', + 0, + true, + 0, + true, + ); + }); + } + + QueryBuilder + allMetaArraysIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'allMetaArrays', + 0, + false, + 999999, + true, + ); + }); + } + + QueryBuilder + allMetaArraysLengthLessThan( + int length, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'allMetaArrays', + 0, + true, + length, + include, + ); + }); + } + + QueryBuilder + allMetaArraysLengthGreaterThan( + int length, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'allMetaArrays', + length, + include, + 999999, + true, + ); + }); + } + + QueryBuilder + allMetaArraysLengthBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'allMetaArrays', + lower, + includeLower, + upper, + includeUpper, + ); + }); + } + + QueryBuilder + channelTypeEqualTo(ChannelType value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'channelType', + value: value, + )); + }); + } + + QueryBuilder + channelTypeGreaterThan( + ChannelType value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'channelType', + value: value, + )); + }); + } + + QueryBuilder + channelTypeLessThan( + ChannelType value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'channelType', + value: value, + )); + }); + } + + QueryBuilder + channelTypeBetween( + ChannelType lower, + ChannelType upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'channelType', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + channelUrlEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'channelUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + channelUrlGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'channelUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + channelUrlLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'channelUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + channelUrlBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'channelUrl', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + channelUrlStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'channelUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + channelUrlEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'channelUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + channelUrlContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'channelUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + channelUrlMatches(String pattern, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'channelUrl', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + channelUrlIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'channelUrl', + value: '', + )); + }); + } + + QueryBuilder + channelUrlIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'channelUrl', + value: '', + )); + }); + } + + QueryBuilder + createdAtEqualTo(int value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'createdAt', + value: value, + )); + }); + } + + QueryBuilder + createdAtGreaterThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'createdAt', + value: value, + )); + }); + } + + QueryBuilder + createdAtLessThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'createdAt', + value: value, + )); + }); + } + + QueryBuilder + createdAtBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'createdAt', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + customTypeIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'customType', + )); + }); + } + + QueryBuilder + customTypeIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'customType', + )); + }); + } + + QueryBuilder + customTypeEqualTo( + String? value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'customType', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + customTypeGreaterThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'customType', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + customTypeLessThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'customType', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + customTypeBetween( + String? lower, + String? upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'customType', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + customTypeStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'customType', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + customTypeEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'customType', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + customTypeContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'customType', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + customTypeMatches(String pattern, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'customType', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + customTypeIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'customType', + value: '', + )); + }); + } + + QueryBuilder + customTypeIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'customType', + value: '', + )); + }); + } + + QueryBuilder dataIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'data', + )); + }); + } + + QueryBuilder + dataIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'data', + )); + }); + } + + QueryBuilder dataEqualTo( + String? value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'data', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + dataGreaterThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'data', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder dataLessThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'data', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder dataBetween( + String? lower, + String? upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'data', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + dataStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'data', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder dataEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'data', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder dataContains( + String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'data', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder dataMatches( + String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'data', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + dataIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'data', + value: '', + )); + }); + } + + QueryBuilder + dataIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'data', + value: '', + )); + }); + } + + QueryBuilder + errorCodeIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'errorCode', + )); + }); + } + + QueryBuilder + errorCodeIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'errorCode', + )); + }); + } + + QueryBuilder + errorCodeEqualTo(int? value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'errorCode', + value: value, + )); + }); + } + + QueryBuilder + errorCodeGreaterThan( + int? value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'errorCode', + value: value, + )); + }); + } + + QueryBuilder + errorCodeLessThan( + int? value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'errorCode', + value: value, + )); + }); + } + + QueryBuilder + errorCodeBetween( + int? lower, + int? upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'errorCode', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + extendedMessageEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'extendedMessage', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + extendedMessageGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'extendedMessage', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + extendedMessageLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'extendedMessage', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + extendedMessageBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'extendedMessage', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + extendedMessageStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'extendedMessage', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + extendedMessageEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'extendedMessage', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + extendedMessageContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'extendedMessage', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + extendedMessageMatches(String pattern, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'extendedMessage', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + extendedMessageIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'extendedMessage', + value: '', + )); + }); + } + + QueryBuilder + extendedMessageIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'extendedMessage', + value: '', + )); + }); + } + + QueryBuilder idEqualTo( + Id value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'id', + value: value, + )); + }); + } + + QueryBuilder idGreaterThan( + Id value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'id', + value: value, + )); + }); + } + + QueryBuilder idLessThan( + Id value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'id', + value: value, + )); + }); + } + + QueryBuilder idBetween( + Id lower, + Id upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'id', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + isOperatorMessageEqualTo(bool value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'isOperatorMessage', + value: value, + )); + }); + } + + QueryBuilder + isReplyToChannelEqualTo(bool value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'isReplyToChannel', + value: value, + )); + }); + } + + QueryBuilder + isSilentEqualTo(bool value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'isSilent', + value: value, + )); + }); + } + + QueryBuilder + mentionTypeEqualTo(MentionType value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'mentionType', + value: value, + )); + }); + } + + QueryBuilder + mentionTypeGreaterThan( + MentionType value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'mentionType', + value: value, + )); + }); + } + + QueryBuilder + mentionTypeLessThan( + MentionType value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'mentionType', + value: value, + )); + }); + } + + QueryBuilder + mentionTypeBetween( + MentionType lower, + MentionType upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'mentionType', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + mentionedUsersElementEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'mentionedUsers', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + mentionedUsersElementGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'mentionedUsers', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + mentionedUsersElementLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'mentionedUsers', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + mentionedUsersElementBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'mentionedUsers', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + mentionedUsersElementStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'mentionedUsers', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + mentionedUsersElementEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'mentionedUsers', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + mentionedUsersElementContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'mentionedUsers', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + mentionedUsersElementMatches(String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'mentionedUsers', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + mentionedUsersElementIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'mentionedUsers', + value: '', + )); + }); + } + + QueryBuilder + mentionedUsersElementIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'mentionedUsers', + value: '', + )); + }); + } + + QueryBuilder + mentionedUsersLengthEqualTo(int length) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'mentionedUsers', + length, + true, + length, + true, + ); + }); + } + + QueryBuilder + mentionedUsersIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'mentionedUsers', + 0, + true, + 0, + true, + ); + }); + } + + QueryBuilder + mentionedUsersIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'mentionedUsers', + 0, + false, + 999999, + true, + ); + }); + } + + QueryBuilder + mentionedUsersLengthLessThan( + int length, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'mentionedUsers', + 0, + true, + length, + include, + ); + }); + } + + QueryBuilder + mentionedUsersLengthGreaterThan( + int length, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'mentionedUsers', + length, + include, + 999999, + true, + ); + }); + } + + QueryBuilder + mentionedUsersLengthBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'mentionedUsers', + lower, + includeLower, + upper, + includeUpper, + ); + }); + } + + QueryBuilder + messageEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'message', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + messageGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'message', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + messageLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'message', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + messageBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'message', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + messageStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'message', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + messageEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'message', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + messageContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'message', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + messageMatches(String pattern, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'message', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + messageIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'message', + value: '', + )); + }); + } + + QueryBuilder + messageIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'message', + value: '', + )); + }); + } + + QueryBuilder + messageCreateParamsIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'messageCreateParams', + )); + }); + } + + QueryBuilder + messageCreateParamsIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'messageCreateParams', + )); + }); + } + + QueryBuilder + messageIdEqualTo(int value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'messageId', + value: value, + )); + }); + } + + QueryBuilder + messageIdGreaterThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'messageId', + value: value, + )); + }); + } + + QueryBuilder + messageIdLessThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'messageId', + value: value, + )); + }); + } + + QueryBuilder + messageIdBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'messageId', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + messageSurvivalSecondsIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'messageSurvivalSeconds', + )); + }); + } + + QueryBuilder + messageSurvivalSecondsIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'messageSurvivalSeconds', + )); + }); + } + + QueryBuilder + messageSurvivalSecondsEqualTo(int? value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'messageSurvivalSeconds', + value: value, + )); + }); + } + + QueryBuilder + messageSurvivalSecondsGreaterThan( + int? value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'messageSurvivalSeconds', + value: value, + )); + }); + } + + QueryBuilder + messageSurvivalSecondsLessThan( + int? value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'messageSurvivalSeconds', + value: value, + )); + }); + } + + QueryBuilder + messageSurvivalSecondsBetween( + int? lower, + int? upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'messageSurvivalSeconds', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + messageTypeEqualTo(MessageType value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'messageType', + value: value, + )); + }); + } + + QueryBuilder + messageTypeGreaterThan( + MessageType value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'messageType', + value: value, + )); + }); + } + + QueryBuilder + messageTypeLessThan( + MessageType value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'messageType', + value: value, + )); + }); + } + + QueryBuilder + messageTypeBetween( + MessageType lower, + MessageType upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'messageType', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder nameIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'name', + )); + }); + } + + QueryBuilder + nameIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'name', + )); + }); + } + + QueryBuilder nameEqualTo( + String? value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'name', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + nameGreaterThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'name', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder nameLessThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'name', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder nameBetween( + String? lower, + String? upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'name', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + nameStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'name', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder nameEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'name', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder nameContains( + String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'name', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder nameMatches( + String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'name', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + nameIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'name', + value: '', + )); + }); + } + + QueryBuilder + nameIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'name', + value: '', + )); + }); + } + + QueryBuilder + ogMetaDataIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'ogMetaData', + )); + }); + } + + QueryBuilder + ogMetaDataIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'ogMetaData', + )); + }); + } + + QueryBuilder + parentMessageIdIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'parentMessageId', + )); + }); + } + + QueryBuilder + parentMessageIdIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'parentMessageId', + )); + }); + } + + QueryBuilder + parentMessageIdEqualTo(int? value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'parentMessageId', + value: value, + )); + }); + } + + QueryBuilder + parentMessageIdGreaterThan( + int? value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'parentMessageId', + value: value, + )); + }); + } + + QueryBuilder + parentMessageIdLessThan( + int? value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'parentMessageId', + value: value, + )); + }); + } + + QueryBuilder + parentMessageIdBetween( + int? lower, + int? upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'parentMessageId', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + parentMessageRootIdIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'parentMessageRootId', + )); + }); + } + + QueryBuilder + parentMessageRootIdIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'parentMessageRootId', + )); + }); + } + + QueryBuilder + parentMessageRootIdEqualTo( + String? value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'parentMessageRootId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + parentMessageRootIdGreaterThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'parentMessageRootId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + parentMessageRootIdLessThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'parentMessageRootId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + parentMessageRootIdBetween( + String? lower, + String? upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'parentMessageRootId', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + parentMessageRootIdStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'parentMessageRootId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + parentMessageRootIdEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'parentMessageRootId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + parentMessageRootIdContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'parentMessageRootId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + parentMessageRootIdMatches(String pattern, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'parentMessageRootId', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + parentMessageRootIdIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'parentMessageRootId', + value: '', + )); + }); + } + + QueryBuilder + parentMessageRootIdIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'parentMessageRootId', + value: '', + )); + }); + } + + QueryBuilder + parentMessageTypeEqualTo(MessageType value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'parentMessageType', + value: value, + )); + }); + } + + QueryBuilder + parentMessageTypeGreaterThan( + MessageType value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'parentMessageType', + value: value, + )); + }); + } + + QueryBuilder + parentMessageTypeLessThan( + MessageType value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'parentMessageType', + value: value, + )); + }); + } + + QueryBuilder + parentMessageTypeBetween( + MessageType lower, + MessageType upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'parentMessageType', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + reactionsIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'reactions', + )); + }); + } + + QueryBuilder + reactionsIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'reactions', + )); + }); + } + + QueryBuilder + reactionsLengthEqualTo(int length) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'reactions', + length, + true, + length, + true, + ); + }); + } + + QueryBuilder + reactionsIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'reactions', + 0, + true, + 0, + true, + ); + }); + } + + QueryBuilder + reactionsIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'reactions', + 0, + false, + 999999, + true, + ); + }); + } + + QueryBuilder + reactionsLengthLessThan( + int length, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'reactions', + 0, + true, + length, + include, + ); + }); + } + + QueryBuilder + reactionsLengthGreaterThan( + int length, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'reactions', + length, + include, + 999999, + true, + ); + }); + } + + QueryBuilder + reactionsLengthBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'reactions', + lower, + includeLower, + upper, + includeUpper, + ); + }); + } + + QueryBuilder + requestIdIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'requestId', + )); + }); + } + + QueryBuilder + requestIdIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'requestId', + )); + }); + } + + QueryBuilder + requestIdEqualTo( + String? value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'requestId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + requestIdGreaterThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'requestId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + requestIdLessThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'requestId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + requestIdBetween( + String? lower, + String? upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'requestId', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + requestIdStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'requestId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + requestIdEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'requestId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + requestIdContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'requestId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + requestIdMatches(String pattern, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'requestId', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + requestIdIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'requestId', + value: '', + )); + }); + } + + QueryBuilder + requestIdIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'requestId', + value: '', + )); + }); + } + + QueryBuilder + requireAuthEqualTo(bool value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'requireAuth', + value: value, + )); + }); + } + + QueryBuilder rootIdEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'rootId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + rootIdGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'rootId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + rootIdLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'rootId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder rootIdBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'rootId', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + rootIdStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'rootId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + rootIdEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'rootId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + rootIdContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'rootId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder rootIdMatches( + String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'rootId', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + rootIdIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'rootId', + value: '', + )); + }); + } + + QueryBuilder + rootIdIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'rootId', + value: '', + )); + }); + } + + QueryBuilder + scheduledInfoIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'scheduledInfo', + )); + }); + } + + QueryBuilder + scheduledInfoIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'scheduledInfo', + )); + }); + } + + QueryBuilder + senderIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'sender', + )); + }); + } + + QueryBuilder + senderIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'sender', + )); + }); + } + + QueryBuilder + sendingStatusEqualTo(SendingStatus value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'sendingStatus', + value: value, + )); + }); + } + + QueryBuilder + sendingStatusGreaterThan( + SendingStatus value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'sendingStatus', + value: value, + )); + }); + } + + QueryBuilder + sendingStatusLessThan( + SendingStatus value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'sendingStatus', + value: value, + )); + }); + } + + QueryBuilder + sendingStatusBetween( + SendingStatus lower, + SendingStatus upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'sendingStatus', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder sizeIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'size', + )); + }); + } + + QueryBuilder + sizeIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'size', + )); + }); + } + + QueryBuilder sizeEqualTo( + int? value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'size', + value: value, + )); + }); + } + + QueryBuilder + sizeGreaterThan( + int? value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'size', + value: value, + )); + }); + } + + QueryBuilder sizeLessThan( + int? value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'size', + value: value, + )); + }); + } + + QueryBuilder sizeBetween( + int? lower, + int? upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'size', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + threadInfoIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'threadInfo', + )); + }); + } + + QueryBuilder + threadInfoIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'threadInfo', + )); + }); + } + + QueryBuilder + thumbnailsIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'thumbnails', + )); + }); + } + + QueryBuilder + thumbnailsIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'thumbnails', + )); + }); + } + + QueryBuilder + thumbnailsLengthEqualTo(int length) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'thumbnails', + length, + true, + length, + true, + ); + }); + } + + QueryBuilder + thumbnailsIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'thumbnails', + 0, + true, + 0, + true, + ); + }); + } + + QueryBuilder + thumbnailsIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'thumbnails', + 0, + false, + 999999, + true, + ); + }); + } + + QueryBuilder + thumbnailsLengthLessThan( + int length, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'thumbnails', + 0, + true, + length, + include, + ); + }); + } + + QueryBuilder + thumbnailsLengthGreaterThan( + int length, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'thumbnails', + length, + include, + 999999, + true, + ); + }); + } + + QueryBuilder + thumbnailsLengthBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'thumbnails', + lower, + includeLower, + upper, + includeUpper, + ); + }); + } + + QueryBuilder typeIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'type', + )); + }); + } + + QueryBuilder + typeIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'type', + )); + }); + } + + QueryBuilder typeEqualTo( + String? value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'type', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + typeGreaterThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'type', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder typeLessThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'type', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder typeBetween( + String? lower, + String? upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'type', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + typeStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'type', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder typeEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'type', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder typeContains( + String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'type', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder typeMatches( + String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'type', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + typeIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'type', + value: '', + )); + }); + } + + QueryBuilder + typeIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'type', + value: '', + )); + }); + } + + QueryBuilder + updatedAtEqualTo(int value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'updatedAt', + value: value, + )); + }); + } + + QueryBuilder + updatedAtGreaterThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'updatedAt', + value: value, + )); + }); + } + + QueryBuilder + updatedAtLessThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'updatedAt', + value: value, + )); + }); + } + + QueryBuilder + updatedAtBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'updatedAt', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder urlEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'url', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + urlGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'url', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder urlLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'url', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder urlBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'url', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder urlStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'url', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder urlEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'url', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder urlContains( + String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'url', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder urlMatches( + String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'url', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder urlIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'url', + value: '', + )); + }); + } + + QueryBuilder + urlIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'url', + value: '', + )); + }); + } +} + +extension CFileMessageQueryObject + on QueryBuilder { + QueryBuilder + allMetaArraysElement(FilterQuery q) { + return QueryBuilder.apply(this, (query) { + return query.object(q, r'allMetaArrays'); + }); + } + + QueryBuilder + messageCreateParams(FilterQuery q) { + return QueryBuilder.apply(this, (query) { + return query.object(q, r'messageCreateParams'); + }); + } + + QueryBuilder ogMetaData( + FilterQuery q) { + return QueryBuilder.apply(this, (query) { + return query.object(q, r'ogMetaData'); + }); + } + + QueryBuilder + reactionsElement(FilterQuery q) { + return QueryBuilder.apply(this, (query) { + return query.object(q, r'reactions'); + }); + } + + QueryBuilder scheduledInfo( + FilterQuery q) { + return QueryBuilder.apply(this, (query) { + return query.object(q, r'scheduledInfo'); + }); + } + + QueryBuilder sender( + FilterQuery q) { + return QueryBuilder.apply(this, (query) { + return query.object(q, r'sender'); + }); + } + + QueryBuilder threadInfo( + FilterQuery q) { + return QueryBuilder.apply(this, (query) { + return query.object(q, r'threadInfo'); + }); + } + + QueryBuilder + thumbnailsElement(FilterQuery q) { + return QueryBuilder.apply(this, (query) { + return query.object(q, r'thumbnails'); + }); + } +} + +extension CFileMessageQueryLinks + on QueryBuilder {} + +extension CFileMessageQuerySortBy + on QueryBuilder { + QueryBuilder sortByChannelType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'channelType', Sort.asc); + }); + } + + QueryBuilder + sortByChannelTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'channelType', Sort.desc); + }); + } + + QueryBuilder sortByChannelUrl() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'channelUrl', Sort.asc); + }); + } + + QueryBuilder + sortByChannelUrlDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'channelUrl', Sort.desc); + }); + } + + QueryBuilder sortByCreatedAt() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'createdAt', Sort.asc); + }); + } + + QueryBuilder sortByCreatedAtDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'createdAt', Sort.desc); + }); + } + + QueryBuilder sortByCustomType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'customType', Sort.asc); + }); + } + + QueryBuilder + sortByCustomTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'customType', Sort.desc); + }); + } + + QueryBuilder sortByData() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'data', Sort.asc); + }); + } + + QueryBuilder sortByDataDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'data', Sort.desc); + }); + } + + QueryBuilder sortByErrorCode() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'errorCode', Sort.asc); + }); + } + + QueryBuilder sortByErrorCodeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'errorCode', Sort.desc); + }); + } + + QueryBuilder + sortByExtendedMessage() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'extendedMessage', Sort.asc); + }); + } + + QueryBuilder + sortByExtendedMessageDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'extendedMessage', Sort.desc); + }); + } + + QueryBuilder + sortByIsOperatorMessage() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isOperatorMessage', Sort.asc); + }); + } + + QueryBuilder + sortByIsOperatorMessageDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isOperatorMessage', Sort.desc); + }); + } + + QueryBuilder + sortByIsReplyToChannel() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isReplyToChannel', Sort.asc); + }); + } + + QueryBuilder + sortByIsReplyToChannelDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isReplyToChannel', Sort.desc); + }); + } + + QueryBuilder sortByIsSilent() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isSilent', Sort.asc); + }); + } + + QueryBuilder sortByIsSilentDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isSilent', Sort.desc); + }); + } + + QueryBuilder sortByMentionType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'mentionType', Sort.asc); + }); + } + + QueryBuilder + sortByMentionTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'mentionType', Sort.desc); + }); + } + + QueryBuilder sortByMessage() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'message', Sort.asc); + }); + } + + QueryBuilder sortByMessageDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'message', Sort.desc); + }); + } + + QueryBuilder sortByMessageId() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'messageId', Sort.asc); + }); + } + + QueryBuilder sortByMessageIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'messageId', Sort.desc); + }); + } + + QueryBuilder + sortByMessageSurvivalSeconds() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'messageSurvivalSeconds', Sort.asc); + }); + } + + QueryBuilder + sortByMessageSurvivalSecondsDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'messageSurvivalSeconds', Sort.desc); + }); + } + + QueryBuilder sortByMessageType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'messageType', Sort.asc); + }); + } + + QueryBuilder + sortByMessageTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'messageType', Sort.desc); + }); + } + + QueryBuilder sortByName() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'name', Sort.asc); + }); + } + + QueryBuilder sortByNameDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'name', Sort.desc); + }); + } + + QueryBuilder + sortByParentMessageId() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'parentMessageId', Sort.asc); + }); + } + + QueryBuilder + sortByParentMessageIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'parentMessageId', Sort.desc); + }); + } + + QueryBuilder + sortByParentMessageRootId() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'parentMessageRootId', Sort.asc); + }); + } + + QueryBuilder + sortByParentMessageRootIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'parentMessageRootId', Sort.desc); + }); + } + + QueryBuilder + sortByParentMessageType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'parentMessageType', Sort.asc); + }); + } + + QueryBuilder + sortByParentMessageTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'parentMessageType', Sort.desc); + }); + } + + QueryBuilder sortByRequestId() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'requestId', Sort.asc); + }); + } + + QueryBuilder sortByRequestIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'requestId', Sort.desc); + }); + } + + QueryBuilder sortByRequireAuth() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'requireAuth', Sort.asc); + }); + } + + QueryBuilder + sortByRequireAuthDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'requireAuth', Sort.desc); + }); + } + + QueryBuilder sortByRootId() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'rootId', Sort.asc); + }); + } + + QueryBuilder sortByRootIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'rootId', Sort.desc); + }); + } + + QueryBuilder sortBySendingStatus() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'sendingStatus', Sort.asc); + }); + } + + QueryBuilder + sortBySendingStatusDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'sendingStatus', Sort.desc); + }); + } + + QueryBuilder sortBySize() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'size', Sort.asc); + }); + } + + QueryBuilder sortBySizeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'size', Sort.desc); + }); + } + + QueryBuilder sortByType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'type', Sort.asc); + }); + } + + QueryBuilder sortByTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'type', Sort.desc); + }); + } + + QueryBuilder sortByUpdatedAt() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'updatedAt', Sort.asc); + }); + } + + QueryBuilder sortByUpdatedAtDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'updatedAt', Sort.desc); + }); + } + + QueryBuilder sortByUrl() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'url', Sort.asc); + }); + } + + QueryBuilder sortByUrlDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'url', Sort.desc); + }); + } +} + +extension CFileMessageQuerySortThenBy + on QueryBuilder { + QueryBuilder thenByChannelType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'channelType', Sort.asc); + }); + } + + QueryBuilder + thenByChannelTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'channelType', Sort.desc); + }); + } + + QueryBuilder thenByChannelUrl() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'channelUrl', Sort.asc); + }); + } + + QueryBuilder + thenByChannelUrlDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'channelUrl', Sort.desc); + }); + } + + QueryBuilder thenByCreatedAt() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'createdAt', Sort.asc); + }); + } + + QueryBuilder thenByCreatedAtDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'createdAt', Sort.desc); + }); + } + + QueryBuilder thenByCustomType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'customType', Sort.asc); + }); + } + + QueryBuilder + thenByCustomTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'customType', Sort.desc); + }); + } + + QueryBuilder thenByData() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'data', Sort.asc); + }); + } + + QueryBuilder thenByDataDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'data', Sort.desc); + }); + } + + QueryBuilder thenByErrorCode() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'errorCode', Sort.asc); + }); + } + + QueryBuilder thenByErrorCodeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'errorCode', Sort.desc); + }); + } + + QueryBuilder + thenByExtendedMessage() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'extendedMessage', Sort.asc); + }); + } + + QueryBuilder + thenByExtendedMessageDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'extendedMessage', Sort.desc); + }); + } + + QueryBuilder thenById() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'id', Sort.asc); + }); + } + + QueryBuilder thenByIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'id', Sort.desc); + }); + } + + QueryBuilder + thenByIsOperatorMessage() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isOperatorMessage', Sort.asc); + }); + } + + QueryBuilder + thenByIsOperatorMessageDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isOperatorMessage', Sort.desc); + }); + } + + QueryBuilder + thenByIsReplyToChannel() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isReplyToChannel', Sort.asc); + }); + } + + QueryBuilder + thenByIsReplyToChannelDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isReplyToChannel', Sort.desc); + }); + } + + QueryBuilder thenByIsSilent() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isSilent', Sort.asc); + }); + } + + QueryBuilder thenByIsSilentDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isSilent', Sort.desc); + }); + } + + QueryBuilder thenByMentionType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'mentionType', Sort.asc); + }); + } + + QueryBuilder + thenByMentionTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'mentionType', Sort.desc); + }); + } + + QueryBuilder thenByMessage() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'message', Sort.asc); + }); + } + + QueryBuilder thenByMessageDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'message', Sort.desc); + }); + } + + QueryBuilder thenByMessageId() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'messageId', Sort.asc); + }); + } + + QueryBuilder thenByMessageIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'messageId', Sort.desc); + }); + } + + QueryBuilder + thenByMessageSurvivalSeconds() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'messageSurvivalSeconds', Sort.asc); + }); + } + + QueryBuilder + thenByMessageSurvivalSecondsDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'messageSurvivalSeconds', Sort.desc); + }); + } + + QueryBuilder thenByMessageType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'messageType', Sort.asc); + }); + } + + QueryBuilder + thenByMessageTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'messageType', Sort.desc); + }); + } + + QueryBuilder thenByName() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'name', Sort.asc); + }); + } + + QueryBuilder thenByNameDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'name', Sort.desc); + }); + } + + QueryBuilder + thenByParentMessageId() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'parentMessageId', Sort.asc); + }); + } + + QueryBuilder + thenByParentMessageIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'parentMessageId', Sort.desc); + }); + } + + QueryBuilder + thenByParentMessageRootId() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'parentMessageRootId', Sort.asc); + }); + } + + QueryBuilder + thenByParentMessageRootIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'parentMessageRootId', Sort.desc); + }); + } + + QueryBuilder + thenByParentMessageType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'parentMessageType', Sort.asc); + }); + } + + QueryBuilder + thenByParentMessageTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'parentMessageType', Sort.desc); + }); + } + + QueryBuilder thenByRequestId() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'requestId', Sort.asc); + }); + } + + QueryBuilder thenByRequestIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'requestId', Sort.desc); + }); + } + + QueryBuilder thenByRequireAuth() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'requireAuth', Sort.asc); + }); + } + + QueryBuilder + thenByRequireAuthDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'requireAuth', Sort.desc); + }); + } + + QueryBuilder thenByRootId() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'rootId', Sort.asc); + }); + } + + QueryBuilder thenByRootIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'rootId', Sort.desc); + }); + } + + QueryBuilder thenBySendingStatus() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'sendingStatus', Sort.asc); + }); + } + + QueryBuilder + thenBySendingStatusDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'sendingStatus', Sort.desc); + }); + } + + QueryBuilder thenBySize() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'size', Sort.asc); + }); + } + + QueryBuilder thenBySizeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'size', Sort.desc); + }); + } + + QueryBuilder thenByType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'type', Sort.asc); + }); + } + + QueryBuilder thenByTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'type', Sort.desc); + }); + } + + QueryBuilder thenByUpdatedAt() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'updatedAt', Sort.asc); + }); + } + + QueryBuilder thenByUpdatedAtDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'updatedAt', Sort.desc); + }); + } + + QueryBuilder thenByUrl() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'url', Sort.asc); + }); + } + + QueryBuilder thenByUrlDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'url', Sort.desc); + }); + } +} + +extension CFileMessageQueryWhereDistinct + on QueryBuilder { + QueryBuilder distinctByChannelType() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'channelType'); + }); + } + + QueryBuilder distinctByChannelUrl( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'channelUrl', caseSensitive: caseSensitive); + }); + } + + QueryBuilder distinctByCreatedAt() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'createdAt'); + }); + } + + QueryBuilder distinctByCustomType( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'customType', caseSensitive: caseSensitive); + }); + } + + QueryBuilder distinctByData( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'data', caseSensitive: caseSensitive); + }); + } + + QueryBuilder distinctByErrorCode() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'errorCode'); + }); + } + + QueryBuilder distinctByExtendedMessage( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'extendedMessage', + caseSensitive: caseSensitive); + }); + } + + QueryBuilder + distinctByIsOperatorMessage() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'isOperatorMessage'); + }); + } + + QueryBuilder + distinctByIsReplyToChannel() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'isReplyToChannel'); + }); + } + + QueryBuilder distinctByIsSilent() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'isSilent'); + }); + } + + QueryBuilder distinctByMentionType() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'mentionType'); + }); + } + + QueryBuilder + distinctByMentionedUsers() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'mentionedUsers'); + }); + } + + QueryBuilder distinctByMessage( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'message', caseSensitive: caseSensitive); + }); + } + + QueryBuilder distinctByMessageId() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'messageId'); + }); + } + + QueryBuilder + distinctByMessageSurvivalSeconds() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'messageSurvivalSeconds'); + }); + } + + QueryBuilder distinctByMessageType() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'messageType'); + }); + } + + QueryBuilder distinctByName( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'name', caseSensitive: caseSensitive); + }); + } + + QueryBuilder + distinctByParentMessageId() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'parentMessageId'); + }); + } + + QueryBuilder + distinctByParentMessageRootId({bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'parentMessageRootId', + caseSensitive: caseSensitive); + }); + } + + QueryBuilder + distinctByParentMessageType() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'parentMessageType'); + }); + } + + QueryBuilder distinctByRequestId( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'requestId', caseSensitive: caseSensitive); + }); + } + + QueryBuilder distinctByRequireAuth() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'requireAuth'); + }); + } + + QueryBuilder distinctByRootId( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'rootId', caseSensitive: caseSensitive); + }); + } + + QueryBuilder + distinctBySendingStatus() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'sendingStatus'); + }); + } + + QueryBuilder distinctBySize() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'size'); + }); + } + + QueryBuilder distinctByType( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'type', caseSensitive: caseSensitive); + }); + } + + QueryBuilder distinctByUpdatedAt() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'updatedAt'); + }); + } + + QueryBuilder distinctByUrl( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'url', caseSensitive: caseSensitive); + }); + } +} + +extension CFileMessageQueryProperty + on QueryBuilder { + QueryBuilder idProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'id'); + }); + } + + QueryBuilder?, QQueryOperations> + allMetaArraysProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'allMetaArrays'); + }); + } + + QueryBuilder + channelTypeProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'channelType'); + }); + } + + QueryBuilder channelUrlProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'channelUrl'); + }); + } + + QueryBuilder createdAtProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'createdAt'); + }); + } + + QueryBuilder customTypeProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'customType'); + }); + } + + QueryBuilder dataProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'data'); + }); + } + + QueryBuilder errorCodeProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'errorCode'); + }); + } + + QueryBuilder + extendedMessageProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'extendedMessage'); + }); + } + + QueryBuilder + isOperatorMessageProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'isOperatorMessage'); + }); + } + + QueryBuilder + isReplyToChannelProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'isReplyToChannel'); + }); + } + + QueryBuilder isSilentProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'isSilent'); + }); + } + + QueryBuilder + mentionTypeProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'mentionType'); + }); + } + + QueryBuilder, QQueryOperations> + mentionedUsersProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'mentionedUsers'); + }); + } + + QueryBuilder messageProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'message'); + }); + } + + QueryBuilder + messageCreateParamsProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'messageCreateParams'); + }); + } + + QueryBuilder messageIdProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'messageId'); + }); + } + + QueryBuilder + messageSurvivalSecondsProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'messageSurvivalSeconds'); + }); + } + + QueryBuilder + messageTypeProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'messageType'); + }); + } + + QueryBuilder nameProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'name'); + }); + } + + QueryBuilder + ogMetaDataProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'ogMetaData'); + }); + } + + QueryBuilder parentMessageIdProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'parentMessageId'); + }); + } + + QueryBuilder + parentMessageRootIdProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'parentMessageRootId'); + }); + } + + QueryBuilder + parentMessageTypeProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'parentMessageType'); + }); + } + + QueryBuilder?, QQueryOperations> + reactionsProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'reactions'); + }); + } + + QueryBuilder requestIdProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'requestId'); + }); + } + + QueryBuilder requireAuthProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'requireAuth'); + }); + } + + QueryBuilder rootIdProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'rootId'); + }); + } + + QueryBuilder + scheduledInfoProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'scheduledInfo'); + }); + } + + QueryBuilder senderProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'sender'); + }); + } + + QueryBuilder + sendingStatusProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'sendingStatus'); + }); + } + + QueryBuilder sizeProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'size'); + }); + } + + QueryBuilder + threadInfoProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'threadInfo'); + }); + } + + QueryBuilder?, QQueryOperations> + thumbnailsProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'thumbnails'); + }); + } + + QueryBuilder typeProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'type'); + }); + } + + QueryBuilder updatedAtProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'updatedAt'); + }); + } + + QueryBuilder urlProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'url'); + }); + } +} + +// ************************************************************************** +// IsarEmbeddedGenerator +// ************************************************************************** + +// coverage:ignore-file +// ignore_for_file: duplicate_ignore, non_constant_identifier_names, constant_identifier_names, invalid_use_of_protected_member, unnecessary_cast, prefer_const_constructors, lines_longer_than_80_chars, require_trailing_commas, inference_failure_on_function_invocation, unnecessary_parenthesis, unnecessary_raw_strings, unnecessary_null_checks, join_return_with_assignment, prefer_final_locals, avoid_js_rounded_ints, avoid_positional_boolean_parameters, always_specify_types + +final CThumbnailSchema = Schema( + name: r'CThumbnail', + id: BigInt.parse('9179756824618085965').toInt(), + properties: { + r'height': PropertySchema( + id: 0, + name: r'height', + type: IsarType.double, + ), + r'plainUrl': PropertySchema( + id: 1, + name: r'plainUrl', + type: IsarType.string, + ), + r'realHeight': PropertySchema( + id: 2, + name: r'realHeight', + type: IsarType.double, + ), + r'realWidth': PropertySchema( + id: 3, + name: r'realWidth', + type: IsarType.double, + ), + r'url': PropertySchema( + id: 4, + name: r'url', + type: IsarType.string, + ), + r'width': PropertySchema( + id: 5, + name: r'width', + type: IsarType.double, + ) + }, + estimateSize: _cThumbnailEstimateSize, + serialize: _cThumbnailSerialize, + deserialize: _cThumbnailDeserialize, + deserializeProp: _cThumbnailDeserializeProp, +); + +int _cThumbnailEstimateSize( + CThumbnail object, + List offsets, + Map> allOffsets, +) { + var bytesCount = offsets.last; + { + final value = object.plainUrl; + if (value != null) { + bytesCount += 3 + value.length * 3; + } + } + bytesCount += 3 + object.url.length * 3; + return bytesCount; +} + +void _cThumbnailSerialize( + CThumbnail object, + IsarWriter writer, + List offsets, + Map> allOffsets, +) { + writer.writeDouble(offsets[0], object.height); + writer.writeString(offsets[1], object.plainUrl); + writer.writeDouble(offsets[2], object.realHeight); + writer.writeDouble(offsets[3], object.realWidth); + writer.writeString(offsets[4], object.url); + writer.writeDouble(offsets[5], object.width); +} + +CThumbnail _cThumbnailDeserialize( + Id id, + IsarReader reader, + List offsets, + Map> allOffsets, +) { + final object = CThumbnail(); + object.height = reader.readDoubleOrNull(offsets[0]); + object.plainUrl = reader.readStringOrNull(offsets[1]); + object.realHeight = reader.readDoubleOrNull(offsets[2]); + object.realWidth = reader.readDoubleOrNull(offsets[3]); + object.url = reader.readString(offsets[4]); + object.width = reader.readDoubleOrNull(offsets[5]); + return object; +} + +P _cThumbnailDeserializeProp

( + IsarReader reader, + int propertyId, + int offset, + Map> allOffsets, +) { + switch (propertyId) { + case 0: + return (reader.readDoubleOrNull(offset)) as P; + case 1: + return (reader.readStringOrNull(offset)) as P; + case 2: + return (reader.readDoubleOrNull(offset)) as P; + case 3: + return (reader.readDoubleOrNull(offset)) as P; + case 4: + return (reader.readString(offset)) as P; + case 5: + return (reader.readDoubleOrNull(offset)) as P; + default: + throw IsarError('Unknown property with id $propertyId'); + } +} + +extension CThumbnailQueryFilter + on QueryBuilder { + QueryBuilder heightIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'height', + )); + }); + } + + QueryBuilder + heightIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'height', + )); + }); + } + + QueryBuilder heightEqualTo( + double? value, { + double epsilon = Query.epsilon, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'height', + value: value, + epsilon: epsilon, + )); + }); + } + + QueryBuilder heightGreaterThan( + double? value, { + bool include = false, + double epsilon = Query.epsilon, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'height', + value: value, + epsilon: epsilon, + )); + }); + } + + QueryBuilder heightLessThan( + double? value, { + bool include = false, + double epsilon = Query.epsilon, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'height', + value: value, + epsilon: epsilon, + )); + }); + } + + QueryBuilder heightBetween( + double? lower, + double? upper, { + bool includeLower = true, + bool includeUpper = true, + double epsilon = Query.epsilon, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'height', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + epsilon: epsilon, + )); + }); + } + + QueryBuilder plainUrlIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'plainUrl', + )); + }); + } + + QueryBuilder + plainUrlIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'plainUrl', + )); + }); + } + + QueryBuilder plainUrlEqualTo( + String? value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'plainUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + plainUrlGreaterThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'plainUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder plainUrlLessThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'plainUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder plainUrlBetween( + String? lower, + String? upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'plainUrl', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + plainUrlStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'plainUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder plainUrlEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'plainUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder plainUrlContains( + String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'plainUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder plainUrlMatches( + String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'plainUrl', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + plainUrlIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'plainUrl', + value: '', + )); + }); + } + + QueryBuilder + plainUrlIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'plainUrl', + value: '', + )); + }); + } + + QueryBuilder + realHeightIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'realHeight', + )); + }); + } + + QueryBuilder + realHeightIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'realHeight', + )); + }); + } + + QueryBuilder realHeightEqualTo( + double? value, { + double epsilon = Query.epsilon, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'realHeight', + value: value, + epsilon: epsilon, + )); + }); + } + + QueryBuilder + realHeightGreaterThan( + double? value, { + bool include = false, + double epsilon = Query.epsilon, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'realHeight', + value: value, + epsilon: epsilon, + )); + }); + } + + QueryBuilder + realHeightLessThan( + double? value, { + bool include = false, + double epsilon = Query.epsilon, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'realHeight', + value: value, + epsilon: epsilon, + )); + }); + } + + QueryBuilder realHeightBetween( + double? lower, + double? upper, { + bool includeLower = true, + bool includeUpper = true, + double epsilon = Query.epsilon, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'realHeight', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + epsilon: epsilon, + )); + }); + } + + QueryBuilder + realWidthIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'realWidth', + )); + }); + } + + QueryBuilder + realWidthIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'realWidth', + )); + }); + } + + QueryBuilder realWidthEqualTo( + double? value, { + double epsilon = Query.epsilon, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'realWidth', + value: value, + epsilon: epsilon, + )); + }); + } + + QueryBuilder + realWidthGreaterThan( + double? value, { + bool include = false, + double epsilon = Query.epsilon, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'realWidth', + value: value, + epsilon: epsilon, + )); + }); + } + + QueryBuilder realWidthLessThan( + double? value, { + bool include = false, + double epsilon = Query.epsilon, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'realWidth', + value: value, + epsilon: epsilon, + )); + }); + } + + QueryBuilder realWidthBetween( + double? lower, + double? upper, { + bool includeLower = true, + bool includeUpper = true, + double epsilon = Query.epsilon, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'realWidth', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + epsilon: epsilon, + )); + }); + } + + QueryBuilder urlEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'url', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder urlGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'url', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder urlLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'url', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder urlBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'url', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder urlStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'url', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder urlEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'url', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder urlContains( + String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'url', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder urlMatches( + String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'url', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder urlIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'url', + value: '', + )); + }); + } + + QueryBuilder urlIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'url', + value: '', + )); + }); + } + + QueryBuilder widthIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'width', + )); + }); + } + + QueryBuilder widthIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'width', + )); + }); + } + + QueryBuilder widthEqualTo( + double? value, { + double epsilon = Query.epsilon, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'width', + value: value, + epsilon: epsilon, + )); + }); + } + + QueryBuilder widthGreaterThan( + double? value, { + bool include = false, + double epsilon = Query.epsilon, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'width', + value: value, + epsilon: epsilon, + )); + }); + } + + QueryBuilder widthLessThan( + double? value, { + bool include = false, + double epsilon = Query.epsilon, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'width', + value: value, + epsilon: epsilon, + )); + }); + } + + QueryBuilder widthBetween( + double? lower, + double? upper, { + bool includeLower = true, + bool includeUpper = true, + double epsilon = Query.epsilon, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'width', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + epsilon: epsilon, + )); + }); + } +} + +extension CThumbnailQueryObject + on QueryBuilder {} + +// coverage:ignore-file +// ignore_for_file: duplicate_ignore, non_constant_identifier_names, constant_identifier_names, invalid_use_of_protected_member, unnecessary_cast, prefer_const_constructors, lines_longer_than_80_chars, require_trailing_commas, inference_failure_on_function_invocation, unnecessary_parenthesis, unnecessary_raw_strings, unnecessary_null_checks, join_return_with_assignment, prefer_final_locals, avoid_js_rounded_ints, avoid_positional_boolean_parameters, always_specify_types + +final CFileMessageCreateParamsSchema = Schema( + name: r'CFileMessageCreateParams', + id: BigInt.parse('-28171588097914807').toInt(), + properties: { + r'customType': PropertySchema( + id: 0, + name: r'customType', + type: IsarType.string, + ), + r'data': PropertySchema( + id: 1, + name: r'data', + type: IsarType.string, + ), + r'fileInfo': PropertySchema( + id: 2, + name: r'fileInfo', + type: IsarType.object, + target: r'CFileInfo', + ), + r'isPinnedMessage': PropertySchema( + id: 3, + name: r'isPinnedMessage', + type: IsarType.bool, + ), + r'mentionType': PropertySchema( + id: 4, + name: r'mentionType', + type: IsarType.byte, + enumMap: _CFileMessageCreateParamsmentionTypeEnumValueMap, + ), + r'mentionedUserIds': PropertySchema( + id: 5, + name: r'mentionedUserIds', + type: IsarType.stringList, + ), + r'metaArrays': PropertySchema( + id: 6, + name: r'metaArrays', + type: IsarType.objectList, + target: r'CMessageMetaArray', + ), + r'parentMessageId': PropertySchema( + id: 7, + name: r'parentMessageId', + type: IsarType.long, + ), + r'pushNotificationDeliveryOption': PropertySchema( + id: 8, + name: r'pushNotificationDeliveryOption', + type: IsarType.byte, + enumMap: + _CFileMessageCreateParamspushNotificationDeliveryOptionEnumValueMap, + ), + r'replyToChannel': PropertySchema( + id: 9, + name: r'replyToChannel', + type: IsarType.bool, + ), + r'thumbnailSizes': PropertySchema( + id: 10, + name: r'thumbnailSizes', + type: IsarType.objectList, + target: r'CSize', + ) + }, + estimateSize: _cFileMessageCreateParamsEstimateSize, + serialize: _cFileMessageCreateParamsSerialize, + deserialize: _cFileMessageCreateParamsDeserialize, + deserializeProp: _cFileMessageCreateParamsDeserializeProp, +); + +int _cFileMessageCreateParamsEstimateSize( + CFileMessageCreateParams object, + List offsets, + Map> allOffsets, +) { + var bytesCount = offsets.last; + { + final value = object.customType; + if (value != null) { + bytesCount += 3 + value.length * 3; + } + } + { + final value = object.data; + if (value != null) { + bytesCount += 3 + value.length * 3; + } + } + bytesCount += 3 + + CFileInfoSchema.estimateSize( + object.fileInfo, allOffsets[CFileInfo]!, allOffsets); + { + final list = object.mentionedUserIds; + if (list != null) { + bytesCount += 3 + list.length * 3; + { + for (var i = 0; i < list.length; i++) { + final value = list[i]; + bytesCount += value.length * 3; + } + } + } + } + { + final list = object.metaArrays; + if (list != null) { + bytesCount += 3 + list.length * 3; + { + final offsets = allOffsets[CMessageMetaArray]!; + for (var i = 0; i < list.length; i++) { + final value = list[i]; + bytesCount += + CMessageMetaArraySchema.estimateSize(value, offsets, allOffsets); + } + } + } + } + { + final list = object.thumbnailSizes; + if (list != null) { + bytesCount += 3 + list.length * 3; + { + final offsets = allOffsets[CSize]!; + for (var i = 0; i < list.length; i++) { + final value = list[i]; + bytesCount += CSizeSchema.estimateSize(value, offsets, allOffsets); + } + } + } + } + return bytesCount; +} + +void _cFileMessageCreateParamsSerialize( + CFileMessageCreateParams object, + IsarWriter writer, + List offsets, + Map> allOffsets, +) { + writer.writeString(offsets[0], object.customType); + writer.writeString(offsets[1], object.data); + writer.writeObject( + offsets[2], + allOffsets, + CFileInfoSchema.serialize, + object.fileInfo, + ); + writer.writeBool(offsets[3], object.isPinnedMessage); + writer.writeByte(offsets[4], object.mentionType.index); + writer.writeStringList(offsets[5], object.mentionedUserIds); + writer.writeObjectList( + offsets[6], + allOffsets, + CMessageMetaArraySchema.serialize, + object.metaArrays, + ); + writer.writeLong(offsets[7], object.parentMessageId); + writer.writeByte(offsets[8], object.pushNotificationDeliveryOption.index); + writer.writeBool(offsets[9], object.replyToChannel); + writer.writeObjectList( + offsets[10], + allOffsets, + CSizeSchema.serialize, + object.thumbnailSizes, + ); +} + +CFileMessageCreateParams _cFileMessageCreateParamsDeserialize( + Id id, + IsarReader reader, + List offsets, + Map> allOffsets, +) { + final object = CFileMessageCreateParams(); + object.customType = reader.readStringOrNull(offsets[0]); + object.data = reader.readStringOrNull(offsets[1]); + object.fileInfo = reader.readObjectOrNull( + offsets[2], + CFileInfoSchema.deserialize, + allOffsets, + ) ?? + CFileInfo(); + object.isPinnedMessage = reader.readBool(offsets[3]); + object.mentionType = _CFileMessageCreateParamsmentionTypeValueEnumMap[ + reader.readByteOrNull(offsets[4])] ?? + MentionType.users; + object.mentionedUserIds = reader.readStringList(offsets[5]); + object.metaArrays = reader.readObjectList( + offsets[6], + CMessageMetaArraySchema.deserialize, + allOffsets, + CMessageMetaArray(), + ); + object.parentMessageId = reader.readLongOrNull(offsets[7]); + object.pushNotificationDeliveryOption = + _CFileMessageCreateParamspushNotificationDeliveryOptionValueEnumMap[ + reader.readByteOrNull(offsets[8])] ?? + PushNotificationDeliveryOption.normal; + object.replyToChannel = reader.readBool(offsets[9]); + object.thumbnailSizes = reader.readObjectList( + offsets[10], + CSizeSchema.deserialize, + allOffsets, + CSize(), + ); + return object; +} + +P _cFileMessageCreateParamsDeserializeProp

( + IsarReader reader, + int propertyId, + int offset, + Map> allOffsets, +) { + switch (propertyId) { + case 0: + return (reader.readStringOrNull(offset)) as P; + case 1: + return (reader.readStringOrNull(offset)) as P; + case 2: + return (reader.readObjectOrNull( + offset, + CFileInfoSchema.deserialize, + allOffsets, + ) ?? + CFileInfo()) as P; + case 3: + return (reader.readBool(offset)) as P; + case 4: + return (_CFileMessageCreateParamsmentionTypeValueEnumMap[ + reader.readByteOrNull(offset)] ?? + MentionType.users) as P; + case 5: + return (reader.readStringList(offset)) as P; + case 6: + return (reader.readObjectList( + offset, + CMessageMetaArraySchema.deserialize, + allOffsets, + CMessageMetaArray(), + )) as P; + case 7: + return (reader.readLongOrNull(offset)) as P; + case 8: + return (_CFileMessageCreateParamspushNotificationDeliveryOptionValueEnumMap[ + reader.readByteOrNull(offset)] ?? + PushNotificationDeliveryOption.normal) as P; + case 9: + return (reader.readBool(offset)) as P; + case 10: + return (reader.readObjectList( + offset, + CSizeSchema.deserialize, + allOffsets, + CSize(), + )) as P; + default: + throw IsarError('Unknown property with id $propertyId'); + } +} + +const _CFileMessageCreateParamsmentionTypeEnumValueMap = { + 'users': 0, + 'channel': 1, +}; +const _CFileMessageCreateParamsmentionTypeValueEnumMap = { + 0: MentionType.users, + 1: MentionType.channel, +}; +const _CFileMessageCreateParamspushNotificationDeliveryOptionEnumValueMap = { + 'normal': 0, + 'suppress': 1, + 'force': 2, +}; +const _CFileMessageCreateParamspushNotificationDeliveryOptionValueEnumMap = { + 0: PushNotificationDeliveryOption.normal, + 1: PushNotificationDeliveryOption.suppress, + 2: PushNotificationDeliveryOption.force, +}; + +extension CFileMessageCreateParamsQueryFilter on QueryBuilder< + CFileMessageCreateParams, CFileMessageCreateParams, QFilterCondition> { + QueryBuilder customTypeIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'customType', + )); + }); + } + + QueryBuilder customTypeIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'customType', + )); + }); + } + + QueryBuilder customTypeEqualTo( + String? value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'customType', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder customTypeGreaterThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'customType', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder customTypeLessThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'customType', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder customTypeBetween( + String? lower, + String? upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'customType', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder customTypeStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'customType', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder customTypeEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'customType', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + customTypeContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'customType', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + customTypeMatches(String pattern, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'customType', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder customTypeIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'customType', + value: '', + )); + }); + } + + QueryBuilder customTypeIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'customType', + value: '', + )); + }); + } + + QueryBuilder dataIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'data', + )); + }); + } + + QueryBuilder dataIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'data', + )); + }); + } + + QueryBuilder dataEqualTo( + String? value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'data', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder dataGreaterThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'data', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder dataLessThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'data', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder dataBetween( + String? lower, + String? upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'data', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder dataStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'data', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder dataEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'data', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + dataContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'data', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + dataMatches(String pattern, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'data', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder dataIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'data', + value: '', + )); + }); + } + + QueryBuilder dataIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'data', + value: '', + )); + }); + } + + QueryBuilder isPinnedMessageEqualTo(bool value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'isPinnedMessage', + value: value, + )); + }); + } + + QueryBuilder mentionTypeEqualTo(MentionType value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'mentionType', + value: value, + )); + }); + } + + QueryBuilder mentionTypeGreaterThan( + MentionType value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'mentionType', + value: value, + )); + }); + } + + QueryBuilder mentionTypeLessThan( + MentionType value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'mentionType', + value: value, + )); + }); + } + + QueryBuilder mentionTypeBetween( + MentionType lower, + MentionType upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'mentionType', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder mentionedUserIdsIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'mentionedUserIds', + )); + }); + } + + QueryBuilder mentionedUserIdsIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'mentionedUserIds', + )); + }); + } + + QueryBuilder mentionedUserIdsElementEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'mentionedUserIds', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder mentionedUserIdsElementGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'mentionedUserIds', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder mentionedUserIdsElementLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'mentionedUserIds', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder mentionedUserIdsElementBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'mentionedUserIds', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder mentionedUserIdsElementStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'mentionedUserIds', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder mentionedUserIdsElementEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'mentionedUserIds', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + mentionedUserIdsElementContains(String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'mentionedUserIds', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + mentionedUserIdsElementMatches(String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'mentionedUserIds', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder mentionedUserIdsElementIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'mentionedUserIds', + value: '', + )); + }); + } + + QueryBuilder mentionedUserIdsElementIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'mentionedUserIds', + value: '', + )); + }); + } + + QueryBuilder mentionedUserIdsLengthEqualTo(int length) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'mentionedUserIds', + length, + true, + length, + true, + ); + }); + } + + QueryBuilder mentionedUserIdsIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'mentionedUserIds', + 0, + true, + 0, + true, + ); + }); + } + + QueryBuilder mentionedUserIdsIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'mentionedUserIds', + 0, + false, + 999999, + true, + ); + }); + } + + QueryBuilder mentionedUserIdsLengthLessThan( + int length, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'mentionedUserIds', + 0, + true, + length, + include, + ); + }); + } + + QueryBuilder mentionedUserIdsLengthGreaterThan( + int length, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'mentionedUserIds', + length, + include, + 999999, + true, + ); + }); + } + + QueryBuilder mentionedUserIdsLengthBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'mentionedUserIds', + lower, + includeLower, + upper, + includeUpper, + ); + }); + } + + QueryBuilder metaArraysIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'metaArrays', + )); + }); + } + + QueryBuilder metaArraysIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'metaArrays', + )); + }); + } + + QueryBuilder metaArraysLengthEqualTo(int length) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'metaArrays', + length, + true, + length, + true, + ); + }); + } + + QueryBuilder metaArraysIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'metaArrays', + 0, + true, + 0, + true, + ); + }); + } + + QueryBuilder metaArraysIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'metaArrays', + 0, + false, + 999999, + true, + ); + }); + } + + QueryBuilder metaArraysLengthLessThan( + int length, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'metaArrays', + 0, + true, + length, + include, + ); + }); + } + + QueryBuilder metaArraysLengthGreaterThan( + int length, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'metaArrays', + length, + include, + 999999, + true, + ); + }); + } + + QueryBuilder metaArraysLengthBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'metaArrays', + lower, + includeLower, + upper, + includeUpper, + ); + }); + } + + QueryBuilder parentMessageIdIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'parentMessageId', + )); + }); + } + + QueryBuilder parentMessageIdIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'parentMessageId', + )); + }); + } + + QueryBuilder parentMessageIdEqualTo(int? value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'parentMessageId', + value: value, + )); + }); + } + + QueryBuilder parentMessageIdGreaterThan( + int? value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'parentMessageId', + value: value, + )); + }); + } + + QueryBuilder parentMessageIdLessThan( + int? value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'parentMessageId', + value: value, + )); + }); + } + + QueryBuilder parentMessageIdBetween( + int? lower, + int? upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'parentMessageId', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + pushNotificationDeliveryOptionEqualTo( + PushNotificationDeliveryOption value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'pushNotificationDeliveryOption', + value: value, + )); + }); + } + + QueryBuilder pushNotificationDeliveryOptionGreaterThan( + PushNotificationDeliveryOption value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'pushNotificationDeliveryOption', + value: value, + )); + }); + } + + QueryBuilder pushNotificationDeliveryOptionLessThan( + PushNotificationDeliveryOption value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'pushNotificationDeliveryOption', + value: value, + )); + }); + } + + QueryBuilder pushNotificationDeliveryOptionBetween( + PushNotificationDeliveryOption lower, + PushNotificationDeliveryOption upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'pushNotificationDeliveryOption', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder replyToChannelEqualTo(bool value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'replyToChannel', + value: value, + )); + }); + } + + QueryBuilder thumbnailSizesIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'thumbnailSizes', + )); + }); + } + + QueryBuilder thumbnailSizesIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'thumbnailSizes', + )); + }); + } + + QueryBuilder thumbnailSizesLengthEqualTo(int length) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'thumbnailSizes', + length, + true, + length, + true, + ); + }); + } + + QueryBuilder thumbnailSizesIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'thumbnailSizes', + 0, + true, + 0, + true, + ); + }); + } + + QueryBuilder thumbnailSizesIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'thumbnailSizes', + 0, + false, + 999999, + true, + ); + }); + } + + QueryBuilder thumbnailSizesLengthLessThan( + int length, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'thumbnailSizes', + 0, + true, + length, + include, + ); + }); + } + + QueryBuilder thumbnailSizesLengthGreaterThan( + int length, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'thumbnailSizes', + length, + include, + 999999, + true, + ); + }); + } + + QueryBuilder thumbnailSizesLengthBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'thumbnailSizes', + lower, + includeLower, + upper, + includeUpper, + ); + }); + } +} + +extension CFileMessageCreateParamsQueryObject on QueryBuilder< + CFileMessageCreateParams, CFileMessageCreateParams, QFilterCondition> { + QueryBuilder fileInfo(FilterQuery q) { + return QueryBuilder.apply(this, (query) { + return query.object(q, r'fileInfo'); + }); + } + + QueryBuilder + metaArraysElement(FilterQuery q) { + return QueryBuilder.apply(this, (query) { + return query.object(q, r'metaArrays'); + }); + } + + QueryBuilder thumbnailSizesElement(FilterQuery q) { + return QueryBuilder.apply(this, (query) { + return query.object(q, r'thumbnailSizes'); + }); + } +} + +// coverage:ignore-file +// ignore_for_file: duplicate_ignore, non_constant_identifier_names, constant_identifier_names, invalid_use_of_protected_member, unnecessary_cast, prefer_const_constructors, lines_longer_than_80_chars, require_trailing_commas, inference_failure_on_function_invocation, unnecessary_parenthesis, unnecessary_raw_strings, unnecessary_null_checks, join_return_with_assignment, prefer_final_locals, avoid_js_rounded_ints, avoid_positional_boolean_parameters, always_specify_types + +final CFileInfoSchema = Schema( + name: r'CFileInfo', + id: BigInt.parse('996992686443270943').toInt(), + properties: { + r'fileName': PropertySchema( + id: 0, + name: r'fileName', + type: IsarType.string, + ), + r'fileSize': PropertySchema( + id: 1, + name: r'fileSize', + type: IsarType.long, + ), + r'fileUrl': PropertySchema( + id: 2, + name: r'fileUrl', + type: IsarType.string, + ), + r'localFilePath': PropertySchema( + id: 3, + name: r'localFilePath', + type: IsarType.string, + ), + r'mimeType': PropertySchema( + id: 4, + name: r'mimeType', + type: IsarType.string, + ) + }, + estimateSize: _cFileInfoEstimateSize, + serialize: _cFileInfoSerialize, + deserialize: _cFileInfoDeserialize, + deserializeProp: _cFileInfoDeserializeProp, +); + +int _cFileInfoEstimateSize( + CFileInfo object, + List offsets, + Map> allOffsets, +) { + var bytesCount = offsets.last; + { + final value = object.fileName; + if (value != null) { + bytesCount += 3 + value.length * 3; + } + } + { + final value = object.fileUrl; + if (value != null) { + bytesCount += 3 + value.length * 3; + } + } + { + final value = object.localFilePath; + if (value != null) { + bytesCount += 3 + value.length * 3; + } + } + { + final value = object.mimeType; + if (value != null) { + bytesCount += 3 + value.length * 3; + } + } + return bytesCount; +} + +void _cFileInfoSerialize( + CFileInfo object, + IsarWriter writer, + List offsets, + Map> allOffsets, +) { + writer.writeString(offsets[0], object.fileName); + writer.writeLong(offsets[1], object.fileSize); + writer.writeString(offsets[2], object.fileUrl); + writer.writeString(offsets[3], object.localFilePath); + writer.writeString(offsets[4], object.mimeType); +} + +CFileInfo _cFileInfoDeserialize( + Id id, + IsarReader reader, + List offsets, + Map> allOffsets, +) { + final object = CFileInfo(); + object.fileName = reader.readStringOrNull(offsets[0]); + object.fileSize = reader.readLongOrNull(offsets[1]); + object.fileUrl = reader.readStringOrNull(offsets[2]); + object.localFilePath = reader.readStringOrNull(offsets[3]); + object.mimeType = reader.readStringOrNull(offsets[4]); + return object; +} + +P _cFileInfoDeserializeProp

( + IsarReader reader, + int propertyId, + int offset, + Map> allOffsets, +) { + switch (propertyId) { + case 0: + return (reader.readStringOrNull(offset)) as P; + case 1: + return (reader.readLongOrNull(offset)) as P; + case 2: + return (reader.readStringOrNull(offset)) as P; + case 3: + return (reader.readStringOrNull(offset)) as P; + case 4: + return (reader.readStringOrNull(offset)) as P; + default: + throw IsarError('Unknown property with id $propertyId'); + } +} + +extension CFileInfoQueryFilter + on QueryBuilder { + QueryBuilder fileNameIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'fileName', + )); + }); + } + + QueryBuilder + fileNameIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'fileName', + )); + }); + } + + QueryBuilder fileNameEqualTo( + String? value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'fileName', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder fileNameGreaterThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'fileName', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder fileNameLessThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'fileName', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder fileNameBetween( + String? lower, + String? upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'fileName', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder fileNameStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'fileName', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder fileNameEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'fileName', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder fileNameContains( + String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'fileName', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder fileNameMatches( + String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'fileName', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder fileNameIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'fileName', + value: '', + )); + }); + } + + QueryBuilder + fileNameIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'fileName', + value: '', + )); + }); + } + + QueryBuilder fileSizeIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'fileSize', + )); + }); + } + + QueryBuilder + fileSizeIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'fileSize', + )); + }); + } + + QueryBuilder fileSizeEqualTo( + int? value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'fileSize', + value: value, + )); + }); + } + + QueryBuilder fileSizeGreaterThan( + int? value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'fileSize', + value: value, + )); + }); + } + + QueryBuilder fileSizeLessThan( + int? value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'fileSize', + value: value, + )); + }); + } + + QueryBuilder fileSizeBetween( + int? lower, + int? upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'fileSize', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder fileUrlIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'fileUrl', + )); + }); + } + + QueryBuilder fileUrlIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'fileUrl', + )); + }); + } + + QueryBuilder fileUrlEqualTo( + String? value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'fileUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder fileUrlGreaterThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'fileUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder fileUrlLessThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'fileUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder fileUrlBetween( + String? lower, + String? upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'fileUrl', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder fileUrlStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'fileUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder fileUrlEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'fileUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder fileUrlContains( + String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'fileUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder fileUrlMatches( + String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'fileUrl', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder fileUrlIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'fileUrl', + value: '', + )); + }); + } + + QueryBuilder + fileUrlIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'fileUrl', + value: '', + )); + }); + } + + QueryBuilder + localFilePathIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'localFilePath', + )); + }); + } + + QueryBuilder + localFilePathIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'localFilePath', + )); + }); + } + + QueryBuilder + localFilePathEqualTo( + String? value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'localFilePath', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + localFilePathGreaterThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'localFilePath', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + localFilePathLessThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'localFilePath', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + localFilePathBetween( + String? lower, + String? upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'localFilePath', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + localFilePathStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'localFilePath', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + localFilePathEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'localFilePath', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + localFilePathContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'localFilePath', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + localFilePathMatches(String pattern, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'localFilePath', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + localFilePathIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'localFilePath', + value: '', + )); + }); + } + + QueryBuilder + localFilePathIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'localFilePath', + value: '', + )); + }); + } + + QueryBuilder mimeTypeIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'mimeType', + )); + }); + } + + QueryBuilder + mimeTypeIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'mimeType', + )); + }); + } + + QueryBuilder mimeTypeEqualTo( + String? value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'mimeType', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder mimeTypeGreaterThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'mimeType', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder mimeTypeLessThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'mimeType', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder mimeTypeBetween( + String? lower, + String? upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'mimeType', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder mimeTypeStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'mimeType', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder mimeTypeEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'mimeType', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder mimeTypeContains( + String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'mimeType', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder mimeTypeMatches( + String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'mimeType', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder mimeTypeIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'mimeType', + value: '', + )); + }); + } + + QueryBuilder + mimeTypeIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'mimeType', + value: '', + )); + }); + } +} + +extension CFileInfoQueryObject + on QueryBuilder {} + +// coverage:ignore-file +// ignore_for_file: duplicate_ignore, non_constant_identifier_names, constant_identifier_names, invalid_use_of_protected_member, unnecessary_cast, prefer_const_constructors, lines_longer_than_80_chars, require_trailing_commas, inference_failure_on_function_invocation, unnecessary_parenthesis, unnecessary_raw_strings, unnecessary_null_checks, join_return_with_assignment, prefer_final_locals, avoid_js_rounded_ints, avoid_positional_boolean_parameters, always_specify_types + +final CSizeSchema = Schema( + name: r'CSize', + id: BigInt.parse('5020865885922142944').toInt(), + properties: { + r'height': PropertySchema( + id: 0, + name: r'height', + type: IsarType.double, + ), + r'width': PropertySchema( + id: 1, + name: r'width', + type: IsarType.double, + ) + }, + estimateSize: _cSizeEstimateSize, + serialize: _cSizeSerialize, + deserialize: _cSizeDeserialize, + deserializeProp: _cSizeDeserializeProp, +); + +int _cSizeEstimateSize( + CSize object, + List offsets, + Map> allOffsets, +) { + var bytesCount = offsets.last; + return bytesCount; +} + +void _cSizeSerialize( + CSize object, + IsarWriter writer, + List offsets, + Map> allOffsets, +) { + writer.writeDouble(offsets[0], object.height); + writer.writeDouble(offsets[1], object.width); +} + +CSize _cSizeDeserialize( + Id id, + IsarReader reader, + List offsets, + Map> allOffsets, +) { + final object = CSize(); + object.height = reader.readDouble(offsets[0]); + object.width = reader.readDouble(offsets[1]); + return object; +} + +P _cSizeDeserializeProp

( + IsarReader reader, + int propertyId, + int offset, + Map> allOffsets, +) { + switch (propertyId) { + case 0: + return (reader.readDouble(offset)) as P; + case 1: + return (reader.readDouble(offset)) as P; + default: + throw IsarError('Unknown property with id $propertyId'); + } +} + +extension CSizeQueryFilter on QueryBuilder { + QueryBuilder heightEqualTo( + double value, { + double epsilon = Query.epsilon, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'height', + value: value, + epsilon: epsilon, + )); + }); + } + + QueryBuilder heightGreaterThan( + double value, { + bool include = false, + double epsilon = Query.epsilon, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'height', + value: value, + epsilon: epsilon, + )); + }); + } + + QueryBuilder heightLessThan( + double value, { + bool include = false, + double epsilon = Query.epsilon, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'height', + value: value, + epsilon: epsilon, + )); + }); + } + + QueryBuilder heightBetween( + double lower, + double upper, { + bool includeLower = true, + bool includeUpper = true, + double epsilon = Query.epsilon, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'height', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + epsilon: epsilon, + )); + }); + } + + QueryBuilder widthEqualTo( + double value, { + double epsilon = Query.epsilon, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'width', + value: value, + epsilon: epsilon, + )); + }); + } + + QueryBuilder widthGreaterThan( + double value, { + bool include = false, + double epsilon = Query.epsilon, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'width', + value: value, + epsilon: epsilon, + )); + }); + } + + QueryBuilder widthLessThan( + double value, { + bool include = false, + double epsilon = Query.epsilon, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'width', + value: value, + epsilon: epsilon, + )); + }); + } + + QueryBuilder widthBetween( + double lower, + double upper, { + bool includeLower = true, + bool includeUpper = true, + double epsilon = Query.epsilon, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'width', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + epsilon: epsilon, + )); + }); + } +} + +extension CSizeQueryObject on QueryBuilder {} diff --git a/lib/src/internal/db/schema/message/c_notification_message.dart b/lib/src/internal/db/schema/message/c_notification_message.dart new file mode 100644 index 00000000..8cb4dab9 --- /dev/null +++ b/lib/src/internal/db/schema/message/c_notification_message.dart @@ -0,0 +1,122 @@ +// Copyright (c) 2023 Sendbird, Inc. All rights reserved. + +import 'dart:convert'; + +import 'package:isar/isar.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/message/c_root_message.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/message/meta/c_channel_message.dart'; +import 'package:sendbird_chat_sdk/src/internal/main/chat/chat.dart'; +import 'package:sendbird_chat_sdk/src/public/core/message/notification_message.dart'; +import 'package:sendbird_chat_sdk/src/public/core/message/root_message.dart'; +import 'package:sendbird_chat_sdk/src/public/main/define/enums.dart'; +import 'package:sendbird_chat_sdk/src/public/main/model/message/notification_data.dart'; + +part 'c_notification_message.g.dart'; + +@collection +class CNotificationMessage extends CRootMessage { + late String notificationId; + + @enumerated + late NotificationMessageStatus messageStatus; + + CNotificationData? notificationData; + + CNotificationMessage(); + + factory CNotificationMessage.fromNotificationMessage( + NotificationMessage message) { + return CNotificationMessage() + // RootMessage + ..setRootMessage(message) + // NotificationMessage + ..notificationId = message.notificationId + ..messageStatus = message.messageStatus + ..notificationData = message.notificationData != null + ? CNotificationData.fromNotificationData(message.notificationData!) + : null; + } + + Future toNotificationMessage( + Chat chat, Isar isar) async { + final notificationMessage = NotificationMessage( + // RootMessage + channelUrl: channelUrl, + channelType: channelType, + // NotificationMessage + notificationId: notificationId, + messageStatus: messageStatus, + )..set(chat); + return await CRootMessage.setCRootMessage( + chat, isar, notificationMessage, this) as NotificationMessage + // NotificationMessage + ..notificationData = notificationData?.toNotificationData(); + } + + static Future upsert( + Chat chat, Isar isar, NotificationMessage message) async { + message.channelType = ChannelType.feed; + + final cNotificationMessage = + CNotificationMessage.fromNotificationMessage(message); + + // RootMessage + await CRootMessage.upsert(chat, isar, message); + + // NotificationMessage + await chat.dbManager.write(() async { + await isar.cNotificationMessages.put(cNotificationMessage); + }); + + // ChannelMessage + await CChannelMessage.upsert(chat, isar, message); + + return cNotificationMessage; + } + + static Future get( + Chat chat, Isar isar, String rootId) async { + final cNotificationMessage = await isar.cNotificationMessages + .where() + .rootIdEqualTo(rootId) + .findFirst(); + return await cNotificationMessage?.toNotificationMessage(chat, isar); + } + + static Future delete(Chat chat, Isar isar, String rootId) async { + // NotificationMessage + await chat.dbManager.write(() async { + await isar.cNotificationMessages.deleteByRootId(rootId); + }); + + // ChannelMessage + await CChannelMessage.delete(chat, isar, rootId); + } +} + +@embedded +class CNotificationData { + late String templateKey; + late String templateVariables; // Map + String? label; + List? tags; + + CNotificationData(); + + factory CNotificationData.fromNotificationData(NotificationData data) { + return CNotificationData() + ..templateKey = data.templateKey + ..templateVariables = jsonEncode(data.templateVariables) + ..label = data.label + ..tags = data.tags; + } + + NotificationData toNotificationData() { + return NotificationData( + templateKey: templateKey, + templateVariables: jsonDecode(templateVariables) as Map, + ) + ..label = label + ..tags = tags ?? []; + } +} diff --git a/lib/src/internal/db/schema/message/c_notification_message.g.dart b/lib/src/internal/db/schema/message/c_notification_message.g.dart new file mode 100644 index 00000000..4014c6fe --- /dev/null +++ b/lib/src/internal/db/schema/message/c_notification_message.g.dart @@ -0,0 +1,3916 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'c_notification_message.dart'; + +// ************************************************************************** +// IsarCollectionGenerator +// ************************************************************************** + +// coverage:ignore-file +// ignore_for_file: duplicate_ignore, non_constant_identifier_names, constant_identifier_names, invalid_use_of_protected_member, unnecessary_cast, prefer_const_constructors, lines_longer_than_80_chars, require_trailing_commas, inference_failure_on_function_invocation, unnecessary_parenthesis, unnecessary_raw_strings, unnecessary_null_checks, join_return_with_assignment, prefer_final_locals, avoid_js_rounded_ints, avoid_positional_boolean_parameters, always_specify_types + +extension GetCNotificationMessageCollection on Isar { + IsarCollection get cNotificationMessages => + this.collection(); +} + +final CNotificationMessageSchema = CollectionSchema( + name: r'CNotificationMessage', + id: BigInt.parse('916250674792986472').toInt(), + properties: { + r'allMetaArrays': PropertySchema( + id: 0, + name: r'allMetaArrays', + type: IsarType.objectList, + target: r'CMessageMetaArray', + ), + r'channelType': PropertySchema( + id: 1, + name: r'channelType', + type: IsarType.byte, + enumMap: _CNotificationMessagechannelTypeEnumValueMap, + ), + r'channelUrl': PropertySchema( + id: 2, + name: r'channelUrl', + type: IsarType.string, + ), + r'createdAt': PropertySchema( + id: 3, + name: r'createdAt', + type: IsarType.long, + ), + r'customType': PropertySchema( + id: 4, + name: r'customType', + type: IsarType.string, + ), + r'data': PropertySchema( + id: 5, + name: r'data', + type: IsarType.string, + ), + r'extendedMessage': PropertySchema( + id: 6, + name: r'extendedMessage', + type: IsarType.string, + ), + r'mentionType': PropertySchema( + id: 7, + name: r'mentionType', + type: IsarType.byte, + enumMap: _CNotificationMessagementionTypeEnumValueMap, + ), + r'mentionedUsers': PropertySchema( + id: 8, + name: r'mentionedUsers', + type: IsarType.stringList, + ), + r'messageStatus': PropertySchema( + id: 9, + name: r'messageStatus', + type: IsarType.byte, + enumMap: _CNotificationMessagemessageStatusEnumValueMap, + ), + r'messageType': PropertySchema( + id: 10, + name: r'messageType', + type: IsarType.byte, + enumMap: _CNotificationMessagemessageTypeEnumValueMap, + ), + r'notificationData': PropertySchema( + id: 11, + name: r'notificationData', + type: IsarType.object, + target: r'CNotificationData', + ), + r'notificationId': PropertySchema( + id: 12, + name: r'notificationId', + type: IsarType.string, + ), + r'rootId': PropertySchema( + id: 13, + name: r'rootId', + type: IsarType.string, + ), + r'updatedAt': PropertySchema( + id: 14, + name: r'updatedAt', + type: IsarType.long, + ) + }, + estimateSize: _cNotificationMessageEstimateSize, + serialize: _cNotificationMessageSerialize, + deserialize: _cNotificationMessageDeserialize, + deserializeProp: _cNotificationMessageDeserializeProp, + idName: r'id', + indexes: { + r'rootId': IndexSchema( + id: BigInt.parse('5087693435549841488').toInt(), + name: r'rootId', + unique: true, + replace: true, + properties: [ + IndexPropertySchema( + name: r'rootId', + type: IndexType.hash, + caseSensitive: true, + ) + ], + ), + r'messageType_rootId': IndexSchema( + id: BigInt.parse('-7060804333380842370').toInt(), + name: r'messageType_rootId', + unique: false, + replace: false, + properties: [ + IndexPropertySchema( + name: r'messageType', + type: IndexType.value, + caseSensitive: false, + ), + IndexPropertySchema( + name: r'rootId', + type: IndexType.hash, + caseSensitive: true, + ) + ], + ), + r'channelUrl': IndexSchema( + id: BigInt.parse('6636052684858767397').toInt(), + name: r'channelUrl', + unique: false, + replace: false, + properties: [ + IndexPropertySchema( + name: r'channelUrl', + type: IndexType.hash, + caseSensitive: true, + ) + ], + ), + r'channelType_channelUrl': IndexSchema( + id: BigInt.parse('-5957547153902522682').toInt(), + name: r'channelType_channelUrl', + unique: false, + replace: false, + properties: [ + IndexPropertySchema( + name: r'channelType', + type: IndexType.value, + caseSensitive: false, + ), + IndexPropertySchema( + name: r'channelUrl', + type: IndexType.hash, + caseSensitive: true, + ) + ], + ) + }, + links: {}, + embeddedSchemas: { + r'CNotificationData': CNotificationDataSchema, + r'CMessageMetaArray': CMessageMetaArraySchema + }, + getId: _cNotificationMessageGetId, + getLinks: _cNotificationMessageGetLinks, + attach: _cNotificationMessageAttach, + version: '3.1.0+1', +); + +int _cNotificationMessageEstimateSize( + CNotificationMessage object, + List offsets, + Map> allOffsets, +) { + var bytesCount = offsets.last; + { + final list = object.allMetaArrays; + if (list != null) { + bytesCount += 3 + list.length * 3; + { + final offsets = allOffsets[CMessageMetaArray]!; + for (var i = 0; i < list.length; i++) { + final value = list[i]; + bytesCount += + CMessageMetaArraySchema.estimateSize(value, offsets, allOffsets); + } + } + } + } + bytesCount += 3 + object.channelUrl.length * 3; + { + final value = object.customType; + if (value != null) { + bytesCount += 3 + value.length * 3; + } + } + { + final value = object.data; + if (value != null) { + bytesCount += 3 + value.length * 3; + } + } + bytesCount += 3 + object.extendedMessage.length * 3; + bytesCount += 3 + object.mentionedUsers.length * 3; + { + for (var i = 0; i < object.mentionedUsers.length; i++) { + final value = object.mentionedUsers[i]; + bytesCount += value.length * 3; + } + } + { + final value = object.notificationData; + if (value != null) { + bytesCount += 3 + + CNotificationDataSchema.estimateSize( + value, allOffsets[CNotificationData]!, allOffsets); + } + } + bytesCount += 3 + object.notificationId.length * 3; + bytesCount += 3 + object.rootId.length * 3; + return bytesCount; +} + +void _cNotificationMessageSerialize( + CNotificationMessage object, + IsarWriter writer, + List offsets, + Map> allOffsets, +) { + writer.writeObjectList( + offsets[0], + allOffsets, + CMessageMetaArraySchema.serialize, + object.allMetaArrays, + ); + writer.writeByte(offsets[1], object.channelType.index); + writer.writeString(offsets[2], object.channelUrl); + writer.writeLong(offsets[3], object.createdAt); + writer.writeString(offsets[4], object.customType); + writer.writeString(offsets[5], object.data); + writer.writeString(offsets[6], object.extendedMessage); + writer.writeByte(offsets[7], object.mentionType.index); + writer.writeStringList(offsets[8], object.mentionedUsers); + writer.writeByte(offsets[9], object.messageStatus.index); + writer.writeByte(offsets[10], object.messageType.index); + writer.writeObject( + offsets[11], + allOffsets, + CNotificationDataSchema.serialize, + object.notificationData, + ); + writer.writeString(offsets[12], object.notificationId); + writer.writeString(offsets[13], object.rootId); + writer.writeLong(offsets[14], object.updatedAt); +} + +CNotificationMessage _cNotificationMessageDeserialize( + Id id, + IsarReader reader, + List offsets, + Map> allOffsets, +) { + final object = CNotificationMessage(); + object.allMetaArrays = reader.readObjectList( + offsets[0], + CMessageMetaArraySchema.deserialize, + allOffsets, + CMessageMetaArray(), + ); + object.channelType = _CNotificationMessagechannelTypeValueEnumMap[ + reader.readByteOrNull(offsets[1])] ?? + ChannelType.group; + object.channelUrl = reader.readString(offsets[2]); + object.createdAt = reader.readLong(offsets[3]); + object.customType = reader.readStringOrNull(offsets[4]); + object.data = reader.readStringOrNull(offsets[5]); + object.extendedMessage = reader.readString(offsets[6]); + object.id = id; + object.mentionType = _CNotificationMessagementionTypeValueEnumMap[ + reader.readByteOrNull(offsets[7])] ?? + MentionType.users; + object.mentionedUsers = reader.readStringList(offsets[8]) ?? []; + object.messageStatus = _CNotificationMessagemessageStatusValueEnumMap[ + reader.readByteOrNull(offsets[9])] ?? + NotificationMessageStatus.sent; + object.messageType = _CNotificationMessagemessageTypeValueEnumMap[ + reader.readByteOrNull(offsets[10])] ?? + MessageType.user; + object.notificationData = reader.readObjectOrNull( + offsets[11], + CNotificationDataSchema.deserialize, + allOffsets, + ); + object.notificationId = reader.readString(offsets[12]); + object.rootId = reader.readString(offsets[13]); + object.updatedAt = reader.readLong(offsets[14]); + return object; +} + +P _cNotificationMessageDeserializeProp

( + IsarReader reader, + int propertyId, + int offset, + Map> allOffsets, +) { + switch (propertyId) { + case 0: + return (reader.readObjectList( + offset, + CMessageMetaArraySchema.deserialize, + allOffsets, + CMessageMetaArray(), + )) as P; + case 1: + return (_CNotificationMessagechannelTypeValueEnumMap[ + reader.readByteOrNull(offset)] ?? + ChannelType.group) as P; + case 2: + return (reader.readString(offset)) as P; + case 3: + return (reader.readLong(offset)) as P; + case 4: + return (reader.readStringOrNull(offset)) as P; + case 5: + return (reader.readStringOrNull(offset)) as P; + case 6: + return (reader.readString(offset)) as P; + case 7: + return (_CNotificationMessagementionTypeValueEnumMap[ + reader.readByteOrNull(offset)] ?? + MentionType.users) as P; + case 8: + return (reader.readStringList(offset) ?? []) as P; + case 9: + return (_CNotificationMessagemessageStatusValueEnumMap[ + reader.readByteOrNull(offset)] ?? + NotificationMessageStatus.sent) as P; + case 10: + return (_CNotificationMessagemessageTypeValueEnumMap[ + reader.readByteOrNull(offset)] ?? + MessageType.user) as P; + case 11: + return (reader.readObjectOrNull( + offset, + CNotificationDataSchema.deserialize, + allOffsets, + )) as P; + case 12: + return (reader.readString(offset)) as P; + case 13: + return (reader.readString(offset)) as P; + case 14: + return (reader.readLong(offset)) as P; + default: + throw IsarError('Unknown property with id $propertyId'); + } +} + +const _CNotificationMessagechannelTypeEnumValueMap = { + 'group': 0, + 'open': 1, + 'feed': 2, +}; +const _CNotificationMessagechannelTypeValueEnumMap = { + 0: ChannelType.group, + 1: ChannelType.open, + 2: ChannelType.feed, +}; +const _CNotificationMessagementionTypeEnumValueMap = { + 'users': 0, + 'channel': 1, +}; +const _CNotificationMessagementionTypeValueEnumMap = { + 0: MentionType.users, + 1: MentionType.channel, +}; +const _CNotificationMessagemessageStatusEnumValueMap = { + 'sent': 0, + 'read': 1, +}; +const _CNotificationMessagemessageStatusValueEnumMap = { + 0: NotificationMessageStatus.sent, + 1: NotificationMessageStatus.read, +}; +const _CNotificationMessagemessageTypeEnumValueMap = { + 'user': 0, + 'file': 1, + 'admin': 2, + 'notification': 3, +}; +const _CNotificationMessagemessageTypeValueEnumMap = { + 0: MessageType.user, + 1: MessageType.file, + 2: MessageType.admin, + 3: MessageType.notification, +}; + +Id _cNotificationMessageGetId(CNotificationMessage object) { + return object.id; +} + +List> _cNotificationMessageGetLinks( + CNotificationMessage object) { + return []; +} + +void _cNotificationMessageAttach( + IsarCollection col, Id id, CNotificationMessage object) { + object.id = id; +} + +extension CNotificationMessageByIndex on IsarCollection { + Future getByRootId(String rootId) { + return getByIndex(r'rootId', [rootId]); + } + + CNotificationMessage? getByRootIdSync(String rootId) { + return getByIndexSync(r'rootId', [rootId]); + } + + Future deleteByRootId(String rootId) { + return deleteByIndex(r'rootId', [rootId]); + } + + bool deleteByRootIdSync(String rootId) { + return deleteByIndexSync(r'rootId', [rootId]); + } + + Future> getAllByRootId( + List rootIdValues) { + final values = rootIdValues.map((e) => [e]).toList(); + return getAllByIndex(r'rootId', values); + } + + List getAllByRootIdSync(List rootIdValues) { + final values = rootIdValues.map((e) => [e]).toList(); + return getAllByIndexSync(r'rootId', values); + } + + Future deleteAllByRootId(List rootIdValues) { + final values = rootIdValues.map((e) => [e]).toList(); + return deleteAllByIndex(r'rootId', values); + } + + int deleteAllByRootIdSync(List rootIdValues) { + final values = rootIdValues.map((e) => [e]).toList(); + return deleteAllByIndexSync(r'rootId', values); + } + + Future putByRootId(CNotificationMessage object) { + return putByIndex(r'rootId', object); + } + + Id putByRootIdSync(CNotificationMessage object, {bool saveLinks = true}) { + return putByIndexSync(r'rootId', object, saveLinks: saveLinks); + } + + Future> putAllByRootId(List objects) { + return putAllByIndex(r'rootId', objects); + } + + List putAllByRootIdSync(List objects, + {bool saveLinks = true}) { + return putAllByIndexSync(r'rootId', objects, saveLinks: saveLinks); + } +} + +extension CNotificationMessageQueryWhereSort + on QueryBuilder { + QueryBuilder + anyId() { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(const IdWhereClause.any()); + }); + } +} + +extension CNotificationMessageQueryWhere + on QueryBuilder { + QueryBuilder + idEqualTo(Id id) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IdWhereClause.between( + lower: id, + upper: id, + )); + }); + } + + QueryBuilder + idNotEqualTo(Id id) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause( + IdWhereClause.lessThan(upper: id, includeUpper: false), + ) + .addWhereClause( + IdWhereClause.greaterThan(lower: id, includeLower: false), + ); + } else { + return query + .addWhereClause( + IdWhereClause.greaterThan(lower: id, includeLower: false), + ) + .addWhereClause( + IdWhereClause.lessThan(upper: id, includeUpper: false), + ); + } + }); + } + + QueryBuilder + idGreaterThan(Id id, {bool include = false}) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause( + IdWhereClause.greaterThan(lower: id, includeLower: include), + ); + }); + } + + QueryBuilder + idLessThan(Id id, {bool include = false}) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause( + IdWhereClause.lessThan(upper: id, includeUpper: include), + ); + }); + } + + QueryBuilder + idBetween( + Id lowerId, + Id upperId, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IdWhereClause.between( + lower: lowerId, + includeLower: includeLower, + upper: upperId, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + rootIdEqualTo(String rootId) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.equalTo( + indexName: r'rootId', + value: [rootId], + )); + }); + } + + QueryBuilder + rootIdNotEqualTo(String rootId) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'rootId', + lower: [], + upper: [rootId], + includeUpper: false, + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'rootId', + lower: [rootId], + includeLower: false, + upper: [], + )); + } else { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'rootId', + lower: [rootId], + includeLower: false, + upper: [], + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'rootId', + lower: [], + upper: [rootId], + includeUpper: false, + )); + } + }); + } + + QueryBuilder + messageTypeEqualToAnyRootId(MessageType messageType) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.equalTo( + indexName: r'messageType_rootId', + value: [messageType], + )); + }); + } + + QueryBuilder + messageTypeNotEqualToAnyRootId(MessageType messageType) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'messageType_rootId', + lower: [], + upper: [messageType], + includeUpper: false, + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'messageType_rootId', + lower: [messageType], + includeLower: false, + upper: [], + )); + } else { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'messageType_rootId', + lower: [messageType], + includeLower: false, + upper: [], + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'messageType_rootId', + lower: [], + upper: [messageType], + includeUpper: false, + )); + } + }); + } + + QueryBuilder + messageTypeGreaterThanAnyRootId( + MessageType messageType, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.between( + indexName: r'messageType_rootId', + lower: [messageType], + includeLower: include, + upper: [], + )); + }); + } + + QueryBuilder + messageTypeLessThanAnyRootId( + MessageType messageType, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.between( + indexName: r'messageType_rootId', + lower: [], + upper: [messageType], + includeUpper: include, + )); + }); + } + + QueryBuilder + messageTypeBetweenAnyRootId( + MessageType lowerMessageType, + MessageType upperMessageType, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.between( + indexName: r'messageType_rootId', + lower: [lowerMessageType], + includeLower: includeLower, + upper: [upperMessageType], + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + messageTypeRootIdEqualTo(MessageType messageType, String rootId) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.equalTo( + indexName: r'messageType_rootId', + value: [messageType, rootId], + )); + }); + } + + QueryBuilder + messageTypeEqualToRootIdNotEqualTo( + MessageType messageType, String rootId) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'messageType_rootId', + lower: [messageType], + upper: [messageType, rootId], + includeUpper: false, + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'messageType_rootId', + lower: [messageType, rootId], + includeLower: false, + upper: [messageType], + )); + } else { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'messageType_rootId', + lower: [messageType, rootId], + includeLower: false, + upper: [messageType], + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'messageType_rootId', + lower: [messageType], + upper: [messageType, rootId], + includeUpper: false, + )); + } + }); + } + + QueryBuilder + channelUrlEqualTo(String channelUrl) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.equalTo( + indexName: r'channelUrl', + value: [channelUrl], + )); + }); + } + + QueryBuilder + channelUrlNotEqualTo(String channelUrl) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'channelUrl', + lower: [], + upper: [channelUrl], + includeUpper: false, + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'channelUrl', + lower: [channelUrl], + includeLower: false, + upper: [], + )); + } else { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'channelUrl', + lower: [channelUrl], + includeLower: false, + upper: [], + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'channelUrl', + lower: [], + upper: [channelUrl], + includeUpper: false, + )); + } + }); + } + + QueryBuilder + channelTypeEqualToAnyChannelUrl(ChannelType channelType) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.equalTo( + indexName: r'channelType_channelUrl', + value: [channelType], + )); + }); + } + + QueryBuilder + channelTypeNotEqualToAnyChannelUrl(ChannelType channelType) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'channelType_channelUrl', + lower: [], + upper: [channelType], + includeUpper: false, + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'channelType_channelUrl', + lower: [channelType], + includeLower: false, + upper: [], + )); + } else { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'channelType_channelUrl', + lower: [channelType], + includeLower: false, + upper: [], + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'channelType_channelUrl', + lower: [], + upper: [channelType], + includeUpper: false, + )); + } + }); + } + + QueryBuilder + channelTypeGreaterThanAnyChannelUrl( + ChannelType channelType, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.between( + indexName: r'channelType_channelUrl', + lower: [channelType], + includeLower: include, + upper: [], + )); + }); + } + + QueryBuilder + channelTypeLessThanAnyChannelUrl( + ChannelType channelType, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.between( + indexName: r'channelType_channelUrl', + lower: [], + upper: [channelType], + includeUpper: include, + )); + }); + } + + QueryBuilder + channelTypeBetweenAnyChannelUrl( + ChannelType lowerChannelType, + ChannelType upperChannelType, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.between( + indexName: r'channelType_channelUrl', + lower: [lowerChannelType], + includeLower: includeLower, + upper: [upperChannelType], + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + channelTypeChannelUrlEqualTo(ChannelType channelType, String channelUrl) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.equalTo( + indexName: r'channelType_channelUrl', + value: [channelType, channelUrl], + )); + }); + } + + QueryBuilder + channelTypeEqualToChannelUrlNotEqualTo( + ChannelType channelType, String channelUrl) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'channelType_channelUrl', + lower: [channelType], + upper: [channelType, channelUrl], + includeUpper: false, + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'channelType_channelUrl', + lower: [channelType, channelUrl], + includeLower: false, + upper: [channelType], + )); + } else { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'channelType_channelUrl', + lower: [channelType, channelUrl], + includeLower: false, + upper: [channelType], + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'channelType_channelUrl', + lower: [channelType], + upper: [channelType, channelUrl], + includeUpper: false, + )); + } + }); + } +} + +extension CNotificationMessageQueryFilter on QueryBuilder { + QueryBuilder allMetaArraysIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'allMetaArrays', + )); + }); + } + + QueryBuilder allMetaArraysIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'allMetaArrays', + )); + }); + } + + QueryBuilder allMetaArraysLengthEqualTo(int length) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'allMetaArrays', + length, + true, + length, + true, + ); + }); + } + + QueryBuilder allMetaArraysIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'allMetaArrays', + 0, + true, + 0, + true, + ); + }); + } + + QueryBuilder allMetaArraysIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'allMetaArrays', + 0, + false, + 999999, + true, + ); + }); + } + + QueryBuilder allMetaArraysLengthLessThan( + int length, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'allMetaArrays', + 0, + true, + length, + include, + ); + }); + } + + QueryBuilder allMetaArraysLengthGreaterThan( + int length, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'allMetaArrays', + length, + include, + 999999, + true, + ); + }); + } + + QueryBuilder allMetaArraysLengthBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'allMetaArrays', + lower, + includeLower, + upper, + includeUpper, + ); + }); + } + + QueryBuilder channelTypeEqualTo(ChannelType value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'channelType', + value: value, + )); + }); + } + + QueryBuilder channelTypeGreaterThan( + ChannelType value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'channelType', + value: value, + )); + }); + } + + QueryBuilder channelTypeLessThan( + ChannelType value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'channelType', + value: value, + )); + }); + } + + QueryBuilder channelTypeBetween( + ChannelType lower, + ChannelType upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'channelType', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder channelUrlEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'channelUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder channelUrlGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'channelUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder channelUrlLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'channelUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder channelUrlBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'channelUrl', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder channelUrlStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'channelUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder channelUrlEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'channelUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + channelUrlContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'channelUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + channelUrlMatches(String pattern, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'channelUrl', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder channelUrlIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'channelUrl', + value: '', + )); + }); + } + + QueryBuilder channelUrlIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'channelUrl', + value: '', + )); + }); + } + + QueryBuilder createdAtEqualTo(int value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'createdAt', + value: value, + )); + }); + } + + QueryBuilder createdAtGreaterThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'createdAt', + value: value, + )); + }); + } + + QueryBuilder createdAtLessThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'createdAt', + value: value, + )); + }); + } + + QueryBuilder createdAtBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'createdAt', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder customTypeIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'customType', + )); + }); + } + + QueryBuilder customTypeIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'customType', + )); + }); + } + + QueryBuilder customTypeEqualTo( + String? value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'customType', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder customTypeGreaterThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'customType', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder customTypeLessThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'customType', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder customTypeBetween( + String? lower, + String? upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'customType', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder customTypeStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'customType', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder customTypeEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'customType', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + customTypeContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'customType', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + customTypeMatches(String pattern, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'customType', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder customTypeIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'customType', + value: '', + )); + }); + } + + QueryBuilder customTypeIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'customType', + value: '', + )); + }); + } + + QueryBuilder dataIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'data', + )); + }); + } + + QueryBuilder dataIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'data', + )); + }); + } + + QueryBuilder dataEqualTo( + String? value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'data', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder dataGreaterThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'data', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder dataLessThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'data', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder dataBetween( + String? lower, + String? upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'data', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder dataStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'data', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder dataEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'data', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + dataContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'data', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + dataMatches(String pattern, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'data', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder dataIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'data', + value: '', + )); + }); + } + + QueryBuilder dataIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'data', + value: '', + )); + }); + } + + QueryBuilder extendedMessageEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'extendedMessage', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder extendedMessageGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'extendedMessage', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder extendedMessageLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'extendedMessage', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder extendedMessageBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'extendedMessage', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder extendedMessageStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'extendedMessage', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder extendedMessageEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'extendedMessage', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + extendedMessageContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'extendedMessage', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + extendedMessageMatches(String pattern, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'extendedMessage', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder extendedMessageIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'extendedMessage', + value: '', + )); + }); + } + + QueryBuilder extendedMessageIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'extendedMessage', + value: '', + )); + }); + } + + QueryBuilder idEqualTo(Id value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'id', + value: value, + )); + }); + } + + QueryBuilder idGreaterThan( + Id value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'id', + value: value, + )); + }); + } + + QueryBuilder idLessThan( + Id value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'id', + value: value, + )); + }); + } + + QueryBuilder idBetween( + Id lower, + Id upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'id', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder mentionTypeEqualTo(MentionType value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'mentionType', + value: value, + )); + }); + } + + QueryBuilder mentionTypeGreaterThan( + MentionType value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'mentionType', + value: value, + )); + }); + } + + QueryBuilder mentionTypeLessThan( + MentionType value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'mentionType', + value: value, + )); + }); + } + + QueryBuilder mentionTypeBetween( + MentionType lower, + MentionType upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'mentionType', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder mentionedUsersElementEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'mentionedUsers', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder mentionedUsersElementGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'mentionedUsers', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder mentionedUsersElementLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'mentionedUsers', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder mentionedUsersElementBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'mentionedUsers', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder mentionedUsersElementStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'mentionedUsers', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder mentionedUsersElementEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'mentionedUsers', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + mentionedUsersElementContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'mentionedUsers', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + mentionedUsersElementMatches(String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'mentionedUsers', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder mentionedUsersElementIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'mentionedUsers', + value: '', + )); + }); + } + + QueryBuilder mentionedUsersElementIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'mentionedUsers', + value: '', + )); + }); + } + + QueryBuilder mentionedUsersLengthEqualTo(int length) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'mentionedUsers', + length, + true, + length, + true, + ); + }); + } + + QueryBuilder mentionedUsersIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'mentionedUsers', + 0, + true, + 0, + true, + ); + }); + } + + QueryBuilder mentionedUsersIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'mentionedUsers', + 0, + false, + 999999, + true, + ); + }); + } + + QueryBuilder mentionedUsersLengthLessThan( + int length, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'mentionedUsers', + 0, + true, + length, + include, + ); + }); + } + + QueryBuilder mentionedUsersLengthGreaterThan( + int length, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'mentionedUsers', + length, + include, + 999999, + true, + ); + }); + } + + QueryBuilder mentionedUsersLengthBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'mentionedUsers', + lower, + includeLower, + upper, + includeUpper, + ); + }); + } + + QueryBuilder + messageStatusEqualTo(NotificationMessageStatus value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'messageStatus', + value: value, + )); + }); + } + + QueryBuilder messageStatusGreaterThan( + NotificationMessageStatus value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'messageStatus', + value: value, + )); + }); + } + + QueryBuilder messageStatusLessThan( + NotificationMessageStatus value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'messageStatus', + value: value, + )); + }); + } + + QueryBuilder messageStatusBetween( + NotificationMessageStatus lower, + NotificationMessageStatus upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'messageStatus', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder messageTypeEqualTo(MessageType value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'messageType', + value: value, + )); + }); + } + + QueryBuilder messageTypeGreaterThan( + MessageType value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'messageType', + value: value, + )); + }); + } + + QueryBuilder messageTypeLessThan( + MessageType value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'messageType', + value: value, + )); + }); + } + + QueryBuilder messageTypeBetween( + MessageType lower, + MessageType upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'messageType', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder notificationDataIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'notificationData', + )); + }); + } + + QueryBuilder notificationDataIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'notificationData', + )); + }); + } + + QueryBuilder notificationIdEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'notificationId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder notificationIdGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'notificationId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder notificationIdLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'notificationId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder notificationIdBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'notificationId', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder notificationIdStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'notificationId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder notificationIdEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'notificationId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + notificationIdContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'notificationId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + notificationIdMatches(String pattern, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'notificationId', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder notificationIdIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'notificationId', + value: '', + )); + }); + } + + QueryBuilder notificationIdIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'notificationId', + value: '', + )); + }); + } + + QueryBuilder rootIdEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'rootId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder rootIdGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'rootId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder rootIdLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'rootId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder rootIdBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'rootId', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder rootIdStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'rootId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder rootIdEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'rootId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + rootIdContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'rootId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + rootIdMatches(String pattern, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'rootId', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder rootIdIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'rootId', + value: '', + )); + }); + } + + QueryBuilder rootIdIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'rootId', + value: '', + )); + }); + } + + QueryBuilder updatedAtEqualTo(int value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'updatedAt', + value: value, + )); + }); + } + + QueryBuilder updatedAtGreaterThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'updatedAt', + value: value, + )); + }); + } + + QueryBuilder updatedAtLessThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'updatedAt', + value: value, + )); + }); + } + + QueryBuilder updatedAtBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'updatedAt', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } +} + +extension CNotificationMessageQueryObject on QueryBuilder { + QueryBuilder + allMetaArraysElement(FilterQuery q) { + return QueryBuilder.apply(this, (query) { + return query.object(q, r'allMetaArrays'); + }); + } + + QueryBuilder + notificationData(FilterQuery q) { + return QueryBuilder.apply(this, (query) { + return query.object(q, r'notificationData'); + }); + } +} + +extension CNotificationMessageQueryLinks on QueryBuilder {} + +extension CNotificationMessageQuerySortBy + on QueryBuilder { + QueryBuilder + sortByChannelType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'channelType', Sort.asc); + }); + } + + QueryBuilder + sortByChannelTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'channelType', Sort.desc); + }); + } + + QueryBuilder + sortByChannelUrl() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'channelUrl', Sort.asc); + }); + } + + QueryBuilder + sortByChannelUrlDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'channelUrl', Sort.desc); + }); + } + + QueryBuilder + sortByCreatedAt() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'createdAt', Sort.asc); + }); + } + + QueryBuilder + sortByCreatedAtDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'createdAt', Sort.desc); + }); + } + + QueryBuilder + sortByCustomType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'customType', Sort.asc); + }); + } + + QueryBuilder + sortByCustomTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'customType', Sort.desc); + }); + } + + QueryBuilder + sortByData() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'data', Sort.asc); + }); + } + + QueryBuilder + sortByDataDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'data', Sort.desc); + }); + } + + QueryBuilder + sortByExtendedMessage() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'extendedMessage', Sort.asc); + }); + } + + QueryBuilder + sortByExtendedMessageDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'extendedMessage', Sort.desc); + }); + } + + QueryBuilder + sortByMentionType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'mentionType', Sort.asc); + }); + } + + QueryBuilder + sortByMentionTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'mentionType', Sort.desc); + }); + } + + QueryBuilder + sortByMessageStatus() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'messageStatus', Sort.asc); + }); + } + + QueryBuilder + sortByMessageStatusDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'messageStatus', Sort.desc); + }); + } + + QueryBuilder + sortByMessageType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'messageType', Sort.asc); + }); + } + + QueryBuilder + sortByMessageTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'messageType', Sort.desc); + }); + } + + QueryBuilder + sortByNotificationId() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'notificationId', Sort.asc); + }); + } + + QueryBuilder + sortByNotificationIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'notificationId', Sort.desc); + }); + } + + QueryBuilder + sortByRootId() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'rootId', Sort.asc); + }); + } + + QueryBuilder + sortByRootIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'rootId', Sort.desc); + }); + } + + QueryBuilder + sortByUpdatedAt() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'updatedAt', Sort.asc); + }); + } + + QueryBuilder + sortByUpdatedAtDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'updatedAt', Sort.desc); + }); + } +} + +extension CNotificationMessageQuerySortThenBy + on QueryBuilder { + QueryBuilder + thenByChannelType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'channelType', Sort.asc); + }); + } + + QueryBuilder + thenByChannelTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'channelType', Sort.desc); + }); + } + + QueryBuilder + thenByChannelUrl() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'channelUrl', Sort.asc); + }); + } + + QueryBuilder + thenByChannelUrlDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'channelUrl', Sort.desc); + }); + } + + QueryBuilder + thenByCreatedAt() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'createdAt', Sort.asc); + }); + } + + QueryBuilder + thenByCreatedAtDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'createdAt', Sort.desc); + }); + } + + QueryBuilder + thenByCustomType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'customType', Sort.asc); + }); + } + + QueryBuilder + thenByCustomTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'customType', Sort.desc); + }); + } + + QueryBuilder + thenByData() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'data', Sort.asc); + }); + } + + QueryBuilder + thenByDataDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'data', Sort.desc); + }); + } + + QueryBuilder + thenByExtendedMessage() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'extendedMessage', Sort.asc); + }); + } + + QueryBuilder + thenByExtendedMessageDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'extendedMessage', Sort.desc); + }); + } + + QueryBuilder + thenById() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'id', Sort.asc); + }); + } + + QueryBuilder + thenByIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'id', Sort.desc); + }); + } + + QueryBuilder + thenByMentionType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'mentionType', Sort.asc); + }); + } + + QueryBuilder + thenByMentionTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'mentionType', Sort.desc); + }); + } + + QueryBuilder + thenByMessageStatus() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'messageStatus', Sort.asc); + }); + } + + QueryBuilder + thenByMessageStatusDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'messageStatus', Sort.desc); + }); + } + + QueryBuilder + thenByMessageType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'messageType', Sort.asc); + }); + } + + QueryBuilder + thenByMessageTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'messageType', Sort.desc); + }); + } + + QueryBuilder + thenByNotificationId() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'notificationId', Sort.asc); + }); + } + + QueryBuilder + thenByNotificationIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'notificationId', Sort.desc); + }); + } + + QueryBuilder + thenByRootId() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'rootId', Sort.asc); + }); + } + + QueryBuilder + thenByRootIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'rootId', Sort.desc); + }); + } + + QueryBuilder + thenByUpdatedAt() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'updatedAt', Sort.asc); + }); + } + + QueryBuilder + thenByUpdatedAtDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'updatedAt', Sort.desc); + }); + } +} + +extension CNotificationMessageQueryWhereDistinct + on QueryBuilder { + QueryBuilder + distinctByChannelType() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'channelType'); + }); + } + + QueryBuilder + distinctByChannelUrl({bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'channelUrl', caseSensitive: caseSensitive); + }); + } + + QueryBuilder + distinctByCreatedAt() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'createdAt'); + }); + } + + QueryBuilder + distinctByCustomType({bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'customType', caseSensitive: caseSensitive); + }); + } + + QueryBuilder + distinctByData({bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'data', caseSensitive: caseSensitive); + }); + } + + QueryBuilder + distinctByExtendedMessage({bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'extendedMessage', + caseSensitive: caseSensitive); + }); + } + + QueryBuilder + distinctByMentionType() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'mentionType'); + }); + } + + QueryBuilder + distinctByMentionedUsers() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'mentionedUsers'); + }); + } + + QueryBuilder + distinctByMessageStatus() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'messageStatus'); + }); + } + + QueryBuilder + distinctByMessageType() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'messageType'); + }); + } + + QueryBuilder + distinctByNotificationId({bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'notificationId', + caseSensitive: caseSensitive); + }); + } + + QueryBuilder + distinctByRootId({bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'rootId', caseSensitive: caseSensitive); + }); + } + + QueryBuilder + distinctByUpdatedAt() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'updatedAt'); + }); + } +} + +extension CNotificationMessageQueryProperty on QueryBuilder< + CNotificationMessage, CNotificationMessage, QQueryProperty> { + QueryBuilder idProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'id'); + }); + } + + QueryBuilder?, QQueryOperations> + allMetaArraysProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'allMetaArrays'); + }); + } + + QueryBuilder + channelTypeProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'channelType'); + }); + } + + QueryBuilder + channelUrlProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'channelUrl'); + }); + } + + QueryBuilder + createdAtProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'createdAt'); + }); + } + + QueryBuilder + customTypeProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'customType'); + }); + } + + QueryBuilder dataProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'data'); + }); + } + + QueryBuilder + extendedMessageProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'extendedMessage'); + }); + } + + QueryBuilder + mentionTypeProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'mentionType'); + }); + } + + QueryBuilder, QQueryOperations> + mentionedUsersProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'mentionedUsers'); + }); + } + + QueryBuilder messageStatusProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'messageStatus'); + }); + } + + QueryBuilder + messageTypeProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'messageType'); + }); + } + + QueryBuilder + notificationDataProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'notificationData'); + }); + } + + QueryBuilder + notificationIdProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'notificationId'); + }); + } + + QueryBuilder + rootIdProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'rootId'); + }); + } + + QueryBuilder + updatedAtProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'updatedAt'); + }); + } +} + +// ************************************************************************** +// IsarEmbeddedGenerator +// ************************************************************************** + +// coverage:ignore-file +// ignore_for_file: duplicate_ignore, non_constant_identifier_names, constant_identifier_names, invalid_use_of_protected_member, unnecessary_cast, prefer_const_constructors, lines_longer_than_80_chars, require_trailing_commas, inference_failure_on_function_invocation, unnecessary_parenthesis, unnecessary_raw_strings, unnecessary_null_checks, join_return_with_assignment, prefer_final_locals, avoid_js_rounded_ints, avoid_positional_boolean_parameters, always_specify_types + +final CNotificationDataSchema = Schema( + name: r'CNotificationData', + id: BigInt.parse('6301434927396286571').toInt(), + properties: { + r'label': PropertySchema( + id: 0, + name: r'label', + type: IsarType.string, + ), + r'tags': PropertySchema( + id: 1, + name: r'tags', + type: IsarType.stringList, + ), + r'templateKey': PropertySchema( + id: 2, + name: r'templateKey', + type: IsarType.string, + ), + r'templateVariables': PropertySchema( + id: 3, + name: r'templateVariables', + type: IsarType.string, + ) + }, + estimateSize: _cNotificationDataEstimateSize, + serialize: _cNotificationDataSerialize, + deserialize: _cNotificationDataDeserialize, + deserializeProp: _cNotificationDataDeserializeProp, +); + +int _cNotificationDataEstimateSize( + CNotificationData object, + List offsets, + Map> allOffsets, +) { + var bytesCount = offsets.last; + { + final value = object.label; + if (value != null) { + bytesCount += 3 + value.length * 3; + } + } + { + final list = object.tags; + if (list != null) { + bytesCount += 3 + list.length * 3; + { + for (var i = 0; i < list.length; i++) { + final value = list[i]; + bytesCount += value.length * 3; + } + } + } + } + bytesCount += 3 + object.templateKey.length * 3; + bytesCount += 3 + object.templateVariables.length * 3; + return bytesCount; +} + +void _cNotificationDataSerialize( + CNotificationData object, + IsarWriter writer, + List offsets, + Map> allOffsets, +) { + writer.writeString(offsets[0], object.label); + writer.writeStringList(offsets[1], object.tags); + writer.writeString(offsets[2], object.templateKey); + writer.writeString(offsets[3], object.templateVariables); +} + +CNotificationData _cNotificationDataDeserialize( + Id id, + IsarReader reader, + List offsets, + Map> allOffsets, +) { + final object = CNotificationData(); + object.label = reader.readStringOrNull(offsets[0]); + object.tags = reader.readStringList(offsets[1]); + object.templateKey = reader.readString(offsets[2]); + object.templateVariables = reader.readString(offsets[3]); + return object; +} + +P _cNotificationDataDeserializeProp

( + IsarReader reader, + int propertyId, + int offset, + Map> allOffsets, +) { + switch (propertyId) { + case 0: + return (reader.readStringOrNull(offset)) as P; + case 1: + return (reader.readStringList(offset)) as P; + case 2: + return (reader.readString(offset)) as P; + case 3: + return (reader.readString(offset)) as P; + default: + throw IsarError('Unknown property with id $propertyId'); + } +} + +extension CNotificationDataQueryFilter + on QueryBuilder { + QueryBuilder + labelIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'label', + )); + }); + } + + QueryBuilder + labelIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'label', + )); + }); + } + + QueryBuilder + labelEqualTo( + String? value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'label', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + labelGreaterThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'label', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + labelLessThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'label', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + labelBetween( + String? lower, + String? upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'label', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + labelStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'label', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + labelEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'label', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + labelContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'label', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + labelMatches(String pattern, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'label', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + labelIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'label', + value: '', + )); + }); + } + + QueryBuilder + labelIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'label', + value: '', + )); + }); + } + + QueryBuilder + tagsIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'tags', + )); + }); + } + + QueryBuilder + tagsIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'tags', + )); + }); + } + + QueryBuilder + tagsElementEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'tags', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + tagsElementGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'tags', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + tagsElementLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'tags', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + tagsElementBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'tags', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + tagsElementStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'tags', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + tagsElementEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'tags', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + tagsElementContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'tags', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + tagsElementMatches(String pattern, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'tags', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + tagsElementIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'tags', + value: '', + )); + }); + } + + QueryBuilder + tagsElementIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'tags', + value: '', + )); + }); + } + + QueryBuilder + tagsLengthEqualTo(int length) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'tags', + length, + true, + length, + true, + ); + }); + } + + QueryBuilder + tagsIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'tags', + 0, + true, + 0, + true, + ); + }); + } + + QueryBuilder + tagsIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'tags', + 0, + false, + 999999, + true, + ); + }); + } + + QueryBuilder + tagsLengthLessThan( + int length, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'tags', + 0, + true, + length, + include, + ); + }); + } + + QueryBuilder + tagsLengthGreaterThan( + int length, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'tags', + length, + include, + 999999, + true, + ); + }); + } + + QueryBuilder + tagsLengthBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'tags', + lower, + includeLower, + upper, + includeUpper, + ); + }); + } + + QueryBuilder + templateKeyEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'templateKey', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + templateKeyGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'templateKey', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + templateKeyLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'templateKey', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + templateKeyBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'templateKey', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + templateKeyStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'templateKey', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + templateKeyEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'templateKey', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + templateKeyContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'templateKey', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + templateKeyMatches(String pattern, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'templateKey', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + templateKeyIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'templateKey', + value: '', + )); + }); + } + + QueryBuilder + templateKeyIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'templateKey', + value: '', + )); + }); + } + + QueryBuilder + templateVariablesEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'templateVariables', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + templateVariablesGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'templateVariables', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + templateVariablesLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'templateVariables', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + templateVariablesBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'templateVariables', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + templateVariablesStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'templateVariables', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + templateVariablesEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'templateVariables', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + templateVariablesContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'templateVariables', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + templateVariablesMatches(String pattern, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'templateVariables', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + templateVariablesIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'templateVariables', + value: '', + )); + }); + } + + QueryBuilder + templateVariablesIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'templateVariables', + value: '', + )); + }); + } +} + +extension CNotificationDataQueryObject + on QueryBuilder {} diff --git a/lib/src/internal/db/schema/message/c_root_message.dart b/lib/src/internal/db/schema/message/c_root_message.dart new file mode 100644 index 00000000..d3d6a694 --- /dev/null +++ b/lib/src/internal/db/schema/message/c_root_message.dart @@ -0,0 +1,127 @@ +// Copyright (c) 2023 Sendbird, Inc. All rights reserved. + +import 'dart:convert'; + +import 'package:isar/isar.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/user/c_user.dart'; +import 'package:sendbird_chat_sdk/src/internal/main/chat/chat.dart'; +import 'package:sendbird_chat_sdk/src/public/core/message/root_message.dart'; +import 'package:sendbird_chat_sdk/src/public/main/define/enums.dart'; +import 'package:sendbird_chat_sdk/src/public/main/model/message/message_meta_array.dart'; + +part 'c_root_message.g.dart'; + +class CRootMessage { + Id id = Isar.autoIncrement; + + @Index(unique: true, replace: true) + late String rootId; + + @Index(composite: [CompositeIndex('rootId')]) + @enumerated + late MessageType messageType; + + @Index() + late String channelUrl; + + @Index(composite: [CompositeIndex('channelUrl')]) + @enumerated + late ChannelType channelType; + + String? data; + String? customType; + + @enumerated + late MentionType mentionType; + + late List mentionedUsers; // List + List? allMetaArrays; + late String extendedMessage; // Map + late int createdAt; + late int updatedAt; + + CRootMessage(); + + factory CRootMessage.fromRootMessage(RootMessage message) { + return CRootMessage()..setRootMessage(message); + } + + void setRootMessage(RootMessage message) { + rootId = message.rootId; + messageType = message.messageType; + channelUrl = message.channelUrl; + channelType = message.channelType; + data = message.data; + customType = message.customType; + mentionType = message.mentionType; + mentionedUsers = message.mentionedUsers.map((user) => user.userId).toList(); + allMetaArrays = message.allMetaArrays + ?.map((array) => CMessageMetaArray.fromMessageMetaArray(array)) + .toList(); + extendedMessage = jsonEncode(message.extendedMessage); + createdAt = message.createdAt; + updatedAt = message.updatedAt; + } + + Future toRootMessage(Chat chat, Isar isar) async { + final rootMessage = RootMessage( + channelUrl: channelUrl, + channelType: channelType, + )..set(chat); + return setCRootMessage(chat, isar, rootMessage, this); + } + + static Future setCRootMessage( + Chat chat, + Isar isar, + RootMessage rootMessage, + CRootMessage cRootMessage, + ) async { + rootMessage + ..data = cRootMessage.data + ..customType = cRootMessage.customType + ..mentionType = cRootMessage.mentionType + ..allMetaArrays = cRootMessage.allMetaArrays + ?.map((cArray) => cArray.toMessageMetaArray()) + .toList() + ..extendedMessage = + jsonDecode(cRootMessage.extendedMessage) as Map + ..createdAt = cRootMessage.createdAt + ..updatedAt = cRootMessage.updatedAt; + + for (final userId in cRootMessage.mentionedUsers) { + final user = await CUser.get(chat, isar, userId); + if (user != null) { + rootMessage.mentionedUsers.add(user); + } + } + return rootMessage; + } + + static Future upsert(Chat chat, Isar isar, RootMessage message) async { + await chat.dbManager.write(() async { + // mentionedUsers + for (final user in message.mentionedUsers) { + await isar.cUsers.put(CUser.fromUser(user)); + } + }); + } +} + +@embedded +class CMessageMetaArray { + late String key; + late List value; + + CMessageMetaArray(); + + factory CMessageMetaArray.fromMessageMetaArray(MessageMetaArray array) { + return CMessageMetaArray() + ..key = array.key + ..value = array.value; + } + + MessageMetaArray toMessageMetaArray() { + return MessageMetaArray(key: key)..value = value; + } +} diff --git a/lib/src/internal/db/schema/message/c_root_message.g.dart b/lib/src/internal/db/schema/message/c_root_message.g.dart new file mode 100644 index 00000000..4e4e14b9 --- /dev/null +++ b/lib/src/internal/db/schema/message/c_root_message.g.dart @@ -0,0 +1,453 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'c_root_message.dart'; + +// ************************************************************************** +// IsarEmbeddedGenerator +// ************************************************************************** + +// coverage:ignore-file +// ignore_for_file: duplicate_ignore, non_constant_identifier_names, constant_identifier_names, invalid_use_of_protected_member, unnecessary_cast, prefer_const_constructors, lines_longer_than_80_chars, require_trailing_commas, inference_failure_on_function_invocation, unnecessary_parenthesis, unnecessary_raw_strings, unnecessary_null_checks, join_return_with_assignment, prefer_final_locals, avoid_js_rounded_ints, avoid_positional_boolean_parameters, always_specify_types + +final CMessageMetaArraySchema = Schema( + name: r'CMessageMetaArray', + id: BigInt.parse('-553637275424192285').toInt(), + properties: { + r'key': PropertySchema( + id: 0, + name: r'key', + type: IsarType.string, + ), + r'value': PropertySchema( + id: 1, + name: r'value', + type: IsarType.stringList, + ) + }, + estimateSize: _cMessageMetaArrayEstimateSize, + serialize: _cMessageMetaArraySerialize, + deserialize: _cMessageMetaArrayDeserialize, + deserializeProp: _cMessageMetaArrayDeserializeProp, +); + +int _cMessageMetaArrayEstimateSize( + CMessageMetaArray object, + List offsets, + Map> allOffsets, +) { + var bytesCount = offsets.last; + bytesCount += 3 + object.key.length * 3; + bytesCount += 3 + object.value.length * 3; + { + for (var i = 0; i < object.value.length; i++) { + final value = object.value[i]; + bytesCount += value.length * 3; + } + } + return bytesCount; +} + +void _cMessageMetaArraySerialize( + CMessageMetaArray object, + IsarWriter writer, + List offsets, + Map> allOffsets, +) { + writer.writeString(offsets[0], object.key); + writer.writeStringList(offsets[1], object.value); +} + +CMessageMetaArray _cMessageMetaArrayDeserialize( + Id id, + IsarReader reader, + List offsets, + Map> allOffsets, +) { + final object = CMessageMetaArray(); + object.key = reader.readString(offsets[0]); + object.value = reader.readStringList(offsets[1]) ?? []; + return object; +} + +P _cMessageMetaArrayDeserializeProp

( + IsarReader reader, + int propertyId, + int offset, + Map> allOffsets, +) { + switch (propertyId) { + case 0: + return (reader.readString(offset)) as P; + case 1: + return (reader.readStringList(offset) ?? []) as P; + default: + throw IsarError('Unknown property with id $propertyId'); + } +} + +extension CMessageMetaArrayQueryFilter + on QueryBuilder { + QueryBuilder + keyEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'key', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + keyGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'key', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + keyLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'key', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + keyBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'key', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + keyStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'key', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + keyEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'key', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + keyContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'key', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + keyMatches(String pattern, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'key', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + keyIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'key', + value: '', + )); + }); + } + + QueryBuilder + keyIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'key', + value: '', + )); + }); + } + + QueryBuilder + valueElementEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'value', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + valueElementGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'value', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + valueElementLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'value', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + valueElementBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'value', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + valueElementStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'value', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + valueElementEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'value', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + valueElementContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'value', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + valueElementMatches(String pattern, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'value', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + valueElementIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'value', + value: '', + )); + }); + } + + QueryBuilder + valueElementIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'value', + value: '', + )); + }); + } + + QueryBuilder + valueLengthEqualTo(int length) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'value', + length, + true, + length, + true, + ); + }); + } + + QueryBuilder + valueIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'value', + 0, + true, + 0, + true, + ); + }); + } + + QueryBuilder + valueIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'value', + 0, + false, + 999999, + true, + ); + }); + } + + QueryBuilder + valueLengthLessThan( + int length, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'value', + 0, + true, + length, + include, + ); + }); + } + + QueryBuilder + valueLengthGreaterThan( + int length, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'value', + length, + include, + 999999, + true, + ); + }); + } + + QueryBuilder + valueLengthBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'value', + lower, + includeLower, + upper, + includeUpper, + ); + }); + } +} + +extension CMessageMetaArrayQueryObject + on QueryBuilder {} diff --git a/lib/src/internal/db/schema/message/c_user_message.dart b/lib/src/internal/db/schema/message/c_user_message.dart new file mode 100644 index 00000000..3be00f5c --- /dev/null +++ b/lib/src/internal/db/schema/message/c_user_message.dart @@ -0,0 +1,206 @@ +// Copyright (c) 2023 Sendbird, Inc. All rights reserved. + +import 'dart:convert'; + +import 'package:isar/isar.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/message/c_base_message.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/message/c_root_message.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/message/meta/c_channel_message.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/user/c_sender.dart'; +import 'package:sendbird_chat_sdk/src/internal/main/chat/chat.dart'; +import 'package:sendbird_chat_sdk/src/public/core/message/root_message.dart'; +import 'package:sendbird_chat_sdk/src/public/core/message/user_message.dart'; +import 'package:sendbird_chat_sdk/src/public/main/define/enums.dart'; +import 'package:sendbird_chat_sdk/src/public/main/model/poll/poll.dart'; +import 'package:sendbird_chat_sdk/src/public/main/model/poll/poll_data.dart'; +import 'package:sendbird_chat_sdk/src/public/main/model/poll/poll_option.dart'; + +part 'c_user_message.g.dart'; + +@collection +class CUserMessage extends CBaseMessage { + late String translations; // Map + List? translationTargetLanguages; + CPoll? poll; + + CUserMessage(); + + factory CUserMessage.fromUserMessage(UserMessage message) { + return CUserMessage() + // BaseMessage + ..setBaseMessage(message) + // UserMessage + ..translations = jsonEncode(message.translations) + ..translationTargetLanguages = message.translationTargetLanguages + ..poll = message.poll != null ? CPoll.fromPoll(message.poll!) : null; + } + + Future toUserMessage(Chat chat, Isar isar) async { + final userMessage = UserMessage( + // RootMessage + channelUrl: channelUrl, + channelType: channelType, + // BaseMessage + messageId: messageId, + message: message, + // UserMessage + translations: (jsonDecode(translations) as Map) + .map((key, value) => MapEntry(key, value.toString())), + )..set(chat); + return await CBaseMessage.setCBaseMessage(chat, isar, userMessage, this) + as UserMessage + // UserMessage + ..translationTargetLanguages = translationTargetLanguages + ..poll = poll?.toPoll(); + } + + static Future upsert( + Chat chat, Isar isar, UserMessage message) async { + final cUserMessage = CUserMessage.fromUserMessage(message); + + // RootMessage + await CRootMessage.upsert(chat, isar, message); + + // BaseMessage + await CBaseMessage.upsert(chat, isar, message); + + // UserMessage + await chat.dbManager.write(() async { + await isar.cUserMessages.put(cUserMessage); + }); + + // ChannelMessage + await CChannelMessage.upsert(chat, isar, message); + + return cUserMessage; + } + + static Future get(Chat chat, Isar isar, String rootId) async { + final cUserMessage = + await isar.cUserMessages.where().rootIdEqualTo(rootId).findFirst(); + return await cUserMessage?.toUserMessage(chat, isar); + } + + static Future delete(Chat chat, Isar isar, String rootId) async { + // UserMessage + await chat.dbManager.write(() async { + await isar.cUserMessages.deleteByRootId(rootId); + }); + + // ChannelMessage + await CChannelMessage.delete(chat, isar, rootId); + } +} + +@embedded +class CPoll { + late int id; + late String title; + late int createdAt; + late int updatedAt; + late int closeAt; + + @enumerated + late PollStatus status; + + int? messageId; + CPollData? data; + late int voterCount; + late List options; + + String? createdBy; + late bool allowUserSuggestion; + late bool allowMultipleVotes; + List? votedPollOptionIds; + + CPoll(); + + factory CPoll.fromPoll(Poll poll) { + return CPoll() + ..id = poll.id + ..title = poll.title + ..createdAt = poll.createdAt + ..updatedAt = poll.updatedAt + ..closeAt = poll.closeAt + ..status = poll.status + ..messageId = poll.messageId + ..data = poll.data != null ? CPollData.fromPollData(poll.data!) : null + ..voterCount = poll.voterCount + ..options = poll.options + .map((option) => CPollOption.fromPollOption(option)) + .toList() + ..createdBy = poll.createdBy + ..allowUserSuggestion = poll.allowUserSuggestion + ..allowMultipleVotes = poll.allowMultipleVotes + ..votedPollOptionIds = poll.votedPollOptionIds; + } + + Poll toPoll() { + return Poll( + id: id, + title: title, + createdAt: createdAt, + updatedAt: updatedAt, + closeAt: closeAt, + status: status, + ) + ..messageId = messageId + ..data = data?.toPollData() + ..voterCount = voterCount + ..options = options.map((option) => option.toPollOption()).toList() + ..createdBy = createdBy + ..allowUserSuggestion = allowUserSuggestion + ..allowMultipleVotes = allowMultipleVotes + ..votedPollOptionIds = votedPollOptionIds; + } +} + +@embedded +class CPollData { + late String text; + + CPollData(); + + factory CPollData.fromPollData(PollData data) { + return CPollData()..text = data.text; + } + + PollData toPollData() { + return PollData()..text = text; + } +} + +@embedded +class CPollOption { + late int pollId; + late int id; + late String text; + String? createdBy; + late int createdAt; + late int voteCount; + late int updatedAt; + + CPollOption(); + + factory CPollOption.fromPollOption(PollOption option) { + return CPollOption() + ..pollId = option.pollId + ..id = option.id + ..text = option.text + ..createdBy = option.createdBy + ..createdAt = option.createdAt + ..voteCount = option.voteCount + ..updatedAt = option.updatedAt; + } + + PollOption toPollOption() { + return PollOption( + pollId: pollId, + id: id, + text: text, + createdAt: createdAt, + voteCount: voteCount, + updatedAt: updatedAt, + )..createdBy = createdBy; + } +} diff --git a/lib/src/internal/db/schema/message/c_user_message.g.dart b/lib/src/internal/db/schema/message/c_user_message.g.dart new file mode 100644 index 00000000..00b1230e --- /dev/null +++ b/lib/src/internal/db/schema/message/c_user_message.g.dart @@ -0,0 +1,7230 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'c_user_message.dart'; + +// ************************************************************************** +// IsarCollectionGenerator +// ************************************************************************** + +// coverage:ignore-file +// ignore_for_file: duplicate_ignore, non_constant_identifier_names, constant_identifier_names, invalid_use_of_protected_member, unnecessary_cast, prefer_const_constructors, lines_longer_than_80_chars, require_trailing_commas, inference_failure_on_function_invocation, unnecessary_parenthesis, unnecessary_raw_strings, unnecessary_null_checks, join_return_with_assignment, prefer_final_locals, avoid_js_rounded_ints, avoid_positional_boolean_parameters, always_specify_types + +extension GetCUserMessageCollection on Isar { + IsarCollection get cUserMessages => this.collection(); +} + +final CUserMessageSchema = CollectionSchema( + name: r'CUserMessage', + id: BigInt.parse('-5236260095734839382').toInt(), + properties: { + r'allMetaArrays': PropertySchema( + id: 0, + name: r'allMetaArrays', + type: IsarType.objectList, + target: r'CMessageMetaArray', + ), + r'channelType': PropertySchema( + id: 1, + name: r'channelType', + type: IsarType.byte, + enumMap: _CUserMessagechannelTypeEnumValueMap, + ), + r'channelUrl': PropertySchema( + id: 2, + name: r'channelUrl', + type: IsarType.string, + ), + r'createdAt': PropertySchema( + id: 3, + name: r'createdAt', + type: IsarType.long, + ), + r'customType': PropertySchema( + id: 4, + name: r'customType', + type: IsarType.string, + ), + r'data': PropertySchema( + id: 5, + name: r'data', + type: IsarType.string, + ), + r'errorCode': PropertySchema( + id: 6, + name: r'errorCode', + type: IsarType.long, + ), + r'extendedMessage': PropertySchema( + id: 7, + name: r'extendedMessage', + type: IsarType.string, + ), + r'isOperatorMessage': PropertySchema( + id: 8, + name: r'isOperatorMessage', + type: IsarType.bool, + ), + r'isReplyToChannel': PropertySchema( + id: 9, + name: r'isReplyToChannel', + type: IsarType.bool, + ), + r'isSilent': PropertySchema( + id: 10, + name: r'isSilent', + type: IsarType.bool, + ), + r'mentionType': PropertySchema( + id: 11, + name: r'mentionType', + type: IsarType.byte, + enumMap: _CUserMessagementionTypeEnumValueMap, + ), + r'mentionedUsers': PropertySchema( + id: 12, + name: r'mentionedUsers', + type: IsarType.stringList, + ), + r'message': PropertySchema( + id: 13, + name: r'message', + type: IsarType.string, + ), + r'messageId': PropertySchema( + id: 14, + name: r'messageId', + type: IsarType.long, + ), + r'messageSurvivalSeconds': PropertySchema( + id: 15, + name: r'messageSurvivalSeconds', + type: IsarType.long, + ), + r'messageType': PropertySchema( + id: 16, + name: r'messageType', + type: IsarType.byte, + enumMap: _CUserMessagemessageTypeEnumValueMap, + ), + r'ogMetaData': PropertySchema( + id: 17, + name: r'ogMetaData', + type: IsarType.object, + target: r'COGMetaData', + ), + r'parentMessageId': PropertySchema( + id: 18, + name: r'parentMessageId', + type: IsarType.long, + ), + r'parentMessageRootId': PropertySchema( + id: 19, + name: r'parentMessageRootId', + type: IsarType.string, + ), + r'parentMessageType': PropertySchema( + id: 20, + name: r'parentMessageType', + type: IsarType.byte, + enumMap: _CUserMessageparentMessageTypeEnumValueMap, + ), + r'poll': PropertySchema( + id: 21, + name: r'poll', + type: IsarType.object, + target: r'CPoll', + ), + r'reactions': PropertySchema( + id: 22, + name: r'reactions', + type: IsarType.objectList, + target: r'CReaction', + ), + r'requestId': PropertySchema( + id: 23, + name: r'requestId', + type: IsarType.string, + ), + r'rootId': PropertySchema( + id: 24, + name: r'rootId', + type: IsarType.string, + ), + r'scheduledInfo': PropertySchema( + id: 25, + name: r'scheduledInfo', + type: IsarType.object, + target: r'CScheduledInfo', + ), + r'sender': PropertySchema( + id: 26, + name: r'sender', + type: IsarType.object, + target: r'CSender', + ), + r'sendingStatus': PropertySchema( + id: 27, + name: r'sendingStatus', + type: IsarType.byte, + enumMap: _CUserMessagesendingStatusEnumValueMap, + ), + r'threadInfo': PropertySchema( + id: 28, + name: r'threadInfo', + type: IsarType.object, + target: r'CThreadInfo', + ), + r'translationTargetLanguages': PropertySchema( + id: 29, + name: r'translationTargetLanguages', + type: IsarType.stringList, + ), + r'translations': PropertySchema( + id: 30, + name: r'translations', + type: IsarType.string, + ), + r'updatedAt': PropertySchema( + id: 31, + name: r'updatedAt', + type: IsarType.long, + ) + }, + estimateSize: _cUserMessageEstimateSize, + serialize: _cUserMessageSerialize, + deserialize: _cUserMessageDeserialize, + deserializeProp: _cUserMessageDeserializeProp, + idName: r'id', + indexes: { + r'rootId': IndexSchema( + id: BigInt.parse('5087693435549841488').toInt(), + name: r'rootId', + unique: true, + replace: true, + properties: [ + IndexPropertySchema( + name: r'rootId', + type: IndexType.hash, + caseSensitive: true, + ) + ], + ), + r'messageType_rootId': IndexSchema( + id: BigInt.parse('-7060804333380842370').toInt(), + name: r'messageType_rootId', + unique: false, + replace: false, + properties: [ + IndexPropertySchema( + name: r'messageType', + type: IndexType.value, + caseSensitive: false, + ), + IndexPropertySchema( + name: r'rootId', + type: IndexType.hash, + caseSensitive: true, + ) + ], + ), + r'channelUrl': IndexSchema( + id: BigInt.parse('6636052684858767397').toInt(), + name: r'channelUrl', + unique: false, + replace: false, + properties: [ + IndexPropertySchema( + name: r'channelUrl', + type: IndexType.hash, + caseSensitive: true, + ) + ], + ), + r'channelType_channelUrl': IndexSchema( + id: BigInt.parse('-5957547153902522682').toInt(), + name: r'channelType_channelUrl', + unique: false, + replace: false, + properties: [ + IndexPropertySchema( + name: r'channelType', + type: IndexType.value, + caseSensitive: false, + ), + IndexPropertySchema( + name: r'channelUrl', + type: IndexType.hash, + caseSensitive: true, + ) + ], + ) + }, + links: {}, + embeddedSchemas: { + r'CPoll': CPollSchema, + r'CPollData': CPollDataSchema, + r'CPollOption': CPollOptionSchema, + r'CThreadInfo': CThreadInfoSchema, + r'COGMetaData': COGMetaDataSchema, + r'COGImage': COGImageSchema, + r'CReaction': CReactionSchema, + r'CScheduledInfo': CScheduledInfoSchema, + r'CSender': CSenderSchema, + r'CMessageMetaArray': CMessageMetaArraySchema + }, + getId: _cUserMessageGetId, + getLinks: _cUserMessageGetLinks, + attach: _cUserMessageAttach, + version: '3.1.0+1', +); + +int _cUserMessageEstimateSize( + CUserMessage object, + List offsets, + Map> allOffsets, +) { + var bytesCount = offsets.last; + { + final list = object.allMetaArrays; + if (list != null) { + bytesCount += 3 + list.length * 3; + { + final offsets = allOffsets[CMessageMetaArray]!; + for (var i = 0; i < list.length; i++) { + final value = list[i]; + bytesCount += + CMessageMetaArraySchema.estimateSize(value, offsets, allOffsets); + } + } + } + } + bytesCount += 3 + object.channelUrl.length * 3; + { + final value = object.customType; + if (value != null) { + bytesCount += 3 + value.length * 3; + } + } + { + final value = object.data; + if (value != null) { + bytesCount += 3 + value.length * 3; + } + } + bytesCount += 3 + object.extendedMessage.length * 3; + bytesCount += 3 + object.mentionedUsers.length * 3; + { + for (var i = 0; i < object.mentionedUsers.length; i++) { + final value = object.mentionedUsers[i]; + bytesCount += value.length * 3; + } + } + bytesCount += 3 + object.message.length * 3; + { + final value = object.ogMetaData; + if (value != null) { + bytesCount += 3 + + COGMetaDataSchema.estimateSize( + value, allOffsets[COGMetaData]!, allOffsets); + } + } + { + final value = object.parentMessageRootId; + if (value != null) { + bytesCount += 3 + value.length * 3; + } + } + { + final value = object.poll; + if (value != null) { + bytesCount += + 3 + CPollSchema.estimateSize(value, allOffsets[CPoll]!, allOffsets); + } + } + { + final list = object.reactions; + if (list != null) { + bytesCount += 3 + list.length * 3; + { + final offsets = allOffsets[CReaction]!; + for (var i = 0; i < list.length; i++) { + final value = list[i]; + bytesCount += + CReactionSchema.estimateSize(value, offsets, allOffsets); + } + } + } + } + { + final value = object.requestId; + if (value != null) { + bytesCount += 3 + value.length * 3; + } + } + bytesCount += 3 + object.rootId.length * 3; + { + final value = object.scheduledInfo; + if (value != null) { + bytesCount += 3 + + CScheduledInfoSchema.estimateSize( + value, allOffsets[CScheduledInfo]!, allOffsets); + } + } + { + final value = object.sender; + if (value != null) { + bytesCount += 3 + + CSenderSchema.estimateSize(value, allOffsets[CSender]!, allOffsets); + } + } + { + final value = object.threadInfo; + if (value != null) { + bytesCount += 3 + + CThreadInfoSchema.estimateSize( + value, allOffsets[CThreadInfo]!, allOffsets); + } + } + { + final list = object.translationTargetLanguages; + if (list != null) { + bytesCount += 3 + list.length * 3; + { + for (var i = 0; i < list.length; i++) { + final value = list[i]; + bytesCount += value.length * 3; + } + } + } + } + bytesCount += 3 + object.translations.length * 3; + return bytesCount; +} + +void _cUserMessageSerialize( + CUserMessage object, + IsarWriter writer, + List offsets, + Map> allOffsets, +) { + writer.writeObjectList( + offsets[0], + allOffsets, + CMessageMetaArraySchema.serialize, + object.allMetaArrays, + ); + writer.writeByte(offsets[1], object.channelType.index); + writer.writeString(offsets[2], object.channelUrl); + writer.writeLong(offsets[3], object.createdAt); + writer.writeString(offsets[4], object.customType); + writer.writeString(offsets[5], object.data); + writer.writeLong(offsets[6], object.errorCode); + writer.writeString(offsets[7], object.extendedMessage); + writer.writeBool(offsets[8], object.isOperatorMessage); + writer.writeBool(offsets[9], object.isReplyToChannel); + writer.writeBool(offsets[10], object.isSilent); + writer.writeByte(offsets[11], object.mentionType.index); + writer.writeStringList(offsets[12], object.mentionedUsers); + writer.writeString(offsets[13], object.message); + writer.writeLong(offsets[14], object.messageId); + writer.writeLong(offsets[15], object.messageSurvivalSeconds); + writer.writeByte(offsets[16], object.messageType.index); + writer.writeObject( + offsets[17], + allOffsets, + COGMetaDataSchema.serialize, + object.ogMetaData, + ); + writer.writeLong(offsets[18], object.parentMessageId); + writer.writeString(offsets[19], object.parentMessageRootId); + writer.writeByte(offsets[20], object.parentMessageType.index); + writer.writeObject( + offsets[21], + allOffsets, + CPollSchema.serialize, + object.poll, + ); + writer.writeObjectList( + offsets[22], + allOffsets, + CReactionSchema.serialize, + object.reactions, + ); + writer.writeString(offsets[23], object.requestId); + writer.writeString(offsets[24], object.rootId); + writer.writeObject( + offsets[25], + allOffsets, + CScheduledInfoSchema.serialize, + object.scheduledInfo, + ); + writer.writeObject( + offsets[26], + allOffsets, + CSenderSchema.serialize, + object.sender, + ); + writer.writeByte(offsets[27], object.sendingStatus.index); + writer.writeObject( + offsets[28], + allOffsets, + CThreadInfoSchema.serialize, + object.threadInfo, + ); + writer.writeStringList(offsets[29], object.translationTargetLanguages); + writer.writeString(offsets[30], object.translations); + writer.writeLong(offsets[31], object.updatedAt); +} + +CUserMessage _cUserMessageDeserialize( + Id id, + IsarReader reader, + List offsets, + Map> allOffsets, +) { + final object = CUserMessage(); + object.allMetaArrays = reader.readObjectList( + offsets[0], + CMessageMetaArraySchema.deserialize, + allOffsets, + CMessageMetaArray(), + ); + object.channelType = + _CUserMessagechannelTypeValueEnumMap[reader.readByteOrNull(offsets[1])] ?? + ChannelType.group; + object.channelUrl = reader.readString(offsets[2]); + object.createdAt = reader.readLong(offsets[3]); + object.customType = reader.readStringOrNull(offsets[4]); + object.data = reader.readStringOrNull(offsets[5]); + object.errorCode = reader.readLongOrNull(offsets[6]); + object.extendedMessage = reader.readString(offsets[7]); + object.id = id; + object.isOperatorMessage = reader.readBool(offsets[8]); + object.isReplyToChannel = reader.readBool(offsets[9]); + object.isSilent = reader.readBool(offsets[10]); + object.mentionType = _CUserMessagementionTypeValueEnumMap[ + reader.readByteOrNull(offsets[11])] ?? + MentionType.users; + object.mentionedUsers = reader.readStringList(offsets[12]) ?? []; + object.message = reader.readString(offsets[13]); + object.messageId = reader.readLong(offsets[14]); + object.messageSurvivalSeconds = reader.readLongOrNull(offsets[15]); + object.messageType = _CUserMessagemessageTypeValueEnumMap[ + reader.readByteOrNull(offsets[16])] ?? + MessageType.user; + object.ogMetaData = reader.readObjectOrNull( + offsets[17], + COGMetaDataSchema.deserialize, + allOffsets, + ); + object.parentMessageId = reader.readLongOrNull(offsets[18]); + object.parentMessageRootId = reader.readStringOrNull(offsets[19]); + object.parentMessageType = _CUserMessageparentMessageTypeValueEnumMap[ + reader.readByteOrNull(offsets[20])] ?? + MessageType.user; + object.poll = reader.readObjectOrNull( + offsets[21], + CPollSchema.deserialize, + allOffsets, + ); + object.reactions = reader.readObjectList( + offsets[22], + CReactionSchema.deserialize, + allOffsets, + CReaction(), + ); + object.requestId = reader.readStringOrNull(offsets[23]); + object.rootId = reader.readString(offsets[24]); + object.scheduledInfo = reader.readObjectOrNull( + offsets[25], + CScheduledInfoSchema.deserialize, + allOffsets, + ); + object.sender = reader.readObjectOrNull( + offsets[26], + CSenderSchema.deserialize, + allOffsets, + ); + object.sendingStatus = _CUserMessagesendingStatusValueEnumMap[ + reader.readByteOrNull(offsets[27])] ?? + SendingStatus.none; + object.threadInfo = reader.readObjectOrNull( + offsets[28], + CThreadInfoSchema.deserialize, + allOffsets, + ); + object.translationTargetLanguages = reader.readStringList(offsets[29]); + object.translations = reader.readString(offsets[30]); + object.updatedAt = reader.readLong(offsets[31]); + return object; +} + +P _cUserMessageDeserializeProp

( + IsarReader reader, + int propertyId, + int offset, + Map> allOffsets, +) { + switch (propertyId) { + case 0: + return (reader.readObjectList( + offset, + CMessageMetaArraySchema.deserialize, + allOffsets, + CMessageMetaArray(), + )) as P; + case 1: + return (_CUserMessagechannelTypeValueEnumMap[ + reader.readByteOrNull(offset)] ?? + ChannelType.group) as P; + case 2: + return (reader.readString(offset)) as P; + case 3: + return (reader.readLong(offset)) as P; + case 4: + return (reader.readStringOrNull(offset)) as P; + case 5: + return (reader.readStringOrNull(offset)) as P; + case 6: + return (reader.readLongOrNull(offset)) as P; + case 7: + return (reader.readString(offset)) as P; + case 8: + return (reader.readBool(offset)) as P; + case 9: + return (reader.readBool(offset)) as P; + case 10: + return (reader.readBool(offset)) as P; + case 11: + return (_CUserMessagementionTypeValueEnumMap[ + reader.readByteOrNull(offset)] ?? + MentionType.users) as P; + case 12: + return (reader.readStringList(offset) ?? []) as P; + case 13: + return (reader.readString(offset)) as P; + case 14: + return (reader.readLong(offset)) as P; + case 15: + return (reader.readLongOrNull(offset)) as P; + case 16: + return (_CUserMessagemessageTypeValueEnumMap[ + reader.readByteOrNull(offset)] ?? + MessageType.user) as P; + case 17: + return (reader.readObjectOrNull( + offset, + COGMetaDataSchema.deserialize, + allOffsets, + )) as P; + case 18: + return (reader.readLongOrNull(offset)) as P; + case 19: + return (reader.readStringOrNull(offset)) as P; + case 20: + return (_CUserMessageparentMessageTypeValueEnumMap[ + reader.readByteOrNull(offset)] ?? + MessageType.user) as P; + case 21: + return (reader.readObjectOrNull( + offset, + CPollSchema.deserialize, + allOffsets, + )) as P; + case 22: + return (reader.readObjectList( + offset, + CReactionSchema.deserialize, + allOffsets, + CReaction(), + )) as P; + case 23: + return (reader.readStringOrNull(offset)) as P; + case 24: + return (reader.readString(offset)) as P; + case 25: + return (reader.readObjectOrNull( + offset, + CScheduledInfoSchema.deserialize, + allOffsets, + )) as P; + case 26: + return (reader.readObjectOrNull( + offset, + CSenderSchema.deserialize, + allOffsets, + )) as P; + case 27: + return (_CUserMessagesendingStatusValueEnumMap[ + reader.readByteOrNull(offset)] ?? + SendingStatus.none) as P; + case 28: + return (reader.readObjectOrNull( + offset, + CThreadInfoSchema.deserialize, + allOffsets, + )) as P; + case 29: + return (reader.readStringList(offset)) as P; + case 30: + return (reader.readString(offset)) as P; + case 31: + return (reader.readLong(offset)) as P; + default: + throw IsarError('Unknown property with id $propertyId'); + } +} + +const _CUserMessagechannelTypeEnumValueMap = { + 'group': 0, + 'open': 1, + 'feed': 2, +}; +const _CUserMessagechannelTypeValueEnumMap = { + 0: ChannelType.group, + 1: ChannelType.open, + 2: ChannelType.feed, +}; +const _CUserMessagementionTypeEnumValueMap = { + 'users': 0, + 'channel': 1, +}; +const _CUserMessagementionTypeValueEnumMap = { + 0: MentionType.users, + 1: MentionType.channel, +}; +const _CUserMessagemessageTypeEnumValueMap = { + 'user': 0, + 'file': 1, + 'admin': 2, + 'notification': 3, +}; +const _CUserMessagemessageTypeValueEnumMap = { + 0: MessageType.user, + 1: MessageType.file, + 2: MessageType.admin, + 3: MessageType.notification, +}; +const _CUserMessageparentMessageTypeEnumValueMap = { + 'user': 0, + 'file': 1, + 'admin': 2, + 'notification': 3, +}; +const _CUserMessageparentMessageTypeValueEnumMap = { + 0: MessageType.user, + 1: MessageType.file, + 2: MessageType.admin, + 3: MessageType.notification, +}; +const _CUserMessagesendingStatusEnumValueMap = { + 'none': 0, + 'pending': 1, + 'failed': 2, + 'succeeded': 3, + 'canceled': 4, +}; +const _CUserMessagesendingStatusValueEnumMap = { + 0: SendingStatus.none, + 1: SendingStatus.pending, + 2: SendingStatus.failed, + 3: SendingStatus.succeeded, + 4: SendingStatus.canceled, +}; + +Id _cUserMessageGetId(CUserMessage object) { + return object.id; +} + +List> _cUserMessageGetLinks(CUserMessage object) { + return []; +} + +void _cUserMessageAttach( + IsarCollection col, Id id, CUserMessage object) { + object.id = id; +} + +extension CUserMessageByIndex on IsarCollection { + Future getByRootId(String rootId) { + return getByIndex(r'rootId', [rootId]); + } + + CUserMessage? getByRootIdSync(String rootId) { + return getByIndexSync(r'rootId', [rootId]); + } + + Future deleteByRootId(String rootId) { + return deleteByIndex(r'rootId', [rootId]); + } + + bool deleteByRootIdSync(String rootId) { + return deleteByIndexSync(r'rootId', [rootId]); + } + + Future> getAllByRootId(List rootIdValues) { + final values = rootIdValues.map((e) => [e]).toList(); + return getAllByIndex(r'rootId', values); + } + + List getAllByRootIdSync(List rootIdValues) { + final values = rootIdValues.map((e) => [e]).toList(); + return getAllByIndexSync(r'rootId', values); + } + + Future deleteAllByRootId(List rootIdValues) { + final values = rootIdValues.map((e) => [e]).toList(); + return deleteAllByIndex(r'rootId', values); + } + + int deleteAllByRootIdSync(List rootIdValues) { + final values = rootIdValues.map((e) => [e]).toList(); + return deleteAllByIndexSync(r'rootId', values); + } + + Future putByRootId(CUserMessage object) { + return putByIndex(r'rootId', object); + } + + Id putByRootIdSync(CUserMessage object, {bool saveLinks = true}) { + return putByIndexSync(r'rootId', object, saveLinks: saveLinks); + } + + Future> putAllByRootId(List objects) { + return putAllByIndex(r'rootId', objects); + } + + List putAllByRootIdSync(List objects, + {bool saveLinks = true}) { + return putAllByIndexSync(r'rootId', objects, saveLinks: saveLinks); + } +} + +extension CUserMessageQueryWhereSort + on QueryBuilder { + QueryBuilder anyId() { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(const IdWhereClause.any()); + }); + } +} + +extension CUserMessageQueryWhere + on QueryBuilder { + QueryBuilder idEqualTo(Id id) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IdWhereClause.between( + lower: id, + upper: id, + )); + }); + } + + QueryBuilder idNotEqualTo( + Id id) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause( + IdWhereClause.lessThan(upper: id, includeUpper: false), + ) + .addWhereClause( + IdWhereClause.greaterThan(lower: id, includeLower: false), + ); + } else { + return query + .addWhereClause( + IdWhereClause.greaterThan(lower: id, includeLower: false), + ) + .addWhereClause( + IdWhereClause.lessThan(upper: id, includeUpper: false), + ); + } + }); + } + + QueryBuilder idGreaterThan( + Id id, + {bool include = false}) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause( + IdWhereClause.greaterThan(lower: id, includeLower: include), + ); + }); + } + + QueryBuilder idLessThan(Id id, + {bool include = false}) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause( + IdWhereClause.lessThan(upper: id, includeUpper: include), + ); + }); + } + + QueryBuilder idBetween( + Id lowerId, + Id upperId, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IdWhereClause.between( + lower: lowerId, + includeLower: includeLower, + upper: upperId, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder rootIdEqualTo( + String rootId) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.equalTo( + indexName: r'rootId', + value: [rootId], + )); + }); + } + + QueryBuilder rootIdNotEqualTo( + String rootId) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'rootId', + lower: [], + upper: [rootId], + includeUpper: false, + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'rootId', + lower: [rootId], + includeLower: false, + upper: [], + )); + } else { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'rootId', + lower: [rootId], + includeLower: false, + upper: [], + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'rootId', + lower: [], + upper: [rootId], + includeUpper: false, + )); + } + }); + } + + QueryBuilder + messageTypeEqualToAnyRootId(MessageType messageType) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.equalTo( + indexName: r'messageType_rootId', + value: [messageType], + )); + }); + } + + QueryBuilder + messageTypeNotEqualToAnyRootId(MessageType messageType) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'messageType_rootId', + lower: [], + upper: [messageType], + includeUpper: false, + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'messageType_rootId', + lower: [messageType], + includeLower: false, + upper: [], + )); + } else { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'messageType_rootId', + lower: [messageType], + includeLower: false, + upper: [], + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'messageType_rootId', + lower: [], + upper: [messageType], + includeUpper: false, + )); + } + }); + } + + QueryBuilder + messageTypeGreaterThanAnyRootId( + MessageType messageType, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.between( + indexName: r'messageType_rootId', + lower: [messageType], + includeLower: include, + upper: [], + )); + }); + } + + QueryBuilder + messageTypeLessThanAnyRootId( + MessageType messageType, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.between( + indexName: r'messageType_rootId', + lower: [], + upper: [messageType], + includeUpper: include, + )); + }); + } + + QueryBuilder + messageTypeBetweenAnyRootId( + MessageType lowerMessageType, + MessageType upperMessageType, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.between( + indexName: r'messageType_rootId', + lower: [lowerMessageType], + includeLower: includeLower, + upper: [upperMessageType], + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + messageTypeRootIdEqualTo(MessageType messageType, String rootId) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.equalTo( + indexName: r'messageType_rootId', + value: [messageType, rootId], + )); + }); + } + + QueryBuilder + messageTypeEqualToRootIdNotEqualTo( + MessageType messageType, String rootId) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'messageType_rootId', + lower: [messageType], + upper: [messageType, rootId], + includeUpper: false, + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'messageType_rootId', + lower: [messageType, rootId], + includeLower: false, + upper: [messageType], + )); + } else { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'messageType_rootId', + lower: [messageType, rootId], + includeLower: false, + upper: [messageType], + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'messageType_rootId', + lower: [messageType], + upper: [messageType, rootId], + includeUpper: false, + )); + } + }); + } + + QueryBuilder channelUrlEqualTo( + String channelUrl) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.equalTo( + indexName: r'channelUrl', + value: [channelUrl], + )); + }); + } + + QueryBuilder + channelUrlNotEqualTo(String channelUrl) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'channelUrl', + lower: [], + upper: [channelUrl], + includeUpper: false, + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'channelUrl', + lower: [channelUrl], + includeLower: false, + upper: [], + )); + } else { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'channelUrl', + lower: [channelUrl], + includeLower: false, + upper: [], + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'channelUrl', + lower: [], + upper: [channelUrl], + includeUpper: false, + )); + } + }); + } + + QueryBuilder + channelTypeEqualToAnyChannelUrl(ChannelType channelType) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.equalTo( + indexName: r'channelType_channelUrl', + value: [channelType], + )); + }); + } + + QueryBuilder + channelTypeNotEqualToAnyChannelUrl(ChannelType channelType) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'channelType_channelUrl', + lower: [], + upper: [channelType], + includeUpper: false, + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'channelType_channelUrl', + lower: [channelType], + includeLower: false, + upper: [], + )); + } else { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'channelType_channelUrl', + lower: [channelType], + includeLower: false, + upper: [], + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'channelType_channelUrl', + lower: [], + upper: [channelType], + includeUpper: false, + )); + } + }); + } + + QueryBuilder + channelTypeGreaterThanAnyChannelUrl( + ChannelType channelType, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.between( + indexName: r'channelType_channelUrl', + lower: [channelType], + includeLower: include, + upper: [], + )); + }); + } + + QueryBuilder + channelTypeLessThanAnyChannelUrl( + ChannelType channelType, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.between( + indexName: r'channelType_channelUrl', + lower: [], + upper: [channelType], + includeUpper: include, + )); + }); + } + + QueryBuilder + channelTypeBetweenAnyChannelUrl( + ChannelType lowerChannelType, + ChannelType upperChannelType, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.between( + indexName: r'channelType_channelUrl', + lower: [lowerChannelType], + includeLower: includeLower, + upper: [upperChannelType], + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + channelTypeChannelUrlEqualTo(ChannelType channelType, String channelUrl) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.equalTo( + indexName: r'channelType_channelUrl', + value: [channelType, channelUrl], + )); + }); + } + + QueryBuilder + channelTypeEqualToChannelUrlNotEqualTo( + ChannelType channelType, String channelUrl) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'channelType_channelUrl', + lower: [channelType], + upper: [channelType, channelUrl], + includeUpper: false, + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'channelType_channelUrl', + lower: [channelType, channelUrl], + includeLower: false, + upper: [channelType], + )); + } else { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'channelType_channelUrl', + lower: [channelType, channelUrl], + includeLower: false, + upper: [channelType], + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'channelType_channelUrl', + lower: [channelType], + upper: [channelType, channelUrl], + includeUpper: false, + )); + } + }); + } +} + +extension CUserMessageQueryFilter + on QueryBuilder { + QueryBuilder + allMetaArraysIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'allMetaArrays', + )); + }); + } + + QueryBuilder + allMetaArraysIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'allMetaArrays', + )); + }); + } + + QueryBuilder + allMetaArraysLengthEqualTo(int length) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'allMetaArrays', + length, + true, + length, + true, + ); + }); + } + + QueryBuilder + allMetaArraysIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'allMetaArrays', + 0, + true, + 0, + true, + ); + }); + } + + QueryBuilder + allMetaArraysIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'allMetaArrays', + 0, + false, + 999999, + true, + ); + }); + } + + QueryBuilder + allMetaArraysLengthLessThan( + int length, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'allMetaArrays', + 0, + true, + length, + include, + ); + }); + } + + QueryBuilder + allMetaArraysLengthGreaterThan( + int length, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'allMetaArrays', + length, + include, + 999999, + true, + ); + }); + } + + QueryBuilder + allMetaArraysLengthBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'allMetaArrays', + lower, + includeLower, + upper, + includeUpper, + ); + }); + } + + QueryBuilder + channelTypeEqualTo(ChannelType value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'channelType', + value: value, + )); + }); + } + + QueryBuilder + channelTypeGreaterThan( + ChannelType value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'channelType', + value: value, + )); + }); + } + + QueryBuilder + channelTypeLessThan( + ChannelType value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'channelType', + value: value, + )); + }); + } + + QueryBuilder + channelTypeBetween( + ChannelType lower, + ChannelType upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'channelType', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + channelUrlEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'channelUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + channelUrlGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'channelUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + channelUrlLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'channelUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + channelUrlBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'channelUrl', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + channelUrlStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'channelUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + channelUrlEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'channelUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + channelUrlContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'channelUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + channelUrlMatches(String pattern, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'channelUrl', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + channelUrlIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'channelUrl', + value: '', + )); + }); + } + + QueryBuilder + channelUrlIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'channelUrl', + value: '', + )); + }); + } + + QueryBuilder + createdAtEqualTo(int value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'createdAt', + value: value, + )); + }); + } + + QueryBuilder + createdAtGreaterThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'createdAt', + value: value, + )); + }); + } + + QueryBuilder + createdAtLessThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'createdAt', + value: value, + )); + }); + } + + QueryBuilder + createdAtBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'createdAt', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + customTypeIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'customType', + )); + }); + } + + QueryBuilder + customTypeIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'customType', + )); + }); + } + + QueryBuilder + customTypeEqualTo( + String? value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'customType', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + customTypeGreaterThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'customType', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + customTypeLessThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'customType', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + customTypeBetween( + String? lower, + String? upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'customType', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + customTypeStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'customType', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + customTypeEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'customType', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + customTypeContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'customType', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + customTypeMatches(String pattern, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'customType', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + customTypeIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'customType', + value: '', + )); + }); + } + + QueryBuilder + customTypeIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'customType', + value: '', + )); + }); + } + + QueryBuilder dataIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'data', + )); + }); + } + + QueryBuilder + dataIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'data', + )); + }); + } + + QueryBuilder dataEqualTo( + String? value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'data', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + dataGreaterThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'data', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder dataLessThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'data', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder dataBetween( + String? lower, + String? upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'data', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + dataStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'data', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder dataEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'data', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder dataContains( + String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'data', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder dataMatches( + String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'data', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + dataIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'data', + value: '', + )); + }); + } + + QueryBuilder + dataIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'data', + value: '', + )); + }); + } + + QueryBuilder + errorCodeIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'errorCode', + )); + }); + } + + QueryBuilder + errorCodeIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'errorCode', + )); + }); + } + + QueryBuilder + errorCodeEqualTo(int? value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'errorCode', + value: value, + )); + }); + } + + QueryBuilder + errorCodeGreaterThan( + int? value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'errorCode', + value: value, + )); + }); + } + + QueryBuilder + errorCodeLessThan( + int? value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'errorCode', + value: value, + )); + }); + } + + QueryBuilder + errorCodeBetween( + int? lower, + int? upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'errorCode', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + extendedMessageEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'extendedMessage', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + extendedMessageGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'extendedMessage', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + extendedMessageLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'extendedMessage', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + extendedMessageBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'extendedMessage', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + extendedMessageStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'extendedMessage', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + extendedMessageEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'extendedMessage', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + extendedMessageContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'extendedMessage', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + extendedMessageMatches(String pattern, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'extendedMessage', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + extendedMessageIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'extendedMessage', + value: '', + )); + }); + } + + QueryBuilder + extendedMessageIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'extendedMessage', + value: '', + )); + }); + } + + QueryBuilder idEqualTo( + Id value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'id', + value: value, + )); + }); + } + + QueryBuilder idGreaterThan( + Id value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'id', + value: value, + )); + }); + } + + QueryBuilder idLessThan( + Id value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'id', + value: value, + )); + }); + } + + QueryBuilder idBetween( + Id lower, + Id upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'id', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + isOperatorMessageEqualTo(bool value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'isOperatorMessage', + value: value, + )); + }); + } + + QueryBuilder + isReplyToChannelEqualTo(bool value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'isReplyToChannel', + value: value, + )); + }); + } + + QueryBuilder + isSilentEqualTo(bool value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'isSilent', + value: value, + )); + }); + } + + QueryBuilder + mentionTypeEqualTo(MentionType value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'mentionType', + value: value, + )); + }); + } + + QueryBuilder + mentionTypeGreaterThan( + MentionType value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'mentionType', + value: value, + )); + }); + } + + QueryBuilder + mentionTypeLessThan( + MentionType value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'mentionType', + value: value, + )); + }); + } + + QueryBuilder + mentionTypeBetween( + MentionType lower, + MentionType upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'mentionType', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + mentionedUsersElementEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'mentionedUsers', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + mentionedUsersElementGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'mentionedUsers', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + mentionedUsersElementLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'mentionedUsers', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + mentionedUsersElementBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'mentionedUsers', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + mentionedUsersElementStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'mentionedUsers', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + mentionedUsersElementEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'mentionedUsers', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + mentionedUsersElementContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'mentionedUsers', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + mentionedUsersElementMatches(String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'mentionedUsers', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + mentionedUsersElementIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'mentionedUsers', + value: '', + )); + }); + } + + QueryBuilder + mentionedUsersElementIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'mentionedUsers', + value: '', + )); + }); + } + + QueryBuilder + mentionedUsersLengthEqualTo(int length) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'mentionedUsers', + length, + true, + length, + true, + ); + }); + } + + QueryBuilder + mentionedUsersIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'mentionedUsers', + 0, + true, + 0, + true, + ); + }); + } + + QueryBuilder + mentionedUsersIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'mentionedUsers', + 0, + false, + 999999, + true, + ); + }); + } + + QueryBuilder + mentionedUsersLengthLessThan( + int length, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'mentionedUsers', + 0, + true, + length, + include, + ); + }); + } + + QueryBuilder + mentionedUsersLengthGreaterThan( + int length, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'mentionedUsers', + length, + include, + 999999, + true, + ); + }); + } + + QueryBuilder + mentionedUsersLengthBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'mentionedUsers', + lower, + includeLower, + upper, + includeUpper, + ); + }); + } + + QueryBuilder + messageEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'message', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + messageGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'message', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + messageLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'message', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + messageBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'message', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + messageStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'message', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + messageEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'message', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + messageContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'message', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + messageMatches(String pattern, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'message', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + messageIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'message', + value: '', + )); + }); + } + + QueryBuilder + messageIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'message', + value: '', + )); + }); + } + + QueryBuilder + messageIdEqualTo(int value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'messageId', + value: value, + )); + }); + } + + QueryBuilder + messageIdGreaterThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'messageId', + value: value, + )); + }); + } + + QueryBuilder + messageIdLessThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'messageId', + value: value, + )); + }); + } + + QueryBuilder + messageIdBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'messageId', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + messageSurvivalSecondsIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'messageSurvivalSeconds', + )); + }); + } + + QueryBuilder + messageSurvivalSecondsIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'messageSurvivalSeconds', + )); + }); + } + + QueryBuilder + messageSurvivalSecondsEqualTo(int? value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'messageSurvivalSeconds', + value: value, + )); + }); + } + + QueryBuilder + messageSurvivalSecondsGreaterThan( + int? value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'messageSurvivalSeconds', + value: value, + )); + }); + } + + QueryBuilder + messageSurvivalSecondsLessThan( + int? value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'messageSurvivalSeconds', + value: value, + )); + }); + } + + QueryBuilder + messageSurvivalSecondsBetween( + int? lower, + int? upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'messageSurvivalSeconds', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + messageTypeEqualTo(MessageType value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'messageType', + value: value, + )); + }); + } + + QueryBuilder + messageTypeGreaterThan( + MessageType value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'messageType', + value: value, + )); + }); + } + + QueryBuilder + messageTypeLessThan( + MessageType value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'messageType', + value: value, + )); + }); + } + + QueryBuilder + messageTypeBetween( + MessageType lower, + MessageType upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'messageType', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + ogMetaDataIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'ogMetaData', + )); + }); + } + + QueryBuilder + ogMetaDataIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'ogMetaData', + )); + }); + } + + QueryBuilder + parentMessageIdIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'parentMessageId', + )); + }); + } + + QueryBuilder + parentMessageIdIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'parentMessageId', + )); + }); + } + + QueryBuilder + parentMessageIdEqualTo(int? value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'parentMessageId', + value: value, + )); + }); + } + + QueryBuilder + parentMessageIdGreaterThan( + int? value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'parentMessageId', + value: value, + )); + }); + } + + QueryBuilder + parentMessageIdLessThan( + int? value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'parentMessageId', + value: value, + )); + }); + } + + QueryBuilder + parentMessageIdBetween( + int? lower, + int? upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'parentMessageId', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + parentMessageRootIdIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'parentMessageRootId', + )); + }); + } + + QueryBuilder + parentMessageRootIdIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'parentMessageRootId', + )); + }); + } + + QueryBuilder + parentMessageRootIdEqualTo( + String? value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'parentMessageRootId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + parentMessageRootIdGreaterThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'parentMessageRootId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + parentMessageRootIdLessThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'parentMessageRootId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + parentMessageRootIdBetween( + String? lower, + String? upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'parentMessageRootId', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + parentMessageRootIdStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'parentMessageRootId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + parentMessageRootIdEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'parentMessageRootId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + parentMessageRootIdContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'parentMessageRootId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + parentMessageRootIdMatches(String pattern, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'parentMessageRootId', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + parentMessageRootIdIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'parentMessageRootId', + value: '', + )); + }); + } + + QueryBuilder + parentMessageRootIdIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'parentMessageRootId', + value: '', + )); + }); + } + + QueryBuilder + parentMessageTypeEqualTo(MessageType value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'parentMessageType', + value: value, + )); + }); + } + + QueryBuilder + parentMessageTypeGreaterThan( + MessageType value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'parentMessageType', + value: value, + )); + }); + } + + QueryBuilder + parentMessageTypeLessThan( + MessageType value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'parentMessageType', + value: value, + )); + }); + } + + QueryBuilder + parentMessageTypeBetween( + MessageType lower, + MessageType upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'parentMessageType', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder pollIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'poll', + )); + }); + } + + QueryBuilder + pollIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'poll', + )); + }); + } + + QueryBuilder + reactionsIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'reactions', + )); + }); + } + + QueryBuilder + reactionsIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'reactions', + )); + }); + } + + QueryBuilder + reactionsLengthEqualTo(int length) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'reactions', + length, + true, + length, + true, + ); + }); + } + + QueryBuilder + reactionsIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'reactions', + 0, + true, + 0, + true, + ); + }); + } + + QueryBuilder + reactionsIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'reactions', + 0, + false, + 999999, + true, + ); + }); + } + + QueryBuilder + reactionsLengthLessThan( + int length, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'reactions', + 0, + true, + length, + include, + ); + }); + } + + QueryBuilder + reactionsLengthGreaterThan( + int length, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'reactions', + length, + include, + 999999, + true, + ); + }); + } + + QueryBuilder + reactionsLengthBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'reactions', + lower, + includeLower, + upper, + includeUpper, + ); + }); + } + + QueryBuilder + requestIdIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'requestId', + )); + }); + } + + QueryBuilder + requestIdIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'requestId', + )); + }); + } + + QueryBuilder + requestIdEqualTo( + String? value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'requestId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + requestIdGreaterThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'requestId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + requestIdLessThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'requestId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + requestIdBetween( + String? lower, + String? upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'requestId', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + requestIdStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'requestId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + requestIdEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'requestId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + requestIdContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'requestId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + requestIdMatches(String pattern, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'requestId', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + requestIdIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'requestId', + value: '', + )); + }); + } + + QueryBuilder + requestIdIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'requestId', + value: '', + )); + }); + } + + QueryBuilder rootIdEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'rootId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + rootIdGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'rootId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + rootIdLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'rootId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder rootIdBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'rootId', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + rootIdStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'rootId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + rootIdEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'rootId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + rootIdContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'rootId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder rootIdMatches( + String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'rootId', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + rootIdIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'rootId', + value: '', + )); + }); + } + + QueryBuilder + rootIdIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'rootId', + value: '', + )); + }); + } + + QueryBuilder + scheduledInfoIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'scheduledInfo', + )); + }); + } + + QueryBuilder + scheduledInfoIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'scheduledInfo', + )); + }); + } + + QueryBuilder + senderIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'sender', + )); + }); + } + + QueryBuilder + senderIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'sender', + )); + }); + } + + QueryBuilder + sendingStatusEqualTo(SendingStatus value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'sendingStatus', + value: value, + )); + }); + } + + QueryBuilder + sendingStatusGreaterThan( + SendingStatus value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'sendingStatus', + value: value, + )); + }); + } + + QueryBuilder + sendingStatusLessThan( + SendingStatus value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'sendingStatus', + value: value, + )); + }); + } + + QueryBuilder + sendingStatusBetween( + SendingStatus lower, + SendingStatus upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'sendingStatus', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + threadInfoIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'threadInfo', + )); + }); + } + + QueryBuilder + threadInfoIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'threadInfo', + )); + }); + } + + QueryBuilder + translationTargetLanguagesIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'translationTargetLanguages', + )); + }); + } + + QueryBuilder + translationTargetLanguagesIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'translationTargetLanguages', + )); + }); + } + + QueryBuilder + translationTargetLanguagesElementEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'translationTargetLanguages', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + translationTargetLanguagesElementGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'translationTargetLanguages', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + translationTargetLanguagesElementLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'translationTargetLanguages', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + translationTargetLanguagesElementBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'translationTargetLanguages', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + translationTargetLanguagesElementStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'translationTargetLanguages', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + translationTargetLanguagesElementEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'translationTargetLanguages', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + translationTargetLanguagesElementContains(String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'translationTargetLanguages', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + translationTargetLanguagesElementMatches(String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'translationTargetLanguages', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + translationTargetLanguagesElementIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'translationTargetLanguages', + value: '', + )); + }); + } + + QueryBuilder + translationTargetLanguagesElementIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'translationTargetLanguages', + value: '', + )); + }); + } + + QueryBuilder + translationTargetLanguagesLengthEqualTo(int length) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'translationTargetLanguages', + length, + true, + length, + true, + ); + }); + } + + QueryBuilder + translationTargetLanguagesIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'translationTargetLanguages', + 0, + true, + 0, + true, + ); + }); + } + + QueryBuilder + translationTargetLanguagesIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'translationTargetLanguages', + 0, + false, + 999999, + true, + ); + }); + } + + QueryBuilder + translationTargetLanguagesLengthLessThan( + int length, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'translationTargetLanguages', + 0, + true, + length, + include, + ); + }); + } + + QueryBuilder + translationTargetLanguagesLengthGreaterThan( + int length, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'translationTargetLanguages', + length, + include, + 999999, + true, + ); + }); + } + + QueryBuilder + translationTargetLanguagesLengthBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'translationTargetLanguages', + lower, + includeLower, + upper, + includeUpper, + ); + }); + } + + QueryBuilder + translationsEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'translations', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + translationsGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'translations', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + translationsLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'translations', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + translationsBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'translations', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + translationsStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'translations', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + translationsEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'translations', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + translationsContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'translations', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + translationsMatches(String pattern, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'translations', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + translationsIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'translations', + value: '', + )); + }); + } + + QueryBuilder + translationsIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'translations', + value: '', + )); + }); + } + + QueryBuilder + updatedAtEqualTo(int value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'updatedAt', + value: value, + )); + }); + } + + QueryBuilder + updatedAtGreaterThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'updatedAt', + value: value, + )); + }); + } + + QueryBuilder + updatedAtLessThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'updatedAt', + value: value, + )); + }); + } + + QueryBuilder + updatedAtBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'updatedAt', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } +} + +extension CUserMessageQueryObject + on QueryBuilder { + QueryBuilder + allMetaArraysElement(FilterQuery q) { + return QueryBuilder.apply(this, (query) { + return query.object(q, r'allMetaArrays'); + }); + } + + QueryBuilder ogMetaData( + FilterQuery q) { + return QueryBuilder.apply(this, (query) { + return query.object(q, r'ogMetaData'); + }); + } + + QueryBuilder poll( + FilterQuery q) { + return QueryBuilder.apply(this, (query) { + return query.object(q, r'poll'); + }); + } + + QueryBuilder + reactionsElement(FilterQuery q) { + return QueryBuilder.apply(this, (query) { + return query.object(q, r'reactions'); + }); + } + + QueryBuilder scheduledInfo( + FilterQuery q) { + return QueryBuilder.apply(this, (query) { + return query.object(q, r'scheduledInfo'); + }); + } + + QueryBuilder sender( + FilterQuery q) { + return QueryBuilder.apply(this, (query) { + return query.object(q, r'sender'); + }); + } + + QueryBuilder threadInfo( + FilterQuery q) { + return QueryBuilder.apply(this, (query) { + return query.object(q, r'threadInfo'); + }); + } +} + +extension CUserMessageQueryLinks + on QueryBuilder {} + +extension CUserMessageQuerySortBy + on QueryBuilder { + QueryBuilder sortByChannelType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'channelType', Sort.asc); + }); + } + + QueryBuilder + sortByChannelTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'channelType', Sort.desc); + }); + } + + QueryBuilder sortByChannelUrl() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'channelUrl', Sort.asc); + }); + } + + QueryBuilder + sortByChannelUrlDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'channelUrl', Sort.desc); + }); + } + + QueryBuilder sortByCreatedAt() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'createdAt', Sort.asc); + }); + } + + QueryBuilder sortByCreatedAtDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'createdAt', Sort.desc); + }); + } + + QueryBuilder sortByCustomType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'customType', Sort.asc); + }); + } + + QueryBuilder + sortByCustomTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'customType', Sort.desc); + }); + } + + QueryBuilder sortByData() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'data', Sort.asc); + }); + } + + QueryBuilder sortByDataDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'data', Sort.desc); + }); + } + + QueryBuilder sortByErrorCode() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'errorCode', Sort.asc); + }); + } + + QueryBuilder sortByErrorCodeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'errorCode', Sort.desc); + }); + } + + QueryBuilder + sortByExtendedMessage() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'extendedMessage', Sort.asc); + }); + } + + QueryBuilder + sortByExtendedMessageDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'extendedMessage', Sort.desc); + }); + } + + QueryBuilder + sortByIsOperatorMessage() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isOperatorMessage', Sort.asc); + }); + } + + QueryBuilder + sortByIsOperatorMessageDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isOperatorMessage', Sort.desc); + }); + } + + QueryBuilder + sortByIsReplyToChannel() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isReplyToChannel', Sort.asc); + }); + } + + QueryBuilder + sortByIsReplyToChannelDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isReplyToChannel', Sort.desc); + }); + } + + QueryBuilder sortByIsSilent() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isSilent', Sort.asc); + }); + } + + QueryBuilder sortByIsSilentDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isSilent', Sort.desc); + }); + } + + QueryBuilder sortByMentionType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'mentionType', Sort.asc); + }); + } + + QueryBuilder + sortByMentionTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'mentionType', Sort.desc); + }); + } + + QueryBuilder sortByMessage() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'message', Sort.asc); + }); + } + + QueryBuilder sortByMessageDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'message', Sort.desc); + }); + } + + QueryBuilder sortByMessageId() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'messageId', Sort.asc); + }); + } + + QueryBuilder sortByMessageIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'messageId', Sort.desc); + }); + } + + QueryBuilder + sortByMessageSurvivalSeconds() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'messageSurvivalSeconds', Sort.asc); + }); + } + + QueryBuilder + sortByMessageSurvivalSecondsDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'messageSurvivalSeconds', Sort.desc); + }); + } + + QueryBuilder sortByMessageType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'messageType', Sort.asc); + }); + } + + QueryBuilder + sortByMessageTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'messageType', Sort.desc); + }); + } + + QueryBuilder + sortByParentMessageId() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'parentMessageId', Sort.asc); + }); + } + + QueryBuilder + sortByParentMessageIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'parentMessageId', Sort.desc); + }); + } + + QueryBuilder + sortByParentMessageRootId() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'parentMessageRootId', Sort.asc); + }); + } + + QueryBuilder + sortByParentMessageRootIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'parentMessageRootId', Sort.desc); + }); + } + + QueryBuilder + sortByParentMessageType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'parentMessageType', Sort.asc); + }); + } + + QueryBuilder + sortByParentMessageTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'parentMessageType', Sort.desc); + }); + } + + QueryBuilder sortByRequestId() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'requestId', Sort.asc); + }); + } + + QueryBuilder sortByRequestIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'requestId', Sort.desc); + }); + } + + QueryBuilder sortByRootId() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'rootId', Sort.asc); + }); + } + + QueryBuilder sortByRootIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'rootId', Sort.desc); + }); + } + + QueryBuilder sortBySendingStatus() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'sendingStatus', Sort.asc); + }); + } + + QueryBuilder + sortBySendingStatusDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'sendingStatus', Sort.desc); + }); + } + + QueryBuilder sortByTranslations() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'translations', Sort.asc); + }); + } + + QueryBuilder + sortByTranslationsDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'translations', Sort.desc); + }); + } + + QueryBuilder sortByUpdatedAt() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'updatedAt', Sort.asc); + }); + } + + QueryBuilder sortByUpdatedAtDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'updatedAt', Sort.desc); + }); + } +} + +extension CUserMessageQuerySortThenBy + on QueryBuilder { + QueryBuilder thenByChannelType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'channelType', Sort.asc); + }); + } + + QueryBuilder + thenByChannelTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'channelType', Sort.desc); + }); + } + + QueryBuilder thenByChannelUrl() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'channelUrl', Sort.asc); + }); + } + + QueryBuilder + thenByChannelUrlDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'channelUrl', Sort.desc); + }); + } + + QueryBuilder thenByCreatedAt() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'createdAt', Sort.asc); + }); + } + + QueryBuilder thenByCreatedAtDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'createdAt', Sort.desc); + }); + } + + QueryBuilder thenByCustomType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'customType', Sort.asc); + }); + } + + QueryBuilder + thenByCustomTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'customType', Sort.desc); + }); + } + + QueryBuilder thenByData() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'data', Sort.asc); + }); + } + + QueryBuilder thenByDataDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'data', Sort.desc); + }); + } + + QueryBuilder thenByErrorCode() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'errorCode', Sort.asc); + }); + } + + QueryBuilder thenByErrorCodeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'errorCode', Sort.desc); + }); + } + + QueryBuilder + thenByExtendedMessage() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'extendedMessage', Sort.asc); + }); + } + + QueryBuilder + thenByExtendedMessageDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'extendedMessage', Sort.desc); + }); + } + + QueryBuilder thenById() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'id', Sort.asc); + }); + } + + QueryBuilder thenByIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'id', Sort.desc); + }); + } + + QueryBuilder + thenByIsOperatorMessage() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isOperatorMessage', Sort.asc); + }); + } + + QueryBuilder + thenByIsOperatorMessageDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isOperatorMessage', Sort.desc); + }); + } + + QueryBuilder + thenByIsReplyToChannel() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isReplyToChannel', Sort.asc); + }); + } + + QueryBuilder + thenByIsReplyToChannelDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isReplyToChannel', Sort.desc); + }); + } + + QueryBuilder thenByIsSilent() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isSilent', Sort.asc); + }); + } + + QueryBuilder thenByIsSilentDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isSilent', Sort.desc); + }); + } + + QueryBuilder thenByMentionType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'mentionType', Sort.asc); + }); + } + + QueryBuilder + thenByMentionTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'mentionType', Sort.desc); + }); + } + + QueryBuilder thenByMessage() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'message', Sort.asc); + }); + } + + QueryBuilder thenByMessageDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'message', Sort.desc); + }); + } + + QueryBuilder thenByMessageId() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'messageId', Sort.asc); + }); + } + + QueryBuilder thenByMessageIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'messageId', Sort.desc); + }); + } + + QueryBuilder + thenByMessageSurvivalSeconds() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'messageSurvivalSeconds', Sort.asc); + }); + } + + QueryBuilder + thenByMessageSurvivalSecondsDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'messageSurvivalSeconds', Sort.desc); + }); + } + + QueryBuilder thenByMessageType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'messageType', Sort.asc); + }); + } + + QueryBuilder + thenByMessageTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'messageType', Sort.desc); + }); + } + + QueryBuilder + thenByParentMessageId() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'parentMessageId', Sort.asc); + }); + } + + QueryBuilder + thenByParentMessageIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'parentMessageId', Sort.desc); + }); + } + + QueryBuilder + thenByParentMessageRootId() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'parentMessageRootId', Sort.asc); + }); + } + + QueryBuilder + thenByParentMessageRootIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'parentMessageRootId', Sort.desc); + }); + } + + QueryBuilder + thenByParentMessageType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'parentMessageType', Sort.asc); + }); + } + + QueryBuilder + thenByParentMessageTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'parentMessageType', Sort.desc); + }); + } + + QueryBuilder thenByRequestId() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'requestId', Sort.asc); + }); + } + + QueryBuilder thenByRequestIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'requestId', Sort.desc); + }); + } + + QueryBuilder thenByRootId() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'rootId', Sort.asc); + }); + } + + QueryBuilder thenByRootIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'rootId', Sort.desc); + }); + } + + QueryBuilder thenBySendingStatus() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'sendingStatus', Sort.asc); + }); + } + + QueryBuilder + thenBySendingStatusDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'sendingStatus', Sort.desc); + }); + } + + QueryBuilder thenByTranslations() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'translations', Sort.asc); + }); + } + + QueryBuilder + thenByTranslationsDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'translations', Sort.desc); + }); + } + + QueryBuilder thenByUpdatedAt() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'updatedAt', Sort.asc); + }); + } + + QueryBuilder thenByUpdatedAtDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'updatedAt', Sort.desc); + }); + } +} + +extension CUserMessageQueryWhereDistinct + on QueryBuilder { + QueryBuilder distinctByChannelType() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'channelType'); + }); + } + + QueryBuilder distinctByChannelUrl( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'channelUrl', caseSensitive: caseSensitive); + }); + } + + QueryBuilder distinctByCreatedAt() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'createdAt'); + }); + } + + QueryBuilder distinctByCustomType( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'customType', caseSensitive: caseSensitive); + }); + } + + QueryBuilder distinctByData( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'data', caseSensitive: caseSensitive); + }); + } + + QueryBuilder distinctByErrorCode() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'errorCode'); + }); + } + + QueryBuilder distinctByExtendedMessage( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'extendedMessage', + caseSensitive: caseSensitive); + }); + } + + QueryBuilder + distinctByIsOperatorMessage() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'isOperatorMessage'); + }); + } + + QueryBuilder + distinctByIsReplyToChannel() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'isReplyToChannel'); + }); + } + + QueryBuilder distinctByIsSilent() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'isSilent'); + }); + } + + QueryBuilder distinctByMentionType() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'mentionType'); + }); + } + + QueryBuilder + distinctByMentionedUsers() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'mentionedUsers'); + }); + } + + QueryBuilder distinctByMessage( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'message', caseSensitive: caseSensitive); + }); + } + + QueryBuilder distinctByMessageId() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'messageId'); + }); + } + + QueryBuilder + distinctByMessageSurvivalSeconds() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'messageSurvivalSeconds'); + }); + } + + QueryBuilder distinctByMessageType() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'messageType'); + }); + } + + QueryBuilder + distinctByParentMessageId() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'parentMessageId'); + }); + } + + QueryBuilder + distinctByParentMessageRootId({bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'parentMessageRootId', + caseSensitive: caseSensitive); + }); + } + + QueryBuilder + distinctByParentMessageType() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'parentMessageType'); + }); + } + + QueryBuilder distinctByRequestId( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'requestId', caseSensitive: caseSensitive); + }); + } + + QueryBuilder distinctByRootId( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'rootId', caseSensitive: caseSensitive); + }); + } + + QueryBuilder + distinctBySendingStatus() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'sendingStatus'); + }); + } + + QueryBuilder + distinctByTranslationTargetLanguages() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'translationTargetLanguages'); + }); + } + + QueryBuilder distinctByTranslations( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'translations', caseSensitive: caseSensitive); + }); + } + + QueryBuilder distinctByUpdatedAt() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'updatedAt'); + }); + } +} + +extension CUserMessageQueryProperty + on QueryBuilder { + QueryBuilder idProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'id'); + }); + } + + QueryBuilder?, QQueryOperations> + allMetaArraysProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'allMetaArrays'); + }); + } + + QueryBuilder + channelTypeProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'channelType'); + }); + } + + QueryBuilder channelUrlProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'channelUrl'); + }); + } + + QueryBuilder createdAtProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'createdAt'); + }); + } + + QueryBuilder customTypeProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'customType'); + }); + } + + QueryBuilder dataProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'data'); + }); + } + + QueryBuilder errorCodeProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'errorCode'); + }); + } + + QueryBuilder + extendedMessageProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'extendedMessage'); + }); + } + + QueryBuilder + isOperatorMessageProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'isOperatorMessage'); + }); + } + + QueryBuilder + isReplyToChannelProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'isReplyToChannel'); + }); + } + + QueryBuilder isSilentProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'isSilent'); + }); + } + + QueryBuilder + mentionTypeProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'mentionType'); + }); + } + + QueryBuilder, QQueryOperations> + mentionedUsersProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'mentionedUsers'); + }); + } + + QueryBuilder messageProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'message'); + }); + } + + QueryBuilder messageIdProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'messageId'); + }); + } + + QueryBuilder + messageSurvivalSecondsProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'messageSurvivalSeconds'); + }); + } + + QueryBuilder + messageTypeProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'messageType'); + }); + } + + QueryBuilder + ogMetaDataProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'ogMetaData'); + }); + } + + QueryBuilder parentMessageIdProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'parentMessageId'); + }); + } + + QueryBuilder + parentMessageRootIdProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'parentMessageRootId'); + }); + } + + QueryBuilder + parentMessageTypeProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'parentMessageType'); + }); + } + + QueryBuilder pollProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'poll'); + }); + } + + QueryBuilder?, QQueryOperations> + reactionsProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'reactions'); + }); + } + + QueryBuilder requestIdProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'requestId'); + }); + } + + QueryBuilder rootIdProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'rootId'); + }); + } + + QueryBuilder + scheduledInfoProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'scheduledInfo'); + }); + } + + QueryBuilder senderProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'sender'); + }); + } + + QueryBuilder + sendingStatusProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'sendingStatus'); + }); + } + + QueryBuilder + threadInfoProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'threadInfo'); + }); + } + + QueryBuilder?, QQueryOperations> + translationTargetLanguagesProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'translationTargetLanguages'); + }); + } + + QueryBuilder translationsProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'translations'); + }); + } + + QueryBuilder updatedAtProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'updatedAt'); + }); + } +} + +// ************************************************************************** +// IsarEmbeddedGenerator +// ************************************************************************** + +// coverage:ignore-file +// ignore_for_file: duplicate_ignore, non_constant_identifier_names, constant_identifier_names, invalid_use_of_protected_member, unnecessary_cast, prefer_const_constructors, lines_longer_than_80_chars, require_trailing_commas, inference_failure_on_function_invocation, unnecessary_parenthesis, unnecessary_raw_strings, unnecessary_null_checks, join_return_with_assignment, prefer_final_locals, avoid_js_rounded_ints, avoid_positional_boolean_parameters, always_specify_types + +final CPollSchema = Schema( + name: r'CPoll', + id: BigInt.parse('-6002142452581641545').toInt(), + properties: { + r'allowMultipleVotes': PropertySchema( + id: 0, + name: r'allowMultipleVotes', + type: IsarType.bool, + ), + r'allowUserSuggestion': PropertySchema( + id: 1, + name: r'allowUserSuggestion', + type: IsarType.bool, + ), + r'closeAt': PropertySchema( + id: 2, + name: r'closeAt', + type: IsarType.long, + ), + r'createdAt': PropertySchema( + id: 3, + name: r'createdAt', + type: IsarType.long, + ), + r'createdBy': PropertySchema( + id: 4, + name: r'createdBy', + type: IsarType.string, + ), + r'data': PropertySchema( + id: 5, + name: r'data', + type: IsarType.object, + target: r'CPollData', + ), + r'id': PropertySchema( + id: 6, + name: r'id', + type: IsarType.long, + ), + r'messageId': PropertySchema( + id: 7, + name: r'messageId', + type: IsarType.long, + ), + r'options': PropertySchema( + id: 8, + name: r'options', + type: IsarType.objectList, + target: r'CPollOption', + ), + r'status': PropertySchema( + id: 9, + name: r'status', + type: IsarType.byte, + enumMap: _CPollstatusEnumValueMap, + ), + r'title': PropertySchema( + id: 10, + name: r'title', + type: IsarType.string, + ), + r'updatedAt': PropertySchema( + id: 11, + name: r'updatedAt', + type: IsarType.long, + ), + r'votedPollOptionIds': PropertySchema( + id: 12, + name: r'votedPollOptionIds', + type: IsarType.longList, + ), + r'voterCount': PropertySchema( + id: 13, + name: r'voterCount', + type: IsarType.long, + ) + }, + estimateSize: _cPollEstimateSize, + serialize: _cPollSerialize, + deserialize: _cPollDeserialize, + deserializeProp: _cPollDeserializeProp, +); + +int _cPollEstimateSize( + CPoll object, + List offsets, + Map> allOffsets, +) { + var bytesCount = offsets.last; + { + final value = object.createdBy; + if (value != null) { + bytesCount += 3 + value.length * 3; + } + } + { + final value = object.data; + if (value != null) { + bytesCount += 3 + + CPollDataSchema.estimateSize( + value, allOffsets[CPollData]!, allOffsets); + } + } + bytesCount += 3 + object.options.length * 3; + { + final offsets = allOffsets[CPollOption]!; + for (var i = 0; i < object.options.length; i++) { + final value = object.options[i]; + bytesCount += CPollOptionSchema.estimateSize(value, offsets, allOffsets); + } + } + bytesCount += 3 + object.title.length * 3; + { + final value = object.votedPollOptionIds; + if (value != null) { + bytesCount += 3 + value.length * 8; + } + } + return bytesCount; +} + +void _cPollSerialize( + CPoll object, + IsarWriter writer, + List offsets, + Map> allOffsets, +) { + writer.writeBool(offsets[0], object.allowMultipleVotes); + writer.writeBool(offsets[1], object.allowUserSuggestion); + writer.writeLong(offsets[2], object.closeAt); + writer.writeLong(offsets[3], object.createdAt); + writer.writeString(offsets[4], object.createdBy); + writer.writeObject( + offsets[5], + allOffsets, + CPollDataSchema.serialize, + object.data, + ); + writer.writeLong(offsets[6], object.id); + writer.writeLong(offsets[7], object.messageId); + writer.writeObjectList( + offsets[8], + allOffsets, + CPollOptionSchema.serialize, + object.options, + ); + writer.writeByte(offsets[9], object.status.index); + writer.writeString(offsets[10], object.title); + writer.writeLong(offsets[11], object.updatedAt); + writer.writeLongList(offsets[12], object.votedPollOptionIds); + writer.writeLong(offsets[13], object.voterCount); +} + +CPoll _cPollDeserialize( + Id id, + IsarReader reader, + List offsets, + Map> allOffsets, +) { + final object = CPoll(); + object.allowMultipleVotes = reader.readBool(offsets[0]); + object.allowUserSuggestion = reader.readBool(offsets[1]); + object.closeAt = reader.readLong(offsets[2]); + object.createdAt = reader.readLong(offsets[3]); + object.createdBy = reader.readStringOrNull(offsets[4]); + object.data = reader.readObjectOrNull( + offsets[5], + CPollDataSchema.deserialize, + allOffsets, + ); + object.id = reader.readLong(offsets[6]); + object.messageId = reader.readLongOrNull(offsets[7]); + object.options = reader.readObjectList( + offsets[8], + CPollOptionSchema.deserialize, + allOffsets, + CPollOption(), + ) ?? + []; + object.status = _CPollstatusValueEnumMap[reader.readByteOrNull(offsets[9])] ?? + PollStatus.open; + object.title = reader.readString(offsets[10]); + object.updatedAt = reader.readLong(offsets[11]); + object.votedPollOptionIds = reader.readLongList(offsets[12]); + object.voterCount = reader.readLong(offsets[13]); + return object; +} + +P _cPollDeserializeProp

( + IsarReader reader, + int propertyId, + int offset, + Map> allOffsets, +) { + switch (propertyId) { + case 0: + return (reader.readBool(offset)) as P; + case 1: + return (reader.readBool(offset)) as P; + case 2: + return (reader.readLong(offset)) as P; + case 3: + return (reader.readLong(offset)) as P; + case 4: + return (reader.readStringOrNull(offset)) as P; + case 5: + return (reader.readObjectOrNull( + offset, + CPollDataSchema.deserialize, + allOffsets, + )) as P; + case 6: + return (reader.readLong(offset)) as P; + case 7: + return (reader.readLongOrNull(offset)) as P; + case 8: + return (reader.readObjectList( + offset, + CPollOptionSchema.deserialize, + allOffsets, + CPollOption(), + ) ?? + []) as P; + case 9: + return (_CPollstatusValueEnumMap[reader.readByteOrNull(offset)] ?? + PollStatus.open) as P; + case 10: + return (reader.readString(offset)) as P; + case 11: + return (reader.readLong(offset)) as P; + case 12: + return (reader.readLongList(offset)) as P; + case 13: + return (reader.readLong(offset)) as P; + default: + throw IsarError('Unknown property with id $propertyId'); + } +} + +const _CPollstatusEnumValueMap = { + 'open': 0, + 'closed': 1, +}; +const _CPollstatusValueEnumMap = { + 0: PollStatus.open, + 1: PollStatus.closed, +}; + +extension CPollQueryFilter on QueryBuilder { + QueryBuilder allowMultipleVotesEqualTo( + bool value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'allowMultipleVotes', + value: value, + )); + }); + } + + QueryBuilder allowUserSuggestionEqualTo( + bool value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'allowUserSuggestion', + value: value, + )); + }); + } + + QueryBuilder closeAtEqualTo(int value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'closeAt', + value: value, + )); + }); + } + + QueryBuilder closeAtGreaterThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'closeAt', + value: value, + )); + }); + } + + QueryBuilder closeAtLessThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'closeAt', + value: value, + )); + }); + } + + QueryBuilder closeAtBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'closeAt', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder createdAtEqualTo( + int value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'createdAt', + value: value, + )); + }); + } + + QueryBuilder createdAtGreaterThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'createdAt', + value: value, + )); + }); + } + + QueryBuilder createdAtLessThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'createdAt', + value: value, + )); + }); + } + + QueryBuilder createdAtBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'createdAt', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder createdByIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'createdBy', + )); + }); + } + + QueryBuilder createdByIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'createdBy', + )); + }); + } + + QueryBuilder createdByEqualTo( + String? value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'createdBy', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder createdByGreaterThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'createdBy', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder createdByLessThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'createdBy', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder createdByBetween( + String? lower, + String? upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'createdBy', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder createdByStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'createdBy', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder createdByEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'createdBy', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder createdByContains( + String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'createdBy', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder createdByMatches( + String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'createdBy', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder createdByIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'createdBy', + value: '', + )); + }); + } + + QueryBuilder createdByIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'createdBy', + value: '', + )); + }); + } + + QueryBuilder dataIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'data', + )); + }); + } + + QueryBuilder dataIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'data', + )); + }); + } + + QueryBuilder idEqualTo(int value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'id', + value: value, + )); + }); + } + + QueryBuilder idGreaterThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'id', + value: value, + )); + }); + } + + QueryBuilder idLessThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'id', + value: value, + )); + }); + } + + QueryBuilder idBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'id', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder messageIdIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'messageId', + )); + }); + } + + QueryBuilder messageIdIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'messageId', + )); + }); + } + + QueryBuilder messageIdEqualTo( + int? value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'messageId', + value: value, + )); + }); + } + + QueryBuilder messageIdGreaterThan( + int? value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'messageId', + value: value, + )); + }); + } + + QueryBuilder messageIdLessThan( + int? value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'messageId', + value: value, + )); + }); + } + + QueryBuilder messageIdBetween( + int? lower, + int? upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'messageId', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder optionsLengthEqualTo( + int length) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'options', + length, + true, + length, + true, + ); + }); + } + + QueryBuilder optionsIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'options', + 0, + true, + 0, + true, + ); + }); + } + + QueryBuilder optionsIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'options', + 0, + false, + 999999, + true, + ); + }); + } + + QueryBuilder optionsLengthLessThan( + int length, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'options', + 0, + true, + length, + include, + ); + }); + } + + QueryBuilder optionsLengthGreaterThan( + int length, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'options', + length, + include, + 999999, + true, + ); + }); + } + + QueryBuilder optionsLengthBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'options', + lower, + includeLower, + upper, + includeUpper, + ); + }); + } + + QueryBuilder statusEqualTo( + PollStatus value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'status', + value: value, + )); + }); + } + + QueryBuilder statusGreaterThan( + PollStatus value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'status', + value: value, + )); + }); + } + + QueryBuilder statusLessThan( + PollStatus value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'status', + value: value, + )); + }); + } + + QueryBuilder statusBetween( + PollStatus lower, + PollStatus upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'status', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder titleEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'title', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder titleGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'title', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder titleLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'title', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder titleBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'title', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder titleStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'title', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder titleEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'title', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder titleContains(String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'title', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder titleMatches(String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'title', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder titleIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'title', + value: '', + )); + }); + } + + QueryBuilder titleIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'title', + value: '', + )); + }); + } + + QueryBuilder updatedAtEqualTo( + int value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'updatedAt', + value: value, + )); + }); + } + + QueryBuilder updatedAtGreaterThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'updatedAt', + value: value, + )); + }); + } + + QueryBuilder updatedAtLessThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'updatedAt', + value: value, + )); + }); + } + + QueryBuilder updatedAtBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'updatedAt', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder votedPollOptionIdsIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'votedPollOptionIds', + )); + }); + } + + QueryBuilder + votedPollOptionIdsIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'votedPollOptionIds', + )); + }); + } + + QueryBuilder + votedPollOptionIdsElementEqualTo(int value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'votedPollOptionIds', + value: value, + )); + }); + } + + QueryBuilder + votedPollOptionIdsElementGreaterThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'votedPollOptionIds', + value: value, + )); + }); + } + + QueryBuilder + votedPollOptionIdsElementLessThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'votedPollOptionIds', + value: value, + )); + }); + } + + QueryBuilder + votedPollOptionIdsElementBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'votedPollOptionIds', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + votedPollOptionIdsLengthEqualTo(int length) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'votedPollOptionIds', + length, + true, + length, + true, + ); + }); + } + + QueryBuilder + votedPollOptionIdsIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'votedPollOptionIds', + 0, + true, + 0, + true, + ); + }); + } + + QueryBuilder + votedPollOptionIdsIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'votedPollOptionIds', + 0, + false, + 999999, + true, + ); + }); + } + + QueryBuilder + votedPollOptionIdsLengthLessThan( + int length, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'votedPollOptionIds', + 0, + true, + length, + include, + ); + }); + } + + QueryBuilder + votedPollOptionIdsLengthGreaterThan( + int length, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'votedPollOptionIds', + length, + include, + 999999, + true, + ); + }); + } + + QueryBuilder + votedPollOptionIdsLengthBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'votedPollOptionIds', + lower, + includeLower, + upper, + includeUpper, + ); + }); + } + + QueryBuilder voterCountEqualTo( + int value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'voterCount', + value: value, + )); + }); + } + + QueryBuilder voterCountGreaterThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'voterCount', + value: value, + )); + }); + } + + QueryBuilder voterCountLessThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'voterCount', + value: value, + )); + }); + } + + QueryBuilder voterCountBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'voterCount', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } +} + +extension CPollQueryObject on QueryBuilder { + QueryBuilder data( + FilterQuery q) { + return QueryBuilder.apply(this, (query) { + return query.object(q, r'data'); + }); + } + + QueryBuilder optionsElement( + FilterQuery q) { + return QueryBuilder.apply(this, (query) { + return query.object(q, r'options'); + }); + } +} + +// coverage:ignore-file +// ignore_for_file: duplicate_ignore, non_constant_identifier_names, constant_identifier_names, invalid_use_of_protected_member, unnecessary_cast, prefer_const_constructors, lines_longer_than_80_chars, require_trailing_commas, inference_failure_on_function_invocation, unnecessary_parenthesis, unnecessary_raw_strings, unnecessary_null_checks, join_return_with_assignment, prefer_final_locals, avoid_js_rounded_ints, avoid_positional_boolean_parameters, always_specify_types + +final CPollDataSchema = Schema( + name: r'CPollData', + id: BigInt.parse('213822990569344781').toInt(), + properties: { + r'text': PropertySchema( + id: 0, + name: r'text', + type: IsarType.string, + ) + }, + estimateSize: _cPollDataEstimateSize, + serialize: _cPollDataSerialize, + deserialize: _cPollDataDeserialize, + deserializeProp: _cPollDataDeserializeProp, +); + +int _cPollDataEstimateSize( + CPollData object, + List offsets, + Map> allOffsets, +) { + var bytesCount = offsets.last; + bytesCount += 3 + object.text.length * 3; + return bytesCount; +} + +void _cPollDataSerialize( + CPollData object, + IsarWriter writer, + List offsets, + Map> allOffsets, +) { + writer.writeString(offsets[0], object.text); +} + +CPollData _cPollDataDeserialize( + Id id, + IsarReader reader, + List offsets, + Map> allOffsets, +) { + final object = CPollData(); + object.text = reader.readString(offsets[0]); + return object; +} + +P _cPollDataDeserializeProp

( + IsarReader reader, + int propertyId, + int offset, + Map> allOffsets, +) { + switch (propertyId) { + case 0: + return (reader.readString(offset)) as P; + default: + throw IsarError('Unknown property with id $propertyId'); + } +} + +extension CPollDataQueryFilter + on QueryBuilder { + QueryBuilder textEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'text', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder textGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'text', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder textLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'text', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder textBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'text', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder textStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'text', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder textEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'text', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder textContains( + String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'text', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder textMatches( + String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'text', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder textIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'text', + value: '', + )); + }); + } + + QueryBuilder textIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'text', + value: '', + )); + }); + } +} + +extension CPollDataQueryObject + on QueryBuilder {} + +// coverage:ignore-file +// ignore_for_file: duplicate_ignore, non_constant_identifier_names, constant_identifier_names, invalid_use_of_protected_member, unnecessary_cast, prefer_const_constructors, lines_longer_than_80_chars, require_trailing_commas, inference_failure_on_function_invocation, unnecessary_parenthesis, unnecessary_raw_strings, unnecessary_null_checks, join_return_with_assignment, prefer_final_locals, avoid_js_rounded_ints, avoid_positional_boolean_parameters, always_specify_types + +final CPollOptionSchema = Schema( + name: r'CPollOption', + id: BigInt.parse('-1226183442370331930').toInt(), + properties: { + r'createdAt': PropertySchema( + id: 0, + name: r'createdAt', + type: IsarType.long, + ), + r'createdBy': PropertySchema( + id: 1, + name: r'createdBy', + type: IsarType.string, + ), + r'id': PropertySchema( + id: 2, + name: r'id', + type: IsarType.long, + ), + r'pollId': PropertySchema( + id: 3, + name: r'pollId', + type: IsarType.long, + ), + r'text': PropertySchema( + id: 4, + name: r'text', + type: IsarType.string, + ), + r'updatedAt': PropertySchema( + id: 5, + name: r'updatedAt', + type: IsarType.long, + ), + r'voteCount': PropertySchema( + id: 6, + name: r'voteCount', + type: IsarType.long, + ) + }, + estimateSize: _cPollOptionEstimateSize, + serialize: _cPollOptionSerialize, + deserialize: _cPollOptionDeserialize, + deserializeProp: _cPollOptionDeserializeProp, +); + +int _cPollOptionEstimateSize( + CPollOption object, + List offsets, + Map> allOffsets, +) { + var bytesCount = offsets.last; + { + final value = object.createdBy; + if (value != null) { + bytesCount += 3 + value.length * 3; + } + } + bytesCount += 3 + object.text.length * 3; + return bytesCount; +} + +void _cPollOptionSerialize( + CPollOption object, + IsarWriter writer, + List offsets, + Map> allOffsets, +) { + writer.writeLong(offsets[0], object.createdAt); + writer.writeString(offsets[1], object.createdBy); + writer.writeLong(offsets[2], object.id); + writer.writeLong(offsets[3], object.pollId); + writer.writeString(offsets[4], object.text); + writer.writeLong(offsets[5], object.updatedAt); + writer.writeLong(offsets[6], object.voteCount); +} + +CPollOption _cPollOptionDeserialize( + Id id, + IsarReader reader, + List offsets, + Map> allOffsets, +) { + final object = CPollOption(); + object.createdAt = reader.readLong(offsets[0]); + object.createdBy = reader.readStringOrNull(offsets[1]); + object.id = reader.readLong(offsets[2]); + object.pollId = reader.readLong(offsets[3]); + object.text = reader.readString(offsets[4]); + object.updatedAt = reader.readLong(offsets[5]); + object.voteCount = reader.readLong(offsets[6]); + return object; +} + +P _cPollOptionDeserializeProp

( + IsarReader reader, + int propertyId, + int offset, + Map> allOffsets, +) { + switch (propertyId) { + case 0: + return (reader.readLong(offset)) as P; + case 1: + return (reader.readStringOrNull(offset)) as P; + case 2: + return (reader.readLong(offset)) as P; + case 3: + return (reader.readLong(offset)) as P; + case 4: + return (reader.readString(offset)) as P; + case 5: + return (reader.readLong(offset)) as P; + case 6: + return (reader.readLong(offset)) as P; + default: + throw IsarError('Unknown property with id $propertyId'); + } +} + +extension CPollOptionQueryFilter + on QueryBuilder { + QueryBuilder + createdAtEqualTo(int value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'createdAt', + value: value, + )); + }); + } + + QueryBuilder + createdAtGreaterThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'createdAt', + value: value, + )); + }); + } + + QueryBuilder + createdAtLessThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'createdAt', + value: value, + )); + }); + } + + QueryBuilder + createdAtBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'createdAt', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + createdByIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'createdBy', + )); + }); + } + + QueryBuilder + createdByIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'createdBy', + )); + }); + } + + QueryBuilder + createdByEqualTo( + String? value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'createdBy', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + createdByGreaterThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'createdBy', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + createdByLessThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'createdBy', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + createdByBetween( + String? lower, + String? upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'createdBy', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + createdByStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'createdBy', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + createdByEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'createdBy', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + createdByContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'createdBy', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + createdByMatches(String pattern, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'createdBy', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + createdByIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'createdBy', + value: '', + )); + }); + } + + QueryBuilder + createdByIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'createdBy', + value: '', + )); + }); + } + + QueryBuilder idEqualTo( + int value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'id', + value: value, + )); + }); + } + + QueryBuilder idGreaterThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'id', + value: value, + )); + }); + } + + QueryBuilder idLessThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'id', + value: value, + )); + }); + } + + QueryBuilder idBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'id', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder pollIdEqualTo( + int value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'pollId', + value: value, + )); + }); + } + + QueryBuilder + pollIdGreaterThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'pollId', + value: value, + )); + }); + } + + QueryBuilder pollIdLessThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'pollId', + value: value, + )); + }); + } + + QueryBuilder pollIdBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'pollId', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder textEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'text', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder textGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'text', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder textLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'text', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder textBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'text', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder textStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'text', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder textEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'text', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder textContains( + String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'text', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder textMatches( + String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'text', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder textIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'text', + value: '', + )); + }); + } + + QueryBuilder + textIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'text', + value: '', + )); + }); + } + + QueryBuilder + updatedAtEqualTo(int value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'updatedAt', + value: value, + )); + }); + } + + QueryBuilder + updatedAtGreaterThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'updatedAt', + value: value, + )); + }); + } + + QueryBuilder + updatedAtLessThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'updatedAt', + value: value, + )); + }); + } + + QueryBuilder + updatedAtBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'updatedAt', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + voteCountEqualTo(int value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'voteCount', + value: value, + )); + }); + } + + QueryBuilder + voteCountGreaterThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'voteCount', + value: value, + )); + }); + } + + QueryBuilder + voteCountLessThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'voteCount', + value: value, + )); + }); + } + + QueryBuilder + voteCountBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'voteCount', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } +} + +extension CPollOptionQueryObject + on QueryBuilder {} diff --git a/lib/src/internal/db/schema/message/meta/c_channel_access.dart b/lib/src/internal/db/schema/message/meta/c_channel_access.dart new file mode 100644 index 00000000..b1d9decd --- /dev/null +++ b/lib/src/internal/db/schema/message/meta/c_channel_access.dart @@ -0,0 +1,60 @@ +// Copyright (c) 2023 Sendbird, Inc. All rights reserved. + +import 'package:isar/isar.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/message/meta/channel_access.dart'; +import 'package:sendbird_chat_sdk/src/internal/main/chat/chat.dart'; + +part 'c_channel_access.g.dart'; + +@collection +class CChannelAccess { + Id id = Isar.autoIncrement; + + @Index(unique: true, replace: true) + late String channelUrl; + + @Index() + late int lastAccessedAt; + + CChannelAccess(); + + factory CChannelAccess.fromChannelAccess(ChannelAccess access) { + return CChannelAccess() + ..channelUrl = access.channelUrl + ..lastAccessedAt = access.lastAccessedAt; + } + + Future toChannelAccess(Chat chat, Isar isar) async { + return ChannelAccess( + channelUrl: channelUrl, + lastAccessedAt: lastAccessedAt, + ); + } + + static Future upsert( + Chat chat, Isar isar, ChannelAccess access) async { + final cChannelAccess = CChannelAccess.fromChannelAccess(access); + + // ChannelAccess + await chat.dbManager.write(() async { + await isar.cChannelAccess.put(cChannelAccess); + }); + + return cChannelAccess; + } + + static Future get( + Chat chat, Isar isar, String channelUrl) async { + final cChannelAccess = await isar.cChannelAccess + .where() + .channelUrlEqualTo(channelUrl) + .findFirst(); + return await cChannelAccess?.toChannelAccess(chat, isar); + } + + static Future delete(Chat chat, Isar isar, String channelUrl) async { + await chat.dbManager.write(() async { + await isar.cChannelAccess.deleteByChannelUrl(channelUrl); + }); + } +} diff --git a/lib/src/internal/db/schema/message/meta/c_channel_access.g.dart b/lib/src/internal/db/schema/message/meta/c_channel_access.g.dart new file mode 100644 index 00000000..426a70e8 --- /dev/null +++ b/lib/src/internal/db/schema/message/meta/c_channel_access.g.dart @@ -0,0 +1,784 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'c_channel_access.dart'; + +// ************************************************************************** +// IsarCollectionGenerator +// ************************************************************************** + +// coverage:ignore-file +// ignore_for_file: duplicate_ignore, non_constant_identifier_names, constant_identifier_names, invalid_use_of_protected_member, unnecessary_cast, prefer_const_constructors, lines_longer_than_80_chars, require_trailing_commas, inference_failure_on_function_invocation, unnecessary_parenthesis, unnecessary_raw_strings, unnecessary_null_checks, join_return_with_assignment, prefer_final_locals, avoid_js_rounded_ints, avoid_positional_boolean_parameters, always_specify_types + +extension GetCChannelAccessCollection on Isar { + IsarCollection get cChannelAccess => this.collection(); +} + +final CChannelAccessSchema = CollectionSchema( + name: r'CChannelAccess', + id: BigInt.parse('-6628375663287460931').toInt(), + properties: { + r'channelUrl': PropertySchema( + id: 0, + name: r'channelUrl', + type: IsarType.string, + ), + r'lastAccessedAt': PropertySchema( + id: 1, + name: r'lastAccessedAt', + type: IsarType.long, + ) + }, + estimateSize: _cChannelAccessEstimateSize, + serialize: _cChannelAccessSerialize, + deserialize: _cChannelAccessDeserialize, + deserializeProp: _cChannelAccessDeserializeProp, + idName: r'id', + indexes: { + r'channelUrl': IndexSchema( + id: BigInt.parse('6636052684858767397').toInt(), + name: r'channelUrl', + unique: true, + replace: true, + properties: [ + IndexPropertySchema( + name: r'channelUrl', + type: IndexType.hash, + caseSensitive: true, + ) + ], + ), + r'lastAccessedAt': IndexSchema( + id: BigInt.parse('7637973981624628205').toInt(), + name: r'lastAccessedAt', + unique: false, + replace: false, + properties: [ + IndexPropertySchema( + name: r'lastAccessedAt', + type: IndexType.value, + caseSensitive: false, + ) + ], + ) + }, + links: {}, + embeddedSchemas: {}, + getId: _cChannelAccessGetId, + getLinks: _cChannelAccessGetLinks, + attach: _cChannelAccessAttach, + version: '3.1.0+1', +); + +int _cChannelAccessEstimateSize( + CChannelAccess object, + List offsets, + Map> allOffsets, +) { + var bytesCount = offsets.last; + bytesCount += 3 + object.channelUrl.length * 3; + return bytesCount; +} + +void _cChannelAccessSerialize( + CChannelAccess object, + IsarWriter writer, + List offsets, + Map> allOffsets, +) { + writer.writeString(offsets[0], object.channelUrl); + writer.writeLong(offsets[1], object.lastAccessedAt); +} + +CChannelAccess _cChannelAccessDeserialize( + Id id, + IsarReader reader, + List offsets, + Map> allOffsets, +) { + final object = CChannelAccess(); + object.channelUrl = reader.readString(offsets[0]); + object.id = id; + object.lastAccessedAt = reader.readLong(offsets[1]); + return object; +} + +P _cChannelAccessDeserializeProp

( + IsarReader reader, + int propertyId, + int offset, + Map> allOffsets, +) { + switch (propertyId) { + case 0: + return (reader.readString(offset)) as P; + case 1: + return (reader.readLong(offset)) as P; + default: + throw IsarError('Unknown property with id $propertyId'); + } +} + +Id _cChannelAccessGetId(CChannelAccess object) { + return object.id; +} + +List> _cChannelAccessGetLinks(CChannelAccess object) { + return []; +} + +void _cChannelAccessAttach( + IsarCollection col, Id id, CChannelAccess object) { + object.id = id; +} + +extension CChannelAccessByIndex on IsarCollection { + Future getByChannelUrl(String channelUrl) { + return getByIndex(r'channelUrl', [channelUrl]); + } + + CChannelAccess? getByChannelUrlSync(String channelUrl) { + return getByIndexSync(r'channelUrl', [channelUrl]); + } + + Future deleteByChannelUrl(String channelUrl) { + return deleteByIndex(r'channelUrl', [channelUrl]); + } + + bool deleteByChannelUrlSync(String channelUrl) { + return deleteByIndexSync(r'channelUrl', [channelUrl]); + } + + Future> getAllByChannelUrl( + List channelUrlValues) { + final values = channelUrlValues.map((e) => [e]).toList(); + return getAllByIndex(r'channelUrl', values); + } + + List getAllByChannelUrlSync(List channelUrlValues) { + final values = channelUrlValues.map((e) => [e]).toList(); + return getAllByIndexSync(r'channelUrl', values); + } + + Future deleteAllByChannelUrl(List channelUrlValues) { + final values = channelUrlValues.map((e) => [e]).toList(); + return deleteAllByIndex(r'channelUrl', values); + } + + int deleteAllByChannelUrlSync(List channelUrlValues) { + final values = channelUrlValues.map((e) => [e]).toList(); + return deleteAllByIndexSync(r'channelUrl', values); + } + + Future putByChannelUrl(CChannelAccess object) { + return putByIndex(r'channelUrl', object); + } + + Id putByChannelUrlSync(CChannelAccess object, {bool saveLinks = true}) { + return putByIndexSync(r'channelUrl', object, saveLinks: saveLinks); + } + + Future> putAllByChannelUrl(List objects) { + return putAllByIndex(r'channelUrl', objects); + } + + List putAllByChannelUrlSync(List objects, + {bool saveLinks = true}) { + return putAllByIndexSync(r'channelUrl', objects, saveLinks: saveLinks); + } +} + +extension CChannelAccessQueryWhereSort + on QueryBuilder { + QueryBuilder anyId() { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(const IdWhereClause.any()); + }); + } + + QueryBuilder + anyLastAccessedAt() { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause( + const IndexWhereClause.any(indexName: r'lastAccessedAt'), + ); + }); + } +} + +extension CChannelAccessQueryWhere + on QueryBuilder { + QueryBuilder idEqualTo( + Id id) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IdWhereClause.between( + lower: id, + upper: id, + )); + }); + } + + QueryBuilder idNotEqualTo( + Id id) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause( + IdWhereClause.lessThan(upper: id, includeUpper: false), + ) + .addWhereClause( + IdWhereClause.greaterThan(lower: id, includeLower: false), + ); + } else { + return query + .addWhereClause( + IdWhereClause.greaterThan(lower: id, includeLower: false), + ) + .addWhereClause( + IdWhereClause.lessThan(upper: id, includeUpper: false), + ); + } + }); + } + + QueryBuilder idGreaterThan( + Id id, + {bool include = false}) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause( + IdWhereClause.greaterThan(lower: id, includeLower: include), + ); + }); + } + + QueryBuilder idLessThan( + Id id, + {bool include = false}) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause( + IdWhereClause.lessThan(upper: id, includeUpper: include), + ); + }); + } + + QueryBuilder idBetween( + Id lowerId, + Id upperId, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IdWhereClause.between( + lower: lowerId, + includeLower: includeLower, + upper: upperId, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + channelUrlEqualTo(String channelUrl) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.equalTo( + indexName: r'channelUrl', + value: [channelUrl], + )); + }); + } + + QueryBuilder + channelUrlNotEqualTo(String channelUrl) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'channelUrl', + lower: [], + upper: [channelUrl], + includeUpper: false, + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'channelUrl', + lower: [channelUrl], + includeLower: false, + upper: [], + )); + } else { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'channelUrl', + lower: [channelUrl], + includeLower: false, + upper: [], + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'channelUrl', + lower: [], + upper: [channelUrl], + includeUpper: false, + )); + } + }); + } + + QueryBuilder + lastAccessedAtEqualTo(int lastAccessedAt) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.equalTo( + indexName: r'lastAccessedAt', + value: [lastAccessedAt], + )); + }); + } + + QueryBuilder + lastAccessedAtNotEqualTo(int lastAccessedAt) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'lastAccessedAt', + lower: [], + upper: [lastAccessedAt], + includeUpper: false, + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'lastAccessedAt', + lower: [lastAccessedAt], + includeLower: false, + upper: [], + )); + } else { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'lastAccessedAt', + lower: [lastAccessedAt], + includeLower: false, + upper: [], + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'lastAccessedAt', + lower: [], + upper: [lastAccessedAt], + includeUpper: false, + )); + } + }); + } + + QueryBuilder + lastAccessedAtGreaterThan( + int lastAccessedAt, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.between( + indexName: r'lastAccessedAt', + lower: [lastAccessedAt], + includeLower: include, + upper: [], + )); + }); + } + + QueryBuilder + lastAccessedAtLessThan( + int lastAccessedAt, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.between( + indexName: r'lastAccessedAt', + lower: [], + upper: [lastAccessedAt], + includeUpper: include, + )); + }); + } + + QueryBuilder + lastAccessedAtBetween( + int lowerLastAccessedAt, + int upperLastAccessedAt, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.between( + indexName: r'lastAccessedAt', + lower: [lowerLastAccessedAt], + includeLower: includeLower, + upper: [upperLastAccessedAt], + includeUpper: includeUpper, + )); + }); + } +} + +extension CChannelAccessQueryFilter + on QueryBuilder { + QueryBuilder + channelUrlEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'channelUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + channelUrlGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'channelUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + channelUrlLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'channelUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + channelUrlBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'channelUrl', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + channelUrlStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'channelUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + channelUrlEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'channelUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + channelUrlContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'channelUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + channelUrlMatches(String pattern, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'channelUrl', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + channelUrlIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'channelUrl', + value: '', + )); + }); + } + + QueryBuilder + channelUrlIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'channelUrl', + value: '', + )); + }); + } + + QueryBuilder idEqualTo( + Id value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'id', + value: value, + )); + }); + } + + QueryBuilder + idGreaterThan( + Id value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'id', + value: value, + )); + }); + } + + QueryBuilder + idLessThan( + Id value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'id', + value: value, + )); + }); + } + + QueryBuilder idBetween( + Id lower, + Id upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'id', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + lastAccessedAtEqualTo(int value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'lastAccessedAt', + value: value, + )); + }); + } + + QueryBuilder + lastAccessedAtGreaterThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'lastAccessedAt', + value: value, + )); + }); + } + + QueryBuilder + lastAccessedAtLessThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'lastAccessedAt', + value: value, + )); + }); + } + + QueryBuilder + lastAccessedAtBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'lastAccessedAt', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } +} + +extension CChannelAccessQueryObject + on QueryBuilder {} + +extension CChannelAccessQueryLinks + on QueryBuilder {} + +extension CChannelAccessQuerySortBy + on QueryBuilder { + QueryBuilder + sortByChannelUrl() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'channelUrl', Sort.asc); + }); + } + + QueryBuilder + sortByChannelUrlDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'channelUrl', Sort.desc); + }); + } + + QueryBuilder + sortByLastAccessedAt() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'lastAccessedAt', Sort.asc); + }); + } + + QueryBuilder + sortByLastAccessedAtDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'lastAccessedAt', Sort.desc); + }); + } +} + +extension CChannelAccessQuerySortThenBy + on QueryBuilder { + QueryBuilder + thenByChannelUrl() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'channelUrl', Sort.asc); + }); + } + + QueryBuilder + thenByChannelUrlDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'channelUrl', Sort.desc); + }); + } + + QueryBuilder thenById() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'id', Sort.asc); + }); + } + + QueryBuilder thenByIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'id', Sort.desc); + }); + } + + QueryBuilder + thenByLastAccessedAt() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'lastAccessedAt', Sort.asc); + }); + } + + QueryBuilder + thenByLastAccessedAtDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'lastAccessedAt', Sort.desc); + }); + } +} + +extension CChannelAccessQueryWhereDistinct + on QueryBuilder { + QueryBuilder distinctByChannelUrl( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'channelUrl', caseSensitive: caseSensitive); + }); + } + + QueryBuilder + distinctByLastAccessedAt() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'lastAccessedAt'); + }); + } +} + +extension CChannelAccessQueryProperty + on QueryBuilder { + QueryBuilder idProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'id'); + }); + } + + QueryBuilder channelUrlProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'channelUrl'); + }); + } + + QueryBuilder lastAccessedAtProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'lastAccessedAt'); + }); + } +} diff --git a/lib/src/internal/db/schema/message/meta/c_channel_message.dart b/lib/src/internal/db/schema/message/meta/c_channel_message.dart new file mode 100644 index 00000000..83f2958a --- /dev/null +++ b/lib/src/internal/db/schema/message/meta/c_channel_message.dart @@ -0,0 +1,472 @@ +// Copyright (c) 2023 Sendbird, Inc. All rights reserved. + +import 'package:isar/isar.dart'; +import 'package:sendbird_chat_sdk/sendbird_chat_sdk.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/message/c_admin_message.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/message/c_file_message.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/message/c_notification_message.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/message/c_user_message.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/message/meta/c_channel_access.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/message/meta/channel_access.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/message/meta/channel_message.dart'; +import 'package:sendbird_chat_sdk/src/internal/main/chat/chat.dart'; + +part 'c_channel_message.g.dart'; + +@collection +class CChannelMessage { + Id id = Isar.autoIncrement; + + @Index(unique: true, replace: true) + late String rootId; + + @Index(composite: [CompositeIndex('rootId')]) + @enumerated + late MessageType messageType; + + @Index() + late String channelUrl; + + @Index(composite: [CompositeIndex('channelUrl')]) + @enumerated + late ChannelType channelType; + + @Index() + late int createdAt; + + @Index() + @enumerated + late SendingStatus sendingStatus; // sendingStatus for filtering + + late String? customType; // customType for filtering + late String? senderId; // senderId for filtering + + CChannelMessage(); + + factory CChannelMessage.fromChannelMessage(ChannelMessage message) { + return CChannelMessage() + ..rootId = message.rootId + ..messageType = message.messageType + ..channelUrl = message.channelUrl + ..channelType = message.channelType + ..createdAt = message.createdAt + ..sendingStatus = message.sendingStatus + ..customType = message.customType + ..senderId = message.senderId; + } + + Future toChannelMessage(Chat chat, Isar isar) async { + late RootMessage? message; + if (messageType == MessageType.user) { + final cUserMessage = await isar.cUserMessages.getByRootId(rootId); + message = await cUserMessage?.toUserMessage(chat, isar); + } else if (messageType == MessageType.file) { + final cFileMessage = await isar.cFileMessages.getByRootId(rootId); + message = await cFileMessage?.toFileMessage(chat, isar); + } else if (messageType == MessageType.admin) { + final cAdminMessage = await isar.cAdminMessages.getByRootId(rootId); + message = await cAdminMessage?.toAdminMessage(chat, isar); + } else if (messageType == MessageType.notification) { + final cNotificationMessage = + await isar.cNotificationMessages.getByRootId(rootId); + message = await cNotificationMessage?.toNotificationMessage(chat, isar); + } + + return message != null + ? ChannelMessage( + rootId: rootId, + messageType: messageType, + channelUrl: channelUrl, + channelType: channelType, + createdAt: createdAt, + sendingStatus: sendingStatus, + customType: customType, + senderId: senderId, + message: message, + ) + : null; + } + + static Future hasMessages( + Chat chat, Isar isar, String channelUrl) async { + return await isar.cChannelMessages + .where() + .channelUrlEqualTo(channelUrl) + .isNotEmpty(); + } + + static Future upsert( + Chat chat, Isar isar, RootMessage message) async { + final cChannelMessage = CChannelMessage.fromChannelMessage( + ChannelMessage( + rootId: message.rootId, + messageType: message.messageType, + channelUrl: message.channelUrl, + channelType: message.channelType, + createdAt: message.createdAt, + sendingStatus: message is BaseMessage + ? (message.sendingStatus ?? SendingStatus.none) + : SendingStatus.succeeded, + customType: message.customType, + senderId: message is BaseMessage ? message.sender?.userId : null, + message: message, + ), + ); + + // ChannelMessage + await chat.dbManager.write(() async { + await isar.cChannelMessages.put(cChannelMessage); + }); + + // ChannelAccess + await CChannelAccess.upsert( + chat, + isar, + ChannelAccess( + channelUrl: message.channelUrl, + lastAccessedAt: DateTime.now().millisecondsSinceEpoch, + ), + ); + + return cChannelMessage; + } + + static Future get( + Chat chat, Isar isar, String rootId) async { + final cChannelMessage = + await isar.cChannelMessages.where().rootIdEqualTo(rootId).findFirst(); + return await cChannelMessage?.toChannelMessage(chat, isar); + } + + static Future> getMessages( + Chat chat, + Isar isar, + ChannelType channelType, + String channelUrl, + SendingStatus sendingStatus, + int timestamp, + MessageListParams params, + bool isPrevious, // false: Next + ) async { + // [includeMetaArray] + // When calling API, this value have to be `true` to make chunk. + + // [includeReactions] + // When calling API, this value have to be `true` to make chunk. + + // [includeThreadInfo] + // When calling API, this value have to be `true` to make chunk. + + // [includeParentMessageInfo] + // When calling API, this value have to be `true` to make chunk. + + // [replyType] + // Must call API, because this can not be queried with local cache. + + // [showSubChannelMessagesOnly] + // Must call API, because this can not be queried with local cache. + + final cChannelMessages = await isar.cChannelMessages + .where() + + // channelType & channelUrl & reverse + .channelTypeChannelUrlEqualTo(channelType, channelUrl) + .filter() + + // sendingStatus + .optional(sendingStatus == SendingStatus.succeeded, (q) { + return q.sendingStatusEqualTo(SendingStatus.succeeded); + }) + .optional(sendingStatus == SendingStatus.failed, (q) { + return q.sendingStatusEqualTo(SendingStatus.failed); + }) + .optional(sendingStatus == SendingStatus.pending, (q) { + return q.sendingStatusEqualTo(SendingStatus.pending); + }) + + // timestamp & inclusive & reverse + .optional(isPrevious, (q) { + return q.createdAtLessThan(timestamp, include: params.inclusive); + }) + .optional(isPrevious == false, (q) { + return q.createdAtGreaterThan(timestamp, include: params.inclusive); + }) + + // messageType + .optional(params.messageType == MessageTypeFilter.user, (q) { + return q.messageTypeEqualTo(MessageType.user); + }) + .optional(params.messageType == MessageTypeFilter.file, (q) { + return q.messageTypeEqualTo(MessageType.file); + }) + .optional(params.messageType == MessageTypeFilter.admin, (q) { + return q.messageTypeEqualTo(MessageType.admin); + }) + + // customTypes + .optional(params.customTypes != null, (q) { + return q.group((groupQ) { + late QueryBuilder qb; + bool isFirst = true; + for (final customType in params.customTypes!) { + if (isFirst) { + qb = groupQ.customTypeEqualTo(customType); + isFirst = false; + } else { + qb = qb.or().customTypeEqualTo(customType); + } + } + return qb; + }); + }) + + // senderIds + .optional(params.senderIds != null, (q) { + return q.group((groupQ) { + late QueryBuilder qb; + bool isFirst = true; + for (final senderId in params.senderIds!) { + if (isFirst) { + qb = groupQ.senderIdEqualTo(senderId); + isFirst = false; + } else { + qb = qb.or().senderIdEqualTo(senderId); + } + } + return qb; + }); + }) + + // isPrevious & reverse + .optional(isPrevious, (q) { + return q.sortByCreatedAtDesc(); + }) + .optional(isPrevious == false, (q) { + return q.thenByCreatedAt(); + }) + + // previousResultSize & params.nextResultSize + .limit(isPrevious ? params.previousResultSize : params.nextResultSize) + .findAll(); + + List messages = []; + for (final cChannelMessage in cChannelMessages) { + final message = await cChannelMessage.toChannelMessage(chat, isar); + if (message != null) { + messages.add(message.message); + } + } + + // reversed + if (messages.length >= 2) { + if ((isPrevious && !params.reverse) || (!isPrevious && params.reverse)) { + messages = messages.reversed.toList(); + } + } + + return messages; + } + + static Future> getPendingMessages( + Chat chat, + Isar isar, + ChannelType channelType, + String channelUrl, + ) async { + final cChannelMessages = await isar.cChannelMessages + .where() + .channelTypeChannelUrlEqualTo(channelType, channelUrl) + .filter() + .sendingStatusEqualTo(SendingStatus.pending) + .sortByCreatedAt() + .findAll(); + + List messages = []; + for (final cChannelMessage in cChannelMessages) { + final message = await cChannelMessage.toChannelMessage(chat, isar); + if (message != null && message.message is BaseMessage) { + messages.add(message.message as BaseMessage); + } + } + + return messages; + } + + static Future> getFailedMessages( + Chat chat, + Isar isar, + ChannelType channelType, + String channelUrl, + bool reverse, + ) async { + final cChannelMessages = await isar.cChannelMessages + .where() + .channelTypeChannelUrlEqualTo(channelType, channelUrl) + .filter() + .sendingStatusEqualTo(SendingStatus.failed) + .optional(!reverse, (q) => q.sortByCreatedAt()) + .optional(reverse, (q) => q.thenByCreatedAtDesc()) + .findAll(); + + List messages = []; + for (final cChannelMessage in cChannelMessages) { + final message = await cChannelMessage.toChannelMessage(chat, isar); + if (message != null && message.message is BaseMessage) { + messages.add(message.message as BaseMessage); + } + } + + return messages; + } + + static Future removeFailedMessages( + Chat chat, + Isar isar, + ChannelType channelType, + String channelUrl, + List messages, + ) async { + await chat.dbManager.write(() async { + // ChannelMessage + await isar.cChannelMessages.deleteAllByRootId(messages + .where((message) => message.sendingStatus == SendingStatus.failed) + .map((message) => message.rootId) + .toList()); + + // UserMessage + await isar.cUserMessages.deleteAllByRootId(messages + .where((message) => message.sendingStatus == SendingStatus.failed) + .map((message) => message.rootId) + .toList()); + + // FileMessage + await isar.cFileMessages.deleteAllByRootId(messages + .where((message) => message.sendingStatus == SendingStatus.failed) + .map((message) => message.rootId) + .toList()); + }); + } + + static Future removeAllFailedMessages( + Chat chat, + Isar isar, + ChannelType channelType, + String channelUrl, + ) async { + await chat.dbManager.write(() async { + // ChannelMessage + await isar.cChannelMessages + .where() + .channelTypeChannelUrlEqualTo(channelType, channelUrl) + .filter() + .sendingStatusEqualTo(SendingStatus.failed) + .deleteAll(); + + // UserMessage + await isar.cUserMessages + .where() + .channelTypeChannelUrlEqualTo(channelType, channelUrl) + .filter() + .sendingStatusEqualTo(SendingStatus.failed) + .deleteAll(); + + // FileMessage + await isar.cFileMessages + .where() + .channelTypeChannelUrlEqualTo(channelType, channelUrl) + .filter() + .sendingStatusEqualTo(SendingStatus.failed) + .deleteAll(); + }); + } + + static Future removeAllPendingMessages( + Chat chat, + Isar isar, + ChannelType channelType, + String channelUrl, + ) async { + await chat.dbManager.write(() async { + // ChannelMessage + await isar.cChannelMessages + .where() + .channelTypeChannelUrlEqualTo(channelType, channelUrl) + .filter() + .sendingStatusEqualTo(SendingStatus.pending) + .deleteAll(); + + // UserMessage + await isar.cUserMessages + .where() + .channelTypeChannelUrlEqualTo(channelType, channelUrl) + .filter() + .sendingStatusEqualTo(SendingStatus.pending) + .deleteAll(); + + // FileMessage + await isar.cFileMessages + .where() + .channelTypeChannelUrlEqualTo(channelType, channelUrl) + .filter() + .sendingStatusEqualTo(SendingStatus.pending) + .deleteAll(); + }); + } + + static Future> getStartingPointMessages( + Chat chat, + Isar isar, + ChannelType channelType, + String channelUrl, + int timestamp, + ) async { + // [includeMetaArray] + // When calling API, this value have to be `true` to make chunk. + + // [includeReactions] + // When calling API, this value have to be `true` to make chunk. + + // [includeThreadInfo] + // When calling API, this value have to be `true` to make chunk. + + // [includeParentMessageInfo] + // When calling API, this value have to be `true` to make chunk. + + // [replyType] + // Must call API, because this can not be queried with local cache. + + // [showSubChannelMessagesOnly] + // Must call API, because this can not be queried with local cache. + + final cChannelMessages = await isar.cChannelMessages + .where() + + // channelType & channelUrl & reverse + .channelTypeChannelUrlEqualTo(channelType, channelUrl) + .filter() + + // timestamp + .createdAtEqualTo(timestamp) + + // no limit + .findAll(); + + List messages = []; + for (final cChannelMessage in cChannelMessages) { + final message = await cChannelMessage.toChannelMessage(chat, isar); + if (message != null) { + messages.add(message.message); + } + } + + return messages; + } + + static Future delete(Chat chat, Isar isar, String rootId) async { + await chat.dbManager.write(() async { + await isar.cChannelMessages.deleteByRootId(rootId); + }); + } +} diff --git a/lib/src/internal/db/schema/message/meta/c_channel_message.g.dart b/lib/src/internal/db/schema/message/meta/c_channel_message.g.dart new file mode 100644 index 00000000..824e15e0 --- /dev/null +++ b/lib/src/internal/db/schema/message/meta/c_channel_message.g.dart @@ -0,0 +1,2248 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'c_channel_message.dart'; + +// ************************************************************************** +// IsarCollectionGenerator +// ************************************************************************** + +// coverage:ignore-file +// ignore_for_file: duplicate_ignore, non_constant_identifier_names, constant_identifier_names, invalid_use_of_protected_member, unnecessary_cast, prefer_const_constructors, lines_longer_than_80_chars, require_trailing_commas, inference_failure_on_function_invocation, unnecessary_parenthesis, unnecessary_raw_strings, unnecessary_null_checks, join_return_with_assignment, prefer_final_locals, avoid_js_rounded_ints, avoid_positional_boolean_parameters, always_specify_types + +extension GetCChannelMessageCollection on Isar { + IsarCollection get cChannelMessages => this.collection(); +} + +int _cChannelMessageEstimateSize( + CChannelMessage object, + List offsets, + Map> allOffsets, +) { + var bytesCount = offsets.last; + bytesCount += 3 + object.channelUrl.length * 3; + { + final value = object.customType; + if (value != null) { + bytesCount += 3 + value.length * 3; + } + } + bytesCount += 3 + object.rootId.length * 3; + { + final value = object.senderId; + if (value != null) { + bytesCount += 3 + value.length * 3; + } + } + return bytesCount; +} + +final CChannelMessageSchema = CollectionSchema( + name: r'CChannelMessage', + id: BigInt.parse('-5850314032481753759').toInt(), + properties: { + r'channelType': PropertySchema( + id: 0, + name: r'channelType', + type: IsarType.byte, + enumMap: _CChannelMessagechannelTypeEnumValueMap, + ), + r'channelUrl': PropertySchema( + id: 1, + name: r'channelUrl', + type: IsarType.string, + ), + r'createdAt': PropertySchema( + id: 2, + name: r'createdAt', + type: IsarType.long, + ), + r'customType': PropertySchema( + id: 3, + name: r'customType', + type: IsarType.string, + ), + r'messageType': PropertySchema( + id: 4, + name: r'messageType', + type: IsarType.byte, + enumMap: _CChannelMessagemessageTypeEnumValueMap, + ), + r'rootId': PropertySchema( + id: 5, + name: r'rootId', + type: IsarType.string, + ), + r'senderId': PropertySchema( + id: 6, + name: r'senderId', + type: IsarType.string, + ), + r'sendingStatus': PropertySchema( + id: 7, + name: r'sendingStatus', + type: IsarType.byte, + enumMap: _CChannelMessagesendingStatusEnumValueMap, + ) + }, + estimateSize: _cChannelMessageEstimateSize, + serialize: _cChannelMessageSerialize, + deserialize: _cChannelMessageDeserialize, + deserializeProp: _cChannelMessageDeserializeProp, + idName: r'id', + indexes: { + r'rootId': IndexSchema( + id: BigInt.parse('5087693435549841488').toInt(), + name: r'rootId', + unique: true, + replace: true, + properties: [ + IndexPropertySchema( + name: r'rootId', + type: IndexType.hash, + caseSensitive: true, + ) + ], + ), + r'messageType_rootId': IndexSchema( + id: BigInt.parse('-7060804333380842370').toInt(), + name: r'messageType_rootId', + unique: false, + replace: false, + properties: [ + IndexPropertySchema( + name: r'messageType', + type: IndexType.value, + caseSensitive: false, + ), + IndexPropertySchema( + name: r'rootId', + type: IndexType.hash, + caseSensitive: true, + ) + ], + ), + r'channelUrl': IndexSchema( + id: BigInt.parse('6636052684858767397').toInt(), + name: r'channelUrl', + unique: false, + replace: false, + properties: [ + IndexPropertySchema( + name: r'channelUrl', + type: IndexType.hash, + caseSensitive: true, + ) + ], + ), + r'channelType_channelUrl': IndexSchema( + id: BigInt.parse('-5957547153902522682').toInt(), + name: r'channelType_channelUrl', + unique: false, + replace: false, + properties: [ + IndexPropertySchema( + name: r'channelType', + type: IndexType.value, + caseSensitive: false, + ), + IndexPropertySchema( + name: r'channelUrl', + type: IndexType.hash, + caseSensitive: true, + ) + ], + ), + r'createdAt': IndexSchema( + id: BigInt.parse('-3433535483987302584').toInt(), + name: r'createdAt', + unique: false, + replace: false, + properties: [ + IndexPropertySchema( + name: r'createdAt', + type: IndexType.value, + caseSensitive: false, + ) + ], + ), + r'sendingStatus': IndexSchema( + id: BigInt.parse('208667966773972562').toInt(), + name: r'sendingStatus', + unique: false, + replace: false, + properties: [ + IndexPropertySchema( + name: r'sendingStatus', + type: IndexType.value, + caseSensitive: false, + ) + ], + ) + }, + links: {}, + embeddedSchemas: {}, + getId: _cChannelMessageGetId, + getLinks: _cChannelMessageGetLinks, + attach: _cChannelMessageAttach, + version: '3.1.0+1', +); + +void _cChannelMessageSerialize( + CChannelMessage object, + IsarWriter writer, + List offsets, + Map> allOffsets, +) { + writer.writeByte(offsets[0], object.channelType.index); + writer.writeString(offsets[1], object.channelUrl); + writer.writeLong(offsets[2], object.createdAt); + writer.writeString(offsets[3], object.customType); + writer.writeByte(offsets[4], object.messageType.index); + writer.writeString(offsets[5], object.rootId); + writer.writeString(offsets[6], object.senderId); + writer.writeByte(offsets[7], object.sendingStatus.index); +} + +CChannelMessage _cChannelMessageDeserialize( + Id id, + IsarReader reader, + List offsets, + Map> allOffsets, +) { + final object = CChannelMessage(); + object.channelType = _CChannelMessagechannelTypeValueEnumMap[ + reader.readByteOrNull(offsets[0])] ?? + ChannelType.group; + object.channelUrl = reader.readString(offsets[1]); + object.createdAt = reader.readLong(offsets[2]); + object.customType = reader.readStringOrNull(offsets[3]); + object.id = id; + object.messageType = _CChannelMessagemessageTypeValueEnumMap[ + reader.readByteOrNull(offsets[4])] ?? + MessageType.user; + object.rootId = reader.readString(offsets[5]); + object.senderId = reader.readStringOrNull(offsets[6]); + object.sendingStatus = _CChannelMessagesendingStatusValueEnumMap[ + reader.readByteOrNull(offsets[7])] ?? + SendingStatus.none; + return object; +} + +P _cChannelMessageDeserializeProp

( + IsarReader reader, + int propertyId, + int offset, + Map> allOffsets, +) { + switch (propertyId) { + case 0: + return (_CChannelMessagechannelTypeValueEnumMap[ + reader.readByteOrNull(offset)] ?? + ChannelType.group) as P; + case 1: + return (reader.readString(offset)) as P; + case 2: + return (reader.readLong(offset)) as P; + case 3: + return (reader.readStringOrNull(offset)) as P; + case 4: + return (_CChannelMessagemessageTypeValueEnumMap[ + reader.readByteOrNull(offset)] ?? + MessageType.user) as P; + case 5: + return (reader.readString(offset)) as P; + case 6: + return (reader.readStringOrNull(offset)) as P; + case 7: + return (_CChannelMessagesendingStatusValueEnumMap[ + reader.readByteOrNull(offset)] ?? + SendingStatus.none) as P; + default: + throw IsarError('Unknown property with id $propertyId'); + } +} + +const _CChannelMessagechannelTypeEnumValueMap = { + 'group': 0, + 'open': 1, + 'feed': 2, +}; +const _CChannelMessagechannelTypeValueEnumMap = { + 0: ChannelType.group, + 1: ChannelType.open, + 2: ChannelType.feed, +}; +const _CChannelMessagemessageTypeEnumValueMap = { + 'user': 0, + 'file': 1, + 'admin': 2, + 'notification': 3, +}; +const _CChannelMessagemessageTypeValueEnumMap = { + 0: MessageType.user, + 1: MessageType.file, + 2: MessageType.admin, + 3: MessageType.notification, +}; +const _CChannelMessagesendingStatusEnumValueMap = { + 'none': 0, + 'pending': 1, + 'failed': 2, + 'succeeded': 3, + 'canceled': 4, +}; +const _CChannelMessagesendingStatusValueEnumMap = { + 0: SendingStatus.none, + 1: SendingStatus.pending, + 2: SendingStatus.failed, + 3: SendingStatus.succeeded, + 4: SendingStatus.canceled, +}; + +Id _cChannelMessageGetId(CChannelMessage object) { + return object.id; +} + +List> _cChannelMessageGetLinks(CChannelMessage object) { + return []; +} + +void _cChannelMessageAttach( + IsarCollection col, Id id, CChannelMessage object) { + object.id = id; +} + +extension CChannelMessageByIndex on IsarCollection { + Future getByRootId(String rootId) { + return getByIndex(r'rootId', [rootId]); + } + + CChannelMessage? getByRootIdSync(String rootId) { + return getByIndexSync(r'rootId', [rootId]); + } + + Future deleteByRootId(String rootId) { + return deleteByIndex(r'rootId', [rootId]); + } + + bool deleteByRootIdSync(String rootId) { + return deleteByIndexSync(r'rootId', [rootId]); + } + + Future> getAllByRootId(List rootIdValues) { + final values = rootIdValues.map((e) => [e]).toList(); + return getAllByIndex(r'rootId', values); + } + + List getAllByRootIdSync(List rootIdValues) { + final values = rootIdValues.map((e) => [e]).toList(); + return getAllByIndexSync(r'rootId', values); + } + + Future deleteAllByRootId(List rootIdValues) { + final values = rootIdValues.map((e) => [e]).toList(); + return deleteAllByIndex(r'rootId', values); + } + + int deleteAllByRootIdSync(List rootIdValues) { + final values = rootIdValues.map((e) => [e]).toList(); + return deleteAllByIndexSync(r'rootId', values); + } + + Future putByRootId(CChannelMessage object) { + return putByIndex(r'rootId', object); + } + + Id putByRootIdSync(CChannelMessage object, {bool saveLinks = true}) { + return putByIndexSync(r'rootId', object, saveLinks: saveLinks); + } + + Future> putAllByRootId(List objects) { + return putAllByIndex(r'rootId', objects); + } + + List putAllByRootIdSync(List objects, + {bool saveLinks = true}) { + return putAllByIndexSync(r'rootId', objects, saveLinks: saveLinks); + } +} + +extension CChannelMessageQueryWhereSort + on QueryBuilder { + QueryBuilder anyId() { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(const IdWhereClause.any()); + }); + } + + QueryBuilder anyCreatedAt() { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause( + const IndexWhereClause.any(indexName: r'createdAt'), + ); + }); + } + + QueryBuilder + anySendingStatus() { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause( + const IndexWhereClause.any(indexName: r'sendingStatus'), + ); + }); + } +} + +extension CChannelMessageQueryWhere + on QueryBuilder { + QueryBuilder idEqualTo( + Id id) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IdWhereClause.between( + lower: id, + upper: id, + )); + }); + } + + QueryBuilder + idNotEqualTo(Id id) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause( + IdWhereClause.lessThan(upper: id, includeUpper: false), + ) + .addWhereClause( + IdWhereClause.greaterThan(lower: id, includeLower: false), + ); + } else { + return query + .addWhereClause( + IdWhereClause.greaterThan(lower: id, includeLower: false), + ) + .addWhereClause( + IdWhereClause.lessThan(upper: id, includeUpper: false), + ); + } + }); + } + + QueryBuilder + idGreaterThan(Id id, {bool include = false}) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause( + IdWhereClause.greaterThan(lower: id, includeLower: include), + ); + }); + } + + QueryBuilder idLessThan( + Id id, + {bool include = false}) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause( + IdWhereClause.lessThan(upper: id, includeUpper: include), + ); + }); + } + + QueryBuilder idBetween( + Id lowerId, + Id upperId, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IdWhereClause.between( + lower: lowerId, + includeLower: includeLower, + upper: upperId, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + rootIdEqualTo(String rootId) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.equalTo( + indexName: r'rootId', + value: [rootId], + )); + }); + } + + QueryBuilder + rootIdNotEqualTo(String rootId) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'rootId', + lower: [], + upper: [rootId], + includeUpper: false, + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'rootId', + lower: [rootId], + includeLower: false, + upper: [], + )); + } else { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'rootId', + lower: [rootId], + includeLower: false, + upper: [], + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'rootId', + lower: [], + upper: [rootId], + includeUpper: false, + )); + } + }); + } + + QueryBuilder + messageTypeEqualToAnyRootId(MessageType messageType) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.equalTo( + indexName: r'messageType_rootId', + value: [messageType], + )); + }); + } + + QueryBuilder + messageTypeNotEqualToAnyRootId(MessageType messageType) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'messageType_rootId', + lower: [], + upper: [messageType], + includeUpper: false, + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'messageType_rootId', + lower: [messageType], + includeLower: false, + upper: [], + )); + } else { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'messageType_rootId', + lower: [messageType], + includeLower: false, + upper: [], + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'messageType_rootId', + lower: [], + upper: [messageType], + includeUpper: false, + )); + } + }); + } + + QueryBuilder + messageTypeGreaterThanAnyRootId( + MessageType messageType, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.between( + indexName: r'messageType_rootId', + lower: [messageType], + includeLower: include, + upper: [], + )); + }); + } + + QueryBuilder + messageTypeLessThanAnyRootId( + MessageType messageType, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.between( + indexName: r'messageType_rootId', + lower: [], + upper: [messageType], + includeUpper: include, + )); + }); + } + + QueryBuilder + messageTypeBetweenAnyRootId( + MessageType lowerMessageType, + MessageType upperMessageType, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.between( + indexName: r'messageType_rootId', + lower: [lowerMessageType], + includeLower: includeLower, + upper: [upperMessageType], + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + messageTypeRootIdEqualTo(MessageType messageType, String rootId) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.equalTo( + indexName: r'messageType_rootId', + value: [messageType, rootId], + )); + }); + } + + QueryBuilder + messageTypeEqualToRootIdNotEqualTo( + MessageType messageType, String rootId) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'messageType_rootId', + lower: [messageType], + upper: [messageType, rootId], + includeUpper: false, + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'messageType_rootId', + lower: [messageType, rootId], + includeLower: false, + upper: [messageType], + )); + } else { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'messageType_rootId', + lower: [messageType, rootId], + includeLower: false, + upper: [messageType], + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'messageType_rootId', + lower: [messageType], + upper: [messageType, rootId], + includeUpper: false, + )); + } + }); + } + + QueryBuilder + channelUrlEqualTo(String channelUrl) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.equalTo( + indexName: r'channelUrl', + value: [channelUrl], + )); + }); + } + + QueryBuilder + channelUrlNotEqualTo(String channelUrl) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'channelUrl', + lower: [], + upper: [channelUrl], + includeUpper: false, + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'channelUrl', + lower: [channelUrl], + includeLower: false, + upper: [], + )); + } else { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'channelUrl', + lower: [channelUrl], + includeLower: false, + upper: [], + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'channelUrl', + lower: [], + upper: [channelUrl], + includeUpper: false, + )); + } + }); + } + + QueryBuilder + channelTypeEqualToAnyChannelUrl(ChannelType channelType) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.equalTo( + indexName: r'channelType_channelUrl', + value: [channelType], + )); + }); + } + + QueryBuilder + channelTypeNotEqualToAnyChannelUrl(ChannelType channelType) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'channelType_channelUrl', + lower: [], + upper: [channelType], + includeUpper: false, + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'channelType_channelUrl', + lower: [channelType], + includeLower: false, + upper: [], + )); + } else { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'channelType_channelUrl', + lower: [channelType], + includeLower: false, + upper: [], + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'channelType_channelUrl', + lower: [], + upper: [channelType], + includeUpper: false, + )); + } + }); + } + + QueryBuilder + channelTypeGreaterThanAnyChannelUrl( + ChannelType channelType, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.between( + indexName: r'channelType_channelUrl', + lower: [channelType], + includeLower: include, + upper: [], + )); + }); + } + + QueryBuilder + channelTypeLessThanAnyChannelUrl( + ChannelType channelType, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.between( + indexName: r'channelType_channelUrl', + lower: [], + upper: [channelType], + includeUpper: include, + )); + }); + } + + QueryBuilder + channelTypeBetweenAnyChannelUrl( + ChannelType lowerChannelType, + ChannelType upperChannelType, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.between( + indexName: r'channelType_channelUrl', + lower: [lowerChannelType], + includeLower: includeLower, + upper: [upperChannelType], + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + channelTypeChannelUrlEqualTo(ChannelType channelType, String channelUrl) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.equalTo( + indexName: r'channelType_channelUrl', + value: [channelType, channelUrl], + )); + }); + } + + QueryBuilder + channelTypeEqualToChannelUrlNotEqualTo( + ChannelType channelType, String channelUrl) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'channelType_channelUrl', + lower: [channelType], + upper: [channelType, channelUrl], + includeUpper: false, + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'channelType_channelUrl', + lower: [channelType, channelUrl], + includeLower: false, + upper: [channelType], + )); + } else { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'channelType_channelUrl', + lower: [channelType, channelUrl], + includeLower: false, + upper: [channelType], + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'channelType_channelUrl', + lower: [channelType], + upper: [channelType, channelUrl], + includeUpper: false, + )); + } + }); + } + + QueryBuilder + createdAtEqualTo(int createdAt) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.equalTo( + indexName: r'createdAt', + value: [createdAt], + )); + }); + } + + QueryBuilder + createdAtNotEqualTo(int createdAt) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'createdAt', + lower: [], + upper: [createdAt], + includeUpper: false, + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'createdAt', + lower: [createdAt], + includeLower: false, + upper: [], + )); + } else { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'createdAt', + lower: [createdAt], + includeLower: false, + upper: [], + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'createdAt', + lower: [], + upper: [createdAt], + includeUpper: false, + )); + } + }); + } + + QueryBuilder + createdAtGreaterThan( + int createdAt, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.between( + indexName: r'createdAt', + lower: [createdAt], + includeLower: include, + upper: [], + )); + }); + } + + QueryBuilder + createdAtLessThan( + int createdAt, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.between( + indexName: r'createdAt', + lower: [], + upper: [createdAt], + includeUpper: include, + )); + }); + } + + QueryBuilder + createdAtBetween( + int lowerCreatedAt, + int upperCreatedAt, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.between( + indexName: r'createdAt', + lower: [lowerCreatedAt], + includeLower: includeLower, + upper: [upperCreatedAt], + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + sendingStatusEqualTo(SendingStatus sendingStatus) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.equalTo( + indexName: r'sendingStatus', + value: [sendingStatus], + )); + }); + } + + QueryBuilder + sendingStatusNotEqualTo(SendingStatus sendingStatus) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'sendingStatus', + lower: [], + upper: [sendingStatus], + includeUpper: false, + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'sendingStatus', + lower: [sendingStatus], + includeLower: false, + upper: [], + )); + } else { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'sendingStatus', + lower: [sendingStatus], + includeLower: false, + upper: [], + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'sendingStatus', + lower: [], + upper: [sendingStatus], + includeUpper: false, + )); + } + }); + } + + QueryBuilder + sendingStatusGreaterThan( + SendingStatus sendingStatus, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.between( + indexName: r'sendingStatus', + lower: [sendingStatus], + includeLower: include, + upper: [], + )); + }); + } + + QueryBuilder + sendingStatusLessThan( + SendingStatus sendingStatus, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.between( + indexName: r'sendingStatus', + lower: [], + upper: [sendingStatus], + includeUpper: include, + )); + }); + } + + QueryBuilder + sendingStatusBetween( + SendingStatus lowerSendingStatus, + SendingStatus upperSendingStatus, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.between( + indexName: r'sendingStatus', + lower: [lowerSendingStatus], + includeLower: includeLower, + upper: [upperSendingStatus], + includeUpper: includeUpper, + )); + }); + } +} + +extension CChannelMessageQueryFilter + on QueryBuilder { + QueryBuilder + channelTypeEqualTo(ChannelType value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'channelType', + value: value, + )); + }); + } + + QueryBuilder + channelTypeGreaterThan( + ChannelType value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'channelType', + value: value, + )); + }); + } + + QueryBuilder + channelTypeLessThan( + ChannelType value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'channelType', + value: value, + )); + }); + } + + QueryBuilder + channelTypeBetween( + ChannelType lower, + ChannelType upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'channelType', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + channelUrlEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'channelUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + channelUrlGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'channelUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + channelUrlLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'channelUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + channelUrlBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'channelUrl', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + channelUrlStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'channelUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + channelUrlEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'channelUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + channelUrlContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'channelUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + channelUrlMatches(String pattern, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'channelUrl', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + channelUrlIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'channelUrl', + value: '', + )); + }); + } + + QueryBuilder + channelUrlIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'channelUrl', + value: '', + )); + }); + } + + QueryBuilder + createdAtEqualTo(int value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'createdAt', + value: value, + )); + }); + } + + QueryBuilder + createdAtGreaterThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'createdAt', + value: value, + )); + }); + } + + QueryBuilder + createdAtLessThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'createdAt', + value: value, + )); + }); + } + + QueryBuilder + createdAtBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'createdAt', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + customTypeIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'customType', + )); + }); + } + + QueryBuilder + customTypeIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'customType', + )); + }); + } + + QueryBuilder + customTypeEqualTo( + String? value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'customType', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + customTypeGreaterThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'customType', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + customTypeLessThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'customType', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + customTypeBetween( + String? lower, + String? upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'customType', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + customTypeStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'customType', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + customTypeEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'customType', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + customTypeContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'customType', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + customTypeMatches(String pattern, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'customType', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + customTypeIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'customType', + value: '', + )); + }); + } + + QueryBuilder + customTypeIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'customType', + value: '', + )); + }); + } + + QueryBuilder + idEqualTo(Id value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'id', + value: value, + )); + }); + } + + QueryBuilder + idGreaterThan( + Id value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'id', + value: value, + )); + }); + } + + QueryBuilder + idLessThan( + Id value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'id', + value: value, + )); + }); + } + + QueryBuilder + idBetween( + Id lower, + Id upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'id', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + messageTypeEqualTo(MessageType value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'messageType', + value: value, + )); + }); + } + + QueryBuilder + messageTypeGreaterThan( + MessageType value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'messageType', + value: value, + )); + }); + } + + QueryBuilder + messageTypeLessThan( + MessageType value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'messageType', + value: value, + )); + }); + } + + QueryBuilder + messageTypeBetween( + MessageType lower, + MessageType upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'messageType', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + rootIdEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'rootId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + rootIdGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'rootId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + rootIdLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'rootId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + rootIdBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'rootId', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + rootIdStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'rootId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + rootIdEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'rootId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + rootIdContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'rootId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + rootIdMatches(String pattern, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'rootId', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + rootIdIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'rootId', + value: '', + )); + }); + } + + QueryBuilder + rootIdIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'rootId', + value: '', + )); + }); + } + + QueryBuilder + senderIdIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'senderId', + )); + }); + } + + QueryBuilder + senderIdIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'senderId', + )); + }); + } + + QueryBuilder + senderIdEqualTo( + String? value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'senderId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + senderIdGreaterThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'senderId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + senderIdLessThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'senderId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + senderIdBetween( + String? lower, + String? upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'senderId', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + senderIdStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'senderId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + senderIdEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'senderId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + senderIdContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'senderId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + senderIdMatches(String pattern, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'senderId', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + senderIdIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'senderId', + value: '', + )); + }); + } + + QueryBuilder + senderIdIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'senderId', + value: '', + )); + }); + } + + QueryBuilder + sendingStatusEqualTo(SendingStatus value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'sendingStatus', + value: value, + )); + }); + } + + QueryBuilder + sendingStatusGreaterThan( + SendingStatus value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'sendingStatus', + value: value, + )); + }); + } + + QueryBuilder + sendingStatusLessThan( + SendingStatus value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'sendingStatus', + value: value, + )); + }); + } + + QueryBuilder + sendingStatusBetween( + SendingStatus lower, + SendingStatus upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'sendingStatus', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } +} + +extension CChannelMessageQueryObject + on QueryBuilder {} + +extension CChannelMessageQueryLinks + on QueryBuilder {} + +extension CChannelMessageQuerySortBy + on QueryBuilder { + QueryBuilder + sortByChannelType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'channelType', Sort.asc); + }); + } + + QueryBuilder + sortByChannelTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'channelType', Sort.desc); + }); + } + + QueryBuilder + sortByChannelUrl() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'channelUrl', Sort.asc); + }); + } + + QueryBuilder + sortByChannelUrlDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'channelUrl', Sort.desc); + }); + } + + QueryBuilder + sortByCreatedAt() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'createdAt', Sort.asc); + }); + } + + QueryBuilder + sortByCreatedAtDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'createdAt', Sort.desc); + }); + } + + QueryBuilder + sortByCustomType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'customType', Sort.asc); + }); + } + + QueryBuilder + sortByCustomTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'customType', Sort.desc); + }); + } + + QueryBuilder + sortByMessageType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'messageType', Sort.asc); + }); + } + + QueryBuilder + sortByMessageTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'messageType', Sort.desc); + }); + } + + QueryBuilder sortByRootId() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'rootId', Sort.asc); + }); + } + + QueryBuilder + sortByRootIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'rootId', Sort.desc); + }); + } + + QueryBuilder + sortBySenderId() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'senderId', Sort.asc); + }); + } + + QueryBuilder + sortBySenderIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'senderId', Sort.desc); + }); + } + + QueryBuilder + sortBySendingStatus() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'sendingStatus', Sort.asc); + }); + } + + QueryBuilder + sortBySendingStatusDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'sendingStatus', Sort.desc); + }); + } +} + +extension CChannelMessageQuerySortThenBy + on QueryBuilder { + QueryBuilder + thenByChannelType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'channelType', Sort.asc); + }); + } + + QueryBuilder + thenByChannelTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'channelType', Sort.desc); + }); + } + + QueryBuilder + thenByChannelUrl() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'channelUrl', Sort.asc); + }); + } + + QueryBuilder + thenByChannelUrlDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'channelUrl', Sort.desc); + }); + } + + QueryBuilder + thenByCreatedAt() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'createdAt', Sort.asc); + }); + } + + QueryBuilder + thenByCreatedAtDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'createdAt', Sort.desc); + }); + } + + QueryBuilder + thenByCustomType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'customType', Sort.asc); + }); + } + + QueryBuilder + thenByCustomTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'customType', Sort.desc); + }); + } + + QueryBuilder thenById() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'id', Sort.asc); + }); + } + + QueryBuilder thenByIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'id', Sort.desc); + }); + } + + QueryBuilder + thenByMessageType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'messageType', Sort.asc); + }); + } + + QueryBuilder + thenByMessageTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'messageType', Sort.desc); + }); + } + + QueryBuilder thenByRootId() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'rootId', Sort.asc); + }); + } + + QueryBuilder + thenByRootIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'rootId', Sort.desc); + }); + } + + QueryBuilder + thenBySenderId() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'senderId', Sort.asc); + }); + } + + QueryBuilder + thenBySenderIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'senderId', Sort.desc); + }); + } + + QueryBuilder + thenBySendingStatus() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'sendingStatus', Sort.asc); + }); + } + + QueryBuilder + thenBySendingStatusDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'sendingStatus', Sort.desc); + }); + } +} + +extension CChannelMessageQueryWhereDistinct + on QueryBuilder { + QueryBuilder + distinctByChannelType() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'channelType'); + }); + } + + QueryBuilder + distinctByChannelUrl({bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'channelUrl', caseSensitive: caseSensitive); + }); + } + + QueryBuilder + distinctByCreatedAt() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'createdAt'); + }); + } + + QueryBuilder + distinctByCustomType({bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'customType', caseSensitive: caseSensitive); + }); + } + + QueryBuilder + distinctByMessageType() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'messageType'); + }); + } + + QueryBuilder distinctByRootId( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'rootId', caseSensitive: caseSensitive); + }); + } + + QueryBuilder distinctBySenderId( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'senderId', caseSensitive: caseSensitive); + }); + } + + QueryBuilder + distinctBySendingStatus() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'sendingStatus'); + }); + } +} + +extension CChannelMessageQueryProperty + on QueryBuilder { + QueryBuilder idProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'id'); + }); + } + + QueryBuilder + channelTypeProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'channelType'); + }); + } + + QueryBuilder channelUrlProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'channelUrl'); + }); + } + + QueryBuilder createdAtProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'createdAt'); + }); + } + + QueryBuilder + customTypeProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'customType'); + }); + } + + QueryBuilder + messageTypeProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'messageType'); + }); + } + + QueryBuilder rootIdProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'rootId'); + }); + } + + QueryBuilder senderIdProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'senderId'); + }); + } + + QueryBuilder + sendingStatusProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'sendingStatus'); + }); + } +} diff --git a/lib/src/internal/db/schema/message/meta/c_message_changelog_info.dart b/lib/src/internal/db/schema/message/meta/c_message_changelog_info.dart new file mode 100644 index 00000000..b1c5a78d --- /dev/null +++ b/lib/src/internal/db/schema/message/meta/c_message_changelog_info.dart @@ -0,0 +1,62 @@ +// Copyright (c) 2023 Sendbird, Inc. All rights reserved. + +import 'package:isar/isar.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/message/meta/message_changelog_info.dart'; +import 'package:sendbird_chat_sdk/src/internal/main/chat/chat.dart'; + +part 'c_message_changelog_info.g.dart'; + +@collection +class CMessageChangeLogInfo { + Id id = Isar.autoIncrement; + + @Index(unique: true, replace: true) + late String channelUrl; + + String? lastMessageToken; + String? lastPollToken; + + CMessageChangeLogInfo(); + + factory CMessageChangeLogInfo.fromChangeLogInfo(MessageChangeLogInfo info) { + return CMessageChangeLogInfo() + ..channelUrl = info.channelUrl + ..lastMessageToken = info.lastMessageToken + ..lastPollToken = info.lastPollToken; + } + + Future toChangeLogInfo(Chat chat, Isar isar) async { + return MessageChangeLogInfo( + channelUrl: channelUrl, + lastMessageToken: lastMessageToken, + lastPollToken: lastPollToken, + ); + } + + static Future upsert( + Chat chat, Isar isar, MessageChangeLogInfo info) async { + final cChangeLog = CMessageChangeLogInfo.fromChangeLogInfo(info); + + // ChangeLogInfo + await chat.dbManager.write(() async { + await isar.cMessageChangeLogInfos.put(cChangeLog); + }); + + return cChangeLog; + } + + static Future get( + Chat chat, Isar isar, String channelUrl) async { + final cChangeLog = await isar.cMessageChangeLogInfos + .where() + .channelUrlEqualTo(channelUrl) + .findFirst(); + return await cChangeLog?.toChangeLogInfo(chat, isar); + } + + static Future delete(Chat chat, Isar isar, String channelUrl) async { + await chat.dbManager.write(() async { + await isar.cMessageChangeLogInfos.deleteByChannelUrl(channelUrl); + }); + } +} diff --git a/lib/src/internal/db/schema/message/meta/c_message_changelog_info.g.dart b/lib/src/internal/db/schema/message/meta/c_message_changelog_info.g.dart new file mode 100644 index 00000000..7acb9fdd --- /dev/null +++ b/lib/src/internal/db/schema/message/meta/c_message_changelog_info.g.dart @@ -0,0 +1,1002 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'c_message_changelog_info.dart'; + +// ************************************************************************** +// IsarCollectionGenerator +// ************************************************************************** + +// coverage:ignore-file +// ignore_for_file: duplicate_ignore, non_constant_identifier_names, constant_identifier_names, invalid_use_of_protected_member, unnecessary_cast, prefer_const_constructors, lines_longer_than_80_chars, require_trailing_commas, inference_failure_on_function_invocation, unnecessary_parenthesis, unnecessary_raw_strings, unnecessary_null_checks, join_return_with_assignment, prefer_final_locals, avoid_js_rounded_ints, avoid_positional_boolean_parameters, always_specify_types + +extension GetCMessageChangeLogInfoCollection on Isar { + IsarCollection get cMessageChangeLogInfos => + this.collection(); +} + +final CMessageChangeLogInfoSchema = CollectionSchema( + name: r'CMessageChangeLogInfo', + id: BigInt.parse('-8707217854990464807').toInt(), + properties: { + r'channelUrl': PropertySchema( + id: 0, + name: r'channelUrl', + type: IsarType.string, + ), + r'lastMessageToken': PropertySchema( + id: 1, + name: r'lastMessageToken', + type: IsarType.string, + ), + r'lastPollToken': PropertySchema( + id: 2, + name: r'lastPollToken', + type: IsarType.string, + ) + }, + estimateSize: _cMessageChangeLogInfoEstimateSize, + serialize: _cMessageChangeLogInfoSerialize, + deserialize: _cMessageChangeLogInfoDeserialize, + deserializeProp: _cMessageChangeLogInfoDeserializeProp, + idName: r'id', + indexes: { + r'channelUrl': IndexSchema( + id: BigInt.parse('6636052684858767397').toInt(), + name: r'channelUrl', + unique: true, + replace: true, + properties: [ + IndexPropertySchema( + name: r'channelUrl', + type: IndexType.hash, + caseSensitive: true, + ) + ], + ) + }, + links: {}, + embeddedSchemas: {}, + getId: _cMessageChangeLogInfoGetId, + getLinks: _cMessageChangeLogInfoGetLinks, + attach: _cMessageChangeLogInfoAttach, + version: '3.1.0+1', +); + +int _cMessageChangeLogInfoEstimateSize( + CMessageChangeLogInfo object, + List offsets, + Map> allOffsets, +) { + var bytesCount = offsets.last; + bytesCount += 3 + object.channelUrl.length * 3; + { + final value = object.lastMessageToken; + if (value != null) { + bytesCount += 3 + value.length * 3; + } + } + { + final value = object.lastPollToken; + if (value != null) { + bytesCount += 3 + value.length * 3; + } + } + return bytesCount; +} + +void _cMessageChangeLogInfoSerialize( + CMessageChangeLogInfo object, + IsarWriter writer, + List offsets, + Map> allOffsets, +) { + writer.writeString(offsets[0], object.channelUrl); + writer.writeString(offsets[1], object.lastMessageToken); + writer.writeString(offsets[2], object.lastPollToken); +} + +CMessageChangeLogInfo _cMessageChangeLogInfoDeserialize( + Id id, + IsarReader reader, + List offsets, + Map> allOffsets, +) { + final object = CMessageChangeLogInfo(); + object.channelUrl = reader.readString(offsets[0]); + object.id = id; + object.lastMessageToken = reader.readStringOrNull(offsets[1]); + object.lastPollToken = reader.readStringOrNull(offsets[2]); + return object; +} + +P _cMessageChangeLogInfoDeserializeProp

( + IsarReader reader, + int propertyId, + int offset, + Map> allOffsets, +) { + switch (propertyId) { + case 0: + return (reader.readString(offset)) as P; + case 1: + return (reader.readStringOrNull(offset)) as P; + case 2: + return (reader.readStringOrNull(offset)) as P; + default: + throw IsarError('Unknown property with id $propertyId'); + } +} + +Id _cMessageChangeLogInfoGetId(CMessageChangeLogInfo object) { + return object.id; +} + +List> _cMessageChangeLogInfoGetLinks( + CMessageChangeLogInfo object) { + return []; +} + +void _cMessageChangeLogInfoAttach( + IsarCollection col, Id id, CMessageChangeLogInfo object) { + object.id = id; +} + +extension CMessageChangeLogInfoByIndex + on IsarCollection { + Future getByChannelUrl(String channelUrl) { + return getByIndex(r'channelUrl', [channelUrl]); + } + + CMessageChangeLogInfo? getByChannelUrlSync(String channelUrl) { + return getByIndexSync(r'channelUrl', [channelUrl]); + } + + Future deleteByChannelUrl(String channelUrl) { + return deleteByIndex(r'channelUrl', [channelUrl]); + } + + bool deleteByChannelUrlSync(String channelUrl) { + return deleteByIndexSync(r'channelUrl', [channelUrl]); + } + + Future> getAllByChannelUrl( + List channelUrlValues) { + final values = channelUrlValues.map((e) => [e]).toList(); + return getAllByIndex(r'channelUrl', values); + } + + List getAllByChannelUrlSync( + List channelUrlValues) { + final values = channelUrlValues.map((e) => [e]).toList(); + return getAllByIndexSync(r'channelUrl', values); + } + + Future deleteAllByChannelUrl(List channelUrlValues) { + final values = channelUrlValues.map((e) => [e]).toList(); + return deleteAllByIndex(r'channelUrl', values); + } + + int deleteAllByChannelUrlSync(List channelUrlValues) { + final values = channelUrlValues.map((e) => [e]).toList(); + return deleteAllByIndexSync(r'channelUrl', values); + } + + Future putByChannelUrl(CMessageChangeLogInfo object) { + return putByIndex(r'channelUrl', object); + } + + Id putByChannelUrlSync(CMessageChangeLogInfo object, + {bool saveLinks = true}) { + return putByIndexSync(r'channelUrl', object, saveLinks: saveLinks); + } + + Future> putAllByChannelUrl(List objects) { + return putAllByIndex(r'channelUrl', objects); + } + + List putAllByChannelUrlSync(List objects, + {bool saveLinks = true}) { + return putAllByIndexSync(r'channelUrl', objects, saveLinks: saveLinks); + } +} + +extension CMessageChangeLogInfoQueryWhereSort + on QueryBuilder { + QueryBuilder + anyId() { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(const IdWhereClause.any()); + }); + } +} + +extension CMessageChangeLogInfoQueryWhere on QueryBuilder { + QueryBuilder + idEqualTo(Id id) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IdWhereClause.between( + lower: id, + upper: id, + )); + }); + } + + QueryBuilder + idNotEqualTo(Id id) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause( + IdWhereClause.lessThan(upper: id, includeUpper: false), + ) + .addWhereClause( + IdWhereClause.greaterThan(lower: id, includeLower: false), + ); + } else { + return query + .addWhereClause( + IdWhereClause.greaterThan(lower: id, includeLower: false), + ) + .addWhereClause( + IdWhereClause.lessThan(upper: id, includeUpper: false), + ); + } + }); + } + + QueryBuilder + idGreaterThan(Id id, {bool include = false}) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause( + IdWhereClause.greaterThan(lower: id, includeLower: include), + ); + }); + } + + QueryBuilder + idLessThan(Id id, {bool include = false}) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause( + IdWhereClause.lessThan(upper: id, includeUpper: include), + ); + }); + } + + QueryBuilder + idBetween( + Id lowerId, + Id upperId, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IdWhereClause.between( + lower: lowerId, + includeLower: includeLower, + upper: upperId, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + channelUrlEqualTo(String channelUrl) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.equalTo( + indexName: r'channelUrl', + value: [channelUrl], + )); + }); + } + + QueryBuilder + channelUrlNotEqualTo(String channelUrl) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'channelUrl', + lower: [], + upper: [channelUrl], + includeUpper: false, + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'channelUrl', + lower: [channelUrl], + includeLower: false, + upper: [], + )); + } else { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'channelUrl', + lower: [channelUrl], + includeLower: false, + upper: [], + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'channelUrl', + lower: [], + upper: [channelUrl], + includeUpper: false, + )); + } + }); + } +} + +extension CMessageChangeLogInfoQueryFilter on QueryBuilder< + CMessageChangeLogInfo, CMessageChangeLogInfo, QFilterCondition> { + QueryBuilder channelUrlEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'channelUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder channelUrlGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'channelUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder channelUrlLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'channelUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder channelUrlBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'channelUrl', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder channelUrlStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'channelUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder channelUrlEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'channelUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + channelUrlContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'channelUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + channelUrlMatches(String pattern, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'channelUrl', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder channelUrlIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'channelUrl', + value: '', + )); + }); + } + + QueryBuilder channelUrlIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'channelUrl', + value: '', + )); + }); + } + + QueryBuilder idEqualTo(Id value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'id', + value: value, + )); + }); + } + + QueryBuilder idGreaterThan( + Id value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'id', + value: value, + )); + }); + } + + QueryBuilder idLessThan( + Id value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'id', + value: value, + )); + }); + } + + QueryBuilder idBetween( + Id lower, + Id upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'id', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder lastMessageTokenIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'lastMessageToken', + )); + }); + } + + QueryBuilder lastMessageTokenIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'lastMessageToken', + )); + }); + } + + QueryBuilder lastMessageTokenEqualTo( + String? value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'lastMessageToken', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder lastMessageTokenGreaterThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'lastMessageToken', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder lastMessageTokenLessThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'lastMessageToken', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder lastMessageTokenBetween( + String? lower, + String? upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'lastMessageToken', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder lastMessageTokenStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'lastMessageToken', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder lastMessageTokenEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'lastMessageToken', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + lastMessageTokenContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'lastMessageToken', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + lastMessageTokenMatches(String pattern, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'lastMessageToken', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder lastMessageTokenIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'lastMessageToken', + value: '', + )); + }); + } + + QueryBuilder lastMessageTokenIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'lastMessageToken', + value: '', + )); + }); + } + + QueryBuilder lastPollTokenIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'lastPollToken', + )); + }); + } + + QueryBuilder lastPollTokenIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'lastPollToken', + )); + }); + } + + QueryBuilder lastPollTokenEqualTo( + String? value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'lastPollToken', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder lastPollTokenGreaterThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'lastPollToken', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder lastPollTokenLessThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'lastPollToken', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder lastPollTokenBetween( + String? lower, + String? upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'lastPollToken', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder lastPollTokenStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'lastPollToken', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder lastPollTokenEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'lastPollToken', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + lastPollTokenContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'lastPollToken', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + lastPollTokenMatches(String pattern, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'lastPollToken', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder lastPollTokenIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'lastPollToken', + value: '', + )); + }); + } + + QueryBuilder lastPollTokenIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'lastPollToken', + value: '', + )); + }); + } +} + +extension CMessageChangeLogInfoQueryObject on QueryBuilder< + CMessageChangeLogInfo, CMessageChangeLogInfo, QFilterCondition> {} + +extension CMessageChangeLogInfoQueryLinks on QueryBuilder {} + +extension CMessageChangeLogInfoQuerySortBy + on QueryBuilder { + QueryBuilder + sortByChannelUrl() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'channelUrl', Sort.asc); + }); + } + + QueryBuilder + sortByChannelUrlDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'channelUrl', Sort.desc); + }); + } + + QueryBuilder + sortByLastMessageToken() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'lastMessageToken', Sort.asc); + }); + } + + QueryBuilder + sortByLastMessageTokenDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'lastMessageToken', Sort.desc); + }); + } + + QueryBuilder + sortByLastPollToken() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'lastPollToken', Sort.asc); + }); + } + + QueryBuilder + sortByLastPollTokenDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'lastPollToken', Sort.desc); + }); + } +} + +extension CMessageChangeLogInfoQuerySortThenBy + on QueryBuilder { + QueryBuilder + thenByChannelUrl() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'channelUrl', Sort.asc); + }); + } + + QueryBuilder + thenByChannelUrlDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'channelUrl', Sort.desc); + }); + } + + QueryBuilder + thenById() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'id', Sort.asc); + }); + } + + QueryBuilder + thenByIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'id', Sort.desc); + }); + } + + QueryBuilder + thenByLastMessageToken() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'lastMessageToken', Sort.asc); + }); + } + + QueryBuilder + thenByLastMessageTokenDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'lastMessageToken', Sort.desc); + }); + } + + QueryBuilder + thenByLastPollToken() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'lastPollToken', Sort.asc); + }); + } + + QueryBuilder + thenByLastPollTokenDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'lastPollToken', Sort.desc); + }); + } +} + +extension CMessageChangeLogInfoQueryWhereDistinct + on QueryBuilder { + QueryBuilder + distinctByChannelUrl({bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'channelUrl', caseSensitive: caseSensitive); + }); + } + + QueryBuilder + distinctByLastMessageToken({bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'lastMessageToken', + caseSensitive: caseSensitive); + }); + } + + QueryBuilder + distinctByLastPollToken({bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'lastPollToken', + caseSensitive: caseSensitive); + }); + } +} + +extension CMessageChangeLogInfoQueryProperty on QueryBuilder< + CMessageChangeLogInfo, CMessageChangeLogInfo, QQueryProperty> { + QueryBuilder idProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'id'); + }); + } + + QueryBuilder + channelUrlProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'channelUrl'); + }); + } + + QueryBuilder + lastMessageTokenProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'lastMessageToken'); + }); + } + + QueryBuilder + lastPollTokenProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'lastPollToken'); + }); + } +} diff --git a/lib/src/internal/db/schema/message/meta/channel_access.dart b/lib/src/internal/db/schema/message/meta/channel_access.dart new file mode 100644 index 00000000..4cf1c400 --- /dev/null +++ b/lib/src/internal/db/schema/message/meta/channel_access.dart @@ -0,0 +1,11 @@ +// Copyright (c) 2023 Sendbird, Inc. All rights reserved. + +class ChannelAccess { + final String channelUrl; + final int lastAccessedAt; + + ChannelAccess({ + required this.channelUrl, + required this.lastAccessedAt, + }); +} diff --git a/lib/src/internal/db/schema/message/meta/channel_message.dart b/lib/src/internal/db/schema/message/meta/channel_message.dart new file mode 100644 index 00000000..186f37bd --- /dev/null +++ b/lib/src/internal/db/schema/message/meta/channel_message.dart @@ -0,0 +1,28 @@ +// Copyright (c) 2023 Sendbird, Inc. All rights reserved. + +import 'package:sendbird_chat_sdk/src/public/core/message/root_message.dart'; +import 'package:sendbird_chat_sdk/src/public/main/define/enums.dart'; + +class ChannelMessage { + final String rootId; + final MessageType messageType; + final String channelUrl; + final ChannelType channelType; + final int createdAt; + final SendingStatus sendingStatus; // sendingStatus for filtering + final String? customType; // customType for filtering + final String? senderId; // senderId for filtering + final RootMessage message; + + ChannelMessage({ + required this.rootId, + required this.messageType, + required this.channelUrl, + required this.channelType, + required this.createdAt, + required this.sendingStatus, + required this.customType, + required this.senderId, + required this.message, + }); +} diff --git a/lib/src/internal/db/schema/message/meta/message_changelog_info.dart b/lib/src/internal/db/schema/message/meta/message_changelog_info.dart new file mode 100644 index 00000000..a992a196 --- /dev/null +++ b/lib/src/internal/db/schema/message/meta/message_changelog_info.dart @@ -0,0 +1,13 @@ +// Copyright (c) 2023 Sendbird, Inc. All rights reserved. + +class MessageChangeLogInfo { + final String channelUrl; + final String? lastMessageToken; + final String? lastPollToken; + + MessageChangeLogInfo({ + required this.channelUrl, + this.lastMessageToken, + this.lastPollToken, + }); +} diff --git a/lib/src/internal/db/schema/user/c_member.dart b/lib/src/internal/db/schema/user/c_member.dart new file mode 100644 index 00000000..b0e2af53 --- /dev/null +++ b/lib/src/internal/db/schema/user/c_member.dart @@ -0,0 +1,91 @@ +// Copyright (c) 2023 Sendbird, Inc. All rights reserved. + +import 'package:isar/isar.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/user/c_user.dart'; +import 'package:sendbird_chat_sdk/src/internal/main/chat/chat.dart'; +import 'package:sendbird_chat_sdk/src/public/core/user/member.dart'; +import 'package:sendbird_chat_sdk/src/public/core/user/restricted_user.dart'; +import 'package:sendbird_chat_sdk/src/public/main/define/enums.dart'; + +part 'c_member.g.dart'; + +@embedded +class CMember { + late String userId; // CUser + late String nickname; // CUser for filtering + + @enumerated + late MemberState memberState; + + late bool isBlockedByMe; + late bool isBlockingMe; + late bool isMuted; + + @enumerated + late Role role; + + CRestrictionInfo? restrictionInfo; + + CMember(); + + factory CMember.fromMember(Member member) { + return CMember() + // User + ..userId = member.userId + ..nickname = member.nickname + // Member + ..memberState = member.memberState + ..isBlockedByMe = member.isBlockedByMe + ..isBlockingMe = member.isBlockingMe + ..isMuted = member.isMuted + ..role = member.role + ..restrictionInfo = member.restrictionInfo != null + ? CRestrictionInfo.fromRestrictionInfo(member.restrictionInfo!) + : null; + } + + Future toMember(Chat chat, Isar isar) async { + final cUser = await CUser.getCUser(chat, isar, userId); + if (cUser == null) return null; + + final member = Member( + // User + userId: cUser.userId, + nickname: cUser.nickname, + ) + ..set(chat) + // Member + ..memberState = memberState + ..isBlockedByMe = isBlockedByMe + ..isBlockingMe = isBlockingMe + ..isMuted = isMuted + ..role = role + ..restrictionInfo = restrictionInfo?.toRestrictionInfo(); + return CUser.setCUser(member, cUser) as Member; + } +} + +@embedded +class CRestrictionInfo { + String? description; + int? endAt; + + @enumerated + late RestrictionType restrictionType; + + CRestrictionInfo(); + + factory CRestrictionInfo.fromRestrictionInfo(RestrictionInfo info) { + return CRestrictionInfo() + ..description = info.description + ..endAt = info.endAt + ..restrictionType = info.restrictionType; + } + + RestrictionInfo toRestrictionInfo() { + return RestrictionInfo() + ..description = description + ..endAt = endAt + ..restrictionType = restrictionType; + } +} diff --git a/lib/src/internal/db/schema/user/c_member.g.dart b/lib/src/internal/db/schema/user/c_member.g.dart new file mode 100644 index 00000000..ac091f9a --- /dev/null +++ b/lib/src/internal/db/schema/user/c_member.g.dart @@ -0,0 +1,999 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'c_member.dart'; + +// ************************************************************************** +// IsarEmbeddedGenerator +// ************************************************************************** + +// coverage:ignore-file +// ignore_for_file: duplicate_ignore, non_constant_identifier_names, constant_identifier_names, invalid_use_of_protected_member, unnecessary_cast, prefer_const_constructors, lines_longer_than_80_chars, require_trailing_commas, inference_failure_on_function_invocation, unnecessary_parenthesis, unnecessary_raw_strings, unnecessary_null_checks, join_return_with_assignment, prefer_final_locals, avoid_js_rounded_ints, avoid_positional_boolean_parameters, always_specify_types + +final CMemberSchema = Schema( + name: r'CMember', + id: BigInt.parse('3727521751473440892').toInt(), + properties: { + r'isBlockedByMe': PropertySchema( + id: 0, + name: r'isBlockedByMe', + type: IsarType.bool, + ), + r'isBlockingMe': PropertySchema( + id: 1, + name: r'isBlockingMe', + type: IsarType.bool, + ), + r'isMuted': PropertySchema( + id: 2, + name: r'isMuted', + type: IsarType.bool, + ), + r'memberState': PropertySchema( + id: 3, + name: r'memberState', + type: IsarType.byte, + enumMap: _CMembermemberStateEnumValueMap, + ), + r'nickname': PropertySchema( + id: 4, + name: r'nickname', + type: IsarType.string, + ), + r'restrictionInfo': PropertySchema( + id: 5, + name: r'restrictionInfo', + type: IsarType.object, + target: r'CRestrictionInfo', + ), + r'role': PropertySchema( + id: 6, + name: r'role', + type: IsarType.byte, + enumMap: _CMemberroleEnumValueMap, + ), + r'userId': PropertySchema( + id: 7, + name: r'userId', + type: IsarType.string, + ) + }, + estimateSize: _cMemberEstimateSize, + serialize: _cMemberSerialize, + deserialize: _cMemberDeserialize, + deserializeProp: _cMemberDeserializeProp, +); + +int _cMemberEstimateSize( + CMember object, + List offsets, + Map> allOffsets, +) { + var bytesCount = offsets.last; + bytesCount += 3 + object.nickname.length * 3; + { + final value = object.restrictionInfo; + if (value != null) { + bytesCount += 3 + + CRestrictionInfoSchema.estimateSize( + value, allOffsets[CRestrictionInfo]!, allOffsets); + } + } + bytesCount += 3 + object.userId.length * 3; + return bytesCount; +} + +void _cMemberSerialize( + CMember object, + IsarWriter writer, + List offsets, + Map> allOffsets, +) { + writer.writeBool(offsets[0], object.isBlockedByMe); + writer.writeBool(offsets[1], object.isBlockingMe); + writer.writeBool(offsets[2], object.isMuted); + writer.writeByte(offsets[3], object.memberState.index); + writer.writeString(offsets[4], object.nickname); + writer.writeObject( + offsets[5], + allOffsets, + CRestrictionInfoSchema.serialize, + object.restrictionInfo, + ); + writer.writeByte(offsets[6], object.role.index); + writer.writeString(offsets[7], object.userId); +} + +CMember _cMemberDeserialize( + Id id, + IsarReader reader, + List offsets, + Map> allOffsets, +) { + final object = CMember(); + object.isBlockedByMe = reader.readBool(offsets[0]); + object.isBlockingMe = reader.readBool(offsets[1]); + object.isMuted = reader.readBool(offsets[2]); + object.memberState = + _CMembermemberStateValueEnumMap[reader.readByteOrNull(offsets[3])] ?? + MemberState.none; + object.nickname = reader.readString(offsets[4]); + object.restrictionInfo = reader.readObjectOrNull( + offsets[5], + CRestrictionInfoSchema.deserialize, + allOffsets, + ); + object.role = + _CMemberroleValueEnumMap[reader.readByteOrNull(offsets[6])] ?? Role.none; + object.userId = reader.readString(offsets[7]); + return object; +} + +P _cMemberDeserializeProp

( + IsarReader reader, + int propertyId, + int offset, + Map> allOffsets, +) { + switch (propertyId) { + case 0: + return (reader.readBool(offset)) as P; + case 1: + return (reader.readBool(offset)) as P; + case 2: + return (reader.readBool(offset)) as P; + case 3: + return (_CMembermemberStateValueEnumMap[reader.readByteOrNull(offset)] ?? + MemberState.none) as P; + case 4: + return (reader.readString(offset)) as P; + case 5: + return (reader.readObjectOrNull( + offset, + CRestrictionInfoSchema.deserialize, + allOffsets, + )) as P; + case 6: + return (_CMemberroleValueEnumMap[reader.readByteOrNull(offset)] ?? + Role.none) as P; + case 7: + return (reader.readString(offset)) as P; + default: + throw IsarError('Unknown property with id $propertyId'); + } +} + +const _CMembermemberStateEnumValueMap = { + 'none': 0, + 'invited': 1, + 'joined': 2, +}; +const _CMembermemberStateValueEnumMap = { + 0: MemberState.none, + 1: MemberState.invited, + 2: MemberState.joined, +}; +const _CMemberroleEnumValueMap = { + 'none': 0, + 'operator': 1, +}; +const _CMemberroleValueEnumMap = { + 0: Role.none, + 1: Role.operator, +}; + +extension CMemberQueryFilter + on QueryBuilder { + QueryBuilder isBlockedByMeEqualTo( + bool value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'isBlockedByMe', + value: value, + )); + }); + } + + QueryBuilder isBlockingMeEqualTo( + bool value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'isBlockingMe', + value: value, + )); + }); + } + + QueryBuilder isMutedEqualTo( + bool value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'isMuted', + value: value, + )); + }); + } + + QueryBuilder memberStateEqualTo( + MemberState value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'memberState', + value: value, + )); + }); + } + + QueryBuilder memberStateGreaterThan( + MemberState value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'memberState', + value: value, + )); + }); + } + + QueryBuilder memberStateLessThan( + MemberState value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'memberState', + value: value, + )); + }); + } + + QueryBuilder memberStateBetween( + MemberState lower, + MemberState upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'memberState', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder nicknameEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'nickname', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder nicknameGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'nickname', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder nicknameLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'nickname', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder nicknameBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'nickname', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder nicknameStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'nickname', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder nicknameEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'nickname', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder nicknameContains( + String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'nickname', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder nicknameMatches( + String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'nickname', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder nicknameIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'nickname', + value: '', + )); + }); + } + + QueryBuilder nicknameIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'nickname', + value: '', + )); + }); + } + + QueryBuilder + restrictionInfoIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'restrictionInfo', + )); + }); + } + + QueryBuilder + restrictionInfoIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'restrictionInfo', + )); + }); + } + + QueryBuilder roleEqualTo( + Role value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'role', + value: value, + )); + }); + } + + QueryBuilder roleGreaterThan( + Role value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'role', + value: value, + )); + }); + } + + QueryBuilder roleLessThan( + Role value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'role', + value: value, + )); + }); + } + + QueryBuilder roleBetween( + Role lower, + Role upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'role', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder userIdEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'userId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder userIdGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'userId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder userIdLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'userId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder userIdBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'userId', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder userIdStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'userId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder userIdEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'userId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder userIdContains( + String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'userId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder userIdMatches( + String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'userId', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder userIdIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'userId', + value: '', + )); + }); + } + + QueryBuilder userIdIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'userId', + value: '', + )); + }); + } +} + +extension CMemberQueryObject + on QueryBuilder { + QueryBuilder restrictionInfo( + FilterQuery q) { + return QueryBuilder.apply(this, (query) { + return query.object(q, r'restrictionInfo'); + }); + } +} + +// coverage:ignore-file +// ignore_for_file: duplicate_ignore, non_constant_identifier_names, constant_identifier_names, invalid_use_of_protected_member, unnecessary_cast, prefer_const_constructors, lines_longer_than_80_chars, require_trailing_commas, inference_failure_on_function_invocation, unnecessary_parenthesis, unnecessary_raw_strings, unnecessary_null_checks, join_return_with_assignment, prefer_final_locals, avoid_js_rounded_ints, avoid_positional_boolean_parameters, always_specify_types + +final CRestrictionInfoSchema = Schema( + name: r'CRestrictionInfo', + id: BigInt.parse('981966653832094849').toInt(), + properties: { + r'description': PropertySchema( + id: 0, + name: r'description', + type: IsarType.string, + ), + r'endAt': PropertySchema( + id: 1, + name: r'endAt', + type: IsarType.long, + ), + r'restrictionType': PropertySchema( + id: 2, + name: r'restrictionType', + type: IsarType.byte, + enumMap: _CRestrictionInforestrictionTypeEnumValueMap, + ) + }, + estimateSize: _cRestrictionInfoEstimateSize, + serialize: _cRestrictionInfoSerialize, + deserialize: _cRestrictionInfoDeserialize, + deserializeProp: _cRestrictionInfoDeserializeProp, +); + +int _cRestrictionInfoEstimateSize( + CRestrictionInfo object, + List offsets, + Map> allOffsets, +) { + var bytesCount = offsets.last; + { + final value = object.description; + if (value != null) { + bytesCount += 3 + value.length * 3; + } + } + return bytesCount; +} + +void _cRestrictionInfoSerialize( + CRestrictionInfo object, + IsarWriter writer, + List offsets, + Map> allOffsets, +) { + writer.writeString(offsets[0], object.description); + writer.writeLong(offsets[1], object.endAt); + writer.writeByte(offsets[2], object.restrictionType.index); +} + +CRestrictionInfo _cRestrictionInfoDeserialize( + Id id, + IsarReader reader, + List offsets, + Map> allOffsets, +) { + final object = CRestrictionInfo(); + object.description = reader.readStringOrNull(offsets[0]); + object.endAt = reader.readLongOrNull(offsets[1]); + object.restrictionType = _CRestrictionInforestrictionTypeValueEnumMap[ + reader.readByteOrNull(offsets[2])] ?? + RestrictionType.muted; + return object; +} + +P _cRestrictionInfoDeserializeProp

( + IsarReader reader, + int propertyId, + int offset, + Map> allOffsets, +) { + switch (propertyId) { + case 0: + return (reader.readStringOrNull(offset)) as P; + case 1: + return (reader.readLongOrNull(offset)) as P; + case 2: + return (_CRestrictionInforestrictionTypeValueEnumMap[ + reader.readByteOrNull(offset)] ?? + RestrictionType.muted) as P; + default: + throw IsarError('Unknown property with id $propertyId'); + } +} + +const _CRestrictionInforestrictionTypeEnumValueMap = { + 'muted': 0, + 'banned': 1, +}; +const _CRestrictionInforestrictionTypeValueEnumMap = { + 0: RestrictionType.muted, + 1: RestrictionType.banned, +}; + +extension CRestrictionInfoQueryFilter + on QueryBuilder { + QueryBuilder + descriptionIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'description', + )); + }); + } + + QueryBuilder + descriptionIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'description', + )); + }); + } + + QueryBuilder + descriptionEqualTo( + String? value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'description', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + descriptionGreaterThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'description', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + descriptionLessThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'description', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + descriptionBetween( + String? lower, + String? upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'description', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + descriptionStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'description', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + descriptionEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'description', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + descriptionContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'description', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + descriptionMatches(String pattern, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'description', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + descriptionIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'description', + value: '', + )); + }); + } + + QueryBuilder + descriptionIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'description', + value: '', + )); + }); + } + + QueryBuilder + endAtIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'endAt', + )); + }); + } + + QueryBuilder + endAtIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'endAt', + )); + }); + } + + QueryBuilder + endAtEqualTo(int? value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'endAt', + value: value, + )); + }); + } + + QueryBuilder + endAtGreaterThan( + int? value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'endAt', + value: value, + )); + }); + } + + QueryBuilder + endAtLessThan( + int? value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'endAt', + value: value, + )); + }); + } + + QueryBuilder + endAtBetween( + int? lower, + int? upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'endAt', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + restrictionTypeEqualTo(RestrictionType value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'restrictionType', + value: value, + )); + }); + } + + QueryBuilder + restrictionTypeGreaterThan( + RestrictionType value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'restrictionType', + value: value, + )); + }); + } + + QueryBuilder + restrictionTypeLessThan( + RestrictionType value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'restrictionType', + value: value, + )); + }); + } + + QueryBuilder + restrictionTypeBetween( + RestrictionType lower, + RestrictionType upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'restrictionType', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } +} + +extension CRestrictionInfoQueryObject + on QueryBuilder {} diff --git a/lib/src/internal/db/schema/user/c_sender.dart b/lib/src/internal/db/schema/user/c_sender.dart new file mode 100644 index 00000000..b94fecda --- /dev/null +++ b/lib/src/internal/db/schema/user/c_sender.dart @@ -0,0 +1,46 @@ +// Copyright (c) 2023 Sendbird, Inc. All rights reserved. + +import 'package:isar/isar.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/user/c_user.dart'; +import 'package:sendbird_chat_sdk/src/internal/main/chat/chat.dart'; +import 'package:sendbird_chat_sdk/src/public/core/user/sender.dart'; +import 'package:sendbird_chat_sdk/src/public/main/define/enums.dart'; + +part 'c_sender.g.dart'; + +@embedded +class CSender { + late String userId; // CUser + + late bool isBlockedByMe; + + @enumerated + late Role role; + + CSender(); + + factory CSender.fromSender(Sender sender) { + return CSender() + // User + ..userId = sender.userId + // Sender + ..isBlockedByMe = sender.isBlockedByMe + ..role = sender.role; + } + + Future toSender(Chat chat, Isar isar) async { + final cUser = await CUser.getCUser(chat, isar, userId); + if (cUser == null) return null; + + final sender = Sender( + // User + userId: cUser.userId, + nickname: cUser.nickname, + ) + ..set(chat) + // Sender + ..isBlockedByMe = isBlockedByMe + ..role = role; + return CUser.setCUser(sender, cUser) as Sender; + } +} diff --git a/lib/src/internal/db/schema/user/c_sender.g.dart b/lib/src/internal/db/schema/user/c_sender.g.dart new file mode 100644 index 00000000..5d39cb18 --- /dev/null +++ b/lib/src/internal/db/schema/user/c_sender.g.dart @@ -0,0 +1,299 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'c_sender.dart'; + +// ************************************************************************** +// IsarEmbeddedGenerator +// ************************************************************************** + +// coverage:ignore-file +// ignore_for_file: duplicate_ignore, non_constant_identifier_names, constant_identifier_names, invalid_use_of_protected_member, unnecessary_cast, prefer_const_constructors, lines_longer_than_80_chars, require_trailing_commas, inference_failure_on_function_invocation, unnecessary_parenthesis, unnecessary_raw_strings, unnecessary_null_checks, join_return_with_assignment, prefer_final_locals, avoid_js_rounded_ints, avoid_positional_boolean_parameters, always_specify_types + +final CSenderSchema = Schema( + name: r'CSender', + id: BigInt.parse('-412392496748020901').toInt(), + properties: { + r'isBlockedByMe': PropertySchema( + id: 0, + name: r'isBlockedByMe', + type: IsarType.bool, + ), + r'role': PropertySchema( + id: 1, + name: r'role', + type: IsarType.byte, + enumMap: _CSenderroleEnumValueMap, + ), + r'userId': PropertySchema( + id: 2, + name: r'userId', + type: IsarType.string, + ) + }, + estimateSize: _cSenderEstimateSize, + serialize: _cSenderSerialize, + deserialize: _cSenderDeserialize, + deserializeProp: _cSenderDeserializeProp, +); + +int _cSenderEstimateSize( + CSender object, + List offsets, + Map> allOffsets, +) { + var bytesCount = offsets.last; + bytesCount += 3 + object.userId.length * 3; + return bytesCount; +} + +void _cSenderSerialize( + CSender object, + IsarWriter writer, + List offsets, + Map> allOffsets, +) { + writer.writeBool(offsets[0], object.isBlockedByMe); + writer.writeByte(offsets[1], object.role.index); + writer.writeString(offsets[2], object.userId); +} + +CSender _cSenderDeserialize( + Id id, + IsarReader reader, + List offsets, + Map> allOffsets, +) { + final object = CSender(); + object.isBlockedByMe = reader.readBool(offsets[0]); + object.role = + _CSenderroleValueEnumMap[reader.readByteOrNull(offsets[1])] ?? Role.none; + object.userId = reader.readString(offsets[2]); + return object; +} + +P _cSenderDeserializeProp

( + IsarReader reader, + int propertyId, + int offset, + Map> allOffsets, +) { + switch (propertyId) { + case 0: + return (reader.readBool(offset)) as P; + case 1: + return (_CSenderroleValueEnumMap[reader.readByteOrNull(offset)] ?? + Role.none) as P; + case 2: + return (reader.readString(offset)) as P; + default: + throw IsarError('Unknown property with id $propertyId'); + } +} + +const _CSenderroleEnumValueMap = { + 'none': 0, + 'operator': 1, +}; +const _CSenderroleValueEnumMap = { + 0: Role.none, + 1: Role.operator, +}; + +extension CSenderQueryFilter + on QueryBuilder { + QueryBuilder isBlockedByMeEqualTo( + bool value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'isBlockedByMe', + value: value, + )); + }); + } + + QueryBuilder roleEqualTo( + Role value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'role', + value: value, + )); + }); + } + + QueryBuilder roleGreaterThan( + Role value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'role', + value: value, + )); + }); + } + + QueryBuilder roleLessThan( + Role value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'role', + value: value, + )); + }); + } + + QueryBuilder roleBetween( + Role lower, + Role upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'role', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder userIdEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'userId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder userIdGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'userId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder userIdLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'userId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder userIdBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'userId', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder userIdStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'userId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder userIdEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'userId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder userIdContains( + String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'userId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder userIdMatches( + String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'userId', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder userIdIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'userId', + value: '', + )); + }); + } + + QueryBuilder userIdIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'userId', + value: '', + )); + }); + } +} + +extension CSenderQueryObject + on QueryBuilder {} diff --git a/lib/src/internal/db/schema/user/c_user.dart b/lib/src/internal/db/schema/user/c_user.dart new file mode 100644 index 00000000..72195d46 --- /dev/null +++ b/lib/src/internal/db/schema/user/c_user.dart @@ -0,0 +1,105 @@ +// Copyright (c) 2023 Sendbird, Inc. All rights reserved. + +import 'dart:convert'; + +import 'package:isar/isar.dart'; +import 'package:sendbird_chat_sdk/src/internal/main/chat/chat.dart'; +import 'package:sendbird_chat_sdk/src/public/core/user/user.dart'; +import 'package:sendbird_chat_sdk/src/public/main/define/enums.dart'; + +part 'c_user.g.dart'; + +@collection +class CUser { + Id id = Isar.autoIncrement; + + @Index(unique: true, replace: true) + late String userId; + + late String nickname; + late String profileUrl; + + @enumerated + late UserConnectionStatus connectionStatus; + + int? lastSeenAt; + bool? isActive; + List? preferredLanguages; + late String friendDiscoveryKey; + late String friendName; + late String metaData; // Map + + // Internal + late bool requireAuth; + + CUser(); + + factory CUser.fromUser(User user) { + return CUser()..setUser(user); + } + + void setUser(User user) { + userId = user.userId; + nickname = user.nickname; + profileUrl = user.profileUrl; + connectionStatus = user.connectionStatus; + lastSeenAt = user.lastSeenAt; + isActive = user.isActive; + preferredLanguages = user.preferredLanguages; + friendDiscoveryKey = user.friendDiscoveryKey; + friendName = user.friendName; + metaData = jsonEncode(user.metaData); + requireAuth = user.requireAuth; + } + + Future toUser(Chat chat, Isar isar) async { + final user = User( + userId: userId, + nickname: nickname, + )..set(chat); + return setCUser(user, this); + } + + static User setCUser(User user, CUser cUser) { + return user + ..userId = cUser.userId + ..nickname = cUser.nickname + ..profileUrl = cUser.profileUrl + ..connectionStatus = cUser.connectionStatus + ..lastSeenAt = cUser.lastSeenAt + ..isActive = cUser.isActive + ..preferredLanguages = cUser.preferredLanguages + ..friendDiscoveryKey = cUser.friendDiscoveryKey + ..friendName = cUser.friendName + ..metaData = (jsonDecode(cUser.metaData) as Map) + .map((key, value) => MapEntry(key, value.toString())) + ..requireAuth = cUser.requireAuth; + } + + static Future upsert(Chat chat, Isar isar, User user) async { + final cUser = CUser.fromUser(user); + + // User + await chat.dbManager.write(() async { + await isar.cUsers.put(cUser); + }); + + return cUser; + } + + static Future get(Chat chat, Isar isar, String userId) async { + final cUser = await isar.cUsers.where().userIdEqualTo(userId).findFirst(); + return await cUser?.toUser(chat, isar); + } + + static Future getCUser(Chat chat, Isar isar, String userId) async { + final cUser = await isar.cUsers.where().userIdEqualTo(userId).findFirst(); + return cUser; + } + + static Future delete(Chat chat, Isar isar, String userId) async { + await chat.dbManager.write(() async { + await isar.cUsers.deleteByUserId(userId); + }); + } +} diff --git a/lib/src/internal/db/schema/user/c_user.g.dart b/lib/src/internal/db/schema/user/c_user.g.dart new file mode 100644 index 00000000..96569d57 --- /dev/null +++ b/lib/src/internal/db/schema/user/c_user.g.dart @@ -0,0 +1,2055 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'c_user.dart'; + +// ************************************************************************** +// IsarCollectionGenerator +// ************************************************************************** + +// coverage:ignore-file +// ignore_for_file: duplicate_ignore, non_constant_identifier_names, constant_identifier_names, invalid_use_of_protected_member, unnecessary_cast, prefer_const_constructors, lines_longer_than_80_chars, require_trailing_commas, inference_failure_on_function_invocation, unnecessary_parenthesis, unnecessary_raw_strings, unnecessary_null_checks, join_return_with_assignment, prefer_final_locals, avoid_js_rounded_ints, avoid_positional_boolean_parameters, always_specify_types + +extension GetCUserCollection on Isar { + IsarCollection get cUsers => this.collection(); +} + +final CUserSchema = CollectionSchema( + name: r'CUser', + id: BigInt.parse('892440936217059961').toInt(), + properties: { + r'connectionStatus': PropertySchema( + id: 0, + name: r'connectionStatus', + type: IsarType.byte, + enumMap: _CUserconnectionStatusEnumValueMap, + ), + r'friendDiscoveryKey': PropertySchema( + id: 1, + name: r'friendDiscoveryKey', + type: IsarType.string, + ), + r'friendName': PropertySchema( + id: 2, + name: r'friendName', + type: IsarType.string, + ), + r'isActive': PropertySchema( + id: 3, + name: r'isActive', + type: IsarType.bool, + ), + r'lastSeenAt': PropertySchema( + id: 4, + name: r'lastSeenAt', + type: IsarType.long, + ), + r'metaData': PropertySchema( + id: 5, + name: r'metaData', + type: IsarType.string, + ), + r'nickname': PropertySchema( + id: 6, + name: r'nickname', + type: IsarType.string, + ), + r'preferredLanguages': PropertySchema( + id: 7, + name: r'preferredLanguages', + type: IsarType.stringList, + ), + r'profileUrl': PropertySchema( + id: 8, + name: r'profileUrl', + type: IsarType.string, + ), + r'requireAuth': PropertySchema( + id: 9, + name: r'requireAuth', + type: IsarType.bool, + ), + r'userId': PropertySchema( + id: 10, + name: r'userId', + type: IsarType.string, + ) + }, + estimateSize: _cUserEstimateSize, + serialize: _cUserSerialize, + deserialize: _cUserDeserialize, + deserializeProp: _cUserDeserializeProp, + idName: r'id', + indexes: { + r'userId': IndexSchema( + id: BigInt.parse('-2005826577402374815').toInt(), + name: r'userId', + unique: true, + replace: true, + properties: [ + IndexPropertySchema( + name: r'userId', + type: IndexType.hash, + caseSensitive: true, + ) + ], + ) + }, + links: {}, + embeddedSchemas: {}, + getId: _cUserGetId, + getLinks: _cUserGetLinks, + attach: _cUserAttach, + version: '3.1.0+1', +); + +int _cUserEstimateSize( + CUser object, + List offsets, + Map> allOffsets, +) { + var bytesCount = offsets.last; + bytesCount += 3 + object.friendDiscoveryKey.length * 3; + bytesCount += 3 + object.friendName.length * 3; + bytesCount += 3 + object.metaData.length * 3; + bytesCount += 3 + object.nickname.length * 3; + { + final list = object.preferredLanguages; + if (list != null) { + bytesCount += 3 + list.length * 3; + { + for (var i = 0; i < list.length; i++) { + final value = list[i]; + bytesCount += value.length * 3; + } + } + } + } + bytesCount += 3 + object.profileUrl.length * 3; + bytesCount += 3 + object.userId.length * 3; + return bytesCount; +} + +void _cUserSerialize( + CUser object, + IsarWriter writer, + List offsets, + Map> allOffsets, +) { + writer.writeByte(offsets[0], object.connectionStatus.index); + writer.writeString(offsets[1], object.friendDiscoveryKey); + writer.writeString(offsets[2], object.friendName); + writer.writeBool(offsets[3], object.isActive); + writer.writeLong(offsets[4], object.lastSeenAt); + writer.writeString(offsets[5], object.metaData); + writer.writeString(offsets[6], object.nickname); + writer.writeStringList(offsets[7], object.preferredLanguages); + writer.writeString(offsets[8], object.profileUrl); + writer.writeBool(offsets[9], object.requireAuth); + writer.writeString(offsets[10], object.userId); +} + +CUser _cUserDeserialize( + Id id, + IsarReader reader, + List offsets, + Map> allOffsets, +) { + final object = CUser(); + object.connectionStatus = + _CUserconnectionStatusValueEnumMap[reader.readByteOrNull(offsets[0])] ?? + UserConnectionStatus.online; + object.friendDiscoveryKey = reader.readString(offsets[1]); + object.friendName = reader.readString(offsets[2]); + object.id = id; + object.isActive = reader.readBoolOrNull(offsets[3]); + object.lastSeenAt = reader.readLongOrNull(offsets[4]); + object.metaData = reader.readString(offsets[5]); + object.nickname = reader.readString(offsets[6]); + object.preferredLanguages = reader.readStringList(offsets[7]); + object.profileUrl = reader.readString(offsets[8]); + object.requireAuth = reader.readBool(offsets[9]); + object.userId = reader.readString(offsets[10]); + return object; +} + +P _cUserDeserializeProp

( + IsarReader reader, + int propertyId, + int offset, + Map> allOffsets, +) { + switch (propertyId) { + case 0: + return (_CUserconnectionStatusValueEnumMap[ + reader.readByteOrNull(offset)] ?? + UserConnectionStatus.online) as P; + case 1: + return (reader.readString(offset)) as P; + case 2: + return (reader.readString(offset)) as P; + case 3: + return (reader.readBoolOrNull(offset)) as P; + case 4: + return (reader.readLongOrNull(offset)) as P; + case 5: + return (reader.readString(offset)) as P; + case 6: + return (reader.readString(offset)) as P; + case 7: + return (reader.readStringList(offset)) as P; + case 8: + return (reader.readString(offset)) as P; + case 9: + return (reader.readBool(offset)) as P; + case 10: + return (reader.readString(offset)) as P; + default: + throw IsarError('Unknown property with id $propertyId'); + } +} + +const _CUserconnectionStatusEnumValueMap = { + 'online': 0, + 'offline': 1, + 'notAvailable': 2, +}; +const _CUserconnectionStatusValueEnumMap = { + 0: UserConnectionStatus.online, + 1: UserConnectionStatus.offline, + 2: UserConnectionStatus.notAvailable, +}; + +Id _cUserGetId(CUser object) { + return object.id; +} + +List> _cUserGetLinks(CUser object) { + return []; +} + +void _cUserAttach(IsarCollection col, Id id, CUser object) { + object.id = id; +} + +extension CUserByIndex on IsarCollection { + Future getByUserId(String userId) { + return getByIndex(r'userId', [userId]); + } + + CUser? getByUserIdSync(String userId) { + return getByIndexSync(r'userId', [userId]); + } + + Future deleteByUserId(String userId) { + return deleteByIndex(r'userId', [userId]); + } + + bool deleteByUserIdSync(String userId) { + return deleteByIndexSync(r'userId', [userId]); + } + + Future> getAllByUserId(List userIdValues) { + final values = userIdValues.map((e) => [e]).toList(); + return getAllByIndex(r'userId', values); + } + + List getAllByUserIdSync(List userIdValues) { + final values = userIdValues.map((e) => [e]).toList(); + return getAllByIndexSync(r'userId', values); + } + + Future deleteAllByUserId(List userIdValues) { + final values = userIdValues.map((e) => [e]).toList(); + return deleteAllByIndex(r'userId', values); + } + + int deleteAllByUserIdSync(List userIdValues) { + final values = userIdValues.map((e) => [e]).toList(); + return deleteAllByIndexSync(r'userId', values); + } + + Future putByUserId(CUser object) { + return putByIndex(r'userId', object); + } + + Id putByUserIdSync(CUser object, {bool saveLinks = true}) { + return putByIndexSync(r'userId', object, saveLinks: saveLinks); + } + + Future> putAllByUserId(List objects) { + return putAllByIndex(r'userId', objects); + } + + List putAllByUserIdSync(List objects, {bool saveLinks = true}) { + return putAllByIndexSync(r'userId', objects, saveLinks: saveLinks); + } +} + +extension CUserQueryWhereSort on QueryBuilder { + QueryBuilder anyId() { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(const IdWhereClause.any()); + }); + } +} + +extension CUserQueryWhere on QueryBuilder { + QueryBuilder idEqualTo(Id id) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IdWhereClause.between( + lower: id, + upper: id, + )); + }); + } + + QueryBuilder idNotEqualTo(Id id) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause( + IdWhereClause.lessThan(upper: id, includeUpper: false), + ) + .addWhereClause( + IdWhereClause.greaterThan(lower: id, includeLower: false), + ); + } else { + return query + .addWhereClause( + IdWhereClause.greaterThan(lower: id, includeLower: false), + ) + .addWhereClause( + IdWhereClause.lessThan(upper: id, includeUpper: false), + ); + } + }); + } + + QueryBuilder idGreaterThan(Id id, + {bool include = false}) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause( + IdWhereClause.greaterThan(lower: id, includeLower: include), + ); + }); + } + + QueryBuilder idLessThan(Id id, + {bool include = false}) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause( + IdWhereClause.lessThan(upper: id, includeUpper: include), + ); + }); + } + + QueryBuilder idBetween( + Id lowerId, + Id upperId, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IdWhereClause.between( + lower: lowerId, + includeLower: includeLower, + upper: upperId, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder userIdEqualTo(String userId) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.equalTo( + indexName: r'userId', + value: [userId], + )); + }); + } + + QueryBuilder userIdNotEqualTo( + String userId) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'userId', + lower: [], + upper: [userId], + includeUpper: false, + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'userId', + lower: [userId], + includeLower: false, + upper: [], + )); + } else { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'userId', + lower: [userId], + includeLower: false, + upper: [], + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'userId', + lower: [], + upper: [userId], + includeUpper: false, + )); + } + }); + } +} + +extension CUserQueryFilter on QueryBuilder { + QueryBuilder connectionStatusEqualTo( + UserConnectionStatus value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'connectionStatus', + value: value, + )); + }); + } + + QueryBuilder connectionStatusGreaterThan( + UserConnectionStatus value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'connectionStatus', + value: value, + )); + }); + } + + QueryBuilder connectionStatusLessThan( + UserConnectionStatus value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'connectionStatus', + value: value, + )); + }); + } + + QueryBuilder connectionStatusBetween( + UserConnectionStatus lower, + UserConnectionStatus upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'connectionStatus', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder friendDiscoveryKeyEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'friendDiscoveryKey', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + friendDiscoveryKeyGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'friendDiscoveryKey', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder friendDiscoveryKeyLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'friendDiscoveryKey', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder friendDiscoveryKeyBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'friendDiscoveryKey', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + friendDiscoveryKeyStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'friendDiscoveryKey', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder friendDiscoveryKeyEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'friendDiscoveryKey', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder friendDiscoveryKeyContains( + String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'friendDiscoveryKey', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder friendDiscoveryKeyMatches( + String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'friendDiscoveryKey', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + friendDiscoveryKeyIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'friendDiscoveryKey', + value: '', + )); + }); + } + + QueryBuilder + friendDiscoveryKeyIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'friendDiscoveryKey', + value: '', + )); + }); + } + + QueryBuilder friendNameEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'friendName', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder friendNameGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'friendName', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder friendNameLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'friendName', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder friendNameBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'friendName', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder friendNameStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'friendName', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder friendNameEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'friendName', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder friendNameContains( + String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'friendName', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder friendNameMatches( + String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'friendName', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder friendNameIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'friendName', + value: '', + )); + }); + } + + QueryBuilder friendNameIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'friendName', + value: '', + )); + }); + } + + QueryBuilder idEqualTo(Id value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'id', + value: value, + )); + }); + } + + QueryBuilder idGreaterThan( + Id value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'id', + value: value, + )); + }); + } + + QueryBuilder idLessThan( + Id value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'id', + value: value, + )); + }); + } + + QueryBuilder idBetween( + Id lower, + Id upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'id', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder isActiveIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'isActive', + )); + }); + } + + QueryBuilder isActiveIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'isActive', + )); + }); + } + + QueryBuilder isActiveEqualTo( + bool? value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'isActive', + value: value, + )); + }); + } + + QueryBuilder lastSeenAtIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'lastSeenAt', + )); + }); + } + + QueryBuilder lastSeenAtIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'lastSeenAt', + )); + }); + } + + QueryBuilder lastSeenAtEqualTo( + int? value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'lastSeenAt', + value: value, + )); + }); + } + + QueryBuilder lastSeenAtGreaterThan( + int? value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'lastSeenAt', + value: value, + )); + }); + } + + QueryBuilder lastSeenAtLessThan( + int? value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'lastSeenAt', + value: value, + )); + }); + } + + QueryBuilder lastSeenAtBetween( + int? lower, + int? upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'lastSeenAt', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder metaDataEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'metaData', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder metaDataGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'metaData', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder metaDataLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'metaData', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder metaDataBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'metaData', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder metaDataStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'metaData', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder metaDataEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'metaData', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder metaDataContains( + String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'metaData', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder metaDataMatches( + String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'metaData', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder metaDataIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'metaData', + value: '', + )); + }); + } + + QueryBuilder metaDataIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'metaData', + value: '', + )); + }); + } + + QueryBuilder nicknameEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'nickname', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder nicknameGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'nickname', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder nicknameLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'nickname', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder nicknameBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'nickname', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder nicknameStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'nickname', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder nicknameEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'nickname', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder nicknameContains( + String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'nickname', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder nicknameMatches( + String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'nickname', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder nicknameIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'nickname', + value: '', + )); + }); + } + + QueryBuilder nicknameIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'nickname', + value: '', + )); + }); + } + + QueryBuilder preferredLanguagesIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'preferredLanguages', + )); + }); + } + + QueryBuilder + preferredLanguagesIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'preferredLanguages', + )); + }); + } + + QueryBuilder + preferredLanguagesElementEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'preferredLanguages', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + preferredLanguagesElementGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'preferredLanguages', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + preferredLanguagesElementLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'preferredLanguages', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + preferredLanguagesElementBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'preferredLanguages', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + preferredLanguagesElementStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'preferredLanguages', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + preferredLanguagesElementEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'preferredLanguages', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + preferredLanguagesElementContains(String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'preferredLanguages', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + preferredLanguagesElementMatches(String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'preferredLanguages', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + preferredLanguagesElementIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'preferredLanguages', + value: '', + )); + }); + } + + QueryBuilder + preferredLanguagesElementIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'preferredLanguages', + value: '', + )); + }); + } + + QueryBuilder + preferredLanguagesLengthEqualTo(int length) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'preferredLanguages', + length, + true, + length, + true, + ); + }); + } + + QueryBuilder + preferredLanguagesIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'preferredLanguages', + 0, + true, + 0, + true, + ); + }); + } + + QueryBuilder + preferredLanguagesIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'preferredLanguages', + 0, + false, + 999999, + true, + ); + }); + } + + QueryBuilder + preferredLanguagesLengthLessThan( + int length, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'preferredLanguages', + 0, + true, + length, + include, + ); + }); + } + + QueryBuilder + preferredLanguagesLengthGreaterThan( + int length, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'preferredLanguages', + length, + include, + 999999, + true, + ); + }); + } + + QueryBuilder + preferredLanguagesLengthBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'preferredLanguages', + lower, + includeLower, + upper, + includeUpper, + ); + }); + } + + QueryBuilder profileUrlEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'profileUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder profileUrlGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'profileUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder profileUrlLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'profileUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder profileUrlBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'profileUrl', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder profileUrlStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'profileUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder profileUrlEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'profileUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder profileUrlContains( + String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'profileUrl', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder profileUrlMatches( + String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'profileUrl', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder profileUrlIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'profileUrl', + value: '', + )); + }); + } + + QueryBuilder profileUrlIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'profileUrl', + value: '', + )); + }); + } + + QueryBuilder requireAuthEqualTo( + bool value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'requireAuth', + value: value, + )); + }); + } + + QueryBuilder userIdEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'userId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder userIdGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'userId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder userIdLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'userId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder userIdBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'userId', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder userIdStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'userId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder userIdEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'userId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder userIdContains(String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'userId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder userIdMatches( + String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'userId', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder userIdIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'userId', + value: '', + )); + }); + } + + QueryBuilder userIdIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'userId', + value: '', + )); + }); + } +} + +extension CUserQueryObject on QueryBuilder {} + +extension CUserQueryLinks on QueryBuilder {} + +extension CUserQuerySortBy on QueryBuilder { + QueryBuilder sortByConnectionStatus() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'connectionStatus', Sort.asc); + }); + } + + QueryBuilder sortByConnectionStatusDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'connectionStatus', Sort.desc); + }); + } + + QueryBuilder sortByFriendDiscoveryKey() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'friendDiscoveryKey', Sort.asc); + }); + } + + QueryBuilder sortByFriendDiscoveryKeyDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'friendDiscoveryKey', Sort.desc); + }); + } + + QueryBuilder sortByFriendName() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'friendName', Sort.asc); + }); + } + + QueryBuilder sortByFriendNameDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'friendName', Sort.desc); + }); + } + + QueryBuilder sortByIsActive() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isActive', Sort.asc); + }); + } + + QueryBuilder sortByIsActiveDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isActive', Sort.desc); + }); + } + + QueryBuilder sortByLastSeenAt() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'lastSeenAt', Sort.asc); + }); + } + + QueryBuilder sortByLastSeenAtDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'lastSeenAt', Sort.desc); + }); + } + + QueryBuilder sortByMetaData() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'metaData', Sort.asc); + }); + } + + QueryBuilder sortByMetaDataDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'metaData', Sort.desc); + }); + } + + QueryBuilder sortByNickname() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'nickname', Sort.asc); + }); + } + + QueryBuilder sortByNicknameDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'nickname', Sort.desc); + }); + } + + QueryBuilder sortByProfileUrl() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'profileUrl', Sort.asc); + }); + } + + QueryBuilder sortByProfileUrlDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'profileUrl', Sort.desc); + }); + } + + QueryBuilder sortByRequireAuth() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'requireAuth', Sort.asc); + }); + } + + QueryBuilder sortByRequireAuthDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'requireAuth', Sort.desc); + }); + } + + QueryBuilder sortByUserId() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'userId', Sort.asc); + }); + } + + QueryBuilder sortByUserIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'userId', Sort.desc); + }); + } +} + +extension CUserQuerySortThenBy on QueryBuilder { + QueryBuilder thenByConnectionStatus() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'connectionStatus', Sort.asc); + }); + } + + QueryBuilder thenByConnectionStatusDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'connectionStatus', Sort.desc); + }); + } + + QueryBuilder thenByFriendDiscoveryKey() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'friendDiscoveryKey', Sort.asc); + }); + } + + QueryBuilder thenByFriendDiscoveryKeyDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'friendDiscoveryKey', Sort.desc); + }); + } + + QueryBuilder thenByFriendName() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'friendName', Sort.asc); + }); + } + + QueryBuilder thenByFriendNameDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'friendName', Sort.desc); + }); + } + + QueryBuilder thenById() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'id', Sort.asc); + }); + } + + QueryBuilder thenByIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'id', Sort.desc); + }); + } + + QueryBuilder thenByIsActive() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isActive', Sort.asc); + }); + } + + QueryBuilder thenByIsActiveDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isActive', Sort.desc); + }); + } + + QueryBuilder thenByLastSeenAt() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'lastSeenAt', Sort.asc); + }); + } + + QueryBuilder thenByLastSeenAtDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'lastSeenAt', Sort.desc); + }); + } + + QueryBuilder thenByMetaData() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'metaData', Sort.asc); + }); + } + + QueryBuilder thenByMetaDataDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'metaData', Sort.desc); + }); + } + + QueryBuilder thenByNickname() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'nickname', Sort.asc); + }); + } + + QueryBuilder thenByNicknameDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'nickname', Sort.desc); + }); + } + + QueryBuilder thenByProfileUrl() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'profileUrl', Sort.asc); + }); + } + + QueryBuilder thenByProfileUrlDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'profileUrl', Sort.desc); + }); + } + + QueryBuilder thenByRequireAuth() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'requireAuth', Sort.asc); + }); + } + + QueryBuilder thenByRequireAuthDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'requireAuth', Sort.desc); + }); + } + + QueryBuilder thenByUserId() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'userId', Sort.asc); + }); + } + + QueryBuilder thenByUserIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'userId', Sort.desc); + }); + } +} + +extension CUserQueryWhereDistinct on QueryBuilder { + QueryBuilder distinctByConnectionStatus() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'connectionStatus'); + }); + } + + QueryBuilder distinctByFriendDiscoveryKey( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'friendDiscoveryKey', + caseSensitive: caseSensitive); + }); + } + + QueryBuilder distinctByFriendName( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'friendName', caseSensitive: caseSensitive); + }); + } + + QueryBuilder distinctByIsActive() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'isActive'); + }); + } + + QueryBuilder distinctByLastSeenAt() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'lastSeenAt'); + }); + } + + QueryBuilder distinctByMetaData( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'metaData', caseSensitive: caseSensitive); + }); + } + + QueryBuilder distinctByNickname( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'nickname', caseSensitive: caseSensitive); + }); + } + + QueryBuilder distinctByPreferredLanguages() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'preferredLanguages'); + }); + } + + QueryBuilder distinctByProfileUrl( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'profileUrl', caseSensitive: caseSensitive); + }); + } + + QueryBuilder distinctByRequireAuth() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'requireAuth'); + }); + } + + QueryBuilder distinctByUserId( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'userId', caseSensitive: caseSensitive); + }); + } +} + +extension CUserQueryProperty on QueryBuilder { + QueryBuilder idProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'id'); + }); + } + + QueryBuilder + connectionStatusProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'connectionStatus'); + }); + } + + QueryBuilder friendDiscoveryKeyProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'friendDiscoveryKey'); + }); + } + + QueryBuilder friendNameProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'friendName'); + }); + } + + QueryBuilder isActiveProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'isActive'); + }); + } + + QueryBuilder lastSeenAtProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'lastSeenAt'); + }); + } + + QueryBuilder metaDataProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'metaData'); + }); + } + + QueryBuilder nicknameProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'nickname'); + }); + } + + QueryBuilder?, QQueryOperations> + preferredLanguagesProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'preferredLanguages'); + }); + } + + QueryBuilder profileUrlProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'profileUrl'); + }); + } + + QueryBuilder requireAuthProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'requireAuth'); + }); + } + + QueryBuilder userIdProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'userId'); + }); + } +} diff --git a/lib/src/internal/main/chat/chat.dart b/lib/src/internal/main/chat/chat.dart index 48f70e09..cad3bbc5 100644 --- a/lib/src/internal/main/chat/chat.dart +++ b/lib/src/internal/main/chat/chat.dart @@ -12,6 +12,7 @@ import 'package:sendbird_chat_sdk/src/internal/main/chat_context/chat_context.da import 'package:sendbird_chat_sdk/src/internal/main/chat_manager/collection_manager/collection_manager.dart'; import 'package:sendbird_chat_sdk/src/internal/main/chat_manager/command_manager.dart'; import 'package:sendbird_chat_sdk/src/internal/main/chat_manager/connection_manager.dart'; +import 'package:sendbird_chat_sdk/src/internal/main/chat_manager/db_manager.dart'; import 'package:sendbird_chat_sdk/src/internal/main/chat_manager/event_dispatcher.dart'; import 'package:sendbird_chat_sdk/src/internal/main/chat_manager/event_manager.dart'; import 'package:sendbird_chat_sdk/src/internal/main/chat_manager/session_manager.dart'; @@ -50,6 +51,7 @@ import 'package:sendbird_chat_sdk/src/internal/network/http/http_client/request/ import 'package:universal_io/io.dart'; part 'chat_auth.dart'; +part 'chat_caching.dart'; part 'chat_channel.dart'; part 'chat_connection.dart'; part 'chat_emoji.dart'; @@ -58,7 +60,7 @@ part 'chat_notifications.dart'; part 'chat_push.dart'; part 'chat_user.dart'; -const sdkVersion = '4.1.2'; +const sdkVersion = '4.2.0'; // Internal implementation for main class. Do not directly access this class. class Chat with WidgetsBindingObserver { @@ -94,6 +96,13 @@ class Chat with WidgetsBindingObserver { // with `!` and `?` to support older versions of the API as well. T? _ambiguate(T? value) => value; // (?) + // isTest + bool get isTest { + return kIsWeb + ? const String.fromEnvironment('FLUTTER_TEST') == 'true' + : Platform.environment['FLUTTER_TEST'] == 'true'; + } + // Check dependencies late ChatContext chatContext; late ChannelCache channelCache; @@ -105,6 +114,7 @@ class Chat with WidgetsBindingObserver { late EventDispatcher eventDispatcher; late CollectionManager collectionManager; late StatManager statManager; + late DBManager dbManager; final int chatId; @@ -127,6 +137,7 @@ class Chat with WidgetsBindingObserver { ); // HttpClient eventDispatcher = EventDispatcher(chat: this); collectionManager = CollectionManager(chat: this); + dbManager = DBManager(chat: this); _listenConnectivityChangedEvent(); } @@ -189,16 +200,7 @@ class Chat with WidgetsBindingObserver { void _listenConnectivityChangedEvent() { sbLog.d(StackTrace.current); - String flutterTest = const String.fromEnvironment('FLUTTER_TEST'); - if (flutterTest.isEmpty && kIsWeb) { - flutterTest = ''; - } - - // NOTE: do not run connectivity on test - final isTest = kIsWeb - ? flutterTest == 'true' - : Platform.environment['FLUTTER_TEST'] == 'true'; - + // Do not run connectivity on test if (!isTest) { sbLog.d( StackTrace.current, 'Connectivity().onConnectivityChanged.listen()'); diff --git a/lib/src/internal/main/chat/chat_auth.dart b/lib/src/internal/main/chat/chat_auth.dart index d42ad449..4beff797 100644 --- a/lib/src/internal/main/chat/chat_auth.dart +++ b/lib/src/internal/main/chat/chat_auth.dart @@ -45,6 +45,15 @@ extension ChatAuth on Chat { apiHost: apiHost, )); } on SendbirdException catch (e) { + //+ [DBManager] + if (dbManager.isEnabled()) { + final user = await dbManager.getLoginInfoByException(userId, e); + if (user != null) { + return user; + } + } + //- [DBManager] + if (e.code == SendbirdError.accessTokenNotValid) { eventManager.notifySessionError(InvalidAccessTokenException()); throw InvalidAccessTokenException(); diff --git a/lib/src/internal/main/chat/chat_caching.dart b/lib/src/internal/main/chat/chat_caching.dart new file mode 100644 index 00000000..57cce15e --- /dev/null +++ b/lib/src/internal/main/chat/chat_caching.dart @@ -0,0 +1,18 @@ +// Copyright (c) 2023 Sendbird, Inc. All rights reserved. + +part of 'chat.dart'; + +extension ChatCaching on Chat { + Future getCachedDataSize() async { + return await dbManager.getDBFileSize(); + } + + Future clearCachedData() async { + await dbManager.clear(); + } + + Future clearCachedMessages(String channelUrl) async { + await dbManager.deleteGroupChannels([channelUrl]); + await dbManager.deleteFeedChannels([channelUrl]); + } +} diff --git a/lib/src/internal/main/chat/chat_channel.dart b/lib/src/internal/main/chat/chat_channel.dart index 987da38e..3df4fc18 100644 --- a/lib/src/internal/main/chat/chat_channel.dart +++ b/lib/src/internal/main/chat/chat_channel.dart @@ -29,6 +29,13 @@ extension ChatChannel on Chat { for (final element in res.updatedChannels) { element.saveToCache(this); } + + //+ [DBManager] + if (dbManager.isEnabled()) { + await dbManager.upsertGroupChannels(res.updatedChannels); + } + //- [DBManager] + return res; } @@ -46,6 +53,13 @@ extension ChatChannel on Chat { for (final element in res.updatedChannels) { element.saveToCache(this); } + + //+ [DBManager] + if (dbManager.isEnabled()) { + await dbManager.upsertFeedChannels(res.updatedChannels); + } + //- [DBManager] + return res; } diff --git a/lib/src/internal/main/chat_manager/collection_manager/collection_manager.dart b/lib/src/internal/main/chat_manager/collection_manager/collection_manager.dart index b9aa80fd..5d22fe8e 100644 --- a/lib/src/internal/main/chat_manager/collection_manager/collection_manager.dart +++ b/lib/src/internal/main/chat_manager/collection_manager/collection_manager.dart @@ -1,12 +1,13 @@ // Copyright (c) 2023 Sendbird, Inc. All rights reserved. -import 'dart:math'; - +import 'package:collection/collection.dart'; import 'package:sendbird_chat_sdk/sendbird_chat_sdk.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/channel/meta/channel_info.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/message/meta/message_changelog_info.dart'; import 'package:sendbird_chat_sdk/src/internal/main/chat/chat.dart'; -import 'package:sendbird_chat_sdk/src/internal/main/extensions/extensions.dart'; import 'package:sendbird_chat_sdk/src/internal/main/logger/sendbird_logger.dart'; import 'package:sendbird_chat_sdk/src/internal/network/http/http_client/request/channel/message/channel_messages_gap_request.dart'; +import 'package:sendbird_chat_sdk/src/internal/network/http/http_client/request/channel/message/channel_messages_get_request.dart'; import 'package:uuid/uuid.dart'; part 'group_channel_collection_manager.dart'; @@ -26,9 +27,9 @@ class CollectionManager { // MessageCollection final List baseMessageCollections = []; - final Map lastRequestTsForMessageChangeLogs = {}; - final Map lastRequestTsForPollChangeLogs = {}; - final Map lastRequestTsForMessagesGap = {}; + int lastRequestTsForMessageChangeLogs = 0; + int lastRequestTsForPollChangeLogs = 0; + int lastRequestTsForMessagesGap = 0; bool isGroupChannelCollectionsRefreshing = false; bool isBaseMessageCollectionsRefreshing = false; @@ -44,25 +45,44 @@ class CollectionManager { ); } + void _setInitialGroupChannelChangeLogsTs() { + final now = DateTime.now().millisecondsSinceEpoch; + lastRequestTsForGroupChannelChangeLogs = now; + } + + void _setInitialMessageChangeLogsAndMessagesGapTs() { + final now = DateTime.now().millisecondsSinceEpoch; + lastRequestTsForMessageChangeLogs = now; + lastRequestTsForPollChangeLogs = now; + lastRequestTsForMessagesGap = now; + } + //------------------------------// // Reconnected //------------------------------// Future onLogin() async { sbLog.d(StackTrace.current); + + //+ [DBManager] + if (_chat.dbManager.isEnabled()) { + await _chat.dbManager.checkDBFileSize(); + await _refresh(); + } + //- [DBManager] } Future onReconnected() async { sbLog.d(StackTrace.current); - await refresh(); + await _refresh(); } - Future refresh() async { + Future _refresh() async { sbLog.d(StackTrace.current); List> futures = []; - futures.add(_refreshGroupChannelCollections()); + futures.add(refreshGroupChannelCollections()); futures.add(_refreshBaseMessageCollections()); if (futures.isNotEmpty) { @@ -70,7 +90,7 @@ class CollectionManager { } } - Future _refreshGroupChannelCollections() async { + Future refreshGroupChannelCollections() async { isGroupChannelCollectionsRefreshing = true; List> futures = []; @@ -89,60 +109,52 @@ class CollectionManager { Future _refreshBaseMessageCollections() async { isBaseMessageCollectionsRefreshing = true; - List> futures = []; - for (final collection in baseMessageCollections) { if (collection.isInitialized) { - futures.add(_requestMessageChangeLogs(collection)); - futures.add(_requestPollChangeLogs(collection)); - futures.add(_requestMessagesGap(collection)); + await _requestMessageChangeLogs(collection); + await _requestPollChangeLogs(collection); + await _requestMessagesGap(collection); } } - if (futures.isNotEmpty) { - await Future.wait(futures); - } - isBaseMessageCollectionsRefreshing = false; } - Future refreshNotificationCollections() async { - List> futures = []; + Future refreshBaseMessageCollection( + BaseMessageCollection collection) async { + for (final collection in baseMessageCollections) { + if (collection.isInitialized) { + await _requestMessageChangeLogs(collection); + await _requestPollChangeLogs(collection); + } + } + } + Future refreshNotificationCollections() async { for (final collection in baseMessageCollections) { if (collection is NotificationCollection) { if (collection.isInitialized) { - futures.add(_requestMessageChangeLogs(collection)); - futures.add(_requestMessagesGap(collection)); + await _requestMessageChangeLogs(collection); + await _requestMessagesGap(collection); } } } - - if (futures.isNotEmpty) { - await Future.wait(futures); - } } Future refreshNotificationCollection({ required String channelUrl, }) async { - List> futures = []; - for (final collection in baseMessageCollections) { if (collection is NotificationCollection) { if (collection.isInitialized) { if (collection.baseChannel.channelUrl == channelUrl) { - futures.add(_requestMessageChangeLogs(collection)); - futures.add(_requestMessagesGap(collection)); + await _requestMessageChangeLogs(collection); + await _requestMessagesGap(collection); break; } } } } - - if (futures.isNotEmpty) { - await Future.wait(futures); - } } void markAsReadForFeedChannel(String channelUrl, List? messageIds) { @@ -181,6 +193,33 @@ class CollectionManager { } } } + + void onMessagesUpdated(String channelUrl, List? messages) async { + sbLog.d(StackTrace.current, 'onMessagesUpdated()'); + + for (final collection in baseMessageCollections) { + if (collection is NotificationCollection) { + if (collection.isInitialized) { + if (collection.baseChannel.channelUrl == channelUrl) { + if (collection.baseHandler is NotificationCollectionHandler && + collection.baseChannel is FeedChannel) { + (collection.baseHandler as NotificationCollectionHandler) + .onMessagesUpdated( + NotificationContext( + CollectionEventSource.eventMessageUpdated, + SendingStatus.succeeded, + ), + collection.baseChannel as FeedChannel, + messages != null + ? List.from(messages) + : collection.messageList); + } + break; + } + } + } + } + } } //------------------------------// @@ -420,7 +459,7 @@ class InternalGroupChannelHandlerForCollectionManager baseChannel: channel, eventSource: CollectionEventSource.eventMessageDeleted, sendingStatus: SendingStatus.succeeded, - deletedMessageIds: [messageId], + deletedMessageIds: [messageId.toString()], ); break; } @@ -663,48 +702,30 @@ class InternalFeedChannelHandlerForCollectionManager // @override // void onMentionReceived(BaseChannel channel, NotificationMessage message) { // if (channel is FeedChannel) { -// for (final messageCollection -// in _collectionManager.baseMessageCollections) { -// if (messageCollection.baseChannel.channelUrl == channel.channelUrl) { -// _collectionManager.sendEventsToMessageCollectionList( -// eventSource: CollectionEventSource.eventMentionReceived, -// updatedChannels: [channel], -// ); -// break; -// } -// } +// _collectionManager.sendEventsToMessageCollectionList( +// eventSource: CollectionEventSource.eventMentionReceived, +// updatedChannels: [channel], +// ); // } // } @override void onChannelChanged(BaseChannel channel) { if (channel is FeedChannel) { - for (final messageCollection - in _collectionManager.baseMessageCollections) { - if (messageCollection.baseChannel.channelUrl == channel.channelUrl) { - _collectionManager.sendEventsToMessageCollectionList( - eventSource: CollectionEventSource.eventChannelChanged, - updatedChannels: [channel], - ); - break; - } - } + _collectionManager.sendEventsToMessageCollectionList( + eventSource: CollectionEventSource.eventChannelChanged, + updatedChannels: [channel], + ); } } // @override // void onChannelDeleted(String channelUrl, ChannelType channelType) { // if (channelType == ChannelType.feed) { - // for (final messageCollection - // in _collectionManager.baseMessageCollections) { - // if (messageCollection.baseChannel.channelUrl == channelUrl) { - // _collectionManager.sendEventsToMessageCollectionList( - // eventSource: CollectionEventSource.eventChannelDeleted, - // deletedChannelUrls: [channelUrl], - // ); - // break; - // } - // } + // _collectionManager.sendEventsToMessageCollectionList( + // eventSource: CollectionEventSource.eventChannelDeleted, + // deletedChannelUrls: [channelUrl], + // ); // } // } diff --git a/lib/src/internal/main/chat_manager/collection_manager/group_channel_collection_manager.dart b/lib/src/internal/main/chat_manager/collection_manager/group_channel_collection_manager.dart index 761ea093..021e5cd7 100644 --- a/lib/src/internal/main/chat_manager/collection_manager/group_channel_collection_manager.dart +++ b/lib/src/internal/main/chat_manager/collection_manager/group_channel_collection_manager.dart @@ -8,15 +8,12 @@ extension GroupChannelCollectionManager on CollectionManager { //------------------------------// void addGroupChannelCollection(GroupChannelCollection collection) { groupChannelCollections.add(collection); - - final now = DateTime.now().millisecondsSinceEpoch; - if (lastRequestTsForGroupChannelChangeLogs == 0) { - lastRequestTsForGroupChannelChangeLogs = now; - } + _setInitialGroupChannelChangeLogsTs(); } void removeGroupChannelCollection(GroupChannelCollection collection) { groupChannelCollections.remove(collection); + _setInitialMessageChangeLogsAndMessagesGapTs(); } //------------------------------// @@ -31,9 +28,14 @@ extension GroupChannelCollectionManager on CollectionManager { GroupChannelChangeLogs changeLogs; String? token; - do { - final now = DateTime.now().millisecondsSinceEpoch; + //+ [DBManager] + final info = await _chat.dbManager.getChannelInfo(); + if (info != null) { + token = info.lastChannelToken; + } + //- [DBManager] + do { if (token == null) { changeLogs = await _chat.getMyGroupChannelChangeLogs( params, @@ -49,10 +51,21 @@ extension GroupChannelCollectionManager on CollectionManager { updatedChannels.addAll(changeLogs.updatedChannels); deletedChannelUrls.addAll(changeLogs.deletedChannelUrls); - lastRequestTsForGroupChannelChangeLogs = now; token = changeLogs.token; } while (changeLogs.hasMore); + //+ [DBManager] + if (token != null && token.isNotEmpty) { + ChannelInfo? channelInfo = await _chat.dbManager.getChannelInfo(); + if (channelInfo != null) { + channelInfo.lastChannelToken = token; + } else { + channelInfo = ChannelInfo(lastChannelToken: token); + } + await _chat.dbManager.upsertChannelInfo(channelInfo); + } + //- [DBManager] + sendEventsToGroupChannelCollectionList( eventSource: eventSource ?? CollectionEventSource.channelChangeLogs, updatedChannels: updatedChannels, @@ -68,7 +81,21 @@ extension GroupChannelCollectionManager on CollectionManager { List? addedChannels, List? updatedChannels, List? deletedChannelUrls, - }) { + }) async { + //+ [DBManager] + if (_chat.dbManager.isEnabled()) { + if (deletedChannelUrls != null) { + await _chat.dbManager.deleteGroupChannels(deletedChannelUrls); + } + if (addedChannels != null) { + await _chat.dbManager.upsertGroupChannels(addedChannels); + } + if (updatedChannels != null) { + await _chat.dbManager.upsertGroupChannels(updatedChannels); + } + } + //- [DBManager] + if ((addedChannels != null && addedChannels.isNotEmpty) || (updatedChannels != null && updatedChannels.isNotEmpty) || (deletedChannelUrls != null && deletedChannelUrls.isNotEmpty)) { @@ -102,11 +129,45 @@ extension GroupChannelCollectionManager on CollectionManager { List? addedChannels, List? updatedChannels, List? deletedChannelUrls, - }) { + }) async { + //+ [DBManager] + if (_chat.dbManager.isEnabled()) { + if (eventSource == CollectionEventSource.channelLoadMore || + eventSource == CollectionEventSource.channelCacheLoadMore) { + if (deletedChannelUrls != null) { + await _chat.dbManager.deleteGroupChannels(deletedChannelUrls); + } + if (addedChannels != null) { + await _chat.dbManager.upsertGroupChannels(addedChannels); + } + if (updatedChannels != null) { + // Not used + await _chat.dbManager.upsertGroupChannels(updatedChannels); + } + } + } + //- [DBManager] + final List addedChannelsForEvent = []; final List updatedChannelsForEvent = []; final List deletedChannelUrlsForEvent = []; + // [First] delete + if (deletedChannelUrls != null && deletedChannelUrls.isNotEmpty) { + for (final deletedChannelUrl in deletedChannelUrls) { + for (int index = 0; + index < channelCollection.channelList.length; + index++) { + final channel = channelCollection.channelList[index]; + if (channel.channelUrl == deletedChannelUrl) { + channelCollection.channelList.removeAt(index); + deletedChannelUrlsForEvent.add(deletedChannelUrl); + break; + } + } + } + } + if (addedChannels != null && addedChannels.isNotEmpty) { for (final addedChannel in addedChannels) { bool isChannelExists = false; @@ -118,10 +179,7 @@ extension GroupChannelCollectionManager on CollectionManager { } if (!isChannelExists) { - if (channelCollection.channelList.isEmpty) { - addedChannelsForEvent.add(addedChannel); - } else if (channelCollection.canAddChannel( - eventSource, addedChannel)) { + if (channelCollection.canAddChannel(eventSource, addedChannel)) { addedChannelsForEvent.add(addedChannel); } } @@ -144,7 +202,8 @@ extension GroupChannelCollectionManager on CollectionManager { // Need to compare channel properties with updatedChannel // when eventSource is CollectionEventSource.channelChangeLogs (?) - if (channelCollection.canAddChannel(eventSource, updatedChannel)) { + if (channelCollection.canAddChannel(eventSource, updatedChannel, + checkToUpdateChannel: true)) { channelCollection.channelList[index] = updatedChannel; updatedChannelsForEvent.add(updatedChannel); } else { @@ -170,17 +229,24 @@ extension GroupChannelCollectionManager on CollectionManager { } } - if (deletedChannelUrls != null && deletedChannelUrls.isNotEmpty) { - for (final deletedChannelUrl in deletedChannelUrls) { - for (int index = 0; - index < channelCollection.channelList.length; - index++) { - final channel = channelCollection.channelList[index]; - if (channel.channelUrl == deletedChannelUrl) { - channelCollection.channelList.removeAt(index); - deletedChannelUrlsForEvent.add(deletedChannelUrl); - break; - } + if (deletedChannelUrlsForEvent.isNotEmpty) { + if (!channelCollection.isDisposed) { + //+ [DBManager] + CollectionEventSource source = eventSource; + if (eventSource == CollectionEventSource.channelLoadMore) { + source = CollectionEventSource.channelCacheLoadMore; + } + //- [DBManager] + + //+ [DBManager] + if (source == CollectionEventSource.channelCacheLoadMore) { + // Do not send this event. + // Customer does not need this event. + } + //- [DBManager] + else { + channelCollection.handler.onChannelsDeleted( + GroupChannelContext(source), deletedChannelUrlsForEvent); } } } @@ -202,12 +268,5 @@ extension GroupChannelCollectionManager on CollectionManager { GroupChannelContext(eventSource), updatedChannelsForEvent); } } - - if (deletedChannelUrlsForEvent.isNotEmpty) { - if (!channelCollection.isDisposed) { - channelCollection.handler.onChannelsDeleted( - GroupChannelContext(eventSource), deletedChannelUrlsForEvent); - } - } } } diff --git a/lib/src/internal/main/chat_manager/collection_manager/message_collection_manager.dart b/lib/src/internal/main/chat_manager/collection_manager/message_collection_manager.dart index 71dca6e7..9d0621be 100644 --- a/lib/src/internal/main/chat_manager/collection_manager/message_collection_manager.dart +++ b/lib/src/internal/main/chat_manager/collection_manager/message_collection_manager.dart @@ -8,11 +8,6 @@ extension MessageCollectionManager on CollectionManager { //------------------------------// void addMessageCollection(BaseMessageCollection collection) { baseMessageCollections.add(collection); - - final now = DateTime.now().millisecondsSinceEpoch; - lastRequestTsForMessageChangeLogs[collection.baseChannel.channelUrl] = now; - lastRequestTsForPollChangeLogs[collection.baseChannel.channelUrl] = now; - lastRequestTsForMessagesGap[collection.baseChannel.channelUrl] = now; } void removeMessageCollection(BaseMessageCollection collection) { @@ -50,13 +45,19 @@ extension MessageCollectionManager on CollectionManager { MessageChangeLogs changeLogs; String? token; - do { - final now = DateTime.now().millisecondsSinceEpoch; + //+ [DBManager] + final info = + await _chat.dbManager.getMessageChangeLogInfo(channel.channelUrl); + if (info != null) { + token = info.lastMessageToken; + } + //- [DBManager] + do { if (token == null) { changeLogs = await channel.getMessageChangeLogs( params, - timestamp: lastRequestTsForMessageChangeLogs[channel.channelUrl] ?? 0, + timestamp: lastRequestTsForMessageChangeLogs, ); } else { changeLogs = await channel.getMessageChangeLogs( @@ -68,10 +69,19 @@ extension MessageCollectionManager on CollectionManager { updatedMessages.addAll(changeLogs.updatedMessages); deletedMessageIds.addAll(changeLogs.deletedMessageIds); - lastRequestTsForMessageChangeLogs[channel.channelUrl] = now; token = changeLogs.token; } while (changeLogs.hasMore); + //+ [DBManager] + if (info != null) { + await _chat.dbManager.upsertMessageChangeLogInfo(MessageChangeLogInfo( + channelUrl: channel.channelUrl, + lastMessageToken: token, + lastPollToken: info.lastPollToken, + )); + } + //- [DBManager] + sendEventsToMessageCollection( messageCollection: messageCollection, baseChannel: channel, @@ -104,12 +114,18 @@ extension MessageCollectionManager on CollectionManager { PollChangeLogs changeLogs; String? token; - do { - final now = DateTime.now().millisecondsSinceEpoch; + //+ [DBManager] + final info = + await _chat.dbManager.getMessageChangeLogInfo(groupChannel.channelUrl); + if (info != null) { + token = info.lastPollToken; + } + //- [DBManager] + do { if (token == null) { changeLogs = await groupChannel.getPollChangeLogsSinceTimestamp( - lastRequestTsForPollChangeLogs[groupChannel.channelUrl] ?? 0, + lastRequestTsForPollChangeLogs, ); } else { changeLogs = await groupChannel.getPollChangeLogsSinceToken( @@ -131,10 +147,19 @@ extension MessageCollectionManager on CollectionManager { // changeLogs.deletedPollIds => changeLogs.deletedMessageIds - lastRequestTsForPollChangeLogs[groupChannel.channelUrl] = now; token = changeLogs.token; } while (changeLogs.hasMore); + //+ [DBManager] + if (info != null) { + await _chat.dbManager.upsertMessageChangeLogInfo(MessageChangeLogInfo( + channelUrl: groupChannel.channelUrl, + lastMessageToken: info.lastMessageToken, + lastPollToken: token, + )); + } + //- [DBManager] + sendEventsToMessageCollection( messageCollection: messageCollection, baseChannel: groupChannel, @@ -151,33 +176,64 @@ extension MessageCollectionManager on CollectionManager { Future _requestMessagesGap( BaseMessageCollection messageCollection, ) async { - final now = DateTime.now().millisecondsSinceEpoch; + final List deletedPrevMessageIds = []; + final List deletedNextMessageIds = []; + + int? prevStartTs = messageCollection.oldestMessage?.createdAt; + int? prevEndTs = messageCollection.oldestSyncedTimestamp ?? prevStartTs; + int prevCacheCount = messageCollection.messageList.where((message) { + if (prevStartTs != null && + message.createdAt >= prevStartTs && + prevEndTs != null && + message.createdAt <= prevEndTs) { + if (message is! BaseMessage || + message.sendingStatus == SendingStatus.succeeded) { + deletedPrevMessageIds.add(message.rootId); + return true; + } + } + return false; + }).length; + + int? nextEndTs = messageCollection.latestMessage?.createdAt; + int? nextStartTs = messageCollection.latestSyncedTimestamp ?? nextEndTs; + int nextCacheCount = messageCollection.messageList.where((message) { + if (nextStartTs != null && + message.createdAt >= nextStartTs && + nextEndTs != null && + message.createdAt <= nextEndTs) { + if (message is! BaseMessage || + message.sendingStatus == SendingStatus.succeeded) { + deletedNextMessageIds.add(message.rootId); + return true; + } + } + return false; + }).length; - final channel = messageCollection.baseChannel; - int nextEndTs = messageCollection.latestMessage != null - ? messageCollection.latestMessage!.createdAt - : min(lastRequestTsForMessagesGap[channel.channelUrl] ?? 0, - messageCollection.startingPoint); - int nextCacheCount = messageCollection.latestMessage != null ? 1 : 0; + nextStartTs ??= messageCollection.latestMessage?.createdAt ?? + lastRequestTsForMessagesGap; + prevStartTs ??= nextStartTs; + prevEndTs ??= nextStartTs; + nextEndTs ??= nextStartTs; - final messages = await _chat.apiClient.send?>( + final res = await _chat.apiClient.send( ChannelMessagesGapRequest( _chat, channelType: ChannelType.group, channelUrl: messageCollection.baseChannel.channelUrl, - messageListParams: messageCollection.loadNextParams.toJson(), - prevStartTs: nextEndTs, - prevEndTs: nextEndTs, - prevCacheCount: nextCacheCount, - nextStartTs: nextEndTs, - nextEndTs: IntMax.max, + messageListParams: messageCollection.params.toJson(), + prevStartTs: prevStartTs, + prevEndTs: prevEndTs, + prevCacheCount: prevCacheCount, + nextStartTs: nextStartTs, + nextEndTs: messageCollection.hasNext ? nextEndTs : SendbirdChat.maxInt, nextCacheCount: nextCacheCount, + checkingContinuousMessages: _chat.dbManager.isEnabled(), // [DBManager] ), ); - lastRequestTsForMessagesGap[channel.channelUrl] = now; - - if (messages == null) { + if (res.isHugeGap) { messageCollection.hasNext = true; if (!messageCollection.isDisposed) { @@ -191,16 +247,159 @@ extension MessageCollectionManager on CollectionManager { } } } else { - messageCollection.hasNext = false; + final List prevMessages = [...res.prevMessages]; + final List nextMessages = [...res.nextMessages]; + + if (prevMessages.isNotEmpty && + res.prevHasMore != null && + res.prevHasMore!) { + // Fill messages from latestTs to oldestTs + final oldestTs = prevStartTs; + final latestTs = prevMessages.map((message) => message.createdAt).min; + + const resultSize = 100; + final params = MessageListParams() + ..previousResultSize = resultSize + ..nextResultSize = 0 + ..inclusive = true; + + bool hasPrevious = false; + do { + ChannelMessagesGetResponse? res = await _chat.apiClient + .send(ChannelMessagesGetRequest( + _chat, + channelType: ChannelType.group, + channelUrl: messageCollection.baseChannel.channelUrl, + params: params.toJson(), + timestamp: latestTs, + checkingHasNext: false, + checkingContinuousMessages: false, + )); + + if (res.messages.isNotEmpty) { + hasPrevious = (res.messages.length == resultSize); + + for (int i = res.messages.length - 1; i >= 0; i--) { + final message = res.messages[i]; + if (message.createdAt >= oldestTs) { + bool found = false; + for (final prevMessage in prevMessages) { + if (prevMessage.rootId == message.rootId) { + found = true; + break; + } + } + if (!found) { + prevMessages.insert(0, message); + } + } else { + hasPrevious = false; + } + } + } + } while (hasPrevious); + } - sendEventsToMessageCollection( - messageCollection: messageCollection, - baseChannel: channel, - eventSource: CollectionEventSource.messagesGap, - sendingStatus: SendingStatus.succeeded, - addedMessages: messages, - isReversedAddedMessages: messageCollection.loadNextParams.reverse, - ); + if (nextMessages.isNotEmpty && + res.nextHasMore != null && + res.nextHasMore!) { + // Fill messages from oldestTs to latestTs + final oldestTs = nextMessages.map((message) => message.createdAt).max; + final latestTs = nextEndTs; + + const resultSize = 100; + final params = MessageListParams() + ..previousResultSize = 0 + ..nextResultSize = resultSize + ..inclusive = true; + + bool hasNext = false; + do { + ChannelMessagesGetResponse? res = await _chat.apiClient + .send(ChannelMessagesGetRequest( + _chat, + channelType: ChannelType.group, + channelUrl: messageCollection.baseChannel.channelUrl, + params: params.toJson(), + timestamp: oldestTs, + checkingHasNext: true, + checkingContinuousMessages: false, + )); + + if (res.messages.isNotEmpty) { + if (res.hasNext != null) { + hasNext = res.hasNext!; + } else { + hasNext = (res.messages.length == resultSize); + } + + for (final message in res.messages) { + if (message.createdAt <= latestTs) { + bool found = false; + for (final nextMessage in nextMessages) { + if (nextMessage.rootId == message.rootId) { + found = true; + break; + } + } + if (!found) { + nextMessages.add(message); + } + } else { + hasNext = false; + } + } + } + } while (hasNext); + } + + if (prevMessages.isNotEmpty) { + // For offline messaging + final List updatedMessages = []; + if (deletedPrevMessageIds.isNotEmpty) { + final removedMessage = prevMessages.removeLast(); + updatedMessages.add(removedMessage); + deletedPrevMessageIds + .removeWhere((id) => removedMessage.rootId == id); + } + + sendEventsToMessageCollection( + messageCollection: messageCollection, + baseChannel: messageCollection.baseChannel, + eventSource: CollectionEventSource.messageFill, + sendingStatus: SendingStatus.succeeded, + addedMessages: prevMessages, + isReversedAddedMessages: + !messageCollection.loadPreviousParams.reverse, + isContinuousAddedMessages: res.isPrevContinuous ?? false, + // Added ! because of loadPrevious() + updatedMessages: updatedMessages, + deletedMessageIds: deletedPrevMessageIds, + ); + } + + if (nextMessages.isNotEmpty) { + // For offline messaging + final List updatedMessages = []; + if (deletedNextMessageIds.isNotEmpty) { + final removedMessage = nextMessages.removeAt(0); + updatedMessages.add(removedMessage); + deletedNextMessageIds + .removeWhere((id) => removedMessage.rootId == id); + } + + sendEventsToMessageCollection( + messageCollection: messageCollection, + baseChannel: messageCollection.baseChannel, + eventSource: CollectionEventSource.messageFill, + sendingStatus: SendingStatus.succeeded, + addedMessages: nextMessages, + isReversedAddedMessages: messageCollection.loadNextParams.reverse, + isContinuousAddedMessages: res.isNextContinuous ?? false, + updatedMessages: updatedMessages, + deletedMessageIds: deletedNextMessageIds, + ); + } } } @@ -211,7 +410,24 @@ extension MessageCollectionManager on CollectionManager { required CollectionEventSource eventSource, List? updatedChannels, List? deletedChannelUrls, - }) { + }) async { + //+ [DBManager] + if (_chat.dbManager.isEnabled()) { + if (updatedChannels != null) { + for (final channel in updatedChannels) { + if (channel is GroupChannel) { + await _chat.dbManager.upsertGroupChannels([channel]); + } else if (channel is FeedChannel) { + await _chat.dbManager.upsertFeedChannels([channel]); + } + } + } + if (deletedChannelUrls != null) { + await _chat.dbManager.deleteGroupChannels(deletedChannelUrls); + } + } + //- [DBManager] + if (updatedChannels != null && updatedChannels.isNotEmpty) { for (final updatedChannel in updatedChannels) { for (final messageCollection in baseMessageCollections) { @@ -263,20 +479,92 @@ extension MessageCollectionManager on CollectionManager { //------------------------------// // Send events to message collection //------------------------------// - void sendEventsToMessageCollection({ + Future sendEventsToMessageCollection({ required BaseMessageCollection messageCollection, required BaseChannel baseChannel, required CollectionEventSource eventSource, required SendingStatus sendingStatus, List? addedMessages, bool isReversedAddedMessages = false, + bool isContinuousAddedMessages = false, List? updatedMessages, List? deletedMessageIds, - }) { + }) async { List addedMessagesForEvent = []; final List updatedMessagesForEvent = []; final List deletedMessagesForEvent = []; + //+ [DBManager] + if (_chat.dbManager.isEnabled()) { + // [First] delete + if (deletedMessageIds != null && deletedMessageIds.isNotEmpty) { + if (eventSource != CollectionEventSource.messageInitialize && + eventSource != CollectionEventSource.messageLoadPrevious && + eventSource != CollectionEventSource.messageLoadNext) { + List deletedStringIds = deletedMessageIds + .map((id) => (id is String) ? id : id.toString()) + .toList(); + + // MessageChunk + await _chat.dbManager.deleteMessagesInChunk( + channelUrl: baseChannel.channelUrl, + rootIds: deletedStringIds.where((id) { + if (addedMessages != null && isContinuousAddedMessages) { + for (final message in addedMessages) { + if (id == message.rootId) { + return false; + } + } + } + return true; + }).toList(), + ); + + await _chat.dbManager.deleteMessages(baseChannel, deletedStringIds); + } + } + + if (addedMessages != null && addedMessages.isNotEmpty) { + await _chat.dbManager.upsertMessages(addedMessages); + + if (isContinuousAddedMessages) { + // For offline messaging + if (updatedMessages != null && updatedMessages.isNotEmpty) { + addedMessages.addAll(updatedMessages); + } + + // MessageChunk + await _chat.dbManager.upsertMessagesInChunk( + channelUrl: baseChannel.channelUrl, + messages: addedMessages, + ); + } + } + + if (updatedMessages != null && updatedMessages.isNotEmpty) { + await _chat.dbManager.upsertMessages(updatedMessages); + } + } + //- [DBManager] + + if (deletedMessageIds != null && deletedMessageIds.isNotEmpty) { + for (final deletedMessageId in deletedMessageIds) { + for (int index = 0; + index < messageCollection.messageList.length; + index++) { + final message = messageCollection.messageList[index]; + final id = deletedMessageId is String + ? deletedMessageId + : deletedMessageId.toString(); + if (message.rootId == id) { + deletedMessagesForEvent.add(message); + messageCollection.messageList.removeAt(index); + break; + } + } + } + } + if (addedMessages != null && addedMessages.isNotEmpty) { for (final addedMessage in addedMessages) { bool isMessageExists = false; @@ -288,11 +576,11 @@ extension MessageCollectionManager on CollectionManager { } if (!isMessageExists) { - if (messageCollection.messageList.isEmpty) { - addedMessagesForEvent.add(addedMessage); - } else if (messageCollection.canAddMessage( - eventSource, addedMessage)) { + if (messageCollection.canAddMessage(eventSource, addedMessage)) { addedMessagesForEvent.add(addedMessage); + } else if (eventSource == CollectionEventSource.eventMessageSent) { + deletedMessagesForEvent.clear(); // Defensive + deletedMessagesForEvent.add(addedMessage); } } } @@ -314,63 +602,111 @@ extension MessageCollectionManager on CollectionManager { if (updatedMessages != null && updatedMessages.isNotEmpty) { for (final updatedMessage in updatedMessages) { + bool found = false; for (int index = 0; index < messageCollection.messageList.length; index++) { final message = messageCollection.messageList[index]; if (message.getMessageId() == updatedMessage.getMessageId()) { - if (eventSource == CollectionEventSource.pollChangeLogs || - eventSource == CollectionEventSource.eventPollVoted || - eventSource == CollectionEventSource.eventPollUpdated) { - if (message is UserMessage && - message.poll != null && - updatedMessage is UserMessage && - updatedMessage.poll != null && - message.poll!.updatedAt <= updatedMessage.poll!.updatedAt) { - messageCollection.messageList[index] = updatedMessage; - updatedMessagesForEvent.add(updatedMessage); - break; - } - } else if (eventSource == - CollectionEventSource.eventReactionUpdated) { - // TODO: updatedAt check (?) - messageCollection.messageList[index] = updatedMessage; - updatedMessagesForEvent.add(updatedMessage); - break; - } else if (eventSource == - CollectionEventSource.eventThreadInfoUpdated) { - // TODO: updatedAt check (?) + found = true; + if (messageCollection.canUpdateMessage( + eventSource, message, updatedMessage)) { messageCollection.messageList[index] = updatedMessage; updatedMessagesForEvent.add(updatedMessage); - break; - } else if (message.updatedAt < updatedMessage.updatedAt) { - messageCollection.messageList[index] = updatedMessage; - updatedMessagesForEvent.add(updatedMessage); - break; + } else { + deletedMessagesForEvent.clear(); // Defensive + deletedMessagesForEvent.add(updatedMessage); + } + break; + } + } + + if (!found) { + if (messageCollection.canAddMessage(eventSource, updatedMessage)) { + addedMessagesForEvent.clear(); // Defensive + addedMessagesForEvent.add(updatedMessage); + + if (messageCollection is NotificationCollection) { + addedMessagesForEvent = + List.from(addedMessagesForEvent); + } else { + // MessageCollection + addedMessagesForEvent = + List.from(addedMessagesForEvent); + } + + if (isReversedAddedMessages) { + messageCollection.messageList.insertAll(0, addedMessagesForEvent); + } else { + messageCollection.messageList.addAll(addedMessagesForEvent); } } } } } - if (deletedMessageIds != null && deletedMessageIds.isNotEmpty) { - for (final deletedMessageId in deletedMessageIds) { - for (int index = 0; - index < messageCollection.messageList.length; - index++) { - final message = messageCollection.messageList[index]; - if (message.getMessageId() == deletedMessageId) { - deletedMessagesForEvent.add(message); - messageCollection.messageList.removeAt(index); - break; + //+ [DBManager] + if (eventSource == CollectionEventSource.messageFill) { + messageCollection.setValuesFromMessageList(); // Check + } + //- [DBManager] + + if (deletedMessagesForEvent.isNotEmpty) { + if (!messageCollection.isDisposed) { + //+ [DBManager] + CollectionEventSource source = eventSource; + if (eventSource == CollectionEventSource.messageInitialize) { + source = CollectionEventSource.messageCacheInitialize; + } else if (eventSource == CollectionEventSource.messageLoadPrevious) { + source = CollectionEventSource.messageCacheLoadPrevious; + } else if (eventSource == CollectionEventSource.messageLoadNext) { + source = CollectionEventSource.messageCacheLoadNext; + } + //- [DBManager] + + //+ [DBManager] + if (source == CollectionEventSource.localMessagePendingCreated) { + // Do not send this event. + // [eventMessageSent] will be changed to a updated event if success. + } else if (source == CollectionEventSource.messageCacheInitialize || + source == CollectionEventSource.messageCacheLoadPrevious || + source == CollectionEventSource.messageCacheLoadNext || + source == CollectionEventSource.messageFill) { + // Do not send this event. + // Customer does not need this event. + } + //- [DBManager] + else { + if (messageCollection.baseHandler is MessageCollectionHandler && + baseChannel is GroupChannel) { + (messageCollection.baseHandler as MessageCollectionHandler) + .onMessagesDeleted( + MessageContext(source, sendingStatus), + baseChannel, + List.from(deletedMessagesForEvent), + ); + } else if (messageCollection.baseHandler + is NotificationCollectionHandler && + baseChannel is FeedChannel) { + (messageCollection.baseHandler as NotificationCollectionHandler) + .onMessagesDeleted( + NotificationContext(source, sendingStatus), + baseChannel, + List.from(deletedMessagesForEvent), + ); } } } } if (addedMessagesForEvent.isNotEmpty) { + messageCollection.sort(); + if (!messageCollection.isDisposed) { - if (messageCollection.baseHandler is MessageCollectionHandler && + if (eventSource == CollectionEventSource.eventMessageSent) { + updatedMessagesForEvent.clear(); // Defensive + updatedMessagesForEvent.addAll(addedMessagesForEvent); + } else if (messageCollection.baseHandler is MessageCollectionHandler && baseChannel is GroupChannel) { (messageCollection.baseHandler as MessageCollectionHandler) .onMessagesAdded( @@ -392,6 +728,8 @@ extension MessageCollectionManager on CollectionManager { } if (updatedMessagesForEvent.isNotEmpty) { + messageCollection.sort(); + if (!messageCollection.isDisposed) { if (messageCollection.baseHandler is MessageCollectionHandler && baseChannel is GroupChannel) { @@ -413,28 +751,5 @@ extension MessageCollectionManager on CollectionManager { } } } - - if (deletedMessagesForEvent.isNotEmpty) { - if (!messageCollection.isDisposed) { - if (messageCollection.baseHandler is MessageCollectionHandler && - baseChannel is GroupChannel) { - (messageCollection.baseHandler as MessageCollectionHandler) - .onMessagesDeleted( - MessageContext(eventSource, sendingStatus), - baseChannel, - List.from(deletedMessagesForEvent), - ); - } else if (messageCollection.baseHandler - is NotificationCollectionHandler && - baseChannel is FeedChannel) { - (messageCollection.baseHandler as NotificationCollectionHandler) - .onMessagesDeleted( - NotificationContext(eventSource, sendingStatus), - baseChannel, - List.from(deletedMessagesForEvent), - ); - } - } - } } } diff --git a/lib/src/internal/main/chat_manager/command_manager.dart b/lib/src/internal/main/chat_manager/command_manager.dart index df5452c0..3e957ba9 100644 --- a/lib/src/internal/main/chat_manager/command_manager.dart +++ b/lib/src/internal/main/chat_manager/command_manager.dart @@ -45,6 +45,7 @@ import 'package:sendbird_chat_sdk/src/public/main/model/thread/thread_info_updat class CommandManager { final Map> _completerMap = {}; final Map _ackTimerMap = {}; + final Map _readMap = {}; final Chat _chat; @@ -77,7 +78,11 @@ class CommandManager { } void cleanUp() { - _ackTimerMap.removeWhere((key, value) => true); + for (final key in _ackTimerMap.keys) { + _ackTimerMap[key]?.cancel(); + } + _ackTimerMap.clear(); + _readMap.clear(); } void clearCompleterMap({SendbirdException? e}) { @@ -100,13 +105,18 @@ class CommandManager { sbLog.d( StackTrace.current, '\n-[cmd] ${cmd.cmd}\n-[payload] ${cmd.payload}'); - try { + runZonedGuarded(() { _chat.connectionManager.webSocketClient.send(cmd.encode()); - } catch (e) { + }, (e, s) { sbLog.e(StackTrace.current, 'e: $e'); _ackTimerMap.remove(cmd.requestId)?.cancel(); - rethrow; - } + + if (e is SendbirdException) { + throw e; + } else { + throw SendbirdException(message: e.toString()); + } + }); final reqId = cmd.requestId; if (cmd.isAckRequired && reqId != null) { @@ -114,7 +124,11 @@ class CommandManager { Duration(seconds: _chat.chatContext.options.webSocketTimeout), () { throw AckTimeoutException(); }); + _ackTimerMap[reqId] = timer; + if (cmd.isRead) { + _readMap[reqId] = DateTime.now().millisecondsSinceEpoch; + } final completer = Completer(); _completerMap[reqId] = completer; @@ -133,7 +147,25 @@ class CommandManager { processUnreadMessageCountPayload(cmd.payload['unread_cnt']); if (cmd.requestId != null) { - _ackTimerMap.remove(cmd.requestId)?.cancel(); + if (cmd.isRead) { + final ackTs = _readMap[cmd.requestId]; + final List removedReadReqIdList = []; + + for (final reqId in _readMap.keys) { + final ts = _readMap[reqId]; + if (ackTs == null || ts == null || ts <= ackTs) { + _ackTimerMap.remove(reqId)?.cancel(); + removedReadReqIdList.add(reqId); + } + } + + for (final reqId in removedReadReqIdList) { + _readMap.remove(reqId); + } + } else { + _ackTimerMap.remove(cmd.requestId)?.cancel(); + } + final completer = _completerMap.remove(cmd.requestId); if (cmd.isError || cmd.hasError) { @@ -270,6 +302,12 @@ class CommandManager { _chat.sessionManager.setSessionKey(event.sessionKey); + //+ [DBManager] + if (_chat.dbManager.isEnabled()) { + await _chat.dbManager.setLoginInfo(_chat.chatContext, event.user); + } + //- [DBManager] + if (fromWebSocket) { _chat.chatContext.reconnectTask = ReconnectTask(event.reconnectConfiguration); diff --git a/lib/src/internal/main/chat_manager/connection_manager.dart b/lib/src/internal/main/chat_manager/connection_manager.dart index e708121f..2671a636 100644 --- a/lib/src/internal/main/chat_manager/connection_manager.dart +++ b/lib/src/internal/main/chat_manager/connection_manager.dart @@ -164,29 +164,54 @@ class ConnectionManager { }, (e, s) async { sbLog.e(StackTrace.current, 'e: $e'); - changeState(DisconnectedState(chat: chat)); - if (chat.chatContext.loginCompleter != null && - !chat.chatContext.loginCompleter!.isCompleted) { - if (e is SendbirdException) { - chat.statManager.endWsConnectStat( - hostUrl: url, - success: false, - errorCode: e.code, - errorDescription: e.message, - ); - - chat.chatContext.loginCompleter?.completeError(e); - } else { - final exception = WebSocketFailedException(message: e.toString()); - - chat.statManager.endWsConnectStat( - hostUrl: url, - success: false, - errorCode: exception.code, - errorDescription: exception.message, - ); - - chat.chatContext.loginCompleter?.completeError(exception); + if (isDisconnected() == false) { + changeState(DisconnectedState(chat: chat)); + + if (chat.chatContext.loginCompleter != null && + !chat.chatContext.loginCompleter!.isCompleted) { + if (e is SendbirdException) { + chat.statManager.endWsConnectStat( + hostUrl: url, + success: false, + errorCode: e.code, + errorDescription: e.message, + ); + + //+ [DBManager] + if (chat.dbManager.isEnabled()) { + final user = + await chat.dbManager.getLoginInfoByException(userId, e); + if (user != null) { + chat.chatContext.loginCompleter?.complete(user); + chat.chatContext.loginCompleter = null; + + if (chat.chatContext.isChatConnected) { + await chat.connectionManager.reconnect(reset: true); + } + return; + } + } + //- [DBManager] + + if (chat.chatContext.loginCompleter != null && + !chat.chatContext.loginCompleter!.isCompleted) { + chat.chatContext.loginCompleter?.completeError(e); + } + } else { + final exception = WebSocketFailedException(message: e.toString()); + + chat.statManager.endWsConnectStat( + hostUrl: url, + success: false, + errorCode: exception.code, + errorDescription: exception.message, + ); + + if (chat.chatContext.loginCompleter != null && + !chat.chatContext.loginCompleter!.isCompleted) { + chat.chatContext.loginCompleter?.completeError(exception); + } + } } } }); @@ -203,7 +228,7 @@ class ConnectionManager { errorDescription: e.name, ); - await doDisconnect(logout: true); + await doDisconnect(clear: true); throw e; }); @@ -215,9 +240,14 @@ class ConnectionManager { return user; } - Future doDisconnect({required bool logout}) async { - sbLog.i(StackTrace.current, - 'logout: $logout, userId: ${chat.chatContext.currentUserId}'); + Future doDisconnect({ + required bool clear, + bool logout = false, + }) async { + sbLog.i( + StackTrace.current, + 'clear: $clear, logout: $logout, userId: ${chat.chatContext.currentUserId}', + ); if (chat.chatContext.loginCompleter != null && !chat.chatContext.loginCompleter!.isCompleted) { @@ -228,7 +258,7 @@ class ConnectionManager { if (isReconnecting()) { reconnectTimer?.cancel(); reconnectTimer = null; - if (logout) { + if (clear) { chat.eventManager.notifyReconnectFailed(); } } @@ -237,7 +267,7 @@ class ConnectionManager { final disconnectedUserId = chat.chatContext.currentUserId ?? ''; - if (logout) { + if (clear || logout) { await chat.eventDispatcher.onLogout(); chat.messageQueueMap.forEach((key, q) => q.cleanUp()); @@ -245,18 +275,26 @@ class ConnectionManager { // chat.uploads.forEach((key, value) => _api.cancelUploadingFile(key)); chat.uploadTaskMap.clear(); - chat.chatContext.cleanUp(); chat.channelCache.cleanUp(); chat.sessionManager.cleanUp(); chat.commandManager.cleanUp(); chat.apiClient.cleanUp(); + + if (logout) { + chat.chatContext.cleanUp(); + //+ [DBManager] + if (chat.dbManager.isEnabled()) { + await chat.dbManager.clear(); + } + //- [DBManager] + } } else { await chat.eventDispatcher.onDisconnected(); } changeState(DisconnectedState(chat: chat)); - if (logout && disconnectedUserId.isNotEmpty) { + if (clear && disconnectedUserId.isNotEmpty) { chat.eventManager.notifyDisconnected(disconnectedUserId); } } @@ -274,7 +312,7 @@ class ConnectionManager { final task = chat.chatContext.reconnectTask; if (task == null || (task.exceedRetryCount && task.hasRetriedLastChance)) { sbLog.w(StackTrace.current, 'exceedRetryCount and hasRetriedLastChance'); - disconnect(logout: true); + disconnect(logout: task != null); return false; } diff --git a/lib/src/internal/main/chat_manager/db_manager.dart b/lib/src/internal/main/chat_manager/db_manager.dart new file mode 100644 index 00000000..e5a16b82 --- /dev/null +++ b/lib/src/internal/main/chat_manager/db_manager.dart @@ -0,0 +1,797 @@ +// Copyright (c) 2023 Sendbird, Inc. All rights reserved. + +import 'package:isar/isar.dart'; +import 'package:path/path.dart' as p; +import 'package:path_provider/path_provider.dart'; +import 'package:sendbird_chat_sdk/sendbird_chat_sdk.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/db.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/channel/c_feed_channel.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/channel/c_group_channel.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/channel/meta/c_channel_info.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/channel/meta/channel_info.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/chunk/c_channel_chunk.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/chunk/c_message_chunk.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/chunk/chunk.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/chunk/message_chunk.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/login/c_login.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/login/login.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/message/c_admin_message.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/message/c_file_message.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/message/c_notification_message.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/message/c_user_message.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/message/meta/c_channel_access.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/message/meta/c_channel_message.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/message/meta/c_message_changelog_info.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/message/meta/message_changelog_info.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/user/c_user.dart'; +import 'package:sendbird_chat_sdk/src/internal/main/chat/chat.dart'; +import 'package:sendbird_chat_sdk/src/internal/main/chat_context/chat_context.dart'; +import 'package:sendbird_chat_sdk/src/internal/main/chat_manager/collection_manager/collection_manager.dart'; +import 'package:sendbird_chat_sdk/src/internal/main/extensions/extensions.dart'; +import 'package:sendbird_chat_sdk/src/internal/main/logger/sendbird_logger.dart'; +import 'package:sendbird_chat_sdk/src/internal/main/model/reconnect_task.dart'; +import 'package:sendbird_chat_sdk/src/internal/main/stats/model/default/local_cache_event_stat.dart'; +import 'package:sendbird_chat_sdk/src/internal/main/stats/sendbird_statistics.dart'; +import 'package:sendbird_chat_sdk/src/internal/main/stats/stat_utils.dart'; +import 'package:universal_io/io.dart'; + +class DBManager { + final _dbName = 'sendbird_chat'; + final _maxDBFileSize = 256; // MB + + late final Isar _isar; + bool _isInitialized = false; + + final Chat _chat; + late final DB _db; + late final Directory _dbDir; + + DBManager({required Chat chat}) : _chat = chat; + + DB getDB() { + return _db; + } + + Future init() async { + try { + if (_chat.isTest) { + // https://github.com/isar/isar#unit-tests + await Isar.initializeIsarCore(download: true); + _dbDir = Directory.systemTemp.createTempSync(); + } else { + _dbDir = await getApplicationDocumentsDirectory(); + } + + _isar = await Isar.open( + [ + // Login + CLoginSchema, + // Chunk + CChannelChunkSchema, + CMessageChunkSchema, + // Channel + CChannelInfoSchema, + CFeedChannelSchema, + CGroupChannelSchema, + // Message + CAdminMessageSchema, + CMessageChangeLogInfoSchema, + CChannelAccessSchema, + CChannelMessageSchema, + CFileMessageSchema, + CNotificationMessageSchema, + CUserMessageSchema, + // User + CUserSchema, + ], + directory: _dbDir.path, + name: _dbName, + maxSizeMiB: Isar.defaultMaxSizeMiB, // 1024 MB + ); + } catch (e) { + sbLog.e(StackTrace.current, 'e: $e'); + return false; + } + + _db = DB(chat: _chat, isar: _isar); + _isInitialized = true; + return true; + } + + bool isEnabled() { + return _chat.chatContext.options.useCollectionCaching && _isInitialized; + } + + Future getDBFileSize() async { + int? dbFileSize; + try { + final path = p.join(_dbDir.path, '$_dbName.isar'); + final file = File(path); + if (await file.exists()) { + dbFileSize = await file.length(); + sbLog.i(StackTrace.current, '$dbFileSize'); + } + } catch (e) { + sbLog.e(StackTrace.current, 'e: $e'); + } + return dbFileSize; + } + + Future write(Function writeFunc, {bool force = false}) async { + if (isEnabled() || force) { + try { + await _db.write(writeFunc); + } catch (e) { + sbLog.e(StackTrace.current, e.toString()); + + _chat.chatContext.options.useCollectionCaching = false; + await clear(); + } + } + } + + Future clear() async { + if (isEnabled()) { + try { + await _db.clear(); + } catch (e) { + sbLog.e(StackTrace.current, e.toString()); + } + } + } + + Future checkDBFileSize() async { + if (isEnabled()) { + final dbFileSize = await getDBFileSize(); + if (dbFileSize != null && dbFileSize > _maxDBFileSize * 1024 * 1024) { + List channelUrls = await _db.getOrderedChannelUrlsToDelete(); + + int? size; + for (final channelUrl in channelUrls) { + size = await getDBFileSize(); + // Delete until the half of it. (Initial DB file size is 1MB.) + if (size != null && + size > (_maxDBFileSize / 2) * 1024 * 1024 && + size > 1024 * 1024) { + await deleteMessagesInChannel(channelUrl); + } else { + break; + } + } + } + } + } + + // Login + Future setLoginInfo(ChatContext context, User user) async { + if (isEnabled()) { + final login = await _db.getLogin(user.userId); + if (login == null) { + await _db.clear(); // Defensive + } + + await _db.upsertUser(user); + await _db.upsertLogin(Login( + userId: user.userId, + services: context.services, + appInfo: context.appInfo, + uploadSizeLimit: context.uploadSizeLimit, + maxUnreadCountOnSuperGroup: context.maxUnreadCountOnSuperGroup, + lastConnectedAt: context.lastConnectedAt, + reconnectConfig: context.reconnectConfig, + )); + } + } + + Future getLoginInfoByException( + String userId, SendbirdException e) async { + User? user; + if (isEnabled()) { + if (e.code == SendbirdError.userNotExist || + e.code == SendbirdError.accessTokenNotValid || + e.code == SendbirdError.accessTokenRevoked) { + await _db.clear(); + } else { + final login = await _db.getLogin(userId); + if (login != null) { + user = await _db.getUser(userId); + if (user != null) { + _chat.chatContext.currentUser = user; + _chat.chatContext.currentUserId = user.userId; + _chat.chatContext.services = login.services; + _chat.chatContext.appInfo = login.appInfo; + _chat.chatContext.uploadSizeLimit = login.uploadSizeLimit; + _chat.chatContext.maxUnreadCountOnSuperGroup = + login.maxUnreadCountOnSuperGroup; + _chat.chatContext.lastConnectedAt = login.lastConnectedAt; + _chat.chatContext.reconnectConfig = login.reconnectConfig; + + // sessionKey + _chat.chatContext.sessionKey = + await _chat.sessionManager.getSessionKey(); + + // reconnectTask + if (_chat.chatContext.reconnectConfig != null) { + _chat.chatContext.reconnectTask = + ReconnectTask(_chat.chatContext.reconnectConfig!); + } + } + } + } + } + return user; + } + + // Channel + Future deleteMessagesInChannel(channelUrl) async { + if (isEnabled()) { + // Messages + await deleteMessagesInDeletedChannel(channelUrl); + + // MessageChangeLogInfo + await _db.deleteMessageChangeLogInfo(channelUrl); + } + } + + // GroupChannel + Future hasGroupChannels() async { + return (await _db.getGroupChannelCount() > 0); + } + + Future upsertGroupChannels(List channels) async { + if (isEnabled()) { + for (final channel in channels) { + await _db.upsertGroupChannel(channel); + } + } + } + + Future> getGroupChannels({ + required GroupChannelListQuery query, + int? offset, + }) async { + if (isEnabled()) { + return await _db.getGroupChannels(query, offset); + } + return []; + } + + Future getGroupChannel(String channelUrl) async { + if (isEnabled()) { + return await _db.getGroupChannel(channelUrl); + } + return null; + } + + Future deleteGroupChannels(List channelUrls) async { + if (isEnabled()) { + for (final channelUrl in channelUrls) { + await _db.deleteGroupChannel(channelUrl); + + // ChannelAccess + await _db.deleteChannelAccess(channelUrl); + + // ChannelChangeLogInfo + await _db.deleteChannelInfo(); + + // Messages + await deleteMessagesInDeletedChannel(channelUrl); + + // MessageChangeLogInfo + await _db.deleteMessageChangeLogInfo(channelUrl); + } + } + } + + // FeedChannel + Future upsertFeedChannels(List channels) async { + if (isEnabled()) { + for (final channel in channels) { + await _db.upsertFeedChannel(channel); + } + } + } + + Future> getFeedChannels({ + required FeedChannelListQuery query, + int? offset, + }) async { + if (isEnabled()) { + return await _db.getFeedChannels(query, offset); + } + return []; + } + + Future getFeedChannel(String channelUrl) async { + if (isEnabled()) { + return await _db.getFeedChannel(channelUrl); + } + return null; + } + + Future deleteFeedChannels(List channelUrls) async { + if (isEnabled()) { + for (final channelUrl in channelUrls) { + await _db.deleteFeedChannel(channelUrl); + + // ChannelAccess + await _db.deleteChannelAccess(channelUrl); + + // ChannelChangeLogInfo + await _db.deleteChannelInfo(); + + // Messages + await deleteMessagesInDeletedChannel(channelUrl); + + // MessageChangeLogInfo + await _db.deleteMessageChangeLogInfo(channelUrl); + } + } + } + + // Message + Future hasMessages(String channelUrl) async { + return await _db.hasMessages(channelUrl); + } + + Future upsertMessages(List messages) async { + if (isEnabled()) { + for (final message in messages) { + switch (message.messageType) { + case MessageType.user: + await _db.upsertUserMessage(message as UserMessage); + break; + case MessageType.file: + // withFileBytes() is not supported. + final params = (message as FileMessage).messageCreateParams; + if (params == null || params.fileInfo.fileBytes == null) { + await _db.upsertFileMessage(message); + } + break; + case MessageType.admin: + await _db.upsertAdminMessage(message as AdminMessage); + break; + case MessageType.notification: + await _db.upsertNotificationMessage(message as NotificationMessage); + break; + } + } + } + } + + Future> getMessages({ + required ChannelType channelType, + required String channelUrl, + required SendingStatus sendingStatus, + required int timestamp, + required MessageListParams params, + required bool isPrevious, + }) async { + if (isEnabled()) { + return await _db.getMessages( + channelType, + channelUrl, + sendingStatus, + timestamp, + params, + isPrevious, + ); + } + return []; + } + + Future> getPendingMessages({ + required ChannelType channelType, + required String channelUrl, + }) async { + if (isEnabled()) { + return await _db.getPendingMessages( + channelType: channelType, + channelUrl: channelUrl, + ); + } + return []; + } + + Future> getFailedMessages({ + required ChannelType channelType, + required String channelUrl, + bool reverse = false, + }) async { + if (isEnabled()) { + return await _db.getFailedMessages( + channelType: channelType, + channelUrl: channelUrl, + reverse: reverse, + ); + } + return []; + } + + Future removeFailedMessages({ + required ChannelType channelType, + required String channelUrl, + required List messages, + }) async { + if (isEnabled()) { + final failedMessages = messages + .where((message) => message.sendingStatus == SendingStatus.failed) + .toList(); + + await _db.removeFailedMessages( + channelType: channelType, + channelUrl: channelUrl, + messages: failedMessages, + ); + + // Event + for (final messageCollection + in _chat.collectionManager.baseMessageCollections) { + if (messageCollection.baseChannel.channelUrl == channelUrl) { + _chat.collectionManager.sendEventsToMessageCollection( + messageCollection: messageCollection, + baseChannel: messageCollection.baseChannel, + eventSource: CollectionEventSource.eventMessageDeleted, + sendingStatus: SendingStatus.failed, + deletedMessageIds: + failedMessages.map((message) => message.rootId).toList(), + ); + break; + } + } + } + } + + Future removeAllFailedMessages({ + required ChannelType channelType, + required String channelUrl, + }) async { + if (isEnabled()) { + await _db.removeAllFailedMessages( + channelType: channelType, + channelUrl: channelUrl, + ); + + // Event + for (final messageCollection + in _chat.collectionManager.baseMessageCollections) { + if (messageCollection.baseChannel.channelUrl == channelUrl) { + final failedMessages = messageCollection.messageList + .where((message) => + message is! BaseMessage || + message.sendingStatus == SendingStatus.failed) + .toList(); + + _chat.collectionManager.sendEventsToMessageCollection( + messageCollection: messageCollection, + baseChannel: messageCollection.baseChannel, + eventSource: CollectionEventSource.eventMessageDeleted, + sendingStatus: SendingStatus.failed, + deletedMessageIds: + failedMessages.map((message) => message.rootId).toList(), + ); + break; + } + } + } + } + + Future removeAllPendingMessages({ + required ChannelType channelType, + required String channelUrl, + }) async { + if (isEnabled()) { + await _db.removeAllPendingMessages( + channelType: channelType, + channelUrl: channelUrl, + ); + } + } + + Future> getStartingPointMessages({ + required ChannelType channelType, + required String channelUrl, + required int timestamp, + }) async { + if (isEnabled()) { + return await _db.getStartingPointMessages( + channelType, channelUrl, timestamp); + } + return []; + } + + Future deleteMessagesInDeletedChannel(String channelUrl) async { + if (isEnabled()) { + // MessageChunk + await _db.deleteMessageChunk(channelUrl); + + // Message + await _db.deleteMessages(channelUrl); + } + } + + Future deleteMessages(BaseChannel channel, List rootIds) async { + if (isEnabled()) { + // Message + if (channel is GroupChannel) { + for (final rootId in rootIds) { + await _db.deleteUserMessage(rootId); + await _db.deleteFileMessage(rootId); + await _db.deleteAdminMessage(rootId); + } + } else if (channel is FeedChannel) { + for (final rootId in rootIds) { + await _db.deleteNotificationMessage(rootId); + } + } + } + } + + Future deleteUserMessage(UserMessage message) async { + if (isEnabled()) { + await _db.deleteUserMessage(message.rootId); + } + } + + Future deleteFileMessage(FileMessage message) async { + if (isEnabled()) { + await _db.deleteFileMessage(message.rootId); + } + } + + // MessageChunk + Future upsertMessagesInChunk({ + required String channelUrl, + required List messages, + }) async { + if (messages.isEmpty) { + return; + } + + if (isEnabled()) { + int oldestTs = messages.first.createdAt; + int latestTs = messages.first.createdAt; + for (final message in messages) { + if (message.createdAt < oldestTs) { + oldestTs = message.createdAt; + } + if (message.createdAt > latestTs) { + latestTs = message.createdAt; + } + } + final Chunk newChunk = Chunk(oldestTs: oldestTs, latestTs: latestTs); + + final messageChunk = await _db.getMessageChunk(channelUrl); + if (messageChunk != null) { + messageChunk.addNewChunk(newChunk); + await _db.upsertMessageChunk(messageChunk); + } else { + await _db.upsertMessageChunk( + MessageChunk(channelUrl: channelUrl, chunks: [newChunk]), + ); + } + } + } + + Future getMessageChunk(String channelUrl) async { + if (isEnabled()) { + return await _db.getMessageChunk(channelUrl); + } + return null; + } + + Future deleteMessagesInChunk({ + required String channelUrl, + required List rootIds, + }) async { + if (isEnabled()) { + await _db.deleteMessagesInChunk(channelUrl: channelUrl, rootIds: rootIds); + } + } + + // ChannelInfo + Future upsertChannelInfo(ChannelInfo info) async { + await _db.upsertChannelInfo(info); + } + + Future getChannelInfo() async { + return await _db.getChannelInfo(); + } + + // MessageChangeLogInfo + Future upsertMessageChangeLogInfo(MessageChangeLogInfo info) async { + await _db.upsertMessageChangeLogInfo(info); + } + + Future getMessageChangeLogInfo( + String channelUrl) async { + return await _db.getMessageChangeLogInfo(channelUrl); + } + + // Cache Hit or Miss + Future isCacheHit({ + required BaseMessageCollection collection, + required MessageListParams params, + required List localMessages, + required int? lastSyncedTimeStamp, + required MessageCollectionLoadType loadType, + }) async { + bool isCacheHit = true; + String cause = ''; + + try { + // Check local message count + switch (loadType) { + case MessageCollectionLoadType.initialize: + // Can not be CacheHit from initialize. + return false; + // int startingPointMessageCount = 0; + // if (params.inclusive) { + // for (final message in localMessages) { + // if (message.createdAt == collection.startingPoint) { + // startingPointMessageCount++; + // } + // } + // } + // + // // We may get the correct hasNext from server. + // if (params.previousResultSize + params.nextResultSize != + // localMessages.length - startingPointMessageCount) { + // isCacheHit = false; // ResultSize is not same queried cache count. + // cause = 'Insufficient local message count'; + // } + // break; + case MessageCollectionLoadType.loadPrevious: + // Server does not support hasPrevious. + if (params.previousResultSize != localMessages.length) { + isCacheHit = false; // ResultSize is not same queried cache count. + cause = 'Insufficient local message count'; + } + break; + case MessageCollectionLoadType.loadNext: + // We may get the correct hasNext from server. + if (params.nextResultSize != localMessages.length) { + isCacheHit = false; // ResultSize is not same queried cache count. + cause = 'Insufficient local message count'; + } + break; + } + + // Check params + if (isCacheHit) { + if (params.replyType != null) { + isCacheHit = false; // This can not be queried in local. + cause = 'params.replyType is not null'; + } else if (params.showSubChannelMessagesOnly) { + isCacheHit = false; // This can not be queried in local. + cause = 'params.showSubChannelMessagesOnly is true'; + } + } + + if (isCacheHit) { + // Check if the localMessages in chunk. + final messageChunk = + await _db.getMessageChunk(collection.baseChannel.channelUrl); + if (messageChunk != null) { + int oldestTs = localMessages.first.createdAt; + int latestTs = localMessages.first.createdAt; + for (final message in localMessages) { + if (message.createdAt < oldestTs) { + oldestTs = message.createdAt; + } + if (message.createdAt > latestTs) { + latestTs = message.createdAt; + } + } + + final isInCurrentChunk = messageChunk.isInCurrentChunk( + oldestTs: oldestTs, + latestTs: latestTs, + lastSyncedTimeStamp: lastSyncedTimeStamp, + ); + + if (isInCurrentChunk) { + isCacheHit = true; + } else { + isCacheHit = false; + cause = 'Not contained in current chunk'; + } + } else { + isCacheHit = false; + cause = 'Not contained in current chunk'; + } + } + } catch (e) { + sbLog.e(StackTrace.current, e.toString()); + isCacheHit = false; + cause = e.toString(); + } + + // LocalCacheEvent Stat + _appendLocalCacheEventStat( + channelUrl: collection.baseChannel.channelUrl, + startingPoint: collection.startingPoint, + measuredOn: _getMeasuredOn(loadType), + event: isCacheHit ? LocalCacheEvent.cacheHit : LocalCacheEvent.cacheMiss, + maxDbSize: _maxDBFileSize, + messageInitPolicy: 'cache_and_replace_by_api', + useLocalCache: SendbirdChat.getOptions().useCollectionCaching, + collectionId: collection.collectionId, + ); + + sbLog.d(StackTrace.current, + '[${loadType.asString()}] ${isCacheHit ? '[HIT]' : '[MISS]($cause)'}'); + return isCacheHit; + } + + LocalCacheEventMeasuredOn _getMeasuredOn(MessageCollectionLoadType loadType) { + switch (loadType) { + case MessageCollectionLoadType.initialize: + return LocalCacheEventMeasuredOn.initialLoad; + case MessageCollectionLoadType.loadPrevious: + return LocalCacheEventMeasuredOn.loadPrev; + case MessageCollectionLoadType.loadNext: + return LocalCacheEventMeasuredOn.loadNext; + } + } + + void _appendLocalCacheEventStat({ + required String channelUrl, + required int startingPoint, + required LocalCacheEventMeasuredOn measuredOn, + required LocalCacheEvent event, + required int maxDbSize, + required String messageInitPolicy, + required bool useLocalCache, + required String collectionId, + }) { + final Map data = { + 'channel_url': channelUrl, + 'starting_point': startingPoint, + 'measured_on': StatUtils.getLocalCacheEventMeasuredOnString(measuredOn), + 'event': StatUtils.getLocalCacheEventString(event), + 'max_db_size': maxDbSize, + 'message_init_policy': messageInitPolicy, + 'use_local_cache': useLocalCache, + 'collection_id': collectionId, + }; + SendbirdStatistics.appendStat( + type: 'feature:local_cache_event', + data: data, + ); + } + + void appendLocalCacheStat({ + required bool useLocalCache, + bool? useGroupChannelCollection, + bool? useMessageCollection, + }) { + final Map data = { + 'use_local_cache': useLocalCache, + }; + + if (useGroupChannelCollection != null || useMessageCollection != null) { + data['collection_interface'] = {}; + + if (useGroupChannelCollection != null) { + data['collection_interface']['group_channel'] = + useGroupChannelCollection; + } + + if (useMessageCollection != null) { + data['collection_interface']['message'] = useMessageCollection; + } + } + + SendbirdStatistics.appendStat( + type: 'feature:local_cache', + data: data, + ); + } +} + +enum MessageCollectionLoadType { + initialize, + loadPrevious, + loadNext, +} diff --git a/lib/src/internal/main/connection_state/connected_state.dart b/lib/src/internal/main/connection_state/connected_state.dart index 0160792f..c4c3a908 100644 --- a/lib/src/internal/main/connection_state/connected_state.dart +++ b/lib/src/internal/main/connection_state/connected_state.dart @@ -26,7 +26,7 @@ class ConnectedState extends BaseConnectionState { return chat.chatContext.currentUser!; } - await chat.connectionManager.doDisconnect(logout: true); + await chat.connectionManager.doDisconnect(clear: true); return await chat.connectionManager.doConnect( userId, nickname: nickname, @@ -39,7 +39,7 @@ class ConnectedState extends BaseConnectionState { @override Future disconnect({required logout}) async { sbLog.i(StackTrace.current); - await chat.connectionManager.doDisconnect(logout: logout); + await chat.connectionManager.doDisconnect(clear: logout, logout: logout); } @override @@ -51,7 +51,7 @@ class ConnectedState extends BaseConnectionState { @override Future enterBackground() async { sbLog.i(StackTrace.current); - await chat.connectionManager.doDisconnect(logout: false); + await chat.connectionManager.doDisconnect(clear: false); } @override diff --git a/lib/src/internal/main/connection_state/connecting_state.dart b/lib/src/internal/main/connection_state/connecting_state.dart index 4545aee2..aaee3d4d 100644 --- a/lib/src/internal/main/connection_state/connecting_state.dart +++ b/lib/src/internal/main/connection_state/connecting_state.dart @@ -27,7 +27,7 @@ class ConnectingState extends BaseConnectionState { return chat.chatContext.loginCompleter!.future; } - await chat.connectionManager.doDisconnect(logout: true); + await chat.connectionManager.doDisconnect(clear: true); return await chat.connectionManager.doConnect( userId, nickname: nickname, @@ -40,7 +40,7 @@ class ConnectingState extends BaseConnectionState { @override Future disconnect({required logout}) async { sbLog.i(StackTrace.current); - await chat.connectionManager.doDisconnect(logout: logout); + await chat.connectionManager.doDisconnect(clear: logout, logout: logout); } @override @@ -52,7 +52,7 @@ class ConnectingState extends BaseConnectionState { @override Future enterBackground() async { sbLog.i(StackTrace.current); - await chat.connectionManager.doDisconnect(logout: false); + await chat.connectionManager.doDisconnect(clear: false); } @override diff --git a/lib/src/internal/main/connection_state/disconnected_state.dart b/lib/src/internal/main/connection_state/disconnected_state.dart index 5100834f..9b867b11 100644 --- a/lib/src/internal/main/connection_state/disconnected_state.dart +++ b/lib/src/internal/main/connection_state/disconnected_state.dart @@ -39,7 +39,7 @@ class DisconnectedState extends BaseConnectionState { @override Future disconnect({required logout}) async { sbLog.i(StackTrace.current); - await chat.connectionManager.doDisconnect(logout: logout); + await chat.connectionManager.doDisconnect(clear: logout, logout: logout); } @override @@ -51,7 +51,7 @@ class DisconnectedState extends BaseConnectionState { @override Future enterBackground() async { sbLog.i(StackTrace.current); - await chat.connectionManager.doDisconnect(logout: false); + await chat.connectionManager.doDisconnect(clear: false); } @override diff --git a/lib/src/internal/main/connection_state/reconnecting_state.dart b/lib/src/internal/main/connection_state/reconnecting_state.dart index 1fa138bf..c2ddda86 100644 --- a/lib/src/internal/main/connection_state/reconnecting_state.dart +++ b/lib/src/internal/main/connection_state/reconnecting_state.dart @@ -25,7 +25,7 @@ class ReconnectingState extends BaseConnectionState { return chat.chatContext.loginCompleter!.future; } - await chat.connectionManager.doDisconnect(logout: true); + await chat.connectionManager.doDisconnect(clear: true); return await chat.connectionManager.doConnect( userId, nickname: nickname, @@ -38,7 +38,7 @@ class ReconnectingState extends BaseConnectionState { @override Future disconnect({required logout}) async { sbLog.i(StackTrace.current); - await chat.connectionManager.doDisconnect(logout: logout); + await chat.connectionManager.doDisconnect(clear: logout, logout: logout); } @override @@ -50,7 +50,7 @@ class ReconnectingState extends BaseConnectionState { @override Future enterBackground() async { sbLog.i(StackTrace.current); - await chat.connectionManager.doDisconnect(logout: false); + await chat.connectionManager.doDisconnect(clear: false); } @override diff --git a/lib/src/internal/main/extensions/extensions.dart b/lib/src/internal/main/extensions/extensions.dart index 052ed795..94ad160c 100644 --- a/lib/src/internal/main/extensions/extensions.dart +++ b/lib/src/internal/main/extensions/extensions.dart @@ -1,18 +1,11 @@ // Copyright (c) 2023 Sendbird, Inc. All rights reserved. -import 'package:flutter/foundation.dart'; import 'package:sendbird_chat_sdk/src/public/main/define/enums.dart'; extension ObjectAsString on Object { String asString() => toString().split('.').last; } -extension IntMax on int { - static int get max { - return kIsWeb ? 9007199254740991.round() : 1.7976931348623157e+308.round(); - } -} - extension ChannelTypeUrlString on ChannelType { String get urlString { switch (this) { diff --git a/lib/src/internal/main/stats/daily_record_stat_prefs.dart b/lib/src/internal/main/stats/daily_record_stat_prefs.dart new file mode 100644 index 00000000..c291c886 --- /dev/null +++ b/lib/src/internal/main/stats/daily_record_stat_prefs.dart @@ -0,0 +1,166 @@ +// Copyright (c) 2023 Sendbird, Inc. All rights reserved. + +import 'dart:convert'; + +import 'package:collection/collection.dart'; +import 'package:sendbird_chat_sdk/src/internal/main/logger/sendbird_logger.dart'; +import 'package:sendbird_chat_sdk/src/internal/main/stats/model/daily_record/daily_record_stat.dart'; +import 'package:sendbird_chat_sdk/src/internal/main/stats/model/daily_record/local_cache_stat.dart'; +import 'package:sendbird_chat_sdk/src/internal/main/stats/stat_type.dart'; +import 'package:sendbird_chat_sdk/src/internal/main/stats/stat_utils.dart'; +import 'package:shared_preferences/shared_preferences.dart'; + +class DailyRecordStatPrefs { + final deleted = 'deleted'; + + SharedPreferences? _sharedPreferences; + + Future get _prefs async { + _sharedPreferences ??= await SharedPreferences.getInstance(); + return _sharedPreferences!; + } + + Future> get stats async { + sbLog.d(StackTrace.current); + + final prefs = (await _prefs); + final dailyRecordStats = prefs + .getKeys() + .map((key) { + if (key.contains(DailyRecordStat.keyPrefix)) { + final json = prefs.getString(key); + if (json != null && json.isNotEmpty) { + return _getDailyRecordStat(json); + } + return null; + } + }) + .whereNotNull() + .toList(); + + return dailyRecordStats; + } + + Future> get uploadCandidateStats async { + sbLog.d(StackTrace.current); + + final prefs = (await _prefs); + final now = DateTime.now().millisecondsSinceEpoch; + final todayDateString = DailyRecordStat.getDateString(now); + final dailyRecordStats = prefs + .getKeys() + .map((key) { + if (key.contains(DailyRecordStat.keyPrefix) && + key.contains(todayDateString) == false) { + final json = prefs.getString(key); + if (json != null && json.isNotEmpty) { + return _getDailyRecordStat(json); + } + } + return null; + }) + .whereNotNull() + .toList(); + + return dailyRecordStats; + } + + Future get uploadCandidateStatCount async { + sbLog.d(StackTrace.current); + + final prefs = (await _prefs); + final now = DateTime.now().millisecondsSinceEpoch; + final todayDateString = DailyRecordStat.getDateString(now); + final count = prefs + .getKeys() + .where((key) => (key.contains(DailyRecordStat.keyPrefix) && + key.contains(todayDateString) == false)) + .length; + + return count; + } + + DailyRecordStat? _getDailyRecordStat(String json) { + if (json == deleted) return null; + + Map stat = jsonDecode(json); + final type = stat['stat_type'] as String; + final ts = stat['ts'] as int; + final data = stat['data'] as Map; + final statType = StatUtils.getStatType(type); + + if (statType != null) { + switch (statType) { + case StatType.apiResult: + return null; + case StatType.wsConnect: + return null; + case StatType.featureLocalCache: + return LocalCacheStat.fromJson(ts: ts, data: data); + case StatType.featureLocalCacheEvent: + return null; + case StatType.notificationStats: + return null; + } + } + return null; + } + + Future upsert(DailyRecordStat stat) async { + sbLog.d(StackTrace.current); + + final prefs = (await _prefs); + final json = prefs.getString(stat.key); + + if (json != null && json.isNotEmpty) { + if (json == deleted) return; + + final newStat = _getDailyRecordStat(json); + if (newStat != null) { + newStat.update(stat); + await prefs.setString(newStat.key, jsonEncode(newStat)); + } + } else { + await prefs.setString(stat.key, jsonEncode(stat)); + } + } + + Future remove(List stats) async { + sbLog.d(StackTrace.current); + + final prefs = (await _prefs); + for (final stat in stats) { + await prefs.setString(stat.key, deleted); + } + } + + Future clearDisallowedStats(Set allowedStatTypes) async { + sbLog.d(StackTrace.current); + + final prefs = (await _prefs); + for (final key in prefs.getKeys()) { + if (key.contains(DailyRecordStat.keyPrefix)) { + final json = prefs.getString(key); + if (json != null && json.isNotEmpty) { + final dailyRecordStat = _getDailyRecordStat(json); + if (dailyRecordStat != null) { + if (allowedStatTypes.contains(dailyRecordStat.type) == false) { + await prefs.remove(key); + } + } + } + } + } + } + + Future clearAll() async { + sbLog.d(StackTrace.current); + + final prefs = (await _prefs); + for (final key in prefs.getKeys()) { + if (key.contains(DailyRecordStat.keyPrefix)) { + await prefs.remove(key); + } + } + } +} diff --git a/lib/src/internal/main/stats/default_stat_prefs.dart b/lib/src/internal/main/stats/default_stat_prefs.dart index 8982ba65..cc33a8fa 100644 --- a/lib/src/internal/main/stats/default_stat_prefs.dart +++ b/lib/src/internal/main/stats/default_stat_prefs.dart @@ -4,12 +4,13 @@ import 'dart:convert'; import 'package:collection/collection.dart'; import 'package:sendbird_chat_sdk/src/internal/main/logger/sendbird_logger.dart'; -import 'package:sendbird_chat_sdk/src/internal/main/stats/api_result_stat.dart'; -import 'package:sendbird_chat_sdk/src/internal/main/stats/default_stat.dart'; -import 'package:sendbird_chat_sdk/src/internal/main/stats/notification_stat.dart'; +import 'package:sendbird_chat_sdk/src/internal/main/stats/model/default/api_result_stat.dart'; +import 'package:sendbird_chat_sdk/src/internal/main/stats/model/default/default_stat.dart'; +import 'package:sendbird_chat_sdk/src/internal/main/stats/model/default/local_cache_event_stat.dart'; +import 'package:sendbird_chat_sdk/src/internal/main/stats/model/default/notification_stat.dart'; import 'package:sendbird_chat_sdk/src/internal/main/stats/stat_type.dart'; import 'package:sendbird_chat_sdk/src/internal/main/stats/stat_utils.dart'; -import 'package:sendbird_chat_sdk/src/internal/main/stats/ws_connect_stat.dart'; +import 'package:sendbird_chat_sdk/src/internal/main/stats/model/default/ws_connect_stat.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:uuid/uuid.dart'; @@ -86,6 +87,8 @@ class DefaultStatPrefs { return WsConnectStat.fromJson(ts: ts, data: data); case StatType.featureLocalCache: return null; + case StatType.featureLocalCacheEvent: + return LocalCacheEventStat.fromJson(ts: ts, data: data); case StatType.notificationStats: return NotificationStat.fromJson(ts: ts, data: data); } diff --git a/lib/src/internal/main/stats/base_stat.dart b/lib/src/internal/main/stats/model/base_stat.dart similarity index 100% rename from lib/src/internal/main/stats/base_stat.dart rename to lib/src/internal/main/stats/model/base_stat.dart diff --git a/lib/src/internal/main/stats/model/daily_record/daily_record_stat.dart b/lib/src/internal/main/stats/model/daily_record/daily_record_stat.dart new file mode 100644 index 00000000..30574ccd --- /dev/null +++ b/lib/src/internal/main/stats/model/daily_record/daily_record_stat.dart @@ -0,0 +1,34 @@ +// Copyright (c) 2023 Sendbird, Inc. All rights reserved. + +import 'package:sendbird_chat_sdk/src/internal/main/stats/model/base_stat.dart'; +import 'package:sendbird_chat_sdk/src/internal/main/stats/stat_type.dart'; +import 'package:sendbird_chat_sdk/src/internal/main/stats/stat_utils.dart'; + +abstract class DailyRecordStat extends BaseStat { + DailyRecordStat(StatType type, int ts) : super(type, ts); + + void update(DailyRecordStat stat); + + static const keyPrefix = 'daily_record'; + + String get key => + '${keyPrefix}_${getDateString(ts)}_${StatUtils.getStatTypeString(type)}'; + + static String getDateString(int ts) { + String dateString; + try { + final date = DateTime.fromMillisecondsSinceEpoch(ts); + String year = date.year.toString(); + String month = date.month.toString(); + String day = date.day.toString(); + + if (month.length == 1) month = '0$month'; + if (day.length == 1) day = '0$day'; + + dateString = '$year$month$day'; + } catch (_) { + dateString = ''; + } + return dateString; + } +} diff --git a/lib/src/internal/main/stats/model/daily_record/local_cache_stat.dart b/lib/src/internal/main/stats/model/daily_record/local_cache_stat.dart new file mode 100644 index 00000000..4e79de3f --- /dev/null +++ b/lib/src/internal/main/stats/model/daily_record/local_cache_stat.dart @@ -0,0 +1,108 @@ +// Copyright (c) 2023 Sendbird, Inc. All rights reserved. + +import 'package:sendbird_chat_sdk/src/internal/main/logger/sendbird_logger.dart'; +import 'package:sendbird_chat_sdk/src/internal/main/stats/model/daily_record/daily_record_stat.dart'; +import 'package:sendbird_chat_sdk/src/internal/main/stats/stat_type.dart'; + +class CollectionInterfaceStat { + bool? useGroupChannelCollection; + bool? useMessageCollection; +} + +class LocalCacheStat extends DailyRecordStat { + bool useLocalCache; + CollectionInterfaceStat? collectionInterfaceStat; + + LocalCacheStat({ + required int ts, + required this.useLocalCache, + this.collectionInterfaceStat, + }) : super(StatType.featureLocalCache, ts); + + @override + Map toJson() { + final json = { + 'use_local_cache': useLocalCache, + }; + + if (collectionInterfaceStat != null) { + json['collection_interface'] = { + if (collectionInterfaceStat?.useGroupChannelCollection != null) + 'group_channel': collectionInterfaceStat?.useGroupChannelCollection, + if (collectionInterfaceStat?.useMessageCollection != null) + 'message': collectionInterfaceStat?.useMessageCollection, + }; + } + + final result = super.toJson(); + result['data'] = json; + return result; + } + + // { + // 'stat_type' : 'feature:local_cache', + // 'ts': int, // timestamp for log creation, + // 'data' : { + // 'use_local_cache': bool + // 'collection_interface' : { // optional + // 'group_channel': bool?, + // 'message': bool?, + // 'message_init_policy': String?, // 'cache_and_replace_by_api' + // }, + // }, + // } + static LocalCacheStat? fromJson({ + required int ts, + required Map data, + }) { + try { + final bool? useLocalCache = data['use_local_cache'] as bool?; + + CollectionInterfaceStat? collectionInterfaceStat; + final collectionInterfaceStatMap = data['collection_interface']; + if (collectionInterfaceStatMap != null) { + collectionInterfaceStat = CollectionInterfaceStat(); + collectionInterfaceStat.useGroupChannelCollection = + collectionInterfaceStatMap['group_channel'] as bool?; + collectionInterfaceStat.useMessageCollection = + collectionInterfaceStatMap['message'] as bool?; + } + + if (useLocalCache == null) { + return null; + } + + return LocalCacheStat( + ts: ts, + useLocalCache: useLocalCache, + collectionInterfaceStat: collectionInterfaceStat, + ); + } catch (e) { + sbLog.d(StackTrace.current, 'e: ${e.toString()}'); + } + return null; + } + + @override + void update(DailyRecordStat stat) { + if (stat is! LocalCacheStat) { + return; + } + + useLocalCache = stat.useLocalCache; + + if (collectionInterfaceStat == null && + stat.collectionInterfaceStat == null) { + return; + } + + collectionInterfaceStat ??= CollectionInterfaceStat(); + + collectionInterfaceStat!.useGroupChannelCollection = + stat.collectionInterfaceStat?.useGroupChannelCollection ?? + collectionInterfaceStat?.useGroupChannelCollection; + collectionInterfaceStat!.useMessageCollection = + stat.collectionInterfaceStat?.useMessageCollection ?? + collectionInterfaceStat?.useMessageCollection; + } +} diff --git a/lib/src/internal/main/stats/api_result_stat.dart b/lib/src/internal/main/stats/model/default/api_result_stat.dart similarity index 96% rename from lib/src/internal/main/stats/api_result_stat.dart rename to lib/src/internal/main/stats/model/default/api_result_stat.dart index 583c6ffd..2a513174 100644 --- a/lib/src/internal/main/stats/api_result_stat.dart +++ b/lib/src/internal/main/stats/model/default/api_result_stat.dart @@ -1,7 +1,7 @@ // Copyright (c) 2023 Sendbird, Inc. All rights reserved. import 'package:sendbird_chat_sdk/src/internal/main/logger/sendbird_logger.dart'; -import 'package:sendbird_chat_sdk/src/internal/main/stats/default_stat.dart'; +import 'package:sendbird_chat_sdk/src/internal/main/stats/model/default/default_stat.dart'; import 'package:sendbird_chat_sdk/src/internal/main/stats/stat_type.dart'; class ApiResultStat extends DefaultStat { diff --git a/lib/src/internal/main/stats/default_stat.dart b/lib/src/internal/main/stats/model/default/default_stat.dart similarity index 73% rename from lib/src/internal/main/stats/default_stat.dart rename to lib/src/internal/main/stats/model/default/default_stat.dart index 68e92caf..a8d12925 100644 --- a/lib/src/internal/main/stats/default_stat.dart +++ b/lib/src/internal/main/stats/model/default/default_stat.dart @@ -1,6 +1,6 @@ // Copyright (c) 2023 Sendbird, Inc. All rights reserved. -import 'package:sendbird_chat_sdk/src/internal/main/stats/base_stat.dart'; +import 'package:sendbird_chat_sdk/src/internal/main/stats/model/base_stat.dart'; import 'package:sendbird_chat_sdk/src/internal/main/stats/stat_type.dart'; class DefaultStat extends BaseStat { diff --git a/lib/src/internal/main/stats/model/default/local_cache_event_stat.dart b/lib/src/internal/main/stats/model/default/local_cache_event_stat.dart new file mode 100644 index 00000000..2ff3ad0c --- /dev/null +++ b/lib/src/internal/main/stats/model/default/local_cache_event_stat.dart @@ -0,0 +1,120 @@ +// Copyright (c) 2023 Sendbird, Inc. All rights reserved. + +import 'package:sendbird_chat_sdk/src/internal/main/logger/sendbird_logger.dart'; +import 'package:sendbird_chat_sdk/src/internal/main/stats/model/default/default_stat.dart'; +import 'package:sendbird_chat_sdk/src/internal/main/stats/stat_type.dart'; +import 'package:sendbird_chat_sdk/src/internal/main/stats/stat_utils.dart'; + +class LocalCacheEventStat extends DefaultStat { + final String channelUrl; + final int startingPoint; + final LocalCacheEventMeasuredOn measuredOn; + final LocalCacheEvent event; + final int maxDbSize; + final String messageInitPolicy; // always 'cache_and_replace_by_api' + final bool useLocalCache; // always true + final String collectionId; + + LocalCacheEventStat({ + required int ts, + required this.channelUrl, + required this.startingPoint, + required this.measuredOn, + required this.event, + required this.maxDbSize, + required this.messageInitPolicy, + required this.useLocalCache, + required this.collectionId, + }) : super(StatType.featureLocalCacheEvent, ts); + + @override + Map toJson() { + final json = { + 'channel_url': channelUrl, + 'starting_point': startingPoint, + 'measured_on': StatUtils.getLocalCacheEventMeasuredOnString(measuredOn), + 'event': StatUtils.getLocalCacheEventString(event), + 'max_db_size': maxDbSize, + 'message_init_policy': messageInitPolicy, + 'use_local_cache': useLocalCache, + 'collection_id': collectionId, + }; + final result = super.toJson(); + result['data'] = json; + return result; + } + + // { + // 'stat_type': 'feature:local_cache_event', + // 'ts': DEVICE_TIMESTAMP, + // 'data': { + // 'channel_url': CHANNEL_URL, + // 'starting_point': STARTING_POINT, + // 'measured_on': 'initial_load'/'load_next'/'load_prev'/'gap_check'/'back_sync' + // 'event': 'cache_miss'/'cache_hit'/'cache_fetch', + // 'max_db_size': MAX_DB_SIZE in MB, + // 'message_init_policy': 'cache_and_replace_by_api', + // 'use_local_cache': true/false, + // 'collection_id': RANDOM_COLLECTION_ID_STRING, // value used internally + // } + // } + static LocalCacheEventStat? fromJson({ + required int ts, + required Map data, + }) { + try { + final String? channelUrl = data['channel_url'] as String?; + final int? startingPoint = data['starting_point'] as int?; + final String? measuredOnString = data['measured_on'] as String?; + final String? eventString = data['event'] as String?; + final int? maxDbSize = data['max_db_size'] as int?; + final String? messageInitPolicy = data['message_init_policy'] as String?; + final bool? useLocalCache = data['use_local_cache'] as bool?; + final String? collectionId = data['collection_id'] as String?; + + final measuredOn = measuredOnString != null + ? StatUtils.getLocalCacheEventMeasuredOn(measuredOnString) + : null; + final event = eventString != null + ? StatUtils.getLocalCacheEvent(eventString) + : null; + + if (channelUrl == null || + startingPoint == null || + measuredOn == null || + event == null || + maxDbSize == null || + messageInitPolicy == null || + useLocalCache == null || + collectionId == null) { + return null; + } + + return LocalCacheEventStat( + ts: ts, + channelUrl: channelUrl, + startingPoint: startingPoint, + measuredOn: measuredOn, + event: event, + maxDbSize: maxDbSize, + messageInitPolicy: messageInitPolicy, + useLocalCache: useLocalCache, + collectionId: collectionId, + ); + } catch (e) { + sbLog.d(StackTrace.current, 'e: ${e.toString()}'); + } + return null; + } +} + +enum LocalCacheEventMeasuredOn { + initialLoad, + loadPrev, + loadNext, +} + +enum LocalCacheEvent { + cacheMiss, + cacheHit, +} diff --git a/lib/src/internal/main/stats/notification_stat.dart b/lib/src/internal/main/stats/model/default/notification_stat.dart similarity index 96% rename from lib/src/internal/main/stats/notification_stat.dart rename to lib/src/internal/main/stats/model/default/notification_stat.dart index ab22bf99..ef182ebf 100644 --- a/lib/src/internal/main/stats/notification_stat.dart +++ b/lib/src/internal/main/stats/model/default/notification_stat.dart @@ -1,7 +1,7 @@ // Copyright (c) 2023 Sendbird, Inc. All rights reserved. import 'package:sendbird_chat_sdk/src/internal/main/logger/sendbird_logger.dart'; -import 'package:sendbird_chat_sdk/src/internal/main/stats/default_stat.dart'; +import 'package:sendbird_chat_sdk/src/internal/main/stats/model/default/default_stat.dart'; import 'package:sendbird_chat_sdk/src/internal/main/stats/stat_type.dart'; class NotificationStat extends DefaultStat { diff --git a/lib/src/internal/main/stats/ws_connect_stat.dart b/lib/src/internal/main/stats/model/default/ws_connect_stat.dart similarity index 95% rename from lib/src/internal/main/stats/ws_connect_stat.dart rename to lib/src/internal/main/stats/model/default/ws_connect_stat.dart index f3da3eeb..80638a4c 100644 --- a/lib/src/internal/main/stats/ws_connect_stat.dart +++ b/lib/src/internal/main/stats/model/default/ws_connect_stat.dart @@ -1,7 +1,7 @@ // Copyright (c) 2023 Sendbird, Inc. All rights reserved. import 'package:sendbird_chat_sdk/src/internal/main/logger/sendbird_logger.dart'; -import 'package:sendbird_chat_sdk/src/internal/main/stats/default_stat.dart'; +import 'package:sendbird_chat_sdk/src/internal/main/stats/model/default/default_stat.dart'; import 'package:sendbird_chat_sdk/src/internal/main/stats/stat_type.dart'; class WsConnectStat extends DefaultStat { diff --git a/lib/src/internal/main/stats/stat_manager.dart b/lib/src/internal/main/stats/stat_manager.dart index 82e242aa..11c1465a 100644 --- a/lib/src/internal/main/stats/stat_manager.dart +++ b/lib/src/internal/main/stats/stat_manager.dart @@ -3,15 +3,19 @@ import 'package:collection/collection.dart'; import 'package:sendbird_chat_sdk/src/internal/main/chat/chat.dart'; import 'package:sendbird_chat_sdk/src/internal/main/logger/sendbird_logger.dart'; -import 'package:sendbird_chat_sdk/src/internal/main/stats/api_result_stat.dart'; -import 'package:sendbird_chat_sdk/src/internal/main/stats/base_stat.dart'; -import 'package:sendbird_chat_sdk/src/internal/main/stats/default_stat.dart'; +import 'package:sendbird_chat_sdk/src/internal/main/stats/daily_record_stat_prefs.dart'; import 'package:sendbird_chat_sdk/src/internal/main/stats/default_stat_prefs.dart'; -import 'package:sendbird_chat_sdk/src/internal/main/stats/notification_stat.dart'; +import 'package:sendbird_chat_sdk/src/internal/main/stats/model/base_stat.dart'; +import 'package:sendbird_chat_sdk/src/internal/main/stats/model/daily_record/daily_record_stat.dart'; +import 'package:sendbird_chat_sdk/src/internal/main/stats/model/daily_record/local_cache_stat.dart'; +import 'package:sendbird_chat_sdk/src/internal/main/stats/model/default/api_result_stat.dart'; +import 'package:sendbird_chat_sdk/src/internal/main/stats/model/default/default_stat.dart'; +import 'package:sendbird_chat_sdk/src/internal/main/stats/model/default/local_cache_event_stat.dart'; +import 'package:sendbird_chat_sdk/src/internal/main/stats/model/default/notification_stat.dart'; +import 'package:sendbird_chat_sdk/src/internal/main/stats/model/default/ws_connect_stat.dart'; import 'package:sendbird_chat_sdk/src/internal/main/stats/stat_state.dart'; import 'package:sendbird_chat_sdk/src/internal/main/stats/stat_type.dart'; import 'package:sendbird_chat_sdk/src/internal/main/stats/stat_utils.dart'; -import 'package:sendbird_chat_sdk/src/internal/main/stats/ws_connect_stat.dart'; import 'package:sendbird_chat_sdk/src/internal/main/utils/json_converter.dart'; import 'package:sendbird_chat_sdk/src/internal/network/http/http_client/request/main/upload_stat_request.dart'; import 'package:sendbird_chat_sdk/src/internal/network/websocket/event/login_event.dart'; @@ -20,7 +24,10 @@ import 'package:sendbird_chat_sdk/src/public/main/define/exceptions.dart'; class StatManager { static const Map> _sdkStatsAttributeTable = { 'allow_sdk_request_log_publish': {StatType.apiResult, StatType.wsConnect}, - 'allow_sdk_feature_local_cache_log_publish': {StatType.featureLocalCache}, + 'allow_sdk_feature_local_cache_log_publish': { + StatType.featureLocalCache, + StatType.featureLocalCacheEvent, + }, 'allow_sdk_noti_stats_log_publish': {StatType.notificationStats}, }; static const int _errStatUploadNotAllowed = 403200; @@ -56,6 +63,7 @@ class StatManager { final List pendingDefaultStats = []; final List cachedDefaultStats = []; final DefaultStatPrefs defaultStatPrefs; + final DailyRecordStatPrefs dailyRecordStatPrefs; bool _isFlushing = false; @@ -64,7 +72,8 @@ class StatManager { StatManager({required Chat chat}) : _chat = chat, - defaultStatPrefs = DefaultStatPrefs(); + defaultStatPrefs = DefaultStatPrefs(), + dailyRecordStatPrefs = DailyRecordStatPrefs(); //+ Public Future appendStat({ @@ -110,7 +119,15 @@ class StatManager { data: data, ); case StatType.featureLocalCache: - return null; + return LocalCacheStat.fromJson( + ts: DateTime.now().millisecondsSinceEpoch, + data: data, + ); + case StatType.featureLocalCacheEvent: + return LocalCacheEventStat.fromJson( + ts: DateTime.now().millisecondsSinceEpoch, + data: data, + ); case StatType.notificationStats: return NotificationStat.fromJson( ts: DateTime.now().millisecondsSinceEpoch, @@ -150,6 +167,9 @@ class StatManager { ' stat: \n${jsonEncoder.convert(stat.toJson())}'); result = true; + } else if (stat is DailyRecordStat) { + await dailyRecordStatPrefs.upsert(stat); + result = true; } break; case StatState.enabled: @@ -166,6 +186,11 @@ class StatManager { ' defaultStatPrefs: ${await defaultStatPrefs.statCount},' ' stat: \n${jsonEncoder.convert(stat.toJson())}'); + await _checkToSendStats(stat); + result = true; + } else if (stat is DailyRecordStat) { + await dailyRecordStatPrefs.upsert(stat); + await _checkToSendStats(stat); result = true; } @@ -177,8 +202,13 @@ class StatManager { } Future _checkToSendStats(BaseStat stat) async { - final count = cachedDefaultStats.length; - sbLog.d(StackTrace.current, 'cachedDefaultStats: $count'); + final dailyRecordStatCount = + await dailyRecordStatPrefs.uploadCandidateStatCount; + final count = cachedDefaultStats.length + dailyRecordStatCount; + sbLog.d( + StackTrace.current, 'cachedDefaultStats: ${cachedDefaultStats.length}'); + sbLog.d(StackTrace.current, 'dailyRecordStatCount: $dailyRecordStatCount'); + sbLog.d(StackTrace.current, 'count: $count'); if (state == StatState.enabled && count >= _lowerThreshold) { final lastSentAt = await defaultStatPrefs.lastSentAt; @@ -211,13 +241,18 @@ class StatManager { await _clearDisallowedStats(); // Defensive code final deviceId = await defaultStatPrefs.deviceId; - final copiedStats = - cachedDefaultStats.take(_maxStatCountPerRequest).toList(); + final dailyRecordStats = (await dailyRecordStatPrefs.uploadCandidateStats) + .take(_maxStatCountPerRequest) + .toList(); + final copiedStats = cachedDefaultStats + .take(_maxStatCountPerRequest - dailyRecordStats.length) + .toList(); Object? exception; try { + final stats = [...dailyRecordStats, ...copiedStats]; await _chat.apiClient.send( - UploadStatRequest(_chat, deviceId: deviceId, stats: copiedStats), + UploadStatRequest(_chat, deviceId: deviceId, stats: stats), ); } catch (e) { if (copiedStats.length >= _minStatCount) { @@ -250,13 +285,15 @@ class StatManager { await defaultStatPrefs .updateLastSentAt(DateTime.now().millisecondsSinceEpoch); await defaultStatPrefs.putStats(remainingStats); + await dailyRecordStatPrefs.remove(dailyRecordStats); sbLog.d( StackTrace.current, '[StatTest][Sent] deviceId: $deviceId,' ' pendingDefaultStats: ${pendingDefaultStats.length},' ' cachedDefaultStats: ${cachedDefaultStats.length},' - ' defaultStatPrefs: ${await defaultStatPrefs.statCount}'); + ' defaultStatPrefs: ${await defaultStatPrefs.statCount},' + ' dailyRecordStatPrefs: ${(await dailyRecordStatPrefs.stats).length}'); } _isFlushing = false; @@ -316,6 +353,7 @@ class StatManager { cachedDefaultStats.clear(); await defaultStatPrefs.clearAll(); + await dailyRecordStatPrefs.clearAll(); } Future _checkLoginEvent(LoginEvent event) async { @@ -356,6 +394,7 @@ class StatManager { .removeWhere((stat) => allowedStatTypes.contains(stat.type) == false); await defaultStatPrefs.clearDisallowedStats(allowedStatTypes); + await dailyRecordStatPrefs.clearDisallowedStats(allowedStatTypes); } bool _isSdkStatsAllowed() { diff --git a/lib/src/internal/main/stats/stat_type.dart b/lib/src/internal/main/stats/stat_type.dart index dacc01c9..821e94cd 100644 --- a/lib/src/internal/main/stats/stat_type.dart +++ b/lib/src/internal/main/stats/stat_type.dart @@ -4,5 +4,6 @@ enum StatType { apiResult, wsConnect, featureLocalCache, + featureLocalCacheEvent, notificationStats, } diff --git a/lib/src/internal/main/stats/stat_utils.dart b/lib/src/internal/main/stats/stat_utils.dart index 86d437a1..7d3dc0d4 100644 --- a/lib/src/internal/main/stats/stat_utils.dart +++ b/lib/src/internal/main/stats/stat_utils.dart @@ -1,6 +1,7 @@ // Copyright (c) 2023 Sendbird, Inc. All rights reserved. import 'package:sendbird_chat_sdk/src/internal/main/logger/sendbird_logger.dart'; +import 'package:sendbird_chat_sdk/src/internal/main/stats/model/default/local_cache_event_stat.dart'; import 'package:sendbird_chat_sdk/src/internal/main/stats/stat_type.dart'; class StatUtils { @@ -12,6 +13,8 @@ class StatUtils { return StatType.wsConnect; case 'feature:local_cache': return StatType.featureLocalCache; + case 'feature:local_cache_event': + return StatType.featureLocalCacheEvent; case 'noti:stats': return StatType.notificationStats; } @@ -27,8 +30,56 @@ class StatUtils { return 'ws:connect'; case StatType.featureLocalCache: return 'feature:local_cache'; + case StatType.featureLocalCacheEvent: + return 'feature:local_cache_event'; case StatType.notificationStats: return 'noti:stats'; } } + + static LocalCacheEventMeasuredOn? getLocalCacheEventMeasuredOn( + String measuredOn) { + switch (measuredOn) { + case 'initial_load': + return LocalCacheEventMeasuredOn.initialLoad; + case 'load_prev': + return LocalCacheEventMeasuredOn.loadPrev; + case 'load_next': + return LocalCacheEventMeasuredOn.loadNext; + } + sbLog.w(StackTrace.current, 'return null'); + return null; + } + + static String getLocalCacheEventMeasuredOnString( + LocalCacheEventMeasuredOn measuredOn) { + switch (measuredOn) { + case LocalCacheEventMeasuredOn.initialLoad: + return 'initial_load'; + case LocalCacheEventMeasuredOn.loadPrev: + return 'load_prev'; + case LocalCacheEventMeasuredOn.loadNext: + return 'load_next'; + } + } + + static LocalCacheEvent? getLocalCacheEvent(String event) { + switch (event) { + case 'cache_miss': + return LocalCacheEvent.cacheMiss; + case 'cache_hit': + return LocalCacheEvent.cacheHit; + } + sbLog.w(StackTrace.current, 'return null'); + return null; + } + + static String getLocalCacheEventString(LocalCacheEvent event) { + switch (event) { + case LocalCacheEvent.cacheMiss: + return 'cache_miss'; + case LocalCacheEvent.cacheHit: + return 'cache_hit'; + } + } } diff --git a/lib/src/internal/network/http/api_client.dart b/lib/src/internal/network/http/api_client.dart index 7dfb2e8b..ca612f65 100644 --- a/lib/src/internal/network/http/api_client.dart +++ b/lib/src/internal/network/http/api_client.dart @@ -14,6 +14,8 @@ class ApiClient { final StatManager? _statManager; final HttpClient _httpClient; + bool throwExceptionForTest = false; + ApiClient({ required ChatContext chatContext, required SessionManager sessionManager, @@ -36,6 +38,10 @@ class ApiClient { // possible other solution T is return type Future send(ApiRequest request) async { + if (throwExceptionForTest) { + throw Exception(); + } + final url = '/${request.version}/${request.url}'; final uri = _httpClient.toUri( url, diff --git a/lib/src/internal/network/http/http_client/request/channel/message/channel_messages_gap_request.dart b/lib/src/internal/network/http/http_client/request/channel/message/channel_messages_gap_request.dart index 6c4d9619..d5885114 100644 --- a/lib/src/internal/network/http/http_client/request/channel/message/channel_messages_gap_request.dart +++ b/lib/src/internal/network/http/http_client/request/channel/message/channel_messages_gap_request.dart @@ -25,7 +25,7 @@ class ChannelMessagesGapRequest extends ApiRequest { int? nextStartTs, // oldest in next direction int? nextEndTs, // latest in next direction int? nextCacheCount, // inclusive next cache count - this.checkingContinuousMessages = false, // useLocalCache (?) + this.checkingContinuousMessages = false, // useLocalCache }) : super(chat: chat) { url = '${channelType.urlString}/$channelUrl/messages_gap'; @@ -48,25 +48,57 @@ class ChannelMessagesGapRequest extends ApiRequest { } @override - Future?> response(Map res) async { + Future response(Map res) async { final isHugeGap = res['is_huge_gap'] as bool; - // final prevMessages = (res['prev_messages'] as List) - // .map((e) => BaseMessage.getMessageFromJsonWithChat(chat, e, - // channelType: channelType)) - // .toList(); + final prevMessages = (res['prev_messages'] as List) + .map((e) => RootMessage.getMessageFromJsonWithChat(chat, e, + channelType: channelType)) + .toList(); + final nextMessages = (res['next_messages'] as List) .map((e) => RootMessage.getMessageFromJsonWithChat(chat, e, channelType: channelType)) .toList(); - // final prevHasMore = res['prev_hasmore'] as bool; - // final nextHasMore = res['next_hasmore'] as bool; - // final isPrevContinuous = checkingContinuousMessages && - // res['is_continuous_prev_messages'] as bool; - // final isNextContinuous = checkingContinuousMessages && - // res['is_continuous_next_messages'] as bool; + final prevHasMore = res['prev_hasmore'] as bool; + final nextHasMore = res['next_hasmore'] as bool; - return isHugeGap ? null : nextMessages; + bool? isPrevContinuous; + bool? isNextContinuous; + if (checkingContinuousMessages) { + isPrevContinuous = res['is_continuous_prev_messages'] as bool; + isNextContinuous = res['is_continuous_next_messages'] as bool; + } + + return ChannelMessagesGapResponse( + isHugeGap: isHugeGap, + prevMessages: prevMessages, + nextMessages: nextMessages, + prevHasMore: prevHasMore, + nextHasMore: nextHasMore, + isPrevContinuous: isPrevContinuous, + isNextContinuous: isNextContinuous, + ); } } + +class ChannelMessagesGapResponse { + final List prevMessages; + final List nextMessages; + final bool? prevHasMore; + final bool? nextHasMore; + final bool? isPrevContinuous; + final bool? isNextContinuous; + final bool isHugeGap; + + ChannelMessagesGapResponse({ + required this.prevMessages, + required this.nextMessages, + required this.prevHasMore, + required this.nextHasMore, + this.isPrevContinuous, + this.isNextContinuous, + required this.isHugeGap, + }); +} diff --git a/lib/src/internal/network/http/http_client/request/channel/message/channel_messages_get_request.dart b/lib/src/internal/network/http/http_client/request/channel/message/channel_messages_get_request.dart index 5ae03f2f..397ed4d3 100644 --- a/lib/src/internal/network/http/http_client/request/channel/message/channel_messages_get_request.dart +++ b/lib/src/internal/network/http/http_client/request/channel/message/channel_messages_get_request.dart @@ -13,6 +13,7 @@ class ChannelMessagesGetRequest extends ApiRequest { HttpMethod get method => HttpMethod.get; ChannelType channelType; + bool checkingContinuousMessages; ChannelMessagesGetRequest( Chat chat, { @@ -23,6 +24,7 @@ class ChannelMessagesGetRequest extends ApiRequest { int messageId = 0, int parentMessageId = 0, bool checkingHasNext = false, + this.checkingContinuousMessages = false, // useLocalCache }) : super(chat: chat) { if (messageId <= 0 && timestamp < 0) { throw InvalidParameterException(); @@ -44,6 +46,8 @@ class ChannelMessagesGetRequest extends ApiRequest { if (parentMessageId > 0) { queryParams['parent_message_id'] = parentMessageId; } + + queryParams['checking_continuous_messages'] = checkingContinuousMessages; } @override @@ -54,9 +58,15 @@ class ChannelMessagesGetRequest extends ApiRequest { .toList(); final hasNext = res['has_next'] as bool?; + bool? isContinuous; + if (checkingContinuousMessages) { + isContinuous = res['is_continuous_messages'] as bool; + } + return ChannelMessagesGetResponse( messages: messages, hasNext: hasNext, + isContinuous: isContinuous, ); } } @@ -64,9 +74,11 @@ class ChannelMessagesGetRequest extends ApiRequest { class ChannelMessagesGetResponse { final List messages; final bool? hasNext; + final bool? isContinuous; ChannelMessagesGetResponse({ required this.messages, this.hasNext, + this.isContinuous, }); } diff --git a/lib/src/internal/network/http/http_client/request/main/upload_stat_request.dart b/lib/src/internal/network/http/http_client/request/main/upload_stat_request.dart index fb77394b..6fd9d19d 100644 --- a/lib/src/internal/network/http/http_client/request/main/upload_stat_request.dart +++ b/lib/src/internal/network/http/http_client/request/main/upload_stat_request.dart @@ -1,7 +1,7 @@ // Copyright (c) 2023 Sendbird, Inc. All rights reserved. import 'package:sendbird_chat_sdk/src/internal/main/chat/chat.dart'; -import 'package:sendbird_chat_sdk/src/internal/main/stats/base_stat.dart'; +import 'package:sendbird_chat_sdk/src/internal/main/stats/model/base_stat.dart'; import 'package:sendbird_chat_sdk/src/internal/network/http/http_client/http_client.dart'; import 'package:sendbird_chat_sdk/src/internal/network/http/http_client/request/api_request.dart'; diff --git a/lib/src/internal/network/websocket/websocket_client.dart b/lib/src/internal/network/websocket/websocket_client.dart index f0157c54..18c7adf5 100644 --- a/lib/src/internal/network/websocket/websocket_client.dart +++ b/lib/src/internal/network/websocket/websocket_client.dart @@ -111,12 +111,12 @@ class WebSocketClient { throw WebSocketFailedException(); } - try { + runZonedGuarded(() { _webSocketChannel?.sink.add(data); - } catch (e) { + }, (e, s) { sbLog.e(StackTrace.current, 'e: $e'); throw WebSocketFailedException(message: e.toString()); - } + }); } bool isConnected() { diff --git a/lib/src/public/core/channel/base_channel/base_channel.dart b/lib/src/public/core/channel/base_channel/base_channel.dart index 7f129d3b..45930eb8 100644 --- a/lib/src/public/core/channel/base_channel/base_channel.dart +++ b/lib/src/public/core/channel/base_channel/base_channel.dart @@ -10,7 +10,6 @@ import 'package:sendbird_chat_sdk/src/internal/main/chat/chat.dart'; import 'package:sendbird_chat_sdk/src/internal/main/chat_cache/cache_service.dart'; import 'package:sendbird_chat_sdk/src/internal/main/chat_cache/channel/meta_data_cache.dart'; import 'package:sendbird_chat_sdk/src/internal/main/chat_manager/collection_manager/collection_manager.dart'; -import 'package:sendbird_chat_sdk/src/internal/main/extensions/extensions.dart'; import 'package:sendbird_chat_sdk/src/internal/main/logger/sendbird_logger.dart'; import 'package:sendbird_chat_sdk/src/internal/main/utils/async/async_task.dart'; import 'package:sendbird_chat_sdk/src/internal/network/http/http_client/request/channel/channel_meta_counter/channel_meta_counter_create_request.dart'; @@ -49,6 +48,8 @@ import 'package:sendbird_chat_sdk/src/public/core/message/file_message.dart'; import 'package:sendbird_chat_sdk/src/public/core/message/root_message.dart'; import 'package:sendbird_chat_sdk/src/public/core/message/user_message.dart'; import 'package:sendbird_chat_sdk/src/public/core/user/sender.dart'; +import 'package:sendbird_chat_sdk/src/public/main/chat/sendbird_chat.dart'; +import 'package:sendbird_chat_sdk/src/public/main/collection/collection_event_source.dart'; import 'package:sendbird_chat_sdk/src/public/main/define/enums.dart'; import 'package:sendbird_chat_sdk/src/public/main/define/exceptions.dart'; import 'package:sendbird_chat_sdk/src/public/main/define/sendbird_error.dart'; @@ -74,7 +75,7 @@ part 'base_channel_operator.dart'; part 'base_channel_reaction.dart'; /// Objects representing a channel. -abstract class BaseChannel implements Cacheable { +class BaseChannel implements Cacheable { /// The unique channel URL. String channelUrl; @@ -319,7 +320,9 @@ abstract class BaseChannel implements Cacheable { dirty = other.dirty; } - Map toJson(); + Map toJson() { + return {}; + } Uint8List serialize() { return Uint8List.fromList(jsonEncode(toJson()).codeUnits); diff --git a/lib/src/public/core/channel/base_channel/base_channel_message.dart b/lib/src/public/core/channel/base_channel/base_channel_message.dart index c1c11cea..e0098769 100644 --- a/lib/src/public/core/channel/base_channel/base_channel_message.dart +++ b/lib/src/public/core/channel/base_channel/base_channel_message.dart @@ -47,6 +47,7 @@ extension BaseChannelMessage on BaseChannel { UserMessage sendUserMessage( UserMessageCreateParams params, { UserMessageHandler? handler, + int? resendMessageId, }) { sbLog.i(StackTrace.current, 'message: ${params.message}'); checkUnsupportedAction(); @@ -69,12 +70,60 @@ extension BaseChannelMessage on BaseChannel { commandType: cmd.cmd, ) as UserMessage; + if (this is GroupChannel) { + pendingUserMessage.messageId = + resendMessageId ?? DateTime.now().millisecondsSinceEpoch; + + for (final messageCollection + in chat.collectionManager.baseMessageCollections) { + if (messageCollection.baseChannel.channelUrl == channelUrl) { + if (resendMessageId != null) { + chat.collectionManager.sendEventsToMessageCollection( + messageCollection: messageCollection, + baseChannel: this, + eventSource: CollectionEventSource.localMessageResendStarted, + sendingStatus: SendingStatus.pending, + updatedMessages: [pendingUserMessage], + ); + } else { + chat.collectionManager.sendEventsToMessageCollection( + messageCollection: messageCollection, + baseChannel: this, + eventSource: CollectionEventSource.localMessagePendingCreated, + sendingStatus: SendingStatus.pending, + addedMessages: [pendingUserMessage], + ); + } + break; + } + } + } + if (chat.chatContext.currentUser == null) { final error = ConnectionRequiredException(); pendingUserMessage ..errorCode = error.code ..sendingStatus = SendingStatus.failed; - if (handler != null) handler(pendingUserMessage, error); + + if (this is GroupChannel) { + for (final messageCollection + in chat.collectionManager.baseMessageCollections) { + if (messageCollection.baseChannel.channelUrl == channelUrl) { + chat.collectionManager.sendEventsToMessageCollection( + messageCollection: messageCollection, + baseChannel: this, + eventSource: CollectionEventSource.localMessageFailed, + sendingStatus: SendingStatus.failed, + updatedMessages: [pendingUserMessage], + ); + break; + } + } + } + + if (handler != null) { + handler(pendingUserMessage, error); + } return pendingUserMessage; } @@ -84,8 +133,26 @@ extension BaseChannelMessage on BaseChannel { pendingUserMessage.messageCreateParams = params; runZonedGuarded(() { - chat.commandManager.sendCommand(cmd).then((result) { - if (result == null) return; + chat.commandManager.sendCommand(cmd).then((result) async { + if (result == null) { + return; + } + + if (this is GroupChannel) { + for (final messageCollection + in chat.collectionManager.baseMessageCollections) { + if (messageCollection.baseChannel.channelUrl == channelUrl) { + await chat.collectionManager.sendEventsToMessageCollection( + messageCollection: messageCollection, + baseChannel: this, + eventSource: CollectionEventSource.localMessagePendingCreated, + sendingStatus: SendingStatus.succeeded, + deletedMessageIds: [pendingUserMessage.rootId], + ); + break; + } + } + } final message = RootMessage.getMessageFromJsonWithChat( chat, @@ -94,7 +161,9 @@ extension BaseChannelMessage on BaseChannel { ) as UserMessage; chat.collectionManager.onMessageSentByMe(message); - if (handler != null) handler(message, null); + if (handler != null) { + handler(message, null); + } }); }, (e, s) { sbLog.e(StackTrace.current, 'e: $e'); @@ -103,7 +172,26 @@ extension BaseChannelMessage on BaseChannel { pendingUserMessage ..errorCode = e.code ?? SendbirdError.unknownError ..sendingStatus = SendingStatus.failed; - if (handler != null) handler(pendingUserMessage, e); + + if (this is GroupChannel) { + for (final messageCollection + in chat.collectionManager.baseMessageCollections) { + if (messageCollection.baseChannel.channelUrl == channelUrl) { + chat.collectionManager.sendEventsToMessageCollection( + messageCollection: messageCollection, + baseChannel: this, + eventSource: CollectionEventSource.localMessageFailed, + sendingStatus: SendingStatus.failed, + updatedMessages: [pendingUserMessage], + ); + break; + } + } + } + + if (handler != null) { + handler(pendingUserMessage, e); + } } }); @@ -134,6 +222,7 @@ extension BaseChannelMessage on BaseChannel { return sendUserMessage( params, handler: handler, + resendMessageId: message.messageId, ); } @@ -171,6 +260,7 @@ extension BaseChannelMessage on BaseChannel { FileMessageCreateParams params, { FileMessageHandler? handler, ProgressHandler? progressHandler, + int? resendMessageId, }) { sbLog.i(StackTrace.current, 'params.uploadFile.name: ${params.fileInfo.fileName}'); @@ -188,6 +278,35 @@ extension BaseChannelMessage on BaseChannel { Sender.fromUser(chat.chatContext.currentUser, this); pendingFileMessage.messageCreateParams = params; + if (this is GroupChannel) { + pendingFileMessage.messageId = + resendMessageId ?? DateTime.now().millisecondsSinceEpoch; + + for (final messageCollection + in chat.collectionManager.baseMessageCollections) { + if (messageCollection.baseChannel.channelUrl == channelUrl) { + if (resendMessageId != null) { + chat.collectionManager.sendEventsToMessageCollection( + messageCollection: messageCollection, + baseChannel: this, + eventSource: CollectionEventSource.localMessageResendStarted, + sendingStatus: SendingStatus.pending, + updatedMessages: [pendingFileMessage], + ); + } else { + chat.collectionManager.sendEventsToMessageCollection( + messageCollection: messageCollection, + baseChannel: this, + eventSource: CollectionEventSource.localMessagePendingCreated, + sendingStatus: SendingStatus.pending, + addedMessages: [pendingFileMessage], + ); + } + break; + } + } + } + bool isCanceled = false; runZonedGuarded(() async { final queue = chat.getMessageQueue(channelUrl); @@ -205,9 +324,28 @@ extension BaseChannelMessage on BaseChannel { .timeout( Duration(seconds: chat.chatContext.options.fileTransferTimeout), onTimeout: () { + pendingFileMessage.sendingStatus = SendingStatus.failed; + + if (this is GroupChannel) { + for (final messageCollection + in chat.collectionManager.baseMessageCollections) { + if (messageCollection.baseChannel.channelUrl == + channelUrl) { + chat.collectionManager.sendEventsToMessageCollection( + messageCollection: messageCollection, + baseChannel: this, + eventSource: CollectionEventSource.localMessageFailed, + sendingStatus: SendingStatus.failed, + updatedMessages: [pendingFileMessage], + ); + break; + } + } + } + if (handler != null) { handler( - pendingFileMessage..sendingStatus = SendingStatus.failed, + pendingFileMessage, SendbirdException(code: SendbirdError.fileUploadTimeout), ); } @@ -229,35 +367,76 @@ extension BaseChannelMessage on BaseChannel { thumbnails: uploadResponse?.thumbnails, ); - final message = RootMessage.getMessageFromJsonWithChat( + final messageBeforeSent = + RootMessage.getMessageFromJsonWithChat( chat, cmd.payload, channelType: channelType, commandType: cmd.cmd, - ) as FileMessage; + ) as FileMessage + ..messageId = pendingFileMessage.messageId; if (chat.chatContext.currentUser == null) { final error = ConnectionRequiredException(); - message + messageBeforeSent ..errorCode = error.code ..sendingStatus = SendingStatus.failed; - if (handler != null) handler(message, error); - return message; + + if (this is GroupChannel) { + for (final messageCollection + in chat.collectionManager.baseMessageCollections) { + if (messageCollection.baseChannel.channelUrl == channelUrl) { + chat.collectionManager.sendEventsToMessageCollection( + messageCollection: messageCollection, + baseChannel: this, + eventSource: CollectionEventSource.localMessageFailed, + sendingStatus: SendingStatus.failed, + updatedMessages: [messageBeforeSent], + ); + break; + } + } + } + + if (handler != null) { + handler(messageBeforeSent, error); + } + return messageBeforeSent; } if (chat.connectionManager.isConnected()) { - chat.commandManager.sendCommand(cmd).then((result) { + chat.commandManager.sendCommand(cmd).then((result) async { if (result == null) return; + if (this is GroupChannel) { + for (final messageCollection + in chat.collectionManager.baseMessageCollections) { + if (messageCollection.baseChannel.channelUrl == channelUrl) { + await chat.collectionManager.sendEventsToMessageCollection( + messageCollection: messageCollection, + baseChannel: this, + eventSource: + CollectionEventSource.localMessagePendingCreated, + sendingStatus: SendingStatus.succeeded, + deletedMessageIds: [messageBeforeSent.rootId], + ); + break; + } + } + } + final message = RootMessage.getMessageFromJsonWithChat( chat, result.payload, + channelType: channelType, commandType: result.cmd, ) as FileMessage; chat.collectionManager.onMessageSentByMe(message); - if (handler != null) handler(message, null); + if (handler != null) { + handler(message, null); + } }); } else { final request = ChannelFileMessageSendRequest( @@ -270,12 +449,49 @@ extension BaseChannelMessage on BaseChannel { ); final message = await chat.apiClient.send(request); + if (this is GroupChannel) { + for (final messageCollection + in chat.collectionManager.baseMessageCollections) { + if (messageCollection.baseChannel.channelUrl == channelUrl) { + await chat.collectionManager.sendEventsToMessageCollection( + messageCollection: messageCollection, + baseChannel: this, + eventSource: + CollectionEventSource.localMessagePendingCreated, + sendingStatus: SendingStatus.succeeded, + deletedMessageIds: [messageBeforeSent.rootId], + ); + break; + } + } + } + chat.collectionManager.onMessageSentByMe(message); - if (handler != null) handler(message, null); + if (handler != null) { + handler(message, null); + } } }, onCancel: () { isCanceled = true; + pendingFileMessage.sendingStatus = SendingStatus.canceled; + + if (this is GroupChannel) { + for (final messageCollection + in chat.collectionManager.baseMessageCollections) { + if (messageCollection.baseChannel.channelUrl == channelUrl) { + chat.collectionManager.sendEventsToMessageCollection( + messageCollection: messageCollection, + baseChannel: this, + eventSource: CollectionEventSource.localMessageCanceled, + sendingStatus: SendingStatus.canceled, + deletedMessageIds: [pendingFileMessage.rootId], + ); + break; + } + } + } + if (handler != null) { handler(pendingFileMessage, OperationCanceledException()); } @@ -294,7 +510,26 @@ extension BaseChannelMessage on BaseChannel { pendingFileMessage ..errorCode = e.code ?? SendbirdError.unknownError ..sendingStatus = SendingStatus.failed; - if (handler != null) handler(pendingFileMessage, e); + + if (this is GroupChannel) { + for (final messageCollection + in chat.collectionManager.baseMessageCollections) { + if (messageCollection.baseChannel.channelUrl == channelUrl) { + chat.collectionManager.sendEventsToMessageCollection( + messageCollection: messageCollection, + baseChannel: this, + eventSource: CollectionEventSource.localMessageFailed, + sendingStatus: SendingStatus.failed, + updatedMessages: [pendingFileMessage], + ); + break; + } + } + } + + if (handler != null) { + handler(pendingFileMessage, e); + } } }); @@ -356,6 +591,7 @@ extension BaseChannelMessage on BaseChannel { params, progressHandler: progressHandler, handler: handler, + resendMessageId: message.messageId, ); } @@ -547,7 +783,7 @@ extension BaseChannelMessage on BaseChannel { channelUrl: channelUrl, params: params, token: token, - timestamp: timestamp ?? IntMax.max, + timestamp: timestamp ?? SendbirdChat.maxInt, ), ); } diff --git a/lib/src/public/core/channel/feed_channel/feed_channel.dart b/lib/src/public/core/channel/feed_channel/feed_channel.dart index d6ecd91b..150d464c 100644 --- a/lib/src/public/core/channel/feed_channel/feed_channel.dart +++ b/lib/src/public/core/channel/feed_channel/feed_channel.dart @@ -13,6 +13,7 @@ import 'package:sendbird_chat_sdk/src/internal/network/http/http_client/request/ import 'package:sendbird_chat_sdk/src/public/core/channel/base_channel/base_channel.dart'; import 'package:sendbird_chat_sdk/src/public/core/channel/group_channel/group_channel.dart'; import 'package:sendbird_chat_sdk/src/public/core/message/notification_message.dart'; +import 'package:sendbird_chat_sdk/src/public/core/message/root_message.dart'; import 'package:sendbird_chat_sdk/src/public/core/user/member.dart'; import 'package:sendbird_chat_sdk/src/public/main/chat/sendbird_chat.dart'; import 'package:sendbird_chat_sdk/src/public/main/define/enums.dart'; @@ -174,7 +175,25 @@ class FeedChannel extends BaseChannel { channel.groupChannel.fromCache = true; return channel; } - return await FeedChannel.refresh(channelUrl, chat: chat); + + try { + final channel = await FeedChannel.refresh(channelUrl, chat: chat); + return channel; + } catch (e) { + //+ [DBManager] + if (chat.dbManager.isEnabled()) { + if (chat.currentUser != null) { + final channel = await chat.dbManager.getFeedChannel(channelUrl); + if (channel != null) { + channel.fromCache = true; + channel.groupChannel.fromCache = true; + return channel; + } + } + } + //- [DBManager] + rethrow; + } } /// Refreshes all the data of this channel. @@ -186,7 +205,7 @@ class FeedChannel extends BaseChannel { sbLog.i(StackTrace.current, 'channelUrl: $channelUrl'); chat ??= SendbirdChat().chat; - return await chat.apiClient.send( + final channel = await chat.apiClient.send( FeedChannelRefreshRequest( chat, channelUrl, @@ -199,20 +218,31 @@ class FeedChannel extends BaseChannel { passive: false, ), ); + + //+ [DBManager] + if (chat.dbManager.isEnabled()) { + await chat.dbManager.upsertFeedChannels([channel]); + } + //- [DBManager] + + return channel; } - /// Sends mark as read all to this channel. + /// Sends mark as read to this channel. /// If [messages] is not null, the [messages] will be marked as read to this channel. /// @since 4.1.0 Future markAsRead({List? messages}) async { sbLog.i(StackTrace.current); List? messageIds; + List? updatedMessages; if (messages != null) { messageIds = []; + updatedMessages = []; for (final message in messages) { if (message.messageStatus == NotificationMessageStatus.sent) { messageIds.add(message.notificationId); + updatedMessages.add(message); } } if (messageIds.isEmpty) return; @@ -226,6 +256,7 @@ class FeedChannel extends BaseChannel { )); chat.collectionManager.markAsReadForFeedChannel(channelUrl, messageIds); + chat.collectionManager.onMessagesUpdated(channelUrl, updatedMessages); if (messageIds == null) { final ts = res['ts'] ?? 0; @@ -244,7 +275,11 @@ class FeedChannel extends BaseChannel { if (groupChannel.unreadMessageCount > 0 || groupChannel.unreadMentionCount > 0) { groupChannel.clearUnreadCount(); - // chat.eventManager.notifyChannelChanged(this); // Refer to [_processChannelPropChanged] + + // When [isChatConnected], [_processChannelPropChanged] is called. + if (chat.chatContext.isFeedAuthenticated) { + chat.eventManager.notifyChannelChanged(this); + } } } else { final unreadMessageCount = res['unread_message_count'] ?? 0; @@ -252,7 +287,11 @@ class FeedChannel extends BaseChannel { if (unreadMessageCount != null && unreadMessageCount != groupChannel.unreadMessageCount) { groupChannel.unreadMessageCount = unreadMessageCount; - // chat.eventManager.notifyChannelChanged(this); // Refer to [_processChannelPropChanged] + + // When [isChatConnected], [_processChannelPropChanged] is called. + if (chat.chatContext.isFeedAuthenticated) { + chat.eventManager.notifyChannelChanged(this); + } } } } diff --git a/lib/src/public/core/channel/group_channel/group_channel.dart b/lib/src/public/core/channel/group_channel/group_channel.dart index ed2c690c..dec328d3 100644 --- a/lib/src/public/core/channel/group_channel/group_channel.dart +++ b/lib/src/public/core/channel/group_channel/group_channel.dart @@ -264,13 +264,30 @@ class GroupChannel extends BaseChannel { sbLog.i(StackTrace.current, 'channelUrl: $channelUrl'); chat ??= SendbirdChat().chat; - final channel = + GroupChannel? channel = chat.channelCache.find(channelKey: channelUrl); if (channel != null && !channel.dirty) { channel.fromCache = true; return channel; } - return await GroupChannel.refresh(channelUrl, chat: chat); + + try { + final channel = await GroupChannel.refresh(channelUrl, chat: chat); + return channel; + } catch (e) { + //+ [DBManager] + if (chat.dbManager.isEnabled()) { + if (chat.currentUser != null) { + final channel = await chat.dbManager.getGroupChannel(channelUrl); + if (channel != null) { + channel.fromCache = true; + return channel; + } + } + } + //- [DBManager] + rethrow; + } } /// Refreshes all the data of this channel. @@ -281,7 +298,7 @@ class GroupChannel extends BaseChannel { sbLog.i(StackTrace.current, 'channelUrl: $channelUrl'); chat ??= SendbirdChat().chat; - return await chat.apiClient.send( + final channel = await chat.apiClient.send( GroupChannelRefreshRequest( chat, channelUrl, @@ -294,6 +311,14 @@ class GroupChannel extends BaseChannel { passive: false, ), ); + + //+ [DBManager] + if (chat.dbManager.isEnabled()) { + await chat.dbManager.upsertGroupChannels([channel]); + } + //- [DBManager] + + return channel; } /// Creates `GroupChannel` with GroupChannelCreateParams. diff --git a/lib/src/public/core/message/admin_message.dart b/lib/src/public/core/message/admin_message.dart index 0de4365f..d3ee1b05 100644 --- a/lib/src/public/core/message/admin_message.dart +++ b/lib/src/public/core/message/admin_message.dart @@ -20,14 +20,14 @@ part 'admin_message.g.dart'; @JsonSerializable() class AdminMessage extends BaseMessage { AdminMessage({ - required int messageId, - required String message, required String channelUrl, required ChannelType channelType, + required int messageId, + required String message, SendingStatus? sendingStatus, String? requestId, List mentionedUsers = const [], - MentionType? mentionType, + MentionType mentionType = MentionType.users, List? requestedMentionUserIds, int createdAt = 0, int updatedAt = 0, diff --git a/lib/src/public/core/message/admin_message.g.dart b/lib/src/public/core/message/admin_message.g.dart index ad685eb2..7712620d 100644 --- a/lib/src/public/core/message/admin_message.g.dart +++ b/lib/src/public/core/message/admin_message.g.dart @@ -7,13 +7,13 @@ part of 'admin_message.dart'; // ************************************************************************** AdminMessage _$AdminMessageFromJson(Map json) => AdminMessage( - messageId: json['message_id'] as int? ?? 0, - message: json['message'] as String, channelUrl: json['channel_url'] as String, channelType: $enumDecodeNullable( _$ChannelTypeEnumMap, json['channel_type'], unknownValue: ChannelType.group) ?? ChannelType.group, + messageId: json['message_id'] as int? ?? 0, + message: json['message'] as String, sendingStatus: $enumDecodeNullable(_$SendingStatusEnumMap, json['sending_status']), requestId: json['request_id'] as String?, @@ -21,8 +21,10 @@ AdminMessage _$AdminMessageFromJson(Map json) => AdminMessage( ?.map((e) => User.fromJson(e as Map)) .toList() ?? const [], - mentionType: - $enumDecodeNullable(_$MentionTypeEnumMap, json['mention_type']), + mentionType: $enumDecodeNullable( + _$MentionTypeEnumMap, json['mention_type'], + unknownValue: MentionType.users) ?? + MentionType.users, createdAt: json['created_at'] as int? ?? 0, updatedAt: json['updated_at'] as int? ?? 0, parentMessageId: json['parent_message_id'] as int?, @@ -61,7 +63,7 @@ Map _$AdminMessageToJson(AdminMessage instance) => 'channel_type': _$ChannelTypeEnumMap[instance.channelType]!, 'data': instance.data, 'custom_type': instance.customType, - 'mention_type': _$MentionTypeEnumMap[instance.mentionType], + 'mention_type': _$MentionTypeEnumMap[instance.mentionType]!, 'mentioned_users': instance.mentionedUsers.map((e) => e.toJson()).toList(), 'sorted_metaarray': @@ -69,8 +71,8 @@ Map _$AdminMessageToJson(AdminMessage instance) => 'extended_message': instance.extendedMessage, 'created_at': instance.createdAt, 'updated_at': instance.updatedAt, - 'request_id': instance.requestId, 'message_id': instance.messageId, + 'request_id': instance.requestId, 'message': instance.message, 'sending_status': _$SendingStatusEnumMap[instance.sendingStatus], 'is_reply_to_channel': instance.isReplyToChannel, diff --git a/lib/src/public/core/message/base_message.dart b/lib/src/public/core/message/base_message.dart index 9796943e..d5324a7d 100644 --- a/lib/src/public/core/message/base_message.dart +++ b/lib/src/public/core/message/base_message.dart @@ -39,16 +39,16 @@ import 'package:sendbird_chat_sdk/src/public/main/params/message/threaded_messag part 'package:sendbird_chat_sdk/src/internal/main/extensions/base_message_extensions.dart'; /// Base class for messages. -abstract class BaseMessage extends RootMessage { - /// The request ID of the message. - final String? requestId; - +class BaseMessage extends RootMessage { /// The ID of the message. @JsonKey(defaultValue: 0) // or msg_id - final int messageId; + int messageId; + + /// The request ID of the message. + String? requestId; /// The message text of the message. - final String message; + String message; /// The sending status of the message. SendingStatus? sendingStatus; @@ -58,19 +58,20 @@ abstract class BaseMessage extends RootMessage { bool isReplyToChannel; /// The parent message's ID if this is a reply message. - final int? parentMessageId; + int? parentMessageId; /// The parent message of this message. /// Only `NonNull` if this message is a reply message. /// It does **not** contain all properties of the parent message. /// Only contains: - /// - [BaseMessage.message]. - /// - [BaseMessage.sender]. (null if the parent message is an [AdminMessage]). - /// - [BaseMessage.createdAt]. - /// - File information if it's a [FileMessage]. - /// - [FileMessage.name]. - /// - [FileMessage.type]. - /// - [FileMessage.url]. + /// [BaseMessage.message]. + /// [BaseMessage.sender]. (null if the parent message is an [AdminMessage]). + /// [BaseMessage.createdAt]. + /// File information if it's a [FileMessage]. + /// [FileMessage.name]. + /// [FileMessage.type]. + /// [FileMessage.url]. + /// [FileMessage.data]. /// This is only for accessing parent message's information (READ ONLY) and should not to be used to modify the parent message. @JsonKey(name: 'parent_message_info') BaseMessage? parentMessage; @@ -80,11 +81,11 @@ abstract class BaseMessage extends RootMessage { /// The message's survival seconds. @JsonKey(defaultValue: -1) - final int? messageSurvivalSeconds; + int? messageSurvivalSeconds; /// Checks whether the message is silent or not. @JsonKey(name: 'silent') - final bool isSilent; + bool isSilent; /// The error code of them message if the [sendingStatus] is [SendingStatus.failed]. int? errorCode; @@ -96,15 +97,15 @@ abstract class BaseMessage extends RootMessage { /// So if the sender's operator status changed after sending a message, /// the value of the property and the result of [Sender.role] might differ. @JsonKey(name: 'is_op_msg') - final bool isOperatorMessage; + bool isOperatorMessage; /// The [OGMetaData] of the message. (https://ogp.me/) /// Might be null if - /// 1. Application does not support OG-TAG. (all new applications support OG-TAG by default) - /// 2. The message does not contain a valid url. - /// 3. The server did not fetch the OG-Tag yet. + /// Application does not support OG-TAG. (all new applications support OG-TAG by default) + /// The message does not contain a valid url. + /// The server did not fetch the OG-Tag yet. @JsonKey(name: 'og_tag') - final OGMetaData? ogMetaData; + OGMetaData? ogMetaData; /// The reactions on the message. @JsonKey(defaultValue: []) @@ -133,8 +134,8 @@ abstract class BaseMessage extends RootMessage { super.createdAt, super.updatedAt, Sender? sender, - this.requestId, this.messageId = 0, + this.requestId, this.isReplyToChannel = false, this.parentMessageId, Map? parentMessage, @@ -167,12 +168,6 @@ abstract class BaseMessage extends RootMessage { } } - MessageType get messageType => this is UserMessage - ? MessageType.user - : this is FileMessage - ? MessageType.file - : MessageType.admin; - @override void set(Chat chat) { super.set(chat); diff --git a/lib/src/public/core/message/file_message.dart b/lib/src/public/core/message/file_message.dart index 84e17faf..6e6815df 100644 --- a/lib/src/public/core/message/file_message.dart +++ b/lib/src/public/core/message/file_message.dart @@ -40,29 +40,32 @@ class FileMessage extends BaseMessage { } /// Represents the name of the file. - final String? name; + String? name; /// Represents the size of the file. - final int? size; + int? size; /// Represents the type of the file. **MIME preferred.** - final String? type; + String? type; /// Represents the thumbnail information of image file. /// To make thumbnail of image when you send it, /// please refer to [BaseChannelMessage.sendFileMessage]. - final List? thumbnails; + List? thumbnails; /// [FileMessageCreateParams] object that used for sending this message. @JsonKey(includeFromJson: false, includeToJson: false) FileMessageCreateParams? messageCreateParams; - final bool requireAuth; + bool requireAuth; @JsonKey(includeFromJson: false, includeToJson: false) File? file; FileMessage({ + required String channelUrl, + required ChannelType channelType, + required int messageId, required this.url, this.name, this.size = 0, @@ -72,13 +75,10 @@ class FileMessage extends BaseMessage { this.file, String? requestId, String? message, - required int messageId, SendingStatus? sendingStatus, Sender? sender, - required String channelUrl, - required ChannelType channelType, List mentionedUsers = const [], - MentionType? mentionType, + MentionType mentionType = MentionType.users, List? requestedMentionUserIds, int createdAt = 0, int updatedAt = 0, diff --git a/lib/src/public/core/message/file_message.g.dart b/lib/src/public/core/message/file_message.g.dart index f2490a2c..bd99bbbc 100644 --- a/lib/src/public/core/message/file_message.g.dart +++ b/lib/src/public/core/message/file_message.g.dart @@ -7,6 +7,12 @@ part of 'file_message.dart'; // ************************************************************************** FileMessage _$FileMessageFromJson(Map json) => FileMessage( + channelUrl: json['channel_url'] as String, + channelType: $enumDecodeNullable( + _$ChannelTypeEnumMap, json['channel_type'], + unknownValue: ChannelType.group) ?? + ChannelType.group, + messageId: json['message_id'] as int? ?? 0, url: json['url'] as String, name: json['name'] as String?, size: json['size'] as int? ?? 0, @@ -17,23 +23,19 @@ FileMessage _$FileMessageFromJson(Map json) => FileMessage( requireAuth: json['require_auth'] as bool? ?? false, requestId: json['request_id'] as String?, message: json['message'] as String?, - messageId: json['message_id'] as int? ?? 0, sendingStatus: $enumDecodeNullable(_$SendingStatusEnumMap, json['sending_status']), sender: json['user'] == null ? null : Sender.fromJson(json['user'] as Map), - channelUrl: json['channel_url'] as String, - channelType: $enumDecodeNullable( - _$ChannelTypeEnumMap, json['channel_type'], - unknownValue: ChannelType.group) ?? - ChannelType.group, mentionedUsers: (json['mentioned_users'] as List?) ?.map((e) => User.fromJson(e as Map)) .toList() ?? const [], - mentionType: - $enumDecodeNullable(_$MentionTypeEnumMap, json['mention_type']), + mentionType: $enumDecodeNullable( + _$MentionTypeEnumMap, json['mention_type'], + unknownValue: MentionType.users) ?? + MentionType.users, createdAt: json['created_at'] as int? ?? 0, updatedAt: json['updated_at'] as int? ?? 0, parentMessageId: json['parent_message_id'] as int?, @@ -70,7 +72,7 @@ Map _$FileMessageToJson(FileMessage instance) => 'channel_type': _$ChannelTypeEnumMap[instance.channelType]!, 'data': instance.data, 'custom_type': instance.customType, - 'mention_type': _$MentionTypeEnumMap[instance.mentionType], + 'mention_type': _$MentionTypeEnumMap[instance.mentionType]!, 'mentioned_users': instance.mentionedUsers.map((e) => e.toJson()).toList(), 'sorted_metaarray': @@ -78,8 +80,8 @@ Map _$FileMessageToJson(FileMessage instance) => 'extended_message': instance.extendedMessage, 'created_at': instance.createdAt, 'updated_at': instance.updatedAt, - 'request_id': instance.requestId, 'message_id': instance.messageId, + 'request_id': instance.requestId, 'message': instance.message, 'sending_status': _$SendingStatusEnumMap[instance.sendingStatus], 'is_reply_to_channel': instance.isReplyToChannel, @@ -102,6 +104,12 @@ Map _$FileMessageToJson(FileMessage instance) => 'require_auth': instance.requireAuth, }; +const _$ChannelTypeEnumMap = { + ChannelType.group: 'group', + ChannelType.open: 'open', + ChannelType.feed: 'feed', +}; + const _$SendingStatusEnumMap = { SendingStatus.none: 'none', SendingStatus.pending: 'pending', @@ -110,12 +118,6 @@ const _$SendingStatusEnumMap = { SendingStatus.canceled: 'canceled', }; -const _$ChannelTypeEnumMap = { - ChannelType.group: 'group', - ChannelType.open: 'open', - ChannelType.feed: 'feed', -}; - const _$MentionTypeEnumMap = { MentionType.users: 'users', MentionType.channel: 'channel', diff --git a/lib/src/public/core/message/notification_message.g.dart b/lib/src/public/core/message/notification_message.g.dart index 93b1808b..8960d64a 100644 --- a/lib/src/public/core/message/notification_message.g.dart +++ b/lib/src/public/core/message/notification_message.g.dart @@ -20,8 +20,10 @@ NotificationMessage _$NotificationMessageFromJson(Map json) => json['message_status'] as String), data: TypeChecker.fromJsonToNullableString(json['data']), customType: json['custom_type'] as String?, - mentionType: - $enumDecodeNullable(_$MentionTypeEnumMap, json['mention_type']), + mentionType: $enumDecodeNullable( + _$MentionTypeEnumMap, json['mention_type'], + unknownValue: MentionType.users) ?? + MentionType.users, mentionedUsers: (json['mentioned_users'] as List?) ?.map((e) => User.fromJson(e as Map)) .toList() ?? @@ -41,7 +43,7 @@ Map _$NotificationMessageToJson( 'channel_type': _$ChannelTypeEnumMap[instance.channelType]!, 'data': instance.data, 'custom_type': instance.customType, - 'mention_type': _$MentionTypeEnumMap[instance.mentionType], + 'mention_type': _$MentionTypeEnumMap[instance.mentionType]!, 'mentioned_users': instance.mentionedUsers.map((e) => e.toJson()).toList(), 'sorted_metaarray': diff --git a/lib/src/public/core/message/root_message.dart b/lib/src/public/core/message/root_message.dart index b78421b8..a18bc5ca 100644 --- a/lib/src/public/core/message/root_message.dart +++ b/lib/src/public/core/message/root_message.dart @@ -19,9 +19,9 @@ import 'package:sendbird_chat_sdk/src/public/main/define/exceptions.dart'; import 'package:sendbird_chat_sdk/src/public/main/model/message/message_meta_array.dart'; /// Class representing a root message. -abstract class RootMessage { +class RootMessage { /// The channel URL of the channel this message belongs to. - final String channelUrl; + String channelUrl; /// The [ChannelType] of the channel this message belongs to. @JsonKey(defaultValue: ChannelType.group, unknownEnumValue: ChannelType.group) @@ -32,11 +32,11 @@ abstract class RootMessage { String? data; /// The custom type of the message. - final String? customType; + String? customType; /// The mention type. Refer to [MentionType]. - @JsonKey(unknownEnumValue: null) - final MentionType? mentionType; + @JsonKey(unknownEnumValue: MentionType.users) + MentionType mentionType; @JsonKey(name: 'mentioned_users', defaultValue: []) List _mentionedUsers; @@ -70,10 +70,10 @@ abstract class RootMessage { Map extendedMessage; /// The creation time of the message in milliseconds. - final int createdAt; + int createdAt; /// The updated time of the message in milliseconds. - final int updatedAt; + int updatedAt; @JsonKey(includeFromJson: false, includeToJson: false) late Chat chat; @@ -83,7 +83,7 @@ abstract class RootMessage { required this.channelType, this.data, this.customType, - this.mentionType, + this.mentionType = MentionType.users, List mentionedUsers = const [], this.allMetaArrays, Map? extendedMessage, @@ -111,7 +111,28 @@ abstract class RootMessage { return (this as BaseMessage).messageId; } - Map toJson(); + MessageType get messageType => this is UserMessage + ? MessageType.user + : this is FileMessage + ? MessageType.file + : this is AdminMessage + ? MessageType.admin + : this is NotificationMessage + ? MessageType.notification + : throw MalformedDataException(); + + String get rootId { + if (this is BaseMessage) { + return (this as BaseMessage).messageId.toString(); + } else if (this is NotificationMessage) { + return (this as NotificationMessage).notificationId; + } + throw MalformedDataException(); + } + + Map toJson() { + return {}; + } static RootMessage getMessageFromJsonWithChat( Chat chat, @@ -260,4 +281,5 @@ enum MessageType { user, file, admin, + notification, } diff --git a/lib/src/public/core/message/user_message.dart b/lib/src/public/core/message/user_message.dart index 45c11a28..4911fd33 100644 --- a/lib/src/public/core/message/user_message.dart +++ b/lib/src/public/core/message/user_message.dart @@ -33,7 +33,7 @@ class UserMessage extends BaseMessage { /// The list of target translation languages with the language codes. /// The messages that have been sent or scheduled with translation option will have this list. /// (refer to [BaseChannelMessage.sendUserMessage]) - final List? translationTargetLanguages; + List? translationTargetLanguages; /// The poll that belongs to this message object. Poll? poll; @@ -43,16 +43,16 @@ class UserMessage extends BaseMessage { UserMessageCreateParams? messageCreateParams; UserMessage({ - required this.translations, - required int messageId, - required String message, required String channelUrl, required ChannelType channelType, + required int messageId, + required String message, + required this.translations, Sender? sender, SendingStatus? sendingStatus, String? requestId, List mentionedUsers = const [], - MentionType? mentionType, + MentionType mentionType = MentionType.users, List? requestedMentionUserIds, int createdAt = 0, int updatedAt = 0, diff --git a/lib/src/public/core/message/user_message.g.dart b/lib/src/public/core/message/user_message.g.dart index bb334e9e..8fbc10cd 100644 --- a/lib/src/public/core/message/user_message.g.dart +++ b/lib/src/public/core/message/user_message.g.dart @@ -7,17 +7,17 @@ part of 'user_message.dart'; // ************************************************************************** UserMessage _$UserMessageFromJson(Map json) => UserMessage( - translations: (json['translations'] as Map?)?.map( - (k, e) => MapEntry(k, e as String), - ) ?? - {}, - messageId: json['message_id'] as int? ?? 0, - message: json['message'] as String, channelUrl: json['channel_url'] as String, channelType: $enumDecodeNullable( _$ChannelTypeEnumMap, json['channel_type'], unknownValue: ChannelType.group) ?? ChannelType.group, + messageId: json['message_id'] as int? ?? 0, + message: json['message'] as String, + translations: (json['translations'] as Map?)?.map( + (k, e) => MapEntry(k, e as String), + ) ?? + {}, sender: json['user'] == null ? null : Sender.fromJson(json['user'] as Map), @@ -28,8 +28,10 @@ UserMessage _$UserMessageFromJson(Map json) => UserMessage( ?.map((e) => User.fromJson(e as Map)) .toList() ?? const [], - mentionType: - $enumDecodeNullable(_$MentionTypeEnumMap, json['mention_type']), + mentionType: $enumDecodeNullable( + _$MentionTypeEnumMap, json['mention_type'], + unknownValue: MentionType.users) ?? + MentionType.users, createdAt: json['created_at'] as int? ?? 0, updatedAt: json['updated_at'] as int? ?? 0, parentMessageId: json['parent_message_id'] as int?, @@ -73,7 +75,7 @@ Map _$UserMessageToJson(UserMessage instance) => 'channel_type': _$ChannelTypeEnumMap[instance.channelType]!, 'data': instance.data, 'custom_type': instance.customType, - 'mention_type': _$MentionTypeEnumMap[instance.mentionType], + 'mention_type': _$MentionTypeEnumMap[instance.mentionType]!, 'mentioned_users': instance.mentionedUsers.map((e) => e.toJson()).toList(), 'sorted_metaarray': @@ -81,8 +83,8 @@ Map _$UserMessageToJson(UserMessage instance) => 'extended_message': instance.extendedMessage, 'created_at': instance.createdAt, 'updated_at': instance.updatedAt, - 'request_id': instance.requestId, 'message_id': instance.messageId, + 'request_id': instance.requestId, 'message': instance.message, 'sending_status': _$SendingStatusEnumMap[instance.sendingStatus], 'is_reply_to_channel': instance.isReplyToChannel, diff --git a/lib/src/public/core/user/restricted_user.dart b/lib/src/public/core/user/restricted_user.dart index 2dc5f69f..036a6959 100644 --- a/lib/src/public/core/user/restricted_user.dart +++ b/lib/src/public/core/user/restricted_user.dart @@ -58,13 +58,13 @@ class RestrictedUser extends User { @JsonSerializable(createToJson: false) class RestrictionInfo { /// Description of the restriction. - final String? description; + String? description; /// End time of the restriction. - final int? endAt; + int? endAt; /// [RestrictionType] of the current user. - final RestrictionType restrictionType; + RestrictionType restrictionType; RestrictionInfo({ this.description, diff --git a/lib/src/public/core/user/sender.dart b/lib/src/public/core/user/sender.dart index 9c832669..7e4f597b 100644 --- a/lib/src/public/core/user/sender.dart +++ b/lib/src/public/core/user/sender.dart @@ -16,7 +16,7 @@ part 'sender.g.dart'; @JsonSerializable(createToJson: false) class Sender extends User { /// Whether this sender is blocked by [SendbirdChat.currentUser]. - final bool isBlockedByMe; + bool isBlockedByMe; /// The [Role] of this sender in the current channel. /// If the sender's role status changes after the field value allocation, diff --git a/lib/src/public/main/chat/sendbird_chat.dart b/lib/src/public/main/chat/sendbird_chat.dart index 25752487..d26d5c34 100644 --- a/lib/src/public/main/chat/sendbird_chat.dart +++ b/lib/src/public/main/chat/sendbird_chat.dart @@ -2,6 +2,7 @@ import 'dart:async'; +import 'package:flutter/foundation.dart'; import 'package:sendbird_chat_sdk/src/internal/main/chat/chat.dart'; import 'package:sendbird_chat_sdk/src/internal/main/logger/sendbird_logger.dart'; import 'package:sendbird_chat_sdk/src/public/core/channel/base_channel/base_channel.dart'; @@ -40,6 +41,9 @@ class SendbirdChat { /// Alternative push template static const String pushTemplateAlternative = 'alternative'; + /// Max int value + static int get maxInt => kIsWeb ? 9007199254740991 : double.maxFinite.toInt(); + static final SendbirdChat _instance = SendbirdChat._internal(); SendbirdChat._internal() @@ -57,16 +61,22 @@ class SendbirdChat { // Chat //------------------------------// /// Initializes SendbirdChat with given app ID. - static void init({ + static Future init({ required String appId, SendbirdChatOptions? options, - }) { - if (appId == _instance._chat.chatContext.appId) { - return; - } - + }) async { + bool result = false; _instance._chat.chatContext.appId = appId; - if (options != null) _instance._chat.chatContext.options = options; + _instance._chat.chatContext.options = options ?? SendbirdChatOptions(); + + //+ [DBManager] + await _instance._chat.dbManager.init(); + + _instance._chat.dbManager.appendLocalCacheStat( + useLocalCache: _instance._chat.chatContext.options.useCollectionCaching, + ); + //- [DBManager] + return result; } /// Current SDK version. @@ -691,4 +701,28 @@ class SendbirdChat { _instance._chat.refreshNotificationCollections(); } + +//------------------------------// +// useCollectionCaching +//------------------------------// + /// Gets cached data size. (Bytes) + /// Refer to [SendbirdChatOptions.useCollectionCaching]. + /// @since 4.2.0 + static Future getCachedDataSize() async { + return await _instance._chat.getCachedDataSize(); + } + + /// Clears all cached data. + /// Refer to [SendbirdChatOptions.useCollectionCaching]. + /// @since 4.2.0 + static Future clearCachedData() async { + await _instance._chat.clearCachedData(); + } + + /// Clears cached messages regarding [channelUrl]. + /// Refer to [SendbirdChatOptions.useCollectionCaching]. + /// @since 4.2.0 + static Future clearCachedMessages(String channelUrl) async { + await _instance._chat.clearCachedMessages(channelUrl); + } } diff --git a/lib/src/public/main/chat/sendbird_chat_options.dart b/lib/src/public/main/chat/sendbird_chat_options.dart index f978955c..acdf805e 100644 --- a/lib/src/public/main/chat/sendbird_chat_options.dart +++ b/lib/src/public/main/chat/sendbird_chat_options.dart @@ -1,15 +1,18 @@ // Copyright (c) 2023 Sendbird, Inc. All rights reserved. +import 'package:flutter/foundation.dart'; import 'package:sendbird_chat_sdk/sendbird_chat_sdk.dart'; /// The SendbirdChatOptions class for [SendbirdChat.init]. class SendbirdChatOptions { + static const defaultUseCollectionCaching = kIsWeb ? false : true; static const defaultConnectionTimeout = 10; static const defaultWebSocketTimeout = 30; static const defaultFileTransferTimeout = 30; static const defaultTypingIndicatorThrottle = 1000; static const defaultUseMemberInfoInMessage = true; + bool _useCollectionCaching = defaultUseCollectionCaching; int _connectionTimeout = defaultConnectionTimeout; int _webSocketTimeout = defaultWebSocketTimeout; int _fileTransferTimeout = defaultFileTransferTimeout; @@ -17,12 +20,14 @@ class SendbirdChatOptions { bool _useMemberInfoInMessage = defaultUseMemberInfoInMessage; SendbirdChatOptions({ + bool? useCollectionCaching = defaultUseCollectionCaching, int? connectionTimeout = defaultConnectionTimeout, int? webSocketTimeout = defaultWebSocketTimeout, int? fileTransferTimeout = defaultFileTransferTimeout, int? typingIndicatorThrottle = defaultTypingIndicatorThrottle, bool? useMemberInfoInMessage = defaultUseMemberInfoInMessage, }) { + this.useCollectionCaching = useCollectionCaching; this.connectionTimeout = connectionTimeout; this.webSocketTimeout = webSocketTimeout; this.fileTransferTimeout = fileTransferTimeout; @@ -30,6 +35,15 @@ class SendbirdChatOptions { this.useMemberInfoInMessage = useMemberInfoInMessage; } + bool get useCollectionCaching => _useCollectionCaching; + + /// If set `true`, the local caching for collection will be worked. + /// The default value is `true`. + /// @since 4.2.0 + set useCollectionCaching(value) { + _useCollectionCaching = value; + } + int get connectionTimeout => _connectionTimeout; /// Sets the timeout for connection. If there is a timeout error @@ -87,7 +101,7 @@ class SendbirdChatOptions { /// 2. [BaseMessage.mentionedUsers] /// such as nickname and profile url will be returned as the same with channel members. /// Otherwise, the information will be the value of the message's creation time. - /// The default value is true. + /// The default value is `true`. set useMemberInfoInMessage(value) { _useMemberInfoInMessage = value; } diff --git a/lib/src/public/main/collection/collection_event_source.dart b/lib/src/public/main/collection/collection_event_source.dart index 3f6f9b15..266f7f6d 100644 --- a/lib/src/public/main/collection/collection_event_source.dart +++ b/lib/src/public/main/collection/collection_event_source.dart @@ -4,6 +4,7 @@ /// [isFromEvent] is true only when it comes from the socket. enum CollectionEventSource { // Channel (isFromEvent = false) + channelCacheLoadMore(false), // loadMore() channelLoadMore(false), // loadMore() channelChangeLogs(false), // onReconnectSucceeded() @@ -36,16 +37,19 @@ enum CollectionEventSource { eventPinnedMessageUpdated(true), // onChannelUpdated() // Message (isFromEvent = false) + messageCacheInitialize(false), // initialize() + messageCacheLoadPrevious(false), // loadPrevious() + messageCacheLoadNext(false), // loadNext() messageInitialize(false), // initialize() messageLoadPrevious(false), // loadPrevious() messageLoadNext(false), // loadNext() messageChangeLogs(false), // onReconnectSucceeded() pollChangeLogs(false), // onReconnectSucceeded() - messagesGap(false), // onReconnectSucceeded() - // localMessagePendingCreated(false), // TODO: (?) - // localMessageFailed(false), // TODO: (?) - // localMessageCanceled(false), // TODO: (?) - // localMessageResendStarted(false), // TODO: (?) + messageFill(false), // onReconnectSucceeded() + localMessagePendingCreated(false), // sendUserMessage(), sendFileMessage() + localMessageFailed(false), // sendUserMessage(), sendFileMessage() + localMessageCanceled(false), // sendFileMessage() + localMessageResendStarted(false), // resendUserMessage(), resendFileMessage() // Message (isFromEvent = true) eventMessageSent(true), // onMessageAdded() diff --git a/lib/src/public/main/collection/group_channel_collection/group_channel_collection.dart b/lib/src/public/main/collection/group_channel_collection/group_channel_collection.dart index 98fe68fc..69521319 100644 --- a/lib/src/public/main/collection/group_channel_collection/group_channel_collection.dart +++ b/lib/src/public/main/collection/group_channel_collection/group_channel_collection.dart @@ -1,6 +1,9 @@ // Copyright (c) 2023 Sendbird, Inc. All rights reserved. +import 'dart:async'; + import 'package:sendbird_chat_sdk/sendbird_chat_sdk.dart'; +import 'package:sendbird_chat_sdk/src/internal/db/schema/channel/meta/channel_info.dart'; import 'package:sendbird_chat_sdk/src/internal/main/chat/chat.dart'; import 'package:sendbird_chat_sdk/src/internal/main/chat_manager/collection_manager/collection_manager.dart'; import 'package:sendbird_chat_sdk/src/internal/main/logger/sendbird_logger.dart'; @@ -14,10 +17,10 @@ class GroupChannelCollection { GroupChannelCollectionHandler get handler => _handler; /// Whether there's more data to load. - bool get hasMore => _isLoaded ? _query.hasNext : false; + bool get hasMore => _hasMore; /// Whether this collection is loading. - bool get isLoading => _query.isLoading; + bool get isLoading => _isLoading; /// Whether this collection is disposed. bool get isDisposed => _isDisposed; @@ -25,8 +28,16 @@ class GroupChannelCollection { final GroupChannelListQuery _query; final GroupChannelCollectionHandler _handler; final Chat _chat; - bool _isLoaded = false; + bool _isLoadedOnce = false; bool _isDisposed = false; + bool _isLoading = false; + bool _hasMore = true; + + //+ [DBManager] + int _fetchedCount = 0; + int _offset = 0; + + //- [DBManager] /// Constructor GroupChannelCollection({ @@ -37,6 +48,51 @@ class GroupChannelCollection { _chat = query.chat { sbLog.i(StackTrace.current, 'GroupChannelCollection()'); _chat.collectionManager.addGroupChannelCollection(this); + + if (_chat.dbManager.isEnabled()) { + runZonedGuarded(() { + _doBackSync(); // Do not await for performance + }, (error, stack) {}); + + runZonedGuarded(() { + _chat.collectionManager + .refreshGroupChannelCollections(); // Do not await for performance + }, (error, stack) {}); + } + + //+ [DBManager] + _chat.dbManager.appendLocalCacheStat( + useLocalCache: _chat.chatContext.options.useCollectionCaching, + useGroupChannelCollection: true, + ); + //- [DBManager] + } + + Future _doBackSync() async { + if (_chat.dbManager.isEnabled()) { + final info = await _chat.dbManager.getChannelInfo(); + if (info == null || info.isChannelBackSyncCompleted == false) { + final backSyncQuery = GroupChannelListQuery() + ..limit = 100 + ..order = GroupChannelListQueryOrder.chronological + ..includeChatNotification = false; // Unsupported filter + + do { + final channels = await backSyncQuery.next(); + if (channels.isNotEmpty) { + await _chat.dbManager.upsertGroupChannels(channels); + } + } while (backSyncQuery.hasNext); + + ChannelInfo? channelInfo = await _chat.dbManager.getChannelInfo(); + if (channelInfo != null) { + channelInfo.isChannelBackSyncCompleted = true; + } else { + channelInfo = ChannelInfo(isChannelBackSyncCompleted: true); + } + await _chat.dbManager.upsertChannelInfo(channelInfo); + } + } } /// Disposes current [GroupChannelCollection] and stops all events from being received. @@ -49,20 +105,95 @@ class GroupChannelCollection { /// Loads next channel lists, depending on the [GroupChannelListQueryOrder] set in the current collection. Future loadMore() async { - if (_isDisposed) return; + if (_isDisposed) { + throw InvalidCollectionDisposedException(); + } sbLog.i(StackTrace.current, 'loadMore()'); - final channels = await _query.next(); - _isLoaded = true; + _isLoading = true; + _isLoadedOnce = true; + + //+ [DBManager] + List localChannels = []; + if (_chat.dbManager.isEnabled()) { + final info = await _chat.dbManager.getChannelInfo(); + if (info != null && info.isChannelBackSyncCompleted) { + final channels = await _chat.dbManager + .getGroupChannels(query: _query, offset: _offset); + if (channels.isNotEmpty) { + localChannels.addAll(channels); + } + + if (_query.limit == localChannels.length) { + final channels = await _chat.dbManager + .getGroupChannels(query: _query, offset: _offset + _query.limit); + _hasMore = channels.isNotEmpty; + } else { + _hasMore = false; + } + + if (localChannels.isNotEmpty) { + _chat.collectionManager.sendEventsToGroupChannelCollection( + channelCollection: this, + eventSource: CollectionEventSource.channelCacheLoadMore, + addedChannels: localChannels, + ); + } + } + } + //- [DBManager] + + try { + if (localChannels.isNotEmpty) { + //+ [DBManager] + if (_chat.dbManager.isEnabled()) { + _offset += localChannels.length; // Check + } + //- [DBManager] + } else { + final channels = await _query.next(); + + _hasMore = _query.hasNext; + + if (channels.isNotEmpty) { + //+ [DBManager] + if (_chat.dbManager.isEnabled()) { + final List addedChannels = [...channels]; + final Set deletedChannelUrls = + localChannels.map((e) => e.channelUrl).toSet(); + deletedChannelUrls.addAll( + channelList.sublist(_fetchedCount).map((e) => e.channelUrl)); - if (channels.isNotEmpty) { - _chat.collectionManager.sendEventsToGroupChannelCollection( - channelCollection: this, - eventSource: CollectionEventSource.channelLoadMore, - addedChannels: channels, - ); + _fetchedCount += channels.length; + _offset = _fetchedCount; + + _chat.collectionManager.sendEventsToGroupChannelCollection( + channelCollection: this, + eventSource: CollectionEventSource.channelLoadMore, + addedChannels: addedChannels, + deletedChannelUrls: deletedChannelUrls.toList(), + ); + } + //- [DBManager] + else { + _chat.collectionManager.sendEventsToGroupChannelCollection( + channelCollection: this, + eventSource: CollectionEventSource.channelLoadMore, + addedChannels: channels, + ); + } + } + } + } catch (e) { + //+ [DBManager] + if (_chat.dbManager.isEnabled()) { + _offset += localChannels.length; // Check + } + //- [DBManager] } + + _isLoading = false; } void sort() { @@ -84,12 +215,10 @@ class GroupChannelCollection { return 1; } else if (a.lastMessage != null && b.lastMessage != null) { return b.lastMessage!.createdAt.compareTo(a.lastMessage!.createdAt); - } else { - if (a.createdAt != null && b.createdAt != null) { - return b.createdAt!.compareTo(a.createdAt!); - } - return 0; + } else if (a.createdAt != null && b.createdAt != null) { + return b.createdAt!.compareTo(a.createdAt!); } + return 0; }); break; @@ -107,13 +236,15 @@ class GroupChannelCollection { bool canAddChannel( CollectionEventSource eventSource, - GroupChannel addedChannel, - ) { - if (eventSource == CollectionEventSource.channelLoadMore) { + GroupChannel addedChannel, { + bool checkToUpdateChannel = false, + }) { + if (eventSource == CollectionEventSource.channelCacheLoadMore || + eventSource == CollectionEventSource.channelLoadMore) { return true; } - if (channelList.isEmpty) { + if (_isLoadedOnce == false) { return false; } @@ -133,20 +264,21 @@ class GroupChannelCollection { case GroupChannelListQueryOrder.latestLastMessage: if (a.lastMessage != null && b.lastMessage == null) { // a < b + if (checkToUpdateChannel) return true; return false; } else if (a.lastMessage == null && b.lastMessage != null) { + // return true } else if (a.lastMessage != null && b.lastMessage != null) { if (b.lastMessage!.createdAt.compareTo(a.lastMessage!.createdAt) == -1) { // a.lastMessage!.createdAt > b.lastMessage!.createdAt + if (checkToUpdateChannel) return true; return false; } - } else { - if (a.createdAt != null && b.createdAt != null) { - if (b.createdAt!.compareTo(a.createdAt!) == -1) { - // a.createdAt > b.createdAt - return false; - } + } else if (a.createdAt != null && b.createdAt != null) { + if (b.createdAt!.compareTo(a.createdAt!) == -1) { + // a.createdAt > b.createdAt + return false; } } break; @@ -160,9 +292,11 @@ class GroupChannelCollection { case GroupChannelListQueryOrder.metadataValueAlphabetical: // TODO: (?) + // return true break; } } + return true; } } diff --git a/lib/src/public/main/collection/group_channel_message_collection/base_message_collection.dart b/lib/src/public/main/collection/group_channel_message_collection/base_message_collection.dart index d32bbd02..c8bc0e13 100644 --- a/lib/src/public/main/collection/group_channel_message_collection/base_message_collection.dart +++ b/lib/src/public/main/collection/group_channel_message_collection/base_message_collection.dart @@ -1,10 +1,14 @@ // Copyright (c) 2023 Sendbird, Inc. All rights reserved. +import 'dart:async'; + import 'package:sendbird_chat_sdk/sendbird_chat_sdk.dart'; import 'package:sendbird_chat_sdk/src/internal/main/chat/chat.dart'; import 'package:sendbird_chat_sdk/src/internal/main/chat_manager/collection_manager/collection_manager.dart'; +import 'package:sendbird_chat_sdk/src/internal/main/chat_manager/db_manager.dart'; import 'package:sendbird_chat_sdk/src/internal/main/logger/sendbird_logger.dart'; import 'package:sendbird_chat_sdk/src/internal/network/http/http_client/request/channel/message/channel_messages_get_request.dart'; +import 'package:uuid/uuid.dart'; /// The base message collection that handles message lists. /// @since 4.0.3 @@ -37,6 +41,8 @@ abstract class BaseMessageCollection { BaseMessageCollectionHandler get baseHandler => _handler; + set hasPrevious(value) => _hasPrevious = value; + set hasNext(value) => _hasNext = value; MessageListParams get loadPreviousParams => _loadPreviousParams; @@ -45,8 +51,16 @@ abstract class BaseMessageCollection { Chat get chat => _chat; + RootMessage? get oldestMessage => _oldestMessage; + RootMessage? get latestMessage => _latestMessage; + int? get oldestSyncedTimestamp => _oldestSyncedTimestamp; + + int? get latestSyncedTimestamp => _latestSyncedTimestamp; + + String get collectionId => _collectionId; + final BaseChannel _channel; final BaseMessageCollectionHandler _handler; @@ -54,15 +68,24 @@ abstract class BaseMessageCollection { final MessageListParams _loadPreviousParams; final MessageListParams _loadNextParams; final int _startingPoint; + final String _collectionId; + final Chat _chat; bool _isInitialized = false; bool _isDisposed = false; bool _isLoading = false; bool _hasPrevious = false; bool _hasNext = false; + RootMessage? _oldestMessage; RootMessage? _latestMessage; + //+ [DBManager] + int? _oldestSyncedTimestamp; + int? _latestSyncedTimestamp; + + //- [DBManager] + BaseMessageCollection({ required BaseChannel channel, required MessageListParams params, @@ -75,9 +98,23 @@ abstract class BaseMessageCollection { _loadNextParams = MessageListParams()..copyWith(params), _handler = handler, _startingPoint = startingPoint, + _collectionId = const Uuid().v1(), _chat = chat { sbLog.i(StackTrace.current, 'BaseMessageCollection()'); _chat.collectionManager.addMessageCollection(this); + + //+ [DBManager] + if (_chat.dbManager.isEnabled()) { + _chat.dbManager.hasMessages(baseChannel.channelUrl).then((hasMessages) { + if (hasMessages) { + runZonedGuarded(() { + _chat.collectionManager.refreshBaseMessageCollection( + this); // Do not await for performance + }, (error, stack) {}); + } + }); + } + //- [DBManager] } /// Disposes current [MessageCollection] and stops all events from being received. @@ -90,193 +127,538 @@ abstract class BaseMessageCollection { /// Initializes this collection from [startingPoint]. Future initialize() async { - if (_isDisposed) return; - if (_isInitialized) { - throw InvalidInitializationException(); - } + if (_isDisposed) throw InvalidCollectionDisposedException(); + if (_isInitialized) throw InvalidInitializationException(); sbLog.i(StackTrace.current, 'initialize()'); _isInitialized = true; - _initializeParams.inclusive = true; + //+ [DBManager] + if (_chat.dbManager.isEnabled()) { + _oldestSyncedTimestamp = null; + _latestSyncedTimestamp = null; + } + //- [DBManager] - final res = await _chat.apiClient - .send(ChannelMessagesGetRequest( - _chat, - channelType: ChannelType.group, - channelUrl: _channel.channelUrl, - params: _initializeParams.toJson(), - timestamp: _startingPoint, - checkingHasNext: true, - )); - final messages = res.messages; + //+ [DBManager] + bool isCacheHit = false; + final List localMessages = []; - if (_isDisposed) return; + if (_chat.dbManager.isEnabled()) { + final localInitializeParams = MessageListParams() + ..copyWith(_initializeParams); - if (messages.isNotEmpty) { - final oldestMessage = - _initializeParams.reverse ? messages.last : messages.first; - final latestMessage = - _initializeParams.reverse ? messages.first : messages.last; - _oldestMessage = oldestMessage; - _latestMessage = latestMessage; + final localPreviousMessages = await _chat.dbManager.getMessages( + channelType: _channel.channelType, + channelUrl: _channel.channelUrl, + sendingStatus: SendingStatus.succeeded, + timestamp: _startingPoint, + params: localInitializeParams..inclusive = false, + isPrevious: true, + ); - final maxCreatedAt = messages - .reduce((current, next) => - current.createdAt > next.createdAt ? current : next) - .createdAt; + List localStartingPointMessages = []; + if (_initializeParams.inclusive) { + final messages = await _chat.dbManager.getStartingPointMessages( + channelType: _channel.channelType, + channelUrl: _channel.channelUrl, + timestamp: _startingPoint, + ); + localStartingPointMessages.addAll(messages); + } - if (_startingPoint > maxCreatedAt) { - _hasPrevious = messages.length == _initializeParams.previousResultSize; - _hasNext = false; - } else if (_startingPoint == 0) { - _hasPrevious = false; - _hasNext = messages.length == _initializeParams.nextResultSize; + final localNextMessages = await _chat.dbManager.getMessages( + channelType: _channel.channelType, + channelUrl: _channel.channelUrl, + sendingStatus: SendingStatus.succeeded, + timestamp: _startingPoint, + params: localInitializeParams..inclusive = false, + isPrevious: false, + ); + + if (_initializeParams.reverse) { + localMessages.addAll(localNextMessages); + localMessages.addAll(localStartingPointMessages); + localMessages.addAll(localPreviousMessages); } else { - final previousMessages = - messages.where((e) => e.createdAt < _startingPoint).toList(); - final nextMessages = - messages.where((e) => e.createdAt > _startingPoint).toList(); - - _hasPrevious = previousMessages.length - - _getExistedMessageCountInMessageList(previousMessages) == - _initializeParams.previousResultSize; - _hasNext = nextMessages.length - - _getExistedMessageCountInMessageList(nextMessages) == - _initializeParams.nextResultSize; + localMessages.addAll(localPreviousMessages); + localMessages.addAll(localStartingPointMessages); + localMessages.addAll(localNextMessages); } - } else { - _hasPrevious = false; - _hasNext = false; + + isCacheHit = await _chat.dbManager.isCacheHit( + collection: this, + params: _initializeParams, + localMessages: localMessages, + lastSyncedTimeStamp: null, + loadType: MessageCollectionLoadType.initialize, + ); + + _setValuesForInitialize( + messages: localMessages, noMoreApiCall: isCacheHit); + + if (localMessages.isNotEmpty) { + await _chat.collectionManager.sendEventsToMessageCollection( + messageCollection: this, + baseChannel: _channel, + eventSource: CollectionEventSource.messageCacheInitialize, + sendingStatus: SendingStatus.succeeded, + addedMessages: localMessages, + isReversedAddedMessages: _initializeParams.reverse, + ); + } + + _initializeParams.includeMetaArray = true; + _initializeParams.includeReactions = true; + _initializeParams.includeThreadInfo = true; + _initializeParams.includeParentMessageInfo = true; + } + //- [DBManager] + + List messages = []; + ChannelMessagesGetResponse? res; + + if (isCacheHit == false) { + try { + res = await _chat.apiClient + .send(ChannelMessagesGetRequest( + _chat, + channelType: ChannelType.group, + channelUrl: _channel.channelUrl, + params: _initializeParams.toJson(), + timestamp: _startingPoint, + checkingHasNext: true, + checkingContinuousMessages: + _chat.dbManager.isEnabled(), // [DBManager] + )); + + messages.addAll(res.messages); + } catch (_) {} } - if (res.hasNext != null) _hasNext = res.hasNext!; + if (_isDisposed) { + return; + } + + if (res != null) { + _setValuesForInitialize(messages: messages, noMoreApiCall: true); + } + + if (res?.hasNext != null) _hasNext = res!.hasNext!; if (messages.isNotEmpty) { - _chat.collectionManager.sendEventsToMessageCollection( - messageCollection: this, - baseChannel: _channel, - eventSource: CollectionEventSource.messageInitialize, - sendingStatus: SendingStatus.succeeded, - addedMessages: messages, - isReversedAddedMessages: _initializeParams.reverse, + //+ [DBManager] + if (_chat.dbManager.isEnabled()) { + final List addedMessages = [...messages]; + final Set deletedMessageIds = + messageList.map((message) => message.rootId).toSet(); + + await _chat.collectionManager.sendEventsToMessageCollection( + messageCollection: this, + baseChannel: _channel, + eventSource: CollectionEventSource.messageInitialize, + sendingStatus: SendingStatus.succeeded, + addedMessages: addedMessages, + isReversedAddedMessages: _initializeParams.reverse, + isContinuousAddedMessages: (_channel.channelType == ChannelType.feed) + ? true + : (res?.isContinuous ?? false), + deletedMessageIds: deletedMessageIds.toList(), + ); + } + //- [DBManager] + else { + await _chat.collectionManager.sendEventsToMessageCollection( + messageCollection: this, + baseChannel: _channel, + eventSource: CollectionEventSource.messageInitialize, + sendingStatus: SendingStatus.succeeded, + addedMessages: messages, + isReversedAddedMessages: _initializeParams.reverse, + ); + } + } + + //+ [DBManager] + if (_chat.dbManager.isEnabled()) { + // Failed messages + final failedMessages = await _chat.dbManager.getFailedMessages( + channelType: _channel.channelType, + channelUrl: _channel.channelUrl, + reverse: _initializeParams.reverse, ); + + if (failedMessages.isNotEmpty) { + await _chat.collectionManager.sendEventsToMessageCollection( + messageCollection: this, + baseChannel: _channel, + eventSource: CollectionEventSource.messageCacheInitialize, + sendingStatus: SendingStatus.failed, + addedMessages: failedMessages, + isReversedAddedMessages: _initializeParams.reverse, + ); + } } + //- [DBManager] } - /// Loads previous (oldest direction) message lists. - Future loadPrevious() async { - if (_isDisposed) { - throw InvalidCollectionDisposedException(); - } - if (!_isInitialized) return; + void _setValuesForInitialize({ + required List messages, + required bool noMoreApiCall, + }) { + if (messages.isNotEmpty) { + _oldestMessage = + _initializeParams.reverse ? messages.last : messages.first; + _latestMessage = + _initializeParams.reverse ? messages.first : messages.last; - if (_isLoading) throw QueryInProgressException(); - if (!_hasPrevious) return; - if (_oldestMessage == null) return; + //+ [DBManager] + if (_chat.dbManager.isEnabled()) { + if (noMoreApiCall) { + _oldestSyncedTimestamp = _oldestMessage!.createdAt; + _latestSyncedTimestamp = _latestMessage!.createdAt; + } + } + //- [DBManager] + + if (noMoreApiCall || !_chat.connectionManager.isConnected()) { + final maxCreatedAt = messages + .reduce((current, next) => + current.createdAt > next.createdAt ? current : next) + .createdAt; + + if (_startingPoint > maxCreatedAt) { + _hasPrevious = + messages.length == _initializeParams.previousResultSize; + _hasNext = false; + } else if (_startingPoint == 0) { + _hasPrevious = false; + _hasNext = messages.length == _initializeParams.nextResultSize; + } else { + final previousMessages = + messages.where((e) => e.createdAt < _startingPoint).toList(); + final nextMessages = + messages.where((e) => e.createdAt > _startingPoint).toList(); + + _hasPrevious = + (previousMessages.length == _initializeParams.previousResultSize); + _hasNext = (nextMessages.length == _initializeParams.nextResultSize); + } + } + } else { + if (noMoreApiCall || !_chat.connectionManager.isConnected()) { + _hasPrevious = false; + _hasNext = false; + } + } + } + /// Loads previous (oldest direction) message lists. + Future loadPrevious() async { sbLog.i(StackTrace.current, 'loadPrevious()'); - _isLoading = true; + await _loadMore(isPrevious: true); + } - _loadPreviousParams - ..nextResultSize = 0 - ..inclusive = true; + /// Loads next (latest direction) message lists. + Future loadNext() async { + sbLog.i(StackTrace.current, 'loadNext()'); + await _loadMore(isPrevious: false); + } - final res = await _chat.apiClient - .send(ChannelMessagesGetRequest( - _chat, - channelType: ChannelType.group, - channelUrl: _channel.channelUrl, - params: _loadPreviousParams.toJson(), - timestamp: _oldestMessage!.createdAt, - )); - final messages = res.messages; + Future _loadMore({ + required bool isPrevious, + }) async { + if (_isDisposed) throw InvalidCollectionDisposedException(); + if (!_isInitialized) return; + if (_isLoading) throw QueryInProgressException(); - if (_isDisposed) return; + if (isPrevious) { + if (!_hasPrevious) return; + if (_oldestMessage == null) return; + } else { + if (!_hasNext) return; + if (_latestMessage == null) return; + } - if (messages.isNotEmpty) { - final oldestMessage = - _loadPreviousParams.reverse ? messages.last : messages.first; - _oldestMessage = oldestMessage; + _isLoading = true; - _hasPrevious = - messages.length - _getExistedMessageCountInMessageList(messages) == - _loadPreviousParams.previousResultSize; + if (isPrevious) { + _loadPreviousParams + ..nextResultSize = 0 + ..inclusive = true; } else { - _hasPrevious = false; + _loadNextParams + ..nextResultSize = (_loadNextParams.nextResultSize != 0 + ? _loadNextParams.nextResultSize + : _loadNextParams.previousResultSize) // Check + ..previousResultSize = 0 + ..inclusive = true; } - _isLoading = false; + final timestamp = isPrevious + ? (_oldestMessage?.createdAt ?? _startingPoint) + : (_latestMessage?.createdAt ?? _startingPoint); - if (messages.isNotEmpty) { - _chat.collectionManager.sendEventsToMessageCollection( - messageCollection: this, - baseChannel: baseChannel, - eventSource: CollectionEventSource.messageLoadPrevious, + //+ [DBManager] + bool isCacheHit = false; + List localMessages = []; + List targetMessages = [...messageList]; + + if (_chat.dbManager.isEnabled()) { + final messages = await _chat.dbManager.getMessages( + channelType: _channel.channelType, + channelUrl: _channel.channelUrl, sendingStatus: SendingStatus.succeeded, - addedMessages: messages, - isReversedAddedMessages: - !_loadPreviousParams.reverse, // Added ! because of loadPrevious() + timestamp: timestamp, + params: isPrevious + ? (_loadPreviousParams..inclusive = false) + : (_loadNextParams..inclusive = false), + isPrevious: isPrevious, ); + localMessages.addAll(messages); + + isCacheHit = await _chat.dbManager.isCacheHit( + collection: this, + params: isPrevious ? _loadPreviousParams : _loadNextParams, + localMessages: localMessages, + lastSyncedTimeStamp: + isPrevious ? _oldestSyncedTimestamp : _latestSyncedTimestamp, + loadType: isPrevious + ? MessageCollectionLoadType.loadPrevious + : MessageCollectionLoadType.loadNext, + ); + + if (isPrevious) { + _setValuesForLoadPrevious( + messages: localMessages, + targetMessages: targetMessages, + noMoreApiCall: isCacheHit, + ); + } else { + _setValuesForLoadNext( + messages: localMessages, + targetMessages: targetMessages, + noMoreApiCall: isCacheHit, + ); + } + + if (localMessages.isNotEmpty) { + await _chat.collectionManager.sendEventsToMessageCollection( + messageCollection: this, + baseChannel: baseChannel, + eventSource: isPrevious + ? CollectionEventSource.messageCacheLoadPrevious + : CollectionEventSource.messageCacheLoadNext, + sendingStatus: SendingStatus.succeeded, + addedMessages: localMessages, + isReversedAddedMessages: isPrevious + ? !_loadPreviousParams + .reverse // Added ! because of loadPrevious() + : _loadNextParams.reverse); + } + + if (isPrevious) { + _loadPreviousParams.includeMetaArray = true; + _loadPreviousParams.includeReactions = true; + _loadPreviousParams.includeThreadInfo = true; + _loadPreviousParams.includeParentMessageInfo = true; + } else { + _loadNextParams.includeMetaArray = true; + _loadNextParams.includeReactions = true; + _loadNextParams.includeThreadInfo = true; + _loadNextParams.includeParentMessageInfo = true; + } + } + //- [DBManager] + + List messages = []; + bool? hasNext; + ChannelMessagesGetResponse? res; + + if (isCacheHit == false) { + try { + res = await _chat.apiClient + .send(ChannelMessagesGetRequest( + _chat, + channelType: ChannelType.group, + channelUrl: _channel.channelUrl, + params: isPrevious + ? (_loadPreviousParams..inclusive = true).toJson() + : (_loadNextParams..inclusive = true).toJson(), + timestamp: timestamp, + checkingHasNext: !isPrevious, + checkingContinuousMessages: + _chat.dbManager.isEnabled(), // [DBManager] + )); + + messages.addAll(res.messages); + hasNext = res.hasNext; + } catch (_) {} } - } - /// Loads next (latest direction) message lists. - Future loadNext() async { if (_isDisposed) { - throw InvalidCollectionDisposedException(); + _isLoading = false; + return; } - if (!_isInitialized) return; - if (_isLoading) throw QueryInProgressException(); - if (!_hasNext) return; - if (_latestMessage == null) return; + if (res != null) { + if (isPrevious) { + _setValuesForLoadPrevious( + messages: messages, + targetMessages: targetMessages, + noMoreApiCall: true, + ); + } else { + _setValuesForLoadNext( + messages: messages, + targetMessages: targetMessages, + noMoreApiCall: true, + ); + } + } + if (hasNext != null) _hasNext = hasNext; - sbLog.i(StackTrace.current, 'loadNext()'); - _isLoading = true; + if (messages.isNotEmpty) { + //+ [DBManager] + if (_chat.dbManager.isEnabled()) { + final List addedMessages = [...messages]; + final Set deletedMessageIds = + localMessages.map((message) => message.rootId).toSet(); + + await _chat.collectionManager.sendEventsToMessageCollection( + messageCollection: this, + baseChannel: baseChannel, + eventSource: isPrevious + ? CollectionEventSource.messageLoadPrevious + : CollectionEventSource.messageLoadNext, + sendingStatus: SendingStatus.succeeded, + addedMessages: addedMessages, + isReversedAddedMessages: isPrevious + ? !_loadPreviousParams + .reverse // Added ! because of loadPrevious() + : _loadNextParams.reverse, + isContinuousAddedMessages: (_channel.channelType == ChannelType.feed) + ? true + : (res?.isContinuous ?? false), + deletedMessageIds: deletedMessageIds.toList(), + ); + } + //- [DBManager] + else { + await _chat.collectionManager.sendEventsToMessageCollection( + messageCollection: this, + baseChannel: baseChannel, + eventSource: isPrevious + ? CollectionEventSource.messageLoadPrevious + : CollectionEventSource.messageLoadNext, + sendingStatus: SendingStatus.succeeded, + addedMessages: messages, + isReversedAddedMessages: isPrevious + ? !_loadPreviousParams + .reverse // Added ! because of loadPrevious() + : _loadNextParams.reverse, + ); + } + } - _loadNextParams - ..previousResultSize = 0 - ..inclusive = true; + _isLoading = false; + } - final res = await _chat.apiClient - .send(ChannelMessagesGetRequest( - _chat, - channelType: ChannelType.group, - channelUrl: _channel.channelUrl, - params: _loadNextParams.toJson(), - timestamp: _latestMessage!.createdAt, - checkingHasNext: true, - )); - final messages = res.messages; + void _setValuesForLoadPrevious({ + required List messages, + required List targetMessages, + required bool noMoreApiCall, + }) { + if (messages.isNotEmpty) { + _oldestMessage = + _loadPreviousParams.reverse ? messages.last : messages.first; - if (_isDisposed) return; + //+ [DBManager] + if (_chat.dbManager.isEnabled()) { + if (noMoreApiCall) { + _oldestSyncedTimestamp = _oldestMessage!.createdAt; + } + } + //- [DBManager] + if (noMoreApiCall || !_chat.connectionManager.isConnected()) { + final count = _getExistedMessageCountInMessageList( + loadedMessages: messages, targetMessages: targetMessages); + _hasPrevious = + messages.length - count == _loadPreviousParams.previousResultSize; + } + } else { + if (noMoreApiCall || !_chat.connectionManager.isConnected()) { + _hasPrevious = false; + } + } + } + + void _setValuesForLoadNext({ + required List messages, + required List targetMessages, + required bool noMoreApiCall, + }) { if (messages.isNotEmpty) { - final latestMessage = - _loadNextParams.reverse ? messages.first : messages.last; - _latestMessage = latestMessage; + _latestMessage = _loadNextParams.reverse ? messages.first : messages.last; + + //+ [DBManager] + if (_chat.dbManager.isEnabled()) { + if (noMoreApiCall) { + _latestSyncedTimestamp = _latestMessage!.createdAt; + } + } + //- [DBManager] - _hasNext = - messages.length - _getExistedMessageCountInMessageList(messages) == - _loadNextParams.nextResultSize; + if (noMoreApiCall || !_chat.connectionManager.isConnected()) { + final count = _getExistedMessageCountInMessageList( + loadedMessages: messages, targetMessages: targetMessages); + _hasNext = messages.length - count == _loadNextParams.nextResultSize; + } } else { - _hasNext = false; + if (noMoreApiCall || !_chat.connectionManager.isConnected()) { + _hasNext = false; + } } + } - if (res.hasNext != null) _hasNext = res.hasNext!; + int _getExistedMessageCountInMessageList({ + required List loadedMessages, + required List targetMessages, + }) { + int existedMessageCount = 0; + for (final loadedMessage in loadedMessages) { + for (final message in targetMessages) { + if (loadedMessage.getMessageId() == message.getMessageId()) { + existedMessageCount++; + break; + } + } + } + return existedMessageCount; + } - _isLoading = false; + void setValuesFromMessageList() { + if (messageList.isNotEmpty) { + _oldestMessage = + _loadPreviousParams.reverse ? messageList.last : messageList.first; + _latestMessage = + _loadNextParams.reverse ? messageList.first : messageList.last; - if (messages.isNotEmpty) { - _chat.collectionManager.sendEventsToMessageCollection( - messageCollection: this, - baseChannel: baseChannel, - eventSource: CollectionEventSource.messageLoadNext, - sendingStatus: SendingStatus.succeeded, - addedMessages: messages, - isReversedAddedMessages: _loadNextParams.reverse, - ); + _oldestSyncedTimestamp = _oldestMessage!.createdAt; + _latestSyncedTimestamp = _latestMessage!.createdAt; + } + } + + void sort() { + if (params.reverse) { + messageList.sort((a, b) { + return b.createdAt.compareTo(a.createdAt); + }); + } else { + messageList.sort((a, b) { + return a.createdAt.compareTo(b.createdAt); + }); } } @@ -284,36 +666,168 @@ abstract class BaseMessageCollection { CollectionEventSource eventSource, RootMessage addedMessage, ) { - if (eventSource == CollectionEventSource.messageLoadPrevious || - eventSource == CollectionEventSource.messageLoadNext) { + if (eventSource == CollectionEventSource.messageCacheInitialize || + eventSource == CollectionEventSource.messageCacheLoadPrevious || + eventSource == CollectionEventSource.messageCacheLoadNext || + eventSource == CollectionEventSource.messageInitialize || + eventSource == CollectionEventSource.messageLoadPrevious || + eventSource == CollectionEventSource.messageLoadNext || + eventSource == CollectionEventSource.messageFill || + eventSource == CollectionEventSource.localMessagePendingCreated || + eventSource == CollectionEventSource.localMessageFailed || + eventSource == CollectionEventSource.localMessageCanceled || + eventSource == CollectionEventSource.localMessageResendStarted) { return true; } - if (messageList.isEmpty) { + if (_isInitialized == false) { return false; } - if (messageList.isNotEmpty && hasNext) { - final a = messageList.last; - final b = addedMessage; + // hasPrevious + if (hasPrevious) { + if (messageList.isNotEmpty) { + if (addedMessage.createdAt < messageList.first.createdAt) { + return false; + } + } + } + + // hasNext + if (hasNext) { + if (messageList.isNotEmpty) { + if (addedMessage.createdAt > messageList.first.createdAt) { + return false; + } + } + } + + // [Filter] messageType + switch (params.messageType) { + case MessageTypeFilter.all: + break; + case MessageTypeFilter.user: + if (addedMessage.messageType == MessageType.file || + addedMessage.messageType == MessageType.admin || + addedMessage.messageType == MessageType.notification) { + return false; + } + break; + case MessageTypeFilter.file: + if (addedMessage.messageType == MessageType.user || + addedMessage.messageType == MessageType.admin || + addedMessage.messageType == MessageType.notification) { + return false; + } + break; + case MessageTypeFilter.admin: + if (addedMessage.messageType == MessageType.user || + addedMessage.messageType == MessageType.file || + addedMessage.messageType == MessageType.notification) { + return false; + } + break; + } + + // [Filter] customTypes + if (params.customTypes != null && params.customTypes!.isNotEmpty) { + bool found = false; + for (final customType in params.customTypes!) { + if (addedMessage.customType == customType) { + found = true; + break; + } + } + + if (!found) { + return false; + } + } + + // [Filter] senderIds + if (addedMessage is BaseMessage && + params.senderIds != null && + params.customTypes!.isNotEmpty) { + bool found = false; + for (final senderId in params.senderIds!) { + if (addedMessage.sender?.userId == senderId) { + found = true; + break; + } + } - if (a.createdAt < b.createdAt) { + if (!found) { return false; } } + return true; } - int _getExistedMessageCountInMessageList(List loadedMessages) { - int existedMessageCount = 0; - for (final loadedMessage in loadedMessages) { - for (final message in messageList) { - if (loadedMessage.getMessageId() == message.getMessageId()) { - existedMessageCount++; - break; + bool canUpdateMessage( + CollectionEventSource eventSource, + RootMessage originalMessage, + RootMessage updatedMessage, + ) { + bool canUpdate = false; + + if (!canAddMessage(eventSource, updatedMessage)) { + return false; + } + + if (eventSource == CollectionEventSource.pollChangeLogs || + eventSource == CollectionEventSource.eventPollVoted || + eventSource == CollectionEventSource.eventPollUpdated) { + if (originalMessage is UserMessage && + originalMessage.poll != null && + updatedMessage is UserMessage && + updatedMessage.poll != null && + originalMessage.poll!.updatedAt <= updatedMessage.poll!.updatedAt) { + canUpdate = true; + } + } else if (eventSource == CollectionEventSource.eventReactionUpdated) { + // Check updatedAt (?) + canUpdate = true; + } else if (eventSource == CollectionEventSource.eventThreadInfoUpdated) { + // Check updatedAt (?) + canUpdate = true; + } else if (originalMessage.updatedAt < updatedMessage.updatedAt) { + canUpdate = true; + } else if (updatedMessage is BaseMessage && + (updatedMessage.sendingStatus == SendingStatus.failed || + updatedMessage.sendingStatus == SendingStatus.pending)) { + canUpdate = true; + } + + return canUpdate; + } + + /// Sends mark as read to this channel. + /// This method has to be called in [MessageCollectionHandler.onMessagesAdded] or [NotificationCollectionHandler.onMessagesAdded]. + /// @since 4.2.0 + Future markAsRead(BaseMessageContext context) async { + sbLog.i(StackTrace.current); + + // 1. hasNext == false + if (hasNext == false) { + // 2. No filters + if (params.messageType == MessageTypeFilter.all && + params.customTypes == null && + params.senderIds == null && + params.showSubChannelMessagesOnly == false) { + // 3. Check collectionEventSource + if (context.collectionEventSource.isFromEvent || + context.collectionEventSource == + CollectionEventSource.messageInitialize || + context.collectionEventSource == + CollectionEventSource.messageFill) { + if (baseChannel is GroupChannel) { + (baseChannel as GroupChannel).markAsRead(); + } else if (baseChannel is FeedChannel) { + (baseChannel as FeedChannel).markAsRead(); + } } } } - return existedMessageCount; } } diff --git a/lib/src/public/main/collection/group_channel_message_collection/message_collection.dart b/lib/src/public/main/collection/group_channel_message_collection/message_collection.dart index 495d72cf..4cc50833 100644 --- a/lib/src/public/main/collection/group_channel_message_collection/message_collection.dart +++ b/lib/src/public/main/collection/group_channel_message_collection/message_collection.dart @@ -2,7 +2,6 @@ import 'package:sendbird_chat_sdk/sendbird_chat_sdk.dart'; import 'package:sendbird_chat_sdk/src/internal/main/chat/chat.dart'; -import 'package:sendbird_chat_sdk/src/internal/main/extensions/extensions.dart'; import 'package:sendbird_chat_sdk/src/internal/main/logger/sendbird_logger.dart'; /// Message collection that handles message lists. @@ -32,9 +31,49 @@ class MessageCollection extends BaseMessageCollection { channel: channel, params: params, handler: handler, - startingPoint: startingPoint ?? IntMax.max, + startingPoint: startingPoint ?? SendbirdChat.maxInt, chat: chat ?? SendbirdChat().chat, ) { sbLog.i(StackTrace.current, 'MessageCollection()'); + + //+ [DBManager] + super.chat.dbManager.appendLocalCacheStat( + useLocalCache: super.chat.chatContext.options.useCollectionCaching, + useMessageCollection: true, + ); + //- [DBManager] + } + + /// Gets all failed messages of this MessageCollection + /// @since 4.2.0 + Future> getFailedMessages() async { + sbLog.i(StackTrace.current, 'getFailedMessages()'); + return await chat.dbManager.getFailedMessages( + channelType: ChannelType.group, + channelUrl: channel.channelUrl, + ); + } + + /// Removes specific failed messages of this MessageCollection. + /// @since 4.2.0 + Future removeFailedMessages({ + required List messages, + }) async { + sbLog.i(StackTrace.current, 'removeFailedMessages()'); + await chat.dbManager.removeFailedMessages( + channelType: ChannelType.group, + channelUrl: channel.channelUrl, + messages: messages, + ); + } + + /// Removes all failed messages of this MessageCollection. + /// @since 4.2.0 + Future removeAllFailedMessages() async { + sbLog.i(StackTrace.current, 'removeAllFailedMessages()'); + await chat.dbManager.removeAllFailedMessages( + channelType: ChannelType.group, + channelUrl: channel.channelUrl, + ); } } diff --git a/lib/src/public/main/collection/group_channel_message_collection/notification_collection.dart b/lib/src/public/main/collection/group_channel_message_collection/notification_collection.dart index 7342bb13..e0e84775 100644 --- a/lib/src/public/main/collection/group_channel_message_collection/notification_collection.dart +++ b/lib/src/public/main/collection/group_channel_message_collection/notification_collection.dart @@ -2,7 +2,6 @@ import 'package:sendbird_chat_sdk/sendbird_chat_sdk.dart'; import 'package:sendbird_chat_sdk/src/internal/main/chat/chat.dart'; -import 'package:sendbird_chat_sdk/src/internal/main/extensions/extensions.dart'; import 'package:sendbird_chat_sdk/src/internal/main/logger/sendbird_logger.dart'; /// Notification collection that handles message lists. @@ -37,7 +36,7 @@ class NotificationCollection extends BaseMessageCollection { channel: channel, params: params, handler: handler, - startingPoint: startingPoint ?? IntMax.max, + startingPoint: startingPoint ?? SendbirdChat.maxInt, chat: chat ?? SendbirdChat().chat, ) { sbLog.i(StackTrace.current, 'MessageCollection()'); diff --git a/lib/src/public/main/model/info/scheduled_info.dart b/lib/src/public/main/model/info/scheduled_info.dart index 4572fc3c..481c6f36 100644 --- a/lib/src/public/main/model/info/scheduled_info.dart +++ b/lib/src/public/main/model/info/scheduled_info.dart @@ -9,13 +9,13 @@ part 'scheduled_info.g.dart'; @JsonSerializable(createToJson: false) class ScheduledInfo { /// The ID of the scheduled message. - final int scheduledMessageId; + int scheduledMessageId; /// The scheduled time of this message. - final int scheduledAt; + int scheduledAt; /// The scheduled message sending status. - final ScheduledStatus scheduledStatus; + ScheduledStatus scheduledStatus; ScheduledInfo({ required this.scheduledMessageId, diff --git a/lib/src/public/main/model/message/message_meta_array.dart b/lib/src/public/main/model/message/message_meta_array.dart index f79cbdd1..2e7acfe1 100644 --- a/lib/src/public/main/model/message/message_meta_array.dart +++ b/lib/src/public/main/model/message/message_meta_array.dart @@ -12,7 +12,7 @@ class MessageMetaArray { final String key; /// The meta array value. - final List value; + List value; MessageMetaArray({ required this.key, diff --git a/lib/src/public/main/model/og/og_image.dart b/lib/src/public/main/model/og/og_image.dart index b5170aec..46717b87 100644 --- a/lib/src/public/main/model/og/og_image.dart +++ b/lib/src/public/main/model/og/og_image.dart @@ -21,25 +21,25 @@ abstract class OGDisplayable { class OGImage implements OGDisplayable, OGMedia { /// An image URL which represents the object within the Open Graph. @override - final String? url; + String? url; /// An alternate url to use if the webpage requires HTTPS. @override - final String? secureUrl; + String? secureUrl; /// A MIME type for this image. - final String? type; + String? type; /// A description of what is in the image (not a caption). - final String? alt; + String? alt; /// The number of pixels wide. @override - final int width; + int width; /// The number of pixels high. @override - final int height; + int height; OGImage({ this.url, diff --git a/lib/src/public/main/model/og/og_meta_data.dart b/lib/src/public/main/model/og/og_meta_data.dart index f9e64d14..b87fce73 100644 --- a/lib/src/public/main/model/og/og_meta_data.dart +++ b/lib/src/public/main/model/og/og_meta_data.dart @@ -12,23 +12,23 @@ part 'og_meta_data.g.dart'; class OGMetaData { /// The title of the object as it should appear within the graph. ex: "The Rock". @JsonKey(name: 'og:title') - final String? title; + String? title; /// The canonical URL of the object that can be used as its permanent ID in the graph. /// ex: "http://www.imdb.com/title/tt0117500/" @JsonKey(name: 'og:url') - final String? url; + String? url; /// A one to two sentence description of the object. /// ex: "Sean Connery found fame and fortune /// as the suave, sophisticated British agent, James Bond." @JsonKey(name: 'og:description') - final String? description; + String? description; /// An [ogImage] object that contains information about the image that this Open Graph /// points to. @JsonKey(name: 'og:image') - final OGImage? ogImage; + OGImage? ogImage; OGMetaData({ this.title, diff --git a/lib/src/public/main/model/poll/poll.dart b/lib/src/public/main/model/poll/poll.dart index 8ce06da0..820ae48d 100644 --- a/lib/src/public/main/model/poll/poll.dart +++ b/lib/src/public/main/model/poll/poll.dart @@ -36,7 +36,7 @@ class Poll { PollStatus status; /// A id of the message that contains this poll - final int? messageId; + int? messageId; /// An additional json data to accompany the poll. PollData? data; @@ -48,7 +48,7 @@ class Poll { List options = []; /// UserId of the poll creator. `null` if the creator account is removed. - final String? createdBy; + String? createdBy; /// True if this poll allows user suggestion, false otherwise. bool allowUserSuggestion = false; diff --git a/lib/src/public/main/model/thread/thread_info.dart b/lib/src/public/main/model/thread/thread_info.dart index c843433a..b1f2e745 100644 --- a/lib/src/public/main/model/thread/thread_info.dart +++ b/lib/src/public/main/model/thread/thread_info.dart @@ -10,15 +10,15 @@ part 'thread_info.g.dart'; class ThreadInfo { /// The total number of replies in a specific thread. /// A value of 0 indicates there is no reply in the thread. - final int replyCount; + int replyCount; /// Users who left a reply in the thread, based on the time the reply was added. @JsonKey(name: 'most_replies') - final List mostRepliesUsers; + List mostRepliesUsers; /// The time that the last reply was created, in Unix milliseconds format. /// A value of 0 indicates there is no reply in the thread. - final int lastRepliedAt; + int lastRepliedAt; int? updatedAt; diff --git a/lib/src/public/main/params/message/base_message_create_params.dart b/lib/src/public/main/params/message/base_message_create_params.dart index 83b83b8b..c89536a4 100644 --- a/lib/src/public/main/params/message/base_message_create_params.dart +++ b/lib/src/public/main/params/message/base_message_create_params.dart @@ -52,7 +52,7 @@ class BaseMessageCreateParams { BaseMessageCreateParams.withMessage(BaseMessage message) { data = message.data; customType = message.customType; - mentionType = message.mentionType ?? MentionType.users; + mentionType = message.mentionType; mentionedUserIds = message.mentionedUsers.map((e) => e.userId).toList(); metaArrays = message.allMetaArrays; parentMessageId = message.parentMessageId; diff --git a/lib/src/public/main/query/channel/feed_channel_list_query.dart b/lib/src/public/main/query/channel/feed_channel_list_query.dart index d1d84ac6..0edfa2d6 100644 --- a/lib/src/public/main/query/channel/feed_channel_list_query.dart +++ b/lib/src/public/main/query/channel/feed_channel_list_query.dart @@ -19,6 +19,11 @@ class FeedChannelListQuery extends BaseQuery { /// @since 4.0.3 bool includeEmpty = true; + //+ [DBManager] This will be supported in FeedChannelCollection because of some limitation. + // int _fetchedCount = 0; + // int _offset = 0; + //- [DBManager] + FeedChannelListQuery({ Chat? chat, }) : super(chat: chat ?? SendbirdChat().chat); @@ -44,22 +49,49 @@ class FeedChannelListQuery extends BaseQuery { ChannelListQueryIncludeOption.includeDeliveryReceipt, ]; - final res = await chat.apiClient.send( - FeedChannelListRequest( - chat, - limit: limit, - options: options, - token: token, - ), - ); + FeedChannelListQueryResponse res; + + try { + res = await chat.apiClient.send( + FeedChannelListRequest( + chat, + limit: limit, + options: options, + token: token, + ), + ); + + token = res.next; + hasNext = res.next != ''; + for (final element in res.channels) { + element.set(chat); + } + + //+ [DBManager] + // if (chat.dbManager.isEnabled()) { + // await chat.dbManager.upsertFeedChannels(res.channels); + // + // _fetchedCount += res.channels.length; + // _offset = _fetchedCount; + // } + //- [DBManager] + } catch (e) { + isLoading = false; - for (final element in res.channels) { - element.set(chat); + //+ [DBManager] + // if (chat.dbManager.isEnabled()) { + // final localChannels = + // await chat.dbManager.getFeedChannels(query: this, offset: _offset); + // _offset += localChannels.length; + // + // hasNext = (limit == localChannels.length); + // return localChannels; + // } + //- [DBManager] + rethrow; } isLoading = false; - token = res.next; - hasNext = res.next != ''; return res.channels; } } diff --git a/lib/src/public/main/query/channel/group_channel_list_query.dart b/lib/src/public/main/query/channel/group_channel_list_query.dart index 7775a1e5..2abb3c9f 100644 --- a/lib/src/public/main/query/channel/group_channel_list_query.dart +++ b/lib/src/public/main/query/channel/group_channel_list_query.dart @@ -24,10 +24,6 @@ class GroupChannelListQuery extends BaseQuery { GroupChannelListQueryOrder order = GroupChannelListQueryOrder.latestLastMessage; - /// [GroupChannelListQueryType] of [User] IDs filter. - /// Refer to [setUserIdsIncludeFilter] - GroupChannelListQueryType queryType = GroupChannelListQueryType.and; - /// List of channel URL filter. It will return `null` if channel URL filter hasn't been set before. /// [GroupChannel] list containing only and exactly the passed [GroupChannel] URLs will be returned. List channelUrlsFilter = []; @@ -69,6 +65,10 @@ class GroupChannelListQuery extends BaseQuery { /// [User] IDs include filter. List userIdsIncludeFilter = []; + /// [GroupChannelListQueryType] of [User] IDs filter. + /// Refer to [setUserIdsIncludeFilter] + GroupChannelListQueryType queryType = GroupChannelListQueryType.and; + /// [User] IDs exact filter.[GroupChannel] list containing only and exactly the passed [User] IDs will be returned. /// This does not cooperate with other filters. List userIdsExactFilter = []; @@ -244,29 +244,40 @@ class GroupChannelListQuery extends BaseQuery { ChannelListQueryIncludeOption.includeDeliveryReceipt, ]; - final res = - await chat.apiClient.send>( - GroupChannelListRequest( - chat, - limit: limit, - filter: filter, - options: options, - queryType: queryType, - token: token, - order: order, - channelUrls: channelUrlsFilter, - searchFields: searchFields, - searchQuery: searchQuery, - ), - ); - - for (final element in res.channels) { - element.set(chat); + ChannelListQueryResponse res; + try { + res = await chat.apiClient.send>( + GroupChannelListRequest( + chat, + limit: limit, + filter: filter, + options: options, + queryType: queryType, + token: token, + order: order, + channelUrls: channelUrlsFilter, + searchFields: searchFields, + searchQuery: searchQuery, + ), + ); + + token = res.next; + hasNext = res.next != ''; + for (final channel in res.channels) { + channel.set(chat); + } + + //+ [DBManager] + if (chat.dbManager.isEnabled()) { + await chat.dbManager.upsertGroupChannels(res.channels); + } + //- [DBManager] + } catch (_) { + isLoading = false; + rethrow; } isLoading = false; - token = res.next; - hasNext = res.next != ''; return res.channels; } } diff --git a/lib/src/public/main/query/message/previous_message_list_query.dart b/lib/src/public/main/query/message/previous_message_list_query.dart index 504188fe..c27c362c 100644 --- a/lib/src/public/main/query/message/previous_message_list_query.dart +++ b/lib/src/public/main/query/message/previous_message_list_query.dart @@ -1,7 +1,6 @@ // Copyright (c) 2023 Sendbird, Inc. All rights reserved. import 'package:sendbird_chat_sdk/src/internal/main/chat/chat.dart'; -import 'package:sendbird_chat_sdk/src/internal/main/extensions/extensions.dart'; import 'package:sendbird_chat_sdk/src/internal/main/logger/sendbird_logger.dart'; import 'package:sendbird_chat_sdk/src/internal/network/http/http_client/request/channel/message/channel_messages_get_request.dart'; import 'package:sendbird_chat_sdk/src/public/core/message/base_message.dart'; @@ -58,7 +57,7 @@ class PreviousMessageListQuery extends BaseQuery { /// The time of a request. /// After each call of [next], this value will change to the oldest [BaseMessage.createdAt] value of the message that have been fetched. - int? messageTimestamp = IntMax.max; + int? messageTimestamp = SendbirdChat.maxInt; PreviousMessageListQuery({ required this.channelType, diff --git a/pubspec.yaml b/pubspec.yaml index 7ce24a84..356544bd 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: sendbird_chat_sdk description: With Sendbird Chat for Flutter, you can easily build an in-app chat with all the essential messaging features. -version: 4.1.2 +version: 4.2.0 homepage: https://sendbird.com repository: https://github.com/sendbird/sendbird-chat-sdk-flutter documentation: https://sendbird.com/docs/chat/sdk/v4/flutter/getting-started/send-first-message @@ -14,6 +14,8 @@ platforms: ios: web: +isar_version: &isar_version 3.1.0+1 + dependencies: flutter: sdk: flutter @@ -30,6 +32,10 @@ dependencies: web_socket_channel: ^2.4.0 universal_io: ^2.2.0 async: ^2.10.0 + isar: *isar_version + isar_flutter_libs: *isar_version + path_provider: ^2.1.1 + path: ^1.8.2 dev_dependencies: flutter_test: @@ -39,3 +45,4 @@ dev_dependencies: stack_trace: ^1.11.0 json_serializable: ^6.6.2 build_runner: ^2.3.3 + isar_generator: *isar_version