diff --git a/lib/blaze/blaze.dart b/lib/blaze/blaze.dart index ddcc0575b0..33f67ae288 100644 --- a/lib/blaze/blaze.dart +++ b/lib/blaze/blaze.dart @@ -232,8 +232,9 @@ class Blaze { } Future makeMessageStatus(String messageId, MessageStatus status) async { - final currentStatus = - await database.messageDao.findMessageStatusById(messageId); + final currentStatus = await database.messageDao + .messageStatusById(messageId) + .getSingleOrNull(); if (currentStatus != null && status.index > currentStatus.index) { await database.messageDao.updateMessageStatusById(messageId, status); } @@ -261,7 +262,7 @@ class Blaze { } await Future.forEach(blazeMessages, (m) async { if (!(await makeMessageStatus(m.messageId, m.status))) { - final messagesHistory = await database.messagesHistoryDao + final messagesHistory = await database.messageHistoryDao .findMessageHistoryById(m.messageId); if (messagesHistory != null) return; diff --git a/lib/crypto/signal/dao/session_dao.dart b/lib/crypto/signal/dao/session_dao.dart index e1b1199cc6..a17587c477 100644 --- a/lib/crypto/signal/dao/session_dao.dart +++ b/lib/crypto/signal/dao/session_dao.dart @@ -1,6 +1,6 @@ +import 'package:collection/collection.dart'; import 'package:drift/drift.dart'; -import '../../../utils/extension/extension.dart'; import '../signal_database.dart'; part 'session_dao.g.dart'; diff --git a/lib/crypto/signal/signal_protocol.dart b/lib/crypto/signal/signal_protocol.dart index ab012f6231..2549d75a14 100644 --- a/lib/crypto/signal/signal_protocol.dart +++ b/lib/crypto/signal/signal_protocol.dart @@ -10,7 +10,7 @@ import 'package:uuid/uuid.dart'; import '../../blaze/blaze_message.dart'; import '../../blaze/blaze_message_param.dart'; -import '../../db/mixin_database.dart'; +import '../../db/dao/message_dao.dart'; import '../../enum/message_category.dart'; import '../../utils/extension/extension.dart'; import '../../utils/logger.dart'; diff --git a/lib/db/custom_vm_database_wrapper.dart b/lib/db/custom_vm_database_wrapper.dart index 197b01c5d0..842273dbb3 100644 --- a/lib/db/custom_vm_database_wrapper.dart +++ b/lib/db/custom_vm_database_wrapper.dart @@ -1,3 +1,4 @@ +import 'package:collection/collection.dart'; import 'package:drift/drift.dart'; import 'package:drift/native.dart'; import 'package:flutter/foundation.dart'; diff --git a/lib/db/dao/circle_conversation_dao.dart b/lib/db/dao/circle_conversation_dao.dart index 25b8de02f3..225d684c0c 100644 --- a/lib/db/dao/circle_conversation_dao.dart +++ b/lib/db/dao/circle_conversation_dao.dart @@ -5,7 +5,7 @@ import '../mixin_database.dart'; part 'circle_conversation_dao.g.dart'; -@DriftAccessor() +@DriftAccessor(include: {'../moor/dao/circle_conversation.drift'}) class CircleConversationDao extends DatabaseAccessor with _$CircleConversationDaoMixin { CircleConversationDao(super.db); @@ -23,13 +23,13 @@ class CircleConversationDao extends DatabaseAccessor ..where((tbl) => tbl.circleId.equals(circleId)); Future deleteByCircleId(String circleId) => - db.deleteByCircleId(circleId).then((value) { + _deleteByCircleId(circleId).then((value) { DataBaseEventBus.instance.updateCircleConversation(); return value; }); Future deleteById(String conversationId, String circleId) => - db.deleteByIds(conversationId, circleId).then((value) { + _deleteByIds(conversationId, circleId).then((value) { DataBaseEventBus.instance.updateCircleConversation(); return value; }); diff --git a/lib/db/dao/circle_conversation_dao.g.dart b/lib/db/dao/circle_conversation_dao.g.dart index d4ad7807d6..521f11f58f 100644 --- a/lib/db/dao/circle_conversation_dao.g.dart +++ b/lib/db/dao/circle_conversation_dao.g.dart @@ -3,4 +3,57 @@ part of 'circle_conversation_dao.dart'; // ignore_for_file: type=lint -mixin _$CircleConversationDaoMixin on DatabaseAccessor {} +mixin _$CircleConversationDaoMixin on DatabaseAccessor { + CircleConversations get circleConversations => + attachedDatabase.circleConversations; + Addresses get addresses => attachedDatabase.addresses; + Apps get apps => attachedDatabase.apps; + Assets get assets => attachedDatabase.assets; + Circles get circles => attachedDatabase.circles; + Conversations get conversations => attachedDatabase.conversations; + FloodMessages get floodMessages => attachedDatabase.floodMessages; + Hyperlinks get hyperlinks => attachedDatabase.hyperlinks; + Jobs get jobs => attachedDatabase.jobs; + MessageMentions get messageMentions => attachedDatabase.messageMentions; + Messages get messages => attachedDatabase.messages; + MessagesHistory get messagesHistory => attachedDatabase.messagesHistory; + Offsets get offsets => attachedDatabase.offsets; + ParticipantSession get participantSession => + attachedDatabase.participantSession; + Participants get participants => attachedDatabase.participants; + ResendSessionMessages get resendSessionMessages => + attachedDatabase.resendSessionMessages; + SentSessionSenderKeys get sentSessionSenderKeys => + attachedDatabase.sentSessionSenderKeys; + Snapshots get snapshots => attachedDatabase.snapshots; + StickerAlbums get stickerAlbums => attachedDatabase.stickerAlbums; + StickerRelationships get stickerRelationships => + attachedDatabase.stickerRelationships; + Stickers get stickers => attachedDatabase.stickers; + Users get users => attachedDatabase.users; + TranscriptMessages get transcriptMessages => + attachedDatabase.transcriptMessages; + PinMessages get pinMessages => attachedDatabase.pinMessages; + Fiats get fiats => attachedDatabase.fiats; + FavoriteApps get favoriteApps => attachedDatabase.favoriteApps; + ExpiredMessages get expiredMessages => attachedDatabase.expiredMessages; + Chains get chains => attachedDatabase.chains; + Properties get properties => attachedDatabase.properties; + Future _deleteByCircleId(String circleId) { + return customUpdate( + 'DELETE FROM circle_conversations WHERE circle_id = ?1', + variables: [Variable(circleId)], + updates: {circleConversations}, + updateKind: UpdateKind.delete, + ); + } + + Future _deleteByIds(String conversationId, String circleId) { + return customUpdate( + 'DELETE FROM circle_conversations WHERE conversation_id = ?1 AND circle_id = ?2', + variables: [Variable(conversationId), Variable(circleId)], + updates: {circleConversations}, + updateKind: UpdateKind.delete, + ); + } +} diff --git a/lib/db/dao/circle_dao.dart b/lib/db/dao/circle_dao.dart index dc06379451..1458534c63 100644 --- a/lib/db/dao/circle_dao.dart +++ b/lib/db/dao/circle_dao.dart @@ -5,7 +5,7 @@ import '../mixin_database.dart'; part 'circle_dao.g.dart'; -@DriftAccessor() +@DriftAccessor(include: {'../moor/dao/circle.drift'}) class CircleDao extends DatabaseAccessor with _$CircleDaoMixin { CircleDao(super.db); @@ -29,23 +29,10 @@ class CircleDao extends DatabaseAccessor with _$CircleDaoMixin { return value; }); - Selectable allCircles() => db.allCircles(); - - Selectable circleByConversationId( - String conversationId) => - db.circleByConversationId(conversationId); - Future findCircleById(String circleId) => (select(db.circles)..where((t) => t.circleId.equals(circleId))) .getSingleOrNull(); - Selectable otherCircleByConversationId( - String conversationId) => - db.otherCircleByConversationId(conversationId); - - Selectable circlesNameByConversationId(String conversationId) => - db.circlesNameByConversationId(conversationId); - Future updateOrders(List value) { final now = DateTime.now(); final newCircles = value.asMap().entries.map((e) { diff --git a/lib/db/dao/circle_dao.g.dart b/lib/db/dao/circle_dao.g.dart index a1be0ff2a4..290691dcfe 100644 --- a/lib/db/dao/circle_dao.g.dart +++ b/lib/db/dao/circle_dao.g.dart @@ -3,4 +3,180 @@ part of 'circle_dao.dart'; // ignore_for_file: type=lint -mixin _$CircleDaoMixin on DatabaseAccessor {} +mixin _$CircleDaoMixin on DatabaseAccessor { + Circles get circles => attachedDatabase.circles; + CircleConversations get circleConversations => + attachedDatabase.circleConversations; + Conversations get conversations => attachedDatabase.conversations; + Users get users => attachedDatabase.users; + Addresses get addresses => attachedDatabase.addresses; + Apps get apps => attachedDatabase.apps; + Assets get assets => attachedDatabase.assets; + FloodMessages get floodMessages => attachedDatabase.floodMessages; + Hyperlinks get hyperlinks => attachedDatabase.hyperlinks; + Jobs get jobs => attachedDatabase.jobs; + MessageMentions get messageMentions => attachedDatabase.messageMentions; + Messages get messages => attachedDatabase.messages; + MessagesHistory get messagesHistory => attachedDatabase.messagesHistory; + Offsets get offsets => attachedDatabase.offsets; + ParticipantSession get participantSession => + attachedDatabase.participantSession; + Participants get participants => attachedDatabase.participants; + ResendSessionMessages get resendSessionMessages => + attachedDatabase.resendSessionMessages; + SentSessionSenderKeys get sentSessionSenderKeys => + attachedDatabase.sentSessionSenderKeys; + Snapshots get snapshots => attachedDatabase.snapshots; + StickerAlbums get stickerAlbums => attachedDatabase.stickerAlbums; + StickerRelationships get stickerRelationships => + attachedDatabase.stickerRelationships; + Stickers get stickers => attachedDatabase.stickers; + TranscriptMessages get transcriptMessages => + attachedDatabase.transcriptMessages; + PinMessages get pinMessages => attachedDatabase.pinMessages; + Fiats get fiats => attachedDatabase.fiats; + FavoriteApps get favoriteApps => attachedDatabase.favoriteApps; + ExpiredMessages get expiredMessages => attachedDatabase.expiredMessages; + Chains get chains => attachedDatabase.chains; + Properties get properties => attachedDatabase.properties; + Selectable allCircles() { + return customSelect( + 'SELECT ci.circle_id, ci.name, ci.created_at, ci.ordered_at, COUNT(c.conversation_id) AS count, IFNULL(SUM(CASE WHEN IFNULL(c.unseen_message_count, 0) > 0 THEN 1 ELSE 0 END), 0) AS unseen_conversation_count, IFNULL(SUM(CASE WHEN(CASE WHEN c.category = \'GROUP\' THEN c.mute_until ELSE owner.mute_until END)>=(strftime(\'%s\', \'now\') * 1000)AND IFNULL(c.unseen_message_count, 0) > 0 THEN 1 ELSE 0 END), 0) AS unseen_muted_conversation_count FROM circles AS ci LEFT JOIN circle_conversations AS cc ON ci.circle_id = cc.circle_id LEFT JOIN conversations AS c ON c.conversation_id = cc.conversation_id LEFT JOIN users AS owner ON owner.user_id = c.owner_id GROUP BY ci.circle_id ORDER BY ci.ordered_at ASC, ci.created_at ASC', + variables: [], + readsFrom: { + circles, + conversations, + users, + circleConversations, + }).map((QueryRow row) { + return ConversationCircleItem( + circleId: row.read('circle_id'), + name: row.read('name'), + createdAt: + Circles.$convertercreatedAt.fromSql(row.read('created_at')), + orderedAt: NullAwareTypeConverter.wrapFromSql( + Circles.$converterorderedAt, row.readNullable('ordered_at')), + count: row.read('count'), + unseenConversationCount: row.read('unseen_conversation_count'), + unseenMutedConversationCount: + row.read('unseen_muted_conversation_count'), + ); + }); + } + + Selectable circleByConversationId( + String? conversationId) { + return customSelect( + 'SELECT ci.circle_id, ci.name, COUNT(c.conversation_id) AS count FROM circles AS ci LEFT JOIN circle_conversations AS cc ON ci.circle_id = cc.circle_id LEFT JOIN conversations AS c ON c.conversation_id = cc.conversation_id WHERE ci.circle_id IN (SELECT cir.circle_id FROM circles AS cir LEFT JOIN circle_conversations AS ccr ON cir.circle_id = ccr.circle_id WHERE ccr.conversation_id = ?1) GROUP BY ci.circle_id ORDER BY ci.ordered_at ASC, ci.created_at ASC', + variables: [ + Variable(conversationId) + ], + readsFrom: { + circles, + conversations, + circleConversations, + }).map((QueryRow row) { + return ConversationCircleManagerItem( + circleId: row.read('circle_id'), + name: row.read('name'), + count: row.read('count'), + ); + }); + } + + Selectable otherCircleByConversationId( + String? conversationId) { + return customSelect( + 'SELECT ci.circle_id, ci.name, COUNT(c.conversation_id) AS count FROM circles AS ci LEFT JOIN circle_conversations AS cc ON ci.circle_id = cc.circle_id LEFT JOIN conversations AS c ON c.conversation_id = cc.conversation_id WHERE ci.circle_id NOT IN (SELECT cir.circle_id FROM circles AS cir LEFT JOIN circle_conversations AS ccr ON cir.circle_id = ccr.circle_id WHERE ccr.conversation_id = ?1) GROUP BY ci.circle_id ORDER BY ci.ordered_at ASC, ci.created_at ASC', + variables: [ + Variable(conversationId) + ], + readsFrom: { + circles, + conversations, + circleConversations, + }).map((QueryRow row) { + return ConversationCircleManagerItem( + circleId: row.read('circle_id'), + name: row.read('name'), + count: row.read('count'), + ); + }); + } +} + +class ConversationCircleItem { + final String circleId; + final String name; + final DateTime createdAt; + final DateTime? orderedAt; + final int count; + final int unseenConversationCount; + final int unseenMutedConversationCount; + ConversationCircleItem({ + required this.circleId, + required this.name, + required this.createdAt, + this.orderedAt, + required this.count, + required this.unseenConversationCount, + required this.unseenMutedConversationCount, + }); + @override + int get hashCode => Object.hash(circleId, name, createdAt, orderedAt, count, + unseenConversationCount, unseenMutedConversationCount); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is ConversationCircleItem && + other.circleId == this.circleId && + other.name == this.name && + other.createdAt == this.createdAt && + other.orderedAt == this.orderedAt && + other.count == this.count && + other.unseenConversationCount == this.unseenConversationCount && + other.unseenMutedConversationCount == + this.unseenMutedConversationCount); + @override + String toString() { + return (StringBuffer('ConversationCircleItem(') + ..write('circleId: $circleId, ') + ..write('name: $name, ') + ..write('createdAt: $createdAt, ') + ..write('orderedAt: $orderedAt, ') + ..write('count: $count, ') + ..write('unseenConversationCount: $unseenConversationCount, ') + ..write('unseenMutedConversationCount: $unseenMutedConversationCount') + ..write(')')) + .toString(); + } +} + +class ConversationCircleManagerItem { + final String circleId; + final String name; + final int count; + ConversationCircleManagerItem({ + required this.circleId, + required this.name, + required this.count, + }); + @override + int get hashCode => Object.hash(circleId, name, count); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is ConversationCircleManagerItem && + other.circleId == this.circleId && + other.name == this.name && + other.count == this.count); + @override + String toString() { + return (StringBuffer('ConversationCircleManagerItem(') + ..write('circleId: $circleId, ') + ..write('name: $name, ') + ..write('count: $count') + ..write(')')) + .toString(); + } +} diff --git a/lib/db/dao/conversation_dao.dart b/lib/db/dao/conversation_dao.dart index 2ca1a9e632..9bb5d9983e 100644 --- a/lib/db/dao/conversation_dao.dart +++ b/lib/db/dao/conversation_dao.dart @@ -17,7 +17,7 @@ import 'participant_dao.dart'; part 'conversation_dao.g.dart'; -@DriftAccessor() +@DriftAccessor(include: {'../moor/dao/conversation.drift'}) class ConversationDao extends DatabaseAccessor with _$ConversationDaoMixin { ConversationDao(super.db); @@ -26,8 +26,7 @@ class ConversationDao extends DatabaseAccessor .instance.updateConversationIdStream .asyncMap((event) => allUnseenIgnoreMuteMessageCount().getSingle()); - Selectable allUnseenIgnoreMuteMessageCount() => - db.baseUnseenMessageCount( + Selectable allUnseenIgnoreMuteMessageCount() => _baseUnseenMessageCount( (conversation, owner, __) { final now = const MillisDateConverter().toSql(DateTime.now()); final groupExpression = @@ -66,45 +65,6 @@ class ConversationDao extends DatabaseAccessor ], ); - Selectable _baseConversationItemCount( - BaseConversationItemCount$where where, - ) => - db.baseConversationItemCount((conversation, owner, circleConversation) => - where(conversation, owner, circleConversation)); - - Selectable _baseConversationItems( - Expression Function( - Conversations conversation, - Users owner, - Messages message, - Users lastMessageSender, - Snapshots snapshot, - Users participant) - where, - Limit limit) => - db.baseConversationItems( - ( - Conversations conversation, - Users owner, - Messages message, - Users lastMessageSender, - Snapshots snapshot, - Users participant, - ExpiredMessages em, - ) => - where( - conversation, - owner, - message, - lastMessageSender, - snapshot, - participant, - ), - (conversation, _, __, ___, ____, _____, em) => - _baseConversationItemOrder(conversation), - (_, __, ___, ____, ______, _______, em) => limit, - ); - Expression _conversationPredicateByCategory(SlideCategoryType category, [Conversations? conversation, Users? owner]) { final Expression predicate; @@ -150,27 +110,35 @@ class ConversationDao extends DatabaseAccessor _conversationPredicateByCategory(category, conversation, owner)) .getSingle(); - Future> conversationItemsByCategory( + Selectable conversationItemsByCategory( SlideCategoryType category, int limit, int offset, ) => _baseConversationItems( - (conversation, owner, message, lastMessageSender, snapshot, - participant) => - _conversationPredicateByCategory(category, conversation, owner), - Limit(limit, offset), - ).get(); + (conversation, owner, lastMessage, lastMessageSender, snapshot, + participant, em) => + _conversationPredicateByCategory(category, conversation, owner), + (conversation, owner, lastMessage, lastMessageSender, snapshot, + participant, em) => + _baseConversationItemOrder(conversation), + (conversation, owner, lastMessage, lastMessageSender, snapshot, + participant, em) => + Limit(limit, offset)); Selectable unseenConversationByCategory( SlideCategoryType category) => _baseConversationItems( - (conversation, owner, message, lastMessageSender, snapshot, - participant) => - _conversationPredicateByCategory(category, conversation, owner) & - conversation.unseenMessageCount.isBiggerThanValue(0), - maxLimit, - ); + (conversation, owner, lastMessage, lastMessageSender, snapshot, + participant, em) => + _conversationPredicateByCategory(category, conversation, owner) & + conversation.unseenMessageCount.isBiggerThanValue(0), + (conversation, owner, lastMessage, lastMessageSender, snapshot, + participant, em) => + _baseConversationItemOrder(conversation), + (conversation, owner, lastMessage, lastMessageSender, snapshot, + participant, em) => + maxLimit); Future _conversationHasData(Expression predicate) => db.hasData( db.conversations, @@ -180,31 +148,35 @@ class ConversationDao extends DatabaseAccessor ], predicate); - Selectable _baseUnseenConversationCount( - Expression Function(Conversations conversation, Users owner) - where) => - db.baseUnseenConversationCount((conversation, owner) => - conversation.unseenMessageCount.isBiggerThanValue(0) & - where(conversation, owner)); - Selectable unseenConversationCountByCategory(SlideCategoryType category) => _baseUnseenConversationCount((conversation, owner) => + conversation.unseenMessageCount.isBiggerThanValue(0) & _conversationPredicateByCategory(category, conversation, owner)); Selectable conversationItem(String conversationId) => _baseConversationItems( - (conversation, _, __, ___, ____, ______) => - conversation.conversationId.equals(conversationId), - Limit(1, null), - ); + (conversation, owner, lastMessage, lastMessageSender, snapshot, + participant, em) => + conversation.conversationId.equals(conversationId), + (conversation, owner, lastMessage, lastMessageSender, snapshot, + participant, em) => + _baseConversationItemOrder(conversation), + (conversation, owner, lastMessage, lastMessageSender, snapshot, + participant, em) => + Limit(1, null)); Selectable conversationItems() => _baseConversationItems( - (conversation, _, __, ___, ____, ______) => - conversation.category.isIn(['CONTACT', 'GROUP']) & - conversation.status.equalsValue(ConversationStatus.success), - maxLimit, - ); + (conversation, owner, lastMessage, lastMessageSender, snapshot, + participant, em) => + conversation.category.isIn(['CONTACT', 'GROUP']) & + conversation.status.equalsValue(ConversationStatus.success), + (conversation, owner, lastMessage, lastMessageSender, snapshot, + participant, em) => + _baseConversationItemOrder(conversation), + (conversation, owner, lastMessage, lastMessageSender, snapshot, + participant, em) => + maxLimit); Selectable conversationsCountByCircleId(String circleId) => _baseConversationItemCount((_, __, circleConversation) => @@ -212,7 +184,7 @@ class ConversationDao extends DatabaseAccessor Selectable conversationsByCircleId( String circleId, int limit, int offset) => - db.baseConversationItemsByCircleId( + _baseConversationItemsByCircleId( (conversation, o, circleConversation, lm, ls, s, p, em) => circleConversation.circleId.equals(circleId), (conversation, _, __, ___, ____, _____, _____i, em) => @@ -234,7 +206,7 @@ class ConversationDao extends DatabaseAccessor db.circleConversations.circleId.equals(circleId)); Selectable unseenConversationsByCircleId(String circleId) => - db.baseConversationItemsByCircleId( + _baseConversationItemsByCircleId( (conversation, o, circleConversation, lm, ls, s, p, em) => circleConversation.circleId.equals(circleId) & conversation.unseenMessageCount.isBiggerThanValue(0), @@ -310,7 +282,7 @@ class ConversationDao extends DatabaseAccessor SlideCategoryState? category, }) { if (category?.type == SlideCategoryType.circle) { - return db.fuzzySearchConversationInCircle( + return _fuzzySearchConversationInCircle( query.trim().escapeSql(), category!.id, (conversation, owner, message, _, cc, __) => filterUnseen @@ -319,7 +291,7 @@ class ConversationDao extends DatabaseAccessor (conversation, owner, message, _, cc, __) => Limit(limit, null), ); } - return db.fuzzySearchConversation(query.trim().escapeSql(), + return _fuzzySearchConversation(query.trim().escapeSql(), (Conversations conversation, Users owner, Messages message, _, __) { Expression predicate = ignoreWhere; switch (category?.type) { @@ -350,7 +322,7 @@ class ConversationDao extends DatabaseAccessor Selectable searchConversationItemByIn( List ids) => - db.searchConversationItemByIn(ids, (conversation, _, __, ___, ____) { + _searchConversationItemByIn(ids, (conversation, _, __, ___, ____) { if (ids.isEmpty) return ignoreOrderBy; final conversationId = @@ -369,9 +341,6 @@ class ConversationDao extends DatabaseAccessor ..limit(1)) .map((row) => row.read(db.conversations.announcement)); - Selectable conversationStorageUsage() => - db.conversationStorageUsage(); - Future updateConversation( ConversationResponse conversation, String currentUserId) { var ownerId = conversation.creatorId; @@ -482,10 +451,6 @@ class ConversationDao extends DatabaseAccessor db.conversations.conversationId.equals(conversationId), ); - Selectable findTheSameConversations( - String selfId, String userId) => - db.findSameConversations(selfId, userId); - Future updateConversationExpireIn(String conversationId, int expireIn) => (update(db.conversations) ..where((tbl) => tbl.conversationId.equals(conversationId))) @@ -542,14 +507,12 @@ class ConversationDao extends DatabaseAccessor String? lastMessageId, DateTime? lastMessageCreatedAt, ) => - db - .updateUnseenMessageCountAndLastMessageId( + _updateUnseenMessageCountAndLastMessageId( conversationId, userId, lastMessageId, lastMessageCreatedAt, - ) - .then((value) { + ).then((value) { if (value > 0) { DataBaseEventBus.instance.updateConversation(conversationId); } diff --git a/lib/db/dao/conversation_dao.g.dart b/lib/db/dao/conversation_dao.g.dart index 0989b1ec98..370ef131b3 100644 --- a/lib/db/dao/conversation_dao.g.dart +++ b/lib/db/dao/conversation_dao.g.dart @@ -3,4 +3,1129 @@ part of 'conversation_dao.dart'; // ignore_for_file: type=lint -mixin _$ConversationDaoMixin on DatabaseAccessor {} +mixin _$ConversationDaoMixin on DatabaseAccessor { + Conversations get conversations => attachedDatabase.conversations; + Users get users => attachedDatabase.users; + CircleConversations get circleConversations => + attachedDatabase.circleConversations; + MessageMentions get messageMentions => attachedDatabase.messageMentions; + Messages get messages => attachedDatabase.messages; + Snapshots get snapshots => attachedDatabase.snapshots; + ExpiredMessages get expiredMessages => attachedDatabase.expiredMessages; + Participants get participants => attachedDatabase.participants; + Addresses get addresses => attachedDatabase.addresses; + Apps get apps => attachedDatabase.apps; + Assets get assets => attachedDatabase.assets; + Circles get circles => attachedDatabase.circles; + FloodMessages get floodMessages => attachedDatabase.floodMessages; + Hyperlinks get hyperlinks => attachedDatabase.hyperlinks; + Jobs get jobs => attachedDatabase.jobs; + MessagesHistory get messagesHistory => attachedDatabase.messagesHistory; + Offsets get offsets => attachedDatabase.offsets; + ParticipantSession get participantSession => + attachedDatabase.participantSession; + ResendSessionMessages get resendSessionMessages => + attachedDatabase.resendSessionMessages; + SentSessionSenderKeys get sentSessionSenderKeys => + attachedDatabase.sentSessionSenderKeys; + StickerAlbums get stickerAlbums => attachedDatabase.stickerAlbums; + StickerRelationships get stickerRelationships => + attachedDatabase.stickerRelationships; + Stickers get stickers => attachedDatabase.stickers; + TranscriptMessages get transcriptMessages => + attachedDatabase.transcriptMessages; + PinMessages get pinMessages => attachedDatabase.pinMessages; + Fiats get fiats => attachedDatabase.fiats; + FavoriteApps get favoriteApps => attachedDatabase.favoriteApps; + Chains get chains => attachedDatabase.chains; + Properties get properties => attachedDatabase.properties; + Selectable _baseConversationItemCount( + BaseConversationItemCount$where where) { + var $arrayStartIndex = 1; + final generatedwhere = $write( + where( + alias(this.conversations, 'conversation'), + alias(this.users, 'owner'), + alias(this.circleConversations, 'circleConversation')), + hasMultipleTables: true, + startIndex: $arrayStartIndex); + $arrayStartIndex += generatedwhere.amountOfVariables; + return customSelect( + 'SELECT COUNT(DISTINCT conversation.conversation_id) AS _c0 FROM conversations AS conversation INNER JOIN users AS owner ON owner.user_id = conversation.owner_id LEFT JOIN circle_conversations AS circleConversation ON conversation.conversation_id = circleConversation.conversation_id WHERE ${generatedwhere.sql}', + variables: [ + ...generatedwhere.introducedVariables + ], + readsFrom: { + conversations, + users, + circleConversations, + ...generatedwhere.watchedTables, + }).map((QueryRow row) => row.read('_c0')); + } + + Selectable _baseConversationItems( + BaseConversationItems$where where, + BaseConversationItems$order order, + BaseConversationItems$limit limit) { + var $arrayStartIndex = 1; + final generatedwhere = $write( + where( + alias(this.conversations, 'conversation'), + alias(this.users, 'owner'), + alias(this.messages, 'lastMessage'), + alias(this.users, 'lastMessageSender'), + alias(this.snapshots, 'snapshot'), + alias(this.users, 'participant'), + alias(this.expiredMessages, 'em')), + hasMultipleTables: true, + startIndex: $arrayStartIndex); + $arrayStartIndex += generatedwhere.amountOfVariables; + final generatedorder = $write( + order?.call( + alias(this.conversations, 'conversation'), + alias(this.users, 'owner'), + alias(this.messages, 'lastMessage'), + alias(this.users, 'lastMessageSender'), + alias(this.snapshots, 'snapshot'), + alias(this.users, 'participant'), + alias(this.expiredMessages, 'em')) ?? + const OrderBy.nothing(), + hasMultipleTables: true, + startIndex: $arrayStartIndex); + $arrayStartIndex += generatedorder.amountOfVariables; + final generatedlimit = $write( + limit( + alias(this.conversations, 'conversation'), + alias(this.users, 'owner'), + alias(this.messages, 'lastMessage'), + alias(this.users, 'lastMessageSender'), + alias(this.snapshots, 'snapshot'), + alias(this.users, 'participant'), + alias(this.expiredMessages, 'em')), + hasMultipleTables: true, + startIndex: $arrayStartIndex); + $arrayStartIndex += generatedlimit.amountOfVariables; + return customSelect( + 'SELECT conversation.conversation_id AS conversationId, conversation.icon_url AS groupIconUrl, conversation.category AS category, conversation.draft AS draft, conversation.name AS groupName, conversation.status AS status, conversation.last_read_message_id AS lastReadMessageId, conversation.unseen_message_count AS unseenMessageCount, conversation.owner_id AS ownerId, conversation.pin_time AS pinTime, conversation.mute_until AS muteUntil, conversation.expire_in AS expireIn, owner.avatar_url AS avatarUrl, owner.full_name AS name, owner.is_verified AS ownerVerified, owner.identity_number AS ownerIdentityNumber, owner.mute_until AS ownerMuteUntil, owner.app_id AS appId, lastMessage.content AS content, lastMessage.category AS contentType, conversation.created_at AS createdAt, lastMessage.created_at AS lastMessageCreatedAt, lastMessage.media_url AS mediaUrl, lastMessage.user_id AS senderId, lastMessage."action" AS actionName, lastMessage.status AS messageStatus, lastMessageSender.full_name AS senderFullName, snapshot.type AS SnapshotType, participant.full_name AS participantFullName, participant.user_id AS participantUserId, em.expire_in AS messageExpireIn, (SELECT COUNT(1) FROM message_mentions AS messageMention WHERE messageMention.conversation_id = conversation.conversation_id AND messageMention.has_read = 0) AS mentionCount, owner.relationship AS relationship FROM conversations AS conversation INNER JOIN users AS owner ON owner.user_id = conversation.owner_id LEFT JOIN messages AS lastMessage ON conversation.last_message_id = lastMessage.message_id LEFT JOIN users AS lastMessageSender ON lastMessageSender.user_id = lastMessage.user_id LEFT JOIN snapshots AS snapshot ON snapshot.snapshot_id = lastMessage.snapshot_id LEFT JOIN users AS participant ON participant.user_id = lastMessage.participant_id LEFT JOIN expired_messages AS em ON lastMessage.message_id = em.message_id WHERE ${generatedwhere.sql} ${generatedorder.sql} ${generatedlimit.sql}', + variables: [ + ...generatedwhere.introducedVariables, + ...generatedorder.introducedVariables, + ...generatedlimit.introducedVariables + ], + readsFrom: { + conversations, + users, + messages, + snapshots, + expiredMessages, + messageMentions, + ...generatedwhere.watchedTables, + ...generatedorder.watchedTables, + ...generatedlimit.watchedTables, + }).map((QueryRow row) { + return ConversationItem( + conversationId: row.read('conversationId'), + groupIconUrl: row.readNullable('groupIconUrl'), + category: Conversations.$convertercategory + .fromSql(row.readNullable('category')), + draft: row.readNullable('draft'), + groupName: row.readNullable('groupName'), + status: Conversations.$converterstatus.fromSql(row.read('status')), + lastReadMessageId: row.readNullable('lastReadMessageId'), + unseenMessageCount: row.readNullable('unseenMessageCount'), + ownerId: row.readNullable('ownerId'), + pinTime: NullAwareTypeConverter.wrapFromSql( + Conversations.$converterpinTime, row.readNullable('pinTime')), + muteUntil: NullAwareTypeConverter.wrapFromSql( + Conversations.$convertermuteUntil, + row.readNullable('muteUntil')), + expireIn: row.readNullable('expireIn'), + avatarUrl: row.readNullable('avatarUrl'), + name: row.readNullable('name'), + ownerVerified: row.readNullable('ownerVerified'), + ownerIdentityNumber: row.read('ownerIdentityNumber'), + ownerMuteUntil: NullAwareTypeConverter.wrapFromSql( + Users.$convertermuteUntil, row.readNullable('ownerMuteUntil')), + appId: row.readNullable('appId'), + content: row.readNullable('content'), + contentType: row.readNullable('contentType'), + createdAt: Conversations.$convertercreatedAt + .fromSql(row.read('createdAt')), + lastMessageCreatedAt: NullAwareTypeConverter.wrapFromSql( + Messages.$convertercreatedAt, + row.readNullable('lastMessageCreatedAt')), + mediaUrl: row.readNullable('mediaUrl'), + senderId: row.readNullable('senderId'), + actionName: row.readNullable('actionName'), + messageStatus: NullAwareTypeConverter.wrapFromSql( + Messages.$converterstatus, + row.readNullable('messageStatus')), + senderFullName: row.readNullable('senderFullName'), + snapshotType: row.readNullable('SnapshotType'), + participantFullName: row.readNullable('participantFullName'), + participantUserId: row.readNullable('participantUserId'), + messageExpireIn: row.readNullable('messageExpireIn'), + mentionCount: row.read('mentionCount'), + relationship: Users.$converterrelationship + .fromSql(row.readNullable('relationship')), + ); + }); + } + + Selectable _baseConversationItemsByCircleId( + BaseConversationItemsByCircleId$where where, + BaseConversationItemsByCircleId$order order, + BaseConversationItemsByCircleId$limit limit) { + var $arrayStartIndex = 1; + final generatedwhere = $write( + where( + alias(this.conversations, 'conversation'), + alias(this.users, 'owner'), + alias(this.circleConversations, 'circleConversation'), + alias(this.messages, 'lastMessage'), + alias(this.users, 'lastMessageSender'), + alias(this.snapshots, 'snapshot'), + alias(this.users, 'participant'), + alias(this.expiredMessages, 'em')), + hasMultipleTables: true, + startIndex: $arrayStartIndex); + $arrayStartIndex += generatedwhere.amountOfVariables; + final generatedorder = $write( + order?.call( + alias(this.conversations, 'conversation'), + alias(this.users, 'owner'), + alias(this.circleConversations, 'circleConversation'), + alias(this.messages, 'lastMessage'), + alias(this.users, 'lastMessageSender'), + alias(this.snapshots, 'snapshot'), + alias(this.users, 'participant'), + alias(this.expiredMessages, 'em')) ?? + const OrderBy.nothing(), + hasMultipleTables: true, + startIndex: $arrayStartIndex); + $arrayStartIndex += generatedorder.amountOfVariables; + final generatedlimit = $write( + limit( + alias(this.conversations, 'conversation'), + alias(this.users, 'owner'), + alias(this.circleConversations, 'circleConversation'), + alias(this.messages, 'lastMessage'), + alias(this.users, 'lastMessageSender'), + alias(this.snapshots, 'snapshot'), + alias(this.users, 'participant'), + alias(this.expiredMessages, 'em')), + hasMultipleTables: true, + startIndex: $arrayStartIndex); + $arrayStartIndex += generatedlimit.amountOfVariables; + return customSelect( + 'SELECT conversation.conversation_id AS conversationId, conversation.icon_url AS groupIconUrl, conversation.category AS category, conversation.draft AS draft, conversation.name AS groupName, conversation.status AS status, conversation.last_read_message_id AS lastReadMessageId, conversation.unseen_message_count AS unseenMessageCount, conversation.owner_id AS ownerId, conversation.pin_time AS pinTime, conversation.mute_until AS muteUntil, conversation.expire_in AS expireIn, owner.avatar_url AS avatarUrl, owner.full_name AS name, owner.is_verified AS ownerVerified, owner.identity_number AS ownerIdentityNumber, owner.mute_until AS ownerMuteUntil, owner.app_id AS appId, lastMessage.content AS content, lastMessage.category AS contentType, conversation.created_at AS createdAt, lastMessage.created_at AS lastMessageCreatedAt, lastMessage.media_url AS mediaUrl, lastMessage.user_id AS senderId, lastMessage."action" AS actionName, lastMessage.status AS messageStatus, lastMessageSender.full_name AS senderFullName, snapshot.type AS SnapshotType, participant.full_name AS participantFullName, participant.user_id AS participantUserId, em.expire_in AS messageExpireIn, (SELECT COUNT(1) FROM message_mentions AS messageMention WHERE messageMention.conversation_id = conversation.conversation_id AND messageMention.has_read = 0) AS mentionCount, owner.relationship AS relationship FROM conversations AS conversation INNER JOIN users AS owner ON owner.user_id = conversation.owner_id LEFT JOIN circle_conversations AS circleConversation ON conversation.conversation_id = circleConversation.conversation_id LEFT JOIN messages AS lastMessage ON conversation.last_message_id = lastMessage.message_id LEFT JOIN users AS lastMessageSender ON lastMessageSender.user_id = lastMessage.user_id LEFT JOIN snapshots AS snapshot ON snapshot.snapshot_id = lastMessage.snapshot_id LEFT JOIN users AS participant ON participant.user_id = lastMessage.participant_id LEFT JOIN expired_messages AS em ON lastMessage.message_id = em.message_id WHERE ${generatedwhere.sql} ${generatedorder.sql} ${generatedlimit.sql}', + variables: [ + ...generatedwhere.introducedVariables, + ...generatedorder.introducedVariables, + ...generatedlimit.introducedVariables + ], + readsFrom: { + conversations, + users, + messages, + snapshots, + expiredMessages, + messageMentions, + circleConversations, + ...generatedwhere.watchedTables, + ...generatedorder.watchedTables, + ...generatedlimit.watchedTables, + }).map((QueryRow row) { + return ConversationItem( + conversationId: row.read('conversationId'), + groupIconUrl: row.readNullable('groupIconUrl'), + category: Conversations.$convertercategory + .fromSql(row.readNullable('category')), + draft: row.readNullable('draft'), + groupName: row.readNullable('groupName'), + status: Conversations.$converterstatus.fromSql(row.read('status')), + lastReadMessageId: row.readNullable('lastReadMessageId'), + unseenMessageCount: row.readNullable('unseenMessageCount'), + ownerId: row.readNullable('ownerId'), + pinTime: NullAwareTypeConverter.wrapFromSql( + Conversations.$converterpinTime, row.readNullable('pinTime')), + muteUntil: NullAwareTypeConverter.wrapFromSql( + Conversations.$convertermuteUntil, + row.readNullable('muteUntil')), + expireIn: row.readNullable('expireIn'), + avatarUrl: row.readNullable('avatarUrl'), + name: row.readNullable('name'), + ownerVerified: row.readNullable('ownerVerified'), + ownerIdentityNumber: row.read('ownerIdentityNumber'), + ownerMuteUntil: NullAwareTypeConverter.wrapFromSql( + Users.$convertermuteUntil, row.readNullable('ownerMuteUntil')), + appId: row.readNullable('appId'), + content: row.readNullable('content'), + contentType: row.readNullable('contentType'), + createdAt: Conversations.$convertercreatedAt + .fromSql(row.read('createdAt')), + lastMessageCreatedAt: NullAwareTypeConverter.wrapFromSql( + Messages.$convertercreatedAt, + row.readNullable('lastMessageCreatedAt')), + mediaUrl: row.readNullable('mediaUrl'), + senderId: row.readNullable('senderId'), + actionName: row.readNullable('actionName'), + messageStatus: NullAwareTypeConverter.wrapFromSql( + Messages.$converterstatus, + row.readNullable('messageStatus')), + senderFullName: row.readNullable('senderFullName'), + snapshotType: row.readNullable('SnapshotType'), + participantFullName: row.readNullable('participantFullName'), + participantUserId: row.readNullable('participantUserId'), + messageExpireIn: row.readNullable('messageExpireIn'), + mentionCount: row.read('mentionCount'), + relationship: Users.$converterrelationship + .fromSql(row.readNullable('relationship')), + ); + }); + } + + Selectable _baseUnseenMessageCount(BaseUnseenMessageCount$where where) { + var $arrayStartIndex = 1; + final generatedwhere = $write( + where( + alias(this.conversations, 'conversation'), + alias(this.users, 'owner'), + alias(this.circleConversations, 'circleConversation')), + hasMultipleTables: true, + startIndex: $arrayStartIndex); + $arrayStartIndex += generatedwhere.amountOfVariables; + return customSelect( + 'SELECT IFNULL(SUM(unseen_message_count), 0) AS _c0 FROM conversations AS conversation INNER JOIN users AS owner ON owner.user_id = conversation.owner_id LEFT JOIN circle_conversations AS circleConversation ON conversation.conversation_id = circleConversation.conversation_id WHERE ${generatedwhere.sql} LIMIT 1', + variables: [ + ...generatedwhere.introducedVariables + ], + readsFrom: { + conversations, + users, + circleConversations, + ...generatedwhere.watchedTables, + }).map((QueryRow row) => row.read('_c0')); + } + + Selectable _baseUnseenConversationCount( + BaseUnseenConversationCount$where where) { + var $arrayStartIndex = 1; + final generatedwhere = $write( + where(alias(this.conversations, 'conversation'), + alias(this.users, 'owner')), + hasMultipleTables: true, + startIndex: $arrayStartIndex); + $arrayStartIndex += generatedwhere.amountOfVariables; + return customSelect( + 'SELECT COUNT(1) AS unseen_conversation_count, IFNULL(SUM(CASE WHEN(CASE WHEN conversation.category = \'GROUP\' THEN conversation.mute_until ELSE owner.mute_until END)>=(strftime(\'%s\', \'now\') * 1000)AND IFNULL(conversation.unseen_message_count, 0) > 0 THEN 1 ELSE 0 END), 0) AS unseen_muted_conversation_count FROM conversations AS conversation INNER JOIN users AS owner ON owner.user_id = conversation.owner_id WHERE ${generatedwhere.sql} LIMIT 1', + variables: [ + ...generatedwhere.introducedVariables + ], + readsFrom: { + conversations, + users, + ...generatedwhere.watchedTables, + }).map((QueryRow row) { + return BaseUnseenConversationCountResult( + unseenConversationCount: row.read('unseen_conversation_count'), + unseenMutedConversationCount: + row.read('unseen_muted_conversation_count'), + ); + }); + } + + Selectable _fuzzySearchConversation( + String query, + FuzzySearchConversation$where where, + FuzzySearchConversation$limit limit) { + var $arrayStartIndex = 2; + final generatedwhere = $write( + where( + alias(this.conversations, 'conversation'), + alias(this.users, 'owner'), + alias(this.messages, 'message'), + alias(this.users, 'lastMessageSender'), + alias(this.users, 'participant')), + hasMultipleTables: true, + startIndex: $arrayStartIndex); + $arrayStartIndex += generatedwhere.amountOfVariables; + final generatedlimit = $write( + limit( + alias(this.conversations, 'conversation'), + alias(this.users, 'owner'), + alias(this.messages, 'message'), + alias(this.users, 'lastMessageSender'), + alias(this.users, 'participant')), + hasMultipleTables: true, + startIndex: $arrayStartIndex); + $arrayStartIndex += generatedlimit.amountOfVariables; + return customSelect( + 'SELECT conversation.conversation_id AS conversationId, conversation.icon_url AS groupIconUrl, conversation.category AS category, conversation.name AS groupName, conversation.pin_time AS pinTime, conversation.mute_until AS muteUntil, conversation.owner_id AS ownerId, owner.mute_until AS ownerMuteUntil, owner.identity_number AS ownerIdentityNumber, owner.full_name AS fullName, owner.avatar_url AS avatarUrl, owner.is_verified AS isVerified, owner.app_id AS appId, message.status AS messageStatus, message.content AS content, message.category AS contentType, message.user_id AS senderId, message."action" AS actionName, lastMessageSender.full_name AS senderFullName, participant.user_id AS participantUserId, participant.full_name AS participantFullName FROM conversations AS conversation INNER JOIN users AS owner ON owner.user_id = conversation.owner_id LEFT JOIN messages AS message ON conversation.last_message_id = message.message_id LEFT JOIN users AS lastMessageSender ON lastMessageSender.user_id = message.user_id LEFT JOIN users AS participant ON participant.user_id = message.participant_id WHERE((conversation.category = \'GROUP\' AND conversation.name LIKE \'%\' || ?1 || \'%\' ESCAPE \'\\\')OR(conversation.category = \'CONTACT\' AND(owner.full_name LIKE \'%\' || ?1 || \'%\' ESCAPE \'\\\' OR owner.identity_number LIKE \'%\' || ?1 || \'%\' ESCAPE \'\\\')))AND ${generatedwhere.sql} ORDER BY(conversation.category = \'GROUP\' AND conversation.name = ?1 COLLATE NOCASE)OR(conversation.category = \'CONTACT\' AND(owner.full_name = ?1 COLLATE NOCASE OR owner.identity_number = ?1 COLLATE NOCASE))DESC, conversation.pin_time DESC, message.created_at DESC ${generatedlimit.sql}', + variables: [ + Variable(query), + ...generatedwhere.introducedVariables, + ...generatedlimit.introducedVariables + ], + readsFrom: { + conversations, + users, + messages, + ...generatedwhere.watchedTables, + ...generatedlimit.watchedTables, + }).map((QueryRow row) { + return SearchConversationItem( + conversationId: row.read('conversationId'), + groupIconUrl: row.readNullable('groupIconUrl'), + category: Conversations.$convertercategory + .fromSql(row.readNullable('category')), + groupName: row.readNullable('groupName'), + pinTime: NullAwareTypeConverter.wrapFromSql( + Conversations.$converterpinTime, row.readNullable('pinTime')), + muteUntil: NullAwareTypeConverter.wrapFromSql( + Conversations.$convertermuteUntil, + row.readNullable('muteUntil')), + ownerId: row.readNullable('ownerId'), + ownerMuteUntil: NullAwareTypeConverter.wrapFromSql( + Users.$convertermuteUntil, row.readNullable('ownerMuteUntil')), + ownerIdentityNumber: row.read('ownerIdentityNumber'), + fullName: row.readNullable('fullName'), + avatarUrl: row.readNullable('avatarUrl'), + isVerified: row.readNullable('isVerified'), + appId: row.readNullable('appId'), + messageStatus: NullAwareTypeConverter.wrapFromSql( + Messages.$converterstatus, + row.readNullable('messageStatus')), + content: row.readNullable('content'), + contentType: row.readNullable('contentType'), + senderId: row.readNullable('senderId'), + actionName: row.readNullable('actionName'), + senderFullName: row.readNullable('senderFullName'), + participantUserId: row.readNullable('participantUserId'), + participantFullName: row.readNullable('participantFullName'), + ); + }); + } + + Selectable _searchConversationItemByIn( + List ids, SearchConversationItemByIn$order order) { + var $arrayStartIndex = 1; + final expandedids = $expandVar($arrayStartIndex, ids.length); + $arrayStartIndex += ids.length; + final generatedorder = $write( + order?.call( + alias(this.conversations, 'conversation'), + alias(this.users, 'owner'), + alias(this.messages, 'message'), + alias(this.users, 'lastMessageSender'), + alias(this.users, 'participant')) ?? + const OrderBy.nothing(), + hasMultipleTables: true, + startIndex: $arrayStartIndex); + $arrayStartIndex += generatedorder.amountOfVariables; + return customSelect( + 'SELECT conversation.conversation_id AS conversationId, conversation.icon_url AS groupIconUrl, conversation.category AS category, conversation.name AS groupName, conversation.pin_time AS pinTime, conversation.mute_until AS muteUntil, conversation.owner_id AS ownerId, owner.mute_until AS ownerMuteUntil, owner.identity_number AS ownerIdentityNumber, owner.full_name AS fullName, owner.avatar_url AS avatarUrl, owner.is_verified AS isVerified, owner.app_id AS appId, message.status AS messageStatus, message.content AS content, message.category AS contentType, message.user_id AS senderId, message."action" AS actionName, lastMessageSender.full_name AS senderFullName, participant.user_id AS participantUserId, participant.full_name AS participantFullName FROM conversations AS conversation INNER JOIN users AS owner ON owner.user_id = conversation.owner_id LEFT JOIN messages AS message ON conversation.last_message_id = message.message_id LEFT JOIN users AS lastMessageSender ON lastMessageSender.user_id = message.user_id LEFT JOIN users AS participant ON participant.user_id = message.participant_id WHERE conversation.conversation_id IN ($expandedids) ${generatedorder.sql}', + variables: [ + for (var $ in ids) Variable($), + ...generatedorder.introducedVariables + ], + readsFrom: { + conversations, + users, + messages, + ...generatedorder.watchedTables, + }).map((QueryRow row) { + return SearchConversationItem( + conversationId: row.read('conversationId'), + groupIconUrl: row.readNullable('groupIconUrl'), + category: Conversations.$convertercategory + .fromSql(row.readNullable('category')), + groupName: row.readNullable('groupName'), + pinTime: NullAwareTypeConverter.wrapFromSql( + Conversations.$converterpinTime, row.readNullable('pinTime')), + muteUntil: NullAwareTypeConverter.wrapFromSql( + Conversations.$convertermuteUntil, + row.readNullable('muteUntil')), + ownerId: row.readNullable('ownerId'), + ownerMuteUntil: NullAwareTypeConverter.wrapFromSql( + Users.$convertermuteUntil, row.readNullable('ownerMuteUntil')), + ownerIdentityNumber: row.read('ownerIdentityNumber'), + fullName: row.readNullable('fullName'), + avatarUrl: row.readNullable('avatarUrl'), + isVerified: row.readNullable('isVerified'), + appId: row.readNullable('appId'), + messageStatus: NullAwareTypeConverter.wrapFromSql( + Messages.$converterstatus, + row.readNullable('messageStatus')), + content: row.readNullable('content'), + contentType: row.readNullable('contentType'), + senderId: row.readNullable('senderId'), + actionName: row.readNullable('actionName'), + senderFullName: row.readNullable('senderFullName'), + participantUserId: row.readNullable('participantUserId'), + participantFullName: row.readNullable('participantFullName'), + ); + }); + } + + Selectable _fuzzySearchConversationInCircle( + String query, + String? circleId, + FuzzySearchConversationInCircle$where where, + FuzzySearchConversationInCircle$limit limit) { + var $arrayStartIndex = 3; + final generatedwhere = $write( + where( + alias(this.conversations, 'conversation'), + alias(this.users, 'owner'), + alias(this.messages, 'message'), + alias(this.users, 'lastMessageSender'), + alias(this.circleConversations, 'circleConversation'), + alias(this.users, 'participant')), + hasMultipleTables: true, + startIndex: $arrayStartIndex); + $arrayStartIndex += generatedwhere.amountOfVariables; + final generatedlimit = $write( + limit( + alias(this.conversations, 'conversation'), + alias(this.users, 'owner'), + alias(this.messages, 'message'), + alias(this.users, 'lastMessageSender'), + alias(this.circleConversations, 'circleConversation'), + alias(this.users, 'participant')), + hasMultipleTables: true, + startIndex: $arrayStartIndex); + $arrayStartIndex += generatedlimit.amountOfVariables; + return customSelect( + 'SELECT conversation.conversation_id AS conversationId, conversation.icon_url AS groupIconUrl, conversation.category AS category, conversation.name AS groupName, conversation.pin_time AS pinTime, conversation.mute_until AS muteUntil, conversation.owner_id AS ownerId, owner.mute_until AS ownerMuteUntil, owner.identity_number AS ownerIdentityNumber, owner.full_name AS fullName, owner.avatar_url AS avatarUrl, owner.is_verified AS isVerified, owner.app_id AS appId, message.status AS messageStatus, message.content AS content, message.category AS contentType, message.user_id AS senderId, message."action" AS actionName, lastMessageSender.full_name AS senderFullName, participant.user_id AS participantUserId, participant.full_name AS participantFullName FROM conversations AS conversation INNER JOIN users AS owner ON owner.user_id = conversation.owner_id LEFT JOIN messages AS message ON conversation.last_message_id = message.message_id LEFT JOIN users AS lastMessageSender ON lastMessageSender.user_id = message.user_id LEFT JOIN circle_conversations AS circleConversation ON conversation.conversation_id = circleConversation.conversation_id LEFT JOIN users AS participant ON participant.user_id = message.participant_id WHERE((conversation.category = \'GROUP\' AND conversation.name LIKE \'%\' || ?1 || \'%\' ESCAPE \'\\\')OR(conversation.category = \'CONTACT\' AND(owner.full_name LIKE \'%\' || ?1 || \'%\' ESCAPE \'\\\' OR owner.identity_number LIKE \'%\' || ?1 || \'%\' ESCAPE \'\\\')))AND circleConversation.circle_id = ?2 AND ${generatedwhere.sql} ORDER BY(conversation.category = \'GROUP\' AND conversation.name = ?1 COLLATE NOCASE)OR(conversation.category = \'CONTACT\' AND(owner.full_name = ?1 COLLATE NOCASE OR owner.identity_number = ?1 COLLATE NOCASE))DESC, conversation.pin_time DESC, message.created_at DESC ${generatedlimit.sql}', + variables: [ + Variable(query), + Variable(circleId), + ...generatedwhere.introducedVariables, + ...generatedlimit.introducedVariables + ], + readsFrom: { + conversations, + users, + messages, + circleConversations, + ...generatedwhere.watchedTables, + ...generatedlimit.watchedTables, + }).map((QueryRow row) { + return SearchConversationItem( + conversationId: row.read('conversationId'), + groupIconUrl: row.readNullable('groupIconUrl'), + category: Conversations.$convertercategory + .fromSql(row.readNullable('category')), + groupName: row.readNullable('groupName'), + pinTime: NullAwareTypeConverter.wrapFromSql( + Conversations.$converterpinTime, row.readNullable('pinTime')), + muteUntil: NullAwareTypeConverter.wrapFromSql( + Conversations.$convertermuteUntil, + row.readNullable('muteUntil')), + ownerId: row.readNullable('ownerId'), + ownerMuteUntil: NullAwareTypeConverter.wrapFromSql( + Users.$convertermuteUntil, row.readNullable('ownerMuteUntil')), + ownerIdentityNumber: row.read('ownerIdentityNumber'), + fullName: row.readNullable('fullName'), + avatarUrl: row.readNullable('avatarUrl'), + isVerified: row.readNullable('isVerified'), + appId: row.readNullable('appId'), + messageStatus: NullAwareTypeConverter.wrapFromSql( + Messages.$converterstatus, + row.readNullable('messageStatus')), + content: row.readNullable('content'), + contentType: row.readNullable('contentType'), + senderId: row.readNullable('senderId'), + actionName: row.readNullable('actionName'), + senderFullName: row.readNullable('senderFullName'), + participantUserId: row.readNullable('participantUserId'), + participantFullName: row.readNullable('participantFullName'), + ); + }); + } + + Selectable conversationStorageUsage() { + return customSelect( + 'SELECT c.conversation_id, c.owner_id, c.category, c.icon_url, c.name, u.identity_number, u.full_name, u.avatar_url, u.is_verified FROM conversations AS c INNER JOIN users AS u ON u.user_id = c.owner_id WHERE c.category IS NOT NULL', + variables: [], + readsFrom: { + conversations, + users, + }).map((QueryRow row) { + return ConversationStorageUsage( + conversationId: row.read('conversation_id'), + ownerId: row.readNullable('owner_id'), + category: Conversations.$convertercategory + .fromSql(row.readNullable('category')), + iconUrl: row.readNullable('icon_url'), + name: row.readNullable('name'), + identityNumber: row.read('identity_number'), + fullName: row.readNullable('full_name'), + avatarUrl: row.readNullable('avatar_url'), + isVerified: row.readNullable('is_verified'), + ); + }); + } + + Selectable findSameConversations(String selfId, String userId) { + return customSelect( + 'SELECT c.conversation_id AS conversationId, c.icon_url AS groupIconUrl, c.name AS groupName, (SELECT count(user_id) FROM participants WHERE conversation_id = c.conversation_id) AS memberCount FROM participants AS p INNER JOIN conversations AS c ON c.conversation_id = p.conversation_id WHERE p.user_id IN (?1, ?2) AND c.status = 2 AND c.category = \'GROUP\' GROUP BY c.conversation_id HAVING count(p.user_id) = 2 ORDER BY c.last_message_created_at DESC', + variables: [ + Variable(selfId), + Variable(userId) + ], + readsFrom: { + conversations, + participants, + }).map((QueryRow row) { + return GroupMinimal( + conversationId: row.read('conversationId'), + groupIconUrl: row.readNullable('groupIconUrl'), + groupName: row.readNullable('groupName'), + memberCount: row.read('memberCount'), + ); + }); + } + + Selectable countConversations() { + return customSelect('SELECT COUNT(1) AS _c0 FROM conversations', + variables: [], + readsFrom: { + conversations, + }).map((QueryRow row) => row.read('_c0')); + } + + Future _updateUnseenMessageCountAndLastMessageId(String conversationId, + String userId, String? lastMessageId, DateTime? lastMessageCreatedAt) { + return customUpdate( + 'UPDATE conversations SET unseen_message_count = (SELECT count(1) FROM messages WHERE conversation_id = ?1 AND status IN (\'SENT\', \'DELIVERED\') AND user_id != ?2), last_message_id = ?3, last_message_created_at = ?4 WHERE conversation_id = ?1', + variables: [ + Variable(conversationId), + Variable(userId), + Variable(lastMessageId), + Variable(NullAwareTypeConverter.wrapToSql( + Conversations.$converterlastMessageCreatedAt, lastMessageCreatedAt)) + ], + updates: {conversations}, + updateKind: UpdateKind.update, + ); + } +} +typedef BaseConversationItemCount$where = Expression Function( + Conversations conversation, + Users owner, + CircleConversations circleConversation); + +class ConversationItem { + final String conversationId; + final String? groupIconUrl; + final ConversationCategory? category; + final String? draft; + final String? groupName; + final ConversationStatus status; + final String? lastReadMessageId; + final int? unseenMessageCount; + final String? ownerId; + final DateTime? pinTime; + final DateTime? muteUntil; + final int? expireIn; + final String? avatarUrl; + final String? name; + final bool? ownerVerified; + final String ownerIdentityNumber; + final DateTime? ownerMuteUntil; + final String? appId; + final String? content; + final String? contentType; + final DateTime createdAt; + final DateTime? lastMessageCreatedAt; + final String? mediaUrl; + final String? senderId; + final String? actionName; + final MessageStatus? messageStatus; + final String? senderFullName; + final String? snapshotType; + final String? participantFullName; + final String? participantUserId; + final int? messageExpireIn; + final int mentionCount; + final UserRelationship? relationship; + ConversationItem({ + required this.conversationId, + this.groupIconUrl, + this.category, + this.draft, + this.groupName, + required this.status, + this.lastReadMessageId, + this.unseenMessageCount, + this.ownerId, + this.pinTime, + this.muteUntil, + this.expireIn, + this.avatarUrl, + this.name, + this.ownerVerified, + required this.ownerIdentityNumber, + this.ownerMuteUntil, + this.appId, + this.content, + this.contentType, + required this.createdAt, + this.lastMessageCreatedAt, + this.mediaUrl, + this.senderId, + this.actionName, + this.messageStatus, + this.senderFullName, + this.snapshotType, + this.participantFullName, + this.participantUserId, + this.messageExpireIn, + required this.mentionCount, + this.relationship, + }); + @override + int get hashCode => Object.hashAll([ + conversationId, + groupIconUrl, + category, + draft, + groupName, + status, + lastReadMessageId, + unseenMessageCount, + ownerId, + pinTime, + muteUntil, + expireIn, + avatarUrl, + name, + ownerVerified, + ownerIdentityNumber, + ownerMuteUntil, + appId, + content, + contentType, + createdAt, + lastMessageCreatedAt, + mediaUrl, + senderId, + actionName, + messageStatus, + senderFullName, + snapshotType, + participantFullName, + participantUserId, + messageExpireIn, + mentionCount, + relationship + ]); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is ConversationItem && + other.conversationId == this.conversationId && + other.groupIconUrl == this.groupIconUrl && + other.category == this.category && + other.draft == this.draft && + other.groupName == this.groupName && + other.status == this.status && + other.lastReadMessageId == this.lastReadMessageId && + other.unseenMessageCount == this.unseenMessageCount && + other.ownerId == this.ownerId && + other.pinTime == this.pinTime && + other.muteUntil == this.muteUntil && + other.expireIn == this.expireIn && + other.avatarUrl == this.avatarUrl && + other.name == this.name && + other.ownerVerified == this.ownerVerified && + other.ownerIdentityNumber == this.ownerIdentityNumber && + other.ownerMuteUntil == this.ownerMuteUntil && + other.appId == this.appId && + other.content == this.content && + other.contentType == this.contentType && + other.createdAt == this.createdAt && + other.lastMessageCreatedAt == this.lastMessageCreatedAt && + other.mediaUrl == this.mediaUrl && + other.senderId == this.senderId && + other.actionName == this.actionName && + other.messageStatus == this.messageStatus && + other.senderFullName == this.senderFullName && + other.snapshotType == this.snapshotType && + other.participantFullName == this.participantFullName && + other.participantUserId == this.participantUserId && + other.messageExpireIn == this.messageExpireIn && + other.mentionCount == this.mentionCount && + other.relationship == this.relationship); + @override + String toString() { + return (StringBuffer('ConversationItem(') + ..write('conversationId: $conversationId, ') + ..write('groupIconUrl: $groupIconUrl, ') + ..write('category: $category, ') + ..write('draft: $draft, ') + ..write('groupName: $groupName, ') + ..write('status: $status, ') + ..write('lastReadMessageId: $lastReadMessageId, ') + ..write('unseenMessageCount: $unseenMessageCount, ') + ..write('ownerId: $ownerId, ') + ..write('pinTime: $pinTime, ') + ..write('muteUntil: $muteUntil, ') + ..write('expireIn: $expireIn, ') + ..write('avatarUrl: $avatarUrl, ') + ..write('name: $name, ') + ..write('ownerVerified: $ownerVerified, ') + ..write('ownerIdentityNumber: $ownerIdentityNumber, ') + ..write('ownerMuteUntil: $ownerMuteUntil, ') + ..write('appId: $appId, ') + ..write('content: $content, ') + ..write('contentType: $contentType, ') + ..write('createdAt: $createdAt, ') + ..write('lastMessageCreatedAt: $lastMessageCreatedAt, ') + ..write('mediaUrl: $mediaUrl, ') + ..write('senderId: $senderId, ') + ..write('actionName: $actionName, ') + ..write('messageStatus: $messageStatus, ') + ..write('senderFullName: $senderFullName, ') + ..write('snapshotType: $snapshotType, ') + ..write('participantFullName: $participantFullName, ') + ..write('participantUserId: $participantUserId, ') + ..write('messageExpireIn: $messageExpireIn, ') + ..write('mentionCount: $mentionCount, ') + ..write('relationship: $relationship') + ..write(')')) + .toString(); + } +} + +typedef BaseConversationItems$where = Expression Function( + Conversations conversation, + Users owner, + Messages lastMessage, + Users lastMessageSender, + Snapshots snapshot, + Users participant, + ExpiredMessages em); +typedef BaseConversationItems$order = OrderBy Function( + Conversations conversation, + Users owner, + Messages lastMessage, + Users lastMessageSender, + Snapshots snapshot, + Users participant, + ExpiredMessages em); +typedef BaseConversationItems$limit = Limit Function( + Conversations conversation, + Users owner, + Messages lastMessage, + Users lastMessageSender, + Snapshots snapshot, + Users participant, + ExpiredMessages em); +typedef BaseConversationItemsByCircleId$where = Expression Function( + Conversations conversation, + Users owner, + CircleConversations circleConversation, + Messages lastMessage, + Users lastMessageSender, + Snapshots snapshot, + Users participant, + ExpiredMessages em); +typedef BaseConversationItemsByCircleId$order = OrderBy Function( + Conversations conversation, + Users owner, + CircleConversations circleConversation, + Messages lastMessage, + Users lastMessageSender, + Snapshots snapshot, + Users participant, + ExpiredMessages em); +typedef BaseConversationItemsByCircleId$limit = Limit Function( + Conversations conversation, + Users owner, + CircleConversations circleConversation, + Messages lastMessage, + Users lastMessageSender, + Snapshots snapshot, + Users participant, + ExpiredMessages em); +typedef BaseUnseenMessageCount$where = Expression Function( + Conversations conversation, + Users owner, + CircleConversations circleConversation); + +class BaseUnseenConversationCountResult { + final int unseenConversationCount; + final int unseenMutedConversationCount; + BaseUnseenConversationCountResult({ + required this.unseenConversationCount, + required this.unseenMutedConversationCount, + }); + @override + int get hashCode => + Object.hash(unseenConversationCount, unseenMutedConversationCount); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is BaseUnseenConversationCountResult && + other.unseenConversationCount == this.unseenConversationCount && + other.unseenMutedConversationCount == + this.unseenMutedConversationCount); + @override + String toString() { + return (StringBuffer('BaseUnseenConversationCountResult(') + ..write('unseenConversationCount: $unseenConversationCount, ') + ..write('unseenMutedConversationCount: $unseenMutedConversationCount') + ..write(')')) + .toString(); + } +} + +typedef BaseUnseenConversationCount$where = Expression Function( + Conversations conversation, Users owner); + +class SearchConversationItem { + final String conversationId; + final String? groupIconUrl; + final ConversationCategory? category; + final String? groupName; + final DateTime? pinTime; + final DateTime? muteUntil; + final String? ownerId; + final DateTime? ownerMuteUntil; + final String ownerIdentityNumber; + final String? fullName; + final String? avatarUrl; + final bool? isVerified; + final String? appId; + final MessageStatus? messageStatus; + final String? content; + final String? contentType; + final String? senderId; + final String? actionName; + final String? senderFullName; + final String? participantUserId; + final String? participantFullName; + SearchConversationItem({ + required this.conversationId, + this.groupIconUrl, + this.category, + this.groupName, + this.pinTime, + this.muteUntil, + this.ownerId, + this.ownerMuteUntil, + required this.ownerIdentityNumber, + this.fullName, + this.avatarUrl, + this.isVerified, + this.appId, + this.messageStatus, + this.content, + this.contentType, + this.senderId, + this.actionName, + this.senderFullName, + this.participantUserId, + this.participantFullName, + }); + @override + int get hashCode => Object.hashAll([ + conversationId, + groupIconUrl, + category, + groupName, + pinTime, + muteUntil, + ownerId, + ownerMuteUntil, + ownerIdentityNumber, + fullName, + avatarUrl, + isVerified, + appId, + messageStatus, + content, + contentType, + senderId, + actionName, + senderFullName, + participantUserId, + participantFullName + ]); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is SearchConversationItem && + other.conversationId == this.conversationId && + other.groupIconUrl == this.groupIconUrl && + other.category == this.category && + other.groupName == this.groupName && + other.pinTime == this.pinTime && + other.muteUntil == this.muteUntil && + other.ownerId == this.ownerId && + other.ownerMuteUntil == this.ownerMuteUntil && + other.ownerIdentityNumber == this.ownerIdentityNumber && + other.fullName == this.fullName && + other.avatarUrl == this.avatarUrl && + other.isVerified == this.isVerified && + other.appId == this.appId && + other.messageStatus == this.messageStatus && + other.content == this.content && + other.contentType == this.contentType && + other.senderId == this.senderId && + other.actionName == this.actionName && + other.senderFullName == this.senderFullName && + other.participantUserId == this.participantUserId && + other.participantFullName == this.participantFullName); + @override + String toString() { + return (StringBuffer('SearchConversationItem(') + ..write('conversationId: $conversationId, ') + ..write('groupIconUrl: $groupIconUrl, ') + ..write('category: $category, ') + ..write('groupName: $groupName, ') + ..write('pinTime: $pinTime, ') + ..write('muteUntil: $muteUntil, ') + ..write('ownerId: $ownerId, ') + ..write('ownerMuteUntil: $ownerMuteUntil, ') + ..write('ownerIdentityNumber: $ownerIdentityNumber, ') + ..write('fullName: $fullName, ') + ..write('avatarUrl: $avatarUrl, ') + ..write('isVerified: $isVerified, ') + ..write('appId: $appId, ') + ..write('messageStatus: $messageStatus, ') + ..write('content: $content, ') + ..write('contentType: $contentType, ') + ..write('senderId: $senderId, ') + ..write('actionName: $actionName, ') + ..write('senderFullName: $senderFullName, ') + ..write('participantUserId: $participantUserId, ') + ..write('participantFullName: $participantFullName') + ..write(')')) + .toString(); + } +} + +typedef FuzzySearchConversation$where = Expression Function( + Conversations conversation, + Users owner, + Messages message, + Users lastMessageSender, + Users participant); +typedef FuzzySearchConversation$limit = Limit Function( + Conversations conversation, + Users owner, + Messages message, + Users lastMessageSender, + Users participant); +typedef SearchConversationItemByIn$order = OrderBy Function( + Conversations conversation, + Users owner, + Messages message, + Users lastMessageSender, + Users participant); +typedef FuzzySearchConversationInCircle$where = Expression Function( + Conversations conversation, + Users owner, + Messages message, + Users lastMessageSender, + CircleConversations circleConversation, + Users participant); +typedef FuzzySearchConversationInCircle$limit = Limit Function( + Conversations conversation, + Users owner, + Messages message, + Users lastMessageSender, + CircleConversations circleConversation, + Users participant); + +class ConversationStorageUsage { + final String conversationId; + final String? ownerId; + final ConversationCategory? category; + final String? iconUrl; + final String? name; + final String identityNumber; + final String? fullName; + final String? avatarUrl; + final bool? isVerified; + ConversationStorageUsage({ + required this.conversationId, + this.ownerId, + this.category, + this.iconUrl, + this.name, + required this.identityNumber, + this.fullName, + this.avatarUrl, + this.isVerified, + }); + @override + int get hashCode => Object.hash(conversationId, ownerId, category, iconUrl, + name, identityNumber, fullName, avatarUrl, isVerified); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is ConversationStorageUsage && + other.conversationId == this.conversationId && + other.ownerId == this.ownerId && + other.category == this.category && + other.iconUrl == this.iconUrl && + other.name == this.name && + other.identityNumber == this.identityNumber && + other.fullName == this.fullName && + other.avatarUrl == this.avatarUrl && + other.isVerified == this.isVerified); + @override + String toString() { + return (StringBuffer('ConversationStorageUsage(') + ..write('conversationId: $conversationId, ') + ..write('ownerId: $ownerId, ') + ..write('category: $category, ') + ..write('iconUrl: $iconUrl, ') + ..write('name: $name, ') + ..write('identityNumber: $identityNumber, ') + ..write('fullName: $fullName, ') + ..write('avatarUrl: $avatarUrl, ') + ..write('isVerified: $isVerified') + ..write(')')) + .toString(); + } +} + +class GroupMinimal { + final String conversationId; + final String? groupIconUrl; + final String? groupName; + final int memberCount; + GroupMinimal({ + required this.conversationId, + this.groupIconUrl, + this.groupName, + required this.memberCount, + }); + @override + int get hashCode => + Object.hash(conversationId, groupIconUrl, groupName, memberCount); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is GroupMinimal && + other.conversationId == this.conversationId && + other.groupIconUrl == this.groupIconUrl && + other.groupName == this.groupName && + other.memberCount == this.memberCount); + @override + String toString() { + return (StringBuffer('GroupMinimal(') + ..write('conversationId: $conversationId, ') + ..write('groupIconUrl: $groupIconUrl, ') + ..write('groupName: $groupName, ') + ..write('memberCount: $memberCount') + ..write(')')) + .toString(); + } +} diff --git a/lib/db/dao/favorite_app_dao.dart b/lib/db/dao/favorite_app_dao.dart index b402f107a7..ae515aa1c3 100644 --- a/lib/db/dao/favorite_app_dao.dart +++ b/lib/db/dao/favorite_app_dao.dart @@ -6,17 +6,14 @@ import '../mixin_database.dart'; part 'favorite_app_dao.g.dart'; -@DriftAccessor() +@DriftAccessor(include: {'../moor/dao/favorite_app.drift'}) class FavoriteAppDao extends DatabaseAccessor with _$FavoriteAppDaoMixin { FavoriteAppDao(super.db); - Future _deleteByUserId(String userId) => - db.deleteFavoriteAppByUserId(userId); - Future insertFavoriteApps( String userId, List apps) async { - await _deleteByUserId(userId); + await _deleteFavoriteAppByUserId(userId); final list = apps .map((app) => FavoriteAppsCompanion.insert( appId: app.appId, @@ -29,7 +26,4 @@ class FavoriteAppDao extends DatabaseAccessor DataBaseEventBus.instance.updateFavoriteApp(apps.map((e) => e.appId)); } - - Selectable getFavoriteAppsByUserId(String userId) => - db.getFavoriteAppByUserId(userId); } diff --git a/lib/db/dao/favorite_app_dao.g.dart b/lib/db/dao/favorite_app_dao.g.dart index 205232f475..048829eeef 100644 --- a/lib/db/dao/favorite_app_dao.g.dart +++ b/lib/db/dao/favorite_app_dao.g.dart @@ -3,4 +3,60 @@ part of 'favorite_app_dao.dart'; // ignore_for_file: type=lint -mixin _$FavoriteAppDaoMixin on DatabaseAccessor {} +mixin _$FavoriteAppDaoMixin on DatabaseAccessor { + FavoriteApps get favoriteApps => attachedDatabase.favoriteApps; + Apps get apps => attachedDatabase.apps; + Addresses get addresses => attachedDatabase.addresses; + Assets get assets => attachedDatabase.assets; + CircleConversations get circleConversations => + attachedDatabase.circleConversations; + Circles get circles => attachedDatabase.circles; + Conversations get conversations => attachedDatabase.conversations; + FloodMessages get floodMessages => attachedDatabase.floodMessages; + Hyperlinks get hyperlinks => attachedDatabase.hyperlinks; + Jobs get jobs => attachedDatabase.jobs; + MessageMentions get messageMentions => attachedDatabase.messageMentions; + Messages get messages => attachedDatabase.messages; + MessagesHistory get messagesHistory => attachedDatabase.messagesHistory; + Offsets get offsets => attachedDatabase.offsets; + ParticipantSession get participantSession => + attachedDatabase.participantSession; + Participants get participants => attachedDatabase.participants; + ResendSessionMessages get resendSessionMessages => + attachedDatabase.resendSessionMessages; + SentSessionSenderKeys get sentSessionSenderKeys => + attachedDatabase.sentSessionSenderKeys; + Snapshots get snapshots => attachedDatabase.snapshots; + StickerAlbums get stickerAlbums => attachedDatabase.stickerAlbums; + StickerRelationships get stickerRelationships => + attachedDatabase.stickerRelationships; + Stickers get stickers => attachedDatabase.stickers; + Users get users => attachedDatabase.users; + TranscriptMessages get transcriptMessages => + attachedDatabase.transcriptMessages; + PinMessages get pinMessages => attachedDatabase.pinMessages; + Fiats get fiats => attachedDatabase.fiats; + ExpiredMessages get expiredMessages => attachedDatabase.expiredMessages; + Chains get chains => attachedDatabase.chains; + Properties get properties => attachedDatabase.properties; + Future _deleteFavoriteAppByUserId(String userId) { + return customUpdate( + 'DELETE FROM favorite_apps WHERE user_id = ?1', + variables: [Variable(userId)], + updates: {favoriteApps}, + updateKind: UpdateKind.delete, + ); + } + + Selectable getFavoriteAppsByUserId(String userId) { + return customSelect( + 'SELECT a.* FROM favorite_apps AS fa INNER JOIN apps AS a ON fa.app_id = a.app_id WHERE fa.user_id = ?1', + variables: [ + Variable(userId) + ], + readsFrom: { + favoriteApps, + apps, + }).asyncMap(apps.mapFromRow); + } +} diff --git a/lib/db/dao/flood_message_dao.dart b/lib/db/dao/flood_message_dao.dart index 67bc017faa..26ef09604e 100644 --- a/lib/db/dao/flood_message_dao.dart +++ b/lib/db/dao/flood_message_dao.dart @@ -4,7 +4,7 @@ import '../mixin_database.dart'; part 'flood_message_dao.g.dart'; -@DriftAccessor() +@DriftAccessor(include: {'../moor/dao/flood.drift'}) class FloodMessageDao extends DatabaseAccessor with _$FloodMessageDaoMixin { FloodMessageDao(super.db); @@ -33,5 +33,5 @@ class FloodMessageDao extends DatabaseAccessor } Future getLastBlazeMessageCreatedAt() => - db.getLastBlazeMessageCreatedAt().getSingleOrNull(); + _getLastBlazeMessageCreatedAt().getSingleOrNull(); } diff --git a/lib/db/dao/flood_message_dao.g.dart b/lib/db/dao/flood_message_dao.g.dart index 2b904fa412..0e0f371d83 100644 --- a/lib/db/dao/flood_message_dao.g.dart +++ b/lib/db/dao/flood_message_dao.g.dart @@ -3,4 +3,49 @@ part of 'flood_message_dao.dart'; // ignore_for_file: type=lint -mixin _$FloodMessageDaoMixin on DatabaseAccessor {} +mixin _$FloodMessageDaoMixin on DatabaseAccessor { + FloodMessages get floodMessages => attachedDatabase.floodMessages; + Addresses get addresses => attachedDatabase.addresses; + Apps get apps => attachedDatabase.apps; + Assets get assets => attachedDatabase.assets; + CircleConversations get circleConversations => + attachedDatabase.circleConversations; + Circles get circles => attachedDatabase.circles; + Conversations get conversations => attachedDatabase.conversations; + Hyperlinks get hyperlinks => attachedDatabase.hyperlinks; + Jobs get jobs => attachedDatabase.jobs; + MessageMentions get messageMentions => attachedDatabase.messageMentions; + Messages get messages => attachedDatabase.messages; + MessagesHistory get messagesHistory => attachedDatabase.messagesHistory; + Offsets get offsets => attachedDatabase.offsets; + ParticipantSession get participantSession => + attachedDatabase.participantSession; + Participants get participants => attachedDatabase.participants; + ResendSessionMessages get resendSessionMessages => + attachedDatabase.resendSessionMessages; + SentSessionSenderKeys get sentSessionSenderKeys => + attachedDatabase.sentSessionSenderKeys; + Snapshots get snapshots => attachedDatabase.snapshots; + StickerAlbums get stickerAlbums => attachedDatabase.stickerAlbums; + StickerRelationships get stickerRelationships => + attachedDatabase.stickerRelationships; + Stickers get stickers => attachedDatabase.stickers; + Users get users => attachedDatabase.users; + TranscriptMessages get transcriptMessages => + attachedDatabase.transcriptMessages; + PinMessages get pinMessages => attachedDatabase.pinMessages; + Fiats get fiats => attachedDatabase.fiats; + FavoriteApps get favoriteApps => attachedDatabase.favoriteApps; + ExpiredMessages get expiredMessages => attachedDatabase.expiredMessages; + Chains get chains => attachedDatabase.chains; + Properties get properties => attachedDatabase.properties; + Selectable _getLastBlazeMessageCreatedAt() { + return customSelect( + 'SELECT created_at FROM flood_messages ORDER BY created_at DESC LIMIT 1', + variables: [], + readsFrom: { + floodMessages, + }).map((QueryRow row) => + FloodMessages.$convertercreatedAt.fromSql(row.read('created_at'))); + } +} diff --git a/lib/db/dao/message_dao.dart b/lib/db/dao/message_dao.dart index f197d06a8c..f556882e60 100644 --- a/lib/db/dao/message_dao.dart +++ b/lib/db/dao/message_dao.dart @@ -23,7 +23,7 @@ class MessageOrderInfo { final int createdAt; } -@DriftAccessor() +@DriftAccessor(include: {'../moor/dao/message.drift'}) class MessageDao extends DatabaseAccessor with _$MessageDaoMixin { MessageDao(super.db); @@ -56,10 +56,6 @@ class MessageDao extends DatabaseAccessor return messages; }); - Selectable notificationMessage( - List messageIds) => - db.notificationMessage(messageIds); - Selectable _baseMessageItems( Expression Function( Messages message, @@ -134,7 +130,7 @@ class MessageDao extends DatabaseAccessor Future future, ) async { final result = await future; - final miniMessage = await db.miniMessageByIds(messageIds).get(); + final miniMessage = await miniMessageByIds(messageIds).get(); DataBaseEventBus.instance.insertOrReplaceMessages(miniMessage); return result; } @@ -304,9 +300,6 @@ class MessageDao extends DatabaseAccessor DataBaseEventBus.instance.updateConversation(conversationId); } - Future sendingMessage(String messageId) async => - db.sendingMessage(messageId).getSingleOrNull(); - Future updateMessageStatusById( String messageId, MessageStatus status) async { final already = await db.hasData( @@ -322,43 +315,48 @@ class MessageDao extends DatabaseAccessor ); } - Future findMessageStatusById(String messageId) => - db.findMessageStatusById(messageId).getSingleOrNull(); - Future updateMedia({ required String path, required String messageId, required int mediaSize, required MediaStatus mediaStatus, String? content, - }) => - _sendInsertOrReplaceEventWithFuture( - [messageId], - db.transaction(() async { - await Future.wait([ - (db.update(db.messages) - ..where((tbl) => tbl.messageId.equals(messageId))) - .write(MessagesCompanion( - mediaUrl: Value(path.pathBasename), - mediaSize: Value(mediaSize), - mediaStatus: Value(mediaStatus), - )), - (db.update(db.transcriptMessages) - ..where((tbl) => tbl.messageId.equals(messageId))) - .write(TranscriptMessagesCompanion( - mediaUrl: Value(path.pathBasename), - mediaSize: Value(mediaSize), - mediaStatus: Value(mediaStatus), - content: content != null ? Value(content) : const Value.absent(), - )), - ]); - }), - ); + }) async { + final [ + messageResult, + transcriptMessageResult + ] = await db.transaction(() => Future.wait([ + (db.update(db.messages) + ..where((tbl) => tbl.messageId.equals(messageId))) + .write(MessagesCompanion( + mediaUrl: Value(path.pathBasename), + mediaSize: Value(mediaSize), + mediaStatus: Value(mediaStatus), + )), + (db.update(db.transcriptMessages) + ..where((tbl) => tbl.messageId.equals(messageId))) + .write(TranscriptMessagesCompanion( + mediaUrl: Value(path.pathBasename), + mediaSize: Value(mediaSize), + mediaStatus: Value(mediaStatus), + content: content != null ? Value(content) : const Value.absent(), + )), + ])); + + await _notifyEventByMessageId( + messageId, + notifyMessageEvent: messageResult > 0, + notifyTranscriptMessageEvent: transcriptMessageResult > 0, + ); + } Future updateMediaStatus(String messageId, MediaStatus status) async { if (!await hasMediaStatus(messageId, status, true)) return; - final result = await db.transaction(() => Future.wait([ + final [ + messageResult, + transcriptMessageResult + ] = await db.transaction(() => Future.wait([ (db.update(db.messages) ..where((tbl) => tbl.messageId.equals(messageId))) .write(MessagesCompanion(mediaStatus: Value(status))), @@ -366,7 +364,20 @@ class MessageDao extends DatabaseAccessor ..where((tbl) => tbl.messageId.equals(messageId))) .write(TranscriptMessagesCompanion(mediaStatus: Value(status))), ])); - if (result.cast().any((element) => element > -1)) { + + await _notifyEventByMessageId( + messageId, + notifyMessageEvent: messageResult > 0, + notifyTranscriptMessageEvent: transcriptMessageResult > 0, + ); + } + + Future _notifyEventByMessageId(String messageId, + {required bool notifyMessageEvent, + required bool notifyTranscriptMessageEvent}) async { + if (!notifyMessageEvent && !notifyTranscriptMessageEvent) return; + + Future notifyEventForMessage() async { final conversationId = await findConversationIdByMessageId(messageId); if (conversationId == null) return; DataBaseEventBus.instance.insertOrReplaceMessages([ @@ -376,6 +387,33 @@ class MessageDao extends DatabaseAccessor ) ]); } + + Future notifyEventForTranscriptMessage() async { + final list = await db.transcriptMessageDao + .transcriptMessageByMessageId(messageId, maxLimit) + .get(); + if (list.isEmpty) return; + + final miniTranscriptMessages = list.map((e) => MiniTranscriptMessage( + transcriptId: e.transcriptId, + messageId: e.messageId, + )); + if (miniTranscriptMessages.isNotEmpty) { + DataBaseEventBus.instance + .updateTranscriptMessage(miniTranscriptMessages); + } + + final miniMessages = + await miniMessageByIds(list.map((e) => e.transcriptId).toList()) + .get(); + if (miniMessages.isEmpty) return; + DataBaseEventBus.instance.insertOrReplaceMessages(miniMessages); + } + + await Future.wait([ + if (notifyMessageEvent) notifyEventForMessage(), + if (notifyTranscriptMessageEvent) notifyEventForTranscriptMessage(), + ]); } Future messageHasMediaStatus(String messageId, MediaStatus mediaStatus, @@ -568,36 +606,28 @@ class MessageDao extends DatabaseAccessor Future findMessageItemById( String conversationId, String messageId) => - db - .baseQuoteMessageItem( - (message, sender, sticker, shareUser, messageMention) => - message.conversationId.equals(conversationId) & - message.messageId.equals(messageId) & - message.status.equalsValue(MessageStatus.failed).not(), - (message, sender, sticker, shareUser, messageMention) => - ignoreOrderBy, - (message, sender, sticker, shareUser, messageMention) => - Limit(1, 0)) - .getSingleOrNull(); + _baseQuoteMessageItem( + (message, sender, sticker, shareUser, messageMention) => + message.conversationId.equals(conversationId) & + message.messageId.equals(messageId) & + message.status.equalsValue(MessageStatus.failed).not(), + (message, sender, sticker, shareUser, messageMention) => + ignoreOrderBy, + (message, sender, sticker, shareUser, messageMention) => + Limit(1, 0)).getSingleOrNull(); Future findMessageItemByMessageId( String? messageId) async { if (messageId == null) return null; - return db - .baseQuoteMessageItem( - (message, sender, sticker, shareUser, messageMention) => - message.messageId.equals(messageId) & - message.status.equalsValue(MessageStatus.failed).not(), - (message, sender, sticker, shareUser, messageMention) => - ignoreOrderBy, - (message, sender, sticker, shareUser, messageMention) => - Limit(1, 0)) - .getSingleOrNull(); + return _baseQuoteMessageItem( + (message, sender, sticker, shareUser, messageMention) => + message.messageId.equals(messageId) & + message.status.equalsValue(MessageStatus.failed).not(), + (message, sender, sticker, shareUser, messageMention) => ignoreOrderBy, + (message, sender, sticker, shareUser, messageMention) => + Limit(1, 0)).getSingleOrNull(); } - Selectable findBigQuoteMessage(int rowId, int limit) => - db.findBigQuoteMessage(rowId, limit); - Future updateMessageQuoteContent( String messageId, String? quoteContent) => (update(db.messages)..where((tbl) => tbl.messageId.equals(messageId))) @@ -605,9 +635,6 @@ class MessageDao extends DatabaseAccessor quoteContent: Value(quoteContent), )); - Selectable miniMessageByIds(List messageIds) => - db.miniMessageByIds(messageIds); - Future findMessageByMessageId(String messageId) => (db.select(db.messages) ..where((tbl) => tbl.messageId.equals(messageId)) @@ -1197,7 +1224,7 @@ class MessageDao extends DatabaseAccessor )) .getSingleOrNull(); } - return db.searchMessage((m, c, u, o) { + return _searchMessage((m, c, u, o) { var predicate = m.conversationId.equals(conversationId) & m.userId.equals(userId); if (categories?.isNotEmpty ?? false) { diff --git a/lib/db/dao/message_dao.g.dart b/lib/db/dao/message_dao.g.dart index aba194430c..efb61232c2 100644 --- a/lib/db/dao/message_dao.g.dart +++ b/lib/db/dao/message_dao.g.dart @@ -3,4 +3,1043 @@ part of 'message_dao.dart'; // ignore_for_file: type=lint -mixin _$MessageDaoMixin on DatabaseAccessor {} +mixin _$MessageDaoMixin on DatabaseAccessor { + Conversations get conversations => attachedDatabase.conversations; + Messages get messages => attachedDatabase.messages; + Users get users => attachedDatabase.users; + Stickers get stickers => attachedDatabase.stickers; + MessageMentions get messageMentions => attachedDatabase.messageMentions; + ResendSessionMessages get resendSessionMessages => + attachedDatabase.resendSessionMessages; + Addresses get addresses => attachedDatabase.addresses; + Apps get apps => attachedDatabase.apps; + Assets get assets => attachedDatabase.assets; + CircleConversations get circleConversations => + attachedDatabase.circleConversations; + Circles get circles => attachedDatabase.circles; + FloodMessages get floodMessages => attachedDatabase.floodMessages; + Hyperlinks get hyperlinks => attachedDatabase.hyperlinks; + Jobs get jobs => attachedDatabase.jobs; + MessagesHistory get messagesHistory => attachedDatabase.messagesHistory; + Offsets get offsets => attachedDatabase.offsets; + ParticipantSession get participantSession => + attachedDatabase.participantSession; + Participants get participants => attachedDatabase.participants; + SentSessionSenderKeys get sentSessionSenderKeys => + attachedDatabase.sentSessionSenderKeys; + Snapshots get snapshots => attachedDatabase.snapshots; + StickerAlbums get stickerAlbums => attachedDatabase.stickerAlbums; + StickerRelationships get stickerRelationships => + attachedDatabase.stickerRelationships; + TranscriptMessages get transcriptMessages => + attachedDatabase.transcriptMessages; + PinMessages get pinMessages => attachedDatabase.pinMessages; + Fiats get fiats => attachedDatabase.fiats; + FavoriteApps get favoriteApps => attachedDatabase.favoriteApps; + ExpiredMessages get expiredMessages => attachedDatabase.expiredMessages; + Chains get chains => attachedDatabase.chains; + Properties get properties => attachedDatabase.properties; + Selectable _baseQuoteMessageItem( + BaseQuoteMessageItem$where where, + BaseQuoteMessageItem$order order, + BaseQuoteMessageItem$limit limit) { + var $arrayStartIndex = 1; + final generatedwhere = $write( + where( + alias(this.messages, 'message'), + alias(this.users, 'sender'), + alias(this.stickers, 'sticker'), + alias(this.users, 'shareUser'), + alias(this.messageMentions, 'messageMention')), + hasMultipleTables: true, + startIndex: $arrayStartIndex); + $arrayStartIndex += generatedwhere.amountOfVariables; + final generatedorder = $write( + order?.call( + alias(this.messages, 'message'), + alias(this.users, 'sender'), + alias(this.stickers, 'sticker'), + alias(this.users, 'shareUser'), + alias(this.messageMentions, 'messageMention')) ?? + const OrderBy.nothing(), + hasMultipleTables: true, + startIndex: $arrayStartIndex); + $arrayStartIndex += generatedorder.amountOfVariables; + final generatedlimit = $write( + limit( + alias(this.messages, 'message'), + alias(this.users, 'sender'), + alias(this.stickers, 'sticker'), + alias(this.users, 'shareUser'), + alias(this.messageMentions, 'messageMention')), + hasMultipleTables: true, + startIndex: $arrayStartIndex); + $arrayStartIndex += generatedlimit.amountOfVariables; + return customSelect( + 'SELECT message.message_id AS messageId, message.conversation_id AS conversationId, sender.user_id AS userId, sender.full_name AS userFullName, sender.identity_number AS userIdentityNumber, sender.app_id AS appId, message.category AS type, message.content AS content, message.created_at AS createdAt, message.status AS status, message.media_status AS mediaStatus, message.media_waveform AS mediaWaveform, message.name AS mediaName, message.media_mime_type AS mediaMimeType, message.media_size AS mediaSize, message.media_width AS mediaWidth, message.media_height AS mediaHeight, message.thumb_image AS thumbImage, message.thumb_url AS thumbUrl, message.media_url AS mediaUrl, message.media_duration AS mediaDuration, message.sticker_id AS stickerId, sticker.asset_url AS assetUrl, sticker.asset_width AS assetWidth, sticker.asset_height AS assetHeight, sticker.name AS assetName, sticker.asset_type AS assetType, message.shared_user_id AS sharedUserId, shareUser.full_name AS sharedUserFullName, shareUser.identity_number AS sharedUserIdentityNumber, shareUser.avatar_url AS sharedUserAvatarUrl, shareUser.is_verified AS sharedUserIsVerified, shareUser.app_id AS sharedUserAppId FROM messages AS message INNER JOIN users AS sender ON message.user_id = sender.user_id LEFT JOIN stickers AS sticker ON sticker.sticker_id = message.sticker_id LEFT JOIN users AS shareUser ON message.shared_user_id = shareUser.user_id LEFT JOIN message_mentions AS messageMention ON message.message_id = messageMention.message_id WHERE ${generatedwhere.sql} ${generatedorder.sql} ${generatedlimit.sql}', + variables: [ + ...generatedwhere.introducedVariables, + ...generatedorder.introducedVariables, + ...generatedlimit.introducedVariables + ], + readsFrom: { + messages, + users, + stickers, + messageMentions, + ...generatedwhere.watchedTables, + ...generatedorder.watchedTables, + ...generatedlimit.watchedTables, + }).map((QueryRow row) { + return QuoteMessageItem( + messageId: row.read('messageId'), + conversationId: row.read('conversationId'), + userId: row.read('userId'), + userFullName: row.readNullable('userFullName'), + userIdentityNumber: row.read('userIdentityNumber'), + appId: row.readNullable('appId'), + type: row.read('type'), + content: row.readNullable('content'), + createdAt: + Messages.$convertercreatedAt.fromSql(row.read('createdAt')), + status: Messages.$converterstatus.fromSql(row.read('status')), + mediaStatus: Messages.$convertermediaStatus + .fromSql(row.readNullable('mediaStatus')), + mediaWaveform: row.readNullable('mediaWaveform'), + mediaName: row.readNullable('mediaName'), + mediaMimeType: row.readNullable('mediaMimeType'), + mediaSize: row.readNullable('mediaSize'), + mediaWidth: row.readNullable('mediaWidth'), + mediaHeight: row.readNullable('mediaHeight'), + thumbImage: row.readNullable('thumbImage'), + thumbUrl: row.readNullable('thumbUrl'), + mediaUrl: row.readNullable('mediaUrl'), + mediaDuration: row.readNullable('mediaDuration'), + stickerId: row.readNullable('stickerId'), + assetUrl: row.readNullable('assetUrl'), + assetWidth: row.readNullable('assetWidth'), + assetHeight: row.readNullable('assetHeight'), + assetName: row.readNullable('assetName'), + assetType: row.readNullable('assetType'), + sharedUserId: row.readNullable('sharedUserId'), + sharedUserFullName: row.readNullable('sharedUserFullName'), + sharedUserIdentityNumber: + row.readNullable('sharedUserIdentityNumber'), + sharedUserAvatarUrl: row.readNullable('sharedUserAvatarUrl'), + sharedUserIsVerified: row.readNullable('sharedUserIsVerified'), + sharedUserAppId: row.readNullable('sharedUserAppId'), + ); + }); + } + + Selectable messageStatusById(String messageId) { + return customSelect( + 'SELECT status FROM messages WHERE message_id = ?1 LIMIT 1', + variables: [ + Variable(messageId) + ], + readsFrom: { + messages, + }).map((QueryRow row) => + Messages.$converterstatus.fromSql(row.read('status'))); + } + + Selectable sendingMessage(String messageId) { + return customSelect( + 'SELECT m.message_id, m.conversation_id, m.user_id, m.category, m.content, m.media_url, m.media_mime_type, m.media_size, m.media_duration, m.media_width, m.media_height, m.media_hash, m.thumb_image, m.media_key, m.media_digest, m.media_status, m.status, m.created_at, m."action", m.participant_id, m.snapshot_id, m.hyperlink, m.name, m.album_id, m.sticker_id, m.shared_user_id, m.media_waveform, m.quote_message_id, m.quote_content, rm.status AS resend_status, rm.user_id AS resend_user_id, rm.session_id AS resend_session_id FROM messages AS m LEFT JOIN resend_session_messages AS rm ON m.message_id = rm.message_id WHERE m.message_id = ?1 AND(m.status = \'SENDING\' OR rm.status = 1)AND m.content IS NOT NULL LIMIT 1', + variables: [ + Variable(messageId) + ], + readsFrom: { + messages, + resendSessionMessages, + }).map((QueryRow row) { + return SendingMessage( + messageId: row.read('message_id'), + conversationId: row.read('conversation_id'), + userId: row.read('user_id'), + category: row.read('category'), + content: row.readNullable('content'), + mediaUrl: row.readNullable('media_url'), + mediaMimeType: row.readNullable('media_mime_type'), + mediaSize: row.readNullable('media_size'), + mediaDuration: row.readNullable('media_duration'), + mediaWidth: row.readNullable('media_width'), + mediaHeight: row.readNullable('media_height'), + mediaHash: row.readNullable('media_hash'), + thumbImage: row.readNullable('thumb_image'), + mediaKey: row.readNullable('media_key'), + mediaDigest: row.readNullable('media_digest'), + mediaStatus: Messages.$convertermediaStatus + .fromSql(row.readNullable('media_status')), + status: Messages.$converterstatus.fromSql(row.read('status')), + createdAt: + Messages.$convertercreatedAt.fromSql(row.read('created_at')), + action: row.readNullable('action'), + participantId: row.readNullable('participant_id'), + snapshotId: row.readNullable('snapshot_id'), + hyperlink: row.readNullable('hyperlink'), + name: row.readNullable('name'), + albumId: row.readNullable('album_id'), + stickerId: row.readNullable('sticker_id'), + sharedUserId: row.readNullable('shared_user_id'), + mediaWaveform: row.readNullable('media_waveform'), + quoteMessageId: row.readNullable('quote_message_id'), + quoteContent: row.readNullable('quote_content'), + resendStatus: row.readNullable('resend_status'), + resendUserId: row.readNullable('resend_user_id'), + resendSessionId: row.readNullable('resend_session_id'), + ); + }); + } + + Selectable notificationMessage(List messageId) { + var $arrayStartIndex = 1; + final expandedmessageId = $expandVar($arrayStartIndex, messageId.length); + $arrayStartIndex += messageId.length; + return customSelect( + 'SELECT m.message_id AS messageId, m.conversation_id AS conversationId, sender.user_id AS senderId, sender.full_name AS senderFullName, m.category AS type, m.content AS content, m.quote_content AS quoteContent, m.status AS status, c.name AS groupName, c.mute_until AS muteUntil, conversationOwner.mute_until AS ownerMuteUntil, conversationOwner.user_id AS ownerUserId, conversationOwner.full_name AS ownerFullName, m.created_at AS createdAt, c.category AS category, m."action" AS actionName, conversationOwner.relationship AS relationship, pu.full_name AS participantFullName, pu.user_id AS participantUserId FROM messages AS m INNER JOIN users AS sender ON m.user_id = sender.user_id LEFT JOIN conversations AS c ON m.conversation_id = c.conversation_id LEFT JOIN users AS conversationOwner ON c.owner_id = conversationOwner.user_id LEFT JOIN message_mentions AS mm ON m.message_id = mm.message_id LEFT JOIN users AS pu ON pu.user_id = m.participant_id WHERE m.message_id IN ($expandedmessageId) ORDER BY m.created_at DESC', + variables: [ + for (var $ in messageId) Variable($) + ], + readsFrom: { + messages, + users, + conversations, + messageMentions, + }).map((QueryRow row) { + return NotificationMessage( + messageId: row.read('messageId'), + conversationId: row.read('conversationId'), + senderId: row.read('senderId'), + senderFullName: row.readNullable('senderFullName'), + type: row.read('type'), + content: row.readNullable('content'), + quoteContent: row.readNullable('quoteContent'), + status: Messages.$converterstatus.fromSql(row.read('status')), + groupName: row.readNullable('groupName'), + muteUntil: NullAwareTypeConverter.wrapFromSql( + Conversations.$convertermuteUntil, + row.readNullable('muteUntil')), + ownerMuteUntil: NullAwareTypeConverter.wrapFromSql( + Users.$convertermuteUntil, row.readNullable('ownerMuteUntil')), + ownerUserId: row.readNullable('ownerUserId'), + ownerFullName: row.readNullable('ownerFullName'), + createdAt: + Messages.$convertercreatedAt.fromSql(row.read('createdAt')), + category: Conversations.$convertercategory + .fromSql(row.readNullable('category')), + actionName: row.readNullable('actionName'), + relationship: Users.$converterrelationship + .fromSql(row.readNullable('relationship')), + participantFullName: row.readNullable('participantFullName'), + participantUserId: row.readNullable('participantUserId'), + ); + }); + } + + Selectable searchMessageByIds( + List messageIds) { + var $arrayStartIndex = 1; + final expandedmessageIds = $expandVar($arrayStartIndex, messageIds.length); + $arrayStartIndex += messageIds.length; + return customSelect( + 'SELECT m.message_id AS messageId, u.user_id AS senderId, u.avatar_url AS senderAvatarUrl, u.full_name AS senderFullName, m.status AS status, m.category AS type, m.content AS content, m.created_at AS createdAt, m.name AS mediaName, u.app_id AS appId, u.is_verified AS verified, c.owner_id AS ownerId, c.icon_url AS groupIconUrl, c.category AS category, c.name AS groupName, c.conversation_id AS conversationId, owner.full_name AS ownerFullName, owner.avatar_url AS ownerAvatarUrl FROM messages AS m INNER JOIN conversations AS c ON c.conversation_id = m.conversation_id INNER JOIN users AS u ON m.user_id = u.user_id INNER JOIN users AS owner ON c.owner_id = owner.user_id WHERE m.message_id IN ($expandedmessageIds) ORDER BY m.created_at DESC, m."rowid" DESC', + variables: [ + for (var $ in messageIds) Variable($) + ], + readsFrom: { + messages, + users, + conversations, + }).map((QueryRow row) { + return SearchMessageDetailItem( + messageId: row.read('messageId'), + senderId: row.read('senderId'), + senderAvatarUrl: row.readNullable('senderAvatarUrl'), + senderFullName: row.readNullable('senderFullName'), + status: Messages.$converterstatus.fromSql(row.read('status')), + type: row.read('type'), + content: row.readNullable('content'), + createdAt: + Messages.$convertercreatedAt.fromSql(row.read('createdAt')), + mediaName: row.readNullable('mediaName'), + appId: row.readNullable('appId'), + verified: row.readNullable('verified'), + ownerId: row.readNullable('ownerId'), + groupIconUrl: row.readNullable('groupIconUrl'), + category: Conversations.$convertercategory + .fromSql(row.readNullable('category')), + groupName: row.readNullable('groupName'), + conversationId: row.read('conversationId'), + ownerFullName: row.readNullable('ownerFullName'), + ownerAvatarUrl: row.readNullable('ownerAvatarUrl'), + ); + }); + } + + Selectable miniMessageByIds(List messageIds) { + var $arrayStartIndex = 1; + final expandedmessageIds = $expandVar($arrayStartIndex, messageIds.length); + $arrayStartIndex += messageIds.length; + return customSelect( + 'SELECT conversation_id AS conversationId, message_id AS messageId FROM messages WHERE message_id IN ($expandedmessageIds)', + variables: [ + for (var $ in messageIds) Variable($) + ], + readsFrom: { + messages, + }).map((QueryRow row) { + return MiniMessageItem( + conversationId: row.read('conversationId'), + messageId: row.read('messageId'), + ); + }); + } + + Selectable _searchMessage( + SearchMessage$where where, SearchMessage$limit limit) { + var $arrayStartIndex = 1; + final generatedwhere = $write( + where(alias(this.messages, 'm'), alias(this.conversations, 'c'), + alias(this.users, 'u'), alias(this.users, 'owner')), + hasMultipleTables: true, + startIndex: $arrayStartIndex); + $arrayStartIndex += generatedwhere.amountOfVariables; + final generatedlimit = $write( + limit(alias(this.messages, 'm'), alias(this.conversations, 'c'), + alias(this.users, 'u'), alias(this.users, 'owner')), + hasMultipleTables: true, + startIndex: $arrayStartIndex); + $arrayStartIndex += generatedlimit.amountOfVariables; + return customSelect( + 'SELECT m.message_id AS messageId, u.user_id AS senderId, u.avatar_url AS senderAvatarUrl, u.full_name AS senderFullName, m.status AS status, m.category AS type, m.content AS content, m.created_at AS createdAt, m.name AS mediaName, u.app_id AS appId, u.is_verified AS verified, c.owner_id AS ownerId, c.icon_url AS groupIconUrl, c.category AS category, c.name AS groupName, c.conversation_id AS conversationId, owner.full_name AS ownerFullName, owner.avatar_url AS ownerAvatarUrl FROM messages AS m INNER JOIN conversations AS c ON c.conversation_id = m.conversation_id INNER JOIN users AS u ON m.user_id = u.user_id INNER JOIN users AS owner ON c.owner_id = owner.user_id WHERE ${generatedwhere.sql} ORDER BY m.created_at DESC, m."rowid" DESC ${generatedlimit.sql}', + variables: [ + ...generatedwhere.introducedVariables, + ...generatedlimit.introducedVariables + ], + readsFrom: { + messages, + users, + conversations, + ...generatedwhere.watchedTables, + ...generatedlimit.watchedTables, + }).map((QueryRow row) { + return SearchMessageDetailItem( + messageId: row.read('messageId'), + senderId: row.read('senderId'), + senderAvatarUrl: row.readNullable('senderAvatarUrl'), + senderFullName: row.readNullable('senderFullName'), + status: Messages.$converterstatus.fromSql(row.read('status')), + type: row.read('type'), + content: row.readNullable('content'), + createdAt: + Messages.$convertercreatedAt.fromSql(row.read('createdAt')), + mediaName: row.readNullable('mediaName'), + appId: row.readNullable('appId'), + verified: row.readNullable('verified'), + ownerId: row.readNullable('ownerId'), + groupIconUrl: row.readNullable('groupIconUrl'), + category: Conversations.$convertercategory + .fromSql(row.readNullable('category')), + groupName: row.readNullable('groupName'), + conversationId: row.read('conversationId'), + ownerFullName: row.readNullable('ownerFullName'), + ownerAvatarUrl: row.readNullable('ownerAvatarUrl'), + ); + }); + } + + Selectable countMessages() { + return customSelect('SELECT count(1) AS _c0 FROM messages', + variables: [], + readsFrom: { + messages, + }).map((QueryRow row) => row.read('_c0')); + } + + Selectable countMediaMessages() { + return customSelect( + 'SELECT count(1) AS _c0 FROM messages WHERE category IN (\'SIGNAL_IMAGE\', \'SIGNAL_VIDEO\', \'SIGNAL_DATA\', \'SIGNAL_AUDIO\', \'PLAIN_IMAGE\', \'PLAIN_VIDEO\', \'PLAIN_DATA\', \'PLAIN_AUDIO\', \'ENCRYPTED_IMAGE\', \'ENCRYPTED_VIDEO\', \'ENCRYPTED_DATA\', \'ENCRYPTED_AUDIO\')', + variables: [], + readsFrom: { + messages, + }).map((QueryRow row) => row.read('_c0')); + } + + Selectable bigQuoteMessage(int rowId, int limit) { + return customSelect( + 'SELECT "rowid", conversation_id, quote_message_id FROM messages WHERE "rowid" > ?1 AND quote_message_id IS NOT NULL AND quote_message_id != \'\' AND length(quote_content) > 10240 GROUP BY quote_message_id ORDER BY "rowid" ASC LIMIT ?2', + variables: [ + Variable(rowId), + Variable(limit) + ], + readsFrom: { + messages, + }).map((QueryRow row) { + return QuoteMinimal( + rowid: row.read('rowid'), + conversationId: row.read('conversation_id'), + quoteMessageId: row.readNullable('quote_message_id'), + ); + }); + } +} + +class QuoteMessageItem { + final String messageId; + final String conversationId; + final String userId; + final String? userFullName; + final String userIdentityNumber; + final String? appId; + final String type; + final String? content; + final DateTime createdAt; + final MessageStatus status; + final MediaStatus? mediaStatus; + final String? mediaWaveform; + final String? mediaName; + final String? mediaMimeType; + final int? mediaSize; + final int? mediaWidth; + final int? mediaHeight; + final String? thumbImage; + final String? thumbUrl; + final String? mediaUrl; + final String? mediaDuration; + final String? stickerId; + final String? assetUrl; + final int? assetWidth; + final int? assetHeight; + final String? assetName; + final String? assetType; + final String? sharedUserId; + final String? sharedUserFullName; + final String? sharedUserIdentityNumber; + final String? sharedUserAvatarUrl; + final bool? sharedUserIsVerified; + final String? sharedUserAppId; + QuoteMessageItem({ + required this.messageId, + required this.conversationId, + required this.userId, + this.userFullName, + required this.userIdentityNumber, + this.appId, + required this.type, + this.content, + required this.createdAt, + required this.status, + this.mediaStatus, + this.mediaWaveform, + this.mediaName, + this.mediaMimeType, + this.mediaSize, + this.mediaWidth, + this.mediaHeight, + this.thumbImage, + this.thumbUrl, + this.mediaUrl, + this.mediaDuration, + this.stickerId, + this.assetUrl, + this.assetWidth, + this.assetHeight, + this.assetName, + this.assetType, + this.sharedUserId, + this.sharedUserFullName, + this.sharedUserIdentityNumber, + this.sharedUserAvatarUrl, + this.sharedUserIsVerified, + this.sharedUserAppId, + }); + @override + int get hashCode => Object.hashAll([ + messageId, + conversationId, + userId, + userFullName, + userIdentityNumber, + appId, + type, + content, + createdAt, + status, + mediaStatus, + mediaWaveform, + mediaName, + mediaMimeType, + mediaSize, + mediaWidth, + mediaHeight, + thumbImage, + thumbUrl, + mediaUrl, + mediaDuration, + stickerId, + assetUrl, + assetWidth, + assetHeight, + assetName, + assetType, + sharedUserId, + sharedUserFullName, + sharedUserIdentityNumber, + sharedUserAvatarUrl, + sharedUserIsVerified, + sharedUserAppId + ]); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is QuoteMessageItem && + other.messageId == this.messageId && + other.conversationId == this.conversationId && + other.userId == this.userId && + other.userFullName == this.userFullName && + other.userIdentityNumber == this.userIdentityNumber && + other.appId == this.appId && + other.type == this.type && + other.content == this.content && + other.createdAt == this.createdAt && + other.status == this.status && + other.mediaStatus == this.mediaStatus && + other.mediaWaveform == this.mediaWaveform && + other.mediaName == this.mediaName && + other.mediaMimeType == this.mediaMimeType && + other.mediaSize == this.mediaSize && + other.mediaWidth == this.mediaWidth && + other.mediaHeight == this.mediaHeight && + other.thumbImage == this.thumbImage && + other.thumbUrl == this.thumbUrl && + other.mediaUrl == this.mediaUrl && + other.mediaDuration == this.mediaDuration && + other.stickerId == this.stickerId && + other.assetUrl == this.assetUrl && + other.assetWidth == this.assetWidth && + other.assetHeight == this.assetHeight && + other.assetName == this.assetName && + other.assetType == this.assetType && + other.sharedUserId == this.sharedUserId && + other.sharedUserFullName == this.sharedUserFullName && + other.sharedUserIdentityNumber == this.sharedUserIdentityNumber && + other.sharedUserAvatarUrl == this.sharedUserAvatarUrl && + other.sharedUserIsVerified == this.sharedUserIsVerified && + other.sharedUserAppId == this.sharedUserAppId); + @override + String toString() { + return (StringBuffer('QuoteMessageItem(') + ..write('messageId: $messageId, ') + ..write('conversationId: $conversationId, ') + ..write('userId: $userId, ') + ..write('userFullName: $userFullName, ') + ..write('userIdentityNumber: $userIdentityNumber, ') + ..write('appId: $appId, ') + ..write('type: $type, ') + ..write('content: $content, ') + ..write('createdAt: $createdAt, ') + ..write('status: $status, ') + ..write('mediaStatus: $mediaStatus, ') + ..write('mediaWaveform: $mediaWaveform, ') + ..write('mediaName: $mediaName, ') + ..write('mediaMimeType: $mediaMimeType, ') + ..write('mediaSize: $mediaSize, ') + ..write('mediaWidth: $mediaWidth, ') + ..write('mediaHeight: $mediaHeight, ') + ..write('thumbImage: $thumbImage, ') + ..write('thumbUrl: $thumbUrl, ') + ..write('mediaUrl: $mediaUrl, ') + ..write('mediaDuration: $mediaDuration, ') + ..write('stickerId: $stickerId, ') + ..write('assetUrl: $assetUrl, ') + ..write('assetWidth: $assetWidth, ') + ..write('assetHeight: $assetHeight, ') + ..write('assetName: $assetName, ') + ..write('assetType: $assetType, ') + ..write('sharedUserId: $sharedUserId, ') + ..write('sharedUserFullName: $sharedUserFullName, ') + ..write('sharedUserIdentityNumber: $sharedUserIdentityNumber, ') + ..write('sharedUserAvatarUrl: $sharedUserAvatarUrl, ') + ..write('sharedUserIsVerified: $sharedUserIsVerified, ') + ..write('sharedUserAppId: $sharedUserAppId') + ..write(')')) + .toString(); + } +} + +typedef BaseQuoteMessageItem$where = Expression Function( + Messages message, + Users sender, + Stickers sticker, + Users shareUser, + MessageMentions messageMention); +typedef BaseQuoteMessageItem$order = OrderBy Function( + Messages message, + Users sender, + Stickers sticker, + Users shareUser, + MessageMentions messageMention); +typedef BaseQuoteMessageItem$limit = Limit Function( + Messages message, + Users sender, + Stickers sticker, + Users shareUser, + MessageMentions messageMention); + +class SendingMessage { + final String messageId; + final String conversationId; + final String userId; + final String category; + final String? content; + final String? mediaUrl; + final String? mediaMimeType; + final int? mediaSize; + final String? mediaDuration; + final int? mediaWidth; + final int? mediaHeight; + final String? mediaHash; + final String? thumbImage; + final String? mediaKey; + final String? mediaDigest; + final MediaStatus? mediaStatus; + final MessageStatus status; + final DateTime createdAt; + final String? action; + final String? participantId; + final String? snapshotId; + final String? hyperlink; + final String? name; + final String? albumId; + final String? stickerId; + final String? sharedUserId; + final String? mediaWaveform; + final String? quoteMessageId; + final String? quoteContent; + final int? resendStatus; + final String? resendUserId; + final String? resendSessionId; + SendingMessage({ + required this.messageId, + required this.conversationId, + required this.userId, + required this.category, + this.content, + this.mediaUrl, + this.mediaMimeType, + this.mediaSize, + this.mediaDuration, + this.mediaWidth, + this.mediaHeight, + this.mediaHash, + this.thumbImage, + this.mediaKey, + this.mediaDigest, + this.mediaStatus, + required this.status, + required this.createdAt, + this.action, + this.participantId, + this.snapshotId, + this.hyperlink, + this.name, + this.albumId, + this.stickerId, + this.sharedUserId, + this.mediaWaveform, + this.quoteMessageId, + this.quoteContent, + this.resendStatus, + this.resendUserId, + this.resendSessionId, + }); + @override + int get hashCode => Object.hashAll([ + messageId, + conversationId, + userId, + category, + content, + mediaUrl, + mediaMimeType, + mediaSize, + mediaDuration, + mediaWidth, + mediaHeight, + mediaHash, + thumbImage, + mediaKey, + mediaDigest, + mediaStatus, + status, + createdAt, + action, + participantId, + snapshotId, + hyperlink, + name, + albumId, + stickerId, + sharedUserId, + mediaWaveform, + quoteMessageId, + quoteContent, + resendStatus, + resendUserId, + resendSessionId + ]); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is SendingMessage && + other.messageId == this.messageId && + other.conversationId == this.conversationId && + other.userId == this.userId && + other.category == this.category && + other.content == this.content && + other.mediaUrl == this.mediaUrl && + other.mediaMimeType == this.mediaMimeType && + other.mediaSize == this.mediaSize && + other.mediaDuration == this.mediaDuration && + other.mediaWidth == this.mediaWidth && + other.mediaHeight == this.mediaHeight && + other.mediaHash == this.mediaHash && + other.thumbImage == this.thumbImage && + other.mediaKey == this.mediaKey && + other.mediaDigest == this.mediaDigest && + other.mediaStatus == this.mediaStatus && + other.status == this.status && + other.createdAt == this.createdAt && + other.action == this.action && + other.participantId == this.participantId && + other.snapshotId == this.snapshotId && + other.hyperlink == this.hyperlink && + other.name == this.name && + other.albumId == this.albumId && + other.stickerId == this.stickerId && + other.sharedUserId == this.sharedUserId && + other.mediaWaveform == this.mediaWaveform && + other.quoteMessageId == this.quoteMessageId && + other.quoteContent == this.quoteContent && + other.resendStatus == this.resendStatus && + other.resendUserId == this.resendUserId && + other.resendSessionId == this.resendSessionId); + @override + String toString() { + return (StringBuffer('SendingMessage(') + ..write('messageId: $messageId, ') + ..write('conversationId: $conversationId, ') + ..write('userId: $userId, ') + ..write('category: $category, ') + ..write('content: $content, ') + ..write('mediaUrl: $mediaUrl, ') + ..write('mediaMimeType: $mediaMimeType, ') + ..write('mediaSize: $mediaSize, ') + ..write('mediaDuration: $mediaDuration, ') + ..write('mediaWidth: $mediaWidth, ') + ..write('mediaHeight: $mediaHeight, ') + ..write('mediaHash: $mediaHash, ') + ..write('thumbImage: $thumbImage, ') + ..write('mediaKey: $mediaKey, ') + ..write('mediaDigest: $mediaDigest, ') + ..write('mediaStatus: $mediaStatus, ') + ..write('status: $status, ') + ..write('createdAt: $createdAt, ') + ..write('action: $action, ') + ..write('participantId: $participantId, ') + ..write('snapshotId: $snapshotId, ') + ..write('hyperlink: $hyperlink, ') + ..write('name: $name, ') + ..write('albumId: $albumId, ') + ..write('stickerId: $stickerId, ') + ..write('sharedUserId: $sharedUserId, ') + ..write('mediaWaveform: $mediaWaveform, ') + ..write('quoteMessageId: $quoteMessageId, ') + ..write('quoteContent: $quoteContent, ') + ..write('resendStatus: $resendStatus, ') + ..write('resendUserId: $resendUserId, ') + ..write('resendSessionId: $resendSessionId') + ..write(')')) + .toString(); + } +} + +class NotificationMessage { + final String messageId; + final String conversationId; + final String senderId; + final String? senderFullName; + final String type; + final String? content; + final String? quoteContent; + final MessageStatus status; + final String? groupName; + final DateTime? muteUntil; + final DateTime? ownerMuteUntil; + final String? ownerUserId; + final String? ownerFullName; + final DateTime createdAt; + final ConversationCategory? category; + final String? actionName; + final UserRelationship? relationship; + final String? participantFullName; + final String? participantUserId; + NotificationMessage({ + required this.messageId, + required this.conversationId, + required this.senderId, + this.senderFullName, + required this.type, + this.content, + this.quoteContent, + required this.status, + this.groupName, + this.muteUntil, + this.ownerMuteUntil, + this.ownerUserId, + this.ownerFullName, + required this.createdAt, + this.category, + this.actionName, + this.relationship, + this.participantFullName, + this.participantUserId, + }); + @override + int get hashCode => Object.hash( + messageId, + conversationId, + senderId, + senderFullName, + type, + content, + quoteContent, + status, + groupName, + muteUntil, + ownerMuteUntil, + ownerUserId, + ownerFullName, + createdAt, + category, + actionName, + relationship, + participantFullName, + participantUserId); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is NotificationMessage && + other.messageId == this.messageId && + other.conversationId == this.conversationId && + other.senderId == this.senderId && + other.senderFullName == this.senderFullName && + other.type == this.type && + other.content == this.content && + other.quoteContent == this.quoteContent && + other.status == this.status && + other.groupName == this.groupName && + other.muteUntil == this.muteUntil && + other.ownerMuteUntil == this.ownerMuteUntil && + other.ownerUserId == this.ownerUserId && + other.ownerFullName == this.ownerFullName && + other.createdAt == this.createdAt && + other.category == this.category && + other.actionName == this.actionName && + other.relationship == this.relationship && + other.participantFullName == this.participantFullName && + other.participantUserId == this.participantUserId); + @override + String toString() { + return (StringBuffer('NotificationMessage(') + ..write('messageId: $messageId, ') + ..write('conversationId: $conversationId, ') + ..write('senderId: $senderId, ') + ..write('senderFullName: $senderFullName, ') + ..write('type: $type, ') + ..write('content: $content, ') + ..write('quoteContent: $quoteContent, ') + ..write('status: $status, ') + ..write('groupName: $groupName, ') + ..write('muteUntil: $muteUntil, ') + ..write('ownerMuteUntil: $ownerMuteUntil, ') + ..write('ownerUserId: $ownerUserId, ') + ..write('ownerFullName: $ownerFullName, ') + ..write('createdAt: $createdAt, ') + ..write('category: $category, ') + ..write('actionName: $actionName, ') + ..write('relationship: $relationship, ') + ..write('participantFullName: $participantFullName, ') + ..write('participantUserId: $participantUserId') + ..write(')')) + .toString(); + } +} + +class SearchMessageDetailItem { + final String messageId; + final String senderId; + final String? senderAvatarUrl; + final String? senderFullName; + final MessageStatus status; + final String type; + final String? content; + final DateTime createdAt; + final String? mediaName; + final String? appId; + final bool? verified; + final String? ownerId; + final String? groupIconUrl; + final ConversationCategory? category; + final String? groupName; + final String conversationId; + final String? ownerFullName; + final String? ownerAvatarUrl; + SearchMessageDetailItem({ + required this.messageId, + required this.senderId, + this.senderAvatarUrl, + this.senderFullName, + required this.status, + required this.type, + this.content, + required this.createdAt, + this.mediaName, + this.appId, + this.verified, + this.ownerId, + this.groupIconUrl, + this.category, + this.groupName, + required this.conversationId, + this.ownerFullName, + this.ownerAvatarUrl, + }); + @override + int get hashCode => Object.hash( + messageId, + senderId, + senderAvatarUrl, + senderFullName, + status, + type, + content, + createdAt, + mediaName, + appId, + verified, + ownerId, + groupIconUrl, + category, + groupName, + conversationId, + ownerFullName, + ownerAvatarUrl); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is SearchMessageDetailItem && + other.messageId == this.messageId && + other.senderId == this.senderId && + other.senderAvatarUrl == this.senderAvatarUrl && + other.senderFullName == this.senderFullName && + other.status == this.status && + other.type == this.type && + other.content == this.content && + other.createdAt == this.createdAt && + other.mediaName == this.mediaName && + other.appId == this.appId && + other.verified == this.verified && + other.ownerId == this.ownerId && + other.groupIconUrl == this.groupIconUrl && + other.category == this.category && + other.groupName == this.groupName && + other.conversationId == this.conversationId && + other.ownerFullName == this.ownerFullName && + other.ownerAvatarUrl == this.ownerAvatarUrl); + @override + String toString() { + return (StringBuffer('SearchMessageDetailItem(') + ..write('messageId: $messageId, ') + ..write('senderId: $senderId, ') + ..write('senderAvatarUrl: $senderAvatarUrl, ') + ..write('senderFullName: $senderFullName, ') + ..write('status: $status, ') + ..write('type: $type, ') + ..write('content: $content, ') + ..write('createdAt: $createdAt, ') + ..write('mediaName: $mediaName, ') + ..write('appId: $appId, ') + ..write('verified: $verified, ') + ..write('ownerId: $ownerId, ') + ..write('groupIconUrl: $groupIconUrl, ') + ..write('category: $category, ') + ..write('groupName: $groupName, ') + ..write('conversationId: $conversationId, ') + ..write('ownerFullName: $ownerFullName, ') + ..write('ownerAvatarUrl: $ownerAvatarUrl') + ..write(')')) + .toString(); + } +} + +class MiniMessageItem { + final String conversationId; + final String messageId; + MiniMessageItem({ + required this.conversationId, + required this.messageId, + }); + @override + int get hashCode => Object.hash(conversationId, messageId); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is MiniMessageItem && + other.conversationId == this.conversationId && + other.messageId == this.messageId); + @override + String toString() { + return (StringBuffer('MiniMessageItem(') + ..write('conversationId: $conversationId, ') + ..write('messageId: $messageId') + ..write(')')) + .toString(); + } +} + +typedef SearchMessage$where = Expression Function( + Messages m, Conversations c, Users u, Users owner); +typedef SearchMessage$limit = Limit Function( + Messages m, Conversations c, Users u, Users owner); + +class QuoteMinimal { + final int rowid; + final String conversationId; + final String? quoteMessageId; + QuoteMinimal({ + required this.rowid, + required this.conversationId, + this.quoteMessageId, + }); + @override + int get hashCode => Object.hash(rowid, conversationId, quoteMessageId); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is QuoteMinimal && + other.rowid == this.rowid && + other.conversationId == this.conversationId && + other.quoteMessageId == this.quoteMessageId); + @override + String toString() { + return (StringBuffer('QuoteMinimal(') + ..write('rowid: $rowid, ') + ..write('conversationId: $conversationId, ') + ..write('quoteMessageId: $quoteMessageId') + ..write(')')) + .toString(); + } +} diff --git a/lib/db/dao/message_mention_dao.dart b/lib/db/dao/message_mention_dao.dart index a5b713c5c0..60e25158a9 100644 --- a/lib/db/dao/message_mention_dao.dart +++ b/lib/db/dao/message_mention_dao.dart @@ -5,6 +5,7 @@ import '../../utils/reg_exp_utils.dart'; import '../database_event_bus.dart'; import '../extension/db.dart'; import '../mixin_database.dart'; +import 'message_dao.dart'; part 'message_mention_dao.g.dart'; diff --git a/lib/db/dao/participant_dao.dart b/lib/db/dao/participant_dao.dart index 9ae8c2a323..4ba3c3a57e 100644 --- a/lib/db/dao/participant_dao.dart +++ b/lib/db/dao/participant_dao.dart @@ -25,7 +25,7 @@ class MiniParticipantItem with EquatableMixin { ]; } -@DriftAccessor() +@DriftAccessor(include: {'../moor/dao/participant.drift'}) class ParticipantDao extends DatabaseAccessor with _$ParticipantDaoMixin { ParticipantDao(super.db); @@ -62,17 +62,8 @@ class ParticipantDao extends DatabaseAccessor return query.get(); } - Selectable groupParticipantsByConversationId( - String conversationId) => - db.groupParticipantsByConversationId(conversationId); - - Future findJoinedConversationId(String userId) async => db - .customSelect( - 'SELECT p.conversation_id FROM participants p, conversations c WHERE p.user_id = ? AND p.conversation_id = c.conversation_id AND c.status = 2 LIMIT 1', - variables: [Variable.withString(userId)], - ) - .map((row) => row.read('conversation_id')) - .getSingleOrNull(); + Future findJoinedConversationId(String userId) async => + _joinedConversationId(userId).getSingleOrNull(); Future insertAll(List add) => batch((batch) { batch.insertAllOnConflictUpdate(db.participants, add); @@ -88,22 +79,15 @@ class ParticipantDao extends DatabaseAccessor }); } - Selectable participantsAvatar(String conversationId) => - db.participantsAvatar(conversationId); - Future updateParticipantRole( String conversationId, String participantId, ParticipantRole? role) => - db - .customUpdate( - 'UPDATE participants SET role = ? where conversation_id = ? AND user_id = ?', - variables: [ - Variable(const ParticipantRoleJsonConverter().toJson(role)), - Variable.withString(conversationId), - Variable.withString(participantId) - ], - updates: {db.participants}, - updateKind: UpdateKind.update, - ) + (update(db.participants) + ..where((tbl) => + tbl.conversationId.equals(conversationId) & + tbl.userId.equals(participantId))) + .write(ParticipantsCompanion( + role: Value(role), + )) .then((value) { DataBaseEventBus.instance.updateParticipant([ MiniParticipantItem( @@ -148,13 +132,6 @@ class ParticipantDao extends DatabaseAccessor return value; }); - Selectable userIdByIdentityNumber( - String conversationId, String identityNumber) => - db.userIdByIdentityNumber(conversationId, identityNumber); - - Selectable conversationParticipantsCount(String conversationId) => - db.conversationParticipantsCount(conversationId); - Selectable participantById( String conversationId, String userId) => (db.select(db.participants) diff --git a/lib/db/dao/participant_dao.g.dart b/lib/db/dao/participant_dao.g.dart index 5e374ebf15..df4b24a1b8 100644 --- a/lib/db/dao/participant_dao.g.dart +++ b/lib/db/dao/participant_dao.g.dart @@ -3,4 +3,230 @@ part of 'participant_dao.dart'; // ignore_for_file: type=lint -mixin _$ParticipantDaoMixin on DatabaseAccessor {} +mixin _$ParticipantDaoMixin on DatabaseAccessor { + Conversations get conversations => attachedDatabase.conversations; + Participants get participants => attachedDatabase.participants; + Users get users => attachedDatabase.users; + Addresses get addresses => attachedDatabase.addresses; + Apps get apps => attachedDatabase.apps; + Assets get assets => attachedDatabase.assets; + CircleConversations get circleConversations => + attachedDatabase.circleConversations; + Circles get circles => attachedDatabase.circles; + FloodMessages get floodMessages => attachedDatabase.floodMessages; + Hyperlinks get hyperlinks => attachedDatabase.hyperlinks; + Jobs get jobs => attachedDatabase.jobs; + MessageMentions get messageMentions => attachedDatabase.messageMentions; + Messages get messages => attachedDatabase.messages; + MessagesHistory get messagesHistory => attachedDatabase.messagesHistory; + Offsets get offsets => attachedDatabase.offsets; + ParticipantSession get participantSession => + attachedDatabase.participantSession; + ResendSessionMessages get resendSessionMessages => + attachedDatabase.resendSessionMessages; + SentSessionSenderKeys get sentSessionSenderKeys => + attachedDatabase.sentSessionSenderKeys; + Snapshots get snapshots => attachedDatabase.snapshots; + StickerAlbums get stickerAlbums => attachedDatabase.stickerAlbums; + StickerRelationships get stickerRelationships => + attachedDatabase.stickerRelationships; + Stickers get stickers => attachedDatabase.stickers; + TranscriptMessages get transcriptMessages => + attachedDatabase.transcriptMessages; + PinMessages get pinMessages => attachedDatabase.pinMessages; + Fiats get fiats => attachedDatabase.fiats; + FavoriteApps get favoriteApps => attachedDatabase.favoriteApps; + ExpiredMessages get expiredMessages => attachedDatabase.expiredMessages; + Chains get chains => attachedDatabase.chains; + Properties get properties => attachedDatabase.properties; + Selectable participantsAvatar(String conversationId) { + return customSelect( + 'SELECT user.* FROM participants AS participant INNER JOIN users AS user ON participant.user_id = user.user_id WHERE participant.conversation_id = ?1 ORDER BY participant.created_at ASC LIMIT 4', + variables: [ + Variable(conversationId) + ], + readsFrom: { + participants, + users, + }).asyncMap(users.mapFromRow); + } + + Selectable groupParticipantsByConversationId( + String conversationId) { + return customSelect( + 'SELECT p.conversation_id AS conversationId, p.role AS role, p.created_at AS createdAt, u.user_id AS userId, u.identity_number AS identityNumber, u.relationship AS relationship, u.biography AS biography, u.full_name AS fullName, u.avatar_url AS avatarUrl, u.phone AS phone, u.is_verified AS isVerified, u.created_at AS userCreatedAt, u.mute_until AS muteUntil, u.has_pin AS hasPin, u.app_id AS appId, u.is_scam AS isScam FROM participants AS p,users AS u WHERE p.conversation_id = ?1 AND p.user_id = u.user_id ORDER BY p.created_at DESC', + variables: [ + Variable(conversationId) + ], + readsFrom: { + participants, + users, + }).map((QueryRow row) { + return ParticipantUser( + conversationId: row.read('conversationId'), + role: Participants.$converterrole + .fromSql(row.readNullable('role')), + createdAt: Participants.$convertercreatedAt + .fromSql(row.read('createdAt')), + userId: row.read('userId'), + identityNumber: row.read('identityNumber'), + relationship: Users.$converterrelationship + .fromSql(row.readNullable('relationship')), + biography: row.readNullable('biography'), + fullName: row.readNullable('fullName'), + avatarUrl: row.readNullable('avatarUrl'), + phone: row.readNullable('phone'), + isVerified: row.readNullable('isVerified'), + userCreatedAt: NullAwareTypeConverter.wrapFromSql( + Users.$convertercreatedAt, row.readNullable('userCreatedAt')), + muteUntil: NullAwareTypeConverter.wrapFromSql( + Users.$convertermuteUntil, row.readNullable('muteUntil')), + hasPin: row.readNullable('hasPin'), + appId: row.readNullable('appId'), + isScam: row.readNullable('isScam'), + ); + }); + } + + Selectable userIdByIdentityNumber( + String conversationId, String identityNumber) { + return customSelect( + 'SELECT u.user_id FROM users AS u INNER JOIN participants AS p ON p.user_id = u.user_id WHERE p.conversation_id = ?1 AND u.identity_number = ?2', + variables: [ + Variable(conversationId), + Variable(identityNumber) + ], + readsFrom: { + users, + participants, + }).map((QueryRow row) => row.read('user_id')); + } + + Selectable countParticipants() { + return customSelect('SELECT COUNT(1) AS _c0 FROM participants', + variables: [], + readsFrom: { + participants, + }).map((QueryRow row) => row.read('_c0')); + } + + Selectable conversationParticipantsCount(String conversationId) { + return customSelect( + 'SELECT COUNT(1) AS _c0 FROM participants WHERE conversation_id = ?1', + variables: [ + Variable(conversationId) + ], + readsFrom: { + participants, + }).map((QueryRow row) => row.read('_c0')); + } + + Selectable _joinedConversationId(String userId) { + return customSelect( + 'SELECT p.conversation_id FROM participants AS p,conversations AS c WHERE p.user_id = ?1 AND p.conversation_id = c.conversation_id AND c.status = 2 LIMIT 1', + variables: [ + Variable(userId) + ], + readsFrom: { + participants, + conversations, + }).map((QueryRow row) => row.read('conversation_id')); + } +} + +class ParticipantUser { + final String conversationId; + final ParticipantRole? role; + final DateTime createdAt; + final String userId; + final String identityNumber; + final UserRelationship? relationship; + final String? biography; + final String? fullName; + final String? avatarUrl; + final String? phone; + final bool? isVerified; + final DateTime? userCreatedAt; + final DateTime? muteUntil; + final int? hasPin; + final String? appId; + final int? isScam; + ParticipantUser({ + required this.conversationId, + this.role, + required this.createdAt, + required this.userId, + required this.identityNumber, + this.relationship, + this.biography, + this.fullName, + this.avatarUrl, + this.phone, + this.isVerified, + this.userCreatedAt, + this.muteUntil, + this.hasPin, + this.appId, + this.isScam, + }); + @override + int get hashCode => Object.hash( + conversationId, + role, + createdAt, + userId, + identityNumber, + relationship, + biography, + fullName, + avatarUrl, + phone, + isVerified, + userCreatedAt, + muteUntil, + hasPin, + appId, + isScam); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is ParticipantUser && + other.conversationId == this.conversationId && + other.role == this.role && + other.createdAt == this.createdAt && + other.userId == this.userId && + other.identityNumber == this.identityNumber && + other.relationship == this.relationship && + other.biography == this.biography && + other.fullName == this.fullName && + other.avatarUrl == this.avatarUrl && + other.phone == this.phone && + other.isVerified == this.isVerified && + other.userCreatedAt == this.userCreatedAt && + other.muteUntil == this.muteUntil && + other.hasPin == this.hasPin && + other.appId == this.appId && + other.isScam == this.isScam); + @override + String toString() { + return (StringBuffer('ParticipantUser(') + ..write('conversationId: $conversationId, ') + ..write('role: $role, ') + ..write('createdAt: $createdAt, ') + ..write('userId: $userId, ') + ..write('identityNumber: $identityNumber, ') + ..write('relationship: $relationship, ') + ..write('biography: $biography, ') + ..write('fullName: $fullName, ') + ..write('avatarUrl: $avatarUrl, ') + ..write('phone: $phone, ') + ..write('isVerified: $isVerified, ') + ..write('userCreatedAt: $userCreatedAt, ') + ..write('muteUntil: $muteUntil, ') + ..write('hasPin: $hasPin, ') + ..write('appId: $appId, ') + ..write('isScam: $isScam') + ..write(')')) + .toString(); + } +} diff --git a/lib/db/dao/participant_session_dao.dart b/lib/db/dao/participant_session_dao.dart index 27fbacb9c5..fe9c6634b7 100644 --- a/lib/db/dao/participant_session_dao.dart +++ b/lib/db/dao/participant_session_dao.dart @@ -4,7 +4,7 @@ import '../mixin_database.dart'; part 'participant_session_dao.g.dart'; -@DriftAccessor() +@DriftAccessor(include: {'../moor/dao/participant_session.drift'}) class ParticipantSessionDao extends DatabaseAccessor with _$ParticipantSessionDaoMixin { ParticipantSessionDao(super.db); @@ -13,18 +13,6 @@ class ParticipantSessionDao extends DatabaseAccessor into(db.participantSession) .insert(participantSession, mode: InsertMode.insertOrReplace); - Future getParticipantSessionKeyWithoutSelf( - String conversationId, String userId) => - db - .participantSessionKeyWithoutSelf(conversationId, userId) - .getSingleOrNull(); - - Future getOtherParticipantSessionKey( - String conversationId, String userId, String sessionId) => - db - .otherParticipantSessionKey(conversationId, userId, sessionId) - .getSingleOrNull(); - Future deleteByStatus(String conversationId) async { await (delete(db.participantSession) ..where((tbl) => @@ -75,16 +63,6 @@ class ParticipantSessionDao extends DatabaseAccessor await insertAll(list); }); - Future> getNotSendSessionParticipants( - String conversationId, String sessionId) async => - db.notSendSessionParticipants(conversationId, sessionId).get(); - - Future getParticipantSessionKeyBySessionId( - String conversationId, String sessionId) async => - db - .participantSessionKeyBySessionId(conversationId, sessionId) - .getSingleOrNull(); - Future updateList(List list) async { for (final p in list) { await update(db.participantSession).replace(p); diff --git a/lib/db/dao/participant_session_dao.g.dart b/lib/db/dao/participant_session_dao.g.dart index 5c02517ecd..acf1b918ad 100644 --- a/lib/db/dao/participant_session_dao.g.dart +++ b/lib/db/dao/participant_session_dao.g.dart @@ -3,4 +3,127 @@ part of 'participant_session_dao.dart'; // ignore_for_file: type=lint -mixin _$ParticipantSessionDaoMixin on DatabaseAccessor {} +mixin _$ParticipantSessionDaoMixin on DatabaseAccessor { + ParticipantSession get participantSession => + attachedDatabase.participantSession; + Users get users => attachedDatabase.users; + Addresses get addresses => attachedDatabase.addresses; + Apps get apps => attachedDatabase.apps; + Assets get assets => attachedDatabase.assets; + CircleConversations get circleConversations => + attachedDatabase.circleConversations; + Circles get circles => attachedDatabase.circles; + Conversations get conversations => attachedDatabase.conversations; + FloodMessages get floodMessages => attachedDatabase.floodMessages; + Hyperlinks get hyperlinks => attachedDatabase.hyperlinks; + Jobs get jobs => attachedDatabase.jobs; + MessageMentions get messageMentions => attachedDatabase.messageMentions; + Messages get messages => attachedDatabase.messages; + MessagesHistory get messagesHistory => attachedDatabase.messagesHistory; + Offsets get offsets => attachedDatabase.offsets; + Participants get participants => attachedDatabase.participants; + ResendSessionMessages get resendSessionMessages => + attachedDatabase.resendSessionMessages; + SentSessionSenderKeys get sentSessionSenderKeys => + attachedDatabase.sentSessionSenderKeys; + Snapshots get snapshots => attachedDatabase.snapshots; + StickerAlbums get stickerAlbums => attachedDatabase.stickerAlbums; + StickerRelationships get stickerRelationships => + attachedDatabase.stickerRelationships; + Stickers get stickers => attachedDatabase.stickers; + TranscriptMessages get transcriptMessages => + attachedDatabase.transcriptMessages; + PinMessages get pinMessages => attachedDatabase.pinMessages; + Fiats get fiats => attachedDatabase.fiats; + FavoriteApps get favoriteApps => attachedDatabase.favoriteApps; + ExpiredMessages get expiredMessages => attachedDatabase.expiredMessages; + Chains get chains => attachedDatabase.chains; + Properties get properties => attachedDatabase.properties; + Selectable participantSessionKeyWithoutSelf( + String conversationId, String userId) { + return customSelect( + 'SELECT conversation_id, user_id, session_id, public_key FROM participant_session WHERE conversation_id = ?1 AND user_id != ?2 LIMIT 1', + variables: [ + Variable(conversationId), + Variable(userId) + ], + readsFrom: { + participantSession, + }).map((QueryRow row) { + return ParticipantSessionKey( + conversationId: row.read('conversation_id'), + userId: row.read('user_id'), + sessionId: row.read('session_id'), + publicKey: row.readNullable('public_key'), + ); + }); + } + + Selectable otherParticipantSessionKey( + String conversationId, String userId, String sessionId) { + return customSelect( + 'SELECT conversation_id, user_id, session_id, public_key FROM participant_session WHERE conversation_id = ?1 AND user_id == ?2 AND session_id != ?3 ORDER BY created_at DESC LIMIT 1', + variables: [ + Variable(conversationId), + Variable(userId), + Variable(sessionId) + ], + readsFrom: { + participantSession, + }).map((QueryRow row) { + return ParticipantSessionKey( + conversationId: row.read('conversation_id'), + userId: row.read('user_id'), + sessionId: row.read('session_id'), + publicKey: row.readNullable('public_key'), + ); + }); + } + + Selectable notSendSessionParticipants( + String conversationId, String sessionId) { + return customSelect( + 'SELECT p.* FROM participant_session AS p LEFT JOIN users AS u ON p.user_id = u.user_id WHERE p.conversation_id = ?1 AND p.session_id != ?2 AND u.app_id IS NULL AND p.sent_to_server IS NULL', + variables: [ + Variable(conversationId), + Variable(sessionId) + ], + readsFrom: { + participantSession, + users, + }).asyncMap(participantSession.mapFromRow); + } +} + +class ParticipantSessionKey { + final String conversationId; + final String userId; + final String sessionId; + final String? publicKey; + ParticipantSessionKey({ + required this.conversationId, + required this.userId, + required this.sessionId, + this.publicKey, + }); + @override + int get hashCode => Object.hash(conversationId, userId, sessionId, publicKey); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is ParticipantSessionKey && + other.conversationId == this.conversationId && + other.userId == this.userId && + other.sessionId == this.sessionId && + other.publicKey == this.publicKey); + @override + String toString() { + return (StringBuffer('ParticipantSessionKey(') + ..write('conversationId: $conversationId, ') + ..write('userId: $userId, ') + ..write('sessionId: $sessionId, ') + ..write('publicKey: $publicKey') + ..write(')')) + .toString(); + } +} diff --git a/lib/db/dao/pin_message_dao.dart b/lib/db/dao/pin_message_dao.dart index 9c63d5adfb..b8a07efe61 100644 --- a/lib/db/dao/pin_message_dao.dart +++ b/lib/db/dao/pin_message_dao.dart @@ -4,10 +4,11 @@ import '../database_event_bus.dart'; import '../extension/db.dart'; import '../mixin_database.dart'; import '../util/util.dart'; +import 'message_dao.dart'; part 'pin_message_dao.g.dart'; -@DriftAccessor() +@DriftAccessor(include: {'../moor/dao/pin_message.drift'}) class PinMessageDao extends DatabaseAccessor with _$PinMessageDaoMixin { PinMessageDao(super.attachedDatabase); @@ -68,11 +69,6 @@ class PinMessageDao extends DatabaseAccessor ); } - Selectable pinMessageIds(String conversationId) => - db.pinMessageIds(conversationId); - - late final pinMessageItem = db.pinMessageItem; - Selectable messageItems(String conversationId) => db.basePinMessageItems( conversationId, diff --git a/lib/db/dao/pin_message_dao.g.dart b/lib/db/dao/pin_message_dao.g.dart index 2e54fa3780..d762c7da7b 100644 --- a/lib/db/dao/pin_message_dao.g.dart +++ b/lib/db/dao/pin_message_dao.g.dart @@ -3,4 +3,104 @@ part of 'pin_message_dao.dart'; // ignore_for_file: type=lint -mixin _$PinMessageDaoMixin on DatabaseAccessor {} +mixin _$PinMessageDaoMixin on DatabaseAccessor { + Conversations get conversations => attachedDatabase.conversations; + Messages get messages => attachedDatabase.messages; + PinMessages get pinMessages => attachedDatabase.pinMessages; + Users get users => attachedDatabase.users; + Addresses get addresses => attachedDatabase.addresses; + Apps get apps => attachedDatabase.apps; + Assets get assets => attachedDatabase.assets; + CircleConversations get circleConversations => + attachedDatabase.circleConversations; + Circles get circles => attachedDatabase.circles; + FloodMessages get floodMessages => attachedDatabase.floodMessages; + Hyperlinks get hyperlinks => attachedDatabase.hyperlinks; + Jobs get jobs => attachedDatabase.jobs; + MessageMentions get messageMentions => attachedDatabase.messageMentions; + MessagesHistory get messagesHistory => attachedDatabase.messagesHistory; + Offsets get offsets => attachedDatabase.offsets; + ParticipantSession get participantSession => + attachedDatabase.participantSession; + Participants get participants => attachedDatabase.participants; + ResendSessionMessages get resendSessionMessages => + attachedDatabase.resendSessionMessages; + SentSessionSenderKeys get sentSessionSenderKeys => + attachedDatabase.sentSessionSenderKeys; + Snapshots get snapshots => attachedDatabase.snapshots; + StickerAlbums get stickerAlbums => attachedDatabase.stickerAlbums; + StickerRelationships get stickerRelationships => + attachedDatabase.stickerRelationships; + Stickers get stickers => attachedDatabase.stickers; + TranscriptMessages get transcriptMessages => + attachedDatabase.transcriptMessages; + Fiats get fiats => attachedDatabase.fiats; + FavoriteApps get favoriteApps => attachedDatabase.favoriteApps; + ExpiredMessages get expiredMessages => attachedDatabase.expiredMessages; + Chains get chains => attachedDatabase.chains; + Properties get properties => attachedDatabase.properties; + Selectable pinMessageItem( + String messageId, String conversationId) { + return customSelect( + 'SELECT message.content AS content, sender.full_name AS userFullName FROM messages AS message INNER JOIN pin_messages AS pinMessage ON ?1 = pinMessage.message_id INNER JOIN users AS sender ON message.user_id = sender.user_id WHERE message.conversation_id = ?2 AND message.category = \'MESSAGE_PIN\' AND message.quote_message_id = ?1 ORDER BY message.created_at DESC LIMIT 1', + variables: [ + Variable(messageId), + Variable(conversationId) + ], + readsFrom: { + messages, + users, + pinMessages, + }).map((QueryRow row) { + return PinMessageItemResult( + content: row.readNullable('content'), + userFullName: row.readNullable('userFullName'), + ); + }); + } + + Selectable pinMessageIds(String conversationId) { + return customSelect( + 'SELECT pinMessage.message_id FROM pin_messages AS pinMessage INNER JOIN messages AS message ON message.message_id = pinMessage.message_id WHERE pinMessage.conversation_id = ?1 ORDER BY message.created_at DESC', + variables: [ + Variable(conversationId) + ], + readsFrom: { + pinMessages, + messages, + }).map((QueryRow row) => row.read('message_id')); + } + + Selectable countPinMessages() { + return customSelect('SELECT COUNT(1) AS _c0 FROM pin_messages', + variables: [], + readsFrom: { + pinMessages, + }).map((QueryRow row) => row.read('_c0')); + } +} + +class PinMessageItemResult { + final String? content; + final String? userFullName; + PinMessageItemResult({ + this.content, + this.userFullName, + }); + @override + int get hashCode => Object.hash(content, userFullName); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is PinMessageItemResult && + other.content == this.content && + other.userFullName == this.userFullName); + @override + String toString() { + return (StringBuffer('PinMessageItemResult(') + ..write('content: $content, ') + ..write('userFullName: $userFullName') + ..write(')')) + .toString(); + } +} diff --git a/lib/db/dao/sticker_album_dao.dart b/lib/db/dao/sticker_album_dao.dart index 2b00b27a3f..e0a3af9f5e 100644 --- a/lib/db/dao/sticker_album_dao.dart +++ b/lib/db/dao/sticker_album_dao.dart @@ -23,7 +23,7 @@ extension StickerAlbumsCompanionExtension on sdk.StickerAlbum { ); } -@DriftAccessor() +@DriftAccessor(include: {'../moor/dao/sticker_album.drift'}) class StickerAlbumDao extends DatabaseAccessor with _$StickerAlbumDaoMixin { StickerAlbumDao(super.db); diff --git a/lib/db/dao/sticker_album_dao.g.dart b/lib/db/dao/sticker_album_dao.g.dart index 89794f9278..99313a6f61 100644 --- a/lib/db/dao/sticker_album_dao.g.dart +++ b/lib/db/dao/sticker_album_dao.g.dart @@ -3,4 +3,40 @@ part of 'sticker_album_dao.dart'; // ignore_for_file: type=lint -mixin _$StickerAlbumDaoMixin on DatabaseAccessor {} +mixin _$StickerAlbumDaoMixin on DatabaseAccessor { + Addresses get addresses => attachedDatabase.addresses; + Apps get apps => attachedDatabase.apps; + Assets get assets => attachedDatabase.assets; + CircleConversations get circleConversations => + attachedDatabase.circleConversations; + Circles get circles => attachedDatabase.circles; + Conversations get conversations => attachedDatabase.conversations; + FloodMessages get floodMessages => attachedDatabase.floodMessages; + Hyperlinks get hyperlinks => attachedDatabase.hyperlinks; + Jobs get jobs => attachedDatabase.jobs; + MessageMentions get messageMentions => attachedDatabase.messageMentions; + Messages get messages => attachedDatabase.messages; + MessagesHistory get messagesHistory => attachedDatabase.messagesHistory; + Offsets get offsets => attachedDatabase.offsets; + ParticipantSession get participantSession => + attachedDatabase.participantSession; + Participants get participants => attachedDatabase.participants; + ResendSessionMessages get resendSessionMessages => + attachedDatabase.resendSessionMessages; + SentSessionSenderKeys get sentSessionSenderKeys => + attachedDatabase.sentSessionSenderKeys; + Snapshots get snapshots => attachedDatabase.snapshots; + StickerAlbums get stickerAlbums => attachedDatabase.stickerAlbums; + StickerRelationships get stickerRelationships => + attachedDatabase.stickerRelationships; + Stickers get stickers => attachedDatabase.stickers; + Users get users => attachedDatabase.users; + TranscriptMessages get transcriptMessages => + attachedDatabase.transcriptMessages; + PinMessages get pinMessages => attachedDatabase.pinMessages; + Fiats get fiats => attachedDatabase.fiats; + FavoriteApps get favoriteApps => attachedDatabase.favoriteApps; + ExpiredMessages get expiredMessages => attachedDatabase.expiredMessages; + Chains get chains => attachedDatabase.chains; + Properties get properties => attachedDatabase.properties; +} diff --git a/lib/db/dao/sticker_dao.dart b/lib/db/dao/sticker_dao.dart index ad5c26801f..c64ad6e66f 100644 --- a/lib/db/dao/sticker_dao.dart +++ b/lib/db/dao/sticker_dao.dart @@ -20,7 +20,7 @@ extension StickerConverter on sdk.Sticker { ); } -@DriftAccessor() +@DriftAccessor(include: {'../moor/dao/sticker.drift'}) class StickerDao extends DatabaseAccessor with _$StickerDaoMixin { StickerDao(super.db); @@ -58,8 +58,6 @@ class StickerDao extends DatabaseAccessor return value; }); - Selectable recentUsedStickers() => db.recentUsedStickers(); - SimpleSelectStatement sticker(String stickerId) => (select(db.stickers) ..where((tbl) => tbl.stickerId.equals(stickerId)) @@ -71,9 +69,9 @@ class StickerDao extends DatabaseAccessor (t) => OrderingTerm(expression: t.createdAt, mode: OrderingMode.desc) ]); - Selectable personalStickers() => db.stickersByCategory('PERSONAL'); + Selectable personalStickers() => _stickersByCategory('PERSONAL'); - Selectable systemStickers() => db.stickersByCategory('SYSTEM'); + Selectable systemStickers() => _stickersByCategory('SYSTEM'); Future updateUsedAt( String? albumId, String stickerId, DateTime dateTime) => diff --git a/lib/db/dao/sticker_dao.g.dart b/lib/db/dao/sticker_dao.g.dart index f7904f364d..feee99885d 100644 --- a/lib/db/dao/sticker_dao.g.dart +++ b/lib/db/dao/sticker_dao.g.dart @@ -3,4 +3,69 @@ part of 'sticker_dao.dart'; // ignore_for_file: type=lint -mixin _$StickerDaoMixin on DatabaseAccessor {} +mixin _$StickerDaoMixin on DatabaseAccessor { + Stickers get stickers => attachedDatabase.stickers; + StickerAlbums get stickerAlbums => attachedDatabase.stickerAlbums; + StickerRelationships get stickerRelationships => + attachedDatabase.stickerRelationships; + Addresses get addresses => attachedDatabase.addresses; + Apps get apps => attachedDatabase.apps; + Assets get assets => attachedDatabase.assets; + CircleConversations get circleConversations => + attachedDatabase.circleConversations; + Circles get circles => attachedDatabase.circles; + Conversations get conversations => attachedDatabase.conversations; + FloodMessages get floodMessages => attachedDatabase.floodMessages; + Hyperlinks get hyperlinks => attachedDatabase.hyperlinks; + Jobs get jobs => attachedDatabase.jobs; + MessageMentions get messageMentions => attachedDatabase.messageMentions; + Messages get messages => attachedDatabase.messages; + MessagesHistory get messagesHistory => attachedDatabase.messagesHistory; + Offsets get offsets => attachedDatabase.offsets; + ParticipantSession get participantSession => + attachedDatabase.participantSession; + Participants get participants => attachedDatabase.participants; + ResendSessionMessages get resendSessionMessages => + attachedDatabase.resendSessionMessages; + SentSessionSenderKeys get sentSessionSenderKeys => + attachedDatabase.sentSessionSenderKeys; + Snapshots get snapshots => attachedDatabase.snapshots; + Users get users => attachedDatabase.users; + TranscriptMessages get transcriptMessages => + attachedDatabase.transcriptMessages; + PinMessages get pinMessages => attachedDatabase.pinMessages; + Fiats get fiats => attachedDatabase.fiats; + FavoriteApps get favoriteApps => attachedDatabase.favoriteApps; + ExpiredMessages get expiredMessages => attachedDatabase.expiredMessages; + Chains get chains => attachedDatabase.chains; + Properties get properties => attachedDatabase.properties; + Selectable recentUsedStickers() { + return customSelect( + 'SELECT * FROM stickers WHERE last_use_at > 0 ORDER BY last_use_at DESC LIMIT 20', + variables: [], + readsFrom: { + stickers, + }).asyncMap(stickers.mapFromRow); + } + + Selectable _stickersByCategory(String category) { + return customSelect( + 'SELECT s.* FROM sticker_albums AS sa INNER JOIN sticker_relationships AS sr ON sr.album_id = sa.album_id INNER JOIN stickers AS s ON sr.sticker_id = s.sticker_id WHERE sa.category = ?1 ORDER BY s.created_at DESC', + variables: [ + Variable(category) + ], + readsFrom: { + stickerAlbums, + stickerRelationships, + stickers, + }).asyncMap(stickers.mapFromRow); + } + + Selectable countStickers() { + return customSelect('SELECT COUNT(1) AS _c0 FROM stickers', + variables: [], + readsFrom: { + stickers, + }).map((QueryRow row) => row.read('_c0')); + } +} diff --git a/lib/db/dao/sticker_relationship_dao.dart b/lib/db/dao/sticker_relationship_dao.dart index faab53e1f8..33913e3d9f 100644 --- a/lib/db/dao/sticker_relationship_dao.dart +++ b/lib/db/dao/sticker_relationship_dao.dart @@ -6,7 +6,7 @@ import '../mixin_database.dart'; part 'sticker_relationship_dao.g.dart'; -@DriftAccessor() +@DriftAccessor(include: {'../moor/dao/sticker_relationship.drift'}) class StickerRelationshipDao extends DatabaseAccessor with _$StickerRelationshipDaoMixin { StickerRelationshipDao(super.db); @@ -44,10 +44,4 @@ class StickerRelationshipDao extends DatabaseAccessor albumId: stickerRelationship.albumId))); return value; }); - - Selectable stickerSystemAlbumId(String stickerId) => - db.stickerSystemAlbumId(stickerId); - - Selectable stickerSystemAlbum(String stickerId) => - db.stickerSystemAlbum(stickerId); } diff --git a/lib/db/dao/sticker_relationship_dao.g.dart b/lib/db/dao/sticker_relationship_dao.g.dart index 84b41da787..50079ef815 100644 --- a/lib/db/dao/sticker_relationship_dao.g.dart +++ b/lib/db/dao/sticker_relationship_dao.g.dart @@ -3,4 +3,63 @@ part of 'sticker_relationship_dao.dart'; // ignore_for_file: type=lint -mixin _$StickerRelationshipDaoMixin on DatabaseAccessor {} +mixin _$StickerRelationshipDaoMixin on DatabaseAccessor { + StickerRelationships get stickerRelationships => + attachedDatabase.stickerRelationships; + StickerAlbums get stickerAlbums => attachedDatabase.stickerAlbums; + Addresses get addresses => attachedDatabase.addresses; + Apps get apps => attachedDatabase.apps; + Assets get assets => attachedDatabase.assets; + CircleConversations get circleConversations => + attachedDatabase.circleConversations; + Circles get circles => attachedDatabase.circles; + Conversations get conversations => attachedDatabase.conversations; + FloodMessages get floodMessages => attachedDatabase.floodMessages; + Hyperlinks get hyperlinks => attachedDatabase.hyperlinks; + Jobs get jobs => attachedDatabase.jobs; + MessageMentions get messageMentions => attachedDatabase.messageMentions; + Messages get messages => attachedDatabase.messages; + MessagesHistory get messagesHistory => attachedDatabase.messagesHistory; + Offsets get offsets => attachedDatabase.offsets; + ParticipantSession get participantSession => + attachedDatabase.participantSession; + Participants get participants => attachedDatabase.participants; + ResendSessionMessages get resendSessionMessages => + attachedDatabase.resendSessionMessages; + SentSessionSenderKeys get sentSessionSenderKeys => + attachedDatabase.sentSessionSenderKeys; + Snapshots get snapshots => attachedDatabase.snapshots; + Stickers get stickers => attachedDatabase.stickers; + Users get users => attachedDatabase.users; + TranscriptMessages get transcriptMessages => + attachedDatabase.transcriptMessages; + PinMessages get pinMessages => attachedDatabase.pinMessages; + Fiats get fiats => attachedDatabase.fiats; + FavoriteApps get favoriteApps => attachedDatabase.favoriteApps; + ExpiredMessages get expiredMessages => attachedDatabase.expiredMessages; + Chains get chains => attachedDatabase.chains; + Properties get properties => attachedDatabase.properties; + Selectable stickerSystemAlbumId(String stickerId) { + return customSelect( + 'SELECT sa.album_id FROM sticker_relationships AS sr INNER JOIN sticker_albums AS sa ON sr.album_id = sa.album_id WHERE sr.sticker_id = ?1 AND sa.category = \'SYSTEM\' LIMIT 1', + variables: [ + Variable(stickerId) + ], + readsFrom: { + stickerAlbums, + stickerRelationships, + }).map((QueryRow row) => row.read('album_id')); + } + + Selectable stickerSystemAlbum(String stickerId) { + return customSelect( + 'SELECT sa.* FROM sticker_relationships AS sr INNER JOIN sticker_albums AS sa ON sr.album_id = sa.album_id WHERE sr.sticker_id = ?1 AND sa.category = \'SYSTEM\' LIMIT 1', + variables: [ + Variable(stickerId) + ], + readsFrom: { + stickerRelationships, + stickerAlbums, + }).asyncMap(stickerAlbums.mapFromRow); + } +} diff --git a/lib/db/dao/user_dao.dart b/lib/db/dao/user_dao.dart index d364e62c30..670a1bd7b7 100644 --- a/lib/db/dao/user_dao.dart +++ b/lib/db/dao/user_dao.dart @@ -29,7 +29,7 @@ extension UserExtension on sdk.User { ); } -@DriftAccessor() +@DriftAccessor(include: {'../moor/dao/user.drift'}) class UserDao extends DatabaseAccessor with _$UserDaoMixin { UserDao(super.db); @@ -89,7 +89,7 @@ class UserDao extends DatabaseAccessor with _$UserDaoMixin { required String conversationId, required String keyword, }) => - db.fuzzySearchBotGroupUser( + _fuzzySearchBotGroupUser( conversationId, DateTime.now().subtract(const Duration(days: 7)), currentUserId, @@ -97,21 +97,6 @@ class UserDao extends DatabaseAccessor with _$UserDaoMixin { keyword, ); - Selectable fuzzySearchGroupUser({ - required String currentUserId, - required String conversationId, - required String keyword, - }) => - db.fuzzySearchGroupUser( - currentUserId, - conversationId, - keyword, - keyword, - ); - - Selectable groupParticipants({required String conversationId}) => - db.groupParticipants(conversationId); - Selectable friends() => (select(db.users) ..where((tbl) => tbl.relationship.equalsValue(sdk.UserRelationship.friend)) ..orderBy([ @@ -119,11 +104,6 @@ class UserDao extends DatabaseAccessor with _$UserDaoMixin { (tbl) => OrderingTerm.asc(tbl.userId), ])); - Selectable notInFriends(List filterIds) => - db.notInFriends(filterIds); - - Selectable usersByIn(List userIds) => db.usersByIn(userIds); - Selectable fuzzySearchUser({ required String id, required String username, @@ -133,14 +113,14 @@ class UserDao extends DatabaseAccessor with _$UserDaoMixin { }) { if (category?.type == SlideCategoryType.circle) { final circleId = category!.id; - return db.fuzzySearchUserInCircle((_, conversation, __) { + return _fuzzySearchUserInCircle((_, conversation, __) { if (!isIncludeConversation) { return conversation.status.isNull(); } return const Constant(true); }, id, username, identityNumber, circleId); } - return db.fuzzySearchUser( + return _fuzzySearchUser( (_, conversation) { if (!isIncludeConversation) { return conversation.status.isNull(); @@ -175,9 +155,6 @@ class UserDao extends DatabaseAccessor with _$UserDaoMixin { }); } - Selectable biography(String userId) => - db.biographyByIdentityNumber(userId); - Future updateMuteUntil(String userId, String muteUntil) async { await (update(db.users)..where((tbl) => tbl.userId.equals(userId))) .write(UsersCompanion(muteUntil: Value(DateTime.tryParse(muteUntil)))); @@ -192,9 +169,6 @@ class UserDao extends DatabaseAccessor with _$UserDaoMixin { .map((row) => row.userId) .get(); - Selectable userByIdentityNumbers(List list) => - db.userByIdentityNumbers(list); - Future hasUser(String userIdOrIdentityNumber) => db.hasData( db.users, [], diff --git a/lib/db/dao/user_dao.g.dart b/lib/db/dao/user_dao.g.dart index f5cf859ba7..989f5f5223 100644 --- a/lib/db/dao/user_dao.g.dart +++ b/lib/db/dao/user_dao.g.dart @@ -3,4 +3,262 @@ part of 'user_dao.dart'; // ignore_for_file: type=lint -mixin _$UserDaoMixin on DatabaseAccessor {} +mixin _$UserDaoMixin on DatabaseAccessor { + Users get users => attachedDatabase.users; + Conversations get conversations => attachedDatabase.conversations; + Messages get messages => attachedDatabase.messages; + Participants get participants => attachedDatabase.participants; + CircleConversations get circleConversations => + attachedDatabase.circleConversations; + Addresses get addresses => attachedDatabase.addresses; + Apps get apps => attachedDatabase.apps; + Assets get assets => attachedDatabase.assets; + Circles get circles => attachedDatabase.circles; + FloodMessages get floodMessages => attachedDatabase.floodMessages; + Hyperlinks get hyperlinks => attachedDatabase.hyperlinks; + Jobs get jobs => attachedDatabase.jobs; + MessageMentions get messageMentions => attachedDatabase.messageMentions; + MessagesHistory get messagesHistory => attachedDatabase.messagesHistory; + Offsets get offsets => attachedDatabase.offsets; + ParticipantSession get participantSession => + attachedDatabase.participantSession; + ResendSessionMessages get resendSessionMessages => + attachedDatabase.resendSessionMessages; + SentSessionSenderKeys get sentSessionSenderKeys => + attachedDatabase.sentSessionSenderKeys; + Snapshots get snapshots => attachedDatabase.snapshots; + StickerAlbums get stickerAlbums => attachedDatabase.stickerAlbums; + StickerRelationships get stickerRelationships => + attachedDatabase.stickerRelationships; + Stickers get stickers => attachedDatabase.stickers; + TranscriptMessages get transcriptMessages => + attachedDatabase.transcriptMessages; + PinMessages get pinMessages => attachedDatabase.pinMessages; + Fiats get fiats => attachedDatabase.fiats; + FavoriteApps get favoriteApps => attachedDatabase.favoriteApps; + ExpiredMessages get expiredMessages => attachedDatabase.expiredMessages; + Chains get chains => attachedDatabase.chains; + Properties get properties => attachedDatabase.properties; + Selectable _fuzzySearchBotGroupUser(String conversationId, + DateTime createdAt, String id, String username, String identityNumber) { + return customSelect( + 'SELECT u.* FROM users AS u WHERE(u.user_id IN (SELECT m.user_id FROM messages AS m WHERE conversation_id = ?1 AND m.created_at > ?2) OR u.user_id IN (SELECT f.user_id FROM users AS f WHERE relationship = \'FRIEND\'))AND u.user_id != ?3 AND u.identity_number != 0 AND(u.full_name LIKE \'%\' || ?4 || \'%\' ESCAPE \'\\\' OR u.identity_number LIKE \'%\' || ?5 || \'%\' ESCAPE \'\\\')ORDER BY CASE u.relationship WHEN \'FRIEND\' THEN 1 ELSE 2 END, u.relationship OR u.full_name = ?4 COLLATE NOCASE OR u.identity_number = ?5 COLLATE NOCASE DESC', + variables: [ + Variable(conversationId), + Variable(Messages.$convertercreatedAt.toSql(createdAt)), + Variable(id), + Variable(username), + Variable(identityNumber) + ], + readsFrom: { + users, + messages, + }).asyncMap(users.mapFromRow); + } + + Selectable fuzzySearchGroupUser( + String currentUserId, String conversationId, String keyword) { + return customSelect( + 'SELECT u.* FROM participants AS p,users AS u WHERE u.user_id != ?1 AND p.conversation_id = ?2 AND p.user_id = u.user_id AND(u.full_name LIKE \'%\' || ?3 || \'%\' ESCAPE \'\\\' OR u.identity_number LIKE \'%\' || ?3 || \'%\' ESCAPE \'\\\')ORDER BY u.full_name = ?3 COLLATE NOCASE OR u.identity_number = ?3 COLLATE NOCASE DESC', + variables: [ + Variable(currentUserId), + Variable(conversationId), + Variable(keyword) + ], + readsFrom: { + participants, + users, + }).asyncMap(users.mapFromRow); + } + + Selectable groupParticipants(String conversationId) { + return customSelect( + 'SELECT u.* FROM participants AS p,users AS u WHERE p.conversation_id = ?1 AND p.user_id = u.user_id', + variables: [ + Variable(conversationId) + ], + readsFrom: { + participants, + users, + }).asyncMap(users.mapFromRow); + } + + Selectable notInFriends(List filterIds) { + var $arrayStartIndex = 1; + final expandedfilterIds = $expandVar($arrayStartIndex, filterIds.length); + $arrayStartIndex += filterIds.length; + return customSelect( + 'SELECT * FROM users WHERE relationship = \'FRIEND\' AND user_id NOT IN ($expandedfilterIds) ORDER BY full_name, user_id ASC', + variables: [ + for (var $ in filterIds) Variable($) + ], + readsFrom: { + users, + }).asyncMap(users.mapFromRow); + } + + Selectable usersByIn(List userIds) { + var $arrayStartIndex = 1; + final expandeduserIds = $expandVar($arrayStartIndex, userIds.length); + $arrayStartIndex += userIds.length; + return customSelect( + 'SELECT * FROM users WHERE user_id IN ($expandeduserIds)', + variables: [ + for (var $ in userIds) Variable($) + ], + readsFrom: { + users, + }).asyncMap(users.mapFromRow); + } + + Selectable userIdsByIn(List userIds) { + var $arrayStartIndex = 1; + final expandeduserIds = $expandVar($arrayStartIndex, userIds.length); + $arrayStartIndex += userIds.length; + return customSelect( + 'SELECT user_id FROM users WHERE user_id IN ($expandeduserIds)', + variables: [ + for (var $ in userIds) Variable($) + ], + readsFrom: { + users, + }).map((QueryRow row) => row.read('user_id')); + } + + Selectable _fuzzySearchUser( + FuzzySearchUser$firstFilter firstFilter, + String id, + String username, + String identityNumber, + FuzzySearchUser$lastFilter lastFilter) { + var $arrayStartIndex = 4; + final generatedfirstFilter = $write( + firstFilter(this.users, this.conversations), + hasMultipleTables: true, + startIndex: $arrayStartIndex); + $arrayStartIndex += generatedfirstFilter.amountOfVariables; + final generatedlastFilter = $write( + lastFilter(this.users, this.conversations), + hasMultipleTables: true, + startIndex: $arrayStartIndex); + $arrayStartIndex += generatedlastFilter.amountOfVariables; + return customSelect( + 'SELECT users.* FROM users LEFT JOIN conversations ON conversations.owner_id = user_id WHERE ${generatedfirstFilter.sql} AND user_id != ?1 AND relationship = \'FRIEND\' AND(full_name LIKE \'%\' || ?2 || \'%\' ESCAPE \'\\\' OR identity_number LIKE \' %\' || ?3 || \' %\' ESCAPE \'\\\')AND ${generatedlastFilter.sql} GROUP BY user_id ORDER BY full_name = ?2 COLLATE nocase OR identity_number = ?3 COLLATE nocase DESC', + variables: [ + Variable(id), + Variable(username), + Variable(identityNumber), + ...generatedfirstFilter.introducedVariables, + ...generatedlastFilter.introducedVariables + ], + readsFrom: { + users, + conversations, + ...generatedfirstFilter.watchedTables, + ...generatedlastFilter.watchedTables, + }).asyncMap(users.mapFromRow); + } + + Selectable _fuzzySearchUserInCircle( + FuzzySearchUserInCircle$filter filter, + String id, + String username, + String identityNumber, + String? circleId) { + var $arrayStartIndex = 5; + final generatedfilter = $write( + filter(this.users, this.conversations, + alias(this.circleConversations, 'circleConversation')), + hasMultipleTables: true, + startIndex: $arrayStartIndex); + $arrayStartIndex += generatedfilter.amountOfVariables; + return customSelect( + 'SELECT users.* FROM users LEFT JOIN conversations ON conversations.owner_id = users.user_id LEFT JOIN circle_conversations AS circleConversation ON circleConversation.user_id = users.user_id WHERE ${generatedfilter.sql} AND users.user_id != ?1 AND relationship = \'FRIEND\' AND(full_name LIKE \'%\' || ?2 || \'%\' ESCAPE \'\\\' OR identity_number LIKE \' %\' || ?3 || \' %\' ESCAPE \'\\\')AND circleConversation.circle_id = ?4 GROUP BY users.user_id ORDER BY full_name = ?2 COLLATE nocase OR identity_number = ?3 COLLATE nocase DESC', + variables: [ + Variable(id), + Variable(username), + Variable(identityNumber), + Variable(circleId), + ...generatedfilter.introducedVariables + ], + readsFrom: { + users, + conversations, + circleConversations, + ...generatedfilter.watchedTables, + }).asyncMap(users.mapFromRow); + } + + Selectable biographyByIdentityNumber(String userId) { + return customSelect('SELECT biography FROM users WHERE user_id = ?1', + variables: [ + Variable(userId) + ], + readsFrom: { + users, + }).map((QueryRow row) => row.readNullable('biography')); + } + + Selectable userByIdentityNumbers(List numbers) { + var $arrayStartIndex = 1; + final expandednumbers = $expandVar($arrayStartIndex, numbers.length); + $arrayStartIndex += numbers.length; + return customSelect( + 'SELECT user_id, identity_number, full_name FROM users WHERE identity_number IN ($expandednumbers)', + variables: [ + for (var $ in numbers) Variable($) + ], + readsFrom: { + users, + }).map((QueryRow row) { + return MentionUser( + userId: row.read('user_id'), + identityNumber: row.read('identity_number'), + fullName: row.readNullable('full_name'), + ); + }); + } + + Selectable countUsers() { + return customSelect('SELECT COUNT(*) AS _c0 FROM users', + variables: [], + readsFrom: { + users, + }).map((QueryRow row) => row.read('_c0')); + } +} +typedef FuzzySearchUser$firstFilter = Expression Function( + Users users, Conversations conversations); +typedef FuzzySearchUser$lastFilter = Expression Function( + Users users, Conversations conversations); +typedef FuzzySearchUserInCircle$filter = Expression Function(Users users, + Conversations conversations, CircleConversations circleConversation); + +class MentionUser { + final String userId; + final String identityNumber; + final String? fullName; + MentionUser({ + required this.userId, + required this.identityNumber, + this.fullName, + }); + @override + int get hashCode => Object.hash(userId, identityNumber, fullName); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is MentionUser && + other.userId == this.userId && + other.identityNumber == this.identityNumber && + other.fullName == this.fullName); + @override + String toString() { + return (StringBuffer('MentionUser(') + ..write('userId: $userId, ') + ..write('identityNumber: $identityNumber, ') + ..write('fullName: $fullName') + ..write(')')) + .toString(); + } +} diff --git a/lib/db/database.dart b/lib/db/database.dart index a6cb1de0c3..342efcdd0c 100644 --- a/lib/db/database.dart +++ b/lib/db/database.dart @@ -34,92 +34,67 @@ import 'mixin_database.dart'; class Database { Database(this.mixinDatabase, this.ftsDatabase) { - appDao = AppDao(mixinDatabase); - assetDao = AssetDao(mixinDatabase); - chainDao = ChainDao(mixinDatabase); - conversationDao = ConversationDao(mixinDatabase); - circleDao = CircleDao(mixinDatabase); - circleConversationDao = CircleConversationDao(mixinDatabase); - floodMessageDao = FloodMessageDao(mixinDatabase); - messageDao = MessageDao(mixinDatabase); - messagesHistoryDao = MessageHistoryDao(mixinDatabase); - messageMentionDao = MessageMentionDao(mixinDatabase); - jobDao = JobDao(mixinDatabase); - offsetDao = OffsetDao(mixinDatabase); - participantDao = ParticipantDao(mixinDatabase); - resendSessionMessageDao = ResendSessionMessageDao(mixinDatabase); - snapshotDao = SnapshotDao(mixinDatabase); - stickerDao = StickerDao(mixinDatabase); - stickerAlbumDao = StickerAlbumDao(mixinDatabase); - stickerRelationshipDao = StickerRelationshipDao(mixinDatabase); - participantSessionDao = ParticipantSessionDao(mixinDatabase); - userDao = UserDao(mixinDatabase); - transcriptMessageDao = TranscriptMessageDao(mixinDatabase); - pinMessageDao = PinMessageDao(mixinDatabase); - fiatDao = FiatDao(mixinDatabase); - favoriteAppDao = FavoriteAppDao(mixinDatabase); - expiredMessageDao = ExpiredMessageDao(mixinDatabase); settingProperties = SettingPropertyStorage(mixinDatabase.propertyDao); } - // static MixinDatabase _database; - // static Future init() async { - // _database = await getMixinDatabaseConnection('3910'); - // } - final MixinDatabase mixinDatabase; final FtsDatabase ftsDatabase; - late final AppDao appDao; + AppDao get appDao => mixinDatabase.appDao; - late final AssetDao assetDao; + AssetDao get assetDao => mixinDatabase.assetDao; - late final ChainDao chainDao; + ChainDao get chainDao => mixinDatabase.chainDao; - late final MessageDao messageDao; + MessageDao get messageDao => mixinDatabase.messageDao; - late final MessageHistoryDao messagesHistoryDao; + MessageHistoryDao get messageHistoryDao => mixinDatabase.messageHistoryDao; - late final MessageMentionDao messageMentionDao; + MessageMentionDao get messageMentionDao => mixinDatabase.messageMentionDao; - late final ConversationDao conversationDao; + ConversationDao get conversationDao => mixinDatabase.conversationDao; - late final CircleDao circleDao; + CircleDao get circleDao => mixinDatabase.circleDao; - late final CircleConversationDao circleConversationDao; + CircleConversationDao get circleConversationDao => + mixinDatabase.circleConversationDao; - late final FloodMessageDao floodMessageDao; + FloodMessageDao get floodMessageDao => mixinDatabase.floodMessageDao; - late final JobDao jobDao; + JobDao get jobDao => mixinDatabase.jobDao; - late final OffsetDao offsetDao; + OffsetDao get offsetDao => mixinDatabase.offsetDao; - late final ParticipantDao participantDao; + ParticipantDao get participantDao => mixinDatabase.participantDao; - late final ParticipantSessionDao participantSessionDao; + ParticipantSessionDao get participantSessionDao => + mixinDatabase.participantSessionDao; - late final ResendSessionMessageDao resendSessionMessageDao; + ResendSessionMessageDao get resendSessionMessageDao => + mixinDatabase.resendSessionMessageDao; - late final SnapshotDao snapshotDao; + SnapshotDao get snapshotDao => mixinDatabase.snapshotDao; - late final StickerDao stickerDao; + StickerDao get stickerDao => mixinDatabase.stickerDao; - late final StickerAlbumDao stickerAlbumDao; + StickerAlbumDao get stickerAlbumDao => mixinDatabase.stickerAlbumDao; - late final StickerRelationshipDao stickerRelationshipDao; + StickerRelationshipDao get stickerRelationshipDao => + mixinDatabase.stickerRelationshipDao; - late final UserDao userDao; + UserDao get userDao => mixinDatabase.userDao; - late final TranscriptMessageDao transcriptMessageDao; + TranscriptMessageDao get transcriptMessageDao => + mixinDatabase.transcriptMessageDao; - late final PinMessageDao pinMessageDao; + PinMessageDao get pinMessageDao => mixinDatabase.pinMessageDao; - late final FiatDao fiatDao; + FiatDao get fiatDao => mixinDatabase.fiatDao; - late final FavoriteAppDao favoriteAppDao; + FavoriteAppDao get favoriteAppDao => mixinDatabase.favoriteAppDao; - late final ExpiredMessageDao expiredMessageDao; + ExpiredMessageDao get expiredMessageDao => mixinDatabase.expiredMessageDao; late final SettingPropertyStorage settingProperties; @@ -150,7 +125,7 @@ class Database { anchorMessageId: anchorMessageId, ); final messages = - await mixinDatabase.getSearchMessageByIds(messageIds).get(); + await mixinDatabase.messageDao.searchMessageByIds(messageIds).get(); final result = []; @@ -184,6 +159,7 @@ class Database { } else { conversations = await conversationDao .conversationItemsByCategory(category.type, 1000, 0) + .get() .then((value) => value.map((e) => e.conversationId).toList()); } return conversations; diff --git a/lib/db/database_event_bus.dart b/lib/db/database_event_bus.dart index 00ea48a744..524b7aca94 100644 --- a/lib/db/database_event_bus.dart +++ b/lib/db/database_event_bus.dart @@ -6,9 +6,9 @@ import 'package:rxdart/rxdart.dart'; import '../utils/event_bus.dart'; import '../utils/logger.dart'; import 'dao/job_dao.dart'; +import 'dao/message_dao.dart'; import 'dao/participant_dao.dart'; import 'event.dart'; -import 'mixin_database.dart'; enum _DatabaseEvent { notification, diff --git a/lib/db/extension/conversation.dart b/lib/db/extension/conversation.dart index e1257de9d1..0a14b74114 100644 --- a/lib/db/extension/conversation.dart +++ b/lib/db/extension/conversation.dart @@ -1,6 +1,6 @@ import 'package:mixin_bot_sdk_dart/mixin_bot_sdk_dart.dart'; -import '../mixin_database.dart'; +import '../dao/conversation_dao.dart'; extension SearchConversationItemExtension on SearchConversationItem { bool get isGroupConversation => category == ConversationCategory.group; diff --git a/lib/db/extension/message.dart b/lib/db/extension/message.dart index 54a9e73667..aaee61a897 100644 --- a/lib/db/extension/message.dart +++ b/lib/db/extension/message.dart @@ -10,6 +10,7 @@ import '../../widgets/message/send_message_dialog/attachment_extra.dart'; import '../converter/media_status_type_converter.dart'; import '../converter/message_status_type_converter.dart'; import '../converter/millis_date_converter.dart'; +import '../dao/message_dao.dart'; import '../mixin_database.dart'; import 'message_category.dart'; diff --git a/lib/db/mixin_database.dart b/lib/db/mixin_database.dart index ef9d39ed0f..f1fc535765 100644 --- a/lib/db/mixin_database.dart +++ b/lib/db/mixin_database.dart @@ -41,6 +41,7 @@ import 'dao/snapshot_dao.dart'; import 'dao/sticker_album_dao.dart'; import 'dao/sticker_dao.dart'; import 'dao/sticker_relationship_dao.dart'; +import 'dao/transcript_message_dao.dart'; import 'dao/user_dao.dart'; import 'database_event_bus.dart'; import 'extension/job.dart'; @@ -52,17 +53,7 @@ part 'mixin_database.g.dart'; @DriftDatabase( include: { 'moor/mixin.drift', - 'moor/dao/conversation.drift', - 'moor/dao/message.drift', - 'moor/dao/participant.drift', - 'moor/dao/sticker.drift', - 'moor/dao/sticker_album.drift', - 'moor/dao/user.drift', - 'moor/dao/circle.drift', - 'moor/dao/flood.drift', - 'moor/dao/pin_message.drift', - 'moor/dao/sticker_relationship.drift', - 'moor/dao/favorite_app.drift', + 'moor/dao/common.drift', }, daos: [ AddressDao, @@ -93,8 +84,8 @@ part 'mixin_database.g.dart'; ExpiredMessageDao, ChainDao, PropertyDao, + TranscriptMessageDao, ], - queries: {}, ) class MixinDatabase extends _$MixinDatabase { MixinDatabase(super.e); diff --git a/lib/db/mixin_database.g.dart b/lib/db/mixin_database.g.dart index f34c611efd..6d5a2e26a0 100644 --- a/lib/db/mixin_database.g.dart +++ b/lib/db/mixin_database.g.dart @@ -3,23 +3,68 @@ part of 'mixin_database.dart'; // ignore_for_file: type=lint -class FavoriteApps extends Table with TableInfo { +class Conversations extends Table with TableInfo { @override final GeneratedDatabase attachedDatabase; final String? _alias; - FavoriteApps(this.attachedDatabase, [this._alias]); - static const VerificationMeta _appIdMeta = const VerificationMeta('appId'); - late final GeneratedColumn appId = GeneratedColumn( - 'app_id', aliasedName, false, + Conversations(this.attachedDatabase, [this._alias]); + static const VerificationMeta _conversationIdMeta = + const VerificationMeta('conversationId'); + late final GeneratedColumn conversationId = GeneratedColumn( + 'conversation_id', aliasedName, false, type: DriftSqlType.string, requiredDuringInsert: true, $customConstraints: 'NOT NULL'); - static const VerificationMeta _userIdMeta = const VerificationMeta('userId'); - late final GeneratedColumn userId = GeneratedColumn( - 'user_id', aliasedName, false, + static const VerificationMeta _ownerIdMeta = + const VerificationMeta('ownerId'); + late final GeneratedColumn ownerId = GeneratedColumn( + 'owner_id', aliasedName, true, type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL'); + requiredDuringInsert: false, + $customConstraints: ''); + static const VerificationMeta _categoryMeta = + const VerificationMeta('category'); + late final GeneratedColumnWithTypeConverter + category = GeneratedColumn('category', aliasedName, true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '') + .withConverter( + Conversations.$convertercategory); + static const VerificationMeta _nameMeta = const VerificationMeta('name'); + late final GeneratedColumn name = GeneratedColumn( + 'name', aliasedName, true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: ''); + static const VerificationMeta _iconUrlMeta = + const VerificationMeta('iconUrl'); + late final GeneratedColumn iconUrl = GeneratedColumn( + 'icon_url', aliasedName, true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: ''); + static const VerificationMeta _announcementMeta = + const VerificationMeta('announcement'); + late final GeneratedColumn announcement = GeneratedColumn( + 'announcement', aliasedName, true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: ''); + static const VerificationMeta _codeUrlMeta = + const VerificationMeta('codeUrl'); + late final GeneratedColumn codeUrl = GeneratedColumn( + 'code_url', aliasedName, true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: ''); + static const VerificationMeta _payTypeMeta = + const VerificationMeta('payType'); + late final GeneratedColumn payType = GeneratedColumn( + 'pay_type', aliasedName, true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: ''); static const VerificationMeta _createdAtMeta = const VerificationMeta('createdAt'); late final GeneratedColumnWithTypeConverter createdAt = @@ -27,177 +72,725 @@ class FavoriteApps extends Table with TableInfo { type: DriftSqlType.int, requiredDuringInsert: true, $customConstraints: 'NOT NULL') - .withConverter(FavoriteApps.$convertercreatedAt); + .withConverter(Conversations.$convertercreatedAt); + static const VerificationMeta _pinTimeMeta = + const VerificationMeta('pinTime'); + late final GeneratedColumnWithTypeConverter pinTime = + GeneratedColumn('pin_time', aliasedName, true, + type: DriftSqlType.int, + requiredDuringInsert: false, + $customConstraints: '') + .withConverter(Conversations.$converterpinTimen); + static const VerificationMeta _lastMessageIdMeta = + const VerificationMeta('lastMessageId'); + late final GeneratedColumn lastMessageId = GeneratedColumn( + 'last_message_id', aliasedName, true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: ''); + static const VerificationMeta _lastMessageCreatedAtMeta = + const VerificationMeta('lastMessageCreatedAt'); + late final GeneratedColumnWithTypeConverter + lastMessageCreatedAt = GeneratedColumn( + 'last_message_created_at', aliasedName, true, + type: DriftSqlType.int, + requiredDuringInsert: false, + $customConstraints: '') + .withConverter( + Conversations.$converterlastMessageCreatedAtn); + static const VerificationMeta _lastReadMessageIdMeta = + const VerificationMeta('lastReadMessageId'); + late final GeneratedColumn lastReadMessageId = + GeneratedColumn('last_read_message_id', aliasedName, true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: ''); + static const VerificationMeta _unseenMessageCountMeta = + const VerificationMeta('unseenMessageCount'); + late final GeneratedColumn unseenMessageCount = GeneratedColumn( + 'unseen_message_count', aliasedName, true, + type: DriftSqlType.int, + requiredDuringInsert: false, + $customConstraints: ''); + static const VerificationMeta _statusMeta = const VerificationMeta('status'); + late final GeneratedColumnWithTypeConverter status = + GeneratedColumn('status', aliasedName, false, + type: DriftSqlType.int, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL') + .withConverter(Conversations.$converterstatus); + static const VerificationMeta _draftMeta = const VerificationMeta('draft'); + late final GeneratedColumn draft = GeneratedColumn( + 'draft', aliasedName, true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: ''); + static const VerificationMeta _muteUntilMeta = + const VerificationMeta('muteUntil'); + late final GeneratedColumnWithTypeConverter muteUntil = + GeneratedColumn('mute_until', aliasedName, true, + type: DriftSqlType.int, + requiredDuringInsert: false, + $customConstraints: '') + .withConverter(Conversations.$convertermuteUntiln); + static const VerificationMeta _expireInMeta = + const VerificationMeta('expireIn'); + late final GeneratedColumn expireIn = GeneratedColumn( + 'expire_in', aliasedName, true, + type: DriftSqlType.int, + requiredDuringInsert: false, + $customConstraints: ''); @override - List get $columns => [appId, userId, createdAt]; + List get $columns => [ + conversationId, + ownerId, + category, + name, + iconUrl, + announcement, + codeUrl, + payType, + createdAt, + pinTime, + lastMessageId, + lastMessageCreatedAt, + lastReadMessageId, + unseenMessageCount, + status, + draft, + muteUntil, + expireIn + ]; @override - String get aliasedName => _alias ?? 'favorite_apps'; + String get aliasedName => _alias ?? 'conversations'; @override - String get actualTableName => 'favorite_apps'; + String get actualTableName => 'conversations'; @override - VerificationContext validateIntegrity(Insertable instance, + VerificationContext validateIntegrity(Insertable instance, {bool isInserting = false}) { final context = VerificationContext(); final data = instance.toColumns(true); - if (data.containsKey('app_id')) { + if (data.containsKey('conversation_id')) { context.handle( - _appIdMeta, appId.isAcceptableOrUnknown(data['app_id']!, _appIdMeta)); + _conversationIdMeta, + conversationId.isAcceptableOrUnknown( + data['conversation_id']!, _conversationIdMeta)); } else if (isInserting) { - context.missing(_appIdMeta); + context.missing(_conversationIdMeta); } - if (data.containsKey('user_id')) { - context.handle(_userIdMeta, - userId.isAcceptableOrUnknown(data['user_id']!, _userIdMeta)); - } else if (isInserting) { - context.missing(_userIdMeta); + if (data.containsKey('owner_id')) { + context.handle(_ownerIdMeta, + ownerId.isAcceptableOrUnknown(data['owner_id']!, _ownerIdMeta)); + } + context.handle(_categoryMeta, const VerificationResult.success()); + if (data.containsKey('name')) { + context.handle( + _nameMeta, name.isAcceptableOrUnknown(data['name']!, _nameMeta)); + } + if (data.containsKey('icon_url')) { + context.handle(_iconUrlMeta, + iconUrl.isAcceptableOrUnknown(data['icon_url']!, _iconUrlMeta)); + } + if (data.containsKey('announcement')) { + context.handle( + _announcementMeta, + announcement.isAcceptableOrUnknown( + data['announcement']!, _announcementMeta)); + } + if (data.containsKey('code_url')) { + context.handle(_codeUrlMeta, + codeUrl.isAcceptableOrUnknown(data['code_url']!, _codeUrlMeta)); + } + if (data.containsKey('pay_type')) { + context.handle(_payTypeMeta, + payType.isAcceptableOrUnknown(data['pay_type']!, _payTypeMeta)); } context.handle(_createdAtMeta, const VerificationResult.success()); + context.handle(_pinTimeMeta, const VerificationResult.success()); + if (data.containsKey('last_message_id')) { + context.handle( + _lastMessageIdMeta, + lastMessageId.isAcceptableOrUnknown( + data['last_message_id']!, _lastMessageIdMeta)); + } + context.handle( + _lastMessageCreatedAtMeta, const VerificationResult.success()); + if (data.containsKey('last_read_message_id')) { + context.handle( + _lastReadMessageIdMeta, + lastReadMessageId.isAcceptableOrUnknown( + data['last_read_message_id']!, _lastReadMessageIdMeta)); + } + if (data.containsKey('unseen_message_count')) { + context.handle( + _unseenMessageCountMeta, + unseenMessageCount.isAcceptableOrUnknown( + data['unseen_message_count']!, _unseenMessageCountMeta)); + } + context.handle(_statusMeta, const VerificationResult.success()); + if (data.containsKey('draft')) { + context.handle( + _draftMeta, draft.isAcceptableOrUnknown(data['draft']!, _draftMeta)); + } + context.handle(_muteUntilMeta, const VerificationResult.success()); + if (data.containsKey('expire_in')) { + context.handle(_expireInMeta, + expireIn.isAcceptableOrUnknown(data['expire_in']!, _expireInMeta)); + } return context; } @override - Set get $primaryKey => {appId, userId}; + Set get $primaryKey => {conversationId}; @override - FavoriteApp map(Map data, {String? tablePrefix}) { + Conversation map(Map data, {String? tablePrefix}) { final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; - return FavoriteApp( - appId: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}app_id'])!, - userId: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}user_id'])!, - createdAt: FavoriteApps.$convertercreatedAt.fromSql(attachedDatabase + return Conversation( + conversationId: attachedDatabase.typeMapping.read( + DriftSqlType.string, data['${effectivePrefix}conversation_id'])!, + ownerId: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}owner_id']), + category: Conversations.$convertercategory.fromSql(attachedDatabase .typeMapping - .read(DriftSqlType.int, data['${effectivePrefix}created_at'])!), - ); - } - - @override - FavoriteApps createAlias(String alias) { - return FavoriteApps(attachedDatabase, alias); - } - + .read(DriftSqlType.string, data['${effectivePrefix}category'])), + name: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}name']), + iconUrl: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}icon_url']), + announcement: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}announcement']), + codeUrl: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}code_url']), + payType: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}pay_type']), + createdAt: Conversations.$convertercreatedAt.fromSql(attachedDatabase + .typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}created_at'])!), + pinTime: Conversations.$converterpinTimen.fromSql(attachedDatabase + .typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}pin_time'])), + lastMessageId: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}last_message_id']), + lastMessageCreatedAt: Conversations.$converterlastMessageCreatedAtn + .fromSql(attachedDatabase.typeMapping.read(DriftSqlType.int, + data['${effectivePrefix}last_message_created_at'])), + lastReadMessageId: attachedDatabase.typeMapping.read( + DriftSqlType.string, data['${effectivePrefix}last_read_message_id']), + unseenMessageCount: attachedDatabase.typeMapping.read( + DriftSqlType.int, data['${effectivePrefix}unseen_message_count']), + status: Conversations.$converterstatus.fromSql(attachedDatabase + .typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}status'])!), + draft: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}draft']), + muteUntil: Conversations.$convertermuteUntiln.fromSql(attachedDatabase + .typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}mute_until'])), + expireIn: attachedDatabase.typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}expire_in']), + ); + } + + @override + Conversations createAlias(String alias) { + return Conversations(attachedDatabase, alias); + } + + static TypeConverter $convertercategory = + const ConversationCategoryTypeConverter(); static TypeConverter $convertercreatedAt = const MillisDateConverter(); + static TypeConverter $converterpinTime = + const MillisDateConverter(); + static TypeConverter $converterpinTimen = + NullAwareTypeConverter.wrap($converterpinTime); + static TypeConverter $converterlastMessageCreatedAt = + const MillisDateConverter(); + static TypeConverter $converterlastMessageCreatedAtn = + NullAwareTypeConverter.wrap($converterlastMessageCreatedAt); + static TypeConverter $converterstatus = + const ConversationStatusTypeConverter(); + static TypeConverter $convertermuteUntil = + const MillisDateConverter(); + static TypeConverter $convertermuteUntiln = + NullAwareTypeConverter.wrap($convertermuteUntil); @override - List get customConstraints => const ['PRIMARY KEY(app_id, user_id)']; + List get customConstraints => const ['PRIMARY KEY(conversation_id)']; @override bool get dontWriteConstraints => true; } -class FavoriteApp extends DataClass implements Insertable { - final String appId; - final String userId; +class Conversation extends DataClass implements Insertable { + final String conversationId; + final String? ownerId; + final ConversationCategory? category; + final String? name; + final String? iconUrl; + final String? announcement; + final String? codeUrl; + final String? payType; final DateTime createdAt; - const FavoriteApp( - {required this.appId, required this.userId, required this.createdAt}); + final DateTime? pinTime; + final String? lastMessageId; + final DateTime? lastMessageCreatedAt; + final String? lastReadMessageId; + final int? unseenMessageCount; + final ConversationStatus status; + final String? draft; + final DateTime? muteUntil; + final int? expireIn; + const Conversation( + {required this.conversationId, + this.ownerId, + this.category, + this.name, + this.iconUrl, + this.announcement, + this.codeUrl, + this.payType, + required this.createdAt, + this.pinTime, + this.lastMessageId, + this.lastMessageCreatedAt, + this.lastReadMessageId, + this.unseenMessageCount, + required this.status, + this.draft, + this.muteUntil, + this.expireIn}); @override Map toColumns(bool nullToAbsent) { final map = {}; - map['app_id'] = Variable(appId); - map['user_id'] = Variable(userId); + map['conversation_id'] = Variable(conversationId); + if (!nullToAbsent || ownerId != null) { + map['owner_id'] = Variable(ownerId); + } + if (!nullToAbsent || category != null) { + final converter = Conversations.$convertercategory; + map['category'] = Variable(converter.toSql(category)); + } + if (!nullToAbsent || name != null) { + map['name'] = Variable(name); + } + if (!nullToAbsent || iconUrl != null) { + map['icon_url'] = Variable(iconUrl); + } + if (!nullToAbsent || announcement != null) { + map['announcement'] = Variable(announcement); + } + if (!nullToAbsent || codeUrl != null) { + map['code_url'] = Variable(codeUrl); + } + if (!nullToAbsent || payType != null) { + map['pay_type'] = Variable(payType); + } { - final converter = FavoriteApps.$convertercreatedAt; + final converter = Conversations.$convertercreatedAt; map['created_at'] = Variable(converter.toSql(createdAt)); } + if (!nullToAbsent || pinTime != null) { + final converter = Conversations.$converterpinTimen; + map['pin_time'] = Variable(converter.toSql(pinTime)); + } + if (!nullToAbsent || lastMessageId != null) { + map['last_message_id'] = Variable(lastMessageId); + } + if (!nullToAbsent || lastMessageCreatedAt != null) { + final converter = Conversations.$converterlastMessageCreatedAtn; + map['last_message_created_at'] = + Variable(converter.toSql(lastMessageCreatedAt)); + } + if (!nullToAbsent || lastReadMessageId != null) { + map['last_read_message_id'] = Variable(lastReadMessageId); + } + if (!nullToAbsent || unseenMessageCount != null) { + map['unseen_message_count'] = Variable(unseenMessageCount); + } + { + final converter = Conversations.$converterstatus; + map['status'] = Variable(converter.toSql(status)); + } + if (!nullToAbsent || draft != null) { + map['draft'] = Variable(draft); + } + if (!nullToAbsent || muteUntil != null) { + final converter = Conversations.$convertermuteUntiln; + map['mute_until'] = Variable(converter.toSql(muteUntil)); + } + if (!nullToAbsent || expireIn != null) { + map['expire_in'] = Variable(expireIn); + } return map; } - FavoriteAppsCompanion toCompanion(bool nullToAbsent) { - return FavoriteAppsCompanion( - appId: Value(appId), - userId: Value(userId), + ConversationsCompanion toCompanion(bool nullToAbsent) { + return ConversationsCompanion( + conversationId: Value(conversationId), + ownerId: ownerId == null && nullToAbsent + ? const Value.absent() + : Value(ownerId), + category: category == null && nullToAbsent + ? const Value.absent() + : Value(category), + name: name == null && nullToAbsent ? const Value.absent() : Value(name), + iconUrl: iconUrl == null && nullToAbsent + ? const Value.absent() + : Value(iconUrl), + announcement: announcement == null && nullToAbsent + ? const Value.absent() + : Value(announcement), + codeUrl: codeUrl == null && nullToAbsent + ? const Value.absent() + : Value(codeUrl), + payType: payType == null && nullToAbsent + ? const Value.absent() + : Value(payType), createdAt: Value(createdAt), + pinTime: pinTime == null && nullToAbsent + ? const Value.absent() + : Value(pinTime), + lastMessageId: lastMessageId == null && nullToAbsent + ? const Value.absent() + : Value(lastMessageId), + lastMessageCreatedAt: lastMessageCreatedAt == null && nullToAbsent + ? const Value.absent() + : Value(lastMessageCreatedAt), + lastReadMessageId: lastReadMessageId == null && nullToAbsent + ? const Value.absent() + : Value(lastReadMessageId), + unseenMessageCount: unseenMessageCount == null && nullToAbsent + ? const Value.absent() + : Value(unseenMessageCount), + status: Value(status), + draft: + draft == null && nullToAbsent ? const Value.absent() : Value(draft), + muteUntil: muteUntil == null && nullToAbsent + ? const Value.absent() + : Value(muteUntil), + expireIn: expireIn == null && nullToAbsent + ? const Value.absent() + : Value(expireIn), ); } - factory FavoriteApp.fromJson(Map json, + factory Conversation.fromJson(Map json, {ValueSerializer? serializer}) { serializer ??= driftRuntimeOptions.defaultSerializer; - return FavoriteApp( - appId: serializer.fromJson(json['app_id']), - userId: serializer.fromJson(json['user_id']), + return Conversation( + conversationId: serializer.fromJson(json['conversation_id']), + ownerId: serializer.fromJson(json['owner_id']), + category: serializer.fromJson(json['category']), + name: serializer.fromJson(json['name']), + iconUrl: serializer.fromJson(json['icon_url']), + announcement: serializer.fromJson(json['announcement']), + codeUrl: serializer.fromJson(json['code_url']), + payType: serializer.fromJson(json['pay_type']), createdAt: serializer.fromJson(json['created_at']), + pinTime: serializer.fromJson(json['pin_time']), + lastMessageId: serializer.fromJson(json['last_message_id']), + lastMessageCreatedAt: + serializer.fromJson(json['last_message_created_at']), + lastReadMessageId: + serializer.fromJson(json['last_read_message_id']), + unseenMessageCount: + serializer.fromJson(json['unseen_message_count']), + status: serializer.fromJson(json['status']), + draft: serializer.fromJson(json['draft']), + muteUntil: serializer.fromJson(json['mute_until']), + expireIn: serializer.fromJson(json['expire_in']), ); } @override Map toJson({ValueSerializer? serializer}) { serializer ??= driftRuntimeOptions.defaultSerializer; return { - 'app_id': serializer.toJson(appId), - 'user_id': serializer.toJson(userId), + 'conversation_id': serializer.toJson(conversationId), + 'owner_id': serializer.toJson(ownerId), + 'category': serializer.toJson(category), + 'name': serializer.toJson(name), + 'icon_url': serializer.toJson(iconUrl), + 'announcement': serializer.toJson(announcement), + 'code_url': serializer.toJson(codeUrl), + 'pay_type': serializer.toJson(payType), 'created_at': serializer.toJson(createdAt), - }; - } - - FavoriteApp copyWith({String? appId, String? userId, DateTime? createdAt}) => - FavoriteApp( - appId: appId ?? this.appId, - userId: userId ?? this.userId, + 'pin_time': serializer.toJson(pinTime), + 'last_message_id': serializer.toJson(lastMessageId), + 'last_message_created_at': + serializer.toJson(lastMessageCreatedAt), + 'last_read_message_id': serializer.toJson(lastReadMessageId), + 'unseen_message_count': serializer.toJson(unseenMessageCount), + 'status': serializer.toJson(status), + 'draft': serializer.toJson(draft), + 'mute_until': serializer.toJson(muteUntil), + 'expire_in': serializer.toJson(expireIn), + }; + } + + Conversation copyWith( + {String? conversationId, + Value ownerId = const Value.absent(), + Value category = const Value.absent(), + Value name = const Value.absent(), + Value iconUrl = const Value.absent(), + Value announcement = const Value.absent(), + Value codeUrl = const Value.absent(), + Value payType = const Value.absent(), + DateTime? createdAt, + Value pinTime = const Value.absent(), + Value lastMessageId = const Value.absent(), + Value lastMessageCreatedAt = const Value.absent(), + Value lastReadMessageId = const Value.absent(), + Value unseenMessageCount = const Value.absent(), + ConversationStatus? status, + Value draft = const Value.absent(), + Value muteUntil = const Value.absent(), + Value expireIn = const Value.absent()}) => + Conversation( + conversationId: conversationId ?? this.conversationId, + ownerId: ownerId.present ? ownerId.value : this.ownerId, + category: category.present ? category.value : this.category, + name: name.present ? name.value : this.name, + iconUrl: iconUrl.present ? iconUrl.value : this.iconUrl, + announcement: + announcement.present ? announcement.value : this.announcement, + codeUrl: codeUrl.present ? codeUrl.value : this.codeUrl, + payType: payType.present ? payType.value : this.payType, createdAt: createdAt ?? this.createdAt, + pinTime: pinTime.present ? pinTime.value : this.pinTime, + lastMessageId: + lastMessageId.present ? lastMessageId.value : this.lastMessageId, + lastMessageCreatedAt: lastMessageCreatedAt.present + ? lastMessageCreatedAt.value + : this.lastMessageCreatedAt, + lastReadMessageId: lastReadMessageId.present + ? lastReadMessageId.value + : this.lastReadMessageId, + unseenMessageCount: unseenMessageCount.present + ? unseenMessageCount.value + : this.unseenMessageCount, + status: status ?? this.status, + draft: draft.present ? draft.value : this.draft, + muteUntil: muteUntil.present ? muteUntil.value : this.muteUntil, + expireIn: expireIn.present ? expireIn.value : this.expireIn, ); @override String toString() { - return (StringBuffer('FavoriteApp(') - ..write('appId: $appId, ') - ..write('userId: $userId, ') - ..write('createdAt: $createdAt') + return (StringBuffer('Conversation(') + ..write('conversationId: $conversationId, ') + ..write('ownerId: $ownerId, ') + ..write('category: $category, ') + ..write('name: $name, ') + ..write('iconUrl: $iconUrl, ') + ..write('announcement: $announcement, ') + ..write('codeUrl: $codeUrl, ') + ..write('payType: $payType, ') + ..write('createdAt: $createdAt, ') + ..write('pinTime: $pinTime, ') + ..write('lastMessageId: $lastMessageId, ') + ..write('lastMessageCreatedAt: $lastMessageCreatedAt, ') + ..write('lastReadMessageId: $lastReadMessageId, ') + ..write('unseenMessageCount: $unseenMessageCount, ') + ..write('status: $status, ') + ..write('draft: $draft, ') + ..write('muteUntil: $muteUntil, ') + ..write('expireIn: $expireIn') ..write(')')) .toString(); } @override - int get hashCode => Object.hash(appId, userId, createdAt); + int get hashCode => Object.hash( + conversationId, + ownerId, + category, + name, + iconUrl, + announcement, + codeUrl, + payType, + createdAt, + pinTime, + lastMessageId, + lastMessageCreatedAt, + lastReadMessageId, + unseenMessageCount, + status, + draft, + muteUntil, + expireIn); @override bool operator ==(Object other) => identical(this, other) || - (other is FavoriteApp && - other.appId == this.appId && - other.userId == this.userId && - other.createdAt == this.createdAt); + (other is Conversation && + other.conversationId == this.conversationId && + other.ownerId == this.ownerId && + other.category == this.category && + other.name == this.name && + other.iconUrl == this.iconUrl && + other.announcement == this.announcement && + other.codeUrl == this.codeUrl && + other.payType == this.payType && + other.createdAt == this.createdAt && + other.pinTime == this.pinTime && + other.lastMessageId == this.lastMessageId && + other.lastMessageCreatedAt == this.lastMessageCreatedAt && + other.lastReadMessageId == this.lastReadMessageId && + other.unseenMessageCount == this.unseenMessageCount && + other.status == this.status && + other.draft == this.draft && + other.muteUntil == this.muteUntil && + other.expireIn == this.expireIn); } -class FavoriteAppsCompanion extends UpdateCompanion { - final Value appId; - final Value userId; +class ConversationsCompanion extends UpdateCompanion { + final Value conversationId; + final Value ownerId; + final Value category; + final Value name; + final Value iconUrl; + final Value announcement; + final Value codeUrl; + final Value payType; final Value createdAt; + final Value pinTime; + final Value lastMessageId; + final Value lastMessageCreatedAt; + final Value lastReadMessageId; + final Value unseenMessageCount; + final Value status; + final Value draft; + final Value muteUntil; + final Value expireIn; final Value rowid; - const FavoriteAppsCompanion({ - this.appId = const Value.absent(), - this.userId = const Value.absent(), + const ConversationsCompanion({ + this.conversationId = const Value.absent(), + this.ownerId = const Value.absent(), + this.category = const Value.absent(), + this.name = const Value.absent(), + this.iconUrl = const Value.absent(), + this.announcement = const Value.absent(), + this.codeUrl = const Value.absent(), + this.payType = const Value.absent(), this.createdAt = const Value.absent(), + this.pinTime = const Value.absent(), + this.lastMessageId = const Value.absent(), + this.lastMessageCreatedAt = const Value.absent(), + this.lastReadMessageId = const Value.absent(), + this.unseenMessageCount = const Value.absent(), + this.status = const Value.absent(), + this.draft = const Value.absent(), + this.muteUntil = const Value.absent(), + this.expireIn = const Value.absent(), this.rowid = const Value.absent(), }); - FavoriteAppsCompanion.insert({ - required String appId, - required String userId, + ConversationsCompanion.insert({ + required String conversationId, + this.ownerId = const Value.absent(), + this.category = const Value.absent(), + this.name = const Value.absent(), + this.iconUrl = const Value.absent(), + this.announcement = const Value.absent(), + this.codeUrl = const Value.absent(), + this.payType = const Value.absent(), required DateTime createdAt, + this.pinTime = const Value.absent(), + this.lastMessageId = const Value.absent(), + this.lastMessageCreatedAt = const Value.absent(), + this.lastReadMessageId = const Value.absent(), + this.unseenMessageCount = const Value.absent(), + required ConversationStatus status, + this.draft = const Value.absent(), + this.muteUntil = const Value.absent(), + this.expireIn = const Value.absent(), this.rowid = const Value.absent(), - }) : appId = Value(appId), - userId = Value(userId), - createdAt = Value(createdAt); - static Insertable custom({ - Expression? appId, - Expression? userId, + }) : conversationId = Value(conversationId), + createdAt = Value(createdAt), + status = Value(status); + static Insertable custom({ + Expression? conversationId, + Expression? ownerId, + Expression? category, + Expression? name, + Expression? iconUrl, + Expression? announcement, + Expression? codeUrl, + Expression? payType, Expression? createdAt, + Expression? pinTime, + Expression? lastMessageId, + Expression? lastMessageCreatedAt, + Expression? lastReadMessageId, + Expression? unseenMessageCount, + Expression? status, + Expression? draft, + Expression? muteUntil, + Expression? expireIn, Expression? rowid, }) { return RawValuesInsertable({ - if (appId != null) 'app_id': appId, - if (userId != null) 'user_id': userId, + if (conversationId != null) 'conversation_id': conversationId, + if (ownerId != null) 'owner_id': ownerId, + if (category != null) 'category': category, + if (name != null) 'name': name, + if (iconUrl != null) 'icon_url': iconUrl, + if (announcement != null) 'announcement': announcement, + if (codeUrl != null) 'code_url': codeUrl, + if (payType != null) 'pay_type': payType, if (createdAt != null) 'created_at': createdAt, + if (pinTime != null) 'pin_time': pinTime, + if (lastMessageId != null) 'last_message_id': lastMessageId, + if (lastMessageCreatedAt != null) + 'last_message_created_at': lastMessageCreatedAt, + if (lastReadMessageId != null) 'last_read_message_id': lastReadMessageId, + if (unseenMessageCount != null) + 'unseen_message_count': unseenMessageCount, + if (status != null) 'status': status, + if (draft != null) 'draft': draft, + if (muteUntil != null) 'mute_until': muteUntil, + if (expireIn != null) 'expire_in': expireIn, if (rowid != null) 'rowid': rowid, }); } - FavoriteAppsCompanion copyWith( - {Value? appId, - Value? userId, + ConversationsCompanion copyWith( + {Value? conversationId, + Value? ownerId, + Value? category, + Value? name, + Value? iconUrl, + Value? announcement, + Value? codeUrl, + Value? payType, Value? createdAt, + Value? pinTime, + Value? lastMessageId, + Value? lastMessageCreatedAt, + Value? lastReadMessageId, + Value? unseenMessageCount, + Value? status, + Value? draft, + Value? muteUntil, + Value? expireIn, Value? rowid}) { - return FavoriteAppsCompanion( - appId: appId ?? this.appId, - userId: userId ?? this.userId, + return ConversationsCompanion( + conversationId: conversationId ?? this.conversationId, + ownerId: ownerId ?? this.ownerId, + category: category ?? this.category, + name: name ?? this.name, + iconUrl: iconUrl ?? this.iconUrl, + announcement: announcement ?? this.announcement, + codeUrl: codeUrl ?? this.codeUrl, + payType: payType ?? this.payType, createdAt: createdAt ?? this.createdAt, + pinTime: pinTime ?? this.pinTime, + lastMessageId: lastMessageId ?? this.lastMessageId, + lastMessageCreatedAt: lastMessageCreatedAt ?? this.lastMessageCreatedAt, + lastReadMessageId: lastReadMessageId ?? this.lastReadMessageId, + unseenMessageCount: unseenMessageCount ?? this.unseenMessageCount, + status: status ?? this.status, + draft: draft ?? this.draft, + muteUntil: muteUntil ?? this.muteUntil, + expireIn: expireIn ?? this.expireIn, rowid: rowid ?? this.rowid, ); } @@ -205,16 +798,67 @@ class FavoriteAppsCompanion extends UpdateCompanion { @override Map toColumns(bool nullToAbsent) { final map = {}; - if (appId.present) { - map['app_id'] = Variable(appId.value); + if (conversationId.present) { + map['conversation_id'] = Variable(conversationId.value); } - if (userId.present) { - map['user_id'] = Variable(userId.value); + if (ownerId.present) { + map['owner_id'] = Variable(ownerId.value); + } + if (category.present) { + final converter = Conversations.$convertercategory; + map['category'] = Variable(converter.toSql(category.value)); + } + if (name.present) { + map['name'] = Variable(name.value); + } + if (iconUrl.present) { + map['icon_url'] = Variable(iconUrl.value); + } + if (announcement.present) { + map['announcement'] = Variable(announcement.value); + } + if (codeUrl.present) { + map['code_url'] = Variable(codeUrl.value); + } + if (payType.present) { + map['pay_type'] = Variable(payType.value); } if (createdAt.present) { - final converter = FavoriteApps.$convertercreatedAt; + final converter = Conversations.$convertercreatedAt; map['created_at'] = Variable(converter.toSql(createdAt.value)); } + if (pinTime.present) { + final converter = Conversations.$converterpinTimen; + map['pin_time'] = Variable(converter.toSql(pinTime.value)); + } + if (lastMessageId.present) { + map['last_message_id'] = Variable(lastMessageId.value); + } + if (lastMessageCreatedAt.present) { + final converter = Conversations.$converterlastMessageCreatedAtn; + map['last_message_created_at'] = + Variable(converter.toSql(lastMessageCreatedAt.value)); + } + if (lastReadMessageId.present) { + map['last_read_message_id'] = Variable(lastReadMessageId.value); + } + if (unseenMessageCount.present) { + map['unseen_message_count'] = Variable(unseenMessageCount.value); + } + if (status.present) { + final converter = Conversations.$converterstatus; + map['status'] = Variable(converter.toSql(status.value)); + } + if (draft.present) { + map['draft'] = Variable(draft.value); + } + if (muteUntil.present) { + final converter = Conversations.$convertermuteUntiln; + map['mute_until'] = Variable(converter.toSql(muteUntil.value)); + } + if (expireIn.present) { + map['expire_in'] = Variable(expireIn.value); + } if (rowid.present) { map['rowid'] = Variable(rowid.value); } @@ -223,589 +867,1278 @@ class FavoriteAppsCompanion extends UpdateCompanion { @override String toString() { - return (StringBuffer('FavoriteAppsCompanion(') - ..write('appId: $appId, ') - ..write('userId: $userId, ') + return (StringBuffer('ConversationsCompanion(') + ..write('conversationId: $conversationId, ') + ..write('ownerId: $ownerId, ') + ..write('category: $category, ') + ..write('name: $name, ') + ..write('iconUrl: $iconUrl, ') + ..write('announcement: $announcement, ') + ..write('codeUrl: $codeUrl, ') + ..write('payType: $payType, ') ..write('createdAt: $createdAt, ') + ..write('pinTime: $pinTime, ') + ..write('lastMessageId: $lastMessageId, ') + ..write('lastMessageCreatedAt: $lastMessageCreatedAt, ') + ..write('lastReadMessageId: $lastReadMessageId, ') + ..write('unseenMessageCount: $unseenMessageCount, ') + ..write('status: $status, ') + ..write('draft: $draft, ') + ..write('muteUntil: $muteUntil, ') + ..write('expireIn: $expireIn, ') ..write('rowid: $rowid') ..write(')')) .toString(); } } -class Apps extends Table with TableInfo { +class Messages extends Table with TableInfo { @override final GeneratedDatabase attachedDatabase; final String? _alias; - Apps(this.attachedDatabase, [this._alias]); - static const VerificationMeta _appIdMeta = const VerificationMeta('appId'); - late final GeneratedColumn appId = GeneratedColumn( - 'app_id', aliasedName, false, + Messages(this.attachedDatabase, [this._alias]); + static const VerificationMeta _messageIdMeta = + const VerificationMeta('messageId'); + late final GeneratedColumn messageId = GeneratedColumn( + 'message_id', aliasedName, false, type: DriftSqlType.string, requiredDuringInsert: true, $customConstraints: 'NOT NULL'); - static const VerificationMeta _appNumberMeta = - const VerificationMeta('appNumber'); - late final GeneratedColumn appNumber = GeneratedColumn( - 'app_number', aliasedName, false, + static const VerificationMeta _conversationIdMeta = + const VerificationMeta('conversationId'); + late final GeneratedColumn conversationId = GeneratedColumn( + 'conversation_id', aliasedName, false, type: DriftSqlType.string, requiredDuringInsert: true, $customConstraints: 'NOT NULL'); - static const VerificationMeta _homeUriMeta = - const VerificationMeta('homeUri'); - late final GeneratedColumn homeUri = GeneratedColumn( - 'home_uri', aliasedName, false, + static const VerificationMeta _userIdMeta = const VerificationMeta('userId'); + late final GeneratedColumn userId = GeneratedColumn( + 'user_id', aliasedName, false, type: DriftSqlType.string, requiredDuringInsert: true, $customConstraints: 'NOT NULL'); - static const VerificationMeta _redirectUriMeta = - const VerificationMeta('redirectUri'); - late final GeneratedColumn redirectUri = GeneratedColumn( - 'redirect_uri', aliasedName, false, + static const VerificationMeta _categoryMeta = + const VerificationMeta('category'); + late final GeneratedColumn category = GeneratedColumn( + 'category', aliasedName, false, type: DriftSqlType.string, requiredDuringInsert: true, $customConstraints: 'NOT NULL'); - static const VerificationMeta _nameMeta = const VerificationMeta('name'); - late final GeneratedColumn name = GeneratedColumn( - 'name', aliasedName, false, + static const VerificationMeta _contentMeta = + const VerificationMeta('content'); + late final GeneratedColumn content = GeneratedColumn( + 'content', aliasedName, true, type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL'); - static const VerificationMeta _iconUrlMeta = - const VerificationMeta('iconUrl'); - late final GeneratedColumn iconUrl = GeneratedColumn( - 'icon_url', aliasedName, false, + requiredDuringInsert: false, + $customConstraints: ''); + static const VerificationMeta _mediaUrlMeta = + const VerificationMeta('mediaUrl'); + late final GeneratedColumn mediaUrl = GeneratedColumn( + 'media_url', aliasedName, true, type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL'); - static const VerificationMeta _categoryMeta = - const VerificationMeta('category'); - late final GeneratedColumn category = GeneratedColumn( - 'category', aliasedName, true, + requiredDuringInsert: false, + $customConstraints: ''); + static const VerificationMeta _mediaMimeTypeMeta = + const VerificationMeta('mediaMimeType'); + late final GeneratedColumn mediaMimeType = GeneratedColumn( + 'media_mime_type', aliasedName, true, type: DriftSqlType.string, requiredDuringInsert: false, $customConstraints: ''); - static const VerificationMeta _descriptionMeta = - const VerificationMeta('description'); - late final GeneratedColumn description = GeneratedColumn( - 'description', aliasedName, false, + static const VerificationMeta _mediaSizeMeta = + const VerificationMeta('mediaSize'); + late final GeneratedColumn mediaSize = GeneratedColumn( + 'media_size', aliasedName, true, + type: DriftSqlType.int, + requiredDuringInsert: false, + $customConstraints: ''); + static const VerificationMeta _mediaDurationMeta = + const VerificationMeta('mediaDuration'); + late final GeneratedColumn mediaDuration = GeneratedColumn( + 'media_duration', aliasedName, true, type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL'); - static const VerificationMeta _appSecretMeta = - const VerificationMeta('appSecret'); - late final GeneratedColumn appSecret = GeneratedColumn( - 'app_secret', aliasedName, false, + requiredDuringInsert: false, + $customConstraints: ''); + static const VerificationMeta _mediaWidthMeta = + const VerificationMeta('mediaWidth'); + late final GeneratedColumn mediaWidth = GeneratedColumn( + 'media_width', aliasedName, true, + type: DriftSqlType.int, + requiredDuringInsert: false, + $customConstraints: ''); + static const VerificationMeta _mediaHeightMeta = + const VerificationMeta('mediaHeight'); + late final GeneratedColumn mediaHeight = GeneratedColumn( + 'media_height', aliasedName, true, + type: DriftSqlType.int, + requiredDuringInsert: false, + $customConstraints: ''); + static const VerificationMeta _mediaHashMeta = + const VerificationMeta('mediaHash'); + late final GeneratedColumn mediaHash = GeneratedColumn( + 'media_hash', aliasedName, true, type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL'); - static const VerificationMeta _capabilitiesMeta = - const VerificationMeta('capabilities'); - late final GeneratedColumn capabilities = GeneratedColumn( - 'capabilities', aliasedName, true, + requiredDuringInsert: false, + $customConstraints: ''); + static const VerificationMeta _thumbImageMeta = + const VerificationMeta('thumbImage'); + late final GeneratedColumn thumbImage = GeneratedColumn( + 'thumb_image', aliasedName, true, type: DriftSqlType.string, requiredDuringInsert: false, $customConstraints: ''); - static const VerificationMeta _creatorIdMeta = - const VerificationMeta('creatorId'); - late final GeneratedColumn creatorId = GeneratedColumn( - 'creator_id', aliasedName, false, + static const VerificationMeta _mediaKeyMeta = + const VerificationMeta('mediaKey'); + late final GeneratedColumn mediaKey = GeneratedColumn( + 'media_key', aliasedName, true, type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL'); - static const VerificationMeta _resourcePatternsMeta = - const VerificationMeta('resourcePatterns'); - late final GeneratedColumn resourcePatterns = GeneratedColumn( - 'resource_patterns', aliasedName, true, + requiredDuringInsert: false, + $customConstraints: ''); + static const VerificationMeta _mediaDigestMeta = + const VerificationMeta('mediaDigest'); + late final GeneratedColumn mediaDigest = GeneratedColumn( + 'media_digest', aliasedName, true, type: DriftSqlType.string, requiredDuringInsert: false, $customConstraints: ''); - static const VerificationMeta _updatedAtMeta = - const VerificationMeta('updatedAt'); - late final GeneratedColumnWithTypeConverter updatedAt = - GeneratedColumn('updated_at', aliasedName, true, - type: DriftSqlType.int, + static const VerificationMeta _mediaStatusMeta = + const VerificationMeta('mediaStatus'); + late final GeneratedColumnWithTypeConverter + mediaStatus = GeneratedColumn('media_status', aliasedName, true, + type: DriftSqlType.string, requiredDuringInsert: false, $customConstraints: '') - .withConverter(Apps.$converterupdatedAtn); - @override - List get $columns => [ - appId, - appNumber, - homeUri, - redirectUri, - name, - iconUrl, + .withConverter(Messages.$convertermediaStatus); + static const VerificationMeta _statusMeta = const VerificationMeta('status'); + late final GeneratedColumnWithTypeConverter status = + GeneratedColumn('status', aliasedName, false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL') + .withConverter(Messages.$converterstatus); + static const VerificationMeta _createdAtMeta = + const VerificationMeta('createdAt'); + late final GeneratedColumnWithTypeConverter createdAt = + GeneratedColumn('created_at', aliasedName, false, + type: DriftSqlType.int, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL') + .withConverter(Messages.$convertercreatedAt); + static const VerificationMeta _actionMeta = const VerificationMeta('action'); + late final GeneratedColumn action = GeneratedColumn( + 'action', aliasedName, true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: ''); + static const VerificationMeta _participantIdMeta = + const VerificationMeta('participantId'); + late final GeneratedColumn participantId = GeneratedColumn( + 'participant_id', aliasedName, true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: ''); + static const VerificationMeta _snapshotIdMeta = + const VerificationMeta('snapshotId'); + late final GeneratedColumn snapshotId = GeneratedColumn( + 'snapshot_id', aliasedName, true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: ''); + static const VerificationMeta _hyperlinkMeta = + const VerificationMeta('hyperlink'); + late final GeneratedColumn hyperlink = GeneratedColumn( + 'hyperlink', aliasedName, true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: ''); + static const VerificationMeta _nameMeta = const VerificationMeta('name'); + late final GeneratedColumn name = GeneratedColumn( + 'name', aliasedName, true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: ''); + static const VerificationMeta _albumIdMeta = + const VerificationMeta('albumId'); + late final GeneratedColumn albumId = GeneratedColumn( + 'album_id', aliasedName, true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: ''); + static const VerificationMeta _stickerIdMeta = + const VerificationMeta('stickerId'); + late final GeneratedColumn stickerId = GeneratedColumn( + 'sticker_id', aliasedName, true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: ''); + static const VerificationMeta _sharedUserIdMeta = + const VerificationMeta('sharedUserId'); + late final GeneratedColumn sharedUserId = GeneratedColumn( + 'shared_user_id', aliasedName, true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: ''); + static const VerificationMeta _mediaWaveformMeta = + const VerificationMeta('mediaWaveform'); + late final GeneratedColumn mediaWaveform = GeneratedColumn( + 'media_waveform', aliasedName, true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: ''); + static const VerificationMeta _quoteMessageIdMeta = + const VerificationMeta('quoteMessageId'); + late final GeneratedColumn quoteMessageId = GeneratedColumn( + 'quote_message_id', aliasedName, true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: ''); + static const VerificationMeta _quoteContentMeta = + const VerificationMeta('quoteContent'); + late final GeneratedColumn quoteContent = GeneratedColumn( + 'quote_content', aliasedName, true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: ''); + static const VerificationMeta _thumbUrlMeta = + const VerificationMeta('thumbUrl'); + late final GeneratedColumn thumbUrl = GeneratedColumn( + 'thumb_url', aliasedName, true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: ''); + static const VerificationMeta _captionMeta = + const VerificationMeta('caption'); + late final GeneratedColumn caption = GeneratedColumn( + 'caption', aliasedName, true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: ''); + @override + List get $columns => [ + messageId, + conversationId, + userId, category, - description, - appSecret, - capabilities, - creatorId, - resourcePatterns, - updatedAt + content, + mediaUrl, + mediaMimeType, + mediaSize, + mediaDuration, + mediaWidth, + mediaHeight, + mediaHash, + thumbImage, + mediaKey, + mediaDigest, + mediaStatus, + status, + createdAt, + action, + participantId, + snapshotId, + hyperlink, + name, + albumId, + stickerId, + sharedUserId, + mediaWaveform, + quoteMessageId, + quoteContent, + thumbUrl, + caption ]; @override - String get aliasedName => _alias ?? 'apps'; + String get aliasedName => _alias ?? 'messages'; @override - String get actualTableName => 'apps'; + String get actualTableName => 'messages'; @override - VerificationContext validateIntegrity(Insertable instance, + VerificationContext validateIntegrity(Insertable instance, {bool isInserting = false}) { final context = VerificationContext(); final data = instance.toColumns(true); - if (data.containsKey('app_id')) { - context.handle( - _appIdMeta, appId.isAcceptableOrUnknown(data['app_id']!, _appIdMeta)); - } else if (isInserting) { - context.missing(_appIdMeta); - } - if (data.containsKey('app_number')) { - context.handle(_appNumberMeta, - appNumber.isAcceptableOrUnknown(data['app_number']!, _appNumberMeta)); - } else if (isInserting) { - context.missing(_appNumberMeta); - } - if (data.containsKey('home_uri')) { - context.handle(_homeUriMeta, - homeUri.isAcceptableOrUnknown(data['home_uri']!, _homeUriMeta)); - } else if (isInserting) { - context.missing(_homeUriMeta); - } - if (data.containsKey('redirect_uri')) { - context.handle( - _redirectUriMeta, - redirectUri.isAcceptableOrUnknown( - data['redirect_uri']!, _redirectUriMeta)); + if (data.containsKey('message_id')) { + context.handle(_messageIdMeta, + messageId.isAcceptableOrUnknown(data['message_id']!, _messageIdMeta)); } else if (isInserting) { - context.missing(_redirectUriMeta); + context.missing(_messageIdMeta); } - if (data.containsKey('name')) { + if (data.containsKey('conversation_id')) { context.handle( - _nameMeta, name.isAcceptableOrUnknown(data['name']!, _nameMeta)); + _conversationIdMeta, + conversationId.isAcceptableOrUnknown( + data['conversation_id']!, _conversationIdMeta)); } else if (isInserting) { - context.missing(_nameMeta); + context.missing(_conversationIdMeta); } - if (data.containsKey('icon_url')) { - context.handle(_iconUrlMeta, - iconUrl.isAcceptableOrUnknown(data['icon_url']!, _iconUrlMeta)); + if (data.containsKey('user_id')) { + context.handle(_userIdMeta, + userId.isAcceptableOrUnknown(data['user_id']!, _userIdMeta)); } else if (isInserting) { - context.missing(_iconUrlMeta); + context.missing(_userIdMeta); } if (data.containsKey('category')) { context.handle(_categoryMeta, category.isAcceptableOrUnknown(data['category']!, _categoryMeta)); + } else if (isInserting) { + context.missing(_categoryMeta); } - if (data.containsKey('description')) { + if (data.containsKey('content')) { + context.handle(_contentMeta, + content.isAcceptableOrUnknown(data['content']!, _contentMeta)); + } + if (data.containsKey('media_url')) { + context.handle(_mediaUrlMeta, + mediaUrl.isAcceptableOrUnknown(data['media_url']!, _mediaUrlMeta)); + } + if (data.containsKey('media_mime_type')) { context.handle( - _descriptionMeta, - description.isAcceptableOrUnknown( - data['description']!, _descriptionMeta)); - } else if (isInserting) { - context.missing(_descriptionMeta); + _mediaMimeTypeMeta, + mediaMimeType.isAcceptableOrUnknown( + data['media_mime_type']!, _mediaMimeTypeMeta)); } - if (data.containsKey('app_secret')) { - context.handle(_appSecretMeta, - appSecret.isAcceptableOrUnknown(data['app_secret']!, _appSecretMeta)); - } else if (isInserting) { - context.missing(_appSecretMeta); + if (data.containsKey('media_size')) { + context.handle(_mediaSizeMeta, + mediaSize.isAcceptableOrUnknown(data['media_size']!, _mediaSizeMeta)); } - if (data.containsKey('capabilities')) { + if (data.containsKey('media_duration')) { context.handle( - _capabilitiesMeta, - capabilities.isAcceptableOrUnknown( - data['capabilities']!, _capabilitiesMeta)); + _mediaDurationMeta, + mediaDuration.isAcceptableOrUnknown( + data['media_duration']!, _mediaDurationMeta)); } - if (data.containsKey('creator_id')) { - context.handle(_creatorIdMeta, - creatorId.isAcceptableOrUnknown(data['creator_id']!, _creatorIdMeta)); - } else if (isInserting) { - context.missing(_creatorIdMeta); + if (data.containsKey('media_width')) { + context.handle( + _mediaWidthMeta, + mediaWidth.isAcceptableOrUnknown( + data['media_width']!, _mediaWidthMeta)); } - if (data.containsKey('resource_patterns')) { + if (data.containsKey('media_height')) { context.handle( - _resourcePatternsMeta, - resourcePatterns.isAcceptableOrUnknown( - data['resource_patterns']!, _resourcePatternsMeta)); + _mediaHeightMeta, + mediaHeight.isAcceptableOrUnknown( + data['media_height']!, _mediaHeightMeta)); } - context.handle(_updatedAtMeta, const VerificationResult.success()); - return context; - } - - @override - Set get $primaryKey => {appId}; + if (data.containsKey('media_hash')) { + context.handle(_mediaHashMeta, + mediaHash.isAcceptableOrUnknown(data['media_hash']!, _mediaHashMeta)); + } + if (data.containsKey('thumb_image')) { + context.handle( + _thumbImageMeta, + thumbImage.isAcceptableOrUnknown( + data['thumb_image']!, _thumbImageMeta)); + } + if (data.containsKey('media_key')) { + context.handle(_mediaKeyMeta, + mediaKey.isAcceptableOrUnknown(data['media_key']!, _mediaKeyMeta)); + } + if (data.containsKey('media_digest')) { + context.handle( + _mediaDigestMeta, + mediaDigest.isAcceptableOrUnknown( + data['media_digest']!, _mediaDigestMeta)); + } + context.handle(_mediaStatusMeta, const VerificationResult.success()); + context.handle(_statusMeta, const VerificationResult.success()); + context.handle(_createdAtMeta, const VerificationResult.success()); + if (data.containsKey('action')) { + context.handle(_actionMeta, + action.isAcceptableOrUnknown(data['action']!, _actionMeta)); + } + if (data.containsKey('participant_id')) { + context.handle( + _participantIdMeta, + participantId.isAcceptableOrUnknown( + data['participant_id']!, _participantIdMeta)); + } + if (data.containsKey('snapshot_id')) { + context.handle( + _snapshotIdMeta, + snapshotId.isAcceptableOrUnknown( + data['snapshot_id']!, _snapshotIdMeta)); + } + if (data.containsKey('hyperlink')) { + context.handle(_hyperlinkMeta, + hyperlink.isAcceptableOrUnknown(data['hyperlink']!, _hyperlinkMeta)); + } + if (data.containsKey('name')) { + context.handle( + _nameMeta, name.isAcceptableOrUnknown(data['name']!, _nameMeta)); + } + if (data.containsKey('album_id')) { + context.handle(_albumIdMeta, + albumId.isAcceptableOrUnknown(data['album_id']!, _albumIdMeta)); + } + if (data.containsKey('sticker_id')) { + context.handle(_stickerIdMeta, + stickerId.isAcceptableOrUnknown(data['sticker_id']!, _stickerIdMeta)); + } + if (data.containsKey('shared_user_id')) { + context.handle( + _sharedUserIdMeta, + sharedUserId.isAcceptableOrUnknown( + data['shared_user_id']!, _sharedUserIdMeta)); + } + if (data.containsKey('media_waveform')) { + context.handle( + _mediaWaveformMeta, + mediaWaveform.isAcceptableOrUnknown( + data['media_waveform']!, _mediaWaveformMeta)); + } + if (data.containsKey('quote_message_id')) { + context.handle( + _quoteMessageIdMeta, + quoteMessageId.isAcceptableOrUnknown( + data['quote_message_id']!, _quoteMessageIdMeta)); + } + if (data.containsKey('quote_content')) { + context.handle( + _quoteContentMeta, + quoteContent.isAcceptableOrUnknown( + data['quote_content']!, _quoteContentMeta)); + } + if (data.containsKey('thumb_url')) { + context.handle(_thumbUrlMeta, + thumbUrl.isAcceptableOrUnknown(data['thumb_url']!, _thumbUrlMeta)); + } + if (data.containsKey('caption')) { + context.handle(_captionMeta, + caption.isAcceptableOrUnknown(data['caption']!, _captionMeta)); + } + return context; + } + @override - App map(Map data, {String? tablePrefix}) { + Set get $primaryKey => {messageId}; + @override + Message map(Map data, {String? tablePrefix}) { final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; - return App( - appId: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}app_id'])!, - appNumber: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}app_number'])!, - homeUri: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}home_uri'])!, - redirectUri: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}redirect_uri'])!, - name: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}name'])!, - iconUrl: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}icon_url'])!, + return Message( + messageId: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}message_id'])!, + conversationId: attachedDatabase.typeMapping.read( + DriftSqlType.string, data['${effectivePrefix}conversation_id'])!, + userId: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}user_id'])!, category: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}category']), - description: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}description'])!, - appSecret: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}app_secret'])!, - capabilities: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}capabilities']), - creatorId: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}creator_id'])!, - resourcePatterns: attachedDatabase.typeMapping.read( - DriftSqlType.string, data['${effectivePrefix}resource_patterns']), - updatedAt: Apps.$converterupdatedAtn.fromSql(attachedDatabase.typeMapping - .read(DriftSqlType.int, data['${effectivePrefix}updated_at'])), + .read(DriftSqlType.string, data['${effectivePrefix}category'])!, + content: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}content']), + mediaUrl: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}media_url']), + mediaMimeType: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}media_mime_type']), + mediaSize: attachedDatabase.typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}media_size']), + mediaDuration: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}media_duration']), + mediaWidth: attachedDatabase.typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}media_width']), + mediaHeight: attachedDatabase.typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}media_height']), + mediaHash: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}media_hash']), + thumbImage: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}thumb_image']), + mediaKey: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}media_key']), + mediaDigest: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}media_digest']), + mediaStatus: Messages.$convertermediaStatus.fromSql(attachedDatabase + .typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}media_status'])), + status: Messages.$converterstatus.fromSql(attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}status'])!), + createdAt: Messages.$convertercreatedAt.fromSql(attachedDatabase + .typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}created_at'])!), + action: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}action']), + participantId: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}participant_id']), + snapshotId: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}snapshot_id']), + hyperlink: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}hyperlink']), + name: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}name']), + albumId: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}album_id']), + stickerId: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}sticker_id']), + sharedUserId: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}shared_user_id']), + mediaWaveform: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}media_waveform']), + quoteMessageId: attachedDatabase.typeMapping.read( + DriftSqlType.string, data['${effectivePrefix}quote_message_id']), + quoteContent: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}quote_content']), + thumbUrl: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}thumb_url']), + caption: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}caption']), ); } @override - Apps createAlias(String alias) { - return Apps(attachedDatabase, alias); + Messages createAlias(String alias) { + return Messages(attachedDatabase, alias); } - static TypeConverter $converterupdatedAt = + static TypeConverter $convertermediaStatus = + const MediaStatusTypeConverter(); + static TypeConverter $converterstatus = + const MessageStatusTypeConverter(); + static TypeConverter $convertercreatedAt = const MillisDateConverter(); - static TypeConverter $converterupdatedAtn = - NullAwareTypeConverter.wrap($converterupdatedAt); @override - List get customConstraints => const ['PRIMARY KEY(app_id)']; + List get customConstraints => const [ + 'PRIMARY KEY(message_id)', + 'FOREIGN KEY(conversation_id)REFERENCES conversations(conversation_id)ON UPDATE NO ACTION ON DELETE CASCADE' + ]; @override bool get dontWriteConstraints => true; } -class App extends DataClass implements Insertable { - final String appId; - final String appNumber; - final String homeUri; - final String redirectUri; - final String name; - final String iconUrl; - final String? category; - final String description; - final String appSecret; - final String? capabilities; - final String creatorId; - final String? resourcePatterns; - final DateTime? updatedAt; - const App( - {required this.appId, - required this.appNumber, - required this.homeUri, - required this.redirectUri, - required this.name, - required this.iconUrl, - this.category, - required this.description, - required this.appSecret, - this.capabilities, - required this.creatorId, - this.resourcePatterns, - this.updatedAt}); - @override - Map toColumns(bool nullToAbsent) { - final map = {}; - map['app_id'] = Variable(appId); - map['app_number'] = Variable(appNumber); - map['home_uri'] = Variable(homeUri); - map['redirect_uri'] = Variable(redirectUri); - map['name'] = Variable(name); - map['icon_url'] = Variable(iconUrl); - if (!nullToAbsent || category != null) { - map['category'] = Variable(category); - } - map['description'] = Variable(description); - map['app_secret'] = Variable(appSecret); - if (!nullToAbsent || capabilities != null) { - map['capabilities'] = Variable(capabilities); - } - map['creator_id'] = Variable(creatorId); - if (!nullToAbsent || resourcePatterns != null) { - map['resource_patterns'] = Variable(resourcePatterns); - } - if (!nullToAbsent || updatedAt != null) { - final converter = Apps.$converterupdatedAtn; - map['updated_at'] = Variable(converter.toSql(updatedAt)); - } - return map; +class Message extends DataClass implements Insertable { + final String messageId; + final String conversationId; + final String userId; + final String category; + final String? content; + final String? mediaUrl; + final String? mediaMimeType; + final int? mediaSize; + final String? mediaDuration; + final int? mediaWidth; + final int? mediaHeight; + final String? mediaHash; + final String? thumbImage; + final String? mediaKey; + final String? mediaDigest; + final MediaStatus? mediaStatus; + final MessageStatus status; + final DateTime createdAt; + final String? action; + final String? participantId; + final String? snapshotId; + final String? hyperlink; + final String? name; + final String? albumId; + final String? stickerId; + final String? sharedUserId; + final String? mediaWaveform; + final String? quoteMessageId; + final String? quoteContent; + final String? thumbUrl; + final String? caption; + const Message( + {required this.messageId, + required this.conversationId, + required this.userId, + required this.category, + this.content, + this.mediaUrl, + this.mediaMimeType, + this.mediaSize, + this.mediaDuration, + this.mediaWidth, + this.mediaHeight, + this.mediaHash, + this.thumbImage, + this.mediaKey, + this.mediaDigest, + this.mediaStatus, + required this.status, + required this.createdAt, + this.action, + this.participantId, + this.snapshotId, + this.hyperlink, + this.name, + this.albumId, + this.stickerId, + this.sharedUserId, + this.mediaWaveform, + this.quoteMessageId, + this.quoteContent, + this.thumbUrl, + this.caption}); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['message_id'] = Variable(messageId); + map['conversation_id'] = Variable(conversationId); + map['user_id'] = Variable(userId); + map['category'] = Variable(category); + if (!nullToAbsent || content != null) { + map['content'] = Variable(content); + } + if (!nullToAbsent || mediaUrl != null) { + map['media_url'] = Variable(mediaUrl); + } + if (!nullToAbsent || mediaMimeType != null) { + map['media_mime_type'] = Variable(mediaMimeType); + } + if (!nullToAbsent || mediaSize != null) { + map['media_size'] = Variable(mediaSize); + } + if (!nullToAbsent || mediaDuration != null) { + map['media_duration'] = Variable(mediaDuration); + } + if (!nullToAbsent || mediaWidth != null) { + map['media_width'] = Variable(mediaWidth); + } + if (!nullToAbsent || mediaHeight != null) { + map['media_height'] = Variable(mediaHeight); + } + if (!nullToAbsent || mediaHash != null) { + map['media_hash'] = Variable(mediaHash); + } + if (!nullToAbsent || thumbImage != null) { + map['thumb_image'] = Variable(thumbImage); + } + if (!nullToAbsent || mediaKey != null) { + map['media_key'] = Variable(mediaKey); + } + if (!nullToAbsent || mediaDigest != null) { + map['media_digest'] = Variable(mediaDigest); + } + if (!nullToAbsent || mediaStatus != null) { + final converter = Messages.$convertermediaStatus; + map['media_status'] = Variable(converter.toSql(mediaStatus)); + } + { + final converter = Messages.$converterstatus; + map['status'] = Variable(converter.toSql(status)); + } + { + final converter = Messages.$convertercreatedAt; + map['created_at'] = Variable(converter.toSql(createdAt)); + } + if (!nullToAbsent || action != null) { + map['action'] = Variable(action); + } + if (!nullToAbsent || participantId != null) { + map['participant_id'] = Variable(participantId); + } + if (!nullToAbsent || snapshotId != null) { + map['snapshot_id'] = Variable(snapshotId); + } + if (!nullToAbsent || hyperlink != null) { + map['hyperlink'] = Variable(hyperlink); + } + if (!nullToAbsent || name != null) { + map['name'] = Variable(name); + } + if (!nullToAbsent || albumId != null) { + map['album_id'] = Variable(albumId); + } + if (!nullToAbsent || stickerId != null) { + map['sticker_id'] = Variable(stickerId); + } + if (!nullToAbsent || sharedUserId != null) { + map['shared_user_id'] = Variable(sharedUserId); + } + if (!nullToAbsent || mediaWaveform != null) { + map['media_waveform'] = Variable(mediaWaveform); + } + if (!nullToAbsent || quoteMessageId != null) { + map['quote_message_id'] = Variable(quoteMessageId); + } + if (!nullToAbsent || quoteContent != null) { + map['quote_content'] = Variable(quoteContent); + } + if (!nullToAbsent || thumbUrl != null) { + map['thumb_url'] = Variable(thumbUrl); + } + if (!nullToAbsent || caption != null) { + map['caption'] = Variable(caption); + } + return map; } - AppsCompanion toCompanion(bool nullToAbsent) { - return AppsCompanion( - appId: Value(appId), - appNumber: Value(appNumber), - homeUri: Value(homeUri), - redirectUri: Value(redirectUri), - name: Value(name), - iconUrl: Value(iconUrl), - category: category == null && nullToAbsent + MessagesCompanion toCompanion(bool nullToAbsent) { + return MessagesCompanion( + messageId: Value(messageId), + conversationId: Value(conversationId), + userId: Value(userId), + category: Value(category), + content: content == null && nullToAbsent ? const Value.absent() - : Value(category), - description: Value(description), - appSecret: Value(appSecret), - capabilities: capabilities == null && nullToAbsent + : Value(content), + mediaUrl: mediaUrl == null && nullToAbsent ? const Value.absent() - : Value(capabilities), - creatorId: Value(creatorId), - resourcePatterns: resourcePatterns == null && nullToAbsent + : Value(mediaUrl), + mediaMimeType: mediaMimeType == null && nullToAbsent ? const Value.absent() - : Value(resourcePatterns), - updatedAt: updatedAt == null && nullToAbsent + : Value(mediaMimeType), + mediaSize: mediaSize == null && nullToAbsent ? const Value.absent() - : Value(updatedAt), + : Value(mediaSize), + mediaDuration: mediaDuration == null && nullToAbsent + ? const Value.absent() + : Value(mediaDuration), + mediaWidth: mediaWidth == null && nullToAbsent + ? const Value.absent() + : Value(mediaWidth), + mediaHeight: mediaHeight == null && nullToAbsent + ? const Value.absent() + : Value(mediaHeight), + mediaHash: mediaHash == null && nullToAbsent + ? const Value.absent() + : Value(mediaHash), + thumbImage: thumbImage == null && nullToAbsent + ? const Value.absent() + : Value(thumbImage), + mediaKey: mediaKey == null && nullToAbsent + ? const Value.absent() + : Value(mediaKey), + mediaDigest: mediaDigest == null && nullToAbsent + ? const Value.absent() + : Value(mediaDigest), + mediaStatus: mediaStatus == null && nullToAbsent + ? const Value.absent() + : Value(mediaStatus), + status: Value(status), + createdAt: Value(createdAt), + action: + action == null && nullToAbsent ? const Value.absent() : Value(action), + participantId: participantId == null && nullToAbsent + ? const Value.absent() + : Value(participantId), + snapshotId: snapshotId == null && nullToAbsent + ? const Value.absent() + : Value(snapshotId), + hyperlink: hyperlink == null && nullToAbsent + ? const Value.absent() + : Value(hyperlink), + name: name == null && nullToAbsent ? const Value.absent() : Value(name), + albumId: albumId == null && nullToAbsent + ? const Value.absent() + : Value(albumId), + stickerId: stickerId == null && nullToAbsent + ? const Value.absent() + : Value(stickerId), + sharedUserId: sharedUserId == null && nullToAbsent + ? const Value.absent() + : Value(sharedUserId), + mediaWaveform: mediaWaveform == null && nullToAbsent + ? const Value.absent() + : Value(mediaWaveform), + quoteMessageId: quoteMessageId == null && nullToAbsent + ? const Value.absent() + : Value(quoteMessageId), + quoteContent: quoteContent == null && nullToAbsent + ? const Value.absent() + : Value(quoteContent), + thumbUrl: thumbUrl == null && nullToAbsent + ? const Value.absent() + : Value(thumbUrl), + caption: caption == null && nullToAbsent + ? const Value.absent() + : Value(caption), ); } - factory App.fromJson(Map json, + factory Message.fromJson(Map json, {ValueSerializer? serializer}) { serializer ??= driftRuntimeOptions.defaultSerializer; - return App( - appId: serializer.fromJson(json['app_id']), - appNumber: serializer.fromJson(json['app_number']), - homeUri: serializer.fromJson(json['home_uri']), - redirectUri: serializer.fromJson(json['redirect_uri']), - name: serializer.fromJson(json['name']), - iconUrl: serializer.fromJson(json['icon_url']), - category: serializer.fromJson(json['category']), - description: serializer.fromJson(json['description']), - appSecret: serializer.fromJson(json['app_secret']), - capabilities: serializer.fromJson(json['capabilities']), - creatorId: serializer.fromJson(json['creator_id']), - resourcePatterns: serializer.fromJson(json['resource_patterns']), - updatedAt: serializer.fromJson(json['updated_at']), + return Message( + messageId: serializer.fromJson(json['message_id']), + conversationId: serializer.fromJson(json['conversation_id']), + userId: serializer.fromJson(json['user_id']), + category: serializer.fromJson(json['category']), + content: serializer.fromJson(json['content']), + mediaUrl: serializer.fromJson(json['media_url']), + mediaMimeType: serializer.fromJson(json['media_mime_type']), + mediaSize: serializer.fromJson(json['media_size']), + mediaDuration: serializer.fromJson(json['media_duration']), + mediaWidth: serializer.fromJson(json['media_width']), + mediaHeight: serializer.fromJson(json['media_height']), + mediaHash: serializer.fromJson(json['media_hash']), + thumbImage: serializer.fromJson(json['thumb_image']), + mediaKey: serializer.fromJson(json['media_key']), + mediaDigest: serializer.fromJson(json['media_digest']), + mediaStatus: serializer.fromJson(json['media_status']), + status: serializer.fromJson(json['status']), + createdAt: serializer.fromJson(json['created_at']), + action: serializer.fromJson(json['action']), + participantId: serializer.fromJson(json['participant_id']), + snapshotId: serializer.fromJson(json['snapshot_id']), + hyperlink: serializer.fromJson(json['hyperlink']), + name: serializer.fromJson(json['name']), + albumId: serializer.fromJson(json['album_id']), + stickerId: serializer.fromJson(json['sticker_id']), + sharedUserId: serializer.fromJson(json['shared_user_id']), + mediaWaveform: serializer.fromJson(json['media_waveform']), + quoteMessageId: serializer.fromJson(json['quote_message_id']), + quoteContent: serializer.fromJson(json['quote_content']), + thumbUrl: serializer.fromJson(json['thumb_url']), + caption: serializer.fromJson(json['caption']), ); } @override Map toJson({ValueSerializer? serializer}) { serializer ??= driftRuntimeOptions.defaultSerializer; return { - 'app_id': serializer.toJson(appId), - 'app_number': serializer.toJson(appNumber), - 'home_uri': serializer.toJson(homeUri), - 'redirect_uri': serializer.toJson(redirectUri), - 'name': serializer.toJson(name), - 'icon_url': serializer.toJson(iconUrl), - 'category': serializer.toJson(category), - 'description': serializer.toJson(description), - 'app_secret': serializer.toJson(appSecret), - 'capabilities': serializer.toJson(capabilities), - 'creator_id': serializer.toJson(creatorId), - 'resource_patterns': serializer.toJson(resourcePatterns), - 'updated_at': serializer.toJson(updatedAt), + 'message_id': serializer.toJson(messageId), + 'conversation_id': serializer.toJson(conversationId), + 'user_id': serializer.toJson(userId), + 'category': serializer.toJson(category), + 'content': serializer.toJson(content), + 'media_url': serializer.toJson(mediaUrl), + 'media_mime_type': serializer.toJson(mediaMimeType), + 'media_size': serializer.toJson(mediaSize), + 'media_duration': serializer.toJson(mediaDuration), + 'media_width': serializer.toJson(mediaWidth), + 'media_height': serializer.toJson(mediaHeight), + 'media_hash': serializer.toJson(mediaHash), + 'thumb_image': serializer.toJson(thumbImage), + 'media_key': serializer.toJson(mediaKey), + 'media_digest': serializer.toJson(mediaDigest), + 'media_status': serializer.toJson(mediaStatus), + 'status': serializer.toJson(status), + 'created_at': serializer.toJson(createdAt), + 'action': serializer.toJson(action), + 'participant_id': serializer.toJson(participantId), + 'snapshot_id': serializer.toJson(snapshotId), + 'hyperlink': serializer.toJson(hyperlink), + 'name': serializer.toJson(name), + 'album_id': serializer.toJson(albumId), + 'sticker_id': serializer.toJson(stickerId), + 'shared_user_id': serializer.toJson(sharedUserId), + 'media_waveform': serializer.toJson(mediaWaveform), + 'quote_message_id': serializer.toJson(quoteMessageId), + 'quote_content': serializer.toJson(quoteContent), + 'thumb_url': serializer.toJson(thumbUrl), + 'caption': serializer.toJson(caption), }; } - App copyWith( - {String? appId, - String? appNumber, - String? homeUri, - String? redirectUri, - String? name, - String? iconUrl, - Value category = const Value.absent(), - String? description, - String? appSecret, - Value capabilities = const Value.absent(), - String? creatorId, - Value resourcePatterns = const Value.absent(), - Value updatedAt = const Value.absent()}) => - App( - appId: appId ?? this.appId, - appNumber: appNumber ?? this.appNumber, - homeUri: homeUri ?? this.homeUri, - redirectUri: redirectUri ?? this.redirectUri, - name: name ?? this.name, - iconUrl: iconUrl ?? this.iconUrl, - category: category.present ? category.value : this.category, - description: description ?? this.description, - appSecret: appSecret ?? this.appSecret, - capabilities: - capabilities.present ? capabilities.value : this.capabilities, - creatorId: creatorId ?? this.creatorId, - resourcePatterns: resourcePatterns.present - ? resourcePatterns.value - : this.resourcePatterns, - updatedAt: updatedAt.present ? updatedAt.value : this.updatedAt, + Message copyWith( + {String? messageId, + String? conversationId, + String? userId, + String? category, + Value content = const Value.absent(), + Value mediaUrl = const Value.absent(), + Value mediaMimeType = const Value.absent(), + Value mediaSize = const Value.absent(), + Value mediaDuration = const Value.absent(), + Value mediaWidth = const Value.absent(), + Value mediaHeight = const Value.absent(), + Value mediaHash = const Value.absent(), + Value thumbImage = const Value.absent(), + Value mediaKey = const Value.absent(), + Value mediaDigest = const Value.absent(), + Value mediaStatus = const Value.absent(), + MessageStatus? status, + DateTime? createdAt, + Value action = const Value.absent(), + Value participantId = const Value.absent(), + Value snapshotId = const Value.absent(), + Value hyperlink = const Value.absent(), + Value name = const Value.absent(), + Value albumId = const Value.absent(), + Value stickerId = const Value.absent(), + Value sharedUserId = const Value.absent(), + Value mediaWaveform = const Value.absent(), + Value quoteMessageId = const Value.absent(), + Value quoteContent = const Value.absent(), + Value thumbUrl = const Value.absent(), + Value caption = const Value.absent()}) => + Message( + messageId: messageId ?? this.messageId, + conversationId: conversationId ?? this.conversationId, + userId: userId ?? this.userId, + category: category ?? this.category, + content: content.present ? content.value : this.content, + mediaUrl: mediaUrl.present ? mediaUrl.value : this.mediaUrl, + mediaMimeType: + mediaMimeType.present ? mediaMimeType.value : this.mediaMimeType, + mediaSize: mediaSize.present ? mediaSize.value : this.mediaSize, + mediaDuration: + mediaDuration.present ? mediaDuration.value : this.mediaDuration, + mediaWidth: mediaWidth.present ? mediaWidth.value : this.mediaWidth, + mediaHeight: mediaHeight.present ? mediaHeight.value : this.mediaHeight, + mediaHash: mediaHash.present ? mediaHash.value : this.mediaHash, + thumbImage: thumbImage.present ? thumbImage.value : this.thumbImage, + mediaKey: mediaKey.present ? mediaKey.value : this.mediaKey, + mediaDigest: mediaDigest.present ? mediaDigest.value : this.mediaDigest, + mediaStatus: mediaStatus.present ? mediaStatus.value : this.mediaStatus, + status: status ?? this.status, + createdAt: createdAt ?? this.createdAt, + action: action.present ? action.value : this.action, + participantId: + participantId.present ? participantId.value : this.participantId, + snapshotId: snapshotId.present ? snapshotId.value : this.snapshotId, + hyperlink: hyperlink.present ? hyperlink.value : this.hyperlink, + name: name.present ? name.value : this.name, + albumId: albumId.present ? albumId.value : this.albumId, + stickerId: stickerId.present ? stickerId.value : this.stickerId, + sharedUserId: + sharedUserId.present ? sharedUserId.value : this.sharedUserId, + mediaWaveform: + mediaWaveform.present ? mediaWaveform.value : this.mediaWaveform, + quoteMessageId: + quoteMessageId.present ? quoteMessageId.value : this.quoteMessageId, + quoteContent: + quoteContent.present ? quoteContent.value : this.quoteContent, + thumbUrl: thumbUrl.present ? thumbUrl.value : this.thumbUrl, + caption: caption.present ? caption.value : this.caption, ); @override String toString() { - return (StringBuffer('App(') - ..write('appId: $appId, ') - ..write('appNumber: $appNumber, ') - ..write('homeUri: $homeUri, ') - ..write('redirectUri: $redirectUri, ') - ..write('name: $name, ') - ..write('iconUrl: $iconUrl, ') + return (StringBuffer('Message(') + ..write('messageId: $messageId, ') + ..write('conversationId: $conversationId, ') + ..write('userId: $userId, ') ..write('category: $category, ') - ..write('description: $description, ') - ..write('appSecret: $appSecret, ') - ..write('capabilities: $capabilities, ') - ..write('creatorId: $creatorId, ') - ..write('resourcePatterns: $resourcePatterns, ') - ..write('updatedAt: $updatedAt') + ..write('content: $content, ') + ..write('mediaUrl: $mediaUrl, ') + ..write('mediaMimeType: $mediaMimeType, ') + ..write('mediaSize: $mediaSize, ') + ..write('mediaDuration: $mediaDuration, ') + ..write('mediaWidth: $mediaWidth, ') + ..write('mediaHeight: $mediaHeight, ') + ..write('mediaHash: $mediaHash, ') + ..write('thumbImage: $thumbImage, ') + ..write('mediaKey: $mediaKey, ') + ..write('mediaDigest: $mediaDigest, ') + ..write('mediaStatus: $mediaStatus, ') + ..write('status: $status, ') + ..write('createdAt: $createdAt, ') + ..write('action: $action, ') + ..write('participantId: $participantId, ') + ..write('snapshotId: $snapshotId, ') + ..write('hyperlink: $hyperlink, ') + ..write('name: $name, ') + ..write('albumId: $albumId, ') + ..write('stickerId: $stickerId, ') + ..write('sharedUserId: $sharedUserId, ') + ..write('mediaWaveform: $mediaWaveform, ') + ..write('quoteMessageId: $quoteMessageId, ') + ..write('quoteContent: $quoteContent, ') + ..write('thumbUrl: $thumbUrl, ') + ..write('caption: $caption') ..write(')')) .toString(); } @override - int get hashCode => Object.hash( - appId, - appNumber, - homeUri, - redirectUri, - name, - iconUrl, - category, - description, - appSecret, - capabilities, - creatorId, - resourcePatterns, - updatedAt); - @override - bool operator ==(Object other) => - identical(this, other) || - (other is App && - other.appId == this.appId && - other.appNumber == this.appNumber && - other.homeUri == this.homeUri && - other.redirectUri == this.redirectUri && - other.name == this.name && - other.iconUrl == this.iconUrl && + int get hashCode => Object.hashAll([ + messageId, + conversationId, + userId, + category, + content, + mediaUrl, + mediaMimeType, + mediaSize, + mediaDuration, + mediaWidth, + mediaHeight, + mediaHash, + thumbImage, + mediaKey, + mediaDigest, + mediaStatus, + status, + createdAt, + action, + participantId, + snapshotId, + hyperlink, + name, + albumId, + stickerId, + sharedUserId, + mediaWaveform, + quoteMessageId, + quoteContent, + thumbUrl, + caption + ]); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is Message && + other.messageId == this.messageId && + other.conversationId == this.conversationId && + other.userId == this.userId && other.category == this.category && - other.description == this.description && - other.appSecret == this.appSecret && - other.capabilities == this.capabilities && - other.creatorId == this.creatorId && - other.resourcePatterns == this.resourcePatterns && - other.updatedAt == this.updatedAt); + other.content == this.content && + other.mediaUrl == this.mediaUrl && + other.mediaMimeType == this.mediaMimeType && + other.mediaSize == this.mediaSize && + other.mediaDuration == this.mediaDuration && + other.mediaWidth == this.mediaWidth && + other.mediaHeight == this.mediaHeight && + other.mediaHash == this.mediaHash && + other.thumbImage == this.thumbImage && + other.mediaKey == this.mediaKey && + other.mediaDigest == this.mediaDigest && + other.mediaStatus == this.mediaStatus && + other.status == this.status && + other.createdAt == this.createdAt && + other.action == this.action && + other.participantId == this.participantId && + other.snapshotId == this.snapshotId && + other.hyperlink == this.hyperlink && + other.name == this.name && + other.albumId == this.albumId && + other.stickerId == this.stickerId && + other.sharedUserId == this.sharedUserId && + other.mediaWaveform == this.mediaWaveform && + other.quoteMessageId == this.quoteMessageId && + other.quoteContent == this.quoteContent && + other.thumbUrl == this.thumbUrl && + other.caption == this.caption); } -class AppsCompanion extends UpdateCompanion { - final Value appId; - final Value appNumber; - final Value homeUri; - final Value redirectUri; - final Value name; - final Value iconUrl; - final Value category; - final Value description; - final Value appSecret; - final Value capabilities; - final Value creatorId; - final Value resourcePatterns; - final Value updatedAt; +class MessagesCompanion extends UpdateCompanion { + final Value messageId; + final Value conversationId; + final Value userId; + final Value category; + final Value content; + final Value mediaUrl; + final Value mediaMimeType; + final Value mediaSize; + final Value mediaDuration; + final Value mediaWidth; + final Value mediaHeight; + final Value mediaHash; + final Value thumbImage; + final Value mediaKey; + final Value mediaDigest; + final Value mediaStatus; + final Value status; + final Value createdAt; + final Value action; + final Value participantId; + final Value snapshotId; + final Value hyperlink; + final Value name; + final Value albumId; + final Value stickerId; + final Value sharedUserId; + final Value mediaWaveform; + final Value quoteMessageId; + final Value quoteContent; + final Value thumbUrl; + final Value caption; final Value rowid; - const AppsCompanion({ - this.appId = const Value.absent(), - this.appNumber = const Value.absent(), - this.homeUri = const Value.absent(), - this.redirectUri = const Value.absent(), - this.name = const Value.absent(), - this.iconUrl = const Value.absent(), + const MessagesCompanion({ + this.messageId = const Value.absent(), + this.conversationId = const Value.absent(), + this.userId = const Value.absent(), this.category = const Value.absent(), - this.description = const Value.absent(), - this.appSecret = const Value.absent(), - this.capabilities = const Value.absent(), - this.creatorId = const Value.absent(), - this.resourcePatterns = const Value.absent(), - this.updatedAt = const Value.absent(), + this.content = const Value.absent(), + this.mediaUrl = const Value.absent(), + this.mediaMimeType = const Value.absent(), + this.mediaSize = const Value.absent(), + this.mediaDuration = const Value.absent(), + this.mediaWidth = const Value.absent(), + this.mediaHeight = const Value.absent(), + this.mediaHash = const Value.absent(), + this.thumbImage = const Value.absent(), + this.mediaKey = const Value.absent(), + this.mediaDigest = const Value.absent(), + this.mediaStatus = const Value.absent(), + this.status = const Value.absent(), + this.createdAt = const Value.absent(), + this.action = const Value.absent(), + this.participantId = const Value.absent(), + this.snapshotId = const Value.absent(), + this.hyperlink = const Value.absent(), + this.name = const Value.absent(), + this.albumId = const Value.absent(), + this.stickerId = const Value.absent(), + this.sharedUserId = const Value.absent(), + this.mediaWaveform = const Value.absent(), + this.quoteMessageId = const Value.absent(), + this.quoteContent = const Value.absent(), + this.thumbUrl = const Value.absent(), + this.caption = const Value.absent(), this.rowid = const Value.absent(), }); - AppsCompanion.insert({ - required String appId, - required String appNumber, - required String homeUri, - required String redirectUri, - required String name, - required String iconUrl, - this.category = const Value.absent(), - required String description, - required String appSecret, - this.capabilities = const Value.absent(), - required String creatorId, - this.resourcePatterns = const Value.absent(), - this.updatedAt = const Value.absent(), + MessagesCompanion.insert({ + required String messageId, + required String conversationId, + required String userId, + required String category, + this.content = const Value.absent(), + this.mediaUrl = const Value.absent(), + this.mediaMimeType = const Value.absent(), + this.mediaSize = const Value.absent(), + this.mediaDuration = const Value.absent(), + this.mediaWidth = const Value.absent(), + this.mediaHeight = const Value.absent(), + this.mediaHash = const Value.absent(), + this.thumbImage = const Value.absent(), + this.mediaKey = const Value.absent(), + this.mediaDigest = const Value.absent(), + this.mediaStatus = const Value.absent(), + required MessageStatus status, + required DateTime createdAt, + this.action = const Value.absent(), + this.participantId = const Value.absent(), + this.snapshotId = const Value.absent(), + this.hyperlink = const Value.absent(), + this.name = const Value.absent(), + this.albumId = const Value.absent(), + this.stickerId = const Value.absent(), + this.sharedUserId = const Value.absent(), + this.mediaWaveform = const Value.absent(), + this.quoteMessageId = const Value.absent(), + this.quoteContent = const Value.absent(), + this.thumbUrl = const Value.absent(), + this.caption = const Value.absent(), this.rowid = const Value.absent(), - }) : appId = Value(appId), - appNumber = Value(appNumber), - homeUri = Value(homeUri), - redirectUri = Value(redirectUri), - name = Value(name), - iconUrl = Value(iconUrl), - description = Value(description), - appSecret = Value(appSecret), - creatorId = Value(creatorId); - static Insertable custom({ - Expression? appId, - Expression? appNumber, - Expression? homeUri, - Expression? redirectUri, - Expression? name, - Expression? iconUrl, + }) : messageId = Value(messageId), + conversationId = Value(conversationId), + userId = Value(userId), + category = Value(category), + status = Value(status), + createdAt = Value(createdAt); + static Insertable custom({ + Expression? messageId, + Expression? conversationId, + Expression? userId, Expression? category, - Expression? description, - Expression? appSecret, - Expression? capabilities, - Expression? creatorId, - Expression? resourcePatterns, - Expression? updatedAt, - Expression? rowid, - }) { - return RawValuesInsertable({ - if (appId != null) 'app_id': appId, - if (appNumber != null) 'app_number': appNumber, - if (homeUri != null) 'home_uri': homeUri, - if (redirectUri != null) 'redirect_uri': redirectUri, - if (name != null) 'name': name, - if (iconUrl != null) 'icon_url': iconUrl, - if (category != null) 'category': category, - if (description != null) 'description': description, - if (appSecret != null) 'app_secret': appSecret, - if (capabilities != null) 'capabilities': capabilities, - if (creatorId != null) 'creator_id': creatorId, - if (resourcePatterns != null) 'resource_patterns': resourcePatterns, - if (updatedAt != null) 'updated_at': updatedAt, + Expression? content, + Expression? mediaUrl, + Expression? mediaMimeType, + Expression? mediaSize, + Expression? mediaDuration, + Expression? mediaWidth, + Expression? mediaHeight, + Expression? mediaHash, + Expression? thumbImage, + Expression? mediaKey, + Expression? mediaDigest, + Expression? mediaStatus, + Expression? status, + Expression? createdAt, + Expression? action, + Expression? participantId, + Expression? snapshotId, + Expression? hyperlink, + Expression? name, + Expression? albumId, + Expression? stickerId, + Expression? sharedUserId, + Expression? mediaWaveform, + Expression? quoteMessageId, + Expression? quoteContent, + Expression? thumbUrl, + Expression? caption, + Expression? rowid, + }) { + return RawValuesInsertable({ + if (messageId != null) 'message_id': messageId, + if (conversationId != null) 'conversation_id': conversationId, + if (userId != null) 'user_id': userId, + if (category != null) 'category': category, + if (content != null) 'content': content, + if (mediaUrl != null) 'media_url': mediaUrl, + if (mediaMimeType != null) 'media_mime_type': mediaMimeType, + if (mediaSize != null) 'media_size': mediaSize, + if (mediaDuration != null) 'media_duration': mediaDuration, + if (mediaWidth != null) 'media_width': mediaWidth, + if (mediaHeight != null) 'media_height': mediaHeight, + if (mediaHash != null) 'media_hash': mediaHash, + if (thumbImage != null) 'thumb_image': thumbImage, + if (mediaKey != null) 'media_key': mediaKey, + if (mediaDigest != null) 'media_digest': mediaDigest, + if (mediaStatus != null) 'media_status': mediaStatus, + if (status != null) 'status': status, + if (createdAt != null) 'created_at': createdAt, + if (action != null) 'action': action, + if (participantId != null) 'participant_id': participantId, + if (snapshotId != null) 'snapshot_id': snapshotId, + if (hyperlink != null) 'hyperlink': hyperlink, + if (name != null) 'name': name, + if (albumId != null) 'album_id': albumId, + if (stickerId != null) 'sticker_id': stickerId, + if (sharedUserId != null) 'shared_user_id': sharedUserId, + if (mediaWaveform != null) 'media_waveform': mediaWaveform, + if (quoteMessageId != null) 'quote_message_id': quoteMessageId, + if (quoteContent != null) 'quote_content': quoteContent, + if (thumbUrl != null) 'thumb_url': thumbUrl, + if (caption != null) 'caption': caption, if (rowid != null) 'rowid': rowid, }); } - AppsCompanion copyWith( - {Value? appId, - Value? appNumber, - Value? homeUri, - Value? redirectUri, - Value? name, - Value? iconUrl, - Value? category, - Value? description, - Value? appSecret, - Value? capabilities, - Value? creatorId, - Value? resourcePatterns, - Value? updatedAt, + MessagesCompanion copyWith( + {Value? messageId, + Value? conversationId, + Value? userId, + Value? category, + Value? content, + Value? mediaUrl, + Value? mediaMimeType, + Value? mediaSize, + Value? mediaDuration, + Value? mediaWidth, + Value? mediaHeight, + Value? mediaHash, + Value? thumbImage, + Value? mediaKey, + Value? mediaDigest, + Value? mediaStatus, + Value? status, + Value? createdAt, + Value? action, + Value? participantId, + Value? snapshotId, + Value? hyperlink, + Value? name, + Value? albumId, + Value? stickerId, + Value? sharedUserId, + Value? mediaWaveform, + Value? quoteMessageId, + Value? quoteContent, + Value? thumbUrl, + Value? caption, Value? rowid}) { - return AppsCompanion( - appId: appId ?? this.appId, - appNumber: appNumber ?? this.appNumber, - homeUri: homeUri ?? this.homeUri, - redirectUri: redirectUri ?? this.redirectUri, - name: name ?? this.name, - iconUrl: iconUrl ?? this.iconUrl, + return MessagesCompanion( + messageId: messageId ?? this.messageId, + conversationId: conversationId ?? this.conversationId, + userId: userId ?? this.userId, category: category ?? this.category, - description: description ?? this.description, - appSecret: appSecret ?? this.appSecret, - capabilities: capabilities ?? this.capabilities, - creatorId: creatorId ?? this.creatorId, - resourcePatterns: resourcePatterns ?? this.resourcePatterns, - updatedAt: updatedAt ?? this.updatedAt, + content: content ?? this.content, + mediaUrl: mediaUrl ?? this.mediaUrl, + mediaMimeType: mediaMimeType ?? this.mediaMimeType, + mediaSize: mediaSize ?? this.mediaSize, + mediaDuration: mediaDuration ?? this.mediaDuration, + mediaWidth: mediaWidth ?? this.mediaWidth, + mediaHeight: mediaHeight ?? this.mediaHeight, + mediaHash: mediaHash ?? this.mediaHash, + thumbImage: thumbImage ?? this.thumbImage, + mediaKey: mediaKey ?? this.mediaKey, + mediaDigest: mediaDigest ?? this.mediaDigest, + mediaStatus: mediaStatus ?? this.mediaStatus, + status: status ?? this.status, + createdAt: createdAt ?? this.createdAt, + action: action ?? this.action, + participantId: participantId ?? this.participantId, + snapshotId: snapshotId ?? this.snapshotId, + hyperlink: hyperlink ?? this.hyperlink, + name: name ?? this.name, + albumId: albumId ?? this.albumId, + stickerId: stickerId ?? this.stickerId, + sharedUserId: sharedUserId ?? this.sharedUserId, + mediaWaveform: mediaWaveform ?? this.mediaWaveform, + quoteMessageId: quoteMessageId ?? this.quoteMessageId, + quoteContent: quoteContent ?? this.quoteContent, + thumbUrl: thumbUrl ?? this.thumbUrl, + caption: caption ?? this.caption, rowid: rowid ?? this.rowid, ); } @@ -813,253 +2146,103 @@ class AppsCompanion extends UpdateCompanion { @override Map toColumns(bool nullToAbsent) { final map = {}; - if (appId.present) { - map['app_id'] = Variable(appId.value); + if (messageId.present) { + map['message_id'] = Variable(messageId.value); } - if (appNumber.present) { - map['app_number'] = Variable(appNumber.value); + if (conversationId.present) { + map['conversation_id'] = Variable(conversationId.value); } - if (homeUri.present) { - map['home_uri'] = Variable(homeUri.value); + if (userId.present) { + map['user_id'] = Variable(userId.value); } - if (redirectUri.present) { - map['redirect_uri'] = Variable(redirectUri.value); + if (category.present) { + map['category'] = Variable(category.value); } - if (name.present) { - map['name'] = Variable(name.value); + if (content.present) { + map['content'] = Variable(content.value); } - if (iconUrl.present) { - map['icon_url'] = Variable(iconUrl.value); + if (mediaUrl.present) { + map['media_url'] = Variable(mediaUrl.value); } - if (category.present) { - map['category'] = Variable(category.value); + if (mediaMimeType.present) { + map['media_mime_type'] = Variable(mediaMimeType.value); } - if (description.present) { - map['description'] = Variable(description.value); + if (mediaSize.present) { + map['media_size'] = Variable(mediaSize.value); } - if (appSecret.present) { - map['app_secret'] = Variable(appSecret.value); + if (mediaDuration.present) { + map['media_duration'] = Variable(mediaDuration.value); } - if (capabilities.present) { - map['capabilities'] = Variable(capabilities.value); + if (mediaWidth.present) { + map['media_width'] = Variable(mediaWidth.value); } - if (creatorId.present) { - map['creator_id'] = Variable(creatorId.value); + if (mediaHeight.present) { + map['media_height'] = Variable(mediaHeight.value); } - if (resourcePatterns.present) { - map['resource_patterns'] = Variable(resourcePatterns.value); + if (mediaHash.present) { + map['media_hash'] = Variable(mediaHash.value); } - if (updatedAt.present) { - final converter = Apps.$converterupdatedAtn; - map['updated_at'] = Variable(converter.toSql(updatedAt.value)); + if (thumbImage.present) { + map['thumb_image'] = Variable(thumbImage.value); } - if (rowid.present) { - map['rowid'] = Variable(rowid.value); + if (mediaKey.present) { + map['media_key'] = Variable(mediaKey.value); } - return map; - } - - @override - String toString() { - return (StringBuffer('AppsCompanion(') - ..write('appId: $appId, ') - ..write('appNumber: $appNumber, ') - ..write('homeUri: $homeUri, ') - ..write('redirectUri: $redirectUri, ') - ..write('name: $name, ') - ..write('iconUrl: $iconUrl, ') - ..write('category: $category, ') - ..write('description: $description, ') - ..write('appSecret: $appSecret, ') - ..write('capabilities: $capabilities, ') - ..write('creatorId: $creatorId, ') - ..write('resourcePatterns: $resourcePatterns, ') - ..write('updatedAt: $updatedAt, ') - ..write('rowid: $rowid') - ..write(')')) - .toString(); - } -} - -class StickerRelationships extends Table - with TableInfo { - @override - final GeneratedDatabase attachedDatabase; - final String? _alias; - StickerRelationships(this.attachedDatabase, [this._alias]); - static const VerificationMeta _albumIdMeta = - const VerificationMeta('albumId'); - late final GeneratedColumn albumId = GeneratedColumn( - 'album_id', aliasedName, false, - type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL'); - static const VerificationMeta _stickerIdMeta = - const VerificationMeta('stickerId'); - late final GeneratedColumn stickerId = GeneratedColumn( - 'sticker_id', aliasedName, false, - type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL'); - @override - List get $columns => [albumId, stickerId]; - @override - String get aliasedName => _alias ?? 'sticker_relationships'; - @override - String get actualTableName => 'sticker_relationships'; - @override - VerificationContext validateIntegrity( - Insertable instance, - {bool isInserting = false}) { - final context = VerificationContext(); - final data = instance.toColumns(true); - if (data.containsKey('album_id')) { - context.handle(_albumIdMeta, - albumId.isAcceptableOrUnknown(data['album_id']!, _albumIdMeta)); - } else if (isInserting) { - context.missing(_albumIdMeta); + if (mediaDigest.present) { + map['media_digest'] = Variable(mediaDigest.value); } - if (data.containsKey('sticker_id')) { - context.handle(_stickerIdMeta, - stickerId.isAcceptableOrUnknown(data['sticker_id']!, _stickerIdMeta)); - } else if (isInserting) { - context.missing(_stickerIdMeta); + if (mediaStatus.present) { + final converter = Messages.$convertermediaStatus; + map['media_status'] = + Variable(converter.toSql(mediaStatus.value)); + } + if (status.present) { + final converter = Messages.$converterstatus; + map['status'] = Variable(converter.toSql(status.value)); + } + if (createdAt.present) { + final converter = Messages.$convertercreatedAt; + map['created_at'] = Variable(converter.toSql(createdAt.value)); + } + if (action.present) { + map['action'] = Variable(action.value); + } + if (participantId.present) { + map['participant_id'] = Variable(participantId.value); + } + if (snapshotId.present) { + map['snapshot_id'] = Variable(snapshotId.value); + } + if (hyperlink.present) { + map['hyperlink'] = Variable(hyperlink.value); + } + if (name.present) { + map['name'] = Variable(name.value); } - return context; - } - - @override - Set get $primaryKey => {albumId, stickerId}; - @override - StickerRelationship map(Map data, {String? tablePrefix}) { - final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; - return StickerRelationship( - albumId: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}album_id'])!, - stickerId: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}sticker_id'])!, - ); - } - - @override - StickerRelationships createAlias(String alias) { - return StickerRelationships(attachedDatabase, alias); - } - - @override - List get customConstraints => - const ['PRIMARY KEY(album_id, sticker_id)']; - @override - bool get dontWriteConstraints => true; -} - -class StickerRelationship extends DataClass - implements Insertable { - final String albumId; - final String stickerId; - const StickerRelationship({required this.albumId, required this.stickerId}); - @override - Map toColumns(bool nullToAbsent) { - final map = {}; - map['album_id'] = Variable(albumId); - map['sticker_id'] = Variable(stickerId); - return map; - } - - StickerRelationshipsCompanion toCompanion(bool nullToAbsent) { - return StickerRelationshipsCompanion( - albumId: Value(albumId), - stickerId: Value(stickerId), - ); - } - - factory StickerRelationship.fromJson(Map json, - {ValueSerializer? serializer}) { - serializer ??= driftRuntimeOptions.defaultSerializer; - return StickerRelationship( - albumId: serializer.fromJson(json['album_id']), - stickerId: serializer.fromJson(json['sticker_id']), - ); - } - @override - Map toJson({ValueSerializer? serializer}) { - serializer ??= driftRuntimeOptions.defaultSerializer; - return { - 'album_id': serializer.toJson(albumId), - 'sticker_id': serializer.toJson(stickerId), - }; - } - - StickerRelationship copyWith({String? albumId, String? stickerId}) => - StickerRelationship( - albumId: albumId ?? this.albumId, - stickerId: stickerId ?? this.stickerId, - ); - @override - String toString() { - return (StringBuffer('StickerRelationship(') - ..write('albumId: $albumId, ') - ..write('stickerId: $stickerId') - ..write(')')) - .toString(); - } - - @override - int get hashCode => Object.hash(albumId, stickerId); - @override - bool operator ==(Object other) => - identical(this, other) || - (other is StickerRelationship && - other.albumId == this.albumId && - other.stickerId == this.stickerId); -} - -class StickerRelationshipsCompanion - extends UpdateCompanion { - final Value albumId; - final Value stickerId; - final Value rowid; - const StickerRelationshipsCompanion({ - this.albumId = const Value.absent(), - this.stickerId = const Value.absent(), - this.rowid = const Value.absent(), - }); - StickerRelationshipsCompanion.insert({ - required String albumId, - required String stickerId, - this.rowid = const Value.absent(), - }) : albumId = Value(albumId), - stickerId = Value(stickerId); - static Insertable custom({ - Expression? albumId, - Expression? stickerId, - Expression? rowid, - }) { - return RawValuesInsertable({ - if (albumId != null) 'album_id': albumId, - if (stickerId != null) 'sticker_id': stickerId, - if (rowid != null) 'rowid': rowid, - }); - } - - StickerRelationshipsCompanion copyWith( - {Value? albumId, Value? stickerId, Value? rowid}) { - return StickerRelationshipsCompanion( - albumId: albumId ?? this.albumId, - stickerId: stickerId ?? this.stickerId, - rowid: rowid ?? this.rowid, - ); - } - - @override - Map toColumns(bool nullToAbsent) { - final map = {}; if (albumId.present) { map['album_id'] = Variable(albumId.value); } if (stickerId.present) { map['sticker_id'] = Variable(stickerId.value); } + if (sharedUserId.present) { + map['shared_user_id'] = Variable(sharedUserId.value); + } + if (mediaWaveform.present) { + map['media_waveform'] = Variable(mediaWaveform.value); + } + if (quoteMessageId.present) { + map['quote_message_id'] = Variable(quoteMessageId.value); + } + if (quoteContent.present) { + map['quote_content'] = Variable(quoteContent.value); + } + if (thumbUrl.present) { + map['thumb_url'] = Variable(thumbUrl.value); + } + if (caption.present) { + map['caption'] = Variable(caption.value); + } if (rowid.present) { map['rowid'] = Variable(rowid.value); } @@ -1068,180 +2251,204 @@ class StickerRelationshipsCompanion @override String toString() { - return (StringBuffer('StickerRelationshipsCompanion(') + return (StringBuffer('MessagesCompanion(') + ..write('messageId: $messageId, ') + ..write('conversationId: $conversationId, ') + ..write('userId: $userId, ') + ..write('category: $category, ') + ..write('content: $content, ') + ..write('mediaUrl: $mediaUrl, ') + ..write('mediaMimeType: $mediaMimeType, ') + ..write('mediaSize: $mediaSize, ') + ..write('mediaDuration: $mediaDuration, ') + ..write('mediaWidth: $mediaWidth, ') + ..write('mediaHeight: $mediaHeight, ') + ..write('mediaHash: $mediaHash, ') + ..write('thumbImage: $thumbImage, ') + ..write('mediaKey: $mediaKey, ') + ..write('mediaDigest: $mediaDigest, ') + ..write('mediaStatus: $mediaStatus, ') + ..write('status: $status, ') + ..write('createdAt: $createdAt, ') + ..write('action: $action, ') + ..write('participantId: $participantId, ') + ..write('snapshotId: $snapshotId, ') + ..write('hyperlink: $hyperlink, ') + ..write('name: $name, ') ..write('albumId: $albumId, ') ..write('stickerId: $stickerId, ') + ..write('sharedUserId: $sharedUserId, ') + ..write('mediaWaveform: $mediaWaveform, ') + ..write('quoteMessageId: $quoteMessageId, ') + ..write('quoteContent: $quoteContent, ') + ..write('thumbUrl: $thumbUrl, ') + ..write('caption: $caption, ') ..write('rowid: $rowid') ..write(')')) .toString(); } } -class StickerAlbums extends Table with TableInfo { +class Users extends Table with TableInfo { @override final GeneratedDatabase attachedDatabase; final String? _alias; - StickerAlbums(this.attachedDatabase, [this._alias]); - static const VerificationMeta _albumIdMeta = - const VerificationMeta('albumId'); - late final GeneratedColumn albumId = GeneratedColumn( - 'album_id', aliasedName, false, - type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL'); - static const VerificationMeta _nameMeta = const VerificationMeta('name'); - late final GeneratedColumn name = GeneratedColumn( - 'name', aliasedName, false, + Users(this.attachedDatabase, [this._alias]); + static const VerificationMeta _userIdMeta = const VerificationMeta('userId'); + late final GeneratedColumn userId = GeneratedColumn( + 'user_id', aliasedName, false, type: DriftSqlType.string, requiredDuringInsert: true, $customConstraints: 'NOT NULL'); - static const VerificationMeta _iconUrlMeta = - const VerificationMeta('iconUrl'); - late final GeneratedColumn iconUrl = GeneratedColumn( - 'icon_url', aliasedName, false, + static const VerificationMeta _identityNumberMeta = + const VerificationMeta('identityNumber'); + late final GeneratedColumn identityNumber = GeneratedColumn( + 'identity_number', aliasedName, false, type: DriftSqlType.string, requiredDuringInsert: true, $customConstraints: 'NOT NULL'); - static const VerificationMeta _createdAtMeta = - const VerificationMeta('createdAt'); - late final GeneratedColumnWithTypeConverter createdAt = - GeneratedColumn('created_at', aliasedName, false, - type: DriftSqlType.int, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL') - .withConverter(StickerAlbums.$convertercreatedAt); - static const VerificationMeta _updateAtMeta = - const VerificationMeta('updateAt'); - late final GeneratedColumnWithTypeConverter updateAt = - GeneratedColumn('update_at', aliasedName, false, - type: DriftSqlType.int, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL') - .withConverter(StickerAlbums.$converterupdateAt); - static const VerificationMeta _orderedAtMeta = - const VerificationMeta('orderedAt'); - late final GeneratedColumn orderedAt = GeneratedColumn( - 'ordered_at', aliasedName, false, - type: DriftSqlType.int, - requiredDuringInsert: false, - $customConstraints: 'NOT NULL DEFAULT 0', - defaultValue: const CustomExpression('0')); - static const VerificationMeta _userIdMeta = const VerificationMeta('userId'); - late final GeneratedColumn userId = GeneratedColumn( - 'user_id', aliasedName, false, - type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL'); - static const VerificationMeta _categoryMeta = - const VerificationMeta('category'); - late final GeneratedColumn category = GeneratedColumn( - 'category', aliasedName, false, - type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL'); - static const VerificationMeta _descriptionMeta = - const VerificationMeta('description'); - late final GeneratedColumn description = GeneratedColumn( - 'description', aliasedName, false, + static const VerificationMeta _relationshipMeta = + const VerificationMeta('relationship'); + late final GeneratedColumnWithTypeConverter + relationship = GeneratedColumn('relationship', aliasedName, true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '') + .withConverter(Users.$converterrelationship); + static const VerificationMeta _fullNameMeta = + const VerificationMeta('fullName'); + late final GeneratedColumn fullName = GeneratedColumn( + 'full_name', aliasedName, true, type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL'); - static const VerificationMeta _bannerMeta = const VerificationMeta('banner'); - late final GeneratedColumn banner = GeneratedColumn( - 'banner', aliasedName, true, + requiredDuringInsert: false, + $customConstraints: ''); + static const VerificationMeta _avatarUrlMeta = + const VerificationMeta('avatarUrl'); + late final GeneratedColumn avatarUrl = GeneratedColumn( + 'avatar_url', aliasedName, true, type: DriftSqlType.string, requiredDuringInsert: false, $customConstraints: ''); - static const VerificationMeta _addedMeta = const VerificationMeta('added'); - late final GeneratedColumn added = GeneratedColumn( - 'added', aliasedName, true, - type: DriftSqlType.bool, + static const VerificationMeta _phoneMeta = const VerificationMeta('phone'); + late final GeneratedColumn phone = GeneratedColumn( + 'phone', aliasedName, true, + type: DriftSqlType.string, requiredDuringInsert: false, - $customConstraints: 'DEFAULT FALSE', - defaultValue: const CustomExpression('FALSE')); + $customConstraints: ''); static const VerificationMeta _isVerifiedMeta = const VerificationMeta('isVerified'); late final GeneratedColumn isVerified = GeneratedColumn( - 'is_verified', aliasedName, false, + 'is_verified', aliasedName, true, type: DriftSqlType.bool, requiredDuringInsert: false, - $customConstraints: 'NOT NULL DEFAULT FALSE', - defaultValue: const CustomExpression('FALSE')); + $customConstraints: ''); + static const VerificationMeta _createdAtMeta = + const VerificationMeta('createdAt'); + late final GeneratedColumnWithTypeConverter createdAt = + GeneratedColumn('created_at', aliasedName, true, + type: DriftSqlType.int, + requiredDuringInsert: false, + $customConstraints: '') + .withConverter(Users.$convertercreatedAtn); + static const VerificationMeta _muteUntilMeta = + const VerificationMeta('muteUntil'); + late final GeneratedColumnWithTypeConverter muteUntil = + GeneratedColumn('mute_until', aliasedName, true, + type: DriftSqlType.int, + requiredDuringInsert: false, + $customConstraints: '') + .withConverter(Users.$convertermuteUntiln); + static const VerificationMeta _hasPinMeta = const VerificationMeta('hasPin'); + late final GeneratedColumn hasPin = GeneratedColumn( + 'has_pin', aliasedName, true, + type: DriftSqlType.int, + requiredDuringInsert: false, + $customConstraints: ''); + static const VerificationMeta _appIdMeta = const VerificationMeta('appId'); + late final GeneratedColumn appId = GeneratedColumn( + 'app_id', aliasedName, true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: ''); + static const VerificationMeta _biographyMeta = + const VerificationMeta('biography'); + late final GeneratedColumn biography = GeneratedColumn( + 'biography', aliasedName, true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: ''); + static const VerificationMeta _isScamMeta = const VerificationMeta('isScam'); + late final GeneratedColumn isScam = GeneratedColumn( + 'is_scam', aliasedName, true, + type: DriftSqlType.int, + requiredDuringInsert: false, + $customConstraints: ''); + static const VerificationMeta _codeUrlMeta = + const VerificationMeta('codeUrl'); + late final GeneratedColumn codeUrl = GeneratedColumn( + 'code_url', aliasedName, true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: ''); + static const VerificationMeta _codeIdMeta = const VerificationMeta('codeId'); + late final GeneratedColumn codeId = GeneratedColumn( + 'code_id', aliasedName, true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: ''); @override List get $columns => [ - albumId, - name, - iconUrl, - createdAt, - updateAt, - orderedAt, userId, - category, - description, - banner, - added, - isVerified + identityNumber, + relationship, + fullName, + avatarUrl, + phone, + isVerified, + createdAt, + muteUntil, + hasPin, + appId, + biography, + isScam, + codeUrl, + codeId ]; @override - String get aliasedName => _alias ?? 'sticker_albums'; + String get aliasedName => _alias ?? 'users'; @override - String get actualTableName => 'sticker_albums'; + String get actualTableName => 'users'; @override - VerificationContext validateIntegrity(Insertable instance, + VerificationContext validateIntegrity(Insertable instance, {bool isInserting = false}) { final context = VerificationContext(); final data = instance.toColumns(true); - if (data.containsKey('album_id')) { - context.handle(_albumIdMeta, - albumId.isAcceptableOrUnknown(data['album_id']!, _albumIdMeta)); - } else if (isInserting) { - context.missing(_albumIdMeta); - } - if (data.containsKey('name')) { - context.handle( - _nameMeta, name.isAcceptableOrUnknown(data['name']!, _nameMeta)); - } else if (isInserting) { - context.missing(_nameMeta); - } - if (data.containsKey('icon_url')) { - context.handle(_iconUrlMeta, - iconUrl.isAcceptableOrUnknown(data['icon_url']!, _iconUrlMeta)); - } else if (isInserting) { - context.missing(_iconUrlMeta); - } - context.handle(_createdAtMeta, const VerificationResult.success()); - context.handle(_updateAtMeta, const VerificationResult.success()); - if (data.containsKey('ordered_at')) { - context.handle(_orderedAtMeta, - orderedAt.isAcceptableOrUnknown(data['ordered_at']!, _orderedAtMeta)); - } if (data.containsKey('user_id')) { context.handle(_userIdMeta, userId.isAcceptableOrUnknown(data['user_id']!, _userIdMeta)); } else if (isInserting) { context.missing(_userIdMeta); } - if (data.containsKey('category')) { - context.handle(_categoryMeta, - category.isAcceptableOrUnknown(data['category']!, _categoryMeta)); - } else if (isInserting) { - context.missing(_categoryMeta); - } - if (data.containsKey('description')) { + if (data.containsKey('identity_number')) { context.handle( - _descriptionMeta, - description.isAcceptableOrUnknown( - data['description']!, _descriptionMeta)); + _identityNumberMeta, + identityNumber.isAcceptableOrUnknown( + data['identity_number']!, _identityNumberMeta)); } else if (isInserting) { - context.missing(_descriptionMeta); + context.missing(_identityNumberMeta); } - if (data.containsKey('banner')) { - context.handle(_bannerMeta, - banner.isAcceptableOrUnknown(data['banner']!, _bannerMeta)); + context.handle(_relationshipMeta, const VerificationResult.success()); + if (data.containsKey('full_name')) { + context.handle(_fullNameMeta, + fullName.isAcceptableOrUnknown(data['full_name']!, _fullNameMeta)); } - if (data.containsKey('added')) { + if (data.containsKey('avatar_url')) { + context.handle(_avatarUrlMeta, + avatarUrl.isAcceptableOrUnknown(data['avatar_url']!, _avatarUrlMeta)); + } + if (data.containsKey('phone')) { context.handle( - _addedMeta, added.isAcceptableOrUnknown(data['added']!, _addedMeta)); + _phoneMeta, phone.isAcceptableOrUnknown(data['phone']!, _phoneMeta)); } if (data.containsKey('is_verified')) { context.handle( @@ -1249,346 +2456,482 @@ class StickerAlbums extends Table with TableInfo { isVerified.isAcceptableOrUnknown( data['is_verified']!, _isVerifiedMeta)); } + context.handle(_createdAtMeta, const VerificationResult.success()); + context.handle(_muteUntilMeta, const VerificationResult.success()); + if (data.containsKey('has_pin')) { + context.handle(_hasPinMeta, + hasPin.isAcceptableOrUnknown(data['has_pin']!, _hasPinMeta)); + } + if (data.containsKey('app_id')) { + context.handle( + _appIdMeta, appId.isAcceptableOrUnknown(data['app_id']!, _appIdMeta)); + } + if (data.containsKey('biography')) { + context.handle(_biographyMeta, + biography.isAcceptableOrUnknown(data['biography']!, _biographyMeta)); + } + if (data.containsKey('is_scam')) { + context.handle(_isScamMeta, + isScam.isAcceptableOrUnknown(data['is_scam']!, _isScamMeta)); + } + if (data.containsKey('code_url')) { + context.handle(_codeUrlMeta, + codeUrl.isAcceptableOrUnknown(data['code_url']!, _codeUrlMeta)); + } + if (data.containsKey('code_id')) { + context.handle(_codeIdMeta, + codeId.isAcceptableOrUnknown(data['code_id']!, _codeIdMeta)); + } return context; } @override - Set get $primaryKey => {albumId}; + Set get $primaryKey => {userId}; @override - StickerAlbum map(Map data, {String? tablePrefix}) { + User map(Map data, {String? tablePrefix}) { final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; - return StickerAlbum( - albumId: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}album_id'])!, - name: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}name'])!, - iconUrl: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}icon_url'])!, - createdAt: StickerAlbums.$convertercreatedAt.fromSql(attachedDatabase - .typeMapping - .read(DriftSqlType.int, data['${effectivePrefix}created_at'])!), - updateAt: StickerAlbums.$converterupdateAt.fromSql(attachedDatabase - .typeMapping - .read(DriftSqlType.int, data['${effectivePrefix}update_at'])!), - orderedAt: attachedDatabase.typeMapping - .read(DriftSqlType.int, data['${effectivePrefix}ordered_at'])!, + return User( userId: attachedDatabase.typeMapping .read(DriftSqlType.string, data['${effectivePrefix}user_id'])!, - category: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}category'])!, - description: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}description'])!, - banner: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}banner']), - added: attachedDatabase.typeMapping - .read(DriftSqlType.bool, data['${effectivePrefix}added']), + identityNumber: attachedDatabase.typeMapping.read( + DriftSqlType.string, data['${effectivePrefix}identity_number'])!, + relationship: Users.$converterrelationship.fromSql(attachedDatabase + .typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}relationship'])), + fullName: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}full_name']), + avatarUrl: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}avatar_url']), + phone: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}phone']), isVerified: attachedDatabase.typeMapping - .read(DriftSqlType.bool, data['${effectivePrefix}is_verified'])!, + .read(DriftSqlType.bool, data['${effectivePrefix}is_verified']), + createdAt: Users.$convertercreatedAtn.fromSql(attachedDatabase.typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}created_at'])), + muteUntil: Users.$convertermuteUntiln.fromSql(attachedDatabase.typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}mute_until'])), + hasPin: attachedDatabase.typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}has_pin']), + appId: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}app_id']), + biography: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}biography']), + isScam: attachedDatabase.typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}is_scam']), + codeUrl: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}code_url']), + codeId: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}code_id']), ); } @override - StickerAlbums createAlias(String alias) { - return StickerAlbums(attachedDatabase, alias); + Users createAlias(String alias) { + return Users(attachedDatabase, alias); } + static TypeConverter $converterrelationship = + const UserRelationshipConverter(); static TypeConverter $convertercreatedAt = const MillisDateConverter(); - static TypeConverter $converterupdateAt = + static TypeConverter $convertercreatedAtn = + NullAwareTypeConverter.wrap($convertercreatedAt); + static TypeConverter $convertermuteUntil = const MillisDateConverter(); + static TypeConverter $convertermuteUntiln = + NullAwareTypeConverter.wrap($convertermuteUntil); @override - List get customConstraints => const ['PRIMARY KEY(album_id)']; + List get customConstraints => const ['PRIMARY KEY(user_id)']; @override bool get dontWriteConstraints => true; } -class StickerAlbum extends DataClass implements Insertable { - final String albumId; - final String name; - final String iconUrl; - final DateTime createdAt; - final DateTime updateAt; - final int orderedAt; +class User extends DataClass implements Insertable { final String userId; - final String category; - final String description; - final String? banner; - final bool? added; - final bool isVerified; - const StickerAlbum( - {required this.albumId, - required this.name, - required this.iconUrl, - required this.createdAt, - required this.updateAt, - required this.orderedAt, - required this.userId, - required this.category, - required this.description, - this.banner, - this.added, - required this.isVerified}); + final String identityNumber; + final UserRelationship? relationship; + final String? fullName; + final String? avatarUrl; + final String? phone; + final bool? isVerified; + final DateTime? createdAt; + final DateTime? muteUntil; + final int? hasPin; + final String? appId; + final String? biography; + final int? isScam; + final String? codeUrl; + final String? codeId; + const User( + {required this.userId, + required this.identityNumber, + this.relationship, + this.fullName, + this.avatarUrl, + this.phone, + this.isVerified, + this.createdAt, + this.muteUntil, + this.hasPin, + this.appId, + this.biography, + this.isScam, + this.codeUrl, + this.codeId}); @override Map toColumns(bool nullToAbsent) { final map = {}; - map['album_id'] = Variable(albumId); - map['name'] = Variable(name); - map['icon_url'] = Variable(iconUrl); - { - final converter = StickerAlbums.$convertercreatedAt; + map['user_id'] = Variable(userId); + map['identity_number'] = Variable(identityNumber); + if (!nullToAbsent || relationship != null) { + final converter = Users.$converterrelationship; + map['relationship'] = Variable(converter.toSql(relationship)); + } + if (!nullToAbsent || fullName != null) { + map['full_name'] = Variable(fullName); + } + if (!nullToAbsent || avatarUrl != null) { + map['avatar_url'] = Variable(avatarUrl); + } + if (!nullToAbsent || phone != null) { + map['phone'] = Variable(phone); + } + if (!nullToAbsent || isVerified != null) { + map['is_verified'] = Variable(isVerified); + } + if (!nullToAbsent || createdAt != null) { + final converter = Users.$convertercreatedAtn; map['created_at'] = Variable(converter.toSql(createdAt)); } - { - final converter = StickerAlbums.$converterupdateAt; - map['update_at'] = Variable(converter.toSql(updateAt)); + if (!nullToAbsent || muteUntil != null) { + final converter = Users.$convertermuteUntiln; + map['mute_until'] = Variable(converter.toSql(muteUntil)); } - map['ordered_at'] = Variable(orderedAt); - map['user_id'] = Variable(userId); - map['category'] = Variable(category); - map['description'] = Variable(description); - if (!nullToAbsent || banner != null) { - map['banner'] = Variable(banner); + if (!nullToAbsent || hasPin != null) { + map['has_pin'] = Variable(hasPin); } - if (!nullToAbsent || added != null) { - map['added'] = Variable(added); + if (!nullToAbsent || appId != null) { + map['app_id'] = Variable(appId); + } + if (!nullToAbsent || biography != null) { + map['biography'] = Variable(biography); + } + if (!nullToAbsent || isScam != null) { + map['is_scam'] = Variable(isScam); + } + if (!nullToAbsent || codeUrl != null) { + map['code_url'] = Variable(codeUrl); + } + if (!nullToAbsent || codeId != null) { + map['code_id'] = Variable(codeId); } - map['is_verified'] = Variable(isVerified); return map; } - StickerAlbumsCompanion toCompanion(bool nullToAbsent) { - return StickerAlbumsCompanion( - albumId: Value(albumId), - name: Value(name), - iconUrl: Value(iconUrl), - createdAt: Value(createdAt), - updateAt: Value(updateAt), - orderedAt: Value(orderedAt), + UsersCompanion toCompanion(bool nullToAbsent) { + return UsersCompanion( userId: Value(userId), - category: Value(category), - description: Value(description), - banner: - banner == null && nullToAbsent ? const Value.absent() : Value(banner), - added: - added == null && nullToAbsent ? const Value.absent() : Value(added), - isVerified: Value(isVerified), + identityNumber: Value(identityNumber), + relationship: relationship == null && nullToAbsent + ? const Value.absent() + : Value(relationship), + fullName: fullName == null && nullToAbsent + ? const Value.absent() + : Value(fullName), + avatarUrl: avatarUrl == null && nullToAbsent + ? const Value.absent() + : Value(avatarUrl), + phone: + phone == null && nullToAbsent ? const Value.absent() : Value(phone), + isVerified: isVerified == null && nullToAbsent + ? const Value.absent() + : Value(isVerified), + createdAt: createdAt == null && nullToAbsent + ? const Value.absent() + : Value(createdAt), + muteUntil: muteUntil == null && nullToAbsent + ? const Value.absent() + : Value(muteUntil), + hasPin: + hasPin == null && nullToAbsent ? const Value.absent() : Value(hasPin), + appId: + appId == null && nullToAbsent ? const Value.absent() : Value(appId), + biography: biography == null && nullToAbsent + ? const Value.absent() + : Value(biography), + isScam: + isScam == null && nullToAbsent ? const Value.absent() : Value(isScam), + codeUrl: codeUrl == null && nullToAbsent + ? const Value.absent() + : Value(codeUrl), + codeId: + codeId == null && nullToAbsent ? const Value.absent() : Value(codeId), ); } - factory StickerAlbum.fromJson(Map json, + factory User.fromJson(Map json, {ValueSerializer? serializer}) { serializer ??= driftRuntimeOptions.defaultSerializer; - return StickerAlbum( - albumId: serializer.fromJson(json['album_id']), - name: serializer.fromJson(json['name']), - iconUrl: serializer.fromJson(json['icon_url']), - createdAt: serializer.fromJson(json['created_at']), - updateAt: serializer.fromJson(json['update_at']), - orderedAt: serializer.fromJson(json['ordered_at']), + return User( userId: serializer.fromJson(json['user_id']), - category: serializer.fromJson(json['category']), - description: serializer.fromJson(json['description']), - banner: serializer.fromJson(json['banner']), - added: serializer.fromJson(json['added']), - isVerified: serializer.fromJson(json['is_verified']), + identityNumber: serializer.fromJson(json['identity_number']), + relationship: + serializer.fromJson(json['relationship']), + fullName: serializer.fromJson(json['full_name']), + avatarUrl: serializer.fromJson(json['avatar_url']), + phone: serializer.fromJson(json['phone']), + isVerified: serializer.fromJson(json['is_verified']), + createdAt: serializer.fromJson(json['created_at']), + muteUntil: serializer.fromJson(json['mute_until']), + hasPin: serializer.fromJson(json['has_pin']), + appId: serializer.fromJson(json['app_id']), + biography: serializer.fromJson(json['biography']), + isScam: serializer.fromJson(json['is_scam']), + codeUrl: serializer.fromJson(json['code_url']), + codeId: serializer.fromJson(json['code_id']), ); } @override Map toJson({ValueSerializer? serializer}) { serializer ??= driftRuntimeOptions.defaultSerializer; return { - 'album_id': serializer.toJson(albumId), - 'name': serializer.toJson(name), - 'icon_url': serializer.toJson(iconUrl), - 'created_at': serializer.toJson(createdAt), - 'update_at': serializer.toJson(updateAt), - 'ordered_at': serializer.toJson(orderedAt), 'user_id': serializer.toJson(userId), - 'category': serializer.toJson(category), - 'description': serializer.toJson(description), - 'banner': serializer.toJson(banner), - 'added': serializer.toJson(added), - 'is_verified': serializer.toJson(isVerified), + 'identity_number': serializer.toJson(identityNumber), + 'relationship': serializer.toJson(relationship), + 'full_name': serializer.toJson(fullName), + 'avatar_url': serializer.toJson(avatarUrl), + 'phone': serializer.toJson(phone), + 'is_verified': serializer.toJson(isVerified), + 'created_at': serializer.toJson(createdAt), + 'mute_until': serializer.toJson(muteUntil), + 'has_pin': serializer.toJson(hasPin), + 'app_id': serializer.toJson(appId), + 'biography': serializer.toJson(biography), + 'is_scam': serializer.toJson(isScam), + 'code_url': serializer.toJson(codeUrl), + 'code_id': serializer.toJson(codeId), }; } - StickerAlbum copyWith( - {String? albumId, - String? name, - String? iconUrl, - DateTime? createdAt, - DateTime? updateAt, - int? orderedAt, - String? userId, - String? category, - String? description, - Value banner = const Value.absent(), - Value added = const Value.absent(), - bool? isVerified}) => - StickerAlbum( - albumId: albumId ?? this.albumId, - name: name ?? this.name, - iconUrl: iconUrl ?? this.iconUrl, - createdAt: createdAt ?? this.createdAt, - updateAt: updateAt ?? this.updateAt, - orderedAt: orderedAt ?? this.orderedAt, + User copyWith( + {String? userId, + String? identityNumber, + Value relationship = const Value.absent(), + Value fullName = const Value.absent(), + Value avatarUrl = const Value.absent(), + Value phone = const Value.absent(), + Value isVerified = const Value.absent(), + Value createdAt = const Value.absent(), + Value muteUntil = const Value.absent(), + Value hasPin = const Value.absent(), + Value appId = const Value.absent(), + Value biography = const Value.absent(), + Value isScam = const Value.absent(), + Value codeUrl = const Value.absent(), + Value codeId = const Value.absent()}) => + User( userId: userId ?? this.userId, - category: category ?? this.category, - description: description ?? this.description, - banner: banner.present ? banner.value : this.banner, - added: added.present ? added.value : this.added, - isVerified: isVerified ?? this.isVerified, + identityNumber: identityNumber ?? this.identityNumber, + relationship: + relationship.present ? relationship.value : this.relationship, + fullName: fullName.present ? fullName.value : this.fullName, + avatarUrl: avatarUrl.present ? avatarUrl.value : this.avatarUrl, + phone: phone.present ? phone.value : this.phone, + isVerified: isVerified.present ? isVerified.value : this.isVerified, + createdAt: createdAt.present ? createdAt.value : this.createdAt, + muteUntil: muteUntil.present ? muteUntil.value : this.muteUntil, + hasPin: hasPin.present ? hasPin.value : this.hasPin, + appId: appId.present ? appId.value : this.appId, + biography: biography.present ? biography.value : this.biography, + isScam: isScam.present ? isScam.value : this.isScam, + codeUrl: codeUrl.present ? codeUrl.value : this.codeUrl, + codeId: codeId.present ? codeId.value : this.codeId, ); @override String toString() { - return (StringBuffer('StickerAlbum(') - ..write('albumId: $albumId, ') - ..write('name: $name, ') - ..write('iconUrl: $iconUrl, ') - ..write('createdAt: $createdAt, ') - ..write('updateAt: $updateAt, ') - ..write('orderedAt: $orderedAt, ') + return (StringBuffer('User(') ..write('userId: $userId, ') - ..write('category: $category, ') - ..write('description: $description, ') - ..write('banner: $banner, ') - ..write('added: $added, ') - ..write('isVerified: $isVerified') + ..write('identityNumber: $identityNumber, ') + ..write('relationship: $relationship, ') + ..write('fullName: $fullName, ') + ..write('avatarUrl: $avatarUrl, ') + ..write('phone: $phone, ') + ..write('isVerified: $isVerified, ') + ..write('createdAt: $createdAt, ') + ..write('muteUntil: $muteUntil, ') + ..write('hasPin: $hasPin, ') + ..write('appId: $appId, ') + ..write('biography: $biography, ') + ..write('isScam: $isScam, ') + ..write('codeUrl: $codeUrl, ') + ..write('codeId: $codeId') ..write(')')) .toString(); } @override - int get hashCode => Object.hash(albumId, name, iconUrl, createdAt, updateAt, - orderedAt, userId, category, description, banner, added, isVerified); + int get hashCode => Object.hash( + userId, + identityNumber, + relationship, + fullName, + avatarUrl, + phone, + isVerified, + createdAt, + muteUntil, + hasPin, + appId, + biography, + isScam, + codeUrl, + codeId); @override bool operator ==(Object other) => identical(this, other) || - (other is StickerAlbum && - other.albumId == this.albumId && - other.name == this.name && - other.iconUrl == this.iconUrl && - other.createdAt == this.createdAt && - other.updateAt == this.updateAt && - other.orderedAt == this.orderedAt && + (other is User && other.userId == this.userId && - other.category == this.category && - other.description == this.description && - other.banner == this.banner && - other.added == this.added && - other.isVerified == this.isVerified); + other.identityNumber == this.identityNumber && + other.relationship == this.relationship && + other.fullName == this.fullName && + other.avatarUrl == this.avatarUrl && + other.phone == this.phone && + other.isVerified == this.isVerified && + other.createdAt == this.createdAt && + other.muteUntil == this.muteUntil && + other.hasPin == this.hasPin && + other.appId == this.appId && + other.biography == this.biography && + other.isScam == this.isScam && + other.codeUrl == this.codeUrl && + other.codeId == this.codeId); } -class StickerAlbumsCompanion extends UpdateCompanion { - final Value albumId; - final Value name; - final Value iconUrl; - final Value createdAt; - final Value updateAt; - final Value orderedAt; +class UsersCompanion extends UpdateCompanion { final Value userId; - final Value category; - final Value description; - final Value banner; - final Value added; - final Value isVerified; + final Value identityNumber; + final Value relationship; + final Value fullName; + final Value avatarUrl; + final Value phone; + final Value isVerified; + final Value createdAt; + final Value muteUntil; + final Value hasPin; + final Value appId; + final Value biography; + final Value isScam; + final Value codeUrl; + final Value codeId; final Value rowid; - const StickerAlbumsCompanion({ - this.albumId = const Value.absent(), - this.name = const Value.absent(), - this.iconUrl = const Value.absent(), - this.createdAt = const Value.absent(), - this.updateAt = const Value.absent(), - this.orderedAt = const Value.absent(), + const UsersCompanion({ this.userId = const Value.absent(), - this.category = const Value.absent(), - this.description = const Value.absent(), - this.banner = const Value.absent(), - this.added = const Value.absent(), + this.identityNumber = const Value.absent(), + this.relationship = const Value.absent(), + this.fullName = const Value.absent(), + this.avatarUrl = const Value.absent(), + this.phone = const Value.absent(), this.isVerified = const Value.absent(), + this.createdAt = const Value.absent(), + this.muteUntil = const Value.absent(), + this.hasPin = const Value.absent(), + this.appId = const Value.absent(), + this.biography = const Value.absent(), + this.isScam = const Value.absent(), + this.codeUrl = const Value.absent(), + this.codeId = const Value.absent(), this.rowid = const Value.absent(), }); - StickerAlbumsCompanion.insert({ - required String albumId, - required String name, - required String iconUrl, - required DateTime createdAt, - required DateTime updateAt, - this.orderedAt = const Value.absent(), + UsersCompanion.insert({ required String userId, - required String category, - required String description, - this.banner = const Value.absent(), - this.added = const Value.absent(), + required String identityNumber, + this.relationship = const Value.absent(), + this.fullName = const Value.absent(), + this.avatarUrl = const Value.absent(), + this.phone = const Value.absent(), this.isVerified = const Value.absent(), + this.createdAt = const Value.absent(), + this.muteUntil = const Value.absent(), + this.hasPin = const Value.absent(), + this.appId = const Value.absent(), + this.biography = const Value.absent(), + this.isScam = const Value.absent(), + this.codeUrl = const Value.absent(), + this.codeId = const Value.absent(), this.rowid = const Value.absent(), - }) : albumId = Value(albumId), - name = Value(name), - iconUrl = Value(iconUrl), - createdAt = Value(createdAt), - updateAt = Value(updateAt), - userId = Value(userId), - category = Value(category), - description = Value(description); - static Insertable custom({ - Expression? albumId, - Expression? name, - Expression? iconUrl, - Expression? createdAt, - Expression? updateAt, - Expression? orderedAt, + }) : userId = Value(userId), + identityNumber = Value(identityNumber); + static Insertable custom({ Expression? userId, - Expression? category, - Expression? description, - Expression? banner, - Expression? added, + Expression? identityNumber, + Expression? relationship, + Expression? fullName, + Expression? avatarUrl, + Expression? phone, Expression? isVerified, - Expression? rowid, - }) { + Expression? createdAt, + Expression? muteUntil, + Expression? hasPin, + Expression? appId, + Expression? biography, + Expression? isScam, + Expression? codeUrl, + Expression? codeId, + Expression? rowid, + }) { return RawValuesInsertable({ - if (albumId != null) 'album_id': albumId, - if (name != null) 'name': name, - if (iconUrl != null) 'icon_url': iconUrl, - if (createdAt != null) 'created_at': createdAt, - if (updateAt != null) 'update_at': updateAt, - if (orderedAt != null) 'ordered_at': orderedAt, if (userId != null) 'user_id': userId, - if (category != null) 'category': category, - if (description != null) 'description': description, - if (banner != null) 'banner': banner, - if (added != null) 'added': added, + if (identityNumber != null) 'identity_number': identityNumber, + if (relationship != null) 'relationship': relationship, + if (fullName != null) 'full_name': fullName, + if (avatarUrl != null) 'avatar_url': avatarUrl, + if (phone != null) 'phone': phone, if (isVerified != null) 'is_verified': isVerified, + if (createdAt != null) 'created_at': createdAt, + if (muteUntil != null) 'mute_until': muteUntil, + if (hasPin != null) 'has_pin': hasPin, + if (appId != null) 'app_id': appId, + if (biography != null) 'biography': biography, + if (isScam != null) 'is_scam': isScam, + if (codeUrl != null) 'code_url': codeUrl, + if (codeId != null) 'code_id': codeId, if (rowid != null) 'rowid': rowid, }); } - StickerAlbumsCompanion copyWith( - {Value? albumId, - Value? name, - Value? iconUrl, - Value? createdAt, - Value? updateAt, - Value? orderedAt, - Value? userId, - Value? category, - Value? description, - Value? banner, - Value? added, - Value? isVerified, + UsersCompanion copyWith( + {Value? userId, + Value? identityNumber, + Value? relationship, + Value? fullName, + Value? avatarUrl, + Value? phone, + Value? isVerified, + Value? createdAt, + Value? muteUntil, + Value? hasPin, + Value? appId, + Value? biography, + Value? isScam, + Value? codeUrl, + Value? codeId, Value? rowid}) { - return StickerAlbumsCompanion( - albumId: albumId ?? this.albumId, - name: name ?? this.name, - iconUrl: iconUrl ?? this.iconUrl, - createdAt: createdAt ?? this.createdAt, - updateAt: updateAt ?? this.updateAt, - orderedAt: orderedAt ?? this.orderedAt, + return UsersCompanion( userId: userId ?? this.userId, - category: category ?? this.category, - description: description ?? this.description, - banner: banner ?? this.banner, - added: added ?? this.added, + identityNumber: identityNumber ?? this.identityNumber, + relationship: relationship ?? this.relationship, + fullName: fullName ?? this.fullName, + avatarUrl: avatarUrl ?? this.avatarUrl, + phone: phone ?? this.phone, isVerified: isVerified ?? this.isVerified, + createdAt: createdAt ?? this.createdAt, + muteUntil: muteUntil ?? this.muteUntil, + hasPin: hasPin ?? this.hasPin, + appId: appId ?? this.appId, + biography: biography ?? this.biography, + isScam: isScam ?? this.isScam, + codeUrl: codeUrl ?? this.codeUrl, + codeId: codeId ?? this.codeId, rowid: rowid ?? this.rowid, ); } @@ -1596,43 +2939,54 @@ class StickerAlbumsCompanion extends UpdateCompanion { @override Map toColumns(bool nullToAbsent) { final map = {}; - if (albumId.present) { - map['album_id'] = Variable(albumId.value); + if (userId.present) { + map['user_id'] = Variable(userId.value); } - if (name.present) { - map['name'] = Variable(name.value); + if (identityNumber.present) { + map['identity_number'] = Variable(identityNumber.value); } - if (iconUrl.present) { - map['icon_url'] = Variable(iconUrl.value); + if (relationship.present) { + final converter = Users.$converterrelationship; + map['relationship'] = + Variable(converter.toSql(relationship.value)); + } + if (fullName.present) { + map['full_name'] = Variable(fullName.value); + } + if (avatarUrl.present) { + map['avatar_url'] = Variable(avatarUrl.value); + } + if (phone.present) { + map['phone'] = Variable(phone.value); + } + if (isVerified.present) { + map['is_verified'] = Variable(isVerified.value); } if (createdAt.present) { - final converter = StickerAlbums.$convertercreatedAt; + final converter = Users.$convertercreatedAtn; map['created_at'] = Variable(converter.toSql(createdAt.value)); } - if (updateAt.present) { - final converter = StickerAlbums.$converterupdateAt; - map['update_at'] = Variable(converter.toSql(updateAt.value)); - } - if (orderedAt.present) { - map['ordered_at'] = Variable(orderedAt.value); + if (muteUntil.present) { + final converter = Users.$convertermuteUntiln; + map['mute_until'] = Variable(converter.toSql(muteUntil.value)); } - if (userId.present) { - map['user_id'] = Variable(userId.value); + if (hasPin.present) { + map['has_pin'] = Variable(hasPin.value); } - if (category.present) { - map['category'] = Variable(category.value); + if (appId.present) { + map['app_id'] = Variable(appId.value); } - if (description.present) { - map['description'] = Variable(description.value); + if (biography.present) { + map['biography'] = Variable(biography.value); } - if (banner.present) { - map['banner'] = Variable(banner.value); + if (isScam.present) { + map['is_scam'] = Variable(isScam.value); } - if (added.present) { - map['added'] = Variable(added.value); + if (codeUrl.present) { + map['code_url'] = Variable(codeUrl.value); } - if (isVerified.present) { - map['is_verified'] = Variable(isVerified.value); + if (codeId.present) { + map['code_id'] = Variable(codeId.value); } if (rowid.present) { map['rowid'] = Variable(rowid.value); @@ -1642,41 +2996,63 @@ class StickerAlbumsCompanion extends UpdateCompanion { @override String toString() { - return (StringBuffer('StickerAlbumsCompanion(') - ..write('albumId: $albumId, ') - ..write('name: $name, ') - ..write('iconUrl: $iconUrl, ') - ..write('createdAt: $createdAt, ') - ..write('updateAt: $updateAt, ') - ..write('orderedAt: $orderedAt, ') + return (StringBuffer('UsersCompanion(') ..write('userId: $userId, ') - ..write('category: $category, ') - ..write('description: $description, ') - ..write('banner: $banner, ') - ..write('added: $added, ') + ..write('identityNumber: $identityNumber, ') + ..write('relationship: $relationship, ') + ..write('fullName: $fullName, ') + ..write('avatarUrl: $avatarUrl, ') + ..write('phone: $phone, ') ..write('isVerified: $isVerified, ') + ..write('createdAt: $createdAt, ') + ..write('muteUntil: $muteUntil, ') + ..write('hasPin: $hasPin, ') + ..write('appId: $appId, ') + ..write('biography: $biography, ') + ..write('isScam: $isScam, ') + ..write('codeUrl: $codeUrl, ') + ..write('codeId: $codeId, ') ..write('rowid: $rowid') ..write(')')) .toString(); } } -class PinMessages extends Table with TableInfo { +class Snapshots extends Table with TableInfo { @override final GeneratedDatabase attachedDatabase; final String? _alias; - PinMessages(this.attachedDatabase, [this._alias]); - static const VerificationMeta _messageIdMeta = - const VerificationMeta('messageId'); - late final GeneratedColumn messageId = GeneratedColumn( - 'message_id', aliasedName, false, + Snapshots(this.attachedDatabase, [this._alias]); + static const VerificationMeta _snapshotIdMeta = + const VerificationMeta('snapshotId'); + late final GeneratedColumn snapshotId = GeneratedColumn( + 'snapshot_id', aliasedName, false, type: DriftSqlType.string, requiredDuringInsert: true, $customConstraints: 'NOT NULL'); - static const VerificationMeta _conversationIdMeta = - const VerificationMeta('conversationId'); - late final GeneratedColumn conversationId = GeneratedColumn( - 'conversation_id', aliasedName, false, + static const VerificationMeta _traceIdMeta = + const VerificationMeta('traceId'); + late final GeneratedColumn traceId = GeneratedColumn( + 'trace_id', aliasedName, true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: ''); + static const VerificationMeta _typeMeta = const VerificationMeta('type'); + late final GeneratedColumn type = GeneratedColumn( + 'type', aliasedName, false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL'); + static const VerificationMeta _assetIdMeta = + const VerificationMeta('assetId'); + late final GeneratedColumn assetId = GeneratedColumn( + 'asset_id', aliasedName, false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL'); + static const VerificationMeta _amountMeta = const VerificationMeta('amount'); + late final GeneratedColumn amount = GeneratedColumn( + 'amount', aliasedName, false, type: DriftSqlType.string, requiredDuringInsert: true, $customConstraints: 'NOT NULL'); @@ -1687,1005 +3063,613 @@ class PinMessages extends Table with TableInfo { type: DriftSqlType.int, requiredDuringInsert: true, $customConstraints: 'NOT NULL') - .withConverter(PinMessages.$convertercreatedAt); - @override - List get $columns => [messageId, conversationId, createdAt]; - @override - String get aliasedName => _alias ?? 'pin_messages'; - @override - String get actualTableName => 'pin_messages'; - @override - VerificationContext validateIntegrity(Insertable instance, - {bool isInserting = false}) { - final context = VerificationContext(); - final data = instance.toColumns(true); - if (data.containsKey('message_id')) { - context.handle(_messageIdMeta, - messageId.isAcceptableOrUnknown(data['message_id']!, _messageIdMeta)); - } else if (isInserting) { - context.missing(_messageIdMeta); - } - if (data.containsKey('conversation_id')) { - context.handle( - _conversationIdMeta, - conversationId.isAcceptableOrUnknown( - data['conversation_id']!, _conversationIdMeta)); - } else if (isInserting) { - context.missing(_conversationIdMeta); - } - context.handle(_createdAtMeta, const VerificationResult.success()); - return context; - } - - @override - Set get $primaryKey => {messageId}; - @override - PinMessage map(Map data, {String? tablePrefix}) { - final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; - return PinMessage( - messageId: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}message_id'])!, - conversationId: attachedDatabase.typeMapping.read( - DriftSqlType.string, data['${effectivePrefix}conversation_id'])!, - createdAt: PinMessages.$convertercreatedAt.fromSql(attachedDatabase - .typeMapping - .read(DriftSqlType.int, data['${effectivePrefix}created_at'])!), - ); - } - - @override - PinMessages createAlias(String alias) { - return PinMessages(attachedDatabase, alias); - } - - static TypeConverter $convertercreatedAt = - const MillisDateConverter(); - @override - List get customConstraints => const ['PRIMARY KEY(message_id)']; - @override - bool get dontWriteConstraints => true; -} - -class PinMessage extends DataClass implements Insertable { - final String messageId; - final String conversationId; - final DateTime createdAt; - const PinMessage( - {required this.messageId, - required this.conversationId, - required this.createdAt}); - @override - Map toColumns(bool nullToAbsent) { - final map = {}; - map['message_id'] = Variable(messageId); - map['conversation_id'] = Variable(conversationId); - { - final converter = PinMessages.$convertercreatedAt; - map['created_at'] = Variable(converter.toSql(createdAt)); - } - return map; - } - - PinMessagesCompanion toCompanion(bool nullToAbsent) { - return PinMessagesCompanion( - messageId: Value(messageId), - conversationId: Value(conversationId), - createdAt: Value(createdAt), - ); - } - - factory PinMessage.fromJson(Map json, - {ValueSerializer? serializer}) { - serializer ??= driftRuntimeOptions.defaultSerializer; - return PinMessage( - messageId: serializer.fromJson(json['message_id']), - conversationId: serializer.fromJson(json['conversation_id']), - createdAt: serializer.fromJson(json['created_at']), - ); - } - @override - Map toJson({ValueSerializer? serializer}) { - serializer ??= driftRuntimeOptions.defaultSerializer; - return { - 'message_id': serializer.toJson(messageId), - 'conversation_id': serializer.toJson(conversationId), - 'created_at': serializer.toJson(createdAt), - }; - } - - PinMessage copyWith( - {String? messageId, String? conversationId, DateTime? createdAt}) => - PinMessage( - messageId: messageId ?? this.messageId, - conversationId: conversationId ?? this.conversationId, - createdAt: createdAt ?? this.createdAt, - ); - @override - String toString() { - return (StringBuffer('PinMessage(') - ..write('messageId: $messageId, ') - ..write('conversationId: $conversationId, ') - ..write('createdAt: $createdAt') - ..write(')')) - .toString(); - } - - @override - int get hashCode => Object.hash(messageId, conversationId, createdAt); - @override - bool operator ==(Object other) => - identical(this, other) || - (other is PinMessage && - other.messageId == this.messageId && - other.conversationId == this.conversationId && - other.createdAt == this.createdAt); -} - -class PinMessagesCompanion extends UpdateCompanion { - final Value messageId; - final Value conversationId; - final Value createdAt; - final Value rowid; - const PinMessagesCompanion({ - this.messageId = const Value.absent(), - this.conversationId = const Value.absent(), - this.createdAt = const Value.absent(), - this.rowid = const Value.absent(), - }); - PinMessagesCompanion.insert({ - required String messageId, - required String conversationId, - required DateTime createdAt, - this.rowid = const Value.absent(), - }) : messageId = Value(messageId), - conversationId = Value(conversationId), - createdAt = Value(createdAt); - static Insertable custom({ - Expression? messageId, - Expression? conversationId, - Expression? createdAt, - Expression? rowid, - }) { - return RawValuesInsertable({ - if (messageId != null) 'message_id': messageId, - if (conversationId != null) 'conversation_id': conversationId, - if (createdAt != null) 'created_at': createdAt, - if (rowid != null) 'rowid': rowid, - }); - } - - PinMessagesCompanion copyWith( - {Value? messageId, - Value? conversationId, - Value? createdAt, - Value? rowid}) { - return PinMessagesCompanion( - messageId: messageId ?? this.messageId, - conversationId: conversationId ?? this.conversationId, - createdAt: createdAt ?? this.createdAt, - rowid: rowid ?? this.rowid, - ); - } - - @override - Map toColumns(bool nullToAbsent) { - final map = {}; - if (messageId.present) { - map['message_id'] = Variable(messageId.value); - } - if (conversationId.present) { - map['conversation_id'] = Variable(conversationId.value); - } - if (createdAt.present) { - final converter = PinMessages.$convertercreatedAt; - map['created_at'] = Variable(converter.toSql(createdAt.value)); - } - if (rowid.present) { - map['rowid'] = Variable(rowid.value); - } - return map; - } - - @override - String toString() { - return (StringBuffer('PinMessagesCompanion(') - ..write('messageId: $messageId, ') - ..write('conversationId: $conversationId, ') - ..write('createdAt: $createdAt, ') - ..write('rowid: $rowid') - ..write(')')) - .toString(); - } -} - -class Conversations extends Table with TableInfo { - @override - final GeneratedDatabase attachedDatabase; - final String? _alias; - Conversations(this.attachedDatabase, [this._alias]); - static const VerificationMeta _conversationIdMeta = - const VerificationMeta('conversationId'); - late final GeneratedColumn conversationId = GeneratedColumn( - 'conversation_id', aliasedName, false, + .withConverter(Snapshots.$convertercreatedAt); + static const VerificationMeta _opponentIdMeta = + const VerificationMeta('opponentId'); + late final GeneratedColumn opponentId = GeneratedColumn( + 'opponent_id', aliasedName, true, type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL'); - static const VerificationMeta _ownerIdMeta = - const VerificationMeta('ownerId'); - late final GeneratedColumn ownerId = GeneratedColumn( - 'owner_id', aliasedName, true, + requiredDuringInsert: false, + $customConstraints: ''); + static const VerificationMeta _transactionHashMeta = + const VerificationMeta('transactionHash'); + late final GeneratedColumn transactionHash = GeneratedColumn( + 'transaction_hash', aliasedName, true, type: DriftSqlType.string, requiredDuringInsert: false, $customConstraints: ''); - static const VerificationMeta _categoryMeta = - const VerificationMeta('category'); - late final GeneratedColumnWithTypeConverter - category = GeneratedColumn('category', aliasedName, true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: '') - .withConverter( - Conversations.$convertercategory); - static const VerificationMeta _nameMeta = const VerificationMeta('name'); - late final GeneratedColumn name = GeneratedColumn( - 'name', aliasedName, true, + static const VerificationMeta _senderMeta = const VerificationMeta('sender'); + late final GeneratedColumn sender = GeneratedColumn( + 'sender', aliasedName, true, type: DriftSqlType.string, requiredDuringInsert: false, $customConstraints: ''); - static const VerificationMeta _iconUrlMeta = - const VerificationMeta('iconUrl'); - late final GeneratedColumn iconUrl = GeneratedColumn( - 'icon_url', aliasedName, true, + static const VerificationMeta _receiverMeta = + const VerificationMeta('receiver'); + late final GeneratedColumn receiver = GeneratedColumn( + 'receiver', aliasedName, true, type: DriftSqlType.string, requiredDuringInsert: false, $customConstraints: ''); - static const VerificationMeta _announcementMeta = - const VerificationMeta('announcement'); - late final GeneratedColumn announcement = GeneratedColumn( - 'announcement', aliasedName, true, + static const VerificationMeta _memoMeta = const VerificationMeta('memo'); + late final GeneratedColumn memo = GeneratedColumn( + 'memo', aliasedName, true, type: DriftSqlType.string, requiredDuringInsert: false, $customConstraints: ''); - static const VerificationMeta _codeUrlMeta = - const VerificationMeta('codeUrl'); - late final GeneratedColumn codeUrl = GeneratedColumn( - 'code_url', aliasedName, true, + static const VerificationMeta _confirmationsMeta = + const VerificationMeta('confirmations'); + late final GeneratedColumn confirmations = GeneratedColumn( + 'confirmations', aliasedName, true, + type: DriftSqlType.int, + requiredDuringInsert: false, + $customConstraints: ''); + static const VerificationMeta _snapshotHashMeta = + const VerificationMeta('snapshotHash'); + late final GeneratedColumn snapshotHash = GeneratedColumn( + 'snapshot_hash', aliasedName, true, type: DriftSqlType.string, requiredDuringInsert: false, $customConstraints: ''); - static const VerificationMeta _payTypeMeta = - const VerificationMeta('payType'); - late final GeneratedColumn payType = GeneratedColumn( - 'pay_type', aliasedName, true, + static const VerificationMeta _openingBalanceMeta = + const VerificationMeta('openingBalance'); + late final GeneratedColumn openingBalance = GeneratedColumn( + 'opening_balance', aliasedName, true, type: DriftSqlType.string, requiredDuringInsert: false, $customConstraints: ''); - static const VerificationMeta _createdAtMeta = - const VerificationMeta('createdAt'); - late final GeneratedColumnWithTypeConverter createdAt = - GeneratedColumn('created_at', aliasedName, false, - type: DriftSqlType.int, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL') - .withConverter(Conversations.$convertercreatedAt); - static const VerificationMeta _pinTimeMeta = - const VerificationMeta('pinTime'); - late final GeneratedColumnWithTypeConverter pinTime = - GeneratedColumn('pin_time', aliasedName, true, - type: DriftSqlType.int, - requiredDuringInsert: false, - $customConstraints: '') - .withConverter(Conversations.$converterpinTimen); - static const VerificationMeta _lastMessageIdMeta = - const VerificationMeta('lastMessageId'); - late final GeneratedColumn lastMessageId = GeneratedColumn( - 'last_message_id', aliasedName, true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: ''); - static const VerificationMeta _lastMessageCreatedAtMeta = - const VerificationMeta('lastMessageCreatedAt'); - late final GeneratedColumnWithTypeConverter - lastMessageCreatedAt = GeneratedColumn( - 'last_message_created_at', aliasedName, true, - type: DriftSqlType.int, - requiredDuringInsert: false, - $customConstraints: '') - .withConverter( - Conversations.$converterlastMessageCreatedAtn); - static const VerificationMeta _lastReadMessageIdMeta = - const VerificationMeta('lastReadMessageId'); - late final GeneratedColumn lastReadMessageId = - GeneratedColumn('last_read_message_id', aliasedName, true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: ''); - static const VerificationMeta _unseenMessageCountMeta = - const VerificationMeta('unseenMessageCount'); - late final GeneratedColumn unseenMessageCount = GeneratedColumn( - 'unseen_message_count', aliasedName, true, - type: DriftSqlType.int, - requiredDuringInsert: false, - $customConstraints: ''); - static const VerificationMeta _statusMeta = const VerificationMeta('status'); - late final GeneratedColumnWithTypeConverter status = - GeneratedColumn('status', aliasedName, false, - type: DriftSqlType.int, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL') - .withConverter(Conversations.$converterstatus); - static const VerificationMeta _draftMeta = const VerificationMeta('draft'); - late final GeneratedColumn draft = GeneratedColumn( - 'draft', aliasedName, true, + static const VerificationMeta _closingBalanceMeta = + const VerificationMeta('closingBalance'); + late final GeneratedColumn closingBalance = GeneratedColumn( + 'closing_balance', aliasedName, true, type: DriftSqlType.string, requiredDuringInsert: false, $customConstraints: ''); - static const VerificationMeta _muteUntilMeta = - const VerificationMeta('muteUntil'); - late final GeneratedColumnWithTypeConverter muteUntil = - GeneratedColumn('mute_until', aliasedName, true, - type: DriftSqlType.int, - requiredDuringInsert: false, - $customConstraints: '') - .withConverter(Conversations.$convertermuteUntiln); - static const VerificationMeta _expireInMeta = - const VerificationMeta('expireIn'); - late final GeneratedColumn expireIn = GeneratedColumn( - 'expire_in', aliasedName, true, - type: DriftSqlType.int, - requiredDuringInsert: false, - $customConstraints: ''); @override List get $columns => [ - conversationId, - ownerId, - category, - name, - iconUrl, - announcement, - codeUrl, - payType, + snapshotId, + traceId, + type, + assetId, + amount, createdAt, - pinTime, - lastMessageId, - lastMessageCreatedAt, - lastReadMessageId, - unseenMessageCount, - status, - draft, - muteUntil, - expireIn + opponentId, + transactionHash, + sender, + receiver, + memo, + confirmations, + snapshotHash, + openingBalance, + closingBalance ]; @override - String get aliasedName => _alias ?? 'conversations'; + String get aliasedName => _alias ?? 'snapshots'; @override - String get actualTableName => 'conversations'; + String get actualTableName => 'snapshots'; @override - VerificationContext validateIntegrity(Insertable instance, + VerificationContext validateIntegrity(Insertable instance, {bool isInserting = false}) { final context = VerificationContext(); final data = instance.toColumns(true); - if (data.containsKey('conversation_id')) { + if (data.containsKey('snapshot_id')) { context.handle( - _conversationIdMeta, - conversationId.isAcceptableOrUnknown( - data['conversation_id']!, _conversationIdMeta)); + _snapshotIdMeta, + snapshotId.isAcceptableOrUnknown( + data['snapshot_id']!, _snapshotIdMeta)); } else if (isInserting) { - context.missing(_conversationIdMeta); + context.missing(_snapshotIdMeta); } - if (data.containsKey('owner_id')) { - context.handle(_ownerIdMeta, - ownerId.isAcceptableOrUnknown(data['owner_id']!, _ownerIdMeta)); + if (data.containsKey('trace_id')) { + context.handle(_traceIdMeta, + traceId.isAcceptableOrUnknown(data['trace_id']!, _traceIdMeta)); } - context.handle(_categoryMeta, const VerificationResult.success()); - if (data.containsKey('name')) { + if (data.containsKey('type')) { context.handle( - _nameMeta, name.isAcceptableOrUnknown(data['name']!, _nameMeta)); + _typeMeta, type.isAcceptableOrUnknown(data['type']!, _typeMeta)); + } else if (isInserting) { + context.missing(_typeMeta); } - if (data.containsKey('icon_url')) { - context.handle(_iconUrlMeta, - iconUrl.isAcceptableOrUnknown(data['icon_url']!, _iconUrlMeta)); + if (data.containsKey('asset_id')) { + context.handle(_assetIdMeta, + assetId.isAcceptableOrUnknown(data['asset_id']!, _assetIdMeta)); + } else if (isInserting) { + context.missing(_assetIdMeta); } - if (data.containsKey('announcement')) { + if (data.containsKey('amount')) { + context.handle(_amountMeta, + amount.isAcceptableOrUnknown(data['amount']!, _amountMeta)); + } else if (isInserting) { + context.missing(_amountMeta); + } + context.handle(_createdAtMeta, const VerificationResult.success()); + if (data.containsKey('opponent_id')) { context.handle( - _announcementMeta, - announcement.isAcceptableOrUnknown( - data['announcement']!, _announcementMeta)); + _opponentIdMeta, + opponentId.isAcceptableOrUnknown( + data['opponent_id']!, _opponentIdMeta)); } - if (data.containsKey('code_url')) { - context.handle(_codeUrlMeta, - codeUrl.isAcceptableOrUnknown(data['code_url']!, _codeUrlMeta)); + if (data.containsKey('transaction_hash')) { + context.handle( + _transactionHashMeta, + transactionHash.isAcceptableOrUnknown( + data['transaction_hash']!, _transactionHashMeta)); } - if (data.containsKey('pay_type')) { - context.handle(_payTypeMeta, - payType.isAcceptableOrUnknown(data['pay_type']!, _payTypeMeta)); + if (data.containsKey('sender')) { + context.handle(_senderMeta, + sender.isAcceptableOrUnknown(data['sender']!, _senderMeta)); } - context.handle(_createdAtMeta, const VerificationResult.success()); - context.handle(_pinTimeMeta, const VerificationResult.success()); - if (data.containsKey('last_message_id')) { + if (data.containsKey('receiver')) { + context.handle(_receiverMeta, + receiver.isAcceptableOrUnknown(data['receiver']!, _receiverMeta)); + } + if (data.containsKey('memo')) { context.handle( - _lastMessageIdMeta, - lastMessageId.isAcceptableOrUnknown( - data['last_message_id']!, _lastMessageIdMeta)); + _memoMeta, memo.isAcceptableOrUnknown(data['memo']!, _memoMeta)); } - context.handle( - _lastMessageCreatedAtMeta, const VerificationResult.success()); - if (data.containsKey('last_read_message_id')) { + if (data.containsKey('confirmations')) { context.handle( - _lastReadMessageIdMeta, - lastReadMessageId.isAcceptableOrUnknown( - data['last_read_message_id']!, _lastReadMessageIdMeta)); + _confirmationsMeta, + confirmations.isAcceptableOrUnknown( + data['confirmations']!, _confirmationsMeta)); } - if (data.containsKey('unseen_message_count')) { + if (data.containsKey('snapshot_hash')) { context.handle( - _unseenMessageCountMeta, - unseenMessageCount.isAcceptableOrUnknown( - data['unseen_message_count']!, _unseenMessageCountMeta)); + _snapshotHashMeta, + snapshotHash.isAcceptableOrUnknown( + data['snapshot_hash']!, _snapshotHashMeta)); } - context.handle(_statusMeta, const VerificationResult.success()); - if (data.containsKey('draft')) { + if (data.containsKey('opening_balance')) { context.handle( - _draftMeta, draft.isAcceptableOrUnknown(data['draft']!, _draftMeta)); + _openingBalanceMeta, + openingBalance.isAcceptableOrUnknown( + data['opening_balance']!, _openingBalanceMeta)); } - context.handle(_muteUntilMeta, const VerificationResult.success()); - if (data.containsKey('expire_in')) { - context.handle(_expireInMeta, - expireIn.isAcceptableOrUnknown(data['expire_in']!, _expireInMeta)); + if (data.containsKey('closing_balance')) { + context.handle( + _closingBalanceMeta, + closingBalance.isAcceptableOrUnknown( + data['closing_balance']!, _closingBalanceMeta)); } return context; } @override - Set get $primaryKey => {conversationId}; + Set get $primaryKey => {snapshotId}; @override - Conversation map(Map data, {String? tablePrefix}) { + Snapshot map(Map data, {String? tablePrefix}) { final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; - return Conversation( - conversationId: attachedDatabase.typeMapping.read( - DriftSqlType.string, data['${effectivePrefix}conversation_id'])!, - ownerId: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}owner_id']), - category: Conversations.$convertercategory.fromSql(attachedDatabase - .typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}category'])), - name: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}name']), - iconUrl: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}icon_url']), - announcement: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}announcement']), - codeUrl: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}code_url']), - payType: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}pay_type']), - createdAt: Conversations.$convertercreatedAt.fromSql(attachedDatabase + return Snapshot( + snapshotId: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}snapshot_id'])!, + traceId: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}trace_id']), + type: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}type'])!, + assetId: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}asset_id'])!, + amount: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}amount'])!, + createdAt: Snapshots.$convertercreatedAt.fromSql(attachedDatabase .typeMapping .read(DriftSqlType.int, data['${effectivePrefix}created_at'])!), - pinTime: Conversations.$converterpinTimen.fromSql(attachedDatabase - .typeMapping - .read(DriftSqlType.int, data['${effectivePrefix}pin_time'])), - lastMessageId: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}last_message_id']), - lastMessageCreatedAt: Conversations.$converterlastMessageCreatedAtn - .fromSql(attachedDatabase.typeMapping.read(DriftSqlType.int, - data['${effectivePrefix}last_message_created_at'])), - lastReadMessageId: attachedDatabase.typeMapping.read( - DriftSqlType.string, data['${effectivePrefix}last_read_message_id']), - unseenMessageCount: attachedDatabase.typeMapping.read( - DriftSqlType.int, data['${effectivePrefix}unseen_message_count']), - status: Conversations.$converterstatus.fromSql(attachedDatabase - .typeMapping - .read(DriftSqlType.int, data['${effectivePrefix}status'])!), - draft: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}draft']), - muteUntil: Conversations.$convertermuteUntiln.fromSql(attachedDatabase - .typeMapping - .read(DriftSqlType.int, data['${effectivePrefix}mute_until'])), - expireIn: attachedDatabase.typeMapping - .read(DriftSqlType.int, data['${effectivePrefix}expire_in']), + opponentId: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}opponent_id']), + transactionHash: attachedDatabase.typeMapping.read( + DriftSqlType.string, data['${effectivePrefix}transaction_hash']), + sender: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}sender']), + receiver: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}receiver']), + memo: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}memo']), + confirmations: attachedDatabase.typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}confirmations']), + snapshotHash: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}snapshot_hash']), + openingBalance: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}opening_balance']), + closingBalance: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}closing_balance']), ); } @override - Conversations createAlias(String alias) { - return Conversations(attachedDatabase, alias); + Snapshots createAlias(String alias) { + return Snapshots(attachedDatabase, alias); } - static TypeConverter $convertercategory = - const ConversationCategoryTypeConverter(); static TypeConverter $convertercreatedAt = const MillisDateConverter(); - static TypeConverter $converterpinTime = - const MillisDateConverter(); - static TypeConverter $converterpinTimen = - NullAwareTypeConverter.wrap($converterpinTime); - static TypeConverter $converterlastMessageCreatedAt = - const MillisDateConverter(); - static TypeConverter $converterlastMessageCreatedAtn = - NullAwareTypeConverter.wrap($converterlastMessageCreatedAt); - static TypeConverter $converterstatus = - const ConversationStatusTypeConverter(); - static TypeConverter $convertermuteUntil = - const MillisDateConverter(); - static TypeConverter $convertermuteUntiln = - NullAwareTypeConverter.wrap($convertermuteUntil); @override - List get customConstraints => const ['PRIMARY KEY(conversation_id)']; + List get customConstraints => const ['PRIMARY KEY(snapshot_id)']; @override bool get dontWriteConstraints => true; } -class Conversation extends DataClass implements Insertable { - final String conversationId; - final String? ownerId; - final ConversationCategory? category; - final String? name; - final String? iconUrl; - final String? announcement; - final String? codeUrl; - final String? payType; +class Snapshot extends DataClass implements Insertable { + final String snapshotId; + final String? traceId; + final String type; + final String assetId; + final String amount; final DateTime createdAt; - final DateTime? pinTime; - final String? lastMessageId; - final DateTime? lastMessageCreatedAt; - final String? lastReadMessageId; - final int? unseenMessageCount; - final ConversationStatus status; - final String? draft; - final DateTime? muteUntil; - final int? expireIn; - const Conversation( - {required this.conversationId, - this.ownerId, - this.category, - this.name, - this.iconUrl, - this.announcement, - this.codeUrl, - this.payType, + final String? opponentId; + final String? transactionHash; + final String? sender; + final String? receiver; + final String? memo; + final int? confirmations; + final String? snapshotHash; + final String? openingBalance; + final String? closingBalance; + const Snapshot( + {required this.snapshotId, + this.traceId, + required this.type, + required this.assetId, + required this.amount, required this.createdAt, - this.pinTime, - this.lastMessageId, - this.lastMessageCreatedAt, - this.lastReadMessageId, - this.unseenMessageCount, - required this.status, - this.draft, - this.muteUntil, - this.expireIn}); + this.opponentId, + this.transactionHash, + this.sender, + this.receiver, + this.memo, + this.confirmations, + this.snapshotHash, + this.openingBalance, + this.closingBalance}); @override Map toColumns(bool nullToAbsent) { final map = {}; - map['conversation_id'] = Variable(conversationId); - if (!nullToAbsent || ownerId != null) { - map['owner_id'] = Variable(ownerId); - } - if (!nullToAbsent || category != null) { - final converter = Conversations.$convertercategory; - map['category'] = Variable(converter.toSql(category)); - } - if (!nullToAbsent || name != null) { - map['name'] = Variable(name); - } - if (!nullToAbsent || iconUrl != null) { - map['icon_url'] = Variable(iconUrl); - } - if (!nullToAbsent || announcement != null) { - map['announcement'] = Variable(announcement); - } - if (!nullToAbsent || codeUrl != null) { - map['code_url'] = Variable(codeUrl); - } - if (!nullToAbsent || payType != null) { - map['pay_type'] = Variable(payType); + map['snapshot_id'] = Variable(snapshotId); + if (!nullToAbsent || traceId != null) { + map['trace_id'] = Variable(traceId); } + map['type'] = Variable(type); + map['asset_id'] = Variable(assetId); + map['amount'] = Variable(amount); { - final converter = Conversations.$convertercreatedAt; + final converter = Snapshots.$convertercreatedAt; map['created_at'] = Variable(converter.toSql(createdAt)); } - if (!nullToAbsent || pinTime != null) { - final converter = Conversations.$converterpinTimen; - map['pin_time'] = Variable(converter.toSql(pinTime)); + if (!nullToAbsent || opponentId != null) { + map['opponent_id'] = Variable(opponentId); } - if (!nullToAbsent || lastMessageId != null) { - map['last_message_id'] = Variable(lastMessageId); + if (!nullToAbsent || transactionHash != null) { + map['transaction_hash'] = Variable(transactionHash); } - if (!nullToAbsent || lastMessageCreatedAt != null) { - final converter = Conversations.$converterlastMessageCreatedAtn; - map['last_message_created_at'] = - Variable(converter.toSql(lastMessageCreatedAt)); + if (!nullToAbsent || sender != null) { + map['sender'] = Variable(sender); } - if (!nullToAbsent || lastReadMessageId != null) { - map['last_read_message_id'] = Variable(lastReadMessageId); + if (!nullToAbsent || receiver != null) { + map['receiver'] = Variable(receiver); } - if (!nullToAbsent || unseenMessageCount != null) { - map['unseen_message_count'] = Variable(unseenMessageCount); + if (!nullToAbsent || memo != null) { + map['memo'] = Variable(memo); } - { - final converter = Conversations.$converterstatus; - map['status'] = Variable(converter.toSql(status)); + if (!nullToAbsent || confirmations != null) { + map['confirmations'] = Variable(confirmations); } - if (!nullToAbsent || draft != null) { - map['draft'] = Variable(draft); + if (!nullToAbsent || snapshotHash != null) { + map['snapshot_hash'] = Variable(snapshotHash); } - if (!nullToAbsent || muteUntil != null) { - final converter = Conversations.$convertermuteUntiln; - map['mute_until'] = Variable(converter.toSql(muteUntil)); + if (!nullToAbsent || openingBalance != null) { + map['opening_balance'] = Variable(openingBalance); } - if (!nullToAbsent || expireIn != null) { - map['expire_in'] = Variable(expireIn); + if (!nullToAbsent || closingBalance != null) { + map['closing_balance'] = Variable(closingBalance); } return map; } - ConversationsCompanion toCompanion(bool nullToAbsent) { - return ConversationsCompanion( - conversationId: Value(conversationId), - ownerId: ownerId == null && nullToAbsent - ? const Value.absent() - : Value(ownerId), - category: category == null && nullToAbsent - ? const Value.absent() - : Value(category), - name: name == null && nullToAbsent ? const Value.absent() : Value(name), - iconUrl: iconUrl == null && nullToAbsent - ? const Value.absent() - : Value(iconUrl), - announcement: announcement == null && nullToAbsent - ? const Value.absent() - : Value(announcement), - codeUrl: codeUrl == null && nullToAbsent - ? const Value.absent() - : Value(codeUrl), - payType: payType == null && nullToAbsent + SnapshotsCompanion toCompanion(bool nullToAbsent) { + return SnapshotsCompanion( + snapshotId: Value(snapshotId), + traceId: traceId == null && nullToAbsent ? const Value.absent() - : Value(payType), + : Value(traceId), + type: Value(type), + assetId: Value(assetId), + amount: Value(amount), createdAt: Value(createdAt), - pinTime: pinTime == null && nullToAbsent + opponentId: opponentId == null && nullToAbsent ? const Value.absent() - : Value(pinTime), - lastMessageId: lastMessageId == null && nullToAbsent + : Value(opponentId), + transactionHash: transactionHash == null && nullToAbsent ? const Value.absent() - : Value(lastMessageId), - lastMessageCreatedAt: lastMessageCreatedAt == null && nullToAbsent + : Value(transactionHash), + sender: + sender == null && nullToAbsent ? const Value.absent() : Value(sender), + receiver: receiver == null && nullToAbsent ? const Value.absent() - : Value(lastMessageCreatedAt), - lastReadMessageId: lastReadMessageId == null && nullToAbsent + : Value(receiver), + memo: memo == null && nullToAbsent ? const Value.absent() : Value(memo), + confirmations: confirmations == null && nullToAbsent ? const Value.absent() - : Value(lastReadMessageId), - unseenMessageCount: unseenMessageCount == null && nullToAbsent + : Value(confirmations), + snapshotHash: snapshotHash == null && nullToAbsent ? const Value.absent() - : Value(unseenMessageCount), - status: Value(status), - draft: - draft == null && nullToAbsent ? const Value.absent() : Value(draft), - muteUntil: muteUntil == null && nullToAbsent + : Value(snapshotHash), + openingBalance: openingBalance == null && nullToAbsent ? const Value.absent() - : Value(muteUntil), - expireIn: expireIn == null && nullToAbsent + : Value(openingBalance), + closingBalance: closingBalance == null && nullToAbsent ? const Value.absent() - : Value(expireIn), + : Value(closingBalance), ); } - factory Conversation.fromJson(Map json, + factory Snapshot.fromJson(Map json, {ValueSerializer? serializer}) { serializer ??= driftRuntimeOptions.defaultSerializer; - return Conversation( - conversationId: serializer.fromJson(json['conversation_id']), - ownerId: serializer.fromJson(json['owner_id']), - category: serializer.fromJson(json['category']), - name: serializer.fromJson(json['name']), - iconUrl: serializer.fromJson(json['icon_url']), - announcement: serializer.fromJson(json['announcement']), - codeUrl: serializer.fromJson(json['code_url']), - payType: serializer.fromJson(json['pay_type']), + return Snapshot( + snapshotId: serializer.fromJson(json['snapshot_id']), + traceId: serializer.fromJson(json['trace_id']), + type: serializer.fromJson(json['type']), + assetId: serializer.fromJson(json['asset_id']), + amount: serializer.fromJson(json['amount']), createdAt: serializer.fromJson(json['created_at']), - pinTime: serializer.fromJson(json['pin_time']), - lastMessageId: serializer.fromJson(json['last_message_id']), - lastMessageCreatedAt: - serializer.fromJson(json['last_message_created_at']), - lastReadMessageId: - serializer.fromJson(json['last_read_message_id']), - unseenMessageCount: - serializer.fromJson(json['unseen_message_count']), - status: serializer.fromJson(json['status']), - draft: serializer.fromJson(json['draft']), - muteUntil: serializer.fromJson(json['mute_until']), - expireIn: serializer.fromJson(json['expire_in']), + opponentId: serializer.fromJson(json['opponent_id']), + transactionHash: serializer.fromJson(json['transaction_hash']), + sender: serializer.fromJson(json['sender']), + receiver: serializer.fromJson(json['receiver']), + memo: serializer.fromJson(json['memo']), + confirmations: serializer.fromJson(json['confirmations']), + snapshotHash: serializer.fromJson(json['snapshot_hash']), + openingBalance: serializer.fromJson(json['opening_balance']), + closingBalance: serializer.fromJson(json['closing_balance']), ); } @override Map toJson({ValueSerializer? serializer}) { serializer ??= driftRuntimeOptions.defaultSerializer; return { - 'conversation_id': serializer.toJson(conversationId), - 'owner_id': serializer.toJson(ownerId), - 'category': serializer.toJson(category), - 'name': serializer.toJson(name), - 'icon_url': serializer.toJson(iconUrl), - 'announcement': serializer.toJson(announcement), - 'code_url': serializer.toJson(codeUrl), - 'pay_type': serializer.toJson(payType), + 'snapshot_id': serializer.toJson(snapshotId), + 'trace_id': serializer.toJson(traceId), + 'type': serializer.toJson(type), + 'asset_id': serializer.toJson(assetId), + 'amount': serializer.toJson(amount), 'created_at': serializer.toJson(createdAt), - 'pin_time': serializer.toJson(pinTime), - 'last_message_id': serializer.toJson(lastMessageId), - 'last_message_created_at': - serializer.toJson(lastMessageCreatedAt), - 'last_read_message_id': serializer.toJson(lastReadMessageId), - 'unseen_message_count': serializer.toJson(unseenMessageCount), - 'status': serializer.toJson(status), - 'draft': serializer.toJson(draft), - 'mute_until': serializer.toJson(muteUntil), - 'expire_in': serializer.toJson(expireIn), + 'opponent_id': serializer.toJson(opponentId), + 'transaction_hash': serializer.toJson(transactionHash), + 'sender': serializer.toJson(sender), + 'receiver': serializer.toJson(receiver), + 'memo': serializer.toJson(memo), + 'confirmations': serializer.toJson(confirmations), + 'snapshot_hash': serializer.toJson(snapshotHash), + 'opening_balance': serializer.toJson(openingBalance), + 'closing_balance': serializer.toJson(closingBalance), }; } - Conversation copyWith( - {String? conversationId, - Value ownerId = const Value.absent(), - Value category = const Value.absent(), - Value name = const Value.absent(), - Value iconUrl = const Value.absent(), - Value announcement = const Value.absent(), - Value codeUrl = const Value.absent(), - Value payType = const Value.absent(), + Snapshot copyWith( + {String? snapshotId, + Value traceId = const Value.absent(), + String? type, + String? assetId, + String? amount, DateTime? createdAt, - Value pinTime = const Value.absent(), - Value lastMessageId = const Value.absent(), - Value lastMessageCreatedAt = const Value.absent(), - Value lastReadMessageId = const Value.absent(), - Value unseenMessageCount = const Value.absent(), - ConversationStatus? status, - Value draft = const Value.absent(), - Value muteUntil = const Value.absent(), - Value expireIn = const Value.absent()}) => - Conversation( - conversationId: conversationId ?? this.conversationId, - ownerId: ownerId.present ? ownerId.value : this.ownerId, - category: category.present ? category.value : this.category, - name: name.present ? name.value : this.name, - iconUrl: iconUrl.present ? iconUrl.value : this.iconUrl, - announcement: - announcement.present ? announcement.value : this.announcement, - codeUrl: codeUrl.present ? codeUrl.value : this.codeUrl, - payType: payType.present ? payType.value : this.payType, + Value opponentId = const Value.absent(), + Value transactionHash = const Value.absent(), + Value sender = const Value.absent(), + Value receiver = const Value.absent(), + Value memo = const Value.absent(), + Value confirmations = const Value.absent(), + Value snapshotHash = const Value.absent(), + Value openingBalance = const Value.absent(), + Value closingBalance = const Value.absent()}) => + Snapshot( + snapshotId: snapshotId ?? this.snapshotId, + traceId: traceId.present ? traceId.value : this.traceId, + type: type ?? this.type, + assetId: assetId ?? this.assetId, + amount: amount ?? this.amount, createdAt: createdAt ?? this.createdAt, - pinTime: pinTime.present ? pinTime.value : this.pinTime, - lastMessageId: - lastMessageId.present ? lastMessageId.value : this.lastMessageId, - lastMessageCreatedAt: lastMessageCreatedAt.present - ? lastMessageCreatedAt.value - : this.lastMessageCreatedAt, - lastReadMessageId: lastReadMessageId.present - ? lastReadMessageId.value - : this.lastReadMessageId, - unseenMessageCount: unseenMessageCount.present - ? unseenMessageCount.value - : this.unseenMessageCount, - status: status ?? this.status, - draft: draft.present ? draft.value : this.draft, - muteUntil: muteUntil.present ? muteUntil.value : this.muteUntil, - expireIn: expireIn.present ? expireIn.value : this.expireIn, + opponentId: opponentId.present ? opponentId.value : this.opponentId, + transactionHash: transactionHash.present + ? transactionHash.value + : this.transactionHash, + sender: sender.present ? sender.value : this.sender, + receiver: receiver.present ? receiver.value : this.receiver, + memo: memo.present ? memo.value : this.memo, + confirmations: + confirmations.present ? confirmations.value : this.confirmations, + snapshotHash: + snapshotHash.present ? snapshotHash.value : this.snapshotHash, + openingBalance: + openingBalance.present ? openingBalance.value : this.openingBalance, + closingBalance: + closingBalance.present ? closingBalance.value : this.closingBalance, ); @override String toString() { - return (StringBuffer('Conversation(') - ..write('conversationId: $conversationId, ') - ..write('ownerId: $ownerId, ') - ..write('category: $category, ') - ..write('name: $name, ') - ..write('iconUrl: $iconUrl, ') - ..write('announcement: $announcement, ') - ..write('codeUrl: $codeUrl, ') - ..write('payType: $payType, ') + return (StringBuffer('Snapshot(') + ..write('snapshotId: $snapshotId, ') + ..write('traceId: $traceId, ') + ..write('type: $type, ') + ..write('assetId: $assetId, ') + ..write('amount: $amount, ') ..write('createdAt: $createdAt, ') - ..write('pinTime: $pinTime, ') - ..write('lastMessageId: $lastMessageId, ') - ..write('lastMessageCreatedAt: $lastMessageCreatedAt, ') - ..write('lastReadMessageId: $lastReadMessageId, ') - ..write('unseenMessageCount: $unseenMessageCount, ') - ..write('status: $status, ') - ..write('draft: $draft, ') - ..write('muteUntil: $muteUntil, ') - ..write('expireIn: $expireIn') + ..write('opponentId: $opponentId, ') + ..write('transactionHash: $transactionHash, ') + ..write('sender: $sender, ') + ..write('receiver: $receiver, ') + ..write('memo: $memo, ') + ..write('confirmations: $confirmations, ') + ..write('snapshotHash: $snapshotHash, ') + ..write('openingBalance: $openingBalance, ') + ..write('closingBalance: $closingBalance') ..write(')')) .toString(); } @override int get hashCode => Object.hash( - conversationId, - ownerId, - category, - name, - iconUrl, - announcement, - codeUrl, - payType, + snapshotId, + traceId, + type, + assetId, + amount, createdAt, - pinTime, - lastMessageId, - lastMessageCreatedAt, - lastReadMessageId, - unseenMessageCount, - status, - draft, - muteUntil, - expireIn); + opponentId, + transactionHash, + sender, + receiver, + memo, + confirmations, + snapshotHash, + openingBalance, + closingBalance); @override bool operator ==(Object other) => identical(this, other) || - (other is Conversation && - other.conversationId == this.conversationId && - other.ownerId == this.ownerId && - other.category == this.category && - other.name == this.name && - other.iconUrl == this.iconUrl && - other.announcement == this.announcement && - other.codeUrl == this.codeUrl && - other.payType == this.payType && + (other is Snapshot && + other.snapshotId == this.snapshotId && + other.traceId == this.traceId && + other.type == this.type && + other.assetId == this.assetId && + other.amount == this.amount && other.createdAt == this.createdAt && - other.pinTime == this.pinTime && - other.lastMessageId == this.lastMessageId && - other.lastMessageCreatedAt == this.lastMessageCreatedAt && - other.lastReadMessageId == this.lastReadMessageId && - other.unseenMessageCount == this.unseenMessageCount && - other.status == this.status && - other.draft == this.draft && - other.muteUntil == this.muteUntil && - other.expireIn == this.expireIn); + other.opponentId == this.opponentId && + other.transactionHash == this.transactionHash && + other.sender == this.sender && + other.receiver == this.receiver && + other.memo == this.memo && + other.confirmations == this.confirmations && + other.snapshotHash == this.snapshotHash && + other.openingBalance == this.openingBalance && + other.closingBalance == this.closingBalance); } -class ConversationsCompanion extends UpdateCompanion { - final Value conversationId; - final Value ownerId; - final Value category; - final Value name; - final Value iconUrl; - final Value announcement; - final Value codeUrl; - final Value payType; +class SnapshotsCompanion extends UpdateCompanion { + final Value snapshotId; + final Value traceId; + final Value type; + final Value assetId; + final Value amount; final Value createdAt; - final Value pinTime; - final Value lastMessageId; - final Value lastMessageCreatedAt; - final Value lastReadMessageId; - final Value unseenMessageCount; - final Value status; - final Value draft; - final Value muteUntil; - final Value expireIn; + final Value opponentId; + final Value transactionHash; + final Value sender; + final Value receiver; + final Value memo; + final Value confirmations; + final Value snapshotHash; + final Value openingBalance; + final Value closingBalance; final Value rowid; - const ConversationsCompanion({ - this.conversationId = const Value.absent(), - this.ownerId = const Value.absent(), - this.category = const Value.absent(), - this.name = const Value.absent(), - this.iconUrl = const Value.absent(), - this.announcement = const Value.absent(), - this.codeUrl = const Value.absent(), - this.payType = const Value.absent(), + const SnapshotsCompanion({ + this.snapshotId = const Value.absent(), + this.traceId = const Value.absent(), + this.type = const Value.absent(), + this.assetId = const Value.absent(), + this.amount = const Value.absent(), this.createdAt = const Value.absent(), - this.pinTime = const Value.absent(), - this.lastMessageId = const Value.absent(), - this.lastMessageCreatedAt = const Value.absent(), - this.lastReadMessageId = const Value.absent(), - this.unseenMessageCount = const Value.absent(), - this.status = const Value.absent(), - this.draft = const Value.absent(), - this.muteUntil = const Value.absent(), - this.expireIn = const Value.absent(), + this.opponentId = const Value.absent(), + this.transactionHash = const Value.absent(), + this.sender = const Value.absent(), + this.receiver = const Value.absent(), + this.memo = const Value.absent(), + this.confirmations = const Value.absent(), + this.snapshotHash = const Value.absent(), + this.openingBalance = const Value.absent(), + this.closingBalance = const Value.absent(), this.rowid = const Value.absent(), }); - ConversationsCompanion.insert({ - required String conversationId, - this.ownerId = const Value.absent(), - this.category = const Value.absent(), - this.name = const Value.absent(), - this.iconUrl = const Value.absent(), - this.announcement = const Value.absent(), - this.codeUrl = const Value.absent(), - this.payType = const Value.absent(), + SnapshotsCompanion.insert({ + required String snapshotId, + this.traceId = const Value.absent(), + required String type, + required String assetId, + required String amount, required DateTime createdAt, - this.pinTime = const Value.absent(), - this.lastMessageId = const Value.absent(), - this.lastMessageCreatedAt = const Value.absent(), - this.lastReadMessageId = const Value.absent(), - this.unseenMessageCount = const Value.absent(), - required ConversationStatus status, - this.draft = const Value.absent(), - this.muteUntil = const Value.absent(), - this.expireIn = const Value.absent(), + this.opponentId = const Value.absent(), + this.transactionHash = const Value.absent(), + this.sender = const Value.absent(), + this.receiver = const Value.absent(), + this.memo = const Value.absent(), + this.confirmations = const Value.absent(), + this.snapshotHash = const Value.absent(), + this.openingBalance = const Value.absent(), + this.closingBalance = const Value.absent(), this.rowid = const Value.absent(), - }) : conversationId = Value(conversationId), - createdAt = Value(createdAt), - status = Value(status); - static Insertable custom({ - Expression? conversationId, - Expression? ownerId, - Expression? category, - Expression? name, - Expression? iconUrl, - Expression? announcement, - Expression? codeUrl, - Expression? payType, + }) : snapshotId = Value(snapshotId), + type = Value(type), + assetId = Value(assetId), + amount = Value(amount), + createdAt = Value(createdAt); + static Insertable custom({ + Expression? snapshotId, + Expression? traceId, + Expression? type, + Expression? assetId, + Expression? amount, Expression? createdAt, - Expression? pinTime, - Expression? lastMessageId, - Expression? lastMessageCreatedAt, - Expression? lastReadMessageId, - Expression? unseenMessageCount, - Expression? status, - Expression? draft, - Expression? muteUntil, - Expression? expireIn, + Expression? opponentId, + Expression? transactionHash, + Expression? sender, + Expression? receiver, + Expression? memo, + Expression? confirmations, + Expression? snapshotHash, + Expression? openingBalance, + Expression? closingBalance, Expression? rowid, }) { return RawValuesInsertable({ - if (conversationId != null) 'conversation_id': conversationId, - if (ownerId != null) 'owner_id': ownerId, - if (category != null) 'category': category, - if (name != null) 'name': name, - if (iconUrl != null) 'icon_url': iconUrl, - if (announcement != null) 'announcement': announcement, - if (codeUrl != null) 'code_url': codeUrl, - if (payType != null) 'pay_type': payType, + if (snapshotId != null) 'snapshot_id': snapshotId, + if (traceId != null) 'trace_id': traceId, + if (type != null) 'type': type, + if (assetId != null) 'asset_id': assetId, + if (amount != null) 'amount': amount, if (createdAt != null) 'created_at': createdAt, - if (pinTime != null) 'pin_time': pinTime, - if (lastMessageId != null) 'last_message_id': lastMessageId, - if (lastMessageCreatedAt != null) - 'last_message_created_at': lastMessageCreatedAt, - if (lastReadMessageId != null) 'last_read_message_id': lastReadMessageId, - if (unseenMessageCount != null) - 'unseen_message_count': unseenMessageCount, - if (status != null) 'status': status, - if (draft != null) 'draft': draft, - if (muteUntil != null) 'mute_until': muteUntil, - if (expireIn != null) 'expire_in': expireIn, + if (opponentId != null) 'opponent_id': opponentId, + if (transactionHash != null) 'transaction_hash': transactionHash, + if (sender != null) 'sender': sender, + if (receiver != null) 'receiver': receiver, + if (memo != null) 'memo': memo, + if (confirmations != null) 'confirmations': confirmations, + if (snapshotHash != null) 'snapshot_hash': snapshotHash, + if (openingBalance != null) 'opening_balance': openingBalance, + if (closingBalance != null) 'closing_balance': closingBalance, if (rowid != null) 'rowid': rowid, }); } - ConversationsCompanion copyWith( - {Value? conversationId, - Value? ownerId, - Value? category, - Value? name, - Value? iconUrl, - Value? announcement, - Value? codeUrl, - Value? payType, + SnapshotsCompanion copyWith( + {Value? snapshotId, + Value? traceId, + Value? type, + Value? assetId, + Value? amount, Value? createdAt, - Value? pinTime, - Value? lastMessageId, - Value? lastMessageCreatedAt, - Value? lastReadMessageId, - Value? unseenMessageCount, - Value? status, - Value? draft, - Value? muteUntil, - Value? expireIn, + Value? opponentId, + Value? transactionHash, + Value? sender, + Value? receiver, + Value? memo, + Value? confirmations, + Value? snapshotHash, + Value? openingBalance, + Value? closingBalance, Value? rowid}) { - return ConversationsCompanion( - conversationId: conversationId ?? this.conversationId, - ownerId: ownerId ?? this.ownerId, - category: category ?? this.category, - name: name ?? this.name, - iconUrl: iconUrl ?? this.iconUrl, - announcement: announcement ?? this.announcement, - codeUrl: codeUrl ?? this.codeUrl, - payType: payType ?? this.payType, + return SnapshotsCompanion( + snapshotId: snapshotId ?? this.snapshotId, + traceId: traceId ?? this.traceId, + type: type ?? this.type, + assetId: assetId ?? this.assetId, + amount: amount ?? this.amount, createdAt: createdAt ?? this.createdAt, - pinTime: pinTime ?? this.pinTime, - lastMessageId: lastMessageId ?? this.lastMessageId, - lastMessageCreatedAt: lastMessageCreatedAt ?? this.lastMessageCreatedAt, - lastReadMessageId: lastReadMessageId ?? this.lastReadMessageId, - unseenMessageCount: unseenMessageCount ?? this.unseenMessageCount, - status: status ?? this.status, - draft: draft ?? this.draft, - muteUntil: muteUntil ?? this.muteUntil, - expireIn: expireIn ?? this.expireIn, + opponentId: opponentId ?? this.opponentId, + transactionHash: transactionHash ?? this.transactionHash, + sender: sender ?? this.sender, + receiver: receiver ?? this.receiver, + memo: memo ?? this.memo, + confirmations: confirmations ?? this.confirmations, + snapshotHash: snapshotHash ?? this.snapshotHash, + openingBalance: openingBalance ?? this.openingBalance, + closingBalance: closingBalance ?? this.closingBalance, rowid: rowid ?? this.rowid, ); } @@ -2693,66 +3677,51 @@ class ConversationsCompanion extends UpdateCompanion { @override Map toColumns(bool nullToAbsent) { final map = {}; - if (conversationId.present) { - map['conversation_id'] = Variable(conversationId.value); - } - if (ownerId.present) { - map['owner_id'] = Variable(ownerId.value); - } - if (category.present) { - final converter = Conversations.$convertercategory; - map['category'] = Variable(converter.toSql(category.value)); - } - if (name.present) { - map['name'] = Variable(name.value); + if (snapshotId.present) { + map['snapshot_id'] = Variable(snapshotId.value); } - if (iconUrl.present) { - map['icon_url'] = Variable(iconUrl.value); + if (traceId.present) { + map['trace_id'] = Variable(traceId.value); } - if (announcement.present) { - map['announcement'] = Variable(announcement.value); + if (type.present) { + map['type'] = Variable(type.value); } - if (codeUrl.present) { - map['code_url'] = Variable(codeUrl.value); + if (assetId.present) { + map['asset_id'] = Variable(assetId.value); } - if (payType.present) { - map['pay_type'] = Variable(payType.value); + if (amount.present) { + map['amount'] = Variable(amount.value); } if (createdAt.present) { - final converter = Conversations.$convertercreatedAt; + final converter = Snapshots.$convertercreatedAt; map['created_at'] = Variable(converter.toSql(createdAt.value)); } - if (pinTime.present) { - final converter = Conversations.$converterpinTimen; - map['pin_time'] = Variable(converter.toSql(pinTime.value)); + if (opponentId.present) { + map['opponent_id'] = Variable(opponentId.value); } - if (lastMessageId.present) { - map['last_message_id'] = Variable(lastMessageId.value); + if (transactionHash.present) { + map['transaction_hash'] = Variable(transactionHash.value); } - if (lastMessageCreatedAt.present) { - final converter = Conversations.$converterlastMessageCreatedAtn; - map['last_message_created_at'] = - Variable(converter.toSql(lastMessageCreatedAt.value)); + if (sender.present) { + map['sender'] = Variable(sender.value); } - if (lastReadMessageId.present) { - map['last_read_message_id'] = Variable(lastReadMessageId.value); + if (receiver.present) { + map['receiver'] = Variable(receiver.value); } - if (unseenMessageCount.present) { - map['unseen_message_count'] = Variable(unseenMessageCount.value); + if (memo.present) { + map['memo'] = Variable(memo.value); } - if (status.present) { - final converter = Conversations.$converterstatus; - map['status'] = Variable(converter.toSql(status.value)); + if (confirmations.present) { + map['confirmations'] = Variable(confirmations.value); } - if (draft.present) { - map['draft'] = Variable(draft.value); + if (snapshotHash.present) { + map['snapshot_hash'] = Variable(snapshotHash.value); } - if (muteUntil.present) { - final converter = Conversations.$convertermuteUntiln; - map['mute_until'] = Variable(converter.toSql(muteUntil.value)); + if (openingBalance.present) { + map['opening_balance'] = Variable(openingBalance.value); } - if (expireIn.present) { - map['expire_in'] = Variable(expireIn.value); + if (closingBalance.present) { + map['closing_balance'] = Variable(closingBalance.value); } if (rowid.present) { map['rowid'] = Variable(rowid.value); @@ -2762,1278 +3731,657 @@ class ConversationsCompanion extends UpdateCompanion { @override String toString() { - return (StringBuffer('ConversationsCompanion(') - ..write('conversationId: $conversationId, ') - ..write('ownerId: $ownerId, ') - ..write('category: $category, ') - ..write('name: $name, ') - ..write('iconUrl: $iconUrl, ') - ..write('announcement: $announcement, ') - ..write('codeUrl: $codeUrl, ') - ..write('payType: $payType, ') + return (StringBuffer('SnapshotsCompanion(') + ..write('snapshotId: $snapshotId, ') + ..write('traceId: $traceId, ') + ..write('type: $type, ') + ..write('assetId: $assetId, ') + ..write('amount: $amount, ') ..write('createdAt: $createdAt, ') - ..write('pinTime: $pinTime, ') - ..write('lastMessageId: $lastMessageId, ') - ..write('lastMessageCreatedAt: $lastMessageCreatedAt, ') - ..write('lastReadMessageId: $lastReadMessageId, ') - ..write('unseenMessageCount: $unseenMessageCount, ') - ..write('status: $status, ') - ..write('draft: $draft, ') - ..write('muteUntil: $muteUntil, ') - ..write('expireIn: $expireIn, ') + ..write('opponentId: $opponentId, ') + ..write('transactionHash: $transactionHash, ') + ..write('sender: $sender, ') + ..write('receiver: $receiver, ') + ..write('memo: $memo, ') + ..write('confirmations: $confirmations, ') + ..write('snapshotHash: $snapshotHash, ') + ..write('openingBalance: $openingBalance, ') + ..write('closingBalance: $closingBalance, ') ..write('rowid: $rowid') ..write(')')) .toString(); } } -class Messages extends Table with TableInfo { +class Assets extends Table with TableInfo { @override final GeneratedDatabase attachedDatabase; final String? _alias; - Messages(this.attachedDatabase, [this._alias]); - static const VerificationMeta _messageIdMeta = - const VerificationMeta('messageId'); - late final GeneratedColumn messageId = GeneratedColumn( - 'message_id', aliasedName, false, + Assets(this.attachedDatabase, [this._alias]); + static const VerificationMeta _assetIdMeta = + const VerificationMeta('assetId'); + late final GeneratedColumn assetId = GeneratedColumn( + 'asset_id', aliasedName, false, type: DriftSqlType.string, requiredDuringInsert: true, $customConstraints: 'NOT NULL'); - static const VerificationMeta _conversationIdMeta = - const VerificationMeta('conversationId'); - late final GeneratedColumn conversationId = GeneratedColumn( - 'conversation_id', aliasedName, false, + static const VerificationMeta _symbolMeta = const VerificationMeta('symbol'); + late final GeneratedColumn symbol = GeneratedColumn( + 'symbol', aliasedName, false, type: DriftSqlType.string, requiredDuringInsert: true, $customConstraints: 'NOT NULL'); - static const VerificationMeta _userIdMeta = const VerificationMeta('userId'); - late final GeneratedColumn userId = GeneratedColumn( - 'user_id', aliasedName, false, + static const VerificationMeta _nameMeta = const VerificationMeta('name'); + late final GeneratedColumn name = GeneratedColumn( + 'name', aliasedName, false, type: DriftSqlType.string, requiredDuringInsert: true, $customConstraints: 'NOT NULL'); - static const VerificationMeta _categoryMeta = - const VerificationMeta('category'); - late final GeneratedColumn category = GeneratedColumn( - 'category', aliasedName, false, + static const VerificationMeta _iconUrlMeta = + const VerificationMeta('iconUrl'); + late final GeneratedColumn iconUrl = GeneratedColumn( + 'icon_url', aliasedName, false, type: DriftSqlType.string, requiredDuringInsert: true, $customConstraints: 'NOT NULL'); - static const VerificationMeta _contentMeta = - const VerificationMeta('content'); - late final GeneratedColumn content = GeneratedColumn( - 'content', aliasedName, true, + static const VerificationMeta _balanceMeta = + const VerificationMeta('balance'); + late final GeneratedColumn balance = GeneratedColumn( + 'balance', aliasedName, false, type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: ''); - static const VerificationMeta _mediaUrlMeta = - const VerificationMeta('mediaUrl'); - late final GeneratedColumn mediaUrl = GeneratedColumn( - 'media_url', aliasedName, true, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL'); + static const VerificationMeta _destinationMeta = + const VerificationMeta('destination'); + late final GeneratedColumn destination = GeneratedColumn( + 'destination', aliasedName, false, type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: ''); - static const VerificationMeta _mediaMimeTypeMeta = - const VerificationMeta('mediaMimeType'); - late final GeneratedColumn mediaMimeType = GeneratedColumn( - 'media_mime_type', aliasedName, true, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL'); + static const VerificationMeta _tagMeta = const VerificationMeta('tag'); + late final GeneratedColumn tag = GeneratedColumn( + 'tag', aliasedName, true, type: DriftSqlType.string, requiredDuringInsert: false, $customConstraints: ''); - static const VerificationMeta _mediaSizeMeta = - const VerificationMeta('mediaSize'); - late final GeneratedColumn mediaSize = GeneratedColumn( - 'media_size', aliasedName, true, - type: DriftSqlType.int, - requiredDuringInsert: false, - $customConstraints: ''); - static const VerificationMeta _mediaDurationMeta = - const VerificationMeta('mediaDuration'); - late final GeneratedColumn mediaDuration = GeneratedColumn( - 'media_duration', aliasedName, true, + static const VerificationMeta _priceBtcMeta = + const VerificationMeta('priceBtc'); + late final GeneratedColumn priceBtc = GeneratedColumn( + 'price_btc', aliasedName, false, type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: ''); - static const VerificationMeta _mediaWidthMeta = - const VerificationMeta('mediaWidth'); - late final GeneratedColumn mediaWidth = GeneratedColumn( - 'media_width', aliasedName, true, - type: DriftSqlType.int, - requiredDuringInsert: false, - $customConstraints: ''); - static const VerificationMeta _mediaHeightMeta = - const VerificationMeta('mediaHeight'); - late final GeneratedColumn mediaHeight = GeneratedColumn( - 'media_height', aliasedName, true, - type: DriftSqlType.int, - requiredDuringInsert: false, - $customConstraints: ''); - static const VerificationMeta _mediaHashMeta = - const VerificationMeta('mediaHash'); - late final GeneratedColumn mediaHash = GeneratedColumn( - 'media_hash', aliasedName, true, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL'); + static const VerificationMeta _priceUsdMeta = + const VerificationMeta('priceUsd'); + late final GeneratedColumn priceUsd = GeneratedColumn( + 'price_usd', aliasedName, false, type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: ''); - static const VerificationMeta _thumbImageMeta = - const VerificationMeta('thumbImage'); - late final GeneratedColumn thumbImage = GeneratedColumn( - 'thumb_image', aliasedName, true, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL'); + static const VerificationMeta _chainIdMeta = + const VerificationMeta('chainId'); + late final GeneratedColumn chainId = GeneratedColumn( + 'chain_id', aliasedName, false, type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: ''); - static const VerificationMeta _mediaKeyMeta = - const VerificationMeta('mediaKey'); - late final GeneratedColumn mediaKey = GeneratedColumn( - 'media_key', aliasedName, true, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL'); + static const VerificationMeta _changeUsdMeta = + const VerificationMeta('changeUsd'); + late final GeneratedColumn changeUsd = GeneratedColumn( + 'change_usd', aliasedName, false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL'); + static const VerificationMeta _changeBtcMeta = + const VerificationMeta('changeBtc'); + late final GeneratedColumn changeBtc = GeneratedColumn( + 'change_btc', aliasedName, false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL'); + static const VerificationMeta _confirmationsMeta = + const VerificationMeta('confirmations'); + late final GeneratedColumn confirmations = GeneratedColumn( + 'confirmations', aliasedName, false, + type: DriftSqlType.int, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL'); + static const VerificationMeta _assetKeyMeta = + const VerificationMeta('assetKey'); + late final GeneratedColumn assetKey = GeneratedColumn( + 'asset_key', aliasedName, true, type: DriftSqlType.string, requiredDuringInsert: false, $customConstraints: ''); - static const VerificationMeta _mediaDigestMeta = - const VerificationMeta('mediaDigest'); - late final GeneratedColumn mediaDigest = GeneratedColumn( - 'media_digest', aliasedName, true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: ''); - static const VerificationMeta _mediaStatusMeta = - const VerificationMeta('mediaStatus'); - late final GeneratedColumnWithTypeConverter - mediaStatus = GeneratedColumn('media_status', aliasedName, true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: '') - .withConverter(Messages.$convertermediaStatus); - static const VerificationMeta _statusMeta = const VerificationMeta('status'); - late final GeneratedColumnWithTypeConverter status = - GeneratedColumn('status', aliasedName, false, - type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL') - .withConverter(Messages.$converterstatus); - static const VerificationMeta _createdAtMeta = - const VerificationMeta('createdAt'); - late final GeneratedColumnWithTypeConverter createdAt = - GeneratedColumn('created_at', aliasedName, false, - type: DriftSqlType.int, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL') - .withConverter(Messages.$convertercreatedAt); - static const VerificationMeta _actionMeta = const VerificationMeta('action'); - late final GeneratedColumn action = GeneratedColumn( - 'action', aliasedName, true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: ''); - static const VerificationMeta _participantIdMeta = - const VerificationMeta('participantId'); - late final GeneratedColumn participantId = GeneratedColumn( - 'participant_id', aliasedName, true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: ''); - static const VerificationMeta _snapshotIdMeta = - const VerificationMeta('snapshotId'); - late final GeneratedColumn snapshotId = GeneratedColumn( - 'snapshot_id', aliasedName, true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: ''); - static const VerificationMeta _hyperlinkMeta = - const VerificationMeta('hyperlink'); - late final GeneratedColumn hyperlink = GeneratedColumn( - 'hyperlink', aliasedName, true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: ''); - static const VerificationMeta _nameMeta = const VerificationMeta('name'); - late final GeneratedColumn name = GeneratedColumn( - 'name', aliasedName, true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: ''); - static const VerificationMeta _albumIdMeta = - const VerificationMeta('albumId'); - late final GeneratedColumn albumId = GeneratedColumn( - 'album_id', aliasedName, true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: ''); - static const VerificationMeta _stickerIdMeta = - const VerificationMeta('stickerId'); - late final GeneratedColumn stickerId = GeneratedColumn( - 'sticker_id', aliasedName, true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: ''); - static const VerificationMeta _sharedUserIdMeta = - const VerificationMeta('sharedUserId'); - late final GeneratedColumn sharedUserId = GeneratedColumn( - 'shared_user_id', aliasedName, true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: ''); - static const VerificationMeta _mediaWaveformMeta = - const VerificationMeta('mediaWaveform'); - late final GeneratedColumn mediaWaveform = GeneratedColumn( - 'media_waveform', aliasedName, true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: ''); - static const VerificationMeta _quoteMessageIdMeta = - const VerificationMeta('quoteMessageId'); - late final GeneratedColumn quoteMessageId = GeneratedColumn( - 'quote_message_id', aliasedName, true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: ''); - static const VerificationMeta _quoteContentMeta = - const VerificationMeta('quoteContent'); - late final GeneratedColumn quoteContent = GeneratedColumn( - 'quote_content', aliasedName, true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: ''); - static const VerificationMeta _thumbUrlMeta = - const VerificationMeta('thumbUrl'); - late final GeneratedColumn thumbUrl = GeneratedColumn( - 'thumb_url', aliasedName, true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: ''); - static const VerificationMeta _captionMeta = - const VerificationMeta('caption'); - late final GeneratedColumn caption = GeneratedColumn( - 'caption', aliasedName, true, + static const VerificationMeta _reserveMeta = + const VerificationMeta('reserve'); + late final GeneratedColumn reserve = GeneratedColumn( + 'reserve', aliasedName, true, type: DriftSqlType.string, requiredDuringInsert: false, $customConstraints: ''); @override List get $columns => [ - messageId, - conversationId, - userId, - category, - content, - mediaUrl, - mediaMimeType, - mediaSize, - mediaDuration, - mediaWidth, - mediaHeight, - mediaHash, - thumbImage, - mediaKey, - mediaDigest, - mediaStatus, - status, - createdAt, - action, - participantId, - snapshotId, - hyperlink, + assetId, + symbol, name, - albumId, - stickerId, - sharedUserId, - mediaWaveform, - quoteMessageId, - quoteContent, - thumbUrl, - caption + iconUrl, + balance, + destination, + tag, + priceBtc, + priceUsd, + chainId, + changeUsd, + changeBtc, + confirmations, + assetKey, + reserve ]; @override - String get aliasedName => _alias ?? 'messages'; + String get aliasedName => _alias ?? 'assets'; @override - String get actualTableName => 'messages'; + String get actualTableName => 'assets'; @override - VerificationContext validateIntegrity(Insertable instance, + VerificationContext validateIntegrity(Insertable instance, {bool isInserting = false}) { final context = VerificationContext(); final data = instance.toColumns(true); - if (data.containsKey('message_id')) { - context.handle(_messageIdMeta, - messageId.isAcceptableOrUnknown(data['message_id']!, _messageIdMeta)); + if (data.containsKey('asset_id')) { + context.handle(_assetIdMeta, + assetId.isAcceptableOrUnknown(data['asset_id']!, _assetIdMeta)); } else if (isInserting) { - context.missing(_messageIdMeta); + context.missing(_assetIdMeta); } - if (data.containsKey('conversation_id')) { - context.handle( - _conversationIdMeta, - conversationId.isAcceptableOrUnknown( - data['conversation_id']!, _conversationIdMeta)); + if (data.containsKey('symbol')) { + context.handle(_symbolMeta, + symbol.isAcceptableOrUnknown(data['symbol']!, _symbolMeta)); } else if (isInserting) { - context.missing(_conversationIdMeta); + context.missing(_symbolMeta); } - if (data.containsKey('user_id')) { - context.handle(_userIdMeta, - userId.isAcceptableOrUnknown(data['user_id']!, _userIdMeta)); + if (data.containsKey('name')) { + context.handle( + _nameMeta, name.isAcceptableOrUnknown(data['name']!, _nameMeta)); } else if (isInserting) { - context.missing(_userIdMeta); + context.missing(_nameMeta); } - if (data.containsKey('category')) { - context.handle(_categoryMeta, - category.isAcceptableOrUnknown(data['category']!, _categoryMeta)); + if (data.containsKey('icon_url')) { + context.handle(_iconUrlMeta, + iconUrl.isAcceptableOrUnknown(data['icon_url']!, _iconUrlMeta)); } else if (isInserting) { - context.missing(_categoryMeta); - } - if (data.containsKey('content')) { - context.handle(_contentMeta, - content.isAcceptableOrUnknown(data['content']!, _contentMeta)); + context.missing(_iconUrlMeta); } - if (data.containsKey('media_url')) { - context.handle(_mediaUrlMeta, - mediaUrl.isAcceptableOrUnknown(data['media_url']!, _mediaUrlMeta)); + if (data.containsKey('balance')) { + context.handle(_balanceMeta, + balance.isAcceptableOrUnknown(data['balance']!, _balanceMeta)); + } else if (isInserting) { + context.missing(_balanceMeta); } - if (data.containsKey('media_mime_type')) { + if (data.containsKey('destination')) { context.handle( - _mediaMimeTypeMeta, - mediaMimeType.isAcceptableOrUnknown( - data['media_mime_type']!, _mediaMimeTypeMeta)); - } - if (data.containsKey('media_size')) { - context.handle(_mediaSizeMeta, - mediaSize.isAcceptableOrUnknown(data['media_size']!, _mediaSizeMeta)); + _destinationMeta, + destination.isAcceptableOrUnknown( + data['destination']!, _destinationMeta)); + } else if (isInserting) { + context.missing(_destinationMeta); } - if (data.containsKey('media_duration')) { + if (data.containsKey('tag')) { context.handle( - _mediaDurationMeta, - mediaDuration.isAcceptableOrUnknown( - data['media_duration']!, _mediaDurationMeta)); + _tagMeta, tag.isAcceptableOrUnknown(data['tag']!, _tagMeta)); } - if (data.containsKey('media_width')) { - context.handle( - _mediaWidthMeta, - mediaWidth.isAcceptableOrUnknown( - data['media_width']!, _mediaWidthMeta)); + if (data.containsKey('price_btc')) { + context.handle(_priceBtcMeta, + priceBtc.isAcceptableOrUnknown(data['price_btc']!, _priceBtcMeta)); + } else if (isInserting) { + context.missing(_priceBtcMeta); } - if (data.containsKey('media_height')) { - context.handle( - _mediaHeightMeta, - mediaHeight.isAcceptableOrUnknown( - data['media_height']!, _mediaHeightMeta)); + if (data.containsKey('price_usd')) { + context.handle(_priceUsdMeta, + priceUsd.isAcceptableOrUnknown(data['price_usd']!, _priceUsdMeta)); + } else if (isInserting) { + context.missing(_priceUsdMeta); } - if (data.containsKey('media_hash')) { - context.handle(_mediaHashMeta, - mediaHash.isAcceptableOrUnknown(data['media_hash']!, _mediaHashMeta)); + if (data.containsKey('chain_id')) { + context.handle(_chainIdMeta, + chainId.isAcceptableOrUnknown(data['chain_id']!, _chainIdMeta)); + } else if (isInserting) { + context.missing(_chainIdMeta); } - if (data.containsKey('thumb_image')) { - context.handle( - _thumbImageMeta, - thumbImage.isAcceptableOrUnknown( - data['thumb_image']!, _thumbImageMeta)); + if (data.containsKey('change_usd')) { + context.handle(_changeUsdMeta, + changeUsd.isAcceptableOrUnknown(data['change_usd']!, _changeUsdMeta)); + } else if (isInserting) { + context.missing(_changeUsdMeta); } - if (data.containsKey('media_key')) { - context.handle(_mediaKeyMeta, - mediaKey.isAcceptableOrUnknown(data['media_key']!, _mediaKeyMeta)); + if (data.containsKey('change_btc')) { + context.handle(_changeBtcMeta, + changeBtc.isAcceptableOrUnknown(data['change_btc']!, _changeBtcMeta)); + } else if (isInserting) { + context.missing(_changeBtcMeta); } - if (data.containsKey('media_digest')) { + if (data.containsKey('confirmations')) { context.handle( - _mediaDigestMeta, - mediaDigest.isAcceptableOrUnknown( - data['media_digest']!, _mediaDigestMeta)); - } - context.handle(_mediaStatusMeta, const VerificationResult.success()); - context.handle(_statusMeta, const VerificationResult.success()); - context.handle(_createdAtMeta, const VerificationResult.success()); - if (data.containsKey('action')) { - context.handle(_actionMeta, - action.isAcceptableOrUnknown(data['action']!, _actionMeta)); - } - if (data.containsKey('participant_id')) { - context.handle( - _participantIdMeta, - participantId.isAcceptableOrUnknown( - data['participant_id']!, _participantIdMeta)); - } - if (data.containsKey('snapshot_id')) { - context.handle( - _snapshotIdMeta, - snapshotId.isAcceptableOrUnknown( - data['snapshot_id']!, _snapshotIdMeta)); - } - if (data.containsKey('hyperlink')) { - context.handle(_hyperlinkMeta, - hyperlink.isAcceptableOrUnknown(data['hyperlink']!, _hyperlinkMeta)); - } - if (data.containsKey('name')) { - context.handle( - _nameMeta, name.isAcceptableOrUnknown(data['name']!, _nameMeta)); - } - if (data.containsKey('album_id')) { - context.handle(_albumIdMeta, - albumId.isAcceptableOrUnknown(data['album_id']!, _albumIdMeta)); - } - if (data.containsKey('sticker_id')) { - context.handle(_stickerIdMeta, - stickerId.isAcceptableOrUnknown(data['sticker_id']!, _stickerIdMeta)); - } - if (data.containsKey('shared_user_id')) { - context.handle( - _sharedUserIdMeta, - sharedUserId.isAcceptableOrUnknown( - data['shared_user_id']!, _sharedUserIdMeta)); - } - if (data.containsKey('media_waveform')) { - context.handle( - _mediaWaveformMeta, - mediaWaveform.isAcceptableOrUnknown( - data['media_waveform']!, _mediaWaveformMeta)); - } - if (data.containsKey('quote_message_id')) { - context.handle( - _quoteMessageIdMeta, - quoteMessageId.isAcceptableOrUnknown( - data['quote_message_id']!, _quoteMessageIdMeta)); - } - if (data.containsKey('quote_content')) { - context.handle( - _quoteContentMeta, - quoteContent.isAcceptableOrUnknown( - data['quote_content']!, _quoteContentMeta)); + _confirmationsMeta, + confirmations.isAcceptableOrUnknown( + data['confirmations']!, _confirmationsMeta)); + } else if (isInserting) { + context.missing(_confirmationsMeta); } - if (data.containsKey('thumb_url')) { - context.handle(_thumbUrlMeta, - thumbUrl.isAcceptableOrUnknown(data['thumb_url']!, _thumbUrlMeta)); + if (data.containsKey('asset_key')) { + context.handle(_assetKeyMeta, + assetKey.isAcceptableOrUnknown(data['asset_key']!, _assetKeyMeta)); } - if (data.containsKey('caption')) { - context.handle(_captionMeta, - caption.isAcceptableOrUnknown(data['caption']!, _captionMeta)); + if (data.containsKey('reserve')) { + context.handle(_reserveMeta, + reserve.isAcceptableOrUnknown(data['reserve']!, _reserveMeta)); } return context; } @override - Set get $primaryKey => {messageId}; + Set get $primaryKey => {assetId}; @override - Message map(Map data, {String? tablePrefix}) { + Asset map(Map data, {String? tablePrefix}) { final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; - return Message( - messageId: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}message_id'])!, - conversationId: attachedDatabase.typeMapping.read( - DriftSqlType.string, data['${effectivePrefix}conversation_id'])!, - userId: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}user_id'])!, - category: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}category'])!, - content: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}content']), - mediaUrl: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}media_url']), - mediaMimeType: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}media_mime_type']), - mediaSize: attachedDatabase.typeMapping - .read(DriftSqlType.int, data['${effectivePrefix}media_size']), - mediaDuration: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}media_duration']), - mediaWidth: attachedDatabase.typeMapping - .read(DriftSqlType.int, data['${effectivePrefix}media_width']), - mediaHeight: attachedDatabase.typeMapping - .read(DriftSqlType.int, data['${effectivePrefix}media_height']), - mediaHash: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}media_hash']), - thumbImage: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}thumb_image']), - mediaKey: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}media_key']), - mediaDigest: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}media_digest']), - mediaStatus: Messages.$convertermediaStatus.fromSql(attachedDatabase - .typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}media_status'])), - status: Messages.$converterstatus.fromSql(attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}status'])!), - createdAt: Messages.$convertercreatedAt.fromSql(attachedDatabase - .typeMapping - .read(DriftSqlType.int, data['${effectivePrefix}created_at'])!), - action: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}action']), - participantId: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}participant_id']), - snapshotId: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}snapshot_id']), - hyperlink: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}hyperlink']), + return Asset( + assetId: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}asset_id'])!, + symbol: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}symbol'])!, name: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}name']), - albumId: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}album_id']), - stickerId: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}sticker_id']), - sharedUserId: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}shared_user_id']), - mediaWaveform: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}media_waveform']), - quoteMessageId: attachedDatabase.typeMapping.read( - DriftSqlType.string, data['${effectivePrefix}quote_message_id']), - quoteContent: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}quote_content']), - thumbUrl: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}thumb_url']), - caption: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}caption']), + .read(DriftSqlType.string, data['${effectivePrefix}name'])!, + iconUrl: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}icon_url'])!, + balance: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}balance'])!, + destination: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}destination'])!, + tag: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}tag']), + priceBtc: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}price_btc'])!, + priceUsd: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}price_usd'])!, + chainId: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}chain_id'])!, + changeUsd: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}change_usd'])!, + changeBtc: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}change_btc'])!, + confirmations: attachedDatabase.typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}confirmations'])!, + assetKey: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}asset_key']), + reserve: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}reserve']), ); } @override - Messages createAlias(String alias) { - return Messages(attachedDatabase, alias); + Assets createAlias(String alias) { + return Assets(attachedDatabase, alias); } - static TypeConverter $convertermediaStatus = - const MediaStatusTypeConverter(); - static TypeConverter $converterstatus = - const MessageStatusTypeConverter(); - static TypeConverter $convertercreatedAt = - const MillisDateConverter(); @override - List get customConstraints => const [ - 'PRIMARY KEY(message_id)', - 'FOREIGN KEY(conversation_id)REFERENCES conversations(conversation_id)ON UPDATE NO ACTION ON DELETE CASCADE' - ]; + List get customConstraints => const ['PRIMARY KEY(asset_id)']; @override bool get dontWriteConstraints => true; } -class Message extends DataClass implements Insertable { - final String messageId; - final String conversationId; - final String userId; - final String category; - final String? content; - final String? mediaUrl; - final String? mediaMimeType; - final int? mediaSize; - final String? mediaDuration; - final int? mediaWidth; - final int? mediaHeight; - final String? mediaHash; - final String? thumbImage; - final String? mediaKey; - final String? mediaDigest; - final MediaStatus? mediaStatus; - final MessageStatus status; - final DateTime createdAt; - final String? action; - final String? participantId; - final String? snapshotId; - final String? hyperlink; - final String? name; - final String? albumId; - final String? stickerId; - final String? sharedUserId; - final String? mediaWaveform; - final String? quoteMessageId; - final String? quoteContent; - final String? thumbUrl; - final String? caption; - const Message( - {required this.messageId, - required this.conversationId, - required this.userId, - required this.category, - this.content, - this.mediaUrl, - this.mediaMimeType, - this.mediaSize, - this.mediaDuration, - this.mediaWidth, - this.mediaHeight, - this.mediaHash, - this.thumbImage, - this.mediaKey, - this.mediaDigest, - this.mediaStatus, - required this.status, - required this.createdAt, - this.action, - this.participantId, - this.snapshotId, - this.hyperlink, - this.name, - this.albumId, - this.stickerId, - this.sharedUserId, - this.mediaWaveform, - this.quoteMessageId, - this.quoteContent, - this.thumbUrl, - this.caption}); - @override - Map toColumns(bool nullToAbsent) { - final map = {}; - map['message_id'] = Variable(messageId); - map['conversation_id'] = Variable(conversationId); - map['user_id'] = Variable(userId); - map['category'] = Variable(category); - if (!nullToAbsent || content != null) { - map['content'] = Variable(content); - } - if (!nullToAbsent || mediaUrl != null) { - map['media_url'] = Variable(mediaUrl); - } - if (!nullToAbsent || mediaMimeType != null) { - map['media_mime_type'] = Variable(mediaMimeType); - } - if (!nullToAbsent || mediaSize != null) { - map['media_size'] = Variable(mediaSize); - } - if (!nullToAbsent || mediaDuration != null) { - map['media_duration'] = Variable(mediaDuration); - } - if (!nullToAbsent || mediaWidth != null) { - map['media_width'] = Variable(mediaWidth); - } - if (!nullToAbsent || mediaHeight != null) { - map['media_height'] = Variable(mediaHeight); - } - if (!nullToAbsent || mediaHash != null) { - map['media_hash'] = Variable(mediaHash); - } - if (!nullToAbsent || thumbImage != null) { - map['thumb_image'] = Variable(thumbImage); - } - if (!nullToAbsent || mediaKey != null) { - map['media_key'] = Variable(mediaKey); - } - if (!nullToAbsent || mediaDigest != null) { - map['media_digest'] = Variable(mediaDigest); - } - if (!nullToAbsent || mediaStatus != null) { - final converter = Messages.$convertermediaStatus; - map['media_status'] = Variable(converter.toSql(mediaStatus)); - } - { - final converter = Messages.$converterstatus; - map['status'] = Variable(converter.toSql(status)); - } - { - final converter = Messages.$convertercreatedAt; - map['created_at'] = Variable(converter.toSql(createdAt)); - } - if (!nullToAbsent || action != null) { - map['action'] = Variable(action); - } - if (!nullToAbsent || participantId != null) { - map['participant_id'] = Variable(participantId); - } - if (!nullToAbsent || snapshotId != null) { - map['snapshot_id'] = Variable(snapshotId); - } - if (!nullToAbsent || hyperlink != null) { - map['hyperlink'] = Variable(hyperlink); - } - if (!nullToAbsent || name != null) { - map['name'] = Variable(name); - } - if (!nullToAbsent || albumId != null) { - map['album_id'] = Variable(albumId); - } - if (!nullToAbsent || stickerId != null) { - map['sticker_id'] = Variable(stickerId); - } - if (!nullToAbsent || sharedUserId != null) { - map['shared_user_id'] = Variable(sharedUserId); - } - if (!nullToAbsent || mediaWaveform != null) { - map['media_waveform'] = Variable(mediaWaveform); - } - if (!nullToAbsent || quoteMessageId != null) { - map['quote_message_id'] = Variable(quoteMessageId); - } - if (!nullToAbsent || quoteContent != null) { - map['quote_content'] = Variable(quoteContent); +class Asset extends DataClass implements Insertable { + final String assetId; + final String symbol; + final String name; + final String iconUrl; + final String balance; + final String destination; + final String? tag; + final String priceBtc; + final String priceUsd; + final String chainId; + final String changeUsd; + final String changeBtc; + final int confirmations; + final String? assetKey; + final String? reserve; + const Asset( + {required this.assetId, + required this.symbol, + required this.name, + required this.iconUrl, + required this.balance, + required this.destination, + this.tag, + required this.priceBtc, + required this.priceUsd, + required this.chainId, + required this.changeUsd, + required this.changeBtc, + required this.confirmations, + this.assetKey, + this.reserve}); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['asset_id'] = Variable(assetId); + map['symbol'] = Variable(symbol); + map['name'] = Variable(name); + map['icon_url'] = Variable(iconUrl); + map['balance'] = Variable(balance); + map['destination'] = Variable(destination); + if (!nullToAbsent || tag != null) { + map['tag'] = Variable(tag); } - if (!nullToAbsent || thumbUrl != null) { - map['thumb_url'] = Variable(thumbUrl); + map['price_btc'] = Variable(priceBtc); + map['price_usd'] = Variable(priceUsd); + map['chain_id'] = Variable(chainId); + map['change_usd'] = Variable(changeUsd); + map['change_btc'] = Variable(changeBtc); + map['confirmations'] = Variable(confirmations); + if (!nullToAbsent || assetKey != null) { + map['asset_key'] = Variable(assetKey); } - if (!nullToAbsent || caption != null) { - map['caption'] = Variable(caption); + if (!nullToAbsent || reserve != null) { + map['reserve'] = Variable(reserve); } return map; } - MessagesCompanion toCompanion(bool nullToAbsent) { - return MessagesCompanion( - messageId: Value(messageId), - conversationId: Value(conversationId), - userId: Value(userId), - category: Value(category), - content: content == null && nullToAbsent - ? const Value.absent() - : Value(content), - mediaUrl: mediaUrl == null && nullToAbsent - ? const Value.absent() - : Value(mediaUrl), - mediaMimeType: mediaMimeType == null && nullToAbsent - ? const Value.absent() - : Value(mediaMimeType), - mediaSize: mediaSize == null && nullToAbsent - ? const Value.absent() - : Value(mediaSize), - mediaDuration: mediaDuration == null && nullToAbsent - ? const Value.absent() - : Value(mediaDuration), - mediaWidth: mediaWidth == null && nullToAbsent - ? const Value.absent() - : Value(mediaWidth), - mediaHeight: mediaHeight == null && nullToAbsent - ? const Value.absent() - : Value(mediaHeight), - mediaHash: mediaHash == null && nullToAbsent - ? const Value.absent() - : Value(mediaHash), - thumbImage: thumbImage == null && nullToAbsent - ? const Value.absent() - : Value(thumbImage), - mediaKey: mediaKey == null && nullToAbsent - ? const Value.absent() - : Value(mediaKey), - mediaDigest: mediaDigest == null && nullToAbsent - ? const Value.absent() - : Value(mediaDigest), - mediaStatus: mediaStatus == null && nullToAbsent - ? const Value.absent() - : Value(mediaStatus), - status: Value(status), - createdAt: Value(createdAt), - action: - action == null && nullToAbsent ? const Value.absent() : Value(action), - participantId: participantId == null && nullToAbsent - ? const Value.absent() - : Value(participantId), - snapshotId: snapshotId == null && nullToAbsent - ? const Value.absent() - : Value(snapshotId), - hyperlink: hyperlink == null && nullToAbsent - ? const Value.absent() - : Value(hyperlink), - name: name == null && nullToAbsent ? const Value.absent() : Value(name), - albumId: albumId == null && nullToAbsent - ? const Value.absent() - : Value(albumId), - stickerId: stickerId == null && nullToAbsent - ? const Value.absent() - : Value(stickerId), - sharedUserId: sharedUserId == null && nullToAbsent - ? const Value.absent() - : Value(sharedUserId), - mediaWaveform: mediaWaveform == null && nullToAbsent - ? const Value.absent() - : Value(mediaWaveform), - quoteMessageId: quoteMessageId == null && nullToAbsent - ? const Value.absent() - : Value(quoteMessageId), - quoteContent: quoteContent == null && nullToAbsent - ? const Value.absent() - : Value(quoteContent), - thumbUrl: thumbUrl == null && nullToAbsent + AssetsCompanion toCompanion(bool nullToAbsent) { + return AssetsCompanion( + assetId: Value(assetId), + symbol: Value(symbol), + name: Value(name), + iconUrl: Value(iconUrl), + balance: Value(balance), + destination: Value(destination), + tag: tag == null && nullToAbsent ? const Value.absent() : Value(tag), + priceBtc: Value(priceBtc), + priceUsd: Value(priceUsd), + chainId: Value(chainId), + changeUsd: Value(changeUsd), + changeBtc: Value(changeBtc), + confirmations: Value(confirmations), + assetKey: assetKey == null && nullToAbsent ? const Value.absent() - : Value(thumbUrl), - caption: caption == null && nullToAbsent + : Value(assetKey), + reserve: reserve == null && nullToAbsent ? const Value.absent() - : Value(caption), + : Value(reserve), ); } - factory Message.fromJson(Map json, + factory Asset.fromJson(Map json, {ValueSerializer? serializer}) { serializer ??= driftRuntimeOptions.defaultSerializer; - return Message( - messageId: serializer.fromJson(json['message_id']), - conversationId: serializer.fromJson(json['conversation_id']), - userId: serializer.fromJson(json['user_id']), - category: serializer.fromJson(json['category']), - content: serializer.fromJson(json['content']), - mediaUrl: serializer.fromJson(json['media_url']), - mediaMimeType: serializer.fromJson(json['media_mime_type']), - mediaSize: serializer.fromJson(json['media_size']), - mediaDuration: serializer.fromJson(json['media_duration']), - mediaWidth: serializer.fromJson(json['media_width']), - mediaHeight: serializer.fromJson(json['media_height']), - mediaHash: serializer.fromJson(json['media_hash']), - thumbImage: serializer.fromJson(json['thumb_image']), - mediaKey: serializer.fromJson(json['media_key']), - mediaDigest: serializer.fromJson(json['media_digest']), - mediaStatus: serializer.fromJson(json['media_status']), - status: serializer.fromJson(json['status']), - createdAt: serializer.fromJson(json['created_at']), - action: serializer.fromJson(json['action']), - participantId: serializer.fromJson(json['participant_id']), - snapshotId: serializer.fromJson(json['snapshot_id']), - hyperlink: serializer.fromJson(json['hyperlink']), - name: serializer.fromJson(json['name']), - albumId: serializer.fromJson(json['album_id']), - stickerId: serializer.fromJson(json['sticker_id']), - sharedUserId: serializer.fromJson(json['shared_user_id']), - mediaWaveform: serializer.fromJson(json['media_waveform']), - quoteMessageId: serializer.fromJson(json['quote_message_id']), - quoteContent: serializer.fromJson(json['quote_content']), - thumbUrl: serializer.fromJson(json['thumb_url']), - caption: serializer.fromJson(json['caption']), + return Asset( + assetId: serializer.fromJson(json['asset_id']), + symbol: serializer.fromJson(json['symbol']), + name: serializer.fromJson(json['name']), + iconUrl: serializer.fromJson(json['icon_url']), + balance: serializer.fromJson(json['balance']), + destination: serializer.fromJson(json['destination']), + tag: serializer.fromJson(json['tag']), + priceBtc: serializer.fromJson(json['price_btc']), + priceUsd: serializer.fromJson(json['price_usd']), + chainId: serializer.fromJson(json['chain_id']), + changeUsd: serializer.fromJson(json['change_usd']), + changeBtc: serializer.fromJson(json['change_btc']), + confirmations: serializer.fromJson(json['confirmations']), + assetKey: serializer.fromJson(json['asset_key']), + reserve: serializer.fromJson(json['reserve']), ); } @override Map toJson({ValueSerializer? serializer}) { serializer ??= driftRuntimeOptions.defaultSerializer; return { - 'message_id': serializer.toJson(messageId), - 'conversation_id': serializer.toJson(conversationId), - 'user_id': serializer.toJson(userId), - 'category': serializer.toJson(category), - 'content': serializer.toJson(content), - 'media_url': serializer.toJson(mediaUrl), - 'media_mime_type': serializer.toJson(mediaMimeType), - 'media_size': serializer.toJson(mediaSize), - 'media_duration': serializer.toJson(mediaDuration), - 'media_width': serializer.toJson(mediaWidth), - 'media_height': serializer.toJson(mediaHeight), - 'media_hash': serializer.toJson(mediaHash), - 'thumb_image': serializer.toJson(thumbImage), - 'media_key': serializer.toJson(mediaKey), - 'media_digest': serializer.toJson(mediaDigest), - 'media_status': serializer.toJson(mediaStatus), - 'status': serializer.toJson(status), - 'created_at': serializer.toJson(createdAt), - 'action': serializer.toJson(action), - 'participant_id': serializer.toJson(participantId), - 'snapshot_id': serializer.toJson(snapshotId), - 'hyperlink': serializer.toJson(hyperlink), - 'name': serializer.toJson(name), - 'album_id': serializer.toJson(albumId), - 'sticker_id': serializer.toJson(stickerId), - 'shared_user_id': serializer.toJson(sharedUserId), - 'media_waveform': serializer.toJson(mediaWaveform), - 'quote_message_id': serializer.toJson(quoteMessageId), - 'quote_content': serializer.toJson(quoteContent), - 'thumb_url': serializer.toJson(thumbUrl), - 'caption': serializer.toJson(caption), + 'asset_id': serializer.toJson(assetId), + 'symbol': serializer.toJson(symbol), + 'name': serializer.toJson(name), + 'icon_url': serializer.toJson(iconUrl), + 'balance': serializer.toJson(balance), + 'destination': serializer.toJson(destination), + 'tag': serializer.toJson(tag), + 'price_btc': serializer.toJson(priceBtc), + 'price_usd': serializer.toJson(priceUsd), + 'chain_id': serializer.toJson(chainId), + 'change_usd': serializer.toJson(changeUsd), + 'change_btc': serializer.toJson(changeBtc), + 'confirmations': serializer.toJson(confirmations), + 'asset_key': serializer.toJson(assetKey), + 'reserve': serializer.toJson(reserve), }; } - Message copyWith( - {String? messageId, - String? conversationId, - String? userId, - String? category, - Value content = const Value.absent(), - Value mediaUrl = const Value.absent(), - Value mediaMimeType = const Value.absent(), - Value mediaSize = const Value.absent(), - Value mediaDuration = const Value.absent(), - Value mediaWidth = const Value.absent(), - Value mediaHeight = const Value.absent(), - Value mediaHash = const Value.absent(), - Value thumbImage = const Value.absent(), - Value mediaKey = const Value.absent(), - Value mediaDigest = const Value.absent(), - Value mediaStatus = const Value.absent(), - MessageStatus? status, - DateTime? createdAt, - Value action = const Value.absent(), - Value participantId = const Value.absent(), - Value snapshotId = const Value.absent(), - Value hyperlink = const Value.absent(), - Value name = const Value.absent(), - Value albumId = const Value.absent(), - Value stickerId = const Value.absent(), - Value sharedUserId = const Value.absent(), - Value mediaWaveform = const Value.absent(), - Value quoteMessageId = const Value.absent(), - Value quoteContent = const Value.absent(), - Value thumbUrl = const Value.absent(), - Value caption = const Value.absent()}) => - Message( - messageId: messageId ?? this.messageId, - conversationId: conversationId ?? this.conversationId, - userId: userId ?? this.userId, - category: category ?? this.category, - content: content.present ? content.value : this.content, - mediaUrl: mediaUrl.present ? mediaUrl.value : this.mediaUrl, - mediaMimeType: - mediaMimeType.present ? mediaMimeType.value : this.mediaMimeType, - mediaSize: mediaSize.present ? mediaSize.value : this.mediaSize, - mediaDuration: - mediaDuration.present ? mediaDuration.value : this.mediaDuration, - mediaWidth: mediaWidth.present ? mediaWidth.value : this.mediaWidth, - mediaHeight: mediaHeight.present ? mediaHeight.value : this.mediaHeight, - mediaHash: mediaHash.present ? mediaHash.value : this.mediaHash, - thumbImage: thumbImage.present ? thumbImage.value : this.thumbImage, - mediaKey: mediaKey.present ? mediaKey.value : this.mediaKey, - mediaDigest: mediaDigest.present ? mediaDigest.value : this.mediaDigest, - mediaStatus: mediaStatus.present ? mediaStatus.value : this.mediaStatus, - status: status ?? this.status, - createdAt: createdAt ?? this.createdAt, - action: action.present ? action.value : this.action, - participantId: - participantId.present ? participantId.value : this.participantId, - snapshotId: snapshotId.present ? snapshotId.value : this.snapshotId, - hyperlink: hyperlink.present ? hyperlink.value : this.hyperlink, - name: name.present ? name.value : this.name, - albumId: albumId.present ? albumId.value : this.albumId, - stickerId: stickerId.present ? stickerId.value : this.stickerId, - sharedUserId: - sharedUserId.present ? sharedUserId.value : this.sharedUserId, - mediaWaveform: - mediaWaveform.present ? mediaWaveform.value : this.mediaWaveform, - quoteMessageId: - quoteMessageId.present ? quoteMessageId.value : this.quoteMessageId, - quoteContent: - quoteContent.present ? quoteContent.value : this.quoteContent, - thumbUrl: thumbUrl.present ? thumbUrl.value : this.thumbUrl, - caption: caption.present ? caption.value : this.caption, + Asset copyWith( + {String? assetId, + String? symbol, + String? name, + String? iconUrl, + String? balance, + String? destination, + Value tag = const Value.absent(), + String? priceBtc, + String? priceUsd, + String? chainId, + String? changeUsd, + String? changeBtc, + int? confirmations, + Value assetKey = const Value.absent(), + Value reserve = const Value.absent()}) => + Asset( + assetId: assetId ?? this.assetId, + symbol: symbol ?? this.symbol, + name: name ?? this.name, + iconUrl: iconUrl ?? this.iconUrl, + balance: balance ?? this.balance, + destination: destination ?? this.destination, + tag: tag.present ? tag.value : this.tag, + priceBtc: priceBtc ?? this.priceBtc, + priceUsd: priceUsd ?? this.priceUsd, + chainId: chainId ?? this.chainId, + changeUsd: changeUsd ?? this.changeUsd, + changeBtc: changeBtc ?? this.changeBtc, + confirmations: confirmations ?? this.confirmations, + assetKey: assetKey.present ? assetKey.value : this.assetKey, + reserve: reserve.present ? reserve.value : this.reserve, ); @override String toString() { - return (StringBuffer('Message(') - ..write('messageId: $messageId, ') - ..write('conversationId: $conversationId, ') - ..write('userId: $userId, ') - ..write('category: $category, ') - ..write('content: $content, ') - ..write('mediaUrl: $mediaUrl, ') - ..write('mediaMimeType: $mediaMimeType, ') - ..write('mediaSize: $mediaSize, ') - ..write('mediaDuration: $mediaDuration, ') - ..write('mediaWidth: $mediaWidth, ') - ..write('mediaHeight: $mediaHeight, ') - ..write('mediaHash: $mediaHash, ') - ..write('thumbImage: $thumbImage, ') - ..write('mediaKey: $mediaKey, ') - ..write('mediaDigest: $mediaDigest, ') - ..write('mediaStatus: $mediaStatus, ') - ..write('status: $status, ') - ..write('createdAt: $createdAt, ') - ..write('action: $action, ') - ..write('participantId: $participantId, ') - ..write('snapshotId: $snapshotId, ') - ..write('hyperlink: $hyperlink, ') + return (StringBuffer('Asset(') + ..write('assetId: $assetId, ') + ..write('symbol: $symbol, ') ..write('name: $name, ') - ..write('albumId: $albumId, ') - ..write('stickerId: $stickerId, ') - ..write('sharedUserId: $sharedUserId, ') - ..write('mediaWaveform: $mediaWaveform, ') - ..write('quoteMessageId: $quoteMessageId, ') - ..write('quoteContent: $quoteContent, ') - ..write('thumbUrl: $thumbUrl, ') - ..write('caption: $caption') + ..write('iconUrl: $iconUrl, ') + ..write('balance: $balance, ') + ..write('destination: $destination, ') + ..write('tag: $tag, ') + ..write('priceBtc: $priceBtc, ') + ..write('priceUsd: $priceUsd, ') + ..write('chainId: $chainId, ') + ..write('changeUsd: $changeUsd, ') + ..write('changeBtc: $changeBtc, ') + ..write('confirmations: $confirmations, ') + ..write('assetKey: $assetKey, ') + ..write('reserve: $reserve') ..write(')')) .toString(); } @override - int get hashCode => Object.hashAll([ - messageId, - conversationId, - userId, - category, - content, - mediaUrl, - mediaMimeType, - mediaSize, - mediaDuration, - mediaWidth, - mediaHeight, - mediaHash, - thumbImage, - mediaKey, - mediaDigest, - mediaStatus, - status, - createdAt, - action, - participantId, - snapshotId, - hyperlink, - name, - albumId, - stickerId, - sharedUserId, - mediaWaveform, - quoteMessageId, - quoteContent, - thumbUrl, - caption - ]); + int get hashCode => Object.hash( + assetId, + symbol, + name, + iconUrl, + balance, + destination, + tag, + priceBtc, + priceUsd, + chainId, + changeUsd, + changeBtc, + confirmations, + assetKey, + reserve); @override bool operator ==(Object other) => identical(this, other) || - (other is Message && - other.messageId == this.messageId && - other.conversationId == this.conversationId && - other.userId == this.userId && - other.category == this.category && - other.content == this.content && - other.mediaUrl == this.mediaUrl && - other.mediaMimeType == this.mediaMimeType && - other.mediaSize == this.mediaSize && - other.mediaDuration == this.mediaDuration && - other.mediaWidth == this.mediaWidth && - other.mediaHeight == this.mediaHeight && - other.mediaHash == this.mediaHash && - other.thumbImage == this.thumbImage && - other.mediaKey == this.mediaKey && - other.mediaDigest == this.mediaDigest && - other.mediaStatus == this.mediaStatus && - other.status == this.status && - other.createdAt == this.createdAt && - other.action == this.action && - other.participantId == this.participantId && - other.snapshotId == this.snapshotId && - other.hyperlink == this.hyperlink && + (other is Asset && + other.assetId == this.assetId && + other.symbol == this.symbol && other.name == this.name && - other.albumId == this.albumId && - other.stickerId == this.stickerId && - other.sharedUserId == this.sharedUserId && - other.mediaWaveform == this.mediaWaveform && - other.quoteMessageId == this.quoteMessageId && - other.quoteContent == this.quoteContent && - other.thumbUrl == this.thumbUrl && - other.caption == this.caption); + other.iconUrl == this.iconUrl && + other.balance == this.balance && + other.destination == this.destination && + other.tag == this.tag && + other.priceBtc == this.priceBtc && + other.priceUsd == this.priceUsd && + other.chainId == this.chainId && + other.changeUsd == this.changeUsd && + other.changeBtc == this.changeBtc && + other.confirmations == this.confirmations && + other.assetKey == this.assetKey && + other.reserve == this.reserve); } -class MessagesCompanion extends UpdateCompanion { - final Value messageId; - final Value conversationId; - final Value userId; - final Value category; - final Value content; - final Value mediaUrl; - final Value mediaMimeType; - final Value mediaSize; - final Value mediaDuration; - final Value mediaWidth; - final Value mediaHeight; - final Value mediaHash; - final Value thumbImage; - final Value mediaKey; - final Value mediaDigest; - final Value mediaStatus; - final Value status; - final Value createdAt; - final Value action; - final Value participantId; - final Value snapshotId; - final Value hyperlink; - final Value name; - final Value albumId; - final Value stickerId; - final Value sharedUserId; - final Value mediaWaveform; - final Value quoteMessageId; - final Value quoteContent; - final Value thumbUrl; - final Value caption; +class AssetsCompanion extends UpdateCompanion { + final Value assetId; + final Value symbol; + final Value name; + final Value iconUrl; + final Value balance; + final Value destination; + final Value tag; + final Value priceBtc; + final Value priceUsd; + final Value chainId; + final Value changeUsd; + final Value changeBtc; + final Value confirmations; + final Value assetKey; + final Value reserve; final Value rowid; - const MessagesCompanion({ - this.messageId = const Value.absent(), - this.conversationId = const Value.absent(), - this.userId = const Value.absent(), - this.category = const Value.absent(), - this.content = const Value.absent(), - this.mediaUrl = const Value.absent(), - this.mediaMimeType = const Value.absent(), - this.mediaSize = const Value.absent(), - this.mediaDuration = const Value.absent(), - this.mediaWidth = const Value.absent(), - this.mediaHeight = const Value.absent(), - this.mediaHash = const Value.absent(), - this.thumbImage = const Value.absent(), - this.mediaKey = const Value.absent(), - this.mediaDigest = const Value.absent(), - this.mediaStatus = const Value.absent(), - this.status = const Value.absent(), - this.createdAt = const Value.absent(), - this.action = const Value.absent(), - this.participantId = const Value.absent(), - this.snapshotId = const Value.absent(), - this.hyperlink = const Value.absent(), + const AssetsCompanion({ + this.assetId = const Value.absent(), + this.symbol = const Value.absent(), this.name = const Value.absent(), - this.albumId = const Value.absent(), - this.stickerId = const Value.absent(), - this.sharedUserId = const Value.absent(), - this.mediaWaveform = const Value.absent(), - this.quoteMessageId = const Value.absent(), - this.quoteContent = const Value.absent(), - this.thumbUrl = const Value.absent(), - this.caption = const Value.absent(), + this.iconUrl = const Value.absent(), + this.balance = const Value.absent(), + this.destination = const Value.absent(), + this.tag = const Value.absent(), + this.priceBtc = const Value.absent(), + this.priceUsd = const Value.absent(), + this.chainId = const Value.absent(), + this.changeUsd = const Value.absent(), + this.changeBtc = const Value.absent(), + this.confirmations = const Value.absent(), + this.assetKey = const Value.absent(), + this.reserve = const Value.absent(), this.rowid = const Value.absent(), }); - MessagesCompanion.insert({ - required String messageId, - required String conversationId, - required String userId, - required String category, - this.content = const Value.absent(), - this.mediaUrl = const Value.absent(), - this.mediaMimeType = const Value.absent(), - this.mediaSize = const Value.absent(), - this.mediaDuration = const Value.absent(), - this.mediaWidth = const Value.absent(), - this.mediaHeight = const Value.absent(), - this.mediaHash = const Value.absent(), - this.thumbImage = const Value.absent(), - this.mediaKey = const Value.absent(), - this.mediaDigest = const Value.absent(), - this.mediaStatus = const Value.absent(), - required MessageStatus status, - required DateTime createdAt, - this.action = const Value.absent(), - this.participantId = const Value.absent(), - this.snapshotId = const Value.absent(), - this.hyperlink = const Value.absent(), - this.name = const Value.absent(), - this.albumId = const Value.absent(), - this.stickerId = const Value.absent(), - this.sharedUserId = const Value.absent(), - this.mediaWaveform = const Value.absent(), - this.quoteMessageId = const Value.absent(), - this.quoteContent = const Value.absent(), - this.thumbUrl = const Value.absent(), - this.caption = const Value.absent(), + AssetsCompanion.insert({ + required String assetId, + required String symbol, + required String name, + required String iconUrl, + required String balance, + required String destination, + this.tag = const Value.absent(), + required String priceBtc, + required String priceUsd, + required String chainId, + required String changeUsd, + required String changeBtc, + required int confirmations, + this.assetKey = const Value.absent(), + this.reserve = const Value.absent(), this.rowid = const Value.absent(), - }) : messageId = Value(messageId), - conversationId = Value(conversationId), - userId = Value(userId), - category = Value(category), - status = Value(status), - createdAt = Value(createdAt); - static Insertable custom({ - Expression? messageId, - Expression? conversationId, - Expression? userId, - Expression? category, - Expression? content, - Expression? mediaUrl, - Expression? mediaMimeType, - Expression? mediaSize, - Expression? mediaDuration, - Expression? mediaWidth, - Expression? mediaHeight, - Expression? mediaHash, - Expression? thumbImage, - Expression? mediaKey, - Expression? mediaDigest, - Expression? mediaStatus, - Expression? status, - Expression? createdAt, - Expression? action, - Expression? participantId, - Expression? snapshotId, - Expression? hyperlink, + }) : assetId = Value(assetId), + symbol = Value(symbol), + name = Value(name), + iconUrl = Value(iconUrl), + balance = Value(balance), + destination = Value(destination), + priceBtc = Value(priceBtc), + priceUsd = Value(priceUsd), + chainId = Value(chainId), + changeUsd = Value(changeUsd), + changeBtc = Value(changeBtc), + confirmations = Value(confirmations); + static Insertable custom({ + Expression? assetId, + Expression? symbol, Expression? name, - Expression? albumId, - Expression? stickerId, - Expression? sharedUserId, - Expression? mediaWaveform, - Expression? quoteMessageId, - Expression? quoteContent, - Expression? thumbUrl, - Expression? caption, + Expression? iconUrl, + Expression? balance, + Expression? destination, + Expression? tag, + Expression? priceBtc, + Expression? priceUsd, + Expression? chainId, + Expression? changeUsd, + Expression? changeBtc, + Expression? confirmations, + Expression? assetKey, + Expression? reserve, Expression? rowid, }) { return RawValuesInsertable({ - if (messageId != null) 'message_id': messageId, - if (conversationId != null) 'conversation_id': conversationId, - if (userId != null) 'user_id': userId, - if (category != null) 'category': category, - if (content != null) 'content': content, - if (mediaUrl != null) 'media_url': mediaUrl, - if (mediaMimeType != null) 'media_mime_type': mediaMimeType, - if (mediaSize != null) 'media_size': mediaSize, - if (mediaDuration != null) 'media_duration': mediaDuration, - if (mediaWidth != null) 'media_width': mediaWidth, - if (mediaHeight != null) 'media_height': mediaHeight, - if (mediaHash != null) 'media_hash': mediaHash, - if (thumbImage != null) 'thumb_image': thumbImage, - if (mediaKey != null) 'media_key': mediaKey, - if (mediaDigest != null) 'media_digest': mediaDigest, - if (mediaStatus != null) 'media_status': mediaStatus, - if (status != null) 'status': status, - if (createdAt != null) 'created_at': createdAt, - if (action != null) 'action': action, - if (participantId != null) 'participant_id': participantId, - if (snapshotId != null) 'snapshot_id': snapshotId, - if (hyperlink != null) 'hyperlink': hyperlink, + if (assetId != null) 'asset_id': assetId, + if (symbol != null) 'symbol': symbol, if (name != null) 'name': name, - if (albumId != null) 'album_id': albumId, - if (stickerId != null) 'sticker_id': stickerId, - if (sharedUserId != null) 'shared_user_id': sharedUserId, - if (mediaWaveform != null) 'media_waveform': mediaWaveform, - if (quoteMessageId != null) 'quote_message_id': quoteMessageId, - if (quoteContent != null) 'quote_content': quoteContent, - if (thumbUrl != null) 'thumb_url': thumbUrl, - if (caption != null) 'caption': caption, + if (iconUrl != null) 'icon_url': iconUrl, + if (balance != null) 'balance': balance, + if (destination != null) 'destination': destination, + if (tag != null) 'tag': tag, + if (priceBtc != null) 'price_btc': priceBtc, + if (priceUsd != null) 'price_usd': priceUsd, + if (chainId != null) 'chain_id': chainId, + if (changeUsd != null) 'change_usd': changeUsd, + if (changeBtc != null) 'change_btc': changeBtc, + if (confirmations != null) 'confirmations': confirmations, + if (assetKey != null) 'asset_key': assetKey, + if (reserve != null) 'reserve': reserve, if (rowid != null) 'rowid': rowid, }); } - MessagesCompanion copyWith( - {Value? messageId, - Value? conversationId, - Value? userId, - Value? category, - Value? content, - Value? mediaUrl, - Value? mediaMimeType, - Value? mediaSize, - Value? mediaDuration, - Value? mediaWidth, - Value? mediaHeight, - Value? mediaHash, - Value? thumbImage, - Value? mediaKey, - Value? mediaDigest, - Value? mediaStatus, - Value? status, - Value? createdAt, - Value? action, - Value? participantId, - Value? snapshotId, - Value? hyperlink, - Value? name, - Value? albumId, - Value? stickerId, - Value? sharedUserId, - Value? mediaWaveform, - Value? quoteMessageId, - Value? quoteContent, - Value? thumbUrl, - Value? caption, + AssetsCompanion copyWith( + {Value? assetId, + Value? symbol, + Value? name, + Value? iconUrl, + Value? balance, + Value? destination, + Value? tag, + Value? priceBtc, + Value? priceUsd, + Value? chainId, + Value? changeUsd, + Value? changeBtc, + Value? confirmations, + Value? assetKey, + Value? reserve, Value? rowid}) { - return MessagesCompanion( - messageId: messageId ?? this.messageId, - conversationId: conversationId ?? this.conversationId, - userId: userId ?? this.userId, - category: category ?? this.category, - content: content ?? this.content, - mediaUrl: mediaUrl ?? this.mediaUrl, - mediaMimeType: mediaMimeType ?? this.mediaMimeType, - mediaSize: mediaSize ?? this.mediaSize, - mediaDuration: mediaDuration ?? this.mediaDuration, - mediaWidth: mediaWidth ?? this.mediaWidth, - mediaHeight: mediaHeight ?? this.mediaHeight, - mediaHash: mediaHash ?? this.mediaHash, - thumbImage: thumbImage ?? this.thumbImage, - mediaKey: mediaKey ?? this.mediaKey, - mediaDigest: mediaDigest ?? this.mediaDigest, - mediaStatus: mediaStatus ?? this.mediaStatus, - status: status ?? this.status, - createdAt: createdAt ?? this.createdAt, - action: action ?? this.action, - participantId: participantId ?? this.participantId, - snapshotId: snapshotId ?? this.snapshotId, - hyperlink: hyperlink ?? this.hyperlink, + return AssetsCompanion( + assetId: assetId ?? this.assetId, + symbol: symbol ?? this.symbol, name: name ?? this.name, - albumId: albumId ?? this.albumId, - stickerId: stickerId ?? this.stickerId, - sharedUserId: sharedUserId ?? this.sharedUserId, - mediaWaveform: mediaWaveform ?? this.mediaWaveform, - quoteMessageId: quoteMessageId ?? this.quoteMessageId, - quoteContent: quoteContent ?? this.quoteContent, - thumbUrl: thumbUrl ?? this.thumbUrl, - caption: caption ?? this.caption, + iconUrl: iconUrl ?? this.iconUrl, + balance: balance ?? this.balance, + destination: destination ?? this.destination, + tag: tag ?? this.tag, + priceBtc: priceBtc ?? this.priceBtc, + priceUsd: priceUsd ?? this.priceUsd, + chainId: chainId ?? this.chainId, + changeUsd: changeUsd ?? this.changeUsd, + changeBtc: changeBtc ?? this.changeBtc, + confirmations: confirmations ?? this.confirmations, + assetKey: assetKey ?? this.assetKey, + reserve: reserve ?? this.reserve, rowid: rowid ?? this.rowid, ); } @@ -4041,792 +4389,346 @@ class MessagesCompanion extends UpdateCompanion { @override Map toColumns(bool nullToAbsent) { final map = {}; - if (messageId.present) { - map['message_id'] = Variable(messageId.value); - } - if (conversationId.present) { - map['conversation_id'] = Variable(conversationId.value); - } - if (userId.present) { - map['user_id'] = Variable(userId.value); - } - if (category.present) { - map['category'] = Variable(category.value); - } - if (content.present) { - map['content'] = Variable(content.value); - } - if (mediaUrl.present) { - map['media_url'] = Variable(mediaUrl.value); - } - if (mediaMimeType.present) { - map['media_mime_type'] = Variable(mediaMimeType.value); - } - if (mediaSize.present) { - map['media_size'] = Variable(mediaSize.value); - } - if (mediaDuration.present) { - map['media_duration'] = Variable(mediaDuration.value); - } - if (mediaWidth.present) { - map['media_width'] = Variable(mediaWidth.value); - } - if (mediaHeight.present) { - map['media_height'] = Variable(mediaHeight.value); - } - if (mediaHash.present) { - map['media_hash'] = Variable(mediaHash.value); - } - if (thumbImage.present) { - map['thumb_image'] = Variable(thumbImage.value); + if (assetId.present) { + map['asset_id'] = Variable(assetId.value); } - if (mediaKey.present) { - map['media_key'] = Variable(mediaKey.value); + if (symbol.present) { + map['symbol'] = Variable(symbol.value); } - if (mediaDigest.present) { - map['media_digest'] = Variable(mediaDigest.value); + if (name.present) { + map['name'] = Variable(name.value); } - if (mediaStatus.present) { - final converter = Messages.$convertermediaStatus; - map['media_status'] = - Variable(converter.toSql(mediaStatus.value)); + if (iconUrl.present) { + map['icon_url'] = Variable(iconUrl.value); } - if (status.present) { - final converter = Messages.$converterstatus; - map['status'] = Variable(converter.toSql(status.value)); + if (balance.present) { + map['balance'] = Variable(balance.value); } - if (createdAt.present) { - final converter = Messages.$convertercreatedAt; - map['created_at'] = Variable(converter.toSql(createdAt.value)); + if (destination.present) { + map['destination'] = Variable(destination.value); } - if (action.present) { - map['action'] = Variable(action.value); + if (tag.present) { + map['tag'] = Variable(tag.value); } - if (participantId.present) { - map['participant_id'] = Variable(participantId.value); + if (priceBtc.present) { + map['price_btc'] = Variable(priceBtc.value); } - if (snapshotId.present) { - map['snapshot_id'] = Variable(snapshotId.value); + if (priceUsd.present) { + map['price_usd'] = Variable(priceUsd.value); } - if (hyperlink.present) { - map['hyperlink'] = Variable(hyperlink.value); + if (chainId.present) { + map['chain_id'] = Variable(chainId.value); } - if (name.present) { - map['name'] = Variable(name.value); + if (changeUsd.present) { + map['change_usd'] = Variable(changeUsd.value); } - if (albumId.present) { - map['album_id'] = Variable(albumId.value); + if (changeBtc.present) { + map['change_btc'] = Variable(changeBtc.value); } - if (stickerId.present) { - map['sticker_id'] = Variable(stickerId.value); + if (confirmations.present) { + map['confirmations'] = Variable(confirmations.value); } - if (sharedUserId.present) { - map['shared_user_id'] = Variable(sharedUserId.value); + if (assetKey.present) { + map['asset_key'] = Variable(assetKey.value); } - if (mediaWaveform.present) { - map['media_waveform'] = Variable(mediaWaveform.value); + if (reserve.present) { + map['reserve'] = Variable(reserve.value); } - if (quoteMessageId.present) { - map['quote_message_id'] = Variable(quoteMessageId.value); - } - if (quoteContent.present) { - map['quote_content'] = Variable(quoteContent.value); - } - if (thumbUrl.present) { - map['thumb_url'] = Variable(thumbUrl.value); - } - if (caption.present) { - map['caption'] = Variable(caption.value); - } - if (rowid.present) { - map['rowid'] = Variable(rowid.value); + if (rowid.present) { + map['rowid'] = Variable(rowid.value); } return map; } @override String toString() { - return (StringBuffer('MessagesCompanion(') - ..write('messageId: $messageId, ') - ..write('conversationId: $conversationId, ') - ..write('userId: $userId, ') - ..write('category: $category, ') - ..write('content: $content, ') - ..write('mediaUrl: $mediaUrl, ') - ..write('mediaMimeType: $mediaMimeType, ') - ..write('mediaSize: $mediaSize, ') - ..write('mediaDuration: $mediaDuration, ') - ..write('mediaWidth: $mediaWidth, ') - ..write('mediaHeight: $mediaHeight, ') - ..write('mediaHash: $mediaHash, ') - ..write('thumbImage: $thumbImage, ') - ..write('mediaKey: $mediaKey, ') - ..write('mediaDigest: $mediaDigest, ') - ..write('mediaStatus: $mediaStatus, ') - ..write('status: $status, ') - ..write('createdAt: $createdAt, ') - ..write('action: $action, ') - ..write('participantId: $participantId, ') - ..write('snapshotId: $snapshotId, ') - ..write('hyperlink: $hyperlink, ') + return (StringBuffer('AssetsCompanion(') + ..write('assetId: $assetId, ') + ..write('symbol: $symbol, ') ..write('name: $name, ') - ..write('albumId: $albumId, ') - ..write('stickerId: $stickerId, ') - ..write('sharedUserId: $sharedUserId, ') - ..write('mediaWaveform: $mediaWaveform, ') - ..write('quoteMessageId: $quoteMessageId, ') - ..write('quoteContent: $quoteContent, ') - ..write('thumbUrl: $thumbUrl, ') - ..write('caption: $caption, ') + ..write('iconUrl: $iconUrl, ') + ..write('balance: $balance, ') + ..write('destination: $destination, ') + ..write('tag: $tag, ') + ..write('priceBtc: $priceBtc, ') + ..write('priceUsd: $priceUsd, ') + ..write('chainId: $chainId, ') + ..write('changeUsd: $changeUsd, ') + ..write('changeBtc: $changeBtc, ') + ..write('confirmations: $confirmations, ') + ..write('assetKey: $assetKey, ') + ..write('reserve: $reserve, ') ..write('rowid: $rowid') ..write(')')) .toString(); } } -class Users extends Table with TableInfo { +class Chains extends Table with TableInfo { @override final GeneratedDatabase attachedDatabase; final String? _alias; - Users(this.attachedDatabase, [this._alias]); - static const VerificationMeta _userIdMeta = const VerificationMeta('userId'); - late final GeneratedColumn userId = GeneratedColumn( - 'user_id', aliasedName, false, + Chains(this.attachedDatabase, [this._alias]); + static const VerificationMeta _chainIdMeta = + const VerificationMeta('chainId'); + late final GeneratedColumn chainId = GeneratedColumn( + 'chain_id', aliasedName, false, type: DriftSqlType.string, requiredDuringInsert: true, $customConstraints: 'NOT NULL'); - static const VerificationMeta _identityNumberMeta = - const VerificationMeta('identityNumber'); - late final GeneratedColumn identityNumber = GeneratedColumn( - 'identity_number', aliasedName, false, + static const VerificationMeta _nameMeta = const VerificationMeta('name'); + late final GeneratedColumn name = GeneratedColumn( + 'name', aliasedName, false, type: DriftSqlType.string, requiredDuringInsert: true, $customConstraints: 'NOT NULL'); - static const VerificationMeta _relationshipMeta = - const VerificationMeta('relationship'); - late final GeneratedColumnWithTypeConverter - relationship = GeneratedColumn('relationship', aliasedName, true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: '') - .withConverter(Users.$converterrelationship); - static const VerificationMeta _fullNameMeta = - const VerificationMeta('fullName'); - late final GeneratedColumn fullName = GeneratedColumn( - 'full_name', aliasedName, true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: ''); - static const VerificationMeta _avatarUrlMeta = - const VerificationMeta('avatarUrl'); - late final GeneratedColumn avatarUrl = GeneratedColumn( - 'avatar_url', aliasedName, true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: ''); - static const VerificationMeta _phoneMeta = const VerificationMeta('phone'); - late final GeneratedColumn phone = GeneratedColumn( - 'phone', aliasedName, true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: ''); - static const VerificationMeta _isVerifiedMeta = - const VerificationMeta('isVerified'); - late final GeneratedColumn isVerified = GeneratedColumn( - 'is_verified', aliasedName, true, - type: DriftSqlType.bool, - requiredDuringInsert: false, - $customConstraints: ''); - static const VerificationMeta _createdAtMeta = - const VerificationMeta('createdAt'); - late final GeneratedColumnWithTypeConverter createdAt = - GeneratedColumn('created_at', aliasedName, true, - type: DriftSqlType.int, - requiredDuringInsert: false, - $customConstraints: '') - .withConverter(Users.$convertercreatedAtn); - static const VerificationMeta _muteUntilMeta = - const VerificationMeta('muteUntil'); - late final GeneratedColumnWithTypeConverter muteUntil = - GeneratedColumn('mute_until', aliasedName, true, - type: DriftSqlType.int, - requiredDuringInsert: false, - $customConstraints: '') - .withConverter(Users.$convertermuteUntiln); - static const VerificationMeta _hasPinMeta = const VerificationMeta('hasPin'); - late final GeneratedColumn hasPin = GeneratedColumn( - 'has_pin', aliasedName, true, - type: DriftSqlType.int, - requiredDuringInsert: false, - $customConstraints: ''); - static const VerificationMeta _appIdMeta = const VerificationMeta('appId'); - late final GeneratedColumn appId = GeneratedColumn( - 'app_id', aliasedName, true, + static const VerificationMeta _symbolMeta = const VerificationMeta('symbol'); + late final GeneratedColumn symbol = GeneratedColumn( + 'symbol', aliasedName, false, type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: ''); - static const VerificationMeta _biographyMeta = - const VerificationMeta('biography'); - late final GeneratedColumn biography = GeneratedColumn( - 'biography', aliasedName, true, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL'); + static const VerificationMeta _iconUrlMeta = + const VerificationMeta('iconUrl'); + late final GeneratedColumn iconUrl = GeneratedColumn( + 'icon_url', aliasedName, false, type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: ''); - static const VerificationMeta _isScamMeta = const VerificationMeta('isScam'); - late final GeneratedColumn isScam = GeneratedColumn( - 'is_scam', aliasedName, true, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL'); + static const VerificationMeta _thresholdMeta = + const VerificationMeta('threshold'); + late final GeneratedColumn threshold = GeneratedColumn( + 'threshold', aliasedName, false, type: DriftSqlType.int, - requiredDuringInsert: false, - $customConstraints: ''); - static const VerificationMeta _codeUrlMeta = - const VerificationMeta('codeUrl'); - late final GeneratedColumn codeUrl = GeneratedColumn( - 'code_url', aliasedName, true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: ''); - static const VerificationMeta _codeIdMeta = const VerificationMeta('codeId'); - late final GeneratedColumn codeId = GeneratedColumn( - 'code_id', aliasedName, true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: ''); + requiredDuringInsert: true, + $customConstraints: 'NOT NULL'); @override - List get $columns => [ - userId, - identityNumber, - relationship, - fullName, - avatarUrl, - phone, - isVerified, - createdAt, - muteUntil, - hasPin, - appId, - biography, - isScam, - codeUrl, - codeId - ]; + List get $columns => + [chainId, name, symbol, iconUrl, threshold]; @override - String get aliasedName => _alias ?? 'users'; + String get aliasedName => _alias ?? 'chains'; @override - String get actualTableName => 'users'; + String get actualTableName => 'chains'; @override - VerificationContext validateIntegrity(Insertable instance, + VerificationContext validateIntegrity(Insertable instance, {bool isInserting = false}) { final context = VerificationContext(); final data = instance.toColumns(true); - if (data.containsKey('user_id')) { - context.handle(_userIdMeta, - userId.isAcceptableOrUnknown(data['user_id']!, _userIdMeta)); + if (data.containsKey('chain_id')) { + context.handle(_chainIdMeta, + chainId.isAcceptableOrUnknown(data['chain_id']!, _chainIdMeta)); } else if (isInserting) { - context.missing(_userIdMeta); + context.missing(_chainIdMeta); } - if (data.containsKey('identity_number')) { + if (data.containsKey('name')) { context.handle( - _identityNumberMeta, - identityNumber.isAcceptableOrUnknown( - data['identity_number']!, _identityNumberMeta)); + _nameMeta, name.isAcceptableOrUnknown(data['name']!, _nameMeta)); } else if (isInserting) { - context.missing(_identityNumberMeta); - } - context.handle(_relationshipMeta, const VerificationResult.success()); - if (data.containsKey('full_name')) { - context.handle(_fullNameMeta, - fullName.isAcceptableOrUnknown(data['full_name']!, _fullNameMeta)); - } - if (data.containsKey('avatar_url')) { - context.handle(_avatarUrlMeta, - avatarUrl.isAcceptableOrUnknown(data['avatar_url']!, _avatarUrlMeta)); + context.missing(_nameMeta); } - if (data.containsKey('phone')) { - context.handle( - _phoneMeta, phone.isAcceptableOrUnknown(data['phone']!, _phoneMeta)); + if (data.containsKey('symbol')) { + context.handle(_symbolMeta, + symbol.isAcceptableOrUnknown(data['symbol']!, _symbolMeta)); + } else if (isInserting) { + context.missing(_symbolMeta); } - if (data.containsKey('is_verified')) { - context.handle( - _isVerifiedMeta, - isVerified.isAcceptableOrUnknown( - data['is_verified']!, _isVerifiedMeta)); + if (data.containsKey('icon_url')) { + context.handle(_iconUrlMeta, + iconUrl.isAcceptableOrUnknown(data['icon_url']!, _iconUrlMeta)); + } else if (isInserting) { + context.missing(_iconUrlMeta); } - context.handle(_createdAtMeta, const VerificationResult.success()); - context.handle(_muteUntilMeta, const VerificationResult.success()); - if (data.containsKey('has_pin')) { - context.handle(_hasPinMeta, - hasPin.isAcceptableOrUnknown(data['has_pin']!, _hasPinMeta)); - } - if (data.containsKey('app_id')) { - context.handle( - _appIdMeta, appId.isAcceptableOrUnknown(data['app_id']!, _appIdMeta)); - } - if (data.containsKey('biography')) { - context.handle(_biographyMeta, - biography.isAcceptableOrUnknown(data['biography']!, _biographyMeta)); - } - if (data.containsKey('is_scam')) { - context.handle(_isScamMeta, - isScam.isAcceptableOrUnknown(data['is_scam']!, _isScamMeta)); - } - if (data.containsKey('code_url')) { - context.handle(_codeUrlMeta, - codeUrl.isAcceptableOrUnknown(data['code_url']!, _codeUrlMeta)); - } - if (data.containsKey('code_id')) { - context.handle(_codeIdMeta, - codeId.isAcceptableOrUnknown(data['code_id']!, _codeIdMeta)); + if (data.containsKey('threshold')) { + context.handle(_thresholdMeta, + threshold.isAcceptableOrUnknown(data['threshold']!, _thresholdMeta)); + } else if (isInserting) { + context.missing(_thresholdMeta); } return context; } @override - Set get $primaryKey => {userId}; + Set get $primaryKey => {chainId}; @override - User map(Map data, {String? tablePrefix}) { + Chain map(Map data, {String? tablePrefix}) { final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; - return User( - userId: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}user_id'])!, - identityNumber: attachedDatabase.typeMapping.read( - DriftSqlType.string, data['${effectivePrefix}identity_number'])!, - relationship: Users.$converterrelationship.fromSql(attachedDatabase - .typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}relationship'])), - fullName: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}full_name']), - avatarUrl: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}avatar_url']), - phone: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}phone']), - isVerified: attachedDatabase.typeMapping - .read(DriftSqlType.bool, data['${effectivePrefix}is_verified']), - createdAt: Users.$convertercreatedAtn.fromSql(attachedDatabase.typeMapping - .read(DriftSqlType.int, data['${effectivePrefix}created_at'])), - muteUntil: Users.$convertermuteUntiln.fromSql(attachedDatabase.typeMapping - .read(DriftSqlType.int, data['${effectivePrefix}mute_until'])), - hasPin: attachedDatabase.typeMapping - .read(DriftSqlType.int, data['${effectivePrefix}has_pin']), - appId: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}app_id']), - biography: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}biography']), - isScam: attachedDatabase.typeMapping - .read(DriftSqlType.int, data['${effectivePrefix}is_scam']), - codeUrl: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}code_url']), - codeId: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}code_id']), + return Chain( + chainId: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}chain_id'])!, + name: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}name'])!, + symbol: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}symbol'])!, + iconUrl: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}icon_url'])!, + threshold: attachedDatabase.typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}threshold'])!, ); } @override - Users createAlias(String alias) { - return Users(attachedDatabase, alias); + Chains createAlias(String alias) { + return Chains(attachedDatabase, alias); } - static TypeConverter $converterrelationship = - const UserRelationshipConverter(); - static TypeConverter $convertercreatedAt = - const MillisDateConverter(); - static TypeConverter $convertercreatedAtn = - NullAwareTypeConverter.wrap($convertercreatedAt); - static TypeConverter $convertermuteUntil = - const MillisDateConverter(); - static TypeConverter $convertermuteUntiln = - NullAwareTypeConverter.wrap($convertermuteUntil); @override - List get customConstraints => const ['PRIMARY KEY(user_id)']; + List get customConstraints => const ['PRIMARY KEY(chain_id)']; @override bool get dontWriteConstraints => true; } -class User extends DataClass implements Insertable { - final String userId; - final String identityNumber; - final UserRelationship? relationship; - final String? fullName; - final String? avatarUrl; - final String? phone; - final bool? isVerified; - final DateTime? createdAt; - final DateTime? muteUntil; - final int? hasPin; - final String? appId; - final String? biography; - final int? isScam; - final String? codeUrl; - final String? codeId; - const User( - {required this.userId, - required this.identityNumber, - this.relationship, - this.fullName, - this.avatarUrl, - this.phone, - this.isVerified, - this.createdAt, - this.muteUntil, - this.hasPin, - this.appId, - this.biography, - this.isScam, - this.codeUrl, - this.codeId}); +class Chain extends DataClass implements Insertable { + final String chainId; + final String name; + final String symbol; + final String iconUrl; + final int threshold; + const Chain( + {required this.chainId, + required this.name, + required this.symbol, + required this.iconUrl, + required this.threshold}); @override Map toColumns(bool nullToAbsent) { final map = {}; - map['user_id'] = Variable(userId); - map['identity_number'] = Variable(identityNumber); - if (!nullToAbsent || relationship != null) { - final converter = Users.$converterrelationship; - map['relationship'] = Variable(converter.toSql(relationship)); - } - if (!nullToAbsent || fullName != null) { - map['full_name'] = Variable(fullName); - } - if (!nullToAbsent || avatarUrl != null) { - map['avatar_url'] = Variable(avatarUrl); - } - if (!nullToAbsent || phone != null) { - map['phone'] = Variable(phone); - } - if (!nullToAbsent || isVerified != null) { - map['is_verified'] = Variable(isVerified); - } - if (!nullToAbsent || createdAt != null) { - final converter = Users.$convertercreatedAtn; - map['created_at'] = Variable(converter.toSql(createdAt)); - } - if (!nullToAbsent || muteUntil != null) { - final converter = Users.$convertermuteUntiln; - map['mute_until'] = Variable(converter.toSql(muteUntil)); - } - if (!nullToAbsent || hasPin != null) { - map['has_pin'] = Variable(hasPin); - } - if (!nullToAbsent || appId != null) { - map['app_id'] = Variable(appId); - } - if (!nullToAbsent || biography != null) { - map['biography'] = Variable(biography); - } - if (!nullToAbsent || isScam != null) { - map['is_scam'] = Variable(isScam); - } - if (!nullToAbsent || codeUrl != null) { - map['code_url'] = Variable(codeUrl); - } - if (!nullToAbsent || codeId != null) { - map['code_id'] = Variable(codeId); - } + map['chain_id'] = Variable(chainId); + map['name'] = Variable(name); + map['symbol'] = Variable(symbol); + map['icon_url'] = Variable(iconUrl); + map['threshold'] = Variable(threshold); return map; } - UsersCompanion toCompanion(bool nullToAbsent) { - return UsersCompanion( - userId: Value(userId), - identityNumber: Value(identityNumber), - relationship: relationship == null && nullToAbsent - ? const Value.absent() - : Value(relationship), - fullName: fullName == null && nullToAbsent - ? const Value.absent() - : Value(fullName), - avatarUrl: avatarUrl == null && nullToAbsent - ? const Value.absent() - : Value(avatarUrl), - phone: - phone == null && nullToAbsent ? const Value.absent() : Value(phone), - isVerified: isVerified == null && nullToAbsent - ? const Value.absent() - : Value(isVerified), - createdAt: createdAt == null && nullToAbsent - ? const Value.absent() - : Value(createdAt), - muteUntil: muteUntil == null && nullToAbsent - ? const Value.absent() - : Value(muteUntil), - hasPin: - hasPin == null && nullToAbsent ? const Value.absent() : Value(hasPin), - appId: - appId == null && nullToAbsent ? const Value.absent() : Value(appId), - biography: biography == null && nullToAbsent - ? const Value.absent() - : Value(biography), - isScam: - isScam == null && nullToAbsent ? const Value.absent() : Value(isScam), - codeUrl: codeUrl == null && nullToAbsent - ? const Value.absent() - : Value(codeUrl), - codeId: - codeId == null && nullToAbsent ? const Value.absent() : Value(codeId), + ChainsCompanion toCompanion(bool nullToAbsent) { + return ChainsCompanion( + chainId: Value(chainId), + name: Value(name), + symbol: Value(symbol), + iconUrl: Value(iconUrl), + threshold: Value(threshold), ); } - factory User.fromJson(Map json, + factory Chain.fromJson(Map json, {ValueSerializer? serializer}) { serializer ??= driftRuntimeOptions.defaultSerializer; - return User( - userId: serializer.fromJson(json['user_id']), - identityNumber: serializer.fromJson(json['identity_number']), - relationship: - serializer.fromJson(json['relationship']), - fullName: serializer.fromJson(json['full_name']), - avatarUrl: serializer.fromJson(json['avatar_url']), - phone: serializer.fromJson(json['phone']), - isVerified: serializer.fromJson(json['is_verified']), - createdAt: serializer.fromJson(json['created_at']), - muteUntil: serializer.fromJson(json['mute_until']), - hasPin: serializer.fromJson(json['has_pin']), - appId: serializer.fromJson(json['app_id']), - biography: serializer.fromJson(json['biography']), - isScam: serializer.fromJson(json['is_scam']), - codeUrl: serializer.fromJson(json['code_url']), - codeId: serializer.fromJson(json['code_id']), + return Chain( + chainId: serializer.fromJson(json['chain_id']), + name: serializer.fromJson(json['name']), + symbol: serializer.fromJson(json['symbol']), + iconUrl: serializer.fromJson(json['icon_url']), + threshold: serializer.fromJson(json['threshold']), ); } @override Map toJson({ValueSerializer? serializer}) { serializer ??= driftRuntimeOptions.defaultSerializer; return { - 'user_id': serializer.toJson(userId), - 'identity_number': serializer.toJson(identityNumber), - 'relationship': serializer.toJson(relationship), - 'full_name': serializer.toJson(fullName), - 'avatar_url': serializer.toJson(avatarUrl), - 'phone': serializer.toJson(phone), - 'is_verified': serializer.toJson(isVerified), - 'created_at': serializer.toJson(createdAt), - 'mute_until': serializer.toJson(muteUntil), - 'has_pin': serializer.toJson(hasPin), - 'app_id': serializer.toJson(appId), - 'biography': serializer.toJson(biography), - 'is_scam': serializer.toJson(isScam), - 'code_url': serializer.toJson(codeUrl), - 'code_id': serializer.toJson(codeId), + 'chain_id': serializer.toJson(chainId), + 'name': serializer.toJson(name), + 'symbol': serializer.toJson(symbol), + 'icon_url': serializer.toJson(iconUrl), + 'threshold': serializer.toJson(threshold), }; } - User copyWith( - {String? userId, - String? identityNumber, - Value relationship = const Value.absent(), - Value fullName = const Value.absent(), - Value avatarUrl = const Value.absent(), - Value phone = const Value.absent(), - Value isVerified = const Value.absent(), - Value createdAt = const Value.absent(), - Value muteUntil = const Value.absent(), - Value hasPin = const Value.absent(), - Value appId = const Value.absent(), - Value biography = const Value.absent(), - Value isScam = const Value.absent(), - Value codeUrl = const Value.absent(), - Value codeId = const Value.absent()}) => - User( - userId: userId ?? this.userId, - identityNumber: identityNumber ?? this.identityNumber, - relationship: - relationship.present ? relationship.value : this.relationship, - fullName: fullName.present ? fullName.value : this.fullName, - avatarUrl: avatarUrl.present ? avatarUrl.value : this.avatarUrl, - phone: phone.present ? phone.value : this.phone, - isVerified: isVerified.present ? isVerified.value : this.isVerified, - createdAt: createdAt.present ? createdAt.value : this.createdAt, - muteUntil: muteUntil.present ? muteUntil.value : this.muteUntil, - hasPin: hasPin.present ? hasPin.value : this.hasPin, - appId: appId.present ? appId.value : this.appId, - biography: biography.present ? biography.value : this.biography, - isScam: isScam.present ? isScam.value : this.isScam, - codeUrl: codeUrl.present ? codeUrl.value : this.codeUrl, - codeId: codeId.present ? codeId.value : this.codeId, + Chain copyWith( + {String? chainId, + String? name, + String? symbol, + String? iconUrl, + int? threshold}) => + Chain( + chainId: chainId ?? this.chainId, + name: name ?? this.name, + symbol: symbol ?? this.symbol, + iconUrl: iconUrl ?? this.iconUrl, + threshold: threshold ?? this.threshold, ); @override String toString() { - return (StringBuffer('User(') - ..write('userId: $userId, ') - ..write('identityNumber: $identityNumber, ') - ..write('relationship: $relationship, ') - ..write('fullName: $fullName, ') - ..write('avatarUrl: $avatarUrl, ') - ..write('phone: $phone, ') - ..write('isVerified: $isVerified, ') - ..write('createdAt: $createdAt, ') - ..write('muteUntil: $muteUntil, ') - ..write('hasPin: $hasPin, ') - ..write('appId: $appId, ') - ..write('biography: $biography, ') - ..write('isScam: $isScam, ') - ..write('codeUrl: $codeUrl, ') - ..write('codeId: $codeId') + return (StringBuffer('Chain(') + ..write('chainId: $chainId, ') + ..write('name: $name, ') + ..write('symbol: $symbol, ') + ..write('iconUrl: $iconUrl, ') + ..write('threshold: $threshold') ..write(')')) .toString(); } @override - int get hashCode => Object.hash( - userId, - identityNumber, - relationship, - fullName, - avatarUrl, - phone, - isVerified, - createdAt, - muteUntil, - hasPin, - appId, - biography, - isScam, - codeUrl, - codeId); + int get hashCode => Object.hash(chainId, name, symbol, iconUrl, threshold); @override bool operator ==(Object other) => identical(this, other) || - (other is User && - other.userId == this.userId && - other.identityNumber == this.identityNumber && - other.relationship == this.relationship && - other.fullName == this.fullName && - other.avatarUrl == this.avatarUrl && - other.phone == this.phone && - other.isVerified == this.isVerified && - other.createdAt == this.createdAt && - other.muteUntil == this.muteUntil && - other.hasPin == this.hasPin && - other.appId == this.appId && - other.biography == this.biography && - other.isScam == this.isScam && - other.codeUrl == this.codeUrl && - other.codeId == this.codeId); + (other is Chain && + other.chainId == this.chainId && + other.name == this.name && + other.symbol == this.symbol && + other.iconUrl == this.iconUrl && + other.threshold == this.threshold); } -class UsersCompanion extends UpdateCompanion { - final Value userId; - final Value identityNumber; - final Value relationship; - final Value fullName; - final Value avatarUrl; - final Value phone; - final Value isVerified; - final Value createdAt; - final Value muteUntil; - final Value hasPin; - final Value appId; - final Value biography; - final Value isScam; - final Value codeUrl; - final Value codeId; +class ChainsCompanion extends UpdateCompanion { + final Value chainId; + final Value name; + final Value symbol; + final Value iconUrl; + final Value threshold; final Value rowid; - const UsersCompanion({ - this.userId = const Value.absent(), - this.identityNumber = const Value.absent(), - this.relationship = const Value.absent(), - this.fullName = const Value.absent(), - this.avatarUrl = const Value.absent(), - this.phone = const Value.absent(), - this.isVerified = const Value.absent(), - this.createdAt = const Value.absent(), - this.muteUntil = const Value.absent(), - this.hasPin = const Value.absent(), - this.appId = const Value.absent(), - this.biography = const Value.absent(), - this.isScam = const Value.absent(), - this.codeUrl = const Value.absent(), - this.codeId = const Value.absent(), + const ChainsCompanion({ + this.chainId = const Value.absent(), + this.name = const Value.absent(), + this.symbol = const Value.absent(), + this.iconUrl = const Value.absent(), + this.threshold = const Value.absent(), this.rowid = const Value.absent(), }); - UsersCompanion.insert({ - required String userId, - required String identityNumber, - this.relationship = const Value.absent(), - this.fullName = const Value.absent(), - this.avatarUrl = const Value.absent(), - this.phone = const Value.absent(), - this.isVerified = const Value.absent(), - this.createdAt = const Value.absent(), - this.muteUntil = const Value.absent(), - this.hasPin = const Value.absent(), - this.appId = const Value.absent(), - this.biography = const Value.absent(), - this.isScam = const Value.absent(), - this.codeUrl = const Value.absent(), - this.codeId = const Value.absent(), + ChainsCompanion.insert({ + required String chainId, + required String name, + required String symbol, + required String iconUrl, + required int threshold, this.rowid = const Value.absent(), - }) : userId = Value(userId), - identityNumber = Value(identityNumber); - static Insertable custom({ - Expression? userId, - Expression? identityNumber, - Expression? relationship, - Expression? fullName, - Expression? avatarUrl, - Expression? phone, - Expression? isVerified, - Expression? createdAt, - Expression? muteUntil, - Expression? hasPin, - Expression? appId, - Expression? biography, - Expression? isScam, - Expression? codeUrl, - Expression? codeId, + }) : chainId = Value(chainId), + name = Value(name), + symbol = Value(symbol), + iconUrl = Value(iconUrl), + threshold = Value(threshold); + static Insertable custom({ + Expression? chainId, + Expression? name, + Expression? symbol, + Expression? iconUrl, + Expression? threshold, Expression? rowid, }) { return RawValuesInsertable({ - if (userId != null) 'user_id': userId, - if (identityNumber != null) 'identity_number': identityNumber, - if (relationship != null) 'relationship': relationship, - if (fullName != null) 'full_name': fullName, - if (avatarUrl != null) 'avatar_url': avatarUrl, - if (phone != null) 'phone': phone, - if (isVerified != null) 'is_verified': isVerified, - if (createdAt != null) 'created_at': createdAt, - if (muteUntil != null) 'mute_until': muteUntil, - if (hasPin != null) 'has_pin': hasPin, - if (appId != null) 'app_id': appId, - if (biography != null) 'biography': biography, - if (isScam != null) 'is_scam': isScam, - if (codeUrl != null) 'code_url': codeUrl, - if (codeId != null) 'code_id': codeId, + if (chainId != null) 'chain_id': chainId, + if (name != null) 'name': name, + if (symbol != null) 'symbol': symbol, + if (iconUrl != null) 'icon_url': iconUrl, + if (threshold != null) 'threshold': threshold, if (rowid != null) 'rowid': rowid, }); } - UsersCompanion copyWith( - {Value? userId, - Value? identityNumber, - Value? relationship, - Value? fullName, - Value? avatarUrl, - Value? phone, - Value? isVerified, - Value? createdAt, - Value? muteUntil, - Value? hasPin, - Value? appId, - Value? biography, - Value? isScam, - Value? codeUrl, - Value? codeId, + ChainsCompanion copyWith( + {Value? chainId, + Value? name, + Value? symbol, + Value? iconUrl, + Value? threshold, Value? rowid}) { - return UsersCompanion( - userId: userId ?? this.userId, - identityNumber: identityNumber ?? this.identityNumber, - relationship: relationship ?? this.relationship, - fullName: fullName ?? this.fullName, - avatarUrl: avatarUrl ?? this.avatarUrl, - phone: phone ?? this.phone, - isVerified: isVerified ?? this.isVerified, - createdAt: createdAt ?? this.createdAt, - muteUntil: muteUntil ?? this.muteUntil, - hasPin: hasPin ?? this.hasPin, - appId: appId ?? this.appId, - biography: biography ?? this.biography, - isScam: isScam ?? this.isScam, - codeUrl: codeUrl ?? this.codeUrl, - codeId: codeId ?? this.codeId, + return ChainsCompanion( + chainId: chainId ?? this.chainId, + name: name ?? this.name, + symbol: symbol ?? this.symbol, + iconUrl: iconUrl ?? this.iconUrl, + threshold: threshold ?? this.threshold, rowid: rowid ?? this.rowid, ); } @@ -4834,54 +4736,20 @@ class UsersCompanion extends UpdateCompanion { @override Map toColumns(bool nullToAbsent) { final map = {}; - if (userId.present) { - map['user_id'] = Variable(userId.value); - } - if (identityNumber.present) { - map['identity_number'] = Variable(identityNumber.value); - } - if (relationship.present) { - final converter = Users.$converterrelationship; - map['relationship'] = - Variable(converter.toSql(relationship.value)); - } - if (fullName.present) { - map['full_name'] = Variable(fullName.value); - } - if (avatarUrl.present) { - map['avatar_url'] = Variable(avatarUrl.value); - } - if (phone.present) { - map['phone'] = Variable(phone.value); - } - if (isVerified.present) { - map['is_verified'] = Variable(isVerified.value); - } - if (createdAt.present) { - final converter = Users.$convertercreatedAtn; - map['created_at'] = Variable(converter.toSql(createdAt.value)); - } - if (muteUntil.present) { - final converter = Users.$convertermuteUntiln; - map['mute_until'] = Variable(converter.toSql(muteUntil.value)); - } - if (hasPin.present) { - map['has_pin'] = Variable(hasPin.value); - } - if (appId.present) { - map['app_id'] = Variable(appId.value); + if (chainId.present) { + map['chain_id'] = Variable(chainId.value); } - if (biography.present) { - map['biography'] = Variable(biography.value); + if (name.present) { + map['name'] = Variable(name.value); } - if (isScam.present) { - map['is_scam'] = Variable(isScam.value); + if (symbol.present) { + map['symbol'] = Variable(symbol.value); } - if (codeUrl.present) { - map['code_url'] = Variable(codeUrl.value); + if (iconUrl.present) { + map['icon_url'] = Variable(iconUrl.value); } - if (codeId.present) { - map['code_id'] = Variable(codeId.value); + if (threshold.present) { + map['threshold'] = Variable(threshold.value); } if (rowid.present) { map['rowid'] = Variable(rowid.value); @@ -4891,66 +4759,71 @@ class UsersCompanion extends UpdateCompanion { @override String toString() { - return (StringBuffer('UsersCompanion(') - ..write('userId: $userId, ') - ..write('identityNumber: $identityNumber, ') - ..write('relationship: $relationship, ') - ..write('fullName: $fullName, ') - ..write('avatarUrl: $avatarUrl, ') - ..write('phone: $phone, ') - ..write('isVerified: $isVerified, ') - ..write('createdAt: $createdAt, ') - ..write('muteUntil: $muteUntil, ') - ..write('hasPin: $hasPin, ') - ..write('appId: $appId, ') - ..write('biography: $biography, ') - ..write('isScam: $isScam, ') - ..write('codeUrl: $codeUrl, ') - ..write('codeId: $codeId, ') + return (StringBuffer('ChainsCompanion(') + ..write('chainId: $chainId, ') + ..write('name: $name, ') + ..write('symbol: $symbol, ') + ..write('iconUrl: $iconUrl, ') + ..write('threshold: $threshold, ') ..write('rowid: $rowid') ..write(')')) .toString(); } } -class Snapshots extends Table with TableInfo { +class Stickers extends Table with TableInfo { @override final GeneratedDatabase attachedDatabase; final String? _alias; - Snapshots(this.attachedDatabase, [this._alias]); - static const VerificationMeta _snapshotIdMeta = - const VerificationMeta('snapshotId'); - late final GeneratedColumn snapshotId = GeneratedColumn( - 'snapshot_id', aliasedName, false, + Stickers(this.attachedDatabase, [this._alias]); + static const VerificationMeta _stickerIdMeta = + const VerificationMeta('stickerId'); + late final GeneratedColumn stickerId = GeneratedColumn( + 'sticker_id', aliasedName, false, type: DriftSqlType.string, requiredDuringInsert: true, $customConstraints: 'NOT NULL'); - static const VerificationMeta _traceIdMeta = - const VerificationMeta('traceId'); - late final GeneratedColumn traceId = GeneratedColumn( - 'trace_id', aliasedName, true, + static const VerificationMeta _albumIdMeta = + const VerificationMeta('albumId'); + late final GeneratedColumn albumId = GeneratedColumn( + 'album_id', aliasedName, true, type: DriftSqlType.string, requiredDuringInsert: false, $customConstraints: ''); - static const VerificationMeta _typeMeta = const VerificationMeta('type'); - late final GeneratedColumn type = GeneratedColumn( - 'type', aliasedName, false, + static const VerificationMeta _nameMeta = const VerificationMeta('name'); + late final GeneratedColumn name = GeneratedColumn( + 'name', aliasedName, false, type: DriftSqlType.string, requiredDuringInsert: true, $customConstraints: 'NOT NULL'); - static const VerificationMeta _assetIdMeta = - const VerificationMeta('assetId'); - late final GeneratedColumn assetId = GeneratedColumn( - 'asset_id', aliasedName, false, + static const VerificationMeta _assetUrlMeta = + const VerificationMeta('assetUrl'); + late final GeneratedColumn assetUrl = GeneratedColumn( + 'asset_url', aliasedName, false, type: DriftSqlType.string, requiredDuringInsert: true, $customConstraints: 'NOT NULL'); - static const VerificationMeta _amountMeta = const VerificationMeta('amount'); - late final GeneratedColumn amount = GeneratedColumn( - 'amount', aliasedName, false, + static const VerificationMeta _assetTypeMeta = + const VerificationMeta('assetType'); + late final GeneratedColumn assetType = GeneratedColumn( + 'asset_type', aliasedName, false, type: DriftSqlType.string, requiredDuringInsert: true, $customConstraints: 'NOT NULL'); + static const VerificationMeta _assetWidthMeta = + const VerificationMeta('assetWidth'); + late final GeneratedColumn assetWidth = GeneratedColumn( + 'asset_width', aliasedName, false, + type: DriftSqlType.int, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL'); + static const VerificationMeta _assetHeightMeta = + const VerificationMeta('assetHeight'); + late final GeneratedColumn assetHeight = GeneratedColumn( + 'asset_height', aliasedName, false, + type: DriftSqlType.int, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL'); static const VerificationMeta _createdAtMeta = const VerificationMeta('createdAt'); late final GeneratedColumnWithTypeConverter createdAt = @@ -4958,613 +4831,366 @@ class Snapshots extends Table with TableInfo { type: DriftSqlType.int, requiredDuringInsert: true, $customConstraints: 'NOT NULL') - .withConverter(Snapshots.$convertercreatedAt); - static const VerificationMeta _opponentIdMeta = - const VerificationMeta('opponentId'); - late final GeneratedColumn opponentId = GeneratedColumn( - 'opponent_id', aliasedName, true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: ''); - static const VerificationMeta _transactionHashMeta = - const VerificationMeta('transactionHash'); - late final GeneratedColumn transactionHash = GeneratedColumn( - 'transaction_hash', aliasedName, true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: ''); - static const VerificationMeta _senderMeta = const VerificationMeta('sender'); - late final GeneratedColumn sender = GeneratedColumn( - 'sender', aliasedName, true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: ''); - static const VerificationMeta _receiverMeta = - const VerificationMeta('receiver'); - late final GeneratedColumn receiver = GeneratedColumn( - 'receiver', aliasedName, true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: ''); - static const VerificationMeta _memoMeta = const VerificationMeta('memo'); - late final GeneratedColumn memo = GeneratedColumn( - 'memo', aliasedName, true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: ''); - static const VerificationMeta _confirmationsMeta = - const VerificationMeta('confirmations'); - late final GeneratedColumn confirmations = GeneratedColumn( - 'confirmations', aliasedName, true, - type: DriftSqlType.int, - requiredDuringInsert: false, - $customConstraints: ''); - static const VerificationMeta _snapshotHashMeta = - const VerificationMeta('snapshotHash'); - late final GeneratedColumn snapshotHash = GeneratedColumn( - 'snapshot_hash', aliasedName, true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: ''); - static const VerificationMeta _openingBalanceMeta = - const VerificationMeta('openingBalance'); - late final GeneratedColumn openingBalance = GeneratedColumn( - 'opening_balance', aliasedName, true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: ''); - static const VerificationMeta _closingBalanceMeta = - const VerificationMeta('closingBalance'); - late final GeneratedColumn closingBalance = GeneratedColumn( - 'closing_balance', aliasedName, true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: ''); + .withConverter(Stickers.$convertercreatedAt); + static const VerificationMeta _lastUseAtMeta = + const VerificationMeta('lastUseAt'); + late final GeneratedColumnWithTypeConverter lastUseAt = + GeneratedColumn('last_use_at', aliasedName, true, + type: DriftSqlType.int, + requiredDuringInsert: false, + $customConstraints: '') + .withConverter(Stickers.$converterlastUseAtn); @override List get $columns => [ - snapshotId, - traceId, - type, - assetId, - amount, + stickerId, + albumId, + name, + assetUrl, + assetType, + assetWidth, + assetHeight, createdAt, - opponentId, - transactionHash, - sender, - receiver, - memo, - confirmations, - snapshotHash, - openingBalance, - closingBalance + lastUseAt ]; @override - String get aliasedName => _alias ?? 'snapshots'; + String get aliasedName => _alias ?? 'stickers'; @override - String get actualTableName => 'snapshots'; + String get actualTableName => 'stickers'; @override - VerificationContext validateIntegrity(Insertable instance, + VerificationContext validateIntegrity(Insertable instance, {bool isInserting = false}) { final context = VerificationContext(); final data = instance.toColumns(true); - if (data.containsKey('snapshot_id')) { - context.handle( - _snapshotIdMeta, - snapshotId.isAcceptableOrUnknown( - data['snapshot_id']!, _snapshotIdMeta)); + if (data.containsKey('sticker_id')) { + context.handle(_stickerIdMeta, + stickerId.isAcceptableOrUnknown(data['sticker_id']!, _stickerIdMeta)); } else if (isInserting) { - context.missing(_snapshotIdMeta); + context.missing(_stickerIdMeta); } - if (data.containsKey('trace_id')) { - context.handle(_traceIdMeta, - traceId.isAcceptableOrUnknown(data['trace_id']!, _traceIdMeta)); + if (data.containsKey('album_id')) { + context.handle(_albumIdMeta, + albumId.isAcceptableOrUnknown(data['album_id']!, _albumIdMeta)); } - if (data.containsKey('type')) { + if (data.containsKey('name')) { context.handle( - _typeMeta, type.isAcceptableOrUnknown(data['type']!, _typeMeta)); + _nameMeta, name.isAcceptableOrUnknown(data['name']!, _nameMeta)); } else if (isInserting) { - context.missing(_typeMeta); + context.missing(_nameMeta); } - if (data.containsKey('asset_id')) { - context.handle(_assetIdMeta, - assetId.isAcceptableOrUnknown(data['asset_id']!, _assetIdMeta)); + if (data.containsKey('asset_url')) { + context.handle(_assetUrlMeta, + assetUrl.isAcceptableOrUnknown(data['asset_url']!, _assetUrlMeta)); } else if (isInserting) { - context.missing(_assetIdMeta); + context.missing(_assetUrlMeta); } - if (data.containsKey('amount')) { - context.handle(_amountMeta, - amount.isAcceptableOrUnknown(data['amount']!, _amountMeta)); + if (data.containsKey('asset_type')) { + context.handle(_assetTypeMeta, + assetType.isAcceptableOrUnknown(data['asset_type']!, _assetTypeMeta)); } else if (isInserting) { - context.missing(_amountMeta); - } - context.handle(_createdAtMeta, const VerificationResult.success()); - if (data.containsKey('opponent_id')) { - context.handle( - _opponentIdMeta, - opponentId.isAcceptableOrUnknown( - data['opponent_id']!, _opponentIdMeta)); - } - if (data.containsKey('transaction_hash')) { - context.handle( - _transactionHashMeta, - transactionHash.isAcceptableOrUnknown( - data['transaction_hash']!, _transactionHashMeta)); - } - if (data.containsKey('sender')) { - context.handle(_senderMeta, - sender.isAcceptableOrUnknown(data['sender']!, _senderMeta)); - } - if (data.containsKey('receiver')) { - context.handle(_receiverMeta, - receiver.isAcceptableOrUnknown(data['receiver']!, _receiverMeta)); - } - if (data.containsKey('memo')) { - context.handle( - _memoMeta, memo.isAcceptableOrUnknown(data['memo']!, _memoMeta)); - } - if (data.containsKey('confirmations')) { - context.handle( - _confirmationsMeta, - confirmations.isAcceptableOrUnknown( - data['confirmations']!, _confirmationsMeta)); - } - if (data.containsKey('snapshot_hash')) { - context.handle( - _snapshotHashMeta, - snapshotHash.isAcceptableOrUnknown( - data['snapshot_hash']!, _snapshotHashMeta)); + context.missing(_assetTypeMeta); } - if (data.containsKey('opening_balance')) { + if (data.containsKey('asset_width')) { context.handle( - _openingBalanceMeta, - openingBalance.isAcceptableOrUnknown( - data['opening_balance']!, _openingBalanceMeta)); + _assetWidthMeta, + assetWidth.isAcceptableOrUnknown( + data['asset_width']!, _assetWidthMeta)); + } else if (isInserting) { + context.missing(_assetWidthMeta); } - if (data.containsKey('closing_balance')) { + if (data.containsKey('asset_height')) { context.handle( - _closingBalanceMeta, - closingBalance.isAcceptableOrUnknown( - data['closing_balance']!, _closingBalanceMeta)); + _assetHeightMeta, + assetHeight.isAcceptableOrUnknown( + data['asset_height']!, _assetHeightMeta)); + } else if (isInserting) { + context.missing(_assetHeightMeta); } + context.handle(_createdAtMeta, const VerificationResult.success()); + context.handle(_lastUseAtMeta, const VerificationResult.success()); return context; } @override - Set get $primaryKey => {snapshotId}; + Set get $primaryKey => {stickerId}; @override - Snapshot map(Map data, {String? tablePrefix}) { + Sticker map(Map data, {String? tablePrefix}) { final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; - return Snapshot( - snapshotId: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}snapshot_id'])!, - traceId: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}trace_id']), - type: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}type'])!, - assetId: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}asset_id'])!, - amount: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}amount'])!, - createdAt: Snapshots.$convertercreatedAt.fromSql(attachedDatabase + return Sticker( + stickerId: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}sticker_id'])!, + albumId: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}album_id']), + name: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}name'])!, + assetUrl: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}asset_url'])!, + assetType: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}asset_type'])!, + assetWidth: attachedDatabase.typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}asset_width'])!, + assetHeight: attachedDatabase.typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}asset_height'])!, + createdAt: Stickers.$convertercreatedAt.fromSql(attachedDatabase .typeMapping .read(DriftSqlType.int, data['${effectivePrefix}created_at'])!), - opponentId: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}opponent_id']), - transactionHash: attachedDatabase.typeMapping.read( - DriftSqlType.string, data['${effectivePrefix}transaction_hash']), - sender: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}sender']), - receiver: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}receiver']), - memo: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}memo']), - confirmations: attachedDatabase.typeMapping - .read(DriftSqlType.int, data['${effectivePrefix}confirmations']), - snapshotHash: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}snapshot_hash']), - openingBalance: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}opening_balance']), - closingBalance: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}closing_balance']), + lastUseAt: Stickers.$converterlastUseAtn.fromSql(attachedDatabase + .typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}last_use_at'])), ); } @override - Snapshots createAlias(String alias) { - return Snapshots(attachedDatabase, alias); + Stickers createAlias(String alias) { + return Stickers(attachedDatabase, alias); } static TypeConverter $convertercreatedAt = const MillisDateConverter(); + static TypeConverter $converterlastUseAt = + const MillisDateConverter(); + static TypeConverter $converterlastUseAtn = + NullAwareTypeConverter.wrap($converterlastUseAt); @override - List get customConstraints => const ['PRIMARY KEY(snapshot_id)']; + List get customConstraints => const ['PRIMARY KEY(sticker_id)']; @override bool get dontWriteConstraints => true; } -class Snapshot extends DataClass implements Insertable { - final String snapshotId; - final String? traceId; - final String type; - final String assetId; - final String amount; +class Sticker extends DataClass implements Insertable { + final String stickerId; + final String? albumId; + final String name; + final String assetUrl; + final String assetType; + final int assetWidth; + final int assetHeight; final DateTime createdAt; - final String? opponentId; - final String? transactionHash; - final String? sender; - final String? receiver; - final String? memo; - final int? confirmations; - final String? snapshotHash; - final String? openingBalance; - final String? closingBalance; - const Snapshot( - {required this.snapshotId, - this.traceId, - required this.type, - required this.assetId, - required this.amount, + final DateTime? lastUseAt; + const Sticker( + {required this.stickerId, + this.albumId, + required this.name, + required this.assetUrl, + required this.assetType, + required this.assetWidth, + required this.assetHeight, required this.createdAt, - this.opponentId, - this.transactionHash, - this.sender, - this.receiver, - this.memo, - this.confirmations, - this.snapshotHash, - this.openingBalance, - this.closingBalance}); + this.lastUseAt}); @override Map toColumns(bool nullToAbsent) { final map = {}; - map['snapshot_id'] = Variable(snapshotId); - if (!nullToAbsent || traceId != null) { - map['trace_id'] = Variable(traceId); + map['sticker_id'] = Variable(stickerId); + if (!nullToAbsent || albumId != null) { + map['album_id'] = Variable(albumId); } - map['type'] = Variable(type); - map['asset_id'] = Variable(assetId); - map['amount'] = Variable(amount); + map['name'] = Variable(name); + map['asset_url'] = Variable(assetUrl); + map['asset_type'] = Variable(assetType); + map['asset_width'] = Variable(assetWidth); + map['asset_height'] = Variable(assetHeight); { - final converter = Snapshots.$convertercreatedAt; + final converter = Stickers.$convertercreatedAt; map['created_at'] = Variable(converter.toSql(createdAt)); } - if (!nullToAbsent || opponentId != null) { - map['opponent_id'] = Variable(opponentId); - } - if (!nullToAbsent || transactionHash != null) { - map['transaction_hash'] = Variable(transactionHash); - } - if (!nullToAbsent || sender != null) { - map['sender'] = Variable(sender); - } - if (!nullToAbsent || receiver != null) { - map['receiver'] = Variable(receiver); - } - if (!nullToAbsent || memo != null) { - map['memo'] = Variable(memo); - } - if (!nullToAbsent || confirmations != null) { - map['confirmations'] = Variable(confirmations); - } - if (!nullToAbsent || snapshotHash != null) { - map['snapshot_hash'] = Variable(snapshotHash); - } - if (!nullToAbsent || openingBalance != null) { - map['opening_balance'] = Variable(openingBalance); - } - if (!nullToAbsent || closingBalance != null) { - map['closing_balance'] = Variable(closingBalance); + if (!nullToAbsent || lastUseAt != null) { + final converter = Stickers.$converterlastUseAtn; + map['last_use_at'] = Variable(converter.toSql(lastUseAt)); } return map; } - SnapshotsCompanion toCompanion(bool nullToAbsent) { - return SnapshotsCompanion( - snapshotId: Value(snapshotId), - traceId: traceId == null && nullToAbsent + StickersCompanion toCompanion(bool nullToAbsent) { + return StickersCompanion( + stickerId: Value(stickerId), + albumId: albumId == null && nullToAbsent ? const Value.absent() - : Value(traceId), - type: Value(type), - assetId: Value(assetId), - amount: Value(amount), + : Value(albumId), + name: Value(name), + assetUrl: Value(assetUrl), + assetType: Value(assetType), + assetWidth: Value(assetWidth), + assetHeight: Value(assetHeight), createdAt: Value(createdAt), - opponentId: opponentId == null && nullToAbsent - ? const Value.absent() - : Value(opponentId), - transactionHash: transactionHash == null && nullToAbsent - ? const Value.absent() - : Value(transactionHash), - sender: - sender == null && nullToAbsent ? const Value.absent() : Value(sender), - receiver: receiver == null && nullToAbsent - ? const Value.absent() - : Value(receiver), - memo: memo == null && nullToAbsent ? const Value.absent() : Value(memo), - confirmations: confirmations == null && nullToAbsent - ? const Value.absent() - : Value(confirmations), - snapshotHash: snapshotHash == null && nullToAbsent - ? const Value.absent() - : Value(snapshotHash), - openingBalance: openingBalance == null && nullToAbsent - ? const Value.absent() - : Value(openingBalance), - closingBalance: closingBalance == null && nullToAbsent + lastUseAt: lastUseAt == null && nullToAbsent ? const Value.absent() - : Value(closingBalance), + : Value(lastUseAt), ); } - factory Snapshot.fromJson(Map json, + factory Sticker.fromJson(Map json, {ValueSerializer? serializer}) { serializer ??= driftRuntimeOptions.defaultSerializer; - return Snapshot( - snapshotId: serializer.fromJson(json['snapshot_id']), - traceId: serializer.fromJson(json['trace_id']), - type: serializer.fromJson(json['type']), - assetId: serializer.fromJson(json['asset_id']), - amount: serializer.fromJson(json['amount']), + return Sticker( + stickerId: serializer.fromJson(json['sticker_id']), + albumId: serializer.fromJson(json['album_id']), + name: serializer.fromJson(json['name']), + assetUrl: serializer.fromJson(json['asset_url']), + assetType: serializer.fromJson(json['asset_type']), + assetWidth: serializer.fromJson(json['asset_width']), + assetHeight: serializer.fromJson(json['asset_height']), createdAt: serializer.fromJson(json['created_at']), - opponentId: serializer.fromJson(json['opponent_id']), - transactionHash: serializer.fromJson(json['transaction_hash']), - sender: serializer.fromJson(json['sender']), - receiver: serializer.fromJson(json['receiver']), - memo: serializer.fromJson(json['memo']), - confirmations: serializer.fromJson(json['confirmations']), - snapshotHash: serializer.fromJson(json['snapshot_hash']), - openingBalance: serializer.fromJson(json['opening_balance']), - closingBalance: serializer.fromJson(json['closing_balance']), + lastUseAt: serializer.fromJson(json['last_use_at']), ); } @override Map toJson({ValueSerializer? serializer}) { serializer ??= driftRuntimeOptions.defaultSerializer; return { - 'snapshot_id': serializer.toJson(snapshotId), - 'trace_id': serializer.toJson(traceId), - 'type': serializer.toJson(type), - 'asset_id': serializer.toJson(assetId), - 'amount': serializer.toJson(amount), + 'sticker_id': serializer.toJson(stickerId), + 'album_id': serializer.toJson(albumId), + 'name': serializer.toJson(name), + 'asset_url': serializer.toJson(assetUrl), + 'asset_type': serializer.toJson(assetType), + 'asset_width': serializer.toJson(assetWidth), + 'asset_height': serializer.toJson(assetHeight), 'created_at': serializer.toJson(createdAt), - 'opponent_id': serializer.toJson(opponentId), - 'transaction_hash': serializer.toJson(transactionHash), - 'sender': serializer.toJson(sender), - 'receiver': serializer.toJson(receiver), - 'memo': serializer.toJson(memo), - 'confirmations': serializer.toJson(confirmations), - 'snapshot_hash': serializer.toJson(snapshotHash), - 'opening_balance': serializer.toJson(openingBalance), - 'closing_balance': serializer.toJson(closingBalance), + 'last_use_at': serializer.toJson(lastUseAt), }; } - Snapshot copyWith( - {String? snapshotId, - Value traceId = const Value.absent(), - String? type, - String? assetId, - String? amount, + Sticker copyWith( + {String? stickerId, + Value albumId = const Value.absent(), + String? name, + String? assetUrl, + String? assetType, + int? assetWidth, + int? assetHeight, DateTime? createdAt, - Value opponentId = const Value.absent(), - Value transactionHash = const Value.absent(), - Value sender = const Value.absent(), - Value receiver = const Value.absent(), - Value memo = const Value.absent(), - Value confirmations = const Value.absent(), - Value snapshotHash = const Value.absent(), - Value openingBalance = const Value.absent(), - Value closingBalance = const Value.absent()}) => - Snapshot( - snapshotId: snapshotId ?? this.snapshotId, - traceId: traceId.present ? traceId.value : this.traceId, - type: type ?? this.type, - assetId: assetId ?? this.assetId, - amount: amount ?? this.amount, + Value lastUseAt = const Value.absent()}) => + Sticker( + stickerId: stickerId ?? this.stickerId, + albumId: albumId.present ? albumId.value : this.albumId, + name: name ?? this.name, + assetUrl: assetUrl ?? this.assetUrl, + assetType: assetType ?? this.assetType, + assetWidth: assetWidth ?? this.assetWidth, + assetHeight: assetHeight ?? this.assetHeight, createdAt: createdAt ?? this.createdAt, - opponentId: opponentId.present ? opponentId.value : this.opponentId, - transactionHash: transactionHash.present - ? transactionHash.value - : this.transactionHash, - sender: sender.present ? sender.value : this.sender, - receiver: receiver.present ? receiver.value : this.receiver, - memo: memo.present ? memo.value : this.memo, - confirmations: - confirmations.present ? confirmations.value : this.confirmations, - snapshotHash: - snapshotHash.present ? snapshotHash.value : this.snapshotHash, - openingBalance: - openingBalance.present ? openingBalance.value : this.openingBalance, - closingBalance: - closingBalance.present ? closingBalance.value : this.closingBalance, + lastUseAt: lastUseAt.present ? lastUseAt.value : this.lastUseAt, ); @override String toString() { - return (StringBuffer('Snapshot(') - ..write('snapshotId: $snapshotId, ') - ..write('traceId: $traceId, ') - ..write('type: $type, ') - ..write('assetId: $assetId, ') - ..write('amount: $amount, ') + return (StringBuffer('Sticker(') + ..write('stickerId: $stickerId, ') + ..write('albumId: $albumId, ') + ..write('name: $name, ') + ..write('assetUrl: $assetUrl, ') + ..write('assetType: $assetType, ') + ..write('assetWidth: $assetWidth, ') + ..write('assetHeight: $assetHeight, ') ..write('createdAt: $createdAt, ') - ..write('opponentId: $opponentId, ') - ..write('transactionHash: $transactionHash, ') - ..write('sender: $sender, ') - ..write('receiver: $receiver, ') - ..write('memo: $memo, ') - ..write('confirmations: $confirmations, ') - ..write('snapshotHash: $snapshotHash, ') - ..write('openingBalance: $openingBalance, ') - ..write('closingBalance: $closingBalance') + ..write('lastUseAt: $lastUseAt') ..write(')')) .toString(); } @override - int get hashCode => Object.hash( - snapshotId, - traceId, - type, - assetId, - amount, - createdAt, - opponentId, - transactionHash, - sender, - receiver, - memo, - confirmations, - snapshotHash, - openingBalance, - closingBalance); + int get hashCode => Object.hash(stickerId, albumId, name, assetUrl, assetType, + assetWidth, assetHeight, createdAt, lastUseAt); @override bool operator ==(Object other) => identical(this, other) || - (other is Snapshot && - other.snapshotId == this.snapshotId && - other.traceId == this.traceId && - other.type == this.type && - other.assetId == this.assetId && - other.amount == this.amount && + (other is Sticker && + other.stickerId == this.stickerId && + other.albumId == this.albumId && + other.name == this.name && + other.assetUrl == this.assetUrl && + other.assetType == this.assetType && + other.assetWidth == this.assetWidth && + other.assetHeight == this.assetHeight && other.createdAt == this.createdAt && - other.opponentId == this.opponentId && - other.transactionHash == this.transactionHash && - other.sender == this.sender && - other.receiver == this.receiver && - other.memo == this.memo && - other.confirmations == this.confirmations && - other.snapshotHash == this.snapshotHash && - other.openingBalance == this.openingBalance && - other.closingBalance == this.closingBalance); + other.lastUseAt == this.lastUseAt); } -class SnapshotsCompanion extends UpdateCompanion { - final Value snapshotId; - final Value traceId; - final Value type; - final Value assetId; - final Value amount; +class StickersCompanion extends UpdateCompanion { + final Value stickerId; + final Value albumId; + final Value name; + final Value assetUrl; + final Value assetType; + final Value assetWidth; + final Value assetHeight; final Value createdAt; - final Value opponentId; - final Value transactionHash; - final Value sender; - final Value receiver; - final Value memo; - final Value confirmations; - final Value snapshotHash; - final Value openingBalance; - final Value closingBalance; + final Value lastUseAt; final Value rowid; - const SnapshotsCompanion({ - this.snapshotId = const Value.absent(), - this.traceId = const Value.absent(), - this.type = const Value.absent(), - this.assetId = const Value.absent(), - this.amount = const Value.absent(), + const StickersCompanion({ + this.stickerId = const Value.absent(), + this.albumId = const Value.absent(), + this.name = const Value.absent(), + this.assetUrl = const Value.absent(), + this.assetType = const Value.absent(), + this.assetWidth = const Value.absent(), + this.assetHeight = const Value.absent(), this.createdAt = const Value.absent(), - this.opponentId = const Value.absent(), - this.transactionHash = const Value.absent(), - this.sender = const Value.absent(), - this.receiver = const Value.absent(), - this.memo = const Value.absent(), - this.confirmations = const Value.absent(), - this.snapshotHash = const Value.absent(), - this.openingBalance = const Value.absent(), - this.closingBalance = const Value.absent(), + this.lastUseAt = const Value.absent(), this.rowid = const Value.absent(), }); - SnapshotsCompanion.insert({ - required String snapshotId, - this.traceId = const Value.absent(), - required String type, - required String assetId, - required String amount, - required DateTime createdAt, - this.opponentId = const Value.absent(), - this.transactionHash = const Value.absent(), - this.sender = const Value.absent(), - this.receiver = const Value.absent(), - this.memo = const Value.absent(), - this.confirmations = const Value.absent(), - this.snapshotHash = const Value.absent(), - this.openingBalance = const Value.absent(), - this.closingBalance = const Value.absent(), + StickersCompanion.insert({ + required String stickerId, + this.albumId = const Value.absent(), + required String name, + required String assetUrl, + required String assetType, + required int assetWidth, + required int assetHeight, + required DateTime createdAt, + this.lastUseAt = const Value.absent(), this.rowid = const Value.absent(), - }) : snapshotId = Value(snapshotId), - type = Value(type), - assetId = Value(assetId), - amount = Value(amount), + }) : stickerId = Value(stickerId), + name = Value(name), + assetUrl = Value(assetUrl), + assetType = Value(assetType), + assetWidth = Value(assetWidth), + assetHeight = Value(assetHeight), createdAt = Value(createdAt); - static Insertable custom({ - Expression? snapshotId, - Expression? traceId, - Expression? type, - Expression? assetId, - Expression? amount, + static Insertable custom({ + Expression? stickerId, + Expression? albumId, + Expression? name, + Expression? assetUrl, + Expression? assetType, + Expression? assetWidth, + Expression? assetHeight, Expression? createdAt, - Expression? opponentId, - Expression? transactionHash, - Expression? sender, - Expression? receiver, - Expression? memo, - Expression? confirmations, - Expression? snapshotHash, - Expression? openingBalance, - Expression? closingBalance, + Expression? lastUseAt, Expression? rowid, }) { return RawValuesInsertable({ - if (snapshotId != null) 'snapshot_id': snapshotId, - if (traceId != null) 'trace_id': traceId, - if (type != null) 'type': type, - if (assetId != null) 'asset_id': assetId, - if (amount != null) 'amount': amount, + if (stickerId != null) 'sticker_id': stickerId, + if (albumId != null) 'album_id': albumId, + if (name != null) 'name': name, + if (assetUrl != null) 'asset_url': assetUrl, + if (assetType != null) 'asset_type': assetType, + if (assetWidth != null) 'asset_width': assetWidth, + if (assetHeight != null) 'asset_height': assetHeight, if (createdAt != null) 'created_at': createdAt, - if (opponentId != null) 'opponent_id': opponentId, - if (transactionHash != null) 'transaction_hash': transactionHash, - if (sender != null) 'sender': sender, - if (receiver != null) 'receiver': receiver, - if (memo != null) 'memo': memo, - if (confirmations != null) 'confirmations': confirmations, - if (snapshotHash != null) 'snapshot_hash': snapshotHash, - if (openingBalance != null) 'opening_balance': openingBalance, - if (closingBalance != null) 'closing_balance': closingBalance, + if (lastUseAt != null) 'last_use_at': lastUseAt, if (rowid != null) 'rowid': rowid, }); } - SnapshotsCompanion copyWith( - {Value? snapshotId, - Value? traceId, - Value? type, - Value? assetId, - Value? amount, + StickersCompanion copyWith( + {Value? stickerId, + Value? albumId, + Value? name, + Value? assetUrl, + Value? assetType, + Value? assetWidth, + Value? assetHeight, Value? createdAt, - Value? opponentId, - Value? transactionHash, - Value? sender, - Value? receiver, - Value? memo, - Value? confirmations, - Value? snapshotHash, - Value? openingBalance, - Value? closingBalance, + Value? lastUseAt, Value? rowid}) { - return SnapshotsCompanion( - snapshotId: snapshotId ?? this.snapshotId, - traceId: traceId ?? this.traceId, - type: type ?? this.type, - assetId: assetId ?? this.assetId, - amount: amount ?? this.amount, + return StickersCompanion( + stickerId: stickerId ?? this.stickerId, + albumId: albumId ?? this.albumId, + name: name ?? this.name, + assetUrl: assetUrl ?? this.assetUrl, + assetType: assetType ?? this.assetType, + assetWidth: assetWidth ?? this.assetWidth, + assetHeight: assetHeight ?? this.assetHeight, createdAt: createdAt ?? this.createdAt, - opponentId: opponentId ?? this.opponentId, - transactionHash: transactionHash ?? this.transactionHash, - sender: sender ?? this.sender, - receiver: receiver ?? this.receiver, - memo: memo ?? this.memo, - confirmations: confirmations ?? this.confirmations, - snapshotHash: snapshotHash ?? this.snapshotHash, - openingBalance: openingBalance ?? this.openingBalance, - closingBalance: closingBalance ?? this.closingBalance, + lastUseAt: lastUseAt ?? this.lastUseAt, rowid: rowid ?? this.rowid, ); } @@ -5572,51 +5198,34 @@ class SnapshotsCompanion extends UpdateCompanion { @override Map toColumns(bool nullToAbsent) { final map = {}; - if (snapshotId.present) { - map['snapshot_id'] = Variable(snapshotId.value); - } - if (traceId.present) { - map['trace_id'] = Variable(traceId.value); - } - if (type.present) { - map['type'] = Variable(type.value); - } - if (assetId.present) { - map['asset_id'] = Variable(assetId.value); - } - if (amount.present) { - map['amount'] = Variable(amount.value); - } - if (createdAt.present) { - final converter = Snapshots.$convertercreatedAt; - map['created_at'] = Variable(converter.toSql(createdAt.value)); - } - if (opponentId.present) { - map['opponent_id'] = Variable(opponentId.value); + if (stickerId.present) { + map['sticker_id'] = Variable(stickerId.value); } - if (transactionHash.present) { - map['transaction_hash'] = Variable(transactionHash.value); + if (albumId.present) { + map['album_id'] = Variable(albumId.value); } - if (sender.present) { - map['sender'] = Variable(sender.value); + if (name.present) { + map['name'] = Variable(name.value); } - if (receiver.present) { - map['receiver'] = Variable(receiver.value); + if (assetUrl.present) { + map['asset_url'] = Variable(assetUrl.value); } - if (memo.present) { - map['memo'] = Variable(memo.value); + if (assetType.present) { + map['asset_type'] = Variable(assetType.value); } - if (confirmations.present) { - map['confirmations'] = Variable(confirmations.value); + if (assetWidth.present) { + map['asset_width'] = Variable(assetWidth.value); } - if (snapshotHash.present) { - map['snapshot_hash'] = Variable(snapshotHash.value); + if (assetHeight.present) { + map['asset_height'] = Variable(assetHeight.value); } - if (openingBalance.present) { - map['opening_balance'] = Variable(openingBalance.value); + if (createdAt.present) { + final converter = Stickers.$convertercreatedAt; + map['created_at'] = Variable(converter.toSql(createdAt.value)); } - if (closingBalance.present) { - map['closing_balance'] = Variable(closingBalance.value); + if (lastUseAt.present) { + final converter = Stickers.$converterlastUseAtn; + map['last_use_at'] = Variable(converter.toSql(lastUseAt.value)); } if (rowid.present) { map['rowid'] = Variable(rowid.value); @@ -5626,657 +5235,296 @@ class SnapshotsCompanion extends UpdateCompanion { @override String toString() { - return (StringBuffer('SnapshotsCompanion(') - ..write('snapshotId: $snapshotId, ') - ..write('traceId: $traceId, ') - ..write('type: $type, ') - ..write('assetId: $assetId, ') - ..write('amount: $amount, ') + return (StringBuffer('StickersCompanion(') + ..write('stickerId: $stickerId, ') + ..write('albumId: $albumId, ') + ..write('name: $name, ') + ..write('assetUrl: $assetUrl, ') + ..write('assetType: $assetType, ') + ..write('assetWidth: $assetWidth, ') + ..write('assetHeight: $assetHeight, ') ..write('createdAt: $createdAt, ') - ..write('opponentId: $opponentId, ') - ..write('transactionHash: $transactionHash, ') - ..write('sender: $sender, ') - ..write('receiver: $receiver, ') - ..write('memo: $memo, ') - ..write('confirmations: $confirmations, ') - ..write('snapshotHash: $snapshotHash, ') - ..write('openingBalance: $openingBalance, ') - ..write('closingBalance: $closingBalance, ') + ..write('lastUseAt: $lastUseAt, ') ..write('rowid: $rowid') ..write(')')) .toString(); } } -class Assets extends Table with TableInfo { +class Hyperlinks extends Table with TableInfo { @override final GeneratedDatabase attachedDatabase; final String? _alias; - Assets(this.attachedDatabase, [this._alias]); - static const VerificationMeta _assetIdMeta = - const VerificationMeta('assetId'); - late final GeneratedColumn assetId = GeneratedColumn( - 'asset_id', aliasedName, false, - type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL'); - static const VerificationMeta _symbolMeta = const VerificationMeta('symbol'); - late final GeneratedColumn symbol = GeneratedColumn( - 'symbol', aliasedName, false, + Hyperlinks(this.attachedDatabase, [this._alias]); + static const VerificationMeta _hyperlinkMeta = + const VerificationMeta('hyperlink'); + late final GeneratedColumn hyperlink = GeneratedColumn( + 'hyperlink', aliasedName, false, type: DriftSqlType.string, requiredDuringInsert: true, $customConstraints: 'NOT NULL'); - static const VerificationMeta _nameMeta = const VerificationMeta('name'); - late final GeneratedColumn name = GeneratedColumn( - 'name', aliasedName, false, + static const VerificationMeta _siteNameMeta = + const VerificationMeta('siteName'); + late final GeneratedColumn siteName = GeneratedColumn( + 'site_name', aliasedName, false, type: DriftSqlType.string, requiredDuringInsert: true, $customConstraints: 'NOT NULL'); - static const VerificationMeta _iconUrlMeta = - const VerificationMeta('iconUrl'); - late final GeneratedColumn iconUrl = GeneratedColumn( - 'icon_url', aliasedName, false, + static const VerificationMeta _siteTitleMeta = + const VerificationMeta('siteTitle'); + late final GeneratedColumn siteTitle = GeneratedColumn( + 'site_title', aliasedName, false, type: DriftSqlType.string, requiredDuringInsert: true, $customConstraints: 'NOT NULL'); - static const VerificationMeta _balanceMeta = - const VerificationMeta('balance'); - late final GeneratedColumn balance = GeneratedColumn( - 'balance', aliasedName, false, + static const VerificationMeta _siteDescriptionMeta = + const VerificationMeta('siteDescription'); + late final GeneratedColumn siteDescription = GeneratedColumn( + 'site_description', aliasedName, true, type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL'); - static const VerificationMeta _destinationMeta = - const VerificationMeta('destination'); - late final GeneratedColumn destination = GeneratedColumn( - 'destination', aliasedName, false, - type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL'); - static const VerificationMeta _tagMeta = const VerificationMeta('tag'); - late final GeneratedColumn tag = GeneratedColumn( - 'tag', aliasedName, true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: ''); - static const VerificationMeta _priceBtcMeta = - const VerificationMeta('priceBtc'); - late final GeneratedColumn priceBtc = GeneratedColumn( - 'price_btc', aliasedName, false, - type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL'); - static const VerificationMeta _priceUsdMeta = - const VerificationMeta('priceUsd'); - late final GeneratedColumn priceUsd = GeneratedColumn( - 'price_usd', aliasedName, false, - type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL'); - static const VerificationMeta _chainIdMeta = - const VerificationMeta('chainId'); - late final GeneratedColumn chainId = GeneratedColumn( - 'chain_id', aliasedName, false, - type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL'); - static const VerificationMeta _changeUsdMeta = - const VerificationMeta('changeUsd'); - late final GeneratedColumn changeUsd = GeneratedColumn( - 'change_usd', aliasedName, false, - type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL'); - static const VerificationMeta _changeBtcMeta = - const VerificationMeta('changeBtc'); - late final GeneratedColumn changeBtc = GeneratedColumn( - 'change_btc', aliasedName, false, - type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL'); - static const VerificationMeta _confirmationsMeta = - const VerificationMeta('confirmations'); - late final GeneratedColumn confirmations = GeneratedColumn( - 'confirmations', aliasedName, false, - type: DriftSqlType.int, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL'); - static const VerificationMeta _assetKeyMeta = - const VerificationMeta('assetKey'); - late final GeneratedColumn assetKey = GeneratedColumn( - 'asset_key', aliasedName, true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: ''); - static const VerificationMeta _reserveMeta = - const VerificationMeta('reserve'); - late final GeneratedColumn reserve = GeneratedColumn( - 'reserve', aliasedName, true, + requiredDuringInsert: false, + $customConstraints: ''); + static const VerificationMeta _siteImageMeta = + const VerificationMeta('siteImage'); + late final GeneratedColumn siteImage = GeneratedColumn( + 'site_image', aliasedName, true, type: DriftSqlType.string, requiredDuringInsert: false, $customConstraints: ''); @override - List get $columns => [ - assetId, - symbol, - name, - iconUrl, - balance, - destination, - tag, - priceBtc, - priceUsd, - chainId, - changeUsd, - changeBtc, - confirmations, - assetKey, - reserve - ]; + List get $columns => + [hyperlink, siteName, siteTitle, siteDescription, siteImage]; @override - String get aliasedName => _alias ?? 'assets'; + String get aliasedName => _alias ?? 'hyperlinks'; @override - String get actualTableName => 'assets'; + String get actualTableName => 'hyperlinks'; @override - VerificationContext validateIntegrity(Insertable instance, + VerificationContext validateIntegrity(Insertable instance, {bool isInserting = false}) { final context = VerificationContext(); final data = instance.toColumns(true); - if (data.containsKey('asset_id')) { - context.handle(_assetIdMeta, - assetId.isAcceptableOrUnknown(data['asset_id']!, _assetIdMeta)); - } else if (isInserting) { - context.missing(_assetIdMeta); - } - if (data.containsKey('symbol')) { - context.handle(_symbolMeta, - symbol.isAcceptableOrUnknown(data['symbol']!, _symbolMeta)); - } else if (isInserting) { - context.missing(_symbolMeta); - } - if (data.containsKey('name')) { - context.handle( - _nameMeta, name.isAcceptableOrUnknown(data['name']!, _nameMeta)); - } else if (isInserting) { - context.missing(_nameMeta); - } - if (data.containsKey('icon_url')) { - context.handle(_iconUrlMeta, - iconUrl.isAcceptableOrUnknown(data['icon_url']!, _iconUrlMeta)); - } else if (isInserting) { - context.missing(_iconUrlMeta); - } - if (data.containsKey('balance')) { - context.handle(_balanceMeta, - balance.isAcceptableOrUnknown(data['balance']!, _balanceMeta)); - } else if (isInserting) { - context.missing(_balanceMeta); - } - if (data.containsKey('destination')) { - context.handle( - _destinationMeta, - destination.isAcceptableOrUnknown( - data['destination']!, _destinationMeta)); - } else if (isInserting) { - context.missing(_destinationMeta); - } - if (data.containsKey('tag')) { - context.handle( - _tagMeta, tag.isAcceptableOrUnknown(data['tag']!, _tagMeta)); - } - if (data.containsKey('price_btc')) { - context.handle(_priceBtcMeta, - priceBtc.isAcceptableOrUnknown(data['price_btc']!, _priceBtcMeta)); - } else if (isInserting) { - context.missing(_priceBtcMeta); - } - if (data.containsKey('price_usd')) { - context.handle(_priceUsdMeta, - priceUsd.isAcceptableOrUnknown(data['price_usd']!, _priceUsdMeta)); - } else if (isInserting) { - context.missing(_priceUsdMeta); - } - if (data.containsKey('chain_id')) { - context.handle(_chainIdMeta, - chainId.isAcceptableOrUnknown(data['chain_id']!, _chainIdMeta)); + if (data.containsKey('hyperlink')) { + context.handle(_hyperlinkMeta, + hyperlink.isAcceptableOrUnknown(data['hyperlink']!, _hyperlinkMeta)); } else if (isInserting) { - context.missing(_chainIdMeta); + context.missing(_hyperlinkMeta); } - if (data.containsKey('change_usd')) { - context.handle(_changeUsdMeta, - changeUsd.isAcceptableOrUnknown(data['change_usd']!, _changeUsdMeta)); + if (data.containsKey('site_name')) { + context.handle(_siteNameMeta, + siteName.isAcceptableOrUnknown(data['site_name']!, _siteNameMeta)); } else if (isInserting) { - context.missing(_changeUsdMeta); + context.missing(_siteNameMeta); } - if (data.containsKey('change_btc')) { - context.handle(_changeBtcMeta, - changeBtc.isAcceptableOrUnknown(data['change_btc']!, _changeBtcMeta)); + if (data.containsKey('site_title')) { + context.handle(_siteTitleMeta, + siteTitle.isAcceptableOrUnknown(data['site_title']!, _siteTitleMeta)); } else if (isInserting) { - context.missing(_changeBtcMeta); + context.missing(_siteTitleMeta); } - if (data.containsKey('confirmations')) { + if (data.containsKey('site_description')) { context.handle( - _confirmationsMeta, - confirmations.isAcceptableOrUnknown( - data['confirmations']!, _confirmationsMeta)); - } else if (isInserting) { - context.missing(_confirmationsMeta); - } - if (data.containsKey('asset_key')) { - context.handle(_assetKeyMeta, - assetKey.isAcceptableOrUnknown(data['asset_key']!, _assetKeyMeta)); + _siteDescriptionMeta, + siteDescription.isAcceptableOrUnknown( + data['site_description']!, _siteDescriptionMeta)); } - if (data.containsKey('reserve')) { - context.handle(_reserveMeta, - reserve.isAcceptableOrUnknown(data['reserve']!, _reserveMeta)); + if (data.containsKey('site_image')) { + context.handle(_siteImageMeta, + siteImage.isAcceptableOrUnknown(data['site_image']!, _siteImageMeta)); } return context; } @override - Set get $primaryKey => {assetId}; + Set get $primaryKey => {hyperlink}; @override - Asset map(Map data, {String? tablePrefix}) { + Hyperlink map(Map data, {String? tablePrefix}) { final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; - return Asset( - assetId: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}asset_id'])!, - symbol: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}symbol'])!, - name: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}name'])!, - iconUrl: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}icon_url'])!, - balance: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}balance'])!, - destination: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}destination'])!, - tag: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}tag']), - priceBtc: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}price_btc'])!, - priceUsd: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}price_usd'])!, - chainId: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}chain_id'])!, - changeUsd: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}change_usd'])!, - changeBtc: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}change_btc'])!, - confirmations: attachedDatabase.typeMapping - .read(DriftSqlType.int, data['${effectivePrefix}confirmations'])!, - assetKey: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}asset_key']), - reserve: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}reserve']), + return Hyperlink( + hyperlink: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}hyperlink'])!, + siteName: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}site_name'])!, + siteTitle: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}site_title'])!, + siteDescription: attachedDatabase.typeMapping.read( + DriftSqlType.string, data['${effectivePrefix}site_description']), + siteImage: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}site_image']), ); } @override - Assets createAlias(String alias) { - return Assets(attachedDatabase, alias); + Hyperlinks createAlias(String alias) { + return Hyperlinks(attachedDatabase, alias); } @override - List get customConstraints => const ['PRIMARY KEY(asset_id)']; + List get customConstraints => const ['PRIMARY KEY(hyperlink)']; @override bool get dontWriteConstraints => true; } -class Asset extends DataClass implements Insertable { - final String assetId; - final String symbol; - final String name; - final String iconUrl; - final String balance; - final String destination; - final String? tag; - final String priceBtc; - final String priceUsd; - final String chainId; - final String changeUsd; - final String changeBtc; - final int confirmations; - final String? assetKey; - final String? reserve; - const Asset( - {required this.assetId, - required this.symbol, - required this.name, - required this.iconUrl, - required this.balance, - required this.destination, - this.tag, - required this.priceBtc, - required this.priceUsd, - required this.chainId, - required this.changeUsd, - required this.changeBtc, - required this.confirmations, - this.assetKey, - this.reserve}); +class Hyperlink extends DataClass implements Insertable { + final String hyperlink; + final String siteName; + final String siteTitle; + final String? siteDescription; + final String? siteImage; + const Hyperlink( + {required this.hyperlink, + required this.siteName, + required this.siteTitle, + this.siteDescription, + this.siteImage}); @override Map toColumns(bool nullToAbsent) { final map = {}; - map['asset_id'] = Variable(assetId); - map['symbol'] = Variable(symbol); - map['name'] = Variable(name); - map['icon_url'] = Variable(iconUrl); - map['balance'] = Variable(balance); - map['destination'] = Variable(destination); - if (!nullToAbsent || tag != null) { - map['tag'] = Variable(tag); - } - map['price_btc'] = Variable(priceBtc); - map['price_usd'] = Variable(priceUsd); - map['chain_id'] = Variable(chainId); - map['change_usd'] = Variable(changeUsd); - map['change_btc'] = Variable(changeBtc); - map['confirmations'] = Variable(confirmations); - if (!nullToAbsent || assetKey != null) { - map['asset_key'] = Variable(assetKey); + map['hyperlink'] = Variable(hyperlink); + map['site_name'] = Variable(siteName); + map['site_title'] = Variable(siteTitle); + if (!nullToAbsent || siteDescription != null) { + map['site_description'] = Variable(siteDescription); } - if (!nullToAbsent || reserve != null) { - map['reserve'] = Variable(reserve); + if (!nullToAbsent || siteImage != null) { + map['site_image'] = Variable(siteImage); } return map; } - AssetsCompanion toCompanion(bool nullToAbsent) { - return AssetsCompanion( - assetId: Value(assetId), - symbol: Value(symbol), - name: Value(name), - iconUrl: Value(iconUrl), - balance: Value(balance), - destination: Value(destination), - tag: tag == null && nullToAbsent ? const Value.absent() : Value(tag), - priceBtc: Value(priceBtc), - priceUsd: Value(priceUsd), - chainId: Value(chainId), - changeUsd: Value(changeUsd), - changeBtc: Value(changeBtc), - confirmations: Value(confirmations), - assetKey: assetKey == null && nullToAbsent + HyperlinksCompanion toCompanion(bool nullToAbsent) { + return HyperlinksCompanion( + hyperlink: Value(hyperlink), + siteName: Value(siteName), + siteTitle: Value(siteTitle), + siteDescription: siteDescription == null && nullToAbsent ? const Value.absent() - : Value(assetKey), - reserve: reserve == null && nullToAbsent + : Value(siteDescription), + siteImage: siteImage == null && nullToAbsent ? const Value.absent() - : Value(reserve), + : Value(siteImage), ); } - factory Asset.fromJson(Map json, + factory Hyperlink.fromJson(Map json, {ValueSerializer? serializer}) { serializer ??= driftRuntimeOptions.defaultSerializer; - return Asset( - assetId: serializer.fromJson(json['asset_id']), - symbol: serializer.fromJson(json['symbol']), - name: serializer.fromJson(json['name']), - iconUrl: serializer.fromJson(json['icon_url']), - balance: serializer.fromJson(json['balance']), - destination: serializer.fromJson(json['destination']), - tag: serializer.fromJson(json['tag']), - priceBtc: serializer.fromJson(json['price_btc']), - priceUsd: serializer.fromJson(json['price_usd']), - chainId: serializer.fromJson(json['chain_id']), - changeUsd: serializer.fromJson(json['change_usd']), - changeBtc: serializer.fromJson(json['change_btc']), - confirmations: serializer.fromJson(json['confirmations']), - assetKey: serializer.fromJson(json['asset_key']), - reserve: serializer.fromJson(json['reserve']), + return Hyperlink( + hyperlink: serializer.fromJson(json['hyperlink']), + siteName: serializer.fromJson(json['site_name']), + siteTitle: serializer.fromJson(json['site_title']), + siteDescription: serializer.fromJson(json['site_description']), + siteImage: serializer.fromJson(json['site_image']), ); } @override Map toJson({ValueSerializer? serializer}) { serializer ??= driftRuntimeOptions.defaultSerializer; return { - 'asset_id': serializer.toJson(assetId), - 'symbol': serializer.toJson(symbol), - 'name': serializer.toJson(name), - 'icon_url': serializer.toJson(iconUrl), - 'balance': serializer.toJson(balance), - 'destination': serializer.toJson(destination), - 'tag': serializer.toJson(tag), - 'price_btc': serializer.toJson(priceBtc), - 'price_usd': serializer.toJson(priceUsd), - 'chain_id': serializer.toJson(chainId), - 'change_usd': serializer.toJson(changeUsd), - 'change_btc': serializer.toJson(changeBtc), - 'confirmations': serializer.toJson(confirmations), - 'asset_key': serializer.toJson(assetKey), - 'reserve': serializer.toJson(reserve), + 'hyperlink': serializer.toJson(hyperlink), + 'site_name': serializer.toJson(siteName), + 'site_title': serializer.toJson(siteTitle), + 'site_description': serializer.toJson(siteDescription), + 'site_image': serializer.toJson(siteImage), }; } - Asset copyWith( - {String? assetId, - String? symbol, - String? name, - String? iconUrl, - String? balance, - String? destination, - Value tag = const Value.absent(), - String? priceBtc, - String? priceUsd, - String? chainId, - String? changeUsd, - String? changeBtc, - int? confirmations, - Value assetKey = const Value.absent(), - Value reserve = const Value.absent()}) => - Asset( - assetId: assetId ?? this.assetId, - symbol: symbol ?? this.symbol, - name: name ?? this.name, - iconUrl: iconUrl ?? this.iconUrl, - balance: balance ?? this.balance, - destination: destination ?? this.destination, - tag: tag.present ? tag.value : this.tag, - priceBtc: priceBtc ?? this.priceBtc, - priceUsd: priceUsd ?? this.priceUsd, - chainId: chainId ?? this.chainId, - changeUsd: changeUsd ?? this.changeUsd, - changeBtc: changeBtc ?? this.changeBtc, - confirmations: confirmations ?? this.confirmations, - assetKey: assetKey.present ? assetKey.value : this.assetKey, - reserve: reserve.present ? reserve.value : this.reserve, + Hyperlink copyWith( + {String? hyperlink, + String? siteName, + String? siteTitle, + Value siteDescription = const Value.absent(), + Value siteImage = const Value.absent()}) => + Hyperlink( + hyperlink: hyperlink ?? this.hyperlink, + siteName: siteName ?? this.siteName, + siteTitle: siteTitle ?? this.siteTitle, + siteDescription: siteDescription.present + ? siteDescription.value + : this.siteDescription, + siteImage: siteImage.present ? siteImage.value : this.siteImage, ); @override String toString() { - return (StringBuffer('Asset(') - ..write('assetId: $assetId, ') - ..write('symbol: $symbol, ') - ..write('name: $name, ') - ..write('iconUrl: $iconUrl, ') - ..write('balance: $balance, ') - ..write('destination: $destination, ') - ..write('tag: $tag, ') - ..write('priceBtc: $priceBtc, ') - ..write('priceUsd: $priceUsd, ') - ..write('chainId: $chainId, ') - ..write('changeUsd: $changeUsd, ') - ..write('changeBtc: $changeBtc, ') - ..write('confirmations: $confirmations, ') - ..write('assetKey: $assetKey, ') - ..write('reserve: $reserve') + return (StringBuffer('Hyperlink(') + ..write('hyperlink: $hyperlink, ') + ..write('siteName: $siteName, ') + ..write('siteTitle: $siteTitle, ') + ..write('siteDescription: $siteDescription, ') + ..write('siteImage: $siteImage') ..write(')')) .toString(); } @override - int get hashCode => Object.hash( - assetId, - symbol, - name, - iconUrl, - balance, - destination, - tag, - priceBtc, - priceUsd, - chainId, - changeUsd, - changeBtc, - confirmations, - assetKey, - reserve); + int get hashCode => + Object.hash(hyperlink, siteName, siteTitle, siteDescription, siteImage); @override bool operator ==(Object other) => identical(this, other) || - (other is Asset && - other.assetId == this.assetId && - other.symbol == this.symbol && - other.name == this.name && - other.iconUrl == this.iconUrl && - other.balance == this.balance && - other.destination == this.destination && - other.tag == this.tag && - other.priceBtc == this.priceBtc && - other.priceUsd == this.priceUsd && - other.chainId == this.chainId && - other.changeUsd == this.changeUsd && - other.changeBtc == this.changeBtc && - other.confirmations == this.confirmations && - other.assetKey == this.assetKey && - other.reserve == this.reserve); + (other is Hyperlink && + other.hyperlink == this.hyperlink && + other.siteName == this.siteName && + other.siteTitle == this.siteTitle && + other.siteDescription == this.siteDescription && + other.siteImage == this.siteImage); } -class AssetsCompanion extends UpdateCompanion { - final Value assetId; - final Value symbol; - final Value name; - final Value iconUrl; - final Value balance; - final Value destination; - final Value tag; - final Value priceBtc; - final Value priceUsd; - final Value chainId; - final Value changeUsd; - final Value changeBtc; - final Value confirmations; - final Value assetKey; - final Value reserve; +class HyperlinksCompanion extends UpdateCompanion { + final Value hyperlink; + final Value siteName; + final Value siteTitle; + final Value siteDescription; + final Value siteImage; final Value rowid; - const AssetsCompanion({ - this.assetId = const Value.absent(), - this.symbol = const Value.absent(), - this.name = const Value.absent(), - this.iconUrl = const Value.absent(), - this.balance = const Value.absent(), - this.destination = const Value.absent(), - this.tag = const Value.absent(), - this.priceBtc = const Value.absent(), - this.priceUsd = const Value.absent(), - this.chainId = const Value.absent(), - this.changeUsd = const Value.absent(), - this.changeBtc = const Value.absent(), - this.confirmations = const Value.absent(), - this.assetKey = const Value.absent(), - this.reserve = const Value.absent(), + const HyperlinksCompanion({ + this.hyperlink = const Value.absent(), + this.siteName = const Value.absent(), + this.siteTitle = const Value.absent(), + this.siteDescription = const Value.absent(), + this.siteImage = const Value.absent(), this.rowid = const Value.absent(), }); - AssetsCompanion.insert({ - required String assetId, - required String symbol, - required String name, - required String iconUrl, - required String balance, - required String destination, - this.tag = const Value.absent(), - required String priceBtc, - required String priceUsd, - required String chainId, - required String changeUsd, - required String changeBtc, - required int confirmations, - this.assetKey = const Value.absent(), - this.reserve = const Value.absent(), + HyperlinksCompanion.insert({ + required String hyperlink, + required String siteName, + required String siteTitle, + this.siteDescription = const Value.absent(), + this.siteImage = const Value.absent(), this.rowid = const Value.absent(), - }) : assetId = Value(assetId), - symbol = Value(symbol), - name = Value(name), - iconUrl = Value(iconUrl), - balance = Value(balance), - destination = Value(destination), - priceBtc = Value(priceBtc), - priceUsd = Value(priceUsd), - chainId = Value(chainId), - changeUsd = Value(changeUsd), - changeBtc = Value(changeBtc), - confirmations = Value(confirmations); - static Insertable custom({ - Expression? assetId, - Expression? symbol, - Expression? name, - Expression? iconUrl, - Expression? balance, - Expression? destination, - Expression? tag, - Expression? priceBtc, - Expression? priceUsd, - Expression? chainId, - Expression? changeUsd, - Expression? changeBtc, - Expression? confirmations, - Expression? assetKey, - Expression? reserve, + }) : hyperlink = Value(hyperlink), + siteName = Value(siteName), + siteTitle = Value(siteTitle); + static Insertable custom({ + Expression? hyperlink, + Expression? siteName, + Expression? siteTitle, + Expression? siteDescription, + Expression? siteImage, Expression? rowid, }) { return RawValuesInsertable({ - if (assetId != null) 'asset_id': assetId, - if (symbol != null) 'symbol': symbol, - if (name != null) 'name': name, - if (iconUrl != null) 'icon_url': iconUrl, - if (balance != null) 'balance': balance, - if (destination != null) 'destination': destination, - if (tag != null) 'tag': tag, - if (priceBtc != null) 'price_btc': priceBtc, - if (priceUsd != null) 'price_usd': priceUsd, - if (chainId != null) 'chain_id': chainId, - if (changeUsd != null) 'change_usd': changeUsd, - if (changeBtc != null) 'change_btc': changeBtc, - if (confirmations != null) 'confirmations': confirmations, - if (assetKey != null) 'asset_key': assetKey, - if (reserve != null) 'reserve': reserve, + if (hyperlink != null) 'hyperlink': hyperlink, + if (siteName != null) 'site_name': siteName, + if (siteTitle != null) 'site_title': siteTitle, + if (siteDescription != null) 'site_description': siteDescription, + if (siteImage != null) 'site_image': siteImage, if (rowid != null) 'rowid': rowid, }); } - AssetsCompanion copyWith( - {Value? assetId, - Value? symbol, - Value? name, - Value? iconUrl, - Value? balance, - Value? destination, - Value? tag, - Value? priceBtc, - Value? priceUsd, - Value? chainId, - Value? changeUsd, - Value? changeBtc, - Value? confirmations, - Value? assetKey, - Value? reserve, + HyperlinksCompanion copyWith( + {Value? hyperlink, + Value? siteName, + Value? siteTitle, + Value? siteDescription, + Value? siteImage, Value? rowid}) { - return AssetsCompanion( - assetId: assetId ?? this.assetId, - symbol: symbol ?? this.symbol, - name: name ?? this.name, - iconUrl: iconUrl ?? this.iconUrl, - balance: balance ?? this.balance, - destination: destination ?? this.destination, - tag: tag ?? this.tag, - priceBtc: priceBtc ?? this.priceBtc, - priceUsd: priceUsd ?? this.priceUsd, - chainId: chainId ?? this.chainId, - changeUsd: changeUsd ?? this.changeUsd, - changeBtc: changeBtc ?? this.changeBtc, - confirmations: confirmations ?? this.confirmations, - assetKey: assetKey ?? this.assetKey, - reserve: reserve ?? this.reserve, + return HyperlinksCompanion( + hyperlink: hyperlink ?? this.hyperlink, + siteName: siteName ?? this.siteName, + siteTitle: siteTitle ?? this.siteTitle, + siteDescription: siteDescription ?? this.siteDescription, + siteImage: siteImage ?? this.siteImage, rowid: rowid ?? this.rowid, ); } @@ -6284,50 +5532,20 @@ class AssetsCompanion extends UpdateCompanion { @override Map toColumns(bool nullToAbsent) { final map = {}; - if (assetId.present) { - map['asset_id'] = Variable(assetId.value); - } - if (symbol.present) { - map['symbol'] = Variable(symbol.value); - } - if (name.present) { - map['name'] = Variable(name.value); - } - if (iconUrl.present) { - map['icon_url'] = Variable(iconUrl.value); - } - if (balance.present) { - map['balance'] = Variable(balance.value); - } - if (destination.present) { - map['destination'] = Variable(destination.value); - } - if (tag.present) { - map['tag'] = Variable(tag.value); - } - if (priceBtc.present) { - map['price_btc'] = Variable(priceBtc.value); - } - if (priceUsd.present) { - map['price_usd'] = Variable(priceUsd.value); - } - if (chainId.present) { - map['chain_id'] = Variable(chainId.value); - } - if (changeUsd.present) { - map['change_usd'] = Variable(changeUsd.value); + if (hyperlink.present) { + map['hyperlink'] = Variable(hyperlink.value); } - if (changeBtc.present) { - map['change_btc'] = Variable(changeBtc.value); + if (siteName.present) { + map['site_name'] = Variable(siteName.value); } - if (confirmations.present) { - map['confirmations'] = Variable(confirmations.value); + if (siteTitle.present) { + map['site_title'] = Variable(siteTitle.value); } - if (assetKey.present) { - map['asset_key'] = Variable(assetKey.value); + if (siteDescription.present) { + map['site_description'] = Variable(siteDescription.value); } - if (reserve.present) { - map['reserve'] = Variable(reserve.value); + if (siteImage.present) { + map['site_image'] = Variable(siteImage.value); } if (rowid.present) { map['rowid'] = Variable(rowid.value); @@ -6337,314 +5555,235 @@ class AssetsCompanion extends UpdateCompanion { @override String toString() { - return (StringBuffer('AssetsCompanion(') - ..write('assetId: $assetId, ') - ..write('symbol: $symbol, ') - ..write('name: $name, ') - ..write('iconUrl: $iconUrl, ') - ..write('balance: $balance, ') - ..write('destination: $destination, ') - ..write('tag: $tag, ') - ..write('priceBtc: $priceBtc, ') - ..write('priceUsd: $priceUsd, ') - ..write('chainId: $chainId, ') - ..write('changeUsd: $changeUsd, ') - ..write('changeBtc: $changeBtc, ') - ..write('confirmations: $confirmations, ') - ..write('assetKey: $assetKey, ') - ..write('reserve: $reserve, ') + return (StringBuffer('HyperlinksCompanion(') + ..write('hyperlink: $hyperlink, ') + ..write('siteName: $siteName, ') + ..write('siteTitle: $siteTitle, ') + ..write('siteDescription: $siteDescription, ') + ..write('siteImage: $siteImage, ') ..write('rowid: $rowid') ..write(')')) .toString(); } } -class Chains extends Table with TableInfo { +class MessageMentions extends Table + with TableInfo { @override final GeneratedDatabase attachedDatabase; final String? _alias; - Chains(this.attachedDatabase, [this._alias]); - static const VerificationMeta _chainIdMeta = - const VerificationMeta('chainId'); - late final GeneratedColumn chainId = GeneratedColumn( - 'chain_id', aliasedName, false, - type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL'); - static const VerificationMeta _nameMeta = const VerificationMeta('name'); - late final GeneratedColumn name = GeneratedColumn( - 'name', aliasedName, false, - type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL'); - static const VerificationMeta _symbolMeta = const VerificationMeta('symbol'); - late final GeneratedColumn symbol = GeneratedColumn( - 'symbol', aliasedName, false, + MessageMentions(this.attachedDatabase, [this._alias]); + static const VerificationMeta _messageIdMeta = + const VerificationMeta('messageId'); + late final GeneratedColumn messageId = GeneratedColumn( + 'message_id', aliasedName, false, type: DriftSqlType.string, requiredDuringInsert: true, $customConstraints: 'NOT NULL'); - static const VerificationMeta _iconUrlMeta = - const VerificationMeta('iconUrl'); - late final GeneratedColumn iconUrl = GeneratedColumn( - 'icon_url', aliasedName, false, + static const VerificationMeta _conversationIdMeta = + const VerificationMeta('conversationId'); + late final GeneratedColumn conversationId = GeneratedColumn( + 'conversation_id', aliasedName, false, type: DriftSqlType.string, requiredDuringInsert: true, $customConstraints: 'NOT NULL'); - static const VerificationMeta _thresholdMeta = - const VerificationMeta('threshold'); - late final GeneratedColumn threshold = GeneratedColumn( - 'threshold', aliasedName, false, - type: DriftSqlType.int, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL'); - @override - List get $columns => - [chainId, name, symbol, iconUrl, threshold]; + static const VerificationMeta _hasReadMeta = + const VerificationMeta('hasRead'); + late final GeneratedColumn hasRead = GeneratedColumn( + 'has_read', aliasedName, true, + type: DriftSqlType.bool, + requiredDuringInsert: false, + $customConstraints: ''); @override - String get aliasedName => _alias ?? 'chains'; + List get $columns => [messageId, conversationId, hasRead]; @override - String get actualTableName => 'chains'; + String get aliasedName => _alias ?? 'message_mentions'; @override - VerificationContext validateIntegrity(Insertable instance, + String get actualTableName => 'message_mentions'; + @override + VerificationContext validateIntegrity(Insertable instance, {bool isInserting = false}) { final context = VerificationContext(); final data = instance.toColumns(true); - if (data.containsKey('chain_id')) { - context.handle(_chainIdMeta, - chainId.isAcceptableOrUnknown(data['chain_id']!, _chainIdMeta)); + if (data.containsKey('message_id')) { + context.handle(_messageIdMeta, + messageId.isAcceptableOrUnknown(data['message_id']!, _messageIdMeta)); } else if (isInserting) { - context.missing(_chainIdMeta); + context.missing(_messageIdMeta); } - if (data.containsKey('name')) { + if (data.containsKey('conversation_id')) { context.handle( - _nameMeta, name.isAcceptableOrUnknown(data['name']!, _nameMeta)); - } else if (isInserting) { - context.missing(_nameMeta); - } - if (data.containsKey('symbol')) { - context.handle(_symbolMeta, - symbol.isAcceptableOrUnknown(data['symbol']!, _symbolMeta)); - } else if (isInserting) { - context.missing(_symbolMeta); - } - if (data.containsKey('icon_url')) { - context.handle(_iconUrlMeta, - iconUrl.isAcceptableOrUnknown(data['icon_url']!, _iconUrlMeta)); + _conversationIdMeta, + conversationId.isAcceptableOrUnknown( + data['conversation_id']!, _conversationIdMeta)); } else if (isInserting) { - context.missing(_iconUrlMeta); + context.missing(_conversationIdMeta); } - if (data.containsKey('threshold')) { - context.handle(_thresholdMeta, - threshold.isAcceptableOrUnknown(data['threshold']!, _thresholdMeta)); - } else if (isInserting) { - context.missing(_thresholdMeta); + if (data.containsKey('has_read')) { + context.handle(_hasReadMeta, + hasRead.isAcceptableOrUnknown(data['has_read']!, _hasReadMeta)); } return context; } @override - Set get $primaryKey => {chainId}; + Set get $primaryKey => {messageId}; @override - Chain map(Map data, {String? tablePrefix}) { + MessageMention map(Map data, {String? tablePrefix}) { final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; - return Chain( - chainId: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}chain_id'])!, - name: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}name'])!, - symbol: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}symbol'])!, - iconUrl: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}icon_url'])!, - threshold: attachedDatabase.typeMapping - .read(DriftSqlType.int, data['${effectivePrefix}threshold'])!, + return MessageMention( + messageId: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}message_id'])!, + conversationId: attachedDatabase.typeMapping.read( + DriftSqlType.string, data['${effectivePrefix}conversation_id'])!, + hasRead: attachedDatabase.typeMapping + .read(DriftSqlType.bool, data['${effectivePrefix}has_read']), ); } @override - Chains createAlias(String alias) { - return Chains(attachedDatabase, alias); + MessageMentions createAlias(String alias) { + return MessageMentions(attachedDatabase, alias); } @override - List get customConstraints => const ['PRIMARY KEY(chain_id)']; + List get customConstraints => const ['PRIMARY KEY(message_id)']; @override bool get dontWriteConstraints => true; } -class Chain extends DataClass implements Insertable { - final String chainId; - final String name; - final String symbol; - final String iconUrl; - final int threshold; - const Chain( - {required this.chainId, - required this.name, - required this.symbol, - required this.iconUrl, - required this.threshold}); +class MessageMention extends DataClass implements Insertable { + final String messageId; + final String conversationId; + final bool? hasRead; + const MessageMention( + {required this.messageId, required this.conversationId, this.hasRead}); @override Map toColumns(bool nullToAbsent) { final map = {}; - map['chain_id'] = Variable(chainId); - map['name'] = Variable(name); - map['symbol'] = Variable(symbol); - map['icon_url'] = Variable(iconUrl); - map['threshold'] = Variable(threshold); + map['message_id'] = Variable(messageId); + map['conversation_id'] = Variable(conversationId); + if (!nullToAbsent || hasRead != null) { + map['has_read'] = Variable(hasRead); + } return map; } - ChainsCompanion toCompanion(bool nullToAbsent) { - return ChainsCompanion( - chainId: Value(chainId), - name: Value(name), - symbol: Value(symbol), - iconUrl: Value(iconUrl), - threshold: Value(threshold), + MessageMentionsCompanion toCompanion(bool nullToAbsent) { + return MessageMentionsCompanion( + messageId: Value(messageId), + conversationId: Value(conversationId), + hasRead: hasRead == null && nullToAbsent + ? const Value.absent() + : Value(hasRead), ); } - factory Chain.fromJson(Map json, + factory MessageMention.fromJson(Map json, {ValueSerializer? serializer}) { serializer ??= driftRuntimeOptions.defaultSerializer; - return Chain( - chainId: serializer.fromJson(json['chain_id']), - name: serializer.fromJson(json['name']), - symbol: serializer.fromJson(json['symbol']), - iconUrl: serializer.fromJson(json['icon_url']), - threshold: serializer.fromJson(json['threshold']), + return MessageMention( + messageId: serializer.fromJson(json['message_id']), + conversationId: serializer.fromJson(json['conversation_id']), + hasRead: serializer.fromJson(json['has_read']), ); } @override Map toJson({ValueSerializer? serializer}) { serializer ??= driftRuntimeOptions.defaultSerializer; return { - 'chain_id': serializer.toJson(chainId), - 'name': serializer.toJson(name), - 'symbol': serializer.toJson(symbol), - 'icon_url': serializer.toJson(iconUrl), - 'threshold': serializer.toJson(threshold), + 'message_id': serializer.toJson(messageId), + 'conversation_id': serializer.toJson(conversationId), + 'has_read': serializer.toJson(hasRead), }; } - Chain copyWith( - {String? chainId, - String? name, - String? symbol, - String? iconUrl, - int? threshold}) => - Chain( - chainId: chainId ?? this.chainId, - name: name ?? this.name, - symbol: symbol ?? this.symbol, - iconUrl: iconUrl ?? this.iconUrl, - threshold: threshold ?? this.threshold, + MessageMention copyWith( + {String? messageId, + String? conversationId, + Value hasRead = const Value.absent()}) => + MessageMention( + messageId: messageId ?? this.messageId, + conversationId: conversationId ?? this.conversationId, + hasRead: hasRead.present ? hasRead.value : this.hasRead, ); @override String toString() { - return (StringBuffer('Chain(') - ..write('chainId: $chainId, ') - ..write('name: $name, ') - ..write('symbol: $symbol, ') - ..write('iconUrl: $iconUrl, ') - ..write('threshold: $threshold') + return (StringBuffer('MessageMention(') + ..write('messageId: $messageId, ') + ..write('conversationId: $conversationId, ') + ..write('hasRead: $hasRead') ..write(')')) .toString(); } @override - int get hashCode => Object.hash(chainId, name, symbol, iconUrl, threshold); + int get hashCode => Object.hash(messageId, conversationId, hasRead); @override bool operator ==(Object other) => identical(this, other) || - (other is Chain && - other.chainId == this.chainId && - other.name == this.name && - other.symbol == this.symbol && - other.iconUrl == this.iconUrl && - other.threshold == this.threshold); + (other is MessageMention && + other.messageId == this.messageId && + other.conversationId == this.conversationId && + other.hasRead == this.hasRead); } -class ChainsCompanion extends UpdateCompanion { - final Value chainId; - final Value name; - final Value symbol; - final Value iconUrl; - final Value threshold; +class MessageMentionsCompanion extends UpdateCompanion { + final Value messageId; + final Value conversationId; + final Value hasRead; final Value rowid; - const ChainsCompanion({ - this.chainId = const Value.absent(), - this.name = const Value.absent(), - this.symbol = const Value.absent(), - this.iconUrl = const Value.absent(), - this.threshold = const Value.absent(), + const MessageMentionsCompanion({ + this.messageId = const Value.absent(), + this.conversationId = const Value.absent(), + this.hasRead = const Value.absent(), this.rowid = const Value.absent(), }); - ChainsCompanion.insert({ - required String chainId, - required String name, - required String symbol, - required String iconUrl, - required int threshold, + MessageMentionsCompanion.insert({ + required String messageId, + required String conversationId, + this.hasRead = const Value.absent(), this.rowid = const Value.absent(), - }) : chainId = Value(chainId), - name = Value(name), - symbol = Value(symbol), - iconUrl = Value(iconUrl), - threshold = Value(threshold); - static Insertable custom({ - Expression? chainId, - Expression? name, - Expression? symbol, - Expression? iconUrl, - Expression? threshold, + }) : messageId = Value(messageId), + conversationId = Value(conversationId); + static Insertable custom({ + Expression? messageId, + Expression? conversationId, + Expression? hasRead, Expression? rowid, }) { return RawValuesInsertable({ - if (chainId != null) 'chain_id': chainId, - if (name != null) 'name': name, - if (symbol != null) 'symbol': symbol, - if (iconUrl != null) 'icon_url': iconUrl, - if (threshold != null) 'threshold': threshold, + if (messageId != null) 'message_id': messageId, + if (conversationId != null) 'conversation_id': conversationId, + if (hasRead != null) 'has_read': hasRead, if (rowid != null) 'rowid': rowid, }); } - ChainsCompanion copyWith( - {Value? chainId, - Value? name, - Value? symbol, - Value? iconUrl, - Value? threshold, + MessageMentionsCompanion copyWith( + {Value? messageId, + Value? conversationId, + Value? hasRead, Value? rowid}) { - return ChainsCompanion( - chainId: chainId ?? this.chainId, - name: name ?? this.name, - symbol: symbol ?? this.symbol, - iconUrl: iconUrl ?? this.iconUrl, - threshold: threshold ?? this.threshold, - rowid: rowid ?? this.rowid, + return MessageMentionsCompanion( + messageId: messageId ?? this.messageId, + conversationId: conversationId ?? this.conversationId, + hasRead: hasRead ?? this.hasRead, + rowid: rowid ?? this.rowid, ); } @override Map toColumns(bool nullToAbsent) { final map = {}; - if (chainId.present) { - map['chain_id'] = Variable(chainId.value); - } - if (name.present) { - map['name'] = Variable(name.value); - } - if (symbol.present) { - map['symbol'] = Variable(symbol.value); + if (messageId.present) { + map['message_id'] = Variable(messageId.value); } - if (iconUrl.present) { - map['icon_url'] = Variable(iconUrl.value); + if (conversationId.present) { + map['conversation_id'] = Variable(conversationId.value); } - if (threshold.present) { - map['threshold'] = Variable(threshold.value); + if (hasRead.present) { + map['has_read'] = Variable(hasRead.value); } if (rowid.present) { map['rowid'] = Variable(rowid.value); @@ -6654,71 +5793,35 @@ class ChainsCompanion extends UpdateCompanion { @override String toString() { - return (StringBuffer('ChainsCompanion(') - ..write('chainId: $chainId, ') - ..write('name: $name, ') - ..write('symbol: $symbol, ') - ..write('iconUrl: $iconUrl, ') - ..write('threshold: $threshold, ') + return (StringBuffer('MessageMentionsCompanion(') + ..write('messageId: $messageId, ') + ..write('conversationId: $conversationId, ') + ..write('hasRead: $hasRead, ') ..write('rowid: $rowid') ..write(')')) .toString(); } } -class Stickers extends Table with TableInfo { +class PinMessages extends Table with TableInfo { @override final GeneratedDatabase attachedDatabase; final String? _alias; - Stickers(this.attachedDatabase, [this._alias]); - static const VerificationMeta _stickerIdMeta = - const VerificationMeta('stickerId'); - late final GeneratedColumn stickerId = GeneratedColumn( - 'sticker_id', aliasedName, false, - type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL'); - static const VerificationMeta _albumIdMeta = - const VerificationMeta('albumId'); - late final GeneratedColumn albumId = GeneratedColumn( - 'album_id', aliasedName, true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: ''); - static const VerificationMeta _nameMeta = const VerificationMeta('name'); - late final GeneratedColumn name = GeneratedColumn( - 'name', aliasedName, false, - type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL'); - static const VerificationMeta _assetUrlMeta = - const VerificationMeta('assetUrl'); - late final GeneratedColumn assetUrl = GeneratedColumn( - 'asset_url', aliasedName, false, + PinMessages(this.attachedDatabase, [this._alias]); + static const VerificationMeta _messageIdMeta = + const VerificationMeta('messageId'); + late final GeneratedColumn messageId = GeneratedColumn( + 'message_id', aliasedName, false, type: DriftSqlType.string, requiredDuringInsert: true, $customConstraints: 'NOT NULL'); - static const VerificationMeta _assetTypeMeta = - const VerificationMeta('assetType'); - late final GeneratedColumn assetType = GeneratedColumn( - 'asset_type', aliasedName, false, + static const VerificationMeta _conversationIdMeta = + const VerificationMeta('conversationId'); + late final GeneratedColumn conversationId = GeneratedColumn( + 'conversation_id', aliasedName, false, type: DriftSqlType.string, requiredDuringInsert: true, $customConstraints: 'NOT NULL'); - static const VerificationMeta _assetWidthMeta = - const VerificationMeta('assetWidth'); - late final GeneratedColumn assetWidth = GeneratedColumn( - 'asset_width', aliasedName, false, - type: DriftSqlType.int, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL'); - static const VerificationMeta _assetHeightMeta = - const VerificationMeta('assetHeight'); - late final GeneratedColumn assetHeight = GeneratedColumn( - 'asset_height', aliasedName, false, - type: DriftSqlType.int, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL'); static const VerificationMeta _createdAtMeta = const VerificationMeta('createdAt'); late final GeneratedColumnWithTypeConverter createdAt = @@ -6726,366 +5829,182 @@ class Stickers extends Table with TableInfo { type: DriftSqlType.int, requiredDuringInsert: true, $customConstraints: 'NOT NULL') - .withConverter(Stickers.$convertercreatedAt); - static const VerificationMeta _lastUseAtMeta = - const VerificationMeta('lastUseAt'); - late final GeneratedColumnWithTypeConverter lastUseAt = - GeneratedColumn('last_use_at', aliasedName, true, - type: DriftSqlType.int, - requiredDuringInsert: false, - $customConstraints: '') - .withConverter(Stickers.$converterlastUseAtn); + .withConverter(PinMessages.$convertercreatedAt); @override - List get $columns => [ - stickerId, - albumId, - name, - assetUrl, - assetType, - assetWidth, - assetHeight, - createdAt, - lastUseAt - ]; + List get $columns => [messageId, conversationId, createdAt]; @override - String get aliasedName => _alias ?? 'stickers'; + String get aliasedName => _alias ?? 'pin_messages'; @override - String get actualTableName => 'stickers'; + String get actualTableName => 'pin_messages'; @override - VerificationContext validateIntegrity(Insertable instance, + VerificationContext validateIntegrity(Insertable instance, {bool isInserting = false}) { final context = VerificationContext(); final data = instance.toColumns(true); - if (data.containsKey('sticker_id')) { - context.handle(_stickerIdMeta, - stickerId.isAcceptableOrUnknown(data['sticker_id']!, _stickerIdMeta)); - } else if (isInserting) { - context.missing(_stickerIdMeta); - } - if (data.containsKey('album_id')) { - context.handle(_albumIdMeta, - albumId.isAcceptableOrUnknown(data['album_id']!, _albumIdMeta)); - } - if (data.containsKey('name')) { - context.handle( - _nameMeta, name.isAcceptableOrUnknown(data['name']!, _nameMeta)); - } else if (isInserting) { - context.missing(_nameMeta); - } - if (data.containsKey('asset_url')) { - context.handle(_assetUrlMeta, - assetUrl.isAcceptableOrUnknown(data['asset_url']!, _assetUrlMeta)); - } else if (isInserting) { - context.missing(_assetUrlMeta); - } - if (data.containsKey('asset_type')) { - context.handle(_assetTypeMeta, - assetType.isAcceptableOrUnknown(data['asset_type']!, _assetTypeMeta)); - } else if (isInserting) { - context.missing(_assetTypeMeta); - } - if (data.containsKey('asset_width')) { - context.handle( - _assetWidthMeta, - assetWidth.isAcceptableOrUnknown( - data['asset_width']!, _assetWidthMeta)); + if (data.containsKey('message_id')) { + context.handle(_messageIdMeta, + messageId.isAcceptableOrUnknown(data['message_id']!, _messageIdMeta)); } else if (isInserting) { - context.missing(_assetWidthMeta); + context.missing(_messageIdMeta); } - if (data.containsKey('asset_height')) { + if (data.containsKey('conversation_id')) { context.handle( - _assetHeightMeta, - assetHeight.isAcceptableOrUnknown( - data['asset_height']!, _assetHeightMeta)); + _conversationIdMeta, + conversationId.isAcceptableOrUnknown( + data['conversation_id']!, _conversationIdMeta)); } else if (isInserting) { - context.missing(_assetHeightMeta); + context.missing(_conversationIdMeta); } context.handle(_createdAtMeta, const VerificationResult.success()); - context.handle(_lastUseAtMeta, const VerificationResult.success()); return context; } @override - Set get $primaryKey => {stickerId}; + Set get $primaryKey => {messageId}; @override - Sticker map(Map data, {String? tablePrefix}) { + PinMessage map(Map data, {String? tablePrefix}) { final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; - return Sticker( - stickerId: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}sticker_id'])!, - albumId: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}album_id']), - name: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}name'])!, - assetUrl: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}asset_url'])!, - assetType: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}asset_type'])!, - assetWidth: attachedDatabase.typeMapping - .read(DriftSqlType.int, data['${effectivePrefix}asset_width'])!, - assetHeight: attachedDatabase.typeMapping - .read(DriftSqlType.int, data['${effectivePrefix}asset_height'])!, - createdAt: Stickers.$convertercreatedAt.fromSql(attachedDatabase + return PinMessage( + messageId: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}message_id'])!, + conversationId: attachedDatabase.typeMapping.read( + DriftSqlType.string, data['${effectivePrefix}conversation_id'])!, + createdAt: PinMessages.$convertercreatedAt.fromSql(attachedDatabase .typeMapping .read(DriftSqlType.int, data['${effectivePrefix}created_at'])!), - lastUseAt: Stickers.$converterlastUseAtn.fromSql(attachedDatabase - .typeMapping - .read(DriftSqlType.int, data['${effectivePrefix}last_use_at'])), ); } @override - Stickers createAlias(String alias) { - return Stickers(attachedDatabase, alias); + PinMessages createAlias(String alias) { + return PinMessages(attachedDatabase, alias); } static TypeConverter $convertercreatedAt = const MillisDateConverter(); - static TypeConverter $converterlastUseAt = - const MillisDateConverter(); - static TypeConverter $converterlastUseAtn = - NullAwareTypeConverter.wrap($converterlastUseAt); @override - List get customConstraints => const ['PRIMARY KEY(sticker_id)']; + List get customConstraints => const ['PRIMARY KEY(message_id)']; @override bool get dontWriteConstraints => true; } -class Sticker extends DataClass implements Insertable { - final String stickerId; - final String? albumId; - final String name; - final String assetUrl; - final String assetType; - final int assetWidth; - final int assetHeight; +class PinMessage extends DataClass implements Insertable { + final String messageId; + final String conversationId; final DateTime createdAt; - final DateTime? lastUseAt; - const Sticker( - {required this.stickerId, - this.albumId, - required this.name, - required this.assetUrl, - required this.assetType, - required this.assetWidth, - required this.assetHeight, - required this.createdAt, - this.lastUseAt}); + const PinMessage( + {required this.messageId, + required this.conversationId, + required this.createdAt}); @override Map toColumns(bool nullToAbsent) { final map = {}; - map['sticker_id'] = Variable(stickerId); - if (!nullToAbsent || albumId != null) { - map['album_id'] = Variable(albumId); - } - map['name'] = Variable(name); - map['asset_url'] = Variable(assetUrl); - map['asset_type'] = Variable(assetType); - map['asset_width'] = Variable(assetWidth); - map['asset_height'] = Variable(assetHeight); + map['message_id'] = Variable(messageId); + map['conversation_id'] = Variable(conversationId); { - final converter = Stickers.$convertercreatedAt; + final converter = PinMessages.$convertercreatedAt; map['created_at'] = Variable(converter.toSql(createdAt)); } - if (!nullToAbsent || lastUseAt != null) { - final converter = Stickers.$converterlastUseAtn; - map['last_use_at'] = Variable(converter.toSql(lastUseAt)); - } return map; } - StickersCompanion toCompanion(bool nullToAbsent) { - return StickersCompanion( - stickerId: Value(stickerId), - albumId: albumId == null && nullToAbsent - ? const Value.absent() - : Value(albumId), - name: Value(name), - assetUrl: Value(assetUrl), - assetType: Value(assetType), - assetWidth: Value(assetWidth), - assetHeight: Value(assetHeight), + PinMessagesCompanion toCompanion(bool nullToAbsent) { + return PinMessagesCompanion( + messageId: Value(messageId), + conversationId: Value(conversationId), createdAt: Value(createdAt), - lastUseAt: lastUseAt == null && nullToAbsent - ? const Value.absent() - : Value(lastUseAt), ); } - factory Sticker.fromJson(Map json, + factory PinMessage.fromJson(Map json, {ValueSerializer? serializer}) { serializer ??= driftRuntimeOptions.defaultSerializer; - return Sticker( - stickerId: serializer.fromJson(json['sticker_id']), - albumId: serializer.fromJson(json['album_id']), - name: serializer.fromJson(json['name']), - assetUrl: serializer.fromJson(json['asset_url']), - assetType: serializer.fromJson(json['asset_type']), - assetWidth: serializer.fromJson(json['asset_width']), - assetHeight: serializer.fromJson(json['asset_height']), + return PinMessage( + messageId: serializer.fromJson(json['message_id']), + conversationId: serializer.fromJson(json['conversation_id']), createdAt: serializer.fromJson(json['created_at']), - lastUseAt: serializer.fromJson(json['last_use_at']), ); } @override Map toJson({ValueSerializer? serializer}) { serializer ??= driftRuntimeOptions.defaultSerializer; return { - 'sticker_id': serializer.toJson(stickerId), - 'album_id': serializer.toJson(albumId), - 'name': serializer.toJson(name), - 'asset_url': serializer.toJson(assetUrl), - 'asset_type': serializer.toJson(assetType), - 'asset_width': serializer.toJson(assetWidth), - 'asset_height': serializer.toJson(assetHeight), + 'message_id': serializer.toJson(messageId), + 'conversation_id': serializer.toJson(conversationId), 'created_at': serializer.toJson(createdAt), - 'last_use_at': serializer.toJson(lastUseAt), }; } - Sticker copyWith( - {String? stickerId, - Value albumId = const Value.absent(), - String? name, - String? assetUrl, - String? assetType, - int? assetWidth, - int? assetHeight, - DateTime? createdAt, - Value lastUseAt = const Value.absent()}) => - Sticker( - stickerId: stickerId ?? this.stickerId, - albumId: albumId.present ? albumId.value : this.albumId, - name: name ?? this.name, - assetUrl: assetUrl ?? this.assetUrl, - assetType: assetType ?? this.assetType, - assetWidth: assetWidth ?? this.assetWidth, - assetHeight: assetHeight ?? this.assetHeight, + PinMessage copyWith( + {String? messageId, String? conversationId, DateTime? createdAt}) => + PinMessage( + messageId: messageId ?? this.messageId, + conversationId: conversationId ?? this.conversationId, createdAt: createdAt ?? this.createdAt, - lastUseAt: lastUseAt.present ? lastUseAt.value : this.lastUseAt, ); @override String toString() { - return (StringBuffer('Sticker(') - ..write('stickerId: $stickerId, ') - ..write('albumId: $albumId, ') - ..write('name: $name, ') - ..write('assetUrl: $assetUrl, ') - ..write('assetType: $assetType, ') - ..write('assetWidth: $assetWidth, ') - ..write('assetHeight: $assetHeight, ') - ..write('createdAt: $createdAt, ') - ..write('lastUseAt: $lastUseAt') + return (StringBuffer('PinMessage(') + ..write('messageId: $messageId, ') + ..write('conversationId: $conversationId, ') + ..write('createdAt: $createdAt') ..write(')')) .toString(); } @override - int get hashCode => Object.hash(stickerId, albumId, name, assetUrl, assetType, - assetWidth, assetHeight, createdAt, lastUseAt); + int get hashCode => Object.hash(messageId, conversationId, createdAt); @override bool operator ==(Object other) => identical(this, other) || - (other is Sticker && - other.stickerId == this.stickerId && - other.albumId == this.albumId && - other.name == this.name && - other.assetUrl == this.assetUrl && - other.assetType == this.assetType && - other.assetWidth == this.assetWidth && - other.assetHeight == this.assetHeight && - other.createdAt == this.createdAt && - other.lastUseAt == this.lastUseAt); + (other is PinMessage && + other.messageId == this.messageId && + other.conversationId == this.conversationId && + other.createdAt == this.createdAt); } -class StickersCompanion extends UpdateCompanion { - final Value stickerId; - final Value albumId; - final Value name; - final Value assetUrl; - final Value assetType; - final Value assetWidth; - final Value assetHeight; +class PinMessagesCompanion extends UpdateCompanion { + final Value messageId; + final Value conversationId; final Value createdAt; - final Value lastUseAt; final Value rowid; - const StickersCompanion({ - this.stickerId = const Value.absent(), - this.albumId = const Value.absent(), - this.name = const Value.absent(), - this.assetUrl = const Value.absent(), - this.assetType = const Value.absent(), - this.assetWidth = const Value.absent(), - this.assetHeight = const Value.absent(), + const PinMessagesCompanion({ + this.messageId = const Value.absent(), + this.conversationId = const Value.absent(), this.createdAt = const Value.absent(), - this.lastUseAt = const Value.absent(), this.rowid = const Value.absent(), }); - StickersCompanion.insert({ - required String stickerId, - this.albumId = const Value.absent(), - required String name, - required String assetUrl, - required String assetType, - required int assetWidth, - required int assetHeight, + PinMessagesCompanion.insert({ + required String messageId, + required String conversationId, required DateTime createdAt, - this.lastUseAt = const Value.absent(), this.rowid = const Value.absent(), - }) : stickerId = Value(stickerId), - name = Value(name), - assetUrl = Value(assetUrl), - assetType = Value(assetType), - assetWidth = Value(assetWidth), - assetHeight = Value(assetHeight), + }) : messageId = Value(messageId), + conversationId = Value(conversationId), createdAt = Value(createdAt); - static Insertable custom({ - Expression? stickerId, - Expression? albumId, - Expression? name, - Expression? assetUrl, - Expression? assetType, - Expression? assetWidth, - Expression? assetHeight, + static Insertable custom({ + Expression? messageId, + Expression? conversationId, Expression? createdAt, - Expression? lastUseAt, Expression? rowid, }) { return RawValuesInsertable({ - if (stickerId != null) 'sticker_id': stickerId, - if (albumId != null) 'album_id': albumId, - if (name != null) 'name': name, - if (assetUrl != null) 'asset_url': assetUrl, - if (assetType != null) 'asset_type': assetType, - if (assetWidth != null) 'asset_width': assetWidth, - if (assetHeight != null) 'asset_height': assetHeight, + if (messageId != null) 'message_id': messageId, + if (conversationId != null) 'conversation_id': conversationId, if (createdAt != null) 'created_at': createdAt, - if (lastUseAt != null) 'last_use_at': lastUseAt, if (rowid != null) 'rowid': rowid, }); } - StickersCompanion copyWith( - {Value? stickerId, - Value? albumId, - Value? name, - Value? assetUrl, - Value? assetType, - Value? assetWidth, - Value? assetHeight, + PinMessagesCompanion copyWith( + {Value? messageId, + Value? conversationId, Value? createdAt, - Value? lastUseAt, Value? rowid}) { - return StickersCompanion( - stickerId: stickerId ?? this.stickerId, - albumId: albumId ?? this.albumId, - name: name ?? this.name, - assetUrl: assetUrl ?? this.assetUrl, - assetType: assetType ?? this.assetType, - assetWidth: assetWidth ?? this.assetWidth, - assetHeight: assetHeight ?? this.assetHeight, + return PinMessagesCompanion( + messageId: messageId ?? this.messageId, + conversationId: conversationId ?? this.conversationId, createdAt: createdAt ?? this.createdAt, - lastUseAt: lastUseAt ?? this.lastUseAt, rowid: rowid ?? this.rowid, ); } @@ -7093,35 +6012,16 @@ class StickersCompanion extends UpdateCompanion { @override Map toColumns(bool nullToAbsent) { final map = {}; - if (stickerId.present) { - map['sticker_id'] = Variable(stickerId.value); - } - if (albumId.present) { - map['album_id'] = Variable(albumId.value); - } - if (name.present) { - map['name'] = Variable(name.value); - } - if (assetUrl.present) { - map['asset_url'] = Variable(assetUrl.value); - } - if (assetType.present) { - map['asset_type'] = Variable(assetType.value); - } - if (assetWidth.present) { - map['asset_width'] = Variable(assetWidth.value); + if (messageId.present) { + map['message_id'] = Variable(messageId.value); } - if (assetHeight.present) { - map['asset_height'] = Variable(assetHeight.value); + if (conversationId.present) { + map['conversation_id'] = Variable(conversationId.value); } if (createdAt.present) { - final converter = Stickers.$convertercreatedAt; + final converter = PinMessages.$convertercreatedAt; map['created_at'] = Variable(converter.toSql(createdAt.value)); } - if (lastUseAt.present) { - final converter = Stickers.$converterlastUseAtn; - map['last_use_at'] = Variable(converter.toSql(lastUseAt.value)); - } if (rowid.present) { map['rowid'] = Variable(rowid.value); } @@ -7130,296 +6030,216 @@ class StickersCompanion extends UpdateCompanion { @override String toString() { - return (StringBuffer('StickersCompanion(') - ..write('stickerId: $stickerId, ') - ..write('albumId: $albumId, ') - ..write('name: $name, ') - ..write('assetUrl: $assetUrl, ') - ..write('assetType: $assetType, ') - ..write('assetWidth: $assetWidth, ') - ..write('assetHeight: $assetHeight, ') + return (StringBuffer('PinMessagesCompanion(') + ..write('messageId: $messageId, ') + ..write('conversationId: $conversationId, ') ..write('createdAt: $createdAt, ') - ..write('lastUseAt: $lastUseAt, ') ..write('rowid: $rowid') ..write(')')) .toString(); } } -class Hyperlinks extends Table with TableInfo { +class ExpiredMessages extends Table + with TableInfo { @override final GeneratedDatabase attachedDatabase; final String? _alias; - Hyperlinks(this.attachedDatabase, [this._alias]); - static const VerificationMeta _hyperlinkMeta = - const VerificationMeta('hyperlink'); - late final GeneratedColumn hyperlink = GeneratedColumn( - 'hyperlink', aliasedName, false, - type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL'); - static const VerificationMeta _siteNameMeta = - const VerificationMeta('siteName'); - late final GeneratedColumn siteName = GeneratedColumn( - 'site_name', aliasedName, false, + ExpiredMessages(this.attachedDatabase, [this._alias]); + static const VerificationMeta _messageIdMeta = + const VerificationMeta('messageId'); + late final GeneratedColumn messageId = GeneratedColumn( + 'message_id', aliasedName, false, type: DriftSqlType.string, requiredDuringInsert: true, $customConstraints: 'NOT NULL'); - static const VerificationMeta _siteTitleMeta = - const VerificationMeta('siteTitle'); - late final GeneratedColumn siteTitle = GeneratedColumn( - 'site_title', aliasedName, false, - type: DriftSqlType.string, + static const VerificationMeta _expireInMeta = + const VerificationMeta('expireIn'); + late final GeneratedColumn expireIn = GeneratedColumn( + 'expire_in', aliasedName, false, + type: DriftSqlType.int, requiredDuringInsert: true, $customConstraints: 'NOT NULL'); - static const VerificationMeta _siteDescriptionMeta = - const VerificationMeta('siteDescription'); - late final GeneratedColumn siteDescription = GeneratedColumn( - 'site_description', aliasedName, true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: ''); - static const VerificationMeta _siteImageMeta = - const VerificationMeta('siteImage'); - late final GeneratedColumn siteImage = GeneratedColumn( - 'site_image', aliasedName, true, - type: DriftSqlType.string, + static const VerificationMeta _expireAtMeta = + const VerificationMeta('expireAt'); + late final GeneratedColumn expireAt = GeneratedColumn( + 'expire_at', aliasedName, true, + type: DriftSqlType.int, requiredDuringInsert: false, $customConstraints: ''); @override - List get $columns => - [hyperlink, siteName, siteTitle, siteDescription, siteImage]; + List get $columns => [messageId, expireIn, expireAt]; @override - String get aliasedName => _alias ?? 'hyperlinks'; + String get aliasedName => _alias ?? 'expired_messages'; @override - String get actualTableName => 'hyperlinks'; + String get actualTableName => 'expired_messages'; @override - VerificationContext validateIntegrity(Insertable instance, + VerificationContext validateIntegrity(Insertable instance, {bool isInserting = false}) { final context = VerificationContext(); final data = instance.toColumns(true); - if (data.containsKey('hyperlink')) { - context.handle(_hyperlinkMeta, - hyperlink.isAcceptableOrUnknown(data['hyperlink']!, _hyperlinkMeta)); - } else if (isInserting) { - context.missing(_hyperlinkMeta); - } - if (data.containsKey('site_name')) { - context.handle(_siteNameMeta, - siteName.isAcceptableOrUnknown(data['site_name']!, _siteNameMeta)); + if (data.containsKey('message_id')) { + context.handle(_messageIdMeta, + messageId.isAcceptableOrUnknown(data['message_id']!, _messageIdMeta)); } else if (isInserting) { - context.missing(_siteNameMeta); + context.missing(_messageIdMeta); } - if (data.containsKey('site_title')) { - context.handle(_siteTitleMeta, - siteTitle.isAcceptableOrUnknown(data['site_title']!, _siteTitleMeta)); + if (data.containsKey('expire_in')) { + context.handle(_expireInMeta, + expireIn.isAcceptableOrUnknown(data['expire_in']!, _expireInMeta)); } else if (isInserting) { - context.missing(_siteTitleMeta); - } - if (data.containsKey('site_description')) { - context.handle( - _siteDescriptionMeta, - siteDescription.isAcceptableOrUnknown( - data['site_description']!, _siteDescriptionMeta)); + context.missing(_expireInMeta); } - if (data.containsKey('site_image')) { - context.handle(_siteImageMeta, - siteImage.isAcceptableOrUnknown(data['site_image']!, _siteImageMeta)); + if (data.containsKey('expire_at')) { + context.handle(_expireAtMeta, + expireAt.isAcceptableOrUnknown(data['expire_at']!, _expireAtMeta)); } return context; } @override - Set get $primaryKey => {hyperlink}; + Set get $primaryKey => {messageId}; @override - Hyperlink map(Map data, {String? tablePrefix}) { + ExpiredMessage map(Map data, {String? tablePrefix}) { final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; - return Hyperlink( - hyperlink: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}hyperlink'])!, - siteName: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}site_name'])!, - siteTitle: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}site_title'])!, - siteDescription: attachedDatabase.typeMapping.read( - DriftSqlType.string, data['${effectivePrefix}site_description']), - siteImage: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}site_image']), + return ExpiredMessage( + messageId: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}message_id'])!, + expireIn: attachedDatabase.typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}expire_in'])!, + expireAt: attachedDatabase.typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}expire_at']), ); } @override - Hyperlinks createAlias(String alias) { - return Hyperlinks(attachedDatabase, alias); + ExpiredMessages createAlias(String alias) { + return ExpiredMessages(attachedDatabase, alias); } @override - List get customConstraints => const ['PRIMARY KEY(hyperlink)']; + List get customConstraints => const ['PRIMARY KEY(message_id)']; @override bool get dontWriteConstraints => true; } -class Hyperlink extends DataClass implements Insertable { - final String hyperlink; - final String siteName; - final String siteTitle; - final String? siteDescription; - final String? siteImage; - const Hyperlink( - {required this.hyperlink, - required this.siteName, - required this.siteTitle, - this.siteDescription, - this.siteImage}); +class ExpiredMessage extends DataClass implements Insertable { + final String messageId; + final int expireIn; + final int? expireAt; + const ExpiredMessage( + {required this.messageId, required this.expireIn, this.expireAt}); @override Map toColumns(bool nullToAbsent) { final map = {}; - map['hyperlink'] = Variable(hyperlink); - map['site_name'] = Variable(siteName); - map['site_title'] = Variable(siteTitle); - if (!nullToAbsent || siteDescription != null) { - map['site_description'] = Variable(siteDescription); - } - if (!nullToAbsent || siteImage != null) { - map['site_image'] = Variable(siteImage); + map['message_id'] = Variable(messageId); + map['expire_in'] = Variable(expireIn); + if (!nullToAbsent || expireAt != null) { + map['expire_at'] = Variable(expireAt); } return map; } - HyperlinksCompanion toCompanion(bool nullToAbsent) { - return HyperlinksCompanion( - hyperlink: Value(hyperlink), - siteName: Value(siteName), - siteTitle: Value(siteTitle), - siteDescription: siteDescription == null && nullToAbsent - ? const Value.absent() - : Value(siteDescription), - siteImage: siteImage == null && nullToAbsent + ExpiredMessagesCompanion toCompanion(bool nullToAbsent) { + return ExpiredMessagesCompanion( + messageId: Value(messageId), + expireIn: Value(expireIn), + expireAt: expireAt == null && nullToAbsent ? const Value.absent() - : Value(siteImage), + : Value(expireAt), ); } - factory Hyperlink.fromJson(Map json, + factory ExpiredMessage.fromJson(Map json, {ValueSerializer? serializer}) { serializer ??= driftRuntimeOptions.defaultSerializer; - return Hyperlink( - hyperlink: serializer.fromJson(json['hyperlink']), - siteName: serializer.fromJson(json['site_name']), - siteTitle: serializer.fromJson(json['site_title']), - siteDescription: serializer.fromJson(json['site_description']), - siteImage: serializer.fromJson(json['site_image']), + return ExpiredMessage( + messageId: serializer.fromJson(json['message_id']), + expireIn: serializer.fromJson(json['expire_in']), + expireAt: serializer.fromJson(json['expire_at']), ); } @override Map toJson({ValueSerializer? serializer}) { serializer ??= driftRuntimeOptions.defaultSerializer; return { - 'hyperlink': serializer.toJson(hyperlink), - 'site_name': serializer.toJson(siteName), - 'site_title': serializer.toJson(siteTitle), - 'site_description': serializer.toJson(siteDescription), - 'site_image': serializer.toJson(siteImage), + 'message_id': serializer.toJson(messageId), + 'expire_in': serializer.toJson(expireIn), + 'expire_at': serializer.toJson(expireAt), }; } - Hyperlink copyWith( - {String? hyperlink, - String? siteName, - String? siteTitle, - Value siteDescription = const Value.absent(), - Value siteImage = const Value.absent()}) => - Hyperlink( - hyperlink: hyperlink ?? this.hyperlink, - siteName: siteName ?? this.siteName, - siteTitle: siteTitle ?? this.siteTitle, - siteDescription: siteDescription.present - ? siteDescription.value - : this.siteDescription, - siteImage: siteImage.present ? siteImage.value : this.siteImage, + ExpiredMessage copyWith( + {String? messageId, + int? expireIn, + Value expireAt = const Value.absent()}) => + ExpiredMessage( + messageId: messageId ?? this.messageId, + expireIn: expireIn ?? this.expireIn, + expireAt: expireAt.present ? expireAt.value : this.expireAt, ); @override String toString() { - return (StringBuffer('Hyperlink(') - ..write('hyperlink: $hyperlink, ') - ..write('siteName: $siteName, ') - ..write('siteTitle: $siteTitle, ') - ..write('siteDescription: $siteDescription, ') - ..write('siteImage: $siteImage') + return (StringBuffer('ExpiredMessage(') + ..write('messageId: $messageId, ') + ..write('expireIn: $expireIn, ') + ..write('expireAt: $expireAt') ..write(')')) .toString(); } @override - int get hashCode => - Object.hash(hyperlink, siteName, siteTitle, siteDescription, siteImage); + int get hashCode => Object.hash(messageId, expireIn, expireAt); @override bool operator ==(Object other) => identical(this, other) || - (other is Hyperlink && - other.hyperlink == this.hyperlink && - other.siteName == this.siteName && - other.siteTitle == this.siteTitle && - other.siteDescription == this.siteDescription && - other.siteImage == this.siteImage); + (other is ExpiredMessage && + other.messageId == this.messageId && + other.expireIn == this.expireIn && + other.expireAt == this.expireAt); } -class HyperlinksCompanion extends UpdateCompanion { - final Value hyperlink; - final Value siteName; - final Value siteTitle; - final Value siteDescription; - final Value siteImage; +class ExpiredMessagesCompanion extends UpdateCompanion { + final Value messageId; + final Value expireIn; + final Value expireAt; final Value rowid; - const HyperlinksCompanion({ - this.hyperlink = const Value.absent(), - this.siteName = const Value.absent(), - this.siteTitle = const Value.absent(), - this.siteDescription = const Value.absent(), - this.siteImage = const Value.absent(), + const ExpiredMessagesCompanion({ + this.messageId = const Value.absent(), + this.expireIn = const Value.absent(), + this.expireAt = const Value.absent(), this.rowid = const Value.absent(), }); - HyperlinksCompanion.insert({ - required String hyperlink, - required String siteName, - required String siteTitle, - this.siteDescription = const Value.absent(), - this.siteImage = const Value.absent(), + ExpiredMessagesCompanion.insert({ + required String messageId, + required int expireIn, + this.expireAt = const Value.absent(), this.rowid = const Value.absent(), - }) : hyperlink = Value(hyperlink), - siteName = Value(siteName), - siteTitle = Value(siteTitle); - static Insertable custom({ - Expression? hyperlink, - Expression? siteName, - Expression? siteTitle, - Expression? siteDescription, - Expression? siteImage, + }) : messageId = Value(messageId), + expireIn = Value(expireIn); + static Insertable custom({ + Expression? messageId, + Expression? expireIn, + Expression? expireAt, Expression? rowid, }) { return RawValuesInsertable({ - if (hyperlink != null) 'hyperlink': hyperlink, - if (siteName != null) 'site_name': siteName, - if (siteTitle != null) 'site_title': siteTitle, - if (siteDescription != null) 'site_description': siteDescription, - if (siteImage != null) 'site_image': siteImage, + if (messageId != null) 'message_id': messageId, + if (expireIn != null) 'expire_in': expireIn, + if (expireAt != null) 'expire_at': expireAt, if (rowid != null) 'rowid': rowid, }); } - HyperlinksCompanion copyWith( - {Value? hyperlink, - Value? siteName, - Value? siteTitle, - Value? siteDescription, - Value? siteImage, + ExpiredMessagesCompanion copyWith( + {Value? messageId, + Value? expireIn, + Value? expireAt, Value? rowid}) { - return HyperlinksCompanion( - hyperlink: hyperlink ?? this.hyperlink, - siteName: siteName ?? this.siteName, - siteTitle: siteTitle ?? this.siteTitle, - siteDescription: siteDescription ?? this.siteDescription, - siteImage: siteImage ?? this.siteImage, + return ExpiredMessagesCompanion( + messageId: messageId ?? this.messageId, + expireIn: expireIn ?? this.expireIn, + expireAt: expireAt ?? this.expireAt, rowid: rowid ?? this.rowid, ); } @@ -7427,20 +6247,14 @@ class HyperlinksCompanion extends UpdateCompanion { @override Map toColumns(bool nullToAbsent) { final map = {}; - if (hyperlink.present) { - map['hyperlink'] = Variable(hyperlink.value); - } - if (siteName.present) { - map['site_name'] = Variable(siteName.value); - } - if (siteTitle.present) { - map['site_title'] = Variable(siteTitle.value); + if (messageId.present) { + map['message_id'] = Variable(messageId.value); } - if (siteDescription.present) { - map['site_description'] = Variable(siteDescription.value); + if (expireIn.present) { + map['expire_in'] = Variable(expireIn.value); } - if (siteImage.present) { - map['site_image'] = Variable(siteImage.value); + if (expireAt.present) { + map['expire_at'] = Variable(expireAt.value); } if (rowid.present) { map['rowid'] = Variable(rowid.value); @@ -7450,235 +6264,493 @@ class HyperlinksCompanion extends UpdateCompanion { @override String toString() { - return (StringBuffer('HyperlinksCompanion(') - ..write('hyperlink: $hyperlink, ') - ..write('siteName: $siteName, ') - ..write('siteTitle: $siteTitle, ') - ..write('siteDescription: $siteDescription, ') - ..write('siteImage: $siteImage, ') + return (StringBuffer('ExpiredMessagesCompanion(') + ..write('messageId: $messageId, ') + ..write('expireIn: $expireIn, ') + ..write('expireAt: $expireAt, ') ..write('rowid: $rowid') ..write(')')) .toString(); } } -class MessageMentions extends Table - with TableInfo { +class Addresses extends Table with TableInfo { @override final GeneratedDatabase attachedDatabase; final String? _alias; - MessageMentions(this.attachedDatabase, [this._alias]); - static const VerificationMeta _messageIdMeta = - const VerificationMeta('messageId'); - late final GeneratedColumn messageId = GeneratedColumn( - 'message_id', aliasedName, false, + Addresses(this.attachedDatabase, [this._alias]); + static const VerificationMeta _addressIdMeta = + const VerificationMeta('addressId'); + late final GeneratedColumn addressId = GeneratedColumn( + 'address_id', aliasedName, false, type: DriftSqlType.string, requiredDuringInsert: true, $customConstraints: 'NOT NULL'); - static const VerificationMeta _conversationIdMeta = - const VerificationMeta('conversationId'); - late final GeneratedColumn conversationId = GeneratedColumn( - 'conversation_id', aliasedName, false, + static const VerificationMeta _typeMeta = const VerificationMeta('type'); + late final GeneratedColumn type = GeneratedColumn( + 'type', aliasedName, false, type: DriftSqlType.string, requiredDuringInsert: true, $customConstraints: 'NOT NULL'); - static const VerificationMeta _hasReadMeta = - const VerificationMeta('hasRead'); - late final GeneratedColumn hasRead = GeneratedColumn( - 'has_read', aliasedName, true, - type: DriftSqlType.bool, + static const VerificationMeta _assetIdMeta = + const VerificationMeta('assetId'); + late final GeneratedColumn assetId = GeneratedColumn( + 'asset_id', aliasedName, false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL'); + static const VerificationMeta _destinationMeta = + const VerificationMeta('destination'); + late final GeneratedColumn destination = GeneratedColumn( + 'destination', aliasedName, false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL'); + static const VerificationMeta _labelMeta = const VerificationMeta('label'); + late final GeneratedColumn label = GeneratedColumn( + 'label', aliasedName, false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL'); + static const VerificationMeta _updatedAtMeta = + const VerificationMeta('updatedAt'); + late final GeneratedColumnWithTypeConverter updatedAt = + GeneratedColumn('updated_at', aliasedName, false, + type: DriftSqlType.int, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL') + .withConverter(Addresses.$converterupdatedAt); + static const VerificationMeta _reserveMeta = + const VerificationMeta('reserve'); + late final GeneratedColumn reserve = GeneratedColumn( + 'reserve', aliasedName, false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL'); + static const VerificationMeta _feeMeta = const VerificationMeta('fee'); + late final GeneratedColumn fee = GeneratedColumn( + 'fee', aliasedName, false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL'); + static const VerificationMeta _tagMeta = const VerificationMeta('tag'); + late final GeneratedColumn tag = GeneratedColumn( + 'tag', aliasedName, true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: ''); + static const VerificationMeta _dustMeta = const VerificationMeta('dust'); + late final GeneratedColumn dust = GeneratedColumn( + 'dust', aliasedName, true, + type: DriftSqlType.string, requiredDuringInsert: false, $customConstraints: ''); @override - List get $columns => [messageId, conversationId, hasRead]; + List get $columns => [ + addressId, + type, + assetId, + destination, + label, + updatedAt, + reserve, + fee, + tag, + dust + ]; @override - String get aliasedName => _alias ?? 'message_mentions'; + String get aliasedName => _alias ?? 'addresses'; @override - String get actualTableName => 'message_mentions'; + String get actualTableName => 'addresses'; @override - VerificationContext validateIntegrity(Insertable instance, + VerificationContext validateIntegrity(Insertable instance, {bool isInserting = false}) { final context = VerificationContext(); final data = instance.toColumns(true); - if (data.containsKey('message_id')) { - context.handle(_messageIdMeta, - messageId.isAcceptableOrUnknown(data['message_id']!, _messageIdMeta)); + if (data.containsKey('address_id')) { + context.handle(_addressIdMeta, + addressId.isAcceptableOrUnknown(data['address_id']!, _addressIdMeta)); } else if (isInserting) { - context.missing(_messageIdMeta); + context.missing(_addressIdMeta); } - if (data.containsKey('conversation_id')) { + if (data.containsKey('type')) { context.handle( - _conversationIdMeta, - conversationId.isAcceptableOrUnknown( - data['conversation_id']!, _conversationIdMeta)); + _typeMeta, type.isAcceptableOrUnknown(data['type']!, _typeMeta)); } else if (isInserting) { - context.missing(_conversationIdMeta); + context.missing(_typeMeta); } - if (data.containsKey('has_read')) { - context.handle(_hasReadMeta, - hasRead.isAcceptableOrUnknown(data['has_read']!, _hasReadMeta)); + if (data.containsKey('asset_id')) { + context.handle(_assetIdMeta, + assetId.isAcceptableOrUnknown(data['asset_id']!, _assetIdMeta)); + } else if (isInserting) { + context.missing(_assetIdMeta); + } + if (data.containsKey('destination')) { + context.handle( + _destinationMeta, + destination.isAcceptableOrUnknown( + data['destination']!, _destinationMeta)); + } else if (isInserting) { + context.missing(_destinationMeta); + } + if (data.containsKey('label')) { + context.handle( + _labelMeta, label.isAcceptableOrUnknown(data['label']!, _labelMeta)); + } else if (isInserting) { + context.missing(_labelMeta); + } + context.handle(_updatedAtMeta, const VerificationResult.success()); + if (data.containsKey('reserve')) { + context.handle(_reserveMeta, + reserve.isAcceptableOrUnknown(data['reserve']!, _reserveMeta)); + } else if (isInserting) { + context.missing(_reserveMeta); + } + if (data.containsKey('fee')) { + context.handle( + _feeMeta, fee.isAcceptableOrUnknown(data['fee']!, _feeMeta)); + } else if (isInserting) { + context.missing(_feeMeta); + } + if (data.containsKey('tag')) { + context.handle( + _tagMeta, tag.isAcceptableOrUnknown(data['tag']!, _tagMeta)); + } + if (data.containsKey('dust')) { + context.handle( + _dustMeta, dust.isAcceptableOrUnknown(data['dust']!, _dustMeta)); } return context; } @override - Set get $primaryKey => {messageId}; + Set get $primaryKey => {addressId}; @override - MessageMention map(Map data, {String? tablePrefix}) { + Addresse map(Map data, {String? tablePrefix}) { final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; - return MessageMention( - messageId: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}message_id'])!, - conversationId: attachedDatabase.typeMapping.read( - DriftSqlType.string, data['${effectivePrefix}conversation_id'])!, - hasRead: attachedDatabase.typeMapping - .read(DriftSqlType.bool, data['${effectivePrefix}has_read']), + return Addresse( + addressId: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}address_id'])!, + type: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}type'])!, + assetId: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}asset_id'])!, + destination: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}destination'])!, + label: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}label'])!, + updatedAt: Addresses.$converterupdatedAt.fromSql(attachedDatabase + .typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}updated_at'])!), + reserve: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}reserve'])!, + fee: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}fee'])!, + tag: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}tag']), + dust: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}dust']), ); } @override - MessageMentions createAlias(String alias) { - return MessageMentions(attachedDatabase, alias); + Addresses createAlias(String alias) { + return Addresses(attachedDatabase, alias); } + static TypeConverter $converterupdatedAt = + const MillisDateConverter(); @override - List get customConstraints => const ['PRIMARY KEY(message_id)']; + List get customConstraints => const ['PRIMARY KEY(address_id)']; @override bool get dontWriteConstraints => true; } -class MessageMention extends DataClass implements Insertable { - final String messageId; - final String conversationId; - final bool? hasRead; - const MessageMention( - {required this.messageId, required this.conversationId, this.hasRead}); - @override - Map toColumns(bool nullToAbsent) { - final map = {}; - map['message_id'] = Variable(messageId); - map['conversation_id'] = Variable(conversationId); - if (!nullToAbsent || hasRead != null) { - map['has_read'] = Variable(hasRead); - } - return map; - } - - MessageMentionsCompanion toCompanion(bool nullToAbsent) { - return MessageMentionsCompanion( - messageId: Value(messageId), - conversationId: Value(conversationId), - hasRead: hasRead == null && nullToAbsent - ? const Value.absent() - : Value(hasRead), - ); +class Addresse extends DataClass implements Insertable { + final String addressId; + final String type; + final String assetId; + final String destination; + final String label; + final DateTime updatedAt; + final String reserve; + final String fee; + final String? tag; + final String? dust; + const Addresse( + {required this.addressId, + required this.type, + required this.assetId, + required this.destination, + required this.label, + required this.updatedAt, + required this.reserve, + required this.fee, + this.tag, + this.dust}); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['address_id'] = Variable(addressId); + map['type'] = Variable(type); + map['asset_id'] = Variable(assetId); + map['destination'] = Variable(destination); + map['label'] = Variable(label); + { + final converter = Addresses.$converterupdatedAt; + map['updated_at'] = Variable(converter.toSql(updatedAt)); + } + map['reserve'] = Variable(reserve); + map['fee'] = Variable(fee); + if (!nullToAbsent || tag != null) { + map['tag'] = Variable(tag); + } + if (!nullToAbsent || dust != null) { + map['dust'] = Variable(dust); + } + return map; } - factory MessageMention.fromJson(Map json, + AddressesCompanion toCompanion(bool nullToAbsent) { + return AddressesCompanion( + addressId: Value(addressId), + type: Value(type), + assetId: Value(assetId), + destination: Value(destination), + label: Value(label), + updatedAt: Value(updatedAt), + reserve: Value(reserve), + fee: Value(fee), + tag: tag == null && nullToAbsent ? const Value.absent() : Value(tag), + dust: dust == null && nullToAbsent ? const Value.absent() : Value(dust), + ); + } + + factory Addresse.fromJson(Map json, {ValueSerializer? serializer}) { serializer ??= driftRuntimeOptions.defaultSerializer; - return MessageMention( - messageId: serializer.fromJson(json['message_id']), - conversationId: serializer.fromJson(json['conversation_id']), - hasRead: serializer.fromJson(json['has_read']), + return Addresse( + addressId: serializer.fromJson(json['address_id']), + type: serializer.fromJson(json['type']), + assetId: serializer.fromJson(json['asset_id']), + destination: serializer.fromJson(json['destination']), + label: serializer.fromJson(json['label']), + updatedAt: serializer.fromJson(json['updated_at']), + reserve: serializer.fromJson(json['reserve']), + fee: serializer.fromJson(json['fee']), + tag: serializer.fromJson(json['tag']), + dust: serializer.fromJson(json['dust']), ); } @override Map toJson({ValueSerializer? serializer}) { serializer ??= driftRuntimeOptions.defaultSerializer; return { - 'message_id': serializer.toJson(messageId), - 'conversation_id': serializer.toJson(conversationId), - 'has_read': serializer.toJson(hasRead), + 'address_id': serializer.toJson(addressId), + 'type': serializer.toJson(type), + 'asset_id': serializer.toJson(assetId), + 'destination': serializer.toJson(destination), + 'label': serializer.toJson(label), + 'updated_at': serializer.toJson(updatedAt), + 'reserve': serializer.toJson(reserve), + 'fee': serializer.toJson(fee), + 'tag': serializer.toJson(tag), + 'dust': serializer.toJson(dust), }; } - MessageMention copyWith( - {String? messageId, - String? conversationId, - Value hasRead = const Value.absent()}) => - MessageMention( - messageId: messageId ?? this.messageId, - conversationId: conversationId ?? this.conversationId, - hasRead: hasRead.present ? hasRead.value : this.hasRead, + Addresse copyWith( + {String? addressId, + String? type, + String? assetId, + String? destination, + String? label, + DateTime? updatedAt, + String? reserve, + String? fee, + Value tag = const Value.absent(), + Value dust = const Value.absent()}) => + Addresse( + addressId: addressId ?? this.addressId, + type: type ?? this.type, + assetId: assetId ?? this.assetId, + destination: destination ?? this.destination, + label: label ?? this.label, + updatedAt: updatedAt ?? this.updatedAt, + reserve: reserve ?? this.reserve, + fee: fee ?? this.fee, + tag: tag.present ? tag.value : this.tag, + dust: dust.present ? dust.value : this.dust, ); @override String toString() { - return (StringBuffer('MessageMention(') - ..write('messageId: $messageId, ') - ..write('conversationId: $conversationId, ') - ..write('hasRead: $hasRead') + return (StringBuffer('Addresse(') + ..write('addressId: $addressId, ') + ..write('type: $type, ') + ..write('assetId: $assetId, ') + ..write('destination: $destination, ') + ..write('label: $label, ') + ..write('updatedAt: $updatedAt, ') + ..write('reserve: $reserve, ') + ..write('fee: $fee, ') + ..write('tag: $tag, ') + ..write('dust: $dust') ..write(')')) .toString(); } @override - int get hashCode => Object.hash(messageId, conversationId, hasRead); + int get hashCode => Object.hash(addressId, type, assetId, destination, label, + updatedAt, reserve, fee, tag, dust); @override bool operator ==(Object other) => identical(this, other) || - (other is MessageMention && - other.messageId == this.messageId && - other.conversationId == this.conversationId && - other.hasRead == this.hasRead); + (other is Addresse && + other.addressId == this.addressId && + other.type == this.type && + other.assetId == this.assetId && + other.destination == this.destination && + other.label == this.label && + other.updatedAt == this.updatedAt && + other.reserve == this.reserve && + other.fee == this.fee && + other.tag == this.tag && + other.dust == this.dust); } -class MessageMentionsCompanion extends UpdateCompanion { - final Value messageId; - final Value conversationId; - final Value hasRead; +class AddressesCompanion extends UpdateCompanion { + final Value addressId; + final Value type; + final Value assetId; + final Value destination; + final Value label; + final Value updatedAt; + final Value reserve; + final Value fee; + final Value tag; + final Value dust; final Value rowid; - const MessageMentionsCompanion({ - this.messageId = const Value.absent(), - this.conversationId = const Value.absent(), - this.hasRead = const Value.absent(), + const AddressesCompanion({ + this.addressId = const Value.absent(), + this.type = const Value.absent(), + this.assetId = const Value.absent(), + this.destination = const Value.absent(), + this.label = const Value.absent(), + this.updatedAt = const Value.absent(), + this.reserve = const Value.absent(), + this.fee = const Value.absent(), + this.tag = const Value.absent(), + this.dust = const Value.absent(), this.rowid = const Value.absent(), }); - MessageMentionsCompanion.insert({ - required String messageId, - required String conversationId, - this.hasRead = const Value.absent(), + AddressesCompanion.insert({ + required String addressId, + required String type, + required String assetId, + required String destination, + required String label, + required DateTime updatedAt, + required String reserve, + required String fee, + this.tag = const Value.absent(), + this.dust = const Value.absent(), this.rowid = const Value.absent(), - }) : messageId = Value(messageId), - conversationId = Value(conversationId); - static Insertable custom({ - Expression? messageId, - Expression? conversationId, - Expression? hasRead, + }) : addressId = Value(addressId), + type = Value(type), + assetId = Value(assetId), + destination = Value(destination), + label = Value(label), + updatedAt = Value(updatedAt), + reserve = Value(reserve), + fee = Value(fee); + static Insertable custom({ + Expression? addressId, + Expression? type, + Expression? assetId, + Expression? destination, + Expression? label, + Expression? updatedAt, + Expression? reserve, + Expression? fee, + Expression? tag, + Expression? dust, Expression? rowid, }) { return RawValuesInsertable({ - if (messageId != null) 'message_id': messageId, - if (conversationId != null) 'conversation_id': conversationId, - if (hasRead != null) 'has_read': hasRead, + if (addressId != null) 'address_id': addressId, + if (type != null) 'type': type, + if (assetId != null) 'asset_id': assetId, + if (destination != null) 'destination': destination, + if (label != null) 'label': label, + if (updatedAt != null) 'updated_at': updatedAt, + if (reserve != null) 'reserve': reserve, + if (fee != null) 'fee': fee, + if (tag != null) 'tag': tag, + if (dust != null) 'dust': dust, if (rowid != null) 'rowid': rowid, }); } - MessageMentionsCompanion copyWith( - {Value? messageId, - Value? conversationId, - Value? hasRead, + AddressesCompanion copyWith( + {Value? addressId, + Value? type, + Value? assetId, + Value? destination, + Value? label, + Value? updatedAt, + Value? reserve, + Value? fee, + Value? tag, + Value? dust, Value? rowid}) { - return MessageMentionsCompanion( - messageId: messageId ?? this.messageId, - conversationId: conversationId ?? this.conversationId, - hasRead: hasRead ?? this.hasRead, - rowid: rowid ?? this.rowid, - ); - } + return AddressesCompanion( + addressId: addressId ?? this.addressId, + type: type ?? this.type, + assetId: assetId ?? this.assetId, + destination: destination ?? this.destination, + label: label ?? this.label, + updatedAt: updatedAt ?? this.updatedAt, + reserve: reserve ?? this.reserve, + fee: fee ?? this.fee, + tag: tag ?? this.tag, + dust: dust ?? this.dust, + rowid: rowid ?? this.rowid, + ); + } @override Map toColumns(bool nullToAbsent) { final map = {}; - if (messageId.present) { - map['message_id'] = Variable(messageId.value); + if (addressId.present) { + map['address_id'] = Variable(addressId.value); } - if (conversationId.present) { - map['conversation_id'] = Variable(conversationId.value); + if (type.present) { + map['type'] = Variable(type.value); } - if (hasRead.present) { - map['has_read'] = Variable(hasRead.value); + if (assetId.present) { + map['asset_id'] = Variable(assetId.value); + } + if (destination.present) { + map['destination'] = Variable(destination.value); + } + if (label.present) { + map['label'] = Variable(label.value); + } + if (updatedAt.present) { + final converter = Addresses.$converterupdatedAt; + map['updated_at'] = Variable(converter.toSql(updatedAt.value)); + } + if (reserve.present) { + map['reserve'] = Variable(reserve.value); + } + if (fee.present) { + map['fee'] = Variable(fee.value); + } + if (tag.present) { + map['tag'] = Variable(tag.value); + } + if (dust.present) { + map['dust'] = Variable(dust.value); } if (rowid.present) { map['rowid'] = Variable(rowid.value); @@ -7688,447 +6760,596 @@ class MessageMentionsCompanion extends UpdateCompanion { @override String toString() { - return (StringBuffer('MessageMentionsCompanion(') - ..write('messageId: $messageId, ') - ..write('conversationId: $conversationId, ') - ..write('hasRead: $hasRead, ') + return (StringBuffer('AddressesCompanion(') + ..write('addressId: $addressId, ') + ..write('type: $type, ') + ..write('assetId: $assetId, ') + ..write('destination: $destination, ') + ..write('label: $label, ') + ..write('updatedAt: $updatedAt, ') + ..write('reserve: $reserve, ') + ..write('fee: $fee, ') + ..write('tag: $tag, ') + ..write('dust: $dust, ') ..write('rowid: $rowid') ..write(')')) .toString(); } } -class ExpiredMessages extends Table - with TableInfo { +class Apps extends Table with TableInfo { @override final GeneratedDatabase attachedDatabase; final String? _alias; - ExpiredMessages(this.attachedDatabase, [this._alias]); - static const VerificationMeta _messageIdMeta = - const VerificationMeta('messageId'); - late final GeneratedColumn messageId = GeneratedColumn( - 'message_id', aliasedName, false, + Apps(this.attachedDatabase, [this._alias]); + static const VerificationMeta _appIdMeta = const VerificationMeta('appId'); + late final GeneratedColumn appId = GeneratedColumn( + 'app_id', aliasedName, false, type: DriftSqlType.string, requiredDuringInsert: true, $customConstraints: 'NOT NULL'); - static const VerificationMeta _expireInMeta = - const VerificationMeta('expireIn'); - late final GeneratedColumn expireIn = GeneratedColumn( - 'expire_in', aliasedName, false, - type: DriftSqlType.int, + static const VerificationMeta _appNumberMeta = + const VerificationMeta('appNumber'); + late final GeneratedColumn appNumber = GeneratedColumn( + 'app_number', aliasedName, false, + type: DriftSqlType.string, requiredDuringInsert: true, $customConstraints: 'NOT NULL'); - static const VerificationMeta _expireAtMeta = - const VerificationMeta('expireAt'); - late final GeneratedColumn expireAt = GeneratedColumn( - 'expire_at', aliasedName, true, - type: DriftSqlType.int, + static const VerificationMeta _homeUriMeta = + const VerificationMeta('homeUri'); + late final GeneratedColumn homeUri = GeneratedColumn( + 'home_uri', aliasedName, false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL'); + static const VerificationMeta _redirectUriMeta = + const VerificationMeta('redirectUri'); + late final GeneratedColumn redirectUri = GeneratedColumn( + 'redirect_uri', aliasedName, false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL'); + static const VerificationMeta _nameMeta = const VerificationMeta('name'); + late final GeneratedColumn name = GeneratedColumn( + 'name', aliasedName, false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL'); + static const VerificationMeta _iconUrlMeta = + const VerificationMeta('iconUrl'); + late final GeneratedColumn iconUrl = GeneratedColumn( + 'icon_url', aliasedName, false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL'); + static const VerificationMeta _categoryMeta = + const VerificationMeta('category'); + late final GeneratedColumn category = GeneratedColumn( + 'category', aliasedName, true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: ''); + static const VerificationMeta _descriptionMeta = + const VerificationMeta('description'); + late final GeneratedColumn description = GeneratedColumn( + 'description', aliasedName, false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL'); + static const VerificationMeta _appSecretMeta = + const VerificationMeta('appSecret'); + late final GeneratedColumn appSecret = GeneratedColumn( + 'app_secret', aliasedName, false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL'); + static const VerificationMeta _capabilitiesMeta = + const VerificationMeta('capabilities'); + late final GeneratedColumn capabilities = GeneratedColumn( + 'capabilities', aliasedName, true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: ''); + static const VerificationMeta _creatorIdMeta = + const VerificationMeta('creatorId'); + late final GeneratedColumn creatorId = GeneratedColumn( + 'creator_id', aliasedName, false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL'); + static const VerificationMeta _resourcePatternsMeta = + const VerificationMeta('resourcePatterns'); + late final GeneratedColumn resourcePatterns = GeneratedColumn( + 'resource_patterns', aliasedName, true, + type: DriftSqlType.string, requiredDuringInsert: false, $customConstraints: ''); + static const VerificationMeta _updatedAtMeta = + const VerificationMeta('updatedAt'); + late final GeneratedColumnWithTypeConverter updatedAt = + GeneratedColumn('updated_at', aliasedName, true, + type: DriftSqlType.int, + requiredDuringInsert: false, + $customConstraints: '') + .withConverter(Apps.$converterupdatedAtn); @override - List get $columns => [messageId, expireIn, expireAt]; + List get $columns => [ + appId, + appNumber, + homeUri, + redirectUri, + name, + iconUrl, + category, + description, + appSecret, + capabilities, + creatorId, + resourcePatterns, + updatedAt + ]; @override - String get aliasedName => _alias ?? 'expired_messages'; + String get aliasedName => _alias ?? 'apps'; @override - String get actualTableName => 'expired_messages'; + String get actualTableName => 'apps'; @override - VerificationContext validateIntegrity(Insertable instance, + VerificationContext validateIntegrity(Insertable instance, {bool isInserting = false}) { final context = VerificationContext(); final data = instance.toColumns(true); - if (data.containsKey('message_id')) { - context.handle(_messageIdMeta, - messageId.isAcceptableOrUnknown(data['message_id']!, _messageIdMeta)); + if (data.containsKey('app_id')) { + context.handle( + _appIdMeta, appId.isAcceptableOrUnknown(data['app_id']!, _appIdMeta)); } else if (isInserting) { - context.missing(_messageIdMeta); + context.missing(_appIdMeta); } - if (data.containsKey('expire_in')) { - context.handle(_expireInMeta, - expireIn.isAcceptableOrUnknown(data['expire_in']!, _expireInMeta)); + if (data.containsKey('app_number')) { + context.handle(_appNumberMeta, + appNumber.isAcceptableOrUnknown(data['app_number']!, _appNumberMeta)); } else if (isInserting) { - context.missing(_expireInMeta); - } - if (data.containsKey('expire_at')) { - context.handle(_expireAtMeta, - expireAt.isAcceptableOrUnknown(data['expire_at']!, _expireAtMeta)); + context.missing(_appNumberMeta); } - return context; - } - - @override - Set get $primaryKey => {messageId}; - @override - ExpiredMessage map(Map data, {String? tablePrefix}) { - final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; - return ExpiredMessage( - messageId: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}message_id'])!, - expireIn: attachedDatabase.typeMapping - .read(DriftSqlType.int, data['${effectivePrefix}expire_in'])!, - expireAt: attachedDatabase.typeMapping - .read(DriftSqlType.int, data['${effectivePrefix}expire_at']), - ); - } - - @override - ExpiredMessages createAlias(String alias) { - return ExpiredMessages(attachedDatabase, alias); - } - - @override - List get customConstraints => const ['PRIMARY KEY(message_id)']; - @override - bool get dontWriteConstraints => true; -} - -class ExpiredMessage extends DataClass implements Insertable { - final String messageId; - final int expireIn; - final int? expireAt; - const ExpiredMessage( - {required this.messageId, required this.expireIn, this.expireAt}); - @override - Map toColumns(bool nullToAbsent) { - final map = {}; - map['message_id'] = Variable(messageId); - map['expire_in'] = Variable(expireIn); - if (!nullToAbsent || expireAt != null) { - map['expire_at'] = Variable(expireAt); + if (data.containsKey('home_uri')) { + context.handle(_homeUriMeta, + homeUri.isAcceptableOrUnknown(data['home_uri']!, _homeUriMeta)); + } else if (isInserting) { + context.missing(_homeUriMeta); } - return map; - } - - ExpiredMessagesCompanion toCompanion(bool nullToAbsent) { - return ExpiredMessagesCompanion( - messageId: Value(messageId), - expireIn: Value(expireIn), - expireAt: expireAt == null && nullToAbsent - ? const Value.absent() - : Value(expireAt), - ); + if (data.containsKey('redirect_uri')) { + context.handle( + _redirectUriMeta, + redirectUri.isAcceptableOrUnknown( + data['redirect_uri']!, _redirectUriMeta)); + } else if (isInserting) { + context.missing(_redirectUriMeta); + } + if (data.containsKey('name')) { + context.handle( + _nameMeta, name.isAcceptableOrUnknown(data['name']!, _nameMeta)); + } else if (isInserting) { + context.missing(_nameMeta); + } + if (data.containsKey('icon_url')) { + context.handle(_iconUrlMeta, + iconUrl.isAcceptableOrUnknown(data['icon_url']!, _iconUrlMeta)); + } else if (isInserting) { + context.missing(_iconUrlMeta); + } + if (data.containsKey('category')) { + context.handle(_categoryMeta, + category.isAcceptableOrUnknown(data['category']!, _categoryMeta)); + } + if (data.containsKey('description')) { + context.handle( + _descriptionMeta, + description.isAcceptableOrUnknown( + data['description']!, _descriptionMeta)); + } else if (isInserting) { + context.missing(_descriptionMeta); + } + if (data.containsKey('app_secret')) { + context.handle(_appSecretMeta, + appSecret.isAcceptableOrUnknown(data['app_secret']!, _appSecretMeta)); + } else if (isInserting) { + context.missing(_appSecretMeta); + } + if (data.containsKey('capabilities')) { + context.handle( + _capabilitiesMeta, + capabilities.isAcceptableOrUnknown( + data['capabilities']!, _capabilitiesMeta)); + } + if (data.containsKey('creator_id')) { + context.handle(_creatorIdMeta, + creatorId.isAcceptableOrUnknown(data['creator_id']!, _creatorIdMeta)); + } else if (isInserting) { + context.missing(_creatorIdMeta); + } + if (data.containsKey('resource_patterns')) { + context.handle( + _resourcePatternsMeta, + resourcePatterns.isAcceptableOrUnknown( + data['resource_patterns']!, _resourcePatternsMeta)); + } + context.handle(_updatedAtMeta, const VerificationResult.success()); + return context; } - factory ExpiredMessage.fromJson(Map json, - {ValueSerializer? serializer}) { - serializer ??= driftRuntimeOptions.defaultSerializer; - return ExpiredMessage( - messageId: serializer.fromJson(json['message_id']), - expireIn: serializer.fromJson(json['expire_in']), - expireAt: serializer.fromJson(json['expire_at']), - ); - } @override - Map toJson({ValueSerializer? serializer}) { - serializer ??= driftRuntimeOptions.defaultSerializer; - return { - 'message_id': serializer.toJson(messageId), - 'expire_in': serializer.toJson(expireIn), - 'expire_at': serializer.toJson(expireAt), - }; + Set get $primaryKey => {appId}; + @override + App map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return App( + appId: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}app_id'])!, + appNumber: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}app_number'])!, + homeUri: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}home_uri'])!, + redirectUri: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}redirect_uri'])!, + name: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}name'])!, + iconUrl: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}icon_url'])!, + category: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}category']), + description: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}description'])!, + appSecret: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}app_secret'])!, + capabilities: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}capabilities']), + creatorId: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}creator_id'])!, + resourcePatterns: attachedDatabase.typeMapping.read( + DriftSqlType.string, data['${effectivePrefix}resource_patterns']), + updatedAt: Apps.$converterupdatedAtn.fromSql(attachedDatabase.typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}updated_at'])), + ); } - ExpiredMessage copyWith( - {String? messageId, - int? expireIn, - Value expireAt = const Value.absent()}) => - ExpiredMessage( - messageId: messageId ?? this.messageId, - expireIn: expireIn ?? this.expireIn, - expireAt: expireAt.present ? expireAt.value : this.expireAt, - ); @override - String toString() { - return (StringBuffer('ExpiredMessage(') - ..write('messageId: $messageId, ') - ..write('expireIn: $expireIn, ') - ..write('expireAt: $expireAt') - ..write(')')) - .toString(); + Apps createAlias(String alias) { + return Apps(attachedDatabase, alias); } + static TypeConverter $converterupdatedAt = + const MillisDateConverter(); + static TypeConverter $converterupdatedAtn = + NullAwareTypeConverter.wrap($converterupdatedAt); @override - int get hashCode => Object.hash(messageId, expireIn, expireAt); + List get customConstraints => const ['PRIMARY KEY(app_id)']; @override - bool operator ==(Object other) => - identical(this, other) || - (other is ExpiredMessage && - other.messageId == this.messageId && - other.expireIn == this.expireIn && - other.expireAt == this.expireAt); + bool get dontWriteConstraints => true; } -class ExpiredMessagesCompanion extends UpdateCompanion { - final Value messageId; - final Value expireIn; - final Value expireAt; - final Value rowid; - const ExpiredMessagesCompanion({ - this.messageId = const Value.absent(), - this.expireIn = const Value.absent(), - this.expireAt = const Value.absent(), - this.rowid = const Value.absent(), - }); - ExpiredMessagesCompanion.insert({ - required String messageId, - required int expireIn, - this.expireAt = const Value.absent(), - this.rowid = const Value.absent(), - }) : messageId = Value(messageId), - expireIn = Value(expireIn); - static Insertable custom({ - Expression? messageId, - Expression? expireIn, - Expression? expireAt, - Expression? rowid, - }) { - return RawValuesInsertable({ - if (messageId != null) 'message_id': messageId, - if (expireIn != null) 'expire_in': expireIn, - if (expireAt != null) 'expire_at': expireAt, - if (rowid != null) 'rowid': rowid, - }); - } - - ExpiredMessagesCompanion copyWith( - {Value? messageId, - Value? expireIn, - Value? expireAt, - Value? rowid}) { - return ExpiredMessagesCompanion( - messageId: messageId ?? this.messageId, - expireIn: expireIn ?? this.expireIn, - expireAt: expireAt ?? this.expireAt, - rowid: rowid ?? this.rowid, - ); - } - +class App extends DataClass implements Insertable { + final String appId; + final String appNumber; + final String homeUri; + final String redirectUri; + final String name; + final String iconUrl; + final String? category; + final String description; + final String appSecret; + final String? capabilities; + final String creatorId; + final String? resourcePatterns; + final DateTime? updatedAt; + const App( + {required this.appId, + required this.appNumber, + required this.homeUri, + required this.redirectUri, + required this.name, + required this.iconUrl, + this.category, + required this.description, + required this.appSecret, + this.capabilities, + required this.creatorId, + this.resourcePatterns, + this.updatedAt}); @override Map toColumns(bool nullToAbsent) { final map = {}; - if (messageId.present) { - map['message_id'] = Variable(messageId.value); + map['app_id'] = Variable(appId); + map['app_number'] = Variable(appNumber); + map['home_uri'] = Variable(homeUri); + map['redirect_uri'] = Variable(redirectUri); + map['name'] = Variable(name); + map['icon_url'] = Variable(iconUrl); + if (!nullToAbsent || category != null) { + map['category'] = Variable(category); } - if (expireIn.present) { - map['expire_in'] = Variable(expireIn.value); + map['description'] = Variable(description); + map['app_secret'] = Variable(appSecret); + if (!nullToAbsent || capabilities != null) { + map['capabilities'] = Variable(capabilities); } - if (expireAt.present) { - map['expire_at'] = Variable(expireAt.value); + map['creator_id'] = Variable(creatorId); + if (!nullToAbsent || resourcePatterns != null) { + map['resource_patterns'] = Variable(resourcePatterns); } - if (rowid.present) { - map['rowid'] = Variable(rowid.value); + if (!nullToAbsent || updatedAt != null) { + final converter = Apps.$converterupdatedAtn; + map['updated_at'] = Variable(converter.toSql(updatedAt)); } return map; } - @override - String toString() { - return (StringBuffer('ExpiredMessagesCompanion(') - ..write('messageId: $messageId, ') - ..write('expireIn: $expireIn, ') - ..write('expireAt: $expireAt, ') - ..write('rowid: $rowid') - ..write(')')) - .toString(); - } -} - -class FloodMessages extends Table with TableInfo { - @override - final GeneratedDatabase attachedDatabase; - final String? _alias; - FloodMessages(this.attachedDatabase, [this._alias]); - static const VerificationMeta _messageIdMeta = - const VerificationMeta('messageId'); - late final GeneratedColumn messageId = GeneratedColumn( - 'message_id', aliasedName, false, - type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL'); - static const VerificationMeta _dataMeta = const VerificationMeta('data'); - late final GeneratedColumn data = GeneratedColumn( - 'data', aliasedName, false, - type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL'); - static const VerificationMeta _createdAtMeta = - const VerificationMeta('createdAt'); - late final GeneratedColumnWithTypeConverter createdAt = - GeneratedColumn('created_at', aliasedName, false, - type: DriftSqlType.int, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL') - .withConverter(FloodMessages.$convertercreatedAt); - @override - List get $columns => [messageId, data, createdAt]; - @override - String get aliasedName => _alias ?? 'flood_messages'; - @override - String get actualTableName => 'flood_messages'; - @override - VerificationContext validateIntegrity(Insertable instance, - {bool isInserting = false}) { - final context = VerificationContext(); - final data = instance.toColumns(true); - if (data.containsKey('message_id')) { - context.handle(_messageIdMeta, - messageId.isAcceptableOrUnknown(data['message_id']!, _messageIdMeta)); - } else if (isInserting) { - context.missing(_messageIdMeta); - } - if (data.containsKey('data')) { - context.handle( - _dataMeta, this.data.isAcceptableOrUnknown(data['data']!, _dataMeta)); - } else if (isInserting) { - context.missing(_dataMeta); - } - context.handle(_createdAtMeta, const VerificationResult.success()); - return context; - } - - @override - Set get $primaryKey => {messageId}; - @override - FloodMessage map(Map data, {String? tablePrefix}) { - final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; - return FloodMessage( - messageId: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}message_id'])!, - data: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}data'])!, - createdAt: FloodMessages.$convertercreatedAt.fromSql(attachedDatabase - .typeMapping - .read(DriftSqlType.int, data['${effectivePrefix}created_at'])!), - ); - } - - @override - FloodMessages createAlias(String alias) { - return FloodMessages(attachedDatabase, alias); - } - - static TypeConverter $convertercreatedAt = - const MillisDateConverter(); - @override - List get customConstraints => const ['PRIMARY KEY(message_id)']; - @override - bool get dontWriteConstraints => true; -} - -class FloodMessage extends DataClass implements Insertable { - final String messageId; - final String data; - final DateTime createdAt; - const FloodMessage( - {required this.messageId, required this.data, required this.createdAt}); - @override - Map toColumns(bool nullToAbsent) { - final map = {}; - map['message_id'] = Variable(messageId); - map['data'] = Variable(data); - { - final converter = FloodMessages.$convertercreatedAt; - map['created_at'] = Variable(converter.toSql(createdAt)); - } - return map; - } - - FloodMessagesCompanion toCompanion(bool nullToAbsent) { - return FloodMessagesCompanion( - messageId: Value(messageId), - data: Value(data), - createdAt: Value(createdAt), + AppsCompanion toCompanion(bool nullToAbsent) { + return AppsCompanion( + appId: Value(appId), + appNumber: Value(appNumber), + homeUri: Value(homeUri), + redirectUri: Value(redirectUri), + name: Value(name), + iconUrl: Value(iconUrl), + category: category == null && nullToAbsent + ? const Value.absent() + : Value(category), + description: Value(description), + appSecret: Value(appSecret), + capabilities: capabilities == null && nullToAbsent + ? const Value.absent() + : Value(capabilities), + creatorId: Value(creatorId), + resourcePatterns: resourcePatterns == null && nullToAbsent + ? const Value.absent() + : Value(resourcePatterns), + updatedAt: updatedAt == null && nullToAbsent + ? const Value.absent() + : Value(updatedAt), ); } - factory FloodMessage.fromJson(Map json, + factory App.fromJson(Map json, {ValueSerializer? serializer}) { serializer ??= driftRuntimeOptions.defaultSerializer; - return FloodMessage( - messageId: serializer.fromJson(json['message_id']), - data: serializer.fromJson(json['data']), - createdAt: serializer.fromJson(json['created_at']), + return App( + appId: serializer.fromJson(json['app_id']), + appNumber: serializer.fromJson(json['app_number']), + homeUri: serializer.fromJson(json['home_uri']), + redirectUri: serializer.fromJson(json['redirect_uri']), + name: serializer.fromJson(json['name']), + iconUrl: serializer.fromJson(json['icon_url']), + category: serializer.fromJson(json['category']), + description: serializer.fromJson(json['description']), + appSecret: serializer.fromJson(json['app_secret']), + capabilities: serializer.fromJson(json['capabilities']), + creatorId: serializer.fromJson(json['creator_id']), + resourcePatterns: serializer.fromJson(json['resource_patterns']), + updatedAt: serializer.fromJson(json['updated_at']), ); } @override Map toJson({ValueSerializer? serializer}) { serializer ??= driftRuntimeOptions.defaultSerializer; return { - 'message_id': serializer.toJson(messageId), - 'data': serializer.toJson(data), - 'created_at': serializer.toJson(createdAt), + 'app_id': serializer.toJson(appId), + 'app_number': serializer.toJson(appNumber), + 'home_uri': serializer.toJson(homeUri), + 'redirect_uri': serializer.toJson(redirectUri), + 'name': serializer.toJson(name), + 'icon_url': serializer.toJson(iconUrl), + 'category': serializer.toJson(category), + 'description': serializer.toJson(description), + 'app_secret': serializer.toJson(appSecret), + 'capabilities': serializer.toJson(capabilities), + 'creator_id': serializer.toJson(creatorId), + 'resource_patterns': serializer.toJson(resourcePatterns), + 'updated_at': serializer.toJson(updatedAt), }; } - FloodMessage copyWith( - {String? messageId, String? data, DateTime? createdAt}) => - FloodMessage( - messageId: messageId ?? this.messageId, - data: data ?? this.data, - createdAt: createdAt ?? this.createdAt, + App copyWith( + {String? appId, + String? appNumber, + String? homeUri, + String? redirectUri, + String? name, + String? iconUrl, + Value category = const Value.absent(), + String? description, + String? appSecret, + Value capabilities = const Value.absent(), + String? creatorId, + Value resourcePatterns = const Value.absent(), + Value updatedAt = const Value.absent()}) => + App( + appId: appId ?? this.appId, + appNumber: appNumber ?? this.appNumber, + homeUri: homeUri ?? this.homeUri, + redirectUri: redirectUri ?? this.redirectUri, + name: name ?? this.name, + iconUrl: iconUrl ?? this.iconUrl, + category: category.present ? category.value : this.category, + description: description ?? this.description, + appSecret: appSecret ?? this.appSecret, + capabilities: + capabilities.present ? capabilities.value : this.capabilities, + creatorId: creatorId ?? this.creatorId, + resourcePatterns: resourcePatterns.present + ? resourcePatterns.value + : this.resourcePatterns, + updatedAt: updatedAt.present ? updatedAt.value : this.updatedAt, ); @override String toString() { - return (StringBuffer('FloodMessage(') - ..write('messageId: $messageId, ') - ..write('data: $data, ') - ..write('createdAt: $createdAt') + return (StringBuffer('App(') + ..write('appId: $appId, ') + ..write('appNumber: $appNumber, ') + ..write('homeUri: $homeUri, ') + ..write('redirectUri: $redirectUri, ') + ..write('name: $name, ') + ..write('iconUrl: $iconUrl, ') + ..write('category: $category, ') + ..write('description: $description, ') + ..write('appSecret: $appSecret, ') + ..write('capabilities: $capabilities, ') + ..write('creatorId: $creatorId, ') + ..write('resourcePatterns: $resourcePatterns, ') + ..write('updatedAt: $updatedAt') ..write(')')) .toString(); } @override - int get hashCode => Object.hash(messageId, data, createdAt); + int get hashCode => Object.hash( + appId, + appNumber, + homeUri, + redirectUri, + name, + iconUrl, + category, + description, + appSecret, + capabilities, + creatorId, + resourcePatterns, + updatedAt); @override bool operator ==(Object other) => identical(this, other) || - (other is FloodMessage && - other.messageId == this.messageId && - other.data == this.data && - other.createdAt == this.createdAt); + (other is App && + other.appId == this.appId && + other.appNumber == this.appNumber && + other.homeUri == this.homeUri && + other.redirectUri == this.redirectUri && + other.name == this.name && + other.iconUrl == this.iconUrl && + other.category == this.category && + other.description == this.description && + other.appSecret == this.appSecret && + other.capabilities == this.capabilities && + other.creatorId == this.creatorId && + other.resourcePatterns == this.resourcePatterns && + other.updatedAt == this.updatedAt); } -class FloodMessagesCompanion extends UpdateCompanion { - final Value messageId; - final Value data; - final Value createdAt; +class AppsCompanion extends UpdateCompanion { + final Value appId; + final Value appNumber; + final Value homeUri; + final Value redirectUri; + final Value name; + final Value iconUrl; + final Value category; + final Value description; + final Value appSecret; + final Value capabilities; + final Value creatorId; + final Value resourcePatterns; + final Value updatedAt; final Value rowid; - const FloodMessagesCompanion({ - this.messageId = const Value.absent(), - this.data = const Value.absent(), - this.createdAt = const Value.absent(), + const AppsCompanion({ + this.appId = const Value.absent(), + this.appNumber = const Value.absent(), + this.homeUri = const Value.absent(), + this.redirectUri = const Value.absent(), + this.name = const Value.absent(), + this.iconUrl = const Value.absent(), + this.category = const Value.absent(), + this.description = const Value.absent(), + this.appSecret = const Value.absent(), + this.capabilities = const Value.absent(), + this.creatorId = const Value.absent(), + this.resourcePatterns = const Value.absent(), + this.updatedAt = const Value.absent(), this.rowid = const Value.absent(), }); - FloodMessagesCompanion.insert({ - required String messageId, - required String data, - required DateTime createdAt, + AppsCompanion.insert({ + required String appId, + required String appNumber, + required String homeUri, + required String redirectUri, + required String name, + required String iconUrl, + this.category = const Value.absent(), + required String description, + required String appSecret, + this.capabilities = const Value.absent(), + required String creatorId, + this.resourcePatterns = const Value.absent(), + this.updatedAt = const Value.absent(), this.rowid = const Value.absent(), - }) : messageId = Value(messageId), - data = Value(data), - createdAt = Value(createdAt); - static Insertable custom({ - Expression? messageId, - Expression? data, - Expression? createdAt, + }) : appId = Value(appId), + appNumber = Value(appNumber), + homeUri = Value(homeUri), + redirectUri = Value(redirectUri), + name = Value(name), + iconUrl = Value(iconUrl), + description = Value(description), + appSecret = Value(appSecret), + creatorId = Value(creatorId); + static Insertable custom({ + Expression? appId, + Expression? appNumber, + Expression? homeUri, + Expression? redirectUri, + Expression? name, + Expression? iconUrl, + Expression? category, + Expression? description, + Expression? appSecret, + Expression? capabilities, + Expression? creatorId, + Expression? resourcePatterns, + Expression? updatedAt, Expression? rowid, }) { return RawValuesInsertable({ - if (messageId != null) 'message_id': messageId, - if (data != null) 'data': data, - if (createdAt != null) 'created_at': createdAt, + if (appId != null) 'app_id': appId, + if (appNumber != null) 'app_number': appNumber, + if (homeUri != null) 'home_uri': homeUri, + if (redirectUri != null) 'redirect_uri': redirectUri, + if (name != null) 'name': name, + if (iconUrl != null) 'icon_url': iconUrl, + if (category != null) 'category': category, + if (description != null) 'description': description, + if (appSecret != null) 'app_secret': appSecret, + if (capabilities != null) 'capabilities': capabilities, + if (creatorId != null) 'creator_id': creatorId, + if (resourcePatterns != null) 'resource_patterns': resourcePatterns, + if (updatedAt != null) 'updated_at': updatedAt, if (rowid != null) 'rowid': rowid, }); } - FloodMessagesCompanion copyWith( - {Value? messageId, - Value? data, - Value? createdAt, + AppsCompanion copyWith( + {Value? appId, + Value? appNumber, + Value? homeUri, + Value? redirectUri, + Value? name, + Value? iconUrl, + Value? category, + Value? description, + Value? appSecret, + Value? capabilities, + Value? creatorId, + Value? resourcePatterns, + Value? updatedAt, Value? rowid}) { - return FloodMessagesCompanion( - messageId: messageId ?? this.messageId, - data: data ?? this.data, - createdAt: createdAt ?? this.createdAt, + return AppsCompanion( + appId: appId ?? this.appId, + appNumber: appNumber ?? this.appNumber, + homeUri: homeUri ?? this.homeUri, + redirectUri: redirectUri ?? this.redirectUri, + name: name ?? this.name, + iconUrl: iconUrl ?? this.iconUrl, + category: category ?? this.category, + description: description ?? this.description, + appSecret: appSecret ?? this.appSecret, + capabilities: capabilities ?? this.capabilities, + creatorId: creatorId ?? this.creatorId, + resourcePatterns: resourcePatterns ?? this.resourcePatterns, + updatedAt: updatedAt ?? this.updatedAt, rowid: rowid ?? this.rowid, ); } @@ -8136,15 +7357,45 @@ class FloodMessagesCompanion extends UpdateCompanion { @override Map toColumns(bool nullToAbsent) { final map = {}; - if (messageId.present) { - map['message_id'] = Variable(messageId.value); + if (appId.present) { + map['app_id'] = Variable(appId.value); } - if (data.present) { - map['data'] = Variable(data.value); + if (appNumber.present) { + map['app_number'] = Variable(appNumber.value); } - if (createdAt.present) { - final converter = FloodMessages.$convertercreatedAt; - map['created_at'] = Variable(converter.toSql(createdAt.value)); + if (homeUri.present) { + map['home_uri'] = Variable(homeUri.value); + } + if (redirectUri.present) { + map['redirect_uri'] = Variable(redirectUri.value); + } + if (name.present) { + map['name'] = Variable(name.value); + } + if (iconUrl.present) { + map['icon_url'] = Variable(iconUrl.value); + } + if (category.present) { + map['category'] = Variable(category.value); + } + if (description.present) { + map['description'] = Variable(description.value); + } + if (appSecret.present) { + map['app_secret'] = Variable(appSecret.value); + } + if (capabilities.present) { + map['capabilities'] = Variable(capabilities.value); + } + if (creatorId.present) { + map['creator_id'] = Variable(creatorId.value); + } + if (resourcePatterns.present) { + map['resource_patterns'] = Variable(resourcePatterns.value); + } + if (updatedAt.present) { + final converter = Apps.$converterupdatedAtn; + map['updated_at'] = Variable(converter.toSql(updatedAt.value)); } if (rowid.present) { map['rowid'] = Variable(rowid.value); @@ -8154,21 +7405,39 @@ class FloodMessagesCompanion extends UpdateCompanion { @override String toString() { - return (StringBuffer('FloodMessagesCompanion(') - ..write('messageId: $messageId, ') - ..write('data: $data, ') - ..write('createdAt: $createdAt, ') + return (StringBuffer('AppsCompanion(') + ..write('appId: $appId, ') + ..write('appNumber: $appNumber, ') + ..write('homeUri: $homeUri, ') + ..write('redirectUri: $redirectUri, ') + ..write('name: $name, ') + ..write('iconUrl: $iconUrl, ') + ..write('category: $category, ') + ..write('description: $description, ') + ..write('appSecret: $appSecret, ') + ..write('capabilities: $capabilities, ') + ..write('creatorId: $creatorId, ') + ..write('resourcePatterns: $resourcePatterns, ') + ..write('updatedAt: $updatedAt, ') ..write('rowid: $rowid') ..write(')')) .toString(); } } -class Circles extends Table with TableInfo { +class CircleConversations extends Table + with TableInfo { @override final GeneratedDatabase attachedDatabase; final String? _alias; - Circles(this.attachedDatabase, [this._alias]); + CircleConversations(this.attachedDatabase, [this._alias]); + static const VerificationMeta _conversationIdMeta = + const VerificationMeta('conversationId'); + late final GeneratedColumn conversationId = GeneratedColumn( + 'conversation_id', aliasedName, false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL'); static const VerificationMeta _circleIdMeta = const VerificationMeta('circleId'); late final GeneratedColumn circleId = GeneratedColumn( @@ -8176,12 +7445,12 @@ class Circles extends Table with TableInfo { type: DriftSqlType.string, requiredDuringInsert: true, $customConstraints: 'NOT NULL'); - static const VerificationMeta _nameMeta = const VerificationMeta('name'); - late final GeneratedColumn name = GeneratedColumn( - 'name', aliasedName, false, + static const VerificationMeta _userIdMeta = const VerificationMeta('userId'); + late final GeneratedColumn userId = GeneratedColumn( + 'user_id', aliasedName, true, type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL'); + requiredDuringInsert: false, + $customConstraints: ''); static const VerificationMeta _createdAtMeta = const VerificationMeta('createdAt'); late final GeneratedColumnWithTypeConverter createdAt = @@ -8189,220 +7458,252 @@ class Circles extends Table with TableInfo { type: DriftSqlType.int, requiredDuringInsert: true, $customConstraints: 'NOT NULL') - .withConverter(Circles.$convertercreatedAt); - static const VerificationMeta _orderedAtMeta = - const VerificationMeta('orderedAt'); - late final GeneratedColumnWithTypeConverter orderedAt = - GeneratedColumn('ordered_at', aliasedName, true, + .withConverter(CircleConversations.$convertercreatedAt); + static const VerificationMeta _pinTimeMeta = + const VerificationMeta('pinTime'); + late final GeneratedColumnWithTypeConverter pinTime = + GeneratedColumn('pin_time', aliasedName, true, type: DriftSqlType.int, requiredDuringInsert: false, $customConstraints: '') - .withConverter(Circles.$converterorderedAtn); + .withConverter(CircleConversations.$converterpinTimen); @override - List get $columns => [circleId, name, createdAt, orderedAt]; + List get $columns => + [conversationId, circleId, userId, createdAt, pinTime]; @override - String get aliasedName => _alias ?? 'circles'; + String get aliasedName => _alias ?? 'circle_conversations'; @override - String get actualTableName => 'circles'; + String get actualTableName => 'circle_conversations'; @override - VerificationContext validateIntegrity(Insertable instance, + VerificationContext validateIntegrity(Insertable instance, {bool isInserting = false}) { final context = VerificationContext(); final data = instance.toColumns(true); + if (data.containsKey('conversation_id')) { + context.handle( + _conversationIdMeta, + conversationId.isAcceptableOrUnknown( + data['conversation_id']!, _conversationIdMeta)); + } else if (isInserting) { + context.missing(_conversationIdMeta); + } if (data.containsKey('circle_id')) { context.handle(_circleIdMeta, circleId.isAcceptableOrUnknown(data['circle_id']!, _circleIdMeta)); } else if (isInserting) { context.missing(_circleIdMeta); } - if (data.containsKey('name')) { - context.handle( - _nameMeta, name.isAcceptableOrUnknown(data['name']!, _nameMeta)); - } else if (isInserting) { - context.missing(_nameMeta); + if (data.containsKey('user_id')) { + context.handle(_userIdMeta, + userId.isAcceptableOrUnknown(data['user_id']!, _userIdMeta)); } context.handle(_createdAtMeta, const VerificationResult.success()); - context.handle(_orderedAtMeta, const VerificationResult.success()); + context.handle(_pinTimeMeta, const VerificationResult.success()); return context; } @override - Set get $primaryKey => {circleId}; + Set get $primaryKey => {conversationId, circleId}; @override - Circle map(Map data, {String? tablePrefix}) { + CircleConversation map(Map data, {String? tablePrefix}) { final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; - return Circle( + return CircleConversation( + conversationId: attachedDatabase.typeMapping.read( + DriftSqlType.string, data['${effectivePrefix}conversation_id'])!, circleId: attachedDatabase.typeMapping .read(DriftSqlType.string, data['${effectivePrefix}circle_id'])!, - name: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}name'])!, - createdAt: Circles.$convertercreatedAt.fromSql(attachedDatabase - .typeMapping - .read(DriftSqlType.int, data['${effectivePrefix}created_at'])!), - orderedAt: Circles.$converterorderedAtn.fromSql(attachedDatabase + userId: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}user_id']), + createdAt: CircleConversations.$convertercreatedAt.fromSql( + attachedDatabase.typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}created_at'])!), + pinTime: CircleConversations.$converterpinTimen.fromSql(attachedDatabase .typeMapping - .read(DriftSqlType.int, data['${effectivePrefix}ordered_at'])), + .read(DriftSqlType.int, data['${effectivePrefix}pin_time'])), ); } @override - Circles createAlias(String alias) { - return Circles(attachedDatabase, alias); + CircleConversations createAlias(String alias) { + return CircleConversations(attachedDatabase, alias); } static TypeConverter $convertercreatedAt = const MillisDateConverter(); - static TypeConverter $converterorderedAt = + static TypeConverter $converterpinTime = const MillisDateConverter(); - static TypeConverter $converterorderedAtn = - NullAwareTypeConverter.wrap($converterorderedAt); + static TypeConverter $converterpinTimen = + NullAwareTypeConverter.wrap($converterpinTime); @override - List get customConstraints => const ['PRIMARY KEY(circle_id)']; + List get customConstraints => + const ['PRIMARY KEY(conversation_id, circle_id)']; @override bool get dontWriteConstraints => true; } -class Circle extends DataClass implements Insertable { +class CircleConversation extends DataClass + implements Insertable { + final String conversationId; final String circleId; - final String name; + final String? userId; final DateTime createdAt; - final DateTime? orderedAt; - const Circle( - {required this.circleId, - required this.name, + final DateTime? pinTime; + const CircleConversation( + {required this.conversationId, + required this.circleId, + this.userId, required this.createdAt, - this.orderedAt}); + this.pinTime}); @override Map toColumns(bool nullToAbsent) { final map = {}; + map['conversation_id'] = Variable(conversationId); map['circle_id'] = Variable(circleId); - map['name'] = Variable(name); + if (!nullToAbsent || userId != null) { + map['user_id'] = Variable(userId); + } { - final converter = Circles.$convertercreatedAt; + final converter = CircleConversations.$convertercreatedAt; map['created_at'] = Variable(converter.toSql(createdAt)); } - if (!nullToAbsent || orderedAt != null) { - final converter = Circles.$converterorderedAtn; - map['ordered_at'] = Variable(converter.toSql(orderedAt)); + if (!nullToAbsent || pinTime != null) { + final converter = CircleConversations.$converterpinTimen; + map['pin_time'] = Variable(converter.toSql(pinTime)); } return map; } - CirclesCompanion toCompanion(bool nullToAbsent) { - return CirclesCompanion( + CircleConversationsCompanion toCompanion(bool nullToAbsent) { + return CircleConversationsCompanion( + conversationId: Value(conversationId), circleId: Value(circleId), - name: Value(name), + userId: + userId == null && nullToAbsent ? const Value.absent() : Value(userId), createdAt: Value(createdAt), - orderedAt: orderedAt == null && nullToAbsent + pinTime: pinTime == null && nullToAbsent ? const Value.absent() - : Value(orderedAt), + : Value(pinTime), ); } - factory Circle.fromJson(Map json, + factory CircleConversation.fromJson(Map json, {ValueSerializer? serializer}) { serializer ??= driftRuntimeOptions.defaultSerializer; - return Circle( + return CircleConversation( + conversationId: serializer.fromJson(json['conversation_id']), circleId: serializer.fromJson(json['circle_id']), - name: serializer.fromJson(json['name']), + userId: serializer.fromJson(json['user_id']), createdAt: serializer.fromJson(json['created_at']), - orderedAt: serializer.fromJson(json['ordered_at']), + pinTime: serializer.fromJson(json['pin_time']), ); } @override Map toJson({ValueSerializer? serializer}) { serializer ??= driftRuntimeOptions.defaultSerializer; return { + 'conversation_id': serializer.toJson(conversationId), 'circle_id': serializer.toJson(circleId), - 'name': serializer.toJson(name), + 'user_id': serializer.toJson(userId), 'created_at': serializer.toJson(createdAt), - 'ordered_at': serializer.toJson(orderedAt), + 'pin_time': serializer.toJson(pinTime), }; } - Circle copyWith( - {String? circleId, - String? name, + CircleConversation copyWith( + {String? conversationId, + String? circleId, + Value userId = const Value.absent(), DateTime? createdAt, - Value orderedAt = const Value.absent()}) => - Circle( + Value pinTime = const Value.absent()}) => + CircleConversation( + conversationId: conversationId ?? this.conversationId, circleId: circleId ?? this.circleId, - name: name ?? this.name, + userId: userId.present ? userId.value : this.userId, createdAt: createdAt ?? this.createdAt, - orderedAt: orderedAt.present ? orderedAt.value : this.orderedAt, + pinTime: pinTime.present ? pinTime.value : this.pinTime, ); @override String toString() { - return (StringBuffer('Circle(') + return (StringBuffer('CircleConversation(') + ..write('conversationId: $conversationId, ') ..write('circleId: $circleId, ') - ..write('name: $name, ') + ..write('userId: $userId, ') ..write('createdAt: $createdAt, ') - ..write('orderedAt: $orderedAt') + ..write('pinTime: $pinTime') ..write(')')) .toString(); } @override - int get hashCode => Object.hash(circleId, name, createdAt, orderedAt); + int get hashCode => + Object.hash(conversationId, circleId, userId, createdAt, pinTime); @override bool operator ==(Object other) => identical(this, other) || - (other is Circle && + (other is CircleConversation && + other.conversationId == this.conversationId && other.circleId == this.circleId && - other.name == this.name && + other.userId == this.userId && other.createdAt == this.createdAt && - other.orderedAt == this.orderedAt); + other.pinTime == this.pinTime); } -class CirclesCompanion extends UpdateCompanion { +class CircleConversationsCompanion extends UpdateCompanion { + final Value conversationId; final Value circleId; - final Value name; + final Value userId; final Value createdAt; - final Value orderedAt; + final Value pinTime; final Value rowid; - const CirclesCompanion({ + const CircleConversationsCompanion({ + this.conversationId = const Value.absent(), this.circleId = const Value.absent(), - this.name = const Value.absent(), + this.userId = const Value.absent(), this.createdAt = const Value.absent(), - this.orderedAt = const Value.absent(), + this.pinTime = const Value.absent(), this.rowid = const Value.absent(), }); - CirclesCompanion.insert({ + CircleConversationsCompanion.insert({ + required String conversationId, required String circleId, - required String name, + this.userId = const Value.absent(), required DateTime createdAt, - this.orderedAt = const Value.absent(), + this.pinTime = const Value.absent(), this.rowid = const Value.absent(), - }) : circleId = Value(circleId), - name = Value(name), + }) : conversationId = Value(conversationId), + circleId = Value(circleId), createdAt = Value(createdAt); - static Insertable custom({ + static Insertable custom({ + Expression? conversationId, Expression? circleId, - Expression? name, + Expression? userId, Expression? createdAt, - Expression? orderedAt, + Expression? pinTime, Expression? rowid, }) { return RawValuesInsertable({ + if (conversationId != null) 'conversation_id': conversationId, if (circleId != null) 'circle_id': circleId, - if (name != null) 'name': name, + if (userId != null) 'user_id': userId, if (createdAt != null) 'created_at': createdAt, - if (orderedAt != null) 'ordered_at': orderedAt, + if (pinTime != null) 'pin_time': pinTime, if (rowid != null) 'rowid': rowid, }); } - CirclesCompanion copyWith( - {Value? circleId, - Value? name, + CircleConversationsCompanion copyWith( + {Value? conversationId, + Value? circleId, + Value? userId, Value? createdAt, - Value? orderedAt, + Value? pinTime, Value? rowid}) { - return CirclesCompanion( + return CircleConversationsCompanion( + conversationId: conversationId ?? this.conversationId, circleId: circleId ?? this.circleId, - name: name ?? this.name, + userId: userId ?? this.userId, createdAt: createdAt ?? this.createdAt, - orderedAt: orderedAt ?? this.orderedAt, + pinTime: pinTime ?? this.pinTime, rowid: rowid ?? this.rowid, ); } @@ -8410,19 +7711,22 @@ class CirclesCompanion extends UpdateCompanion { @override Map toColumns(bool nullToAbsent) { final map = {}; + if (conversationId.present) { + map['conversation_id'] = Variable(conversationId.value); + } if (circleId.present) { map['circle_id'] = Variable(circleId.value); } - if (name.present) { - map['name'] = Variable(name.value); + if (userId.present) { + map['user_id'] = Variable(userId.value); } if (createdAt.present) { - final converter = Circles.$convertercreatedAt; + final converter = CircleConversations.$convertercreatedAt; map['created_at'] = Variable(converter.toSql(createdAt.value)); } - if (orderedAt.present) { - final converter = Circles.$converterorderedAtn; - map['ordered_at'] = Variable(converter.toSql(orderedAt.value)); + if (pinTime.present) { + final converter = CircleConversations.$converterpinTimen; + map['pin_time'] = Variable(converter.toSql(pinTime.value)); } if (rowid.present) { map['rowid'] = Variable(rowid.value); @@ -8432,30 +7736,23 @@ class CirclesCompanion extends UpdateCompanion { @override String toString() { - return (StringBuffer('CirclesCompanion(') + return (StringBuffer('CircleConversationsCompanion(') + ..write('conversationId: $conversationId, ') ..write('circleId: $circleId, ') - ..write('name: $name, ') + ..write('userId: $userId, ') ..write('createdAt: $createdAt, ') - ..write('orderedAt: $orderedAt, ') + ..write('pinTime: $pinTime, ') ..write('rowid: $rowid') ..write(')')) .toString(); } } -class CircleConversations extends Table - with TableInfo { +class Circles extends Table with TableInfo { @override final GeneratedDatabase attachedDatabase; final String? _alias; - CircleConversations(this.attachedDatabase, [this._alias]); - static const VerificationMeta _conversationIdMeta = - const VerificationMeta('conversationId'); - late final GeneratedColumn conversationId = GeneratedColumn( - 'conversation_id', aliasedName, false, - type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL'); + Circles(this.attachedDatabase, [this._alias]); static const VerificationMeta _circleIdMeta = const VerificationMeta('circleId'); late final GeneratedColumn circleId = GeneratedColumn( @@ -8463,12 +7760,12 @@ class CircleConversations extends Table type: DriftSqlType.string, requiredDuringInsert: true, $customConstraints: 'NOT NULL'); - static const VerificationMeta _userIdMeta = const VerificationMeta('userId'); - late final GeneratedColumn userId = GeneratedColumn( - 'user_id', aliasedName, true, + static const VerificationMeta _nameMeta = const VerificationMeta('name'); + late final GeneratedColumn name = GeneratedColumn( + 'name', aliasedName, false, type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: ''); + requiredDuringInsert: true, + $customConstraints: 'NOT NULL'); static const VerificationMeta _createdAtMeta = const VerificationMeta('createdAt'); late final GeneratedColumnWithTypeConverter createdAt = @@ -8476,252 +7773,220 @@ class CircleConversations extends Table type: DriftSqlType.int, requiredDuringInsert: true, $customConstraints: 'NOT NULL') - .withConverter(CircleConversations.$convertercreatedAt); - static const VerificationMeta _pinTimeMeta = - const VerificationMeta('pinTime'); - late final GeneratedColumnWithTypeConverter pinTime = - GeneratedColumn('pin_time', aliasedName, true, + .withConverter(Circles.$convertercreatedAt); + static const VerificationMeta _orderedAtMeta = + const VerificationMeta('orderedAt'); + late final GeneratedColumnWithTypeConverter orderedAt = + GeneratedColumn('ordered_at', aliasedName, true, type: DriftSqlType.int, requiredDuringInsert: false, $customConstraints: '') - .withConverter(CircleConversations.$converterpinTimen); + .withConverter(Circles.$converterorderedAtn); @override - List get $columns => - [conversationId, circleId, userId, createdAt, pinTime]; + List get $columns => [circleId, name, createdAt, orderedAt]; @override - String get aliasedName => _alias ?? 'circle_conversations'; + String get aliasedName => _alias ?? 'circles'; @override - String get actualTableName => 'circle_conversations'; + String get actualTableName => 'circles'; @override - VerificationContext validateIntegrity(Insertable instance, + VerificationContext validateIntegrity(Insertable instance, {bool isInserting = false}) { final context = VerificationContext(); final data = instance.toColumns(true); - if (data.containsKey('conversation_id')) { - context.handle( - _conversationIdMeta, - conversationId.isAcceptableOrUnknown( - data['conversation_id']!, _conversationIdMeta)); - } else if (isInserting) { - context.missing(_conversationIdMeta); - } if (data.containsKey('circle_id')) { context.handle(_circleIdMeta, circleId.isAcceptableOrUnknown(data['circle_id']!, _circleIdMeta)); } else if (isInserting) { context.missing(_circleIdMeta); } - if (data.containsKey('user_id')) { - context.handle(_userIdMeta, - userId.isAcceptableOrUnknown(data['user_id']!, _userIdMeta)); - } - context.handle(_createdAtMeta, const VerificationResult.success()); - context.handle(_pinTimeMeta, const VerificationResult.success()); + if (data.containsKey('name')) { + context.handle( + _nameMeta, name.isAcceptableOrUnknown(data['name']!, _nameMeta)); + } else if (isInserting) { + context.missing(_nameMeta); + } + context.handle(_createdAtMeta, const VerificationResult.success()); + context.handle(_orderedAtMeta, const VerificationResult.success()); return context; } @override - Set get $primaryKey => {conversationId, circleId}; + Set get $primaryKey => {circleId}; @override - CircleConversation map(Map data, {String? tablePrefix}) { + Circle map(Map data, {String? tablePrefix}) { final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; - return CircleConversation( - conversationId: attachedDatabase.typeMapping.read( - DriftSqlType.string, data['${effectivePrefix}conversation_id'])!, + return Circle( circleId: attachedDatabase.typeMapping .read(DriftSqlType.string, data['${effectivePrefix}circle_id'])!, - userId: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}user_id']), - createdAt: CircleConversations.$convertercreatedAt.fromSql( - attachedDatabase.typeMapping - .read(DriftSqlType.int, data['${effectivePrefix}created_at'])!), - pinTime: CircleConversations.$converterpinTimen.fromSql(attachedDatabase + name: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}name'])!, + createdAt: Circles.$convertercreatedAt.fromSql(attachedDatabase .typeMapping - .read(DriftSqlType.int, data['${effectivePrefix}pin_time'])), + .read(DriftSqlType.int, data['${effectivePrefix}created_at'])!), + orderedAt: Circles.$converterorderedAtn.fromSql(attachedDatabase + .typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}ordered_at'])), ); } @override - CircleConversations createAlias(String alias) { - return CircleConversations(attachedDatabase, alias); + Circles createAlias(String alias) { + return Circles(attachedDatabase, alias); } static TypeConverter $convertercreatedAt = const MillisDateConverter(); - static TypeConverter $converterpinTime = + static TypeConverter $converterorderedAt = const MillisDateConverter(); - static TypeConverter $converterpinTimen = - NullAwareTypeConverter.wrap($converterpinTime); + static TypeConverter $converterorderedAtn = + NullAwareTypeConverter.wrap($converterorderedAt); @override - List get customConstraints => - const ['PRIMARY KEY(conversation_id, circle_id)']; + List get customConstraints => const ['PRIMARY KEY(circle_id)']; @override bool get dontWriteConstraints => true; } -class CircleConversation extends DataClass - implements Insertable { - final String conversationId; +class Circle extends DataClass implements Insertable { final String circleId; - final String? userId; + final String name; final DateTime createdAt; - final DateTime? pinTime; - const CircleConversation( - {required this.conversationId, - required this.circleId, - this.userId, + final DateTime? orderedAt; + const Circle( + {required this.circleId, + required this.name, required this.createdAt, - this.pinTime}); + this.orderedAt}); @override Map toColumns(bool nullToAbsent) { final map = {}; - map['conversation_id'] = Variable(conversationId); map['circle_id'] = Variable(circleId); - if (!nullToAbsent || userId != null) { - map['user_id'] = Variable(userId); - } + map['name'] = Variable(name); { - final converter = CircleConversations.$convertercreatedAt; + final converter = Circles.$convertercreatedAt; map['created_at'] = Variable(converter.toSql(createdAt)); } - if (!nullToAbsent || pinTime != null) { - final converter = CircleConversations.$converterpinTimen; - map['pin_time'] = Variable(converter.toSql(pinTime)); + if (!nullToAbsent || orderedAt != null) { + final converter = Circles.$converterorderedAtn; + map['ordered_at'] = Variable(converter.toSql(orderedAt)); } return map; } - CircleConversationsCompanion toCompanion(bool nullToAbsent) { - return CircleConversationsCompanion( - conversationId: Value(conversationId), + CirclesCompanion toCompanion(bool nullToAbsent) { + return CirclesCompanion( circleId: Value(circleId), - userId: - userId == null && nullToAbsent ? const Value.absent() : Value(userId), + name: Value(name), createdAt: Value(createdAt), - pinTime: pinTime == null && nullToAbsent + orderedAt: orderedAt == null && nullToAbsent ? const Value.absent() - : Value(pinTime), + : Value(orderedAt), ); } - factory CircleConversation.fromJson(Map json, + factory Circle.fromJson(Map json, {ValueSerializer? serializer}) { serializer ??= driftRuntimeOptions.defaultSerializer; - return CircleConversation( - conversationId: serializer.fromJson(json['conversation_id']), + return Circle( circleId: serializer.fromJson(json['circle_id']), - userId: serializer.fromJson(json['user_id']), + name: serializer.fromJson(json['name']), createdAt: serializer.fromJson(json['created_at']), - pinTime: serializer.fromJson(json['pin_time']), + orderedAt: serializer.fromJson(json['ordered_at']), ); } @override Map toJson({ValueSerializer? serializer}) { serializer ??= driftRuntimeOptions.defaultSerializer; return { - 'conversation_id': serializer.toJson(conversationId), 'circle_id': serializer.toJson(circleId), - 'user_id': serializer.toJson(userId), + 'name': serializer.toJson(name), 'created_at': serializer.toJson(createdAt), - 'pin_time': serializer.toJson(pinTime), + 'ordered_at': serializer.toJson(orderedAt), }; } - CircleConversation copyWith( - {String? conversationId, - String? circleId, - Value userId = const Value.absent(), + Circle copyWith( + {String? circleId, + String? name, DateTime? createdAt, - Value pinTime = const Value.absent()}) => - CircleConversation( - conversationId: conversationId ?? this.conversationId, + Value orderedAt = const Value.absent()}) => + Circle( circleId: circleId ?? this.circleId, - userId: userId.present ? userId.value : this.userId, + name: name ?? this.name, createdAt: createdAt ?? this.createdAt, - pinTime: pinTime.present ? pinTime.value : this.pinTime, + orderedAt: orderedAt.present ? orderedAt.value : this.orderedAt, ); @override String toString() { - return (StringBuffer('CircleConversation(') - ..write('conversationId: $conversationId, ') + return (StringBuffer('Circle(') ..write('circleId: $circleId, ') - ..write('userId: $userId, ') + ..write('name: $name, ') ..write('createdAt: $createdAt, ') - ..write('pinTime: $pinTime') + ..write('orderedAt: $orderedAt') ..write(')')) .toString(); } @override - int get hashCode => - Object.hash(conversationId, circleId, userId, createdAt, pinTime); + int get hashCode => Object.hash(circleId, name, createdAt, orderedAt); @override bool operator ==(Object other) => identical(this, other) || - (other is CircleConversation && - other.conversationId == this.conversationId && + (other is Circle && other.circleId == this.circleId && - other.userId == this.userId && + other.name == this.name && other.createdAt == this.createdAt && - other.pinTime == this.pinTime); + other.orderedAt == this.orderedAt); } -class CircleConversationsCompanion extends UpdateCompanion { - final Value conversationId; +class CirclesCompanion extends UpdateCompanion { final Value circleId; - final Value userId; + final Value name; final Value createdAt; - final Value pinTime; + final Value orderedAt; final Value rowid; - const CircleConversationsCompanion({ - this.conversationId = const Value.absent(), + const CirclesCompanion({ this.circleId = const Value.absent(), - this.userId = const Value.absent(), + this.name = const Value.absent(), this.createdAt = const Value.absent(), - this.pinTime = const Value.absent(), + this.orderedAt = const Value.absent(), this.rowid = const Value.absent(), }); - CircleConversationsCompanion.insert({ - required String conversationId, + CirclesCompanion.insert({ required String circleId, - this.userId = const Value.absent(), + required String name, required DateTime createdAt, - this.pinTime = const Value.absent(), + this.orderedAt = const Value.absent(), this.rowid = const Value.absent(), - }) : conversationId = Value(conversationId), - circleId = Value(circleId), + }) : circleId = Value(circleId), + name = Value(name), createdAt = Value(createdAt); - static Insertable custom({ - Expression? conversationId, + static Insertable custom({ Expression? circleId, - Expression? userId, + Expression? name, Expression? createdAt, - Expression? pinTime, + Expression? orderedAt, Expression? rowid, }) { return RawValuesInsertable({ - if (conversationId != null) 'conversation_id': conversationId, if (circleId != null) 'circle_id': circleId, - if (userId != null) 'user_id': userId, + if (name != null) 'name': name, if (createdAt != null) 'created_at': createdAt, - if (pinTime != null) 'pin_time': pinTime, + if (orderedAt != null) 'ordered_at': orderedAt, if (rowid != null) 'rowid': rowid, }); } - CircleConversationsCompanion copyWith( - {Value? conversationId, - Value? circleId, - Value? userId, + CirclesCompanion copyWith( + {Value? circleId, + Value? name, Value? createdAt, - Value? pinTime, + Value? orderedAt, Value? rowid}) { - return CircleConversationsCompanion( - conversationId: conversationId ?? this.conversationId, + return CirclesCompanion( circleId: circleId ?? this.circleId, - userId: userId ?? this.userId, + name: name ?? this.name, createdAt: createdAt ?? this.createdAt, - pinTime: pinTime ?? this.pinTime, + orderedAt: orderedAt ?? this.orderedAt, rowid: rowid ?? this.rowid, ); } @@ -8729,22 +7994,19 @@ class CircleConversationsCompanion extends UpdateCompanion { @override Map toColumns(bool nullToAbsent) { final map = {}; - if (conversationId.present) { - map['conversation_id'] = Variable(conversationId.value); - } if (circleId.present) { map['circle_id'] = Variable(circleId.value); } - if (userId.present) { - map['user_id'] = Variable(userId.value); + if (name.present) { + map['name'] = Variable(name.value); } if (createdAt.present) { - final converter = CircleConversations.$convertercreatedAt; + final converter = Circles.$convertercreatedAt; map['created_at'] = Variable(converter.toSql(createdAt.value)); } - if (pinTime.present) { - final converter = CircleConversations.$converterpinTimen; - map['pin_time'] = Variable(converter.toSql(pinTime.value)); + if (orderedAt.present) { + final converter = Circles.$converterorderedAtn; + map['ordered_at'] = Variable(converter.toSql(orderedAt.value)); } if (rowid.present) { map['rowid'] = Variable(rowid.value); @@ -8754,43 +8016,35 @@ class CircleConversationsCompanion extends UpdateCompanion { @override String toString() { - return (StringBuffer('CircleConversationsCompanion(') - ..write('conversationId: $conversationId, ') + return (StringBuffer('CirclesCompanion(') ..write('circleId: $circleId, ') - ..write('userId: $userId, ') + ..write('name: $name, ') ..write('createdAt: $createdAt, ') - ..write('pinTime: $pinTime, ') + ..write('orderedAt: $orderedAt, ') ..write('rowid: $rowid') ..write(')')) .toString(); } } -class Participants extends Table with TableInfo { +class FloodMessages extends Table with TableInfo { @override final GeneratedDatabase attachedDatabase; final String? _alias; - Participants(this.attachedDatabase, [this._alias]); - static const VerificationMeta _conversationIdMeta = - const VerificationMeta('conversationId'); - late final GeneratedColumn conversationId = GeneratedColumn( - 'conversation_id', aliasedName, false, + FloodMessages(this.attachedDatabase, [this._alias]); + static const VerificationMeta _messageIdMeta = + const VerificationMeta('messageId'); + late final GeneratedColumn messageId = GeneratedColumn( + 'message_id', aliasedName, false, type: DriftSqlType.string, requiredDuringInsert: true, $customConstraints: 'NOT NULL'); - static const VerificationMeta _userIdMeta = const VerificationMeta('userId'); - late final GeneratedColumn userId = GeneratedColumn( - 'user_id', aliasedName, false, + static const VerificationMeta _dataMeta = const VerificationMeta('data'); + late final GeneratedColumn data = GeneratedColumn( + 'data', aliasedName, false, type: DriftSqlType.string, requiredDuringInsert: true, $customConstraints: 'NOT NULL'); - static const VerificationMeta _roleMeta = const VerificationMeta('role'); - late final GeneratedColumnWithTypeConverter role = - GeneratedColumn('role', aliasedName, true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: '') - .withConverter(Participants.$converterrole); static const VerificationMeta _createdAtMeta = const VerificationMeta('createdAt'); late final GeneratedColumnWithTypeConverter createdAt = @@ -8798,116 +8052,95 @@ class Participants extends Table with TableInfo { type: DriftSqlType.int, requiredDuringInsert: true, $customConstraints: 'NOT NULL') - .withConverter(Participants.$convertercreatedAt); + .withConverter(FloodMessages.$convertercreatedAt); @override - List get $columns => - [conversationId, userId, role, createdAt]; + List get $columns => [messageId, data, createdAt]; @override - String get aliasedName => _alias ?? 'participants'; + String get aliasedName => _alias ?? 'flood_messages'; @override - String get actualTableName => 'participants'; + String get actualTableName => 'flood_messages'; @override - VerificationContext validateIntegrity(Insertable instance, + VerificationContext validateIntegrity(Insertable instance, {bool isInserting = false}) { final context = VerificationContext(); final data = instance.toColumns(true); - if (data.containsKey('conversation_id')) { - context.handle( - _conversationIdMeta, - conversationId.isAcceptableOrUnknown( - data['conversation_id']!, _conversationIdMeta)); + if (data.containsKey('message_id')) { + context.handle(_messageIdMeta, + messageId.isAcceptableOrUnknown(data['message_id']!, _messageIdMeta)); } else if (isInserting) { - context.missing(_conversationIdMeta); + context.missing(_messageIdMeta); } - if (data.containsKey('user_id')) { - context.handle(_userIdMeta, - userId.isAcceptableOrUnknown(data['user_id']!, _userIdMeta)); + if (data.containsKey('data')) { + context.handle( + _dataMeta, this.data.isAcceptableOrUnknown(data['data']!, _dataMeta)); } else if (isInserting) { - context.missing(_userIdMeta); + context.missing(_dataMeta); } - context.handle(_roleMeta, const VerificationResult.success()); context.handle(_createdAtMeta, const VerificationResult.success()); return context; } @override - Set get $primaryKey => {conversationId, userId}; + Set get $primaryKey => {messageId}; @override - Participant map(Map data, {String? tablePrefix}) { + FloodMessage map(Map data, {String? tablePrefix}) { final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; - return Participant( - conversationId: attachedDatabase.typeMapping.read( - DriftSqlType.string, data['${effectivePrefix}conversation_id'])!, - userId: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}user_id'])!, - role: Participants.$converterrole.fromSql(attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}role'])), - createdAt: Participants.$convertercreatedAt.fromSql(attachedDatabase + return FloodMessage( + messageId: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}message_id'])!, + data: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}data'])!, + createdAt: FloodMessages.$convertercreatedAt.fromSql(attachedDatabase .typeMapping .read(DriftSqlType.int, data['${effectivePrefix}created_at'])!), ); } @override - Participants createAlias(String alias) { - return Participants(attachedDatabase, alias); + FloodMessages createAlias(String alias) { + return FloodMessages(attachedDatabase, alias); } - static TypeConverter $converterrole = - const ParticipantRoleConverter(); static TypeConverter $convertercreatedAt = const MillisDateConverter(); @override - List get customConstraints => const [ - 'PRIMARY KEY(conversation_id, user_id)', - 'FOREIGN KEY(conversation_id)REFERENCES conversations(conversation_id)ON UPDATE NO ACTION ON DELETE CASCADE' - ]; + List get customConstraints => const ['PRIMARY KEY(message_id)']; @override bool get dontWriteConstraints => true; } -class Participant extends DataClass implements Insertable { - final String conversationId; - final String userId; - final ParticipantRole? role; +class FloodMessage extends DataClass implements Insertable { + final String messageId; + final String data; final DateTime createdAt; - const Participant( - {required this.conversationId, - required this.userId, - this.role, - required this.createdAt}); + const FloodMessage( + {required this.messageId, required this.data, required this.createdAt}); @override Map toColumns(bool nullToAbsent) { final map = {}; - map['conversation_id'] = Variable(conversationId); - map['user_id'] = Variable(userId); - if (!nullToAbsent || role != null) { - final converter = Participants.$converterrole; - map['role'] = Variable(converter.toSql(role)); - } + map['message_id'] = Variable(messageId); + map['data'] = Variable(data); { - final converter = Participants.$convertercreatedAt; + final converter = FloodMessages.$convertercreatedAt; map['created_at'] = Variable(converter.toSql(createdAt)); } return map; } - ParticipantsCompanion toCompanion(bool nullToAbsent) { - return ParticipantsCompanion( - conversationId: Value(conversationId), - userId: Value(userId), - role: role == null && nullToAbsent ? const Value.absent() : Value(role), + FloodMessagesCompanion toCompanion(bool nullToAbsent) { + return FloodMessagesCompanion( + messageId: Value(messageId), + data: Value(data), createdAt: Value(createdAt), ); } - factory Participant.fromJson(Map json, + factory FloodMessage.fromJson(Map json, {ValueSerializer? serializer}) { serializer ??= driftRuntimeOptions.defaultSerializer; - return Participant( - conversationId: serializer.fromJson(json['conversation_id']), - userId: serializer.fromJson(json['user_id']), - role: serializer.fromJson(json['role']), + return FloodMessage( + messageId: serializer.fromJson(json['message_id']), + data: serializer.fromJson(json['data']), createdAt: serializer.fromJson(json['created_at']), ); } @@ -8915,95 +8148,81 @@ class Participant extends DataClass implements Insertable { Map toJson({ValueSerializer? serializer}) { serializer ??= driftRuntimeOptions.defaultSerializer; return { - 'conversation_id': serializer.toJson(conversationId), - 'user_id': serializer.toJson(userId), - 'role': serializer.toJson(role), + 'message_id': serializer.toJson(messageId), + 'data': serializer.toJson(data), 'created_at': serializer.toJson(createdAt), }; } - Participant copyWith( - {String? conversationId, - String? userId, - Value role = const Value.absent(), - DateTime? createdAt}) => - Participant( - conversationId: conversationId ?? this.conversationId, - userId: userId ?? this.userId, - role: role.present ? role.value : this.role, + FloodMessage copyWith( + {String? messageId, String? data, DateTime? createdAt}) => + FloodMessage( + messageId: messageId ?? this.messageId, + data: data ?? this.data, createdAt: createdAt ?? this.createdAt, ); @override String toString() { - return (StringBuffer('Participant(') - ..write('conversationId: $conversationId, ') - ..write('userId: $userId, ') - ..write('role: $role, ') + return (StringBuffer('FloodMessage(') + ..write('messageId: $messageId, ') + ..write('data: $data, ') ..write('createdAt: $createdAt') ..write(')')) .toString(); } @override - int get hashCode => Object.hash(conversationId, userId, role, createdAt); + int get hashCode => Object.hash(messageId, data, createdAt); @override bool operator ==(Object other) => identical(this, other) || - (other is Participant && - other.conversationId == this.conversationId && - other.userId == this.userId && - other.role == this.role && + (other is FloodMessage && + other.messageId == this.messageId && + other.data == this.data && other.createdAt == this.createdAt); } -class ParticipantsCompanion extends UpdateCompanion { - final Value conversationId; - final Value userId; - final Value role; +class FloodMessagesCompanion extends UpdateCompanion { + final Value messageId; + final Value data; final Value createdAt; final Value rowid; - const ParticipantsCompanion({ - this.conversationId = const Value.absent(), - this.userId = const Value.absent(), - this.role = const Value.absent(), + const FloodMessagesCompanion({ + this.messageId = const Value.absent(), + this.data = const Value.absent(), this.createdAt = const Value.absent(), this.rowid = const Value.absent(), }); - ParticipantsCompanion.insert({ - required String conversationId, - required String userId, - this.role = const Value.absent(), + FloodMessagesCompanion.insert({ + required String messageId, + required String data, required DateTime createdAt, this.rowid = const Value.absent(), - }) : conversationId = Value(conversationId), - userId = Value(userId), + }) : messageId = Value(messageId), + data = Value(data), createdAt = Value(createdAt); - static Insertable custom({ - Expression? conversationId, - Expression? userId, - Expression? role, + static Insertable custom({ + Expression? messageId, + Expression? data, Expression? createdAt, Expression? rowid, }) { return RawValuesInsertable({ - if (conversationId != null) 'conversation_id': conversationId, - if (userId != null) 'user_id': userId, - if (role != null) 'role': role, + if (messageId != null) 'message_id': messageId, + if (data != null) 'data': data, if (createdAt != null) 'created_at': createdAt, if (rowid != null) 'rowid': rowid, }); } - ParticipantsCompanion copyWith( - {Value? conversationId, - Value? userId, - Value? role, + FloodMessagesCompanion copyWith( + {Value? messageId, + Value? data, Value? createdAt, Value? rowid}) { - return ParticipantsCompanion( - conversationId: conversationId ?? this.conversationId, - userId: userId ?? this.userId, - role: role ?? this.role, + return FloodMessagesCompanion( + messageId: messageId ?? this.messageId, + data: data ?? this.data, createdAt: createdAt ?? this.createdAt, rowid: rowid ?? this.rowid, ); @@ -9012,18 +8231,14 @@ class ParticipantsCompanion extends UpdateCompanion { @override Map toColumns(bool nullToAbsent) { final map = {}; - if (conversationId.present) { - map['conversation_id'] = Variable(conversationId.value); - } - if (userId.present) { - map['user_id'] = Variable(userId.value); + if (messageId.present) { + map['message_id'] = Variable(messageId.value); } - if (role.present) { - final converter = Participants.$converterrole; - map['role'] = Variable(converter.toSql(role.value)); + if (data.present) { + map['data'] = Variable(data.value); } if (createdAt.present) { - final converter = Participants.$convertercreatedAt; + final converter = FloodMessages.$convertercreatedAt; map['created_at'] = Variable(converter.toSql(createdAt.value)); } if (rowid.present) { @@ -9034,10 +8249,9 @@ class ParticipantsCompanion extends UpdateCompanion { @override String toString() { - return (StringBuffer('ParticipantsCompanion(') - ..write('conversationId: $conversationId, ') - ..write('userId: $userId, ') - ..write('role: $role, ') + return (StringBuffer('FloodMessagesCompanion(') + ..write('messageId: $messageId, ') + ..write('data: $data, ') ..write('createdAt: $createdAt, ') ..write('rowid: $rowid') ..write(')')) @@ -9045,323 +8259,461 @@ class ParticipantsCompanion extends UpdateCompanion { } } -class ParticipantSession extends Table - with TableInfo { +class Jobs extends Table with TableInfo { @override final GeneratedDatabase attachedDatabase; final String? _alias; - ParticipantSession(this.attachedDatabase, [this._alias]); - static const VerificationMeta _conversationIdMeta = - const VerificationMeta('conversationId'); - late final GeneratedColumn conversationId = GeneratedColumn( - 'conversation_id', aliasedName, false, + Jobs(this.attachedDatabase, [this._alias]); + static const VerificationMeta _jobIdMeta = const VerificationMeta('jobId'); + late final GeneratedColumn jobId = GeneratedColumn( + 'job_id', aliasedName, false, type: DriftSqlType.string, requiredDuringInsert: true, $customConstraints: 'NOT NULL'); - static const VerificationMeta _userIdMeta = const VerificationMeta('userId'); - late final GeneratedColumn userId = GeneratedColumn( - 'user_id', aliasedName, false, + static const VerificationMeta _actionMeta = const VerificationMeta('action'); + late final GeneratedColumn action = GeneratedColumn( + 'action', aliasedName, false, type: DriftSqlType.string, requiredDuringInsert: true, $customConstraints: 'NOT NULL'); - static const VerificationMeta _sessionIdMeta = - const VerificationMeta('sessionId'); - late final GeneratedColumn sessionId = GeneratedColumn( - 'session_id', aliasedName, false, - type: DriftSqlType.string, + static const VerificationMeta _createdAtMeta = + const VerificationMeta('createdAt'); + late final GeneratedColumnWithTypeConverter createdAt = + GeneratedColumn('created_at', aliasedName, false, + type: DriftSqlType.int, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL') + .withConverter(Jobs.$convertercreatedAt); + static const VerificationMeta _orderIdMeta = + const VerificationMeta('orderId'); + late final GeneratedColumn orderId = GeneratedColumn( + 'order_id', aliasedName, true, + type: DriftSqlType.int, + requiredDuringInsert: false, + $customConstraints: ''); + static const VerificationMeta _priorityMeta = + const VerificationMeta('priority'); + late final GeneratedColumn priority = GeneratedColumn( + 'priority', aliasedName, false, + type: DriftSqlType.int, requiredDuringInsert: true, $customConstraints: 'NOT NULL'); - static const VerificationMeta _sentToServerMeta = - const VerificationMeta('sentToServer'); - late final GeneratedColumn sentToServer = GeneratedColumn( - 'sent_to_server', aliasedName, true, - type: DriftSqlType.int, + static const VerificationMeta _userIdMeta = const VerificationMeta('userId'); + late final GeneratedColumn userId = GeneratedColumn( + 'user_id', aliasedName, true, + type: DriftSqlType.string, requiredDuringInsert: false, $customConstraints: ''); - static const VerificationMeta _createdAtMeta = - const VerificationMeta('createdAt'); - late final GeneratedColumnWithTypeConverter createdAt = - GeneratedColumn('created_at', aliasedName, true, - type: DriftSqlType.int, - requiredDuringInsert: false, - $customConstraints: '') - .withConverter(ParticipantSession.$convertercreatedAtn); - static const VerificationMeta _publicKeyMeta = - const VerificationMeta('publicKey'); - late final GeneratedColumn publicKey = GeneratedColumn( - 'public_key', aliasedName, true, + static const VerificationMeta _blazeMessageMeta = + const VerificationMeta('blazeMessage'); + late final GeneratedColumn blazeMessage = GeneratedColumn( + 'blaze_message', aliasedName, true, type: DriftSqlType.string, requiredDuringInsert: false, $customConstraints: ''); + static const VerificationMeta _conversationIdMeta = + const VerificationMeta('conversationId'); + late final GeneratedColumn conversationId = GeneratedColumn( + 'conversation_id', aliasedName, true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: ''); + static const VerificationMeta _resendMessageIdMeta = + const VerificationMeta('resendMessageId'); + late final GeneratedColumn resendMessageId = GeneratedColumn( + 'resend_message_id', aliasedName, true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: ''); + static const VerificationMeta _runCountMeta = + const VerificationMeta('runCount'); + late final GeneratedColumn runCount = GeneratedColumn( + 'run_count', aliasedName, false, + type: DriftSqlType.int, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL'); @override - List get $columns => - [conversationId, userId, sessionId, sentToServer, createdAt, publicKey]; - @override - String get aliasedName => _alias ?? 'participant_session'; - @override - String get actualTableName => 'participant_session'; + List get $columns => [ + jobId, + action, + createdAt, + orderId, + priority, + userId, + blazeMessage, + conversationId, + resendMessageId, + runCount + ]; @override - VerificationContext validateIntegrity( - Insertable instance, + String get aliasedName => _alias ?? 'jobs'; + @override + String get actualTableName => 'jobs'; + @override + VerificationContext validateIntegrity(Insertable instance, {bool isInserting = false}) { final context = VerificationContext(); final data = instance.toColumns(true); - if (data.containsKey('conversation_id')) { + if (data.containsKey('job_id')) { context.handle( - _conversationIdMeta, - conversationId.isAcceptableOrUnknown( - data['conversation_id']!, _conversationIdMeta)); + _jobIdMeta, jobId.isAcceptableOrUnknown(data['job_id']!, _jobIdMeta)); } else if (isInserting) { - context.missing(_conversationIdMeta); + context.missing(_jobIdMeta); + } + if (data.containsKey('action')) { + context.handle(_actionMeta, + action.isAcceptableOrUnknown(data['action']!, _actionMeta)); + } else if (isInserting) { + context.missing(_actionMeta); + } + context.handle(_createdAtMeta, const VerificationResult.success()); + if (data.containsKey('order_id')) { + context.handle(_orderIdMeta, + orderId.isAcceptableOrUnknown(data['order_id']!, _orderIdMeta)); + } + if (data.containsKey('priority')) { + context.handle(_priorityMeta, + priority.isAcceptableOrUnknown(data['priority']!, _priorityMeta)); + } else if (isInserting) { + context.missing(_priorityMeta); } if (data.containsKey('user_id')) { context.handle(_userIdMeta, userId.isAcceptableOrUnknown(data['user_id']!, _userIdMeta)); - } else if (isInserting) { - context.missing(_userIdMeta); } - if (data.containsKey('session_id')) { - context.handle(_sessionIdMeta, - sessionId.isAcceptableOrUnknown(data['session_id']!, _sessionIdMeta)); - } else if (isInserting) { - context.missing(_sessionIdMeta); + if (data.containsKey('blaze_message')) { + context.handle( + _blazeMessageMeta, + blazeMessage.isAcceptableOrUnknown( + data['blaze_message']!, _blazeMessageMeta)); } - if (data.containsKey('sent_to_server')) { + if (data.containsKey('conversation_id')) { context.handle( - _sentToServerMeta, - sentToServer.isAcceptableOrUnknown( - data['sent_to_server']!, _sentToServerMeta)); + _conversationIdMeta, + conversationId.isAcceptableOrUnknown( + data['conversation_id']!, _conversationIdMeta)); } - context.handle(_createdAtMeta, const VerificationResult.success()); - if (data.containsKey('public_key')) { - context.handle(_publicKeyMeta, - publicKey.isAcceptableOrUnknown(data['public_key']!, _publicKeyMeta)); + if (data.containsKey('resend_message_id')) { + context.handle( + _resendMessageIdMeta, + resendMessageId.isAcceptableOrUnknown( + data['resend_message_id']!, _resendMessageIdMeta)); + } + if (data.containsKey('run_count')) { + context.handle(_runCountMeta, + runCount.isAcceptableOrUnknown(data['run_count']!, _runCountMeta)); + } else if (isInserting) { + context.missing(_runCountMeta); } return context; } @override - Set get $primaryKey => {conversationId, userId, sessionId}; + Set get $primaryKey => {jobId}; @override - ParticipantSessionData map(Map data, {String? tablePrefix}) { + Job map(Map data, {String? tablePrefix}) { final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; - return ParticipantSessionData( - conversationId: attachedDatabase.typeMapping.read( - DriftSqlType.string, data['${effectivePrefix}conversation_id'])!, + return Job( + jobId: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}job_id'])!, + action: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}action'])!, + createdAt: Jobs.$convertercreatedAt.fromSql(attachedDatabase.typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}created_at'])!), + orderId: attachedDatabase.typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}order_id']), + priority: attachedDatabase.typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}priority'])!, userId: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}user_id'])!, - sessionId: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}session_id'])!, - sentToServer: attachedDatabase.typeMapping - .read(DriftSqlType.int, data['${effectivePrefix}sent_to_server']), - createdAt: ParticipantSession.$convertercreatedAtn.fromSql( - attachedDatabase.typeMapping - .read(DriftSqlType.int, data['${effectivePrefix}created_at'])), - publicKey: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}public_key']), + .read(DriftSqlType.string, data['${effectivePrefix}user_id']), + blazeMessage: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}blaze_message']), + conversationId: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}conversation_id']), + resendMessageId: attachedDatabase.typeMapping.read( + DriftSqlType.string, data['${effectivePrefix}resend_message_id']), + runCount: attachedDatabase.typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}run_count'])!, ); } @override - ParticipantSession createAlias(String alias) { - return ParticipantSession(attachedDatabase, alias); + Jobs createAlias(String alias) { + return Jobs(attachedDatabase, alias); } static TypeConverter $convertercreatedAt = const MillisDateConverter(); - static TypeConverter $convertercreatedAtn = - NullAwareTypeConverter.wrap($convertercreatedAt); @override - List get customConstraints => - const ['PRIMARY KEY(conversation_id, user_id, session_id)']; + List get customConstraints => const ['PRIMARY KEY(job_id)']; @override bool get dontWriteConstraints => true; } -class ParticipantSessionData extends DataClass - implements Insertable { - final String conversationId; - final String userId; - final String sessionId; - final int? sentToServer; - final DateTime? createdAt; - final String? publicKey; - const ParticipantSessionData( - {required this.conversationId, - required this.userId, - required this.sessionId, - this.sentToServer, - this.createdAt, - this.publicKey}); +class Job extends DataClass implements Insertable { + final String jobId; + final String action; + final DateTime createdAt; + final int? orderId; + final int priority; + final String? userId; + final String? blazeMessage; + final String? conversationId; + final String? resendMessageId; + final int runCount; + const Job( + {required this.jobId, + required this.action, + required this.createdAt, + this.orderId, + required this.priority, + this.userId, + this.blazeMessage, + this.conversationId, + this.resendMessageId, + required this.runCount}); @override Map toColumns(bool nullToAbsent) { final map = {}; - map['conversation_id'] = Variable(conversationId); - map['user_id'] = Variable(userId); - map['session_id'] = Variable(sessionId); - if (!nullToAbsent || sentToServer != null) { - map['sent_to_server'] = Variable(sentToServer); - } - if (!nullToAbsent || createdAt != null) { - final converter = ParticipantSession.$convertercreatedAtn; + map['job_id'] = Variable(jobId); + map['action'] = Variable(action); + { + final converter = Jobs.$convertercreatedAt; map['created_at'] = Variable(converter.toSql(createdAt)); } - if (!nullToAbsent || publicKey != null) { - map['public_key'] = Variable(publicKey); + if (!nullToAbsent || orderId != null) { + map['order_id'] = Variable(orderId); + } + map['priority'] = Variable(priority); + if (!nullToAbsent || userId != null) { + map['user_id'] = Variable(userId); + } + if (!nullToAbsent || blazeMessage != null) { + map['blaze_message'] = Variable(blazeMessage); } + if (!nullToAbsent || conversationId != null) { + map['conversation_id'] = Variable(conversationId); + } + if (!nullToAbsent || resendMessageId != null) { + map['resend_message_id'] = Variable(resendMessageId); + } + map['run_count'] = Variable(runCount); return map; } - ParticipantSessionCompanion toCompanion(bool nullToAbsent) { - return ParticipantSessionCompanion( - conversationId: Value(conversationId), - userId: Value(userId), - sessionId: Value(sessionId), - sentToServer: sentToServer == null && nullToAbsent + JobsCompanion toCompanion(bool nullToAbsent) { + return JobsCompanion( + jobId: Value(jobId), + action: Value(action), + createdAt: Value(createdAt), + orderId: orderId == null && nullToAbsent ? const Value.absent() - : Value(sentToServer), - createdAt: createdAt == null && nullToAbsent + : Value(orderId), + priority: Value(priority), + userId: + userId == null && nullToAbsent ? const Value.absent() : Value(userId), + blazeMessage: blazeMessage == null && nullToAbsent ? const Value.absent() - : Value(createdAt), - publicKey: publicKey == null && nullToAbsent + : Value(blazeMessage), + conversationId: conversationId == null && nullToAbsent ? const Value.absent() - : Value(publicKey), + : Value(conversationId), + resendMessageId: resendMessageId == null && nullToAbsent + ? const Value.absent() + : Value(resendMessageId), + runCount: Value(runCount), ); } - factory ParticipantSessionData.fromJson(Map json, + factory Job.fromJson(Map json, {ValueSerializer? serializer}) { serializer ??= driftRuntimeOptions.defaultSerializer; - return ParticipantSessionData( - conversationId: serializer.fromJson(json['conversation_id']), - userId: serializer.fromJson(json['user_id']), - sessionId: serializer.fromJson(json['session_id']), - sentToServer: serializer.fromJson(json['sent_to_server']), - createdAt: serializer.fromJson(json['created_at']), - publicKey: serializer.fromJson(json['public_key']), - ); - } - @override + return Job( + jobId: serializer.fromJson(json['job_id']), + action: serializer.fromJson(json['action']), + createdAt: serializer.fromJson(json['created_at']), + orderId: serializer.fromJson(json['order_id']), + priority: serializer.fromJson(json['priority']), + userId: serializer.fromJson(json['user_id']), + blazeMessage: serializer.fromJson(json['blaze_message']), + conversationId: serializer.fromJson(json['conversation_id']), + resendMessageId: serializer.fromJson(json['resend_message_id']), + runCount: serializer.fromJson(json['run_count']), + ); + } + @override Map toJson({ValueSerializer? serializer}) { serializer ??= driftRuntimeOptions.defaultSerializer; return { - 'conversation_id': serializer.toJson(conversationId), - 'user_id': serializer.toJson(userId), - 'session_id': serializer.toJson(sessionId), - 'sent_to_server': serializer.toJson(sentToServer), - 'created_at': serializer.toJson(createdAt), - 'public_key': serializer.toJson(publicKey), + 'job_id': serializer.toJson(jobId), + 'action': serializer.toJson(action), + 'created_at': serializer.toJson(createdAt), + 'order_id': serializer.toJson(orderId), + 'priority': serializer.toJson(priority), + 'user_id': serializer.toJson(userId), + 'blaze_message': serializer.toJson(blazeMessage), + 'conversation_id': serializer.toJson(conversationId), + 'resend_message_id': serializer.toJson(resendMessageId), + 'run_count': serializer.toJson(runCount), }; } - ParticipantSessionData copyWith( - {String? conversationId, - String? userId, - String? sessionId, - Value sentToServer = const Value.absent(), - Value createdAt = const Value.absent(), - Value publicKey = const Value.absent()}) => - ParticipantSessionData( - conversationId: conversationId ?? this.conversationId, - userId: userId ?? this.userId, - sessionId: sessionId ?? this.sessionId, - sentToServer: - sentToServer.present ? sentToServer.value : this.sentToServer, - createdAt: createdAt.present ? createdAt.value : this.createdAt, - publicKey: publicKey.present ? publicKey.value : this.publicKey, + Job copyWith( + {String? jobId, + String? action, + DateTime? createdAt, + Value orderId = const Value.absent(), + int? priority, + Value userId = const Value.absent(), + Value blazeMessage = const Value.absent(), + Value conversationId = const Value.absent(), + Value resendMessageId = const Value.absent(), + int? runCount}) => + Job( + jobId: jobId ?? this.jobId, + action: action ?? this.action, + createdAt: createdAt ?? this.createdAt, + orderId: orderId.present ? orderId.value : this.orderId, + priority: priority ?? this.priority, + userId: userId.present ? userId.value : this.userId, + blazeMessage: + blazeMessage.present ? blazeMessage.value : this.blazeMessage, + conversationId: + conversationId.present ? conversationId.value : this.conversationId, + resendMessageId: resendMessageId.present + ? resendMessageId.value + : this.resendMessageId, + runCount: runCount ?? this.runCount, ); @override String toString() { - return (StringBuffer('ParticipantSessionData(') - ..write('conversationId: $conversationId, ') - ..write('userId: $userId, ') - ..write('sessionId: $sessionId, ') - ..write('sentToServer: $sentToServer, ') + return (StringBuffer('Job(') + ..write('jobId: $jobId, ') + ..write('action: $action, ') ..write('createdAt: $createdAt, ') - ..write('publicKey: $publicKey') + ..write('orderId: $orderId, ') + ..write('priority: $priority, ') + ..write('userId: $userId, ') + ..write('blazeMessage: $blazeMessage, ') + ..write('conversationId: $conversationId, ') + ..write('resendMessageId: $resendMessageId, ') + ..write('runCount: $runCount') ..write(')')) .toString(); } @override - int get hashCode => Object.hash( - conversationId, userId, sessionId, sentToServer, createdAt, publicKey); + int get hashCode => Object.hash(jobId, action, createdAt, orderId, priority, + userId, blazeMessage, conversationId, resendMessageId, runCount); @override bool operator ==(Object other) => identical(this, other) || - (other is ParticipantSessionData && - other.conversationId == this.conversationId && - other.userId == this.userId && - other.sessionId == this.sessionId && - other.sentToServer == this.sentToServer && + (other is Job && + other.jobId == this.jobId && + other.action == this.action && other.createdAt == this.createdAt && - other.publicKey == this.publicKey); + other.orderId == this.orderId && + other.priority == this.priority && + other.userId == this.userId && + other.blazeMessage == this.blazeMessage && + other.conversationId == this.conversationId && + other.resendMessageId == this.resendMessageId && + other.runCount == this.runCount); } -class ParticipantSessionCompanion - extends UpdateCompanion { - final Value conversationId; - final Value userId; - final Value sessionId; - final Value sentToServer; - final Value createdAt; - final Value publicKey; +class JobsCompanion extends UpdateCompanion { + final Value jobId; + final Value action; + final Value createdAt; + final Value orderId; + final Value priority; + final Value userId; + final Value blazeMessage; + final Value conversationId; + final Value resendMessageId; + final Value runCount; final Value rowid; - const ParticipantSessionCompanion({ - this.conversationId = const Value.absent(), - this.userId = const Value.absent(), - this.sessionId = const Value.absent(), - this.sentToServer = const Value.absent(), + const JobsCompanion({ + this.jobId = const Value.absent(), + this.action = const Value.absent(), this.createdAt = const Value.absent(), - this.publicKey = const Value.absent(), + this.orderId = const Value.absent(), + this.priority = const Value.absent(), + this.userId = const Value.absent(), + this.blazeMessage = const Value.absent(), + this.conversationId = const Value.absent(), + this.resendMessageId = const Value.absent(), + this.runCount = const Value.absent(), this.rowid = const Value.absent(), }); - ParticipantSessionCompanion.insert({ - required String conversationId, - required String userId, - required String sessionId, - this.sentToServer = const Value.absent(), - this.createdAt = const Value.absent(), - this.publicKey = const Value.absent(), + JobsCompanion.insert({ + required String jobId, + required String action, + required DateTime createdAt, + this.orderId = const Value.absent(), + required int priority, + this.userId = const Value.absent(), + this.blazeMessage = const Value.absent(), + this.conversationId = const Value.absent(), + this.resendMessageId = const Value.absent(), + required int runCount, this.rowid = const Value.absent(), - }) : conversationId = Value(conversationId), - userId = Value(userId), - sessionId = Value(sessionId); - static Insertable custom({ - Expression? conversationId, - Expression? userId, - Expression? sessionId, - Expression? sentToServer, + }) : jobId = Value(jobId), + action = Value(action), + createdAt = Value(createdAt), + priority = Value(priority), + runCount = Value(runCount); + static Insertable custom({ + Expression? jobId, + Expression? action, Expression? createdAt, - Expression? publicKey, + Expression? orderId, + Expression? priority, + Expression? userId, + Expression? blazeMessage, + Expression? conversationId, + Expression? resendMessageId, + Expression? runCount, Expression? rowid, }) { return RawValuesInsertable({ - if (conversationId != null) 'conversation_id': conversationId, - if (userId != null) 'user_id': userId, - if (sessionId != null) 'session_id': sessionId, - if (sentToServer != null) 'sent_to_server': sentToServer, + if (jobId != null) 'job_id': jobId, + if (action != null) 'action': action, if (createdAt != null) 'created_at': createdAt, - if (publicKey != null) 'public_key': publicKey, + if (orderId != null) 'order_id': orderId, + if (priority != null) 'priority': priority, + if (userId != null) 'user_id': userId, + if (blazeMessage != null) 'blaze_message': blazeMessage, + if (conversationId != null) 'conversation_id': conversationId, + if (resendMessageId != null) 'resend_message_id': resendMessageId, + if (runCount != null) 'run_count': runCount, if (rowid != null) 'rowid': rowid, }); } - ParticipantSessionCompanion copyWith( - {Value? conversationId, - Value? userId, - Value? sessionId, - Value? sentToServer, - Value? createdAt, - Value? publicKey, + JobsCompanion copyWith( + {Value? jobId, + Value? action, + Value? createdAt, + Value? orderId, + Value? priority, + Value? userId, + Value? blazeMessage, + Value? conversationId, + Value? resendMessageId, + Value? runCount, Value? rowid}) { - return ParticipantSessionCompanion( - conversationId: conversationId ?? this.conversationId, - userId: userId ?? this.userId, - sessionId: sessionId ?? this.sessionId, - sentToServer: sentToServer ?? this.sentToServer, + return JobsCompanion( + jobId: jobId ?? this.jobId, + action: action ?? this.action, createdAt: createdAt ?? this.createdAt, - publicKey: publicKey ?? this.publicKey, + orderId: orderId ?? this.orderId, + priority: priority ?? this.priority, + userId: userId ?? this.userId, + blazeMessage: blazeMessage ?? this.blazeMessage, + conversationId: conversationId ?? this.conversationId, + resendMessageId: resendMessageId ?? this.resendMessageId, + runCount: runCount ?? this.runCount, rowid: rowid ?? this.rowid, ); } @@ -9369,52 +8721,68 @@ class ParticipantSessionCompanion @override Map toColumns(bool nullToAbsent) { final map = {}; - if (conversationId.present) { - map['conversation_id'] = Variable(conversationId.value); - } - if (userId.present) { - map['user_id'] = Variable(userId.value); - } - if (sessionId.present) { - map['session_id'] = Variable(sessionId.value); + if (jobId.present) { + map['job_id'] = Variable(jobId.value); } - if (sentToServer.present) { - map['sent_to_server'] = Variable(sentToServer.value); + if (action.present) { + map['action'] = Variable(action.value); } if (createdAt.present) { - final converter = ParticipantSession.$convertercreatedAtn; + final converter = Jobs.$convertercreatedAt; map['created_at'] = Variable(converter.toSql(createdAt.value)); } - if (publicKey.present) { - map['public_key'] = Variable(publicKey.value); + if (orderId.present) { + map['order_id'] = Variable(orderId.value); } - if (rowid.present) { - map['rowid'] = Variable(rowid.value); + if (priority.present) { + map['priority'] = Variable(priority.value); + } + if (userId.present) { + map['user_id'] = Variable(userId.value); + } + if (blazeMessage.present) { + map['blaze_message'] = Variable(blazeMessage.value); + } + if (conversationId.present) { + map['conversation_id'] = Variable(conversationId.value); + } + if (resendMessageId.present) { + map['resend_message_id'] = Variable(resendMessageId.value); + } + if (runCount.present) { + map['run_count'] = Variable(runCount.value); + } + if (rowid.present) { + map['rowid'] = Variable(rowid.value); } return map; } @override String toString() { - return (StringBuffer('ParticipantSessionCompanion(') - ..write('conversationId: $conversationId, ') - ..write('userId: $userId, ') - ..write('sessionId: $sessionId, ') - ..write('sentToServer: $sentToServer, ') + return (StringBuffer('JobsCompanion(') + ..write('jobId: $jobId, ') + ..write('action: $action, ') ..write('createdAt: $createdAt, ') - ..write('publicKey: $publicKey, ') + ..write('orderId: $orderId, ') + ..write('priority: $priority, ') + ..write('userId: $userId, ') + ..write('blazeMessage: $blazeMessage, ') + ..write('conversationId: $conversationId, ') + ..write('resendMessageId: $resendMessageId, ') + ..write('runCount: $runCount, ') ..write('rowid: $rowid') ..write(')')) .toString(); } } -class ResendSessionMessages extends Table - with TableInfo { +class MessagesHistory extends Table + with TableInfo { @override final GeneratedDatabase attachedDatabase; final String? _alias; - ResendSessionMessages(this.attachedDatabase, [this._alias]); + MessagesHistory(this.attachedDatabase, [this._alias]); static const VerificationMeta _messageIdMeta = const VerificationMeta('messageId'); late final GeneratedColumn messageId = GeneratedColumn( @@ -9422,43 +8790,15 @@ class ResendSessionMessages extends Table type: DriftSqlType.string, requiredDuringInsert: true, $customConstraints: 'NOT NULL'); - static const VerificationMeta _userIdMeta = const VerificationMeta('userId'); - late final GeneratedColumn userId = GeneratedColumn( - 'user_id', aliasedName, false, - type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL'); - static const VerificationMeta _sessionIdMeta = - const VerificationMeta('sessionId'); - late final GeneratedColumn sessionId = GeneratedColumn( - 'session_id', aliasedName, false, - type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL'); - static const VerificationMeta _statusMeta = const VerificationMeta('status'); - late final GeneratedColumn status = GeneratedColumn( - 'status', aliasedName, false, - type: DriftSqlType.int, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL'); - static const VerificationMeta _createdAtMeta = - const VerificationMeta('createdAt'); - late final GeneratedColumnWithTypeConverter createdAt = - GeneratedColumn('created_at', aliasedName, false, - type: DriftSqlType.int, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL') - .withConverter(ResendSessionMessages.$convertercreatedAt); @override - List get $columns => - [messageId, userId, sessionId, status, createdAt]; + List get $columns => [messageId]; @override - String get aliasedName => _alias ?? 'resend_session_messages'; + String get aliasedName => _alias ?? 'messages_history'; @override - String get actualTableName => 'resend_session_messages'; + String get actualTableName => 'messages_history'; @override VerificationContext validateIntegrity( - Insertable instance, + Insertable instance, {bool isInserting = false}) { final context = VerificationContext(); final data = instance.toColumns(true); @@ -9468,108 +8808,53 @@ class ResendSessionMessages extends Table } else if (isInserting) { context.missing(_messageIdMeta); } - if (data.containsKey('user_id')) { - context.handle(_userIdMeta, - userId.isAcceptableOrUnknown(data['user_id']!, _userIdMeta)); - } else if (isInserting) { - context.missing(_userIdMeta); - } - if (data.containsKey('session_id')) { - context.handle(_sessionIdMeta, - sessionId.isAcceptableOrUnknown(data['session_id']!, _sessionIdMeta)); - } else if (isInserting) { - context.missing(_sessionIdMeta); - } - if (data.containsKey('status')) { - context.handle(_statusMeta, - status.isAcceptableOrUnknown(data['status']!, _statusMeta)); - } else if (isInserting) { - context.missing(_statusMeta); - } - context.handle(_createdAtMeta, const VerificationResult.success()); return context; } @override - Set get $primaryKey => {messageId, userId, sessionId}; + Set get $primaryKey => {messageId}; @override - ResendSessionMessage map(Map data, {String? tablePrefix}) { + MessagesHistoryData map(Map data, {String? tablePrefix}) { final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; - return ResendSessionMessage( + return MessagesHistoryData( messageId: attachedDatabase.typeMapping .read(DriftSqlType.string, data['${effectivePrefix}message_id'])!, - userId: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}user_id'])!, - sessionId: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}session_id'])!, - status: attachedDatabase.typeMapping - .read(DriftSqlType.int, data['${effectivePrefix}status'])!, - createdAt: ResendSessionMessages.$convertercreatedAt.fromSql( - attachedDatabase.typeMapping - .read(DriftSqlType.int, data['${effectivePrefix}created_at'])!), ); } @override - ResendSessionMessages createAlias(String alias) { - return ResendSessionMessages(attachedDatabase, alias); + MessagesHistory createAlias(String alias) { + return MessagesHistory(attachedDatabase, alias); } - static TypeConverter $convertercreatedAt = - const MillisDateConverter(); @override - List get customConstraints => - const ['PRIMARY KEY(message_id, user_id, session_id)']; + List get customConstraints => const ['PRIMARY KEY(message_id)']; @override bool get dontWriteConstraints => true; } -class ResendSessionMessage extends DataClass - implements Insertable { +class MessagesHistoryData extends DataClass + implements Insertable { final String messageId; - final String userId; - final String sessionId; - final int status; - final DateTime createdAt; - const ResendSessionMessage( - {required this.messageId, - required this.userId, - required this.sessionId, - required this.status, - required this.createdAt}); + const MessagesHistoryData({required this.messageId}); @override Map toColumns(bool nullToAbsent) { final map = {}; map['message_id'] = Variable(messageId); - map['user_id'] = Variable(userId); - map['session_id'] = Variable(sessionId); - map['status'] = Variable(status); - { - final converter = ResendSessionMessages.$convertercreatedAt; - map['created_at'] = Variable(converter.toSql(createdAt)); - } return map; } - ResendSessionMessagesCompanion toCompanion(bool nullToAbsent) { - return ResendSessionMessagesCompanion( + MessagesHistoryCompanion toCompanion(bool nullToAbsent) { + return MessagesHistoryCompanion( messageId: Value(messageId), - userId: Value(userId), - sessionId: Value(sessionId), - status: Value(status), - createdAt: Value(createdAt), ); } - factory ResendSessionMessage.fromJson(Map json, + factory MessagesHistoryData.fromJson(Map json, {ValueSerializer? serializer}) { serializer ??= driftRuntimeOptions.defaultSerializer; - return ResendSessionMessage( + return MessagesHistoryData( messageId: serializer.fromJson(json['message_id']), - userId: serializer.fromJson(json['user_id']), - sessionId: serializer.fromJson(json['session_id']), - status: serializer.fromJson(json['status']), - createdAt: serializer.fromJson(json['created_at']), ); } @override @@ -9577,111 +8862,53 @@ class ResendSessionMessage extends DataClass serializer ??= driftRuntimeOptions.defaultSerializer; return { 'message_id': serializer.toJson(messageId), - 'user_id': serializer.toJson(userId), - 'session_id': serializer.toJson(sessionId), - 'status': serializer.toJson(status), - 'created_at': serializer.toJson(createdAt), }; } - ResendSessionMessage copyWith( - {String? messageId, - String? userId, - String? sessionId, - int? status, - DateTime? createdAt}) => - ResendSessionMessage( + MessagesHistoryData copyWith({String? messageId}) => MessagesHistoryData( messageId: messageId ?? this.messageId, - userId: userId ?? this.userId, - sessionId: sessionId ?? this.sessionId, - status: status ?? this.status, - createdAt: createdAt ?? this.createdAt, ); @override String toString() { - return (StringBuffer('ResendSessionMessage(') - ..write('messageId: $messageId, ') - ..write('userId: $userId, ') - ..write('sessionId: $sessionId, ') - ..write('status: $status, ') - ..write('createdAt: $createdAt') + return (StringBuffer('MessagesHistoryData(') + ..write('messageId: $messageId') ..write(')')) .toString(); } @override - int get hashCode => - Object.hash(messageId, userId, sessionId, status, createdAt); + int get hashCode => messageId.hashCode; @override bool operator ==(Object other) => identical(this, other) || - (other is ResendSessionMessage && - other.messageId == this.messageId && - other.userId == this.userId && - other.sessionId == this.sessionId && - other.status == this.status && - other.createdAt == this.createdAt); + (other is MessagesHistoryData && other.messageId == this.messageId); } -class ResendSessionMessagesCompanion - extends UpdateCompanion { +class MessagesHistoryCompanion extends UpdateCompanion { final Value messageId; - final Value userId; - final Value sessionId; - final Value status; - final Value createdAt; final Value rowid; - const ResendSessionMessagesCompanion({ + const MessagesHistoryCompanion({ this.messageId = const Value.absent(), - this.userId = const Value.absent(), - this.sessionId = const Value.absent(), - this.status = const Value.absent(), - this.createdAt = const Value.absent(), this.rowid = const Value.absent(), }); - ResendSessionMessagesCompanion.insert({ + MessagesHistoryCompanion.insert({ required String messageId, - required String userId, - required String sessionId, - required int status, - required DateTime createdAt, this.rowid = const Value.absent(), - }) : messageId = Value(messageId), - userId = Value(userId), - sessionId = Value(sessionId), - status = Value(status), - createdAt = Value(createdAt); - static Insertable custom({ + }) : messageId = Value(messageId); + static Insertable custom({ Expression? messageId, - Expression? userId, - Expression? sessionId, - Expression? status, - Expression? createdAt, Expression? rowid, }) { return RawValuesInsertable({ if (messageId != null) 'message_id': messageId, - if (userId != null) 'user_id': userId, - if (sessionId != null) 'session_id': sessionId, - if (status != null) 'status': status, - if (createdAt != null) 'created_at': createdAt, if (rowid != null) 'rowid': rowid, }); } - ResendSessionMessagesCompanion copyWith( - {Value? messageId, - Value? userId, - Value? sessionId, - Value? status, - Value? createdAt, - Value? rowid}) { - return ResendSessionMessagesCompanion( + MessagesHistoryCompanion copyWith( + {Value? messageId, Value? rowid}) { + return MessagesHistoryCompanion( messageId: messageId ?? this.messageId, - userId: userId ?? this.userId, - sessionId: sessionId ?? this.sessionId, - status: status ?? this.status, - createdAt: createdAt ?? this.createdAt, rowid: rowid ?? this.rowid, ); } @@ -9692,19 +8919,6 @@ class ResendSessionMessagesCompanion if (messageId.present) { map['message_id'] = Variable(messageId.value); } - if (userId.present) { - map['user_id'] = Variable(userId.value); - } - if (sessionId.present) { - map['session_id'] = Variable(sessionId.value); - } - if (status.present) { - map['status'] = Variable(status.value); - } - if (createdAt.present) { - final converter = ResendSessionMessages.$convertercreatedAt; - map['created_at'] = Variable(converter.toSql(createdAt.value)); - } if (rowid.present) { map['rowid'] = Variable(rowid.value); } @@ -9713,458 +8927,173 @@ class ResendSessionMessagesCompanion @override String toString() { - return (StringBuffer('ResendSessionMessagesCompanion(') + return (StringBuffer('MessagesHistoryCompanion(') ..write('messageId: $messageId, ') - ..write('userId: $userId, ') - ..write('sessionId: $sessionId, ') - ..write('status: $status, ') - ..write('createdAt: $createdAt, ') ..write('rowid: $rowid') ..write(')')) .toString(); } } -class Addresses extends Table with TableInfo { +class Offsets extends Table with TableInfo { @override final GeneratedDatabase attachedDatabase; final String? _alias; - Addresses(this.attachedDatabase, [this._alias]); - static const VerificationMeta _addressIdMeta = - const VerificationMeta('addressId'); - late final GeneratedColumn addressId = GeneratedColumn( - 'address_id', aliasedName, false, - type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL'); - static const VerificationMeta _typeMeta = const VerificationMeta('type'); - late final GeneratedColumn type = GeneratedColumn( - 'type', aliasedName, false, - type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL'); - static const VerificationMeta _assetIdMeta = - const VerificationMeta('assetId'); - late final GeneratedColumn assetId = GeneratedColumn( - 'asset_id', aliasedName, false, - type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL'); - static const VerificationMeta _destinationMeta = - const VerificationMeta('destination'); - late final GeneratedColumn destination = GeneratedColumn( - 'destination', aliasedName, false, - type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL'); - static const VerificationMeta _labelMeta = const VerificationMeta('label'); - late final GeneratedColumn label = GeneratedColumn( - 'label', aliasedName, false, - type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL'); - static const VerificationMeta _updatedAtMeta = - const VerificationMeta('updatedAt'); - late final GeneratedColumnWithTypeConverter updatedAt = - GeneratedColumn('updated_at', aliasedName, false, - type: DriftSqlType.int, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL') - .withConverter(Addresses.$converterupdatedAt); - static const VerificationMeta _reserveMeta = - const VerificationMeta('reserve'); - late final GeneratedColumn reserve = GeneratedColumn( - 'reserve', aliasedName, false, + Offsets(this.attachedDatabase, [this._alias]); + static const VerificationMeta _keyMeta = const VerificationMeta('key'); + late final GeneratedColumn key = GeneratedColumn( + 'key', aliasedName, false, type: DriftSqlType.string, requiredDuringInsert: true, $customConstraints: 'NOT NULL'); - static const VerificationMeta _feeMeta = const VerificationMeta('fee'); - late final GeneratedColumn fee = GeneratedColumn( - 'fee', aliasedName, false, + static const VerificationMeta _timestampMeta = + const VerificationMeta('timestamp'); + late final GeneratedColumn timestamp = GeneratedColumn( + 'timestamp', aliasedName, false, type: DriftSqlType.string, requiredDuringInsert: true, $customConstraints: 'NOT NULL'); - static const VerificationMeta _tagMeta = const VerificationMeta('tag'); - late final GeneratedColumn tag = GeneratedColumn( - 'tag', aliasedName, true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: ''); - static const VerificationMeta _dustMeta = const VerificationMeta('dust'); - late final GeneratedColumn dust = GeneratedColumn( - 'dust', aliasedName, true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: ''); @override - List get $columns => [ - addressId, - type, - assetId, - destination, - label, - updatedAt, - reserve, - fee, - tag, - dust - ]; + List get $columns => [key, timestamp]; @override - String get aliasedName => _alias ?? 'addresses'; + String get aliasedName => _alias ?? 'offsets'; @override - String get actualTableName => 'addresses'; + String get actualTableName => 'offsets'; @override - VerificationContext validateIntegrity(Insertable instance, + VerificationContext validateIntegrity(Insertable instance, {bool isInserting = false}) { final context = VerificationContext(); final data = instance.toColumns(true); - if (data.containsKey('address_id')) { - context.handle(_addressIdMeta, - addressId.isAcceptableOrUnknown(data['address_id']!, _addressIdMeta)); - } else if (isInserting) { - context.missing(_addressIdMeta); - } - if (data.containsKey('type')) { - context.handle( - _typeMeta, type.isAcceptableOrUnknown(data['type']!, _typeMeta)); - } else if (isInserting) { - context.missing(_typeMeta); - } - if (data.containsKey('asset_id')) { - context.handle(_assetIdMeta, - assetId.isAcceptableOrUnknown(data['asset_id']!, _assetIdMeta)); - } else if (isInserting) { - context.missing(_assetIdMeta); - } - if (data.containsKey('destination')) { - context.handle( - _destinationMeta, - destination.isAcceptableOrUnknown( - data['destination']!, _destinationMeta)); - } else if (isInserting) { - context.missing(_destinationMeta); - } - if (data.containsKey('label')) { + if (data.containsKey('key')) { context.handle( - _labelMeta, label.isAcceptableOrUnknown(data['label']!, _labelMeta)); - } else if (isInserting) { - context.missing(_labelMeta); - } - context.handle(_updatedAtMeta, const VerificationResult.success()); - if (data.containsKey('reserve')) { - context.handle(_reserveMeta, - reserve.isAcceptableOrUnknown(data['reserve']!, _reserveMeta)); + _keyMeta, key.isAcceptableOrUnknown(data['key']!, _keyMeta)); } else if (isInserting) { - context.missing(_reserveMeta); + context.missing(_keyMeta); } - if (data.containsKey('fee')) { - context.handle( - _feeMeta, fee.isAcceptableOrUnknown(data['fee']!, _feeMeta)); + if (data.containsKey('timestamp')) { + context.handle(_timestampMeta, + timestamp.isAcceptableOrUnknown(data['timestamp']!, _timestampMeta)); } else if (isInserting) { - context.missing(_feeMeta); - } - if (data.containsKey('tag')) { - context.handle( - _tagMeta, tag.isAcceptableOrUnknown(data['tag']!, _tagMeta)); - } - if (data.containsKey('dust')) { - context.handle( - _dustMeta, dust.isAcceptableOrUnknown(data['dust']!, _dustMeta)); + context.missing(_timestampMeta); } return context; } @override - Set get $primaryKey => {addressId}; + Set get $primaryKey => {key}; @override - Addresse map(Map data, {String? tablePrefix}) { + Offset map(Map data, {String? tablePrefix}) { final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; - return Addresse( - addressId: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}address_id'])!, - type: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}type'])!, - assetId: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}asset_id'])!, - destination: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}destination'])!, - label: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}label'])!, - updatedAt: Addresses.$converterupdatedAt.fromSql(attachedDatabase - .typeMapping - .read(DriftSqlType.int, data['${effectivePrefix}updated_at'])!), - reserve: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}reserve'])!, - fee: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}fee'])!, - tag: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}tag']), - dust: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}dust']), + return Offset( + key: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}key'])!, + timestamp: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}timestamp'])!, ); } @override - Addresses createAlias(String alias) { - return Addresses(attachedDatabase, alias); + Offsets createAlias(String alias) { + return Offsets(attachedDatabase, alias); } - static TypeConverter $converterupdatedAt = - const MillisDateConverter(); @override - List get customConstraints => const ['PRIMARY KEY(address_id)']; + List get customConstraints => const ['PRIMARY KEY("key")']; @override bool get dontWriteConstraints => true; } -class Addresse extends DataClass implements Insertable { - final String addressId; - final String type; - final String assetId; - final String destination; - final String label; - final DateTime updatedAt; - final String reserve; - final String fee; - final String? tag; - final String? dust; - const Addresse( - {required this.addressId, - required this.type, - required this.assetId, - required this.destination, - required this.label, - required this.updatedAt, - required this.reserve, - required this.fee, - this.tag, - this.dust}); +class Offset extends DataClass implements Insertable { + final String key; + final String timestamp; + const Offset({required this.key, required this.timestamp}); @override Map toColumns(bool nullToAbsent) { final map = {}; - map['address_id'] = Variable(addressId); - map['type'] = Variable(type); - map['asset_id'] = Variable(assetId); - map['destination'] = Variable(destination); - map['label'] = Variable(label); - { - final converter = Addresses.$converterupdatedAt; - map['updated_at'] = Variable(converter.toSql(updatedAt)); - } - map['reserve'] = Variable(reserve); - map['fee'] = Variable(fee); - if (!nullToAbsent || tag != null) { - map['tag'] = Variable(tag); - } - if (!nullToAbsent || dust != null) { - map['dust'] = Variable(dust); - } + map['key'] = Variable(key); + map['timestamp'] = Variable(timestamp); return map; } - AddressesCompanion toCompanion(bool nullToAbsent) { - return AddressesCompanion( - addressId: Value(addressId), - type: Value(type), - assetId: Value(assetId), - destination: Value(destination), - label: Value(label), - updatedAt: Value(updatedAt), - reserve: Value(reserve), - fee: Value(fee), - tag: tag == null && nullToAbsent ? const Value.absent() : Value(tag), - dust: dust == null && nullToAbsent ? const Value.absent() : Value(dust), + OffsetsCompanion toCompanion(bool nullToAbsent) { + return OffsetsCompanion( + key: Value(key), + timestamp: Value(timestamp), ); } - factory Addresse.fromJson(Map json, + factory Offset.fromJson(Map json, {ValueSerializer? serializer}) { serializer ??= driftRuntimeOptions.defaultSerializer; - return Addresse( - addressId: serializer.fromJson(json['address_id']), - type: serializer.fromJson(json['type']), - assetId: serializer.fromJson(json['asset_id']), - destination: serializer.fromJson(json['destination']), - label: serializer.fromJson(json['label']), - updatedAt: serializer.fromJson(json['updated_at']), - reserve: serializer.fromJson(json['reserve']), - fee: serializer.fromJson(json['fee']), - tag: serializer.fromJson(json['tag']), - dust: serializer.fromJson(json['dust']), + return Offset( + key: serializer.fromJson(json['key']), + timestamp: serializer.fromJson(json['timestamp']), ); } @override Map toJson({ValueSerializer? serializer}) { serializer ??= driftRuntimeOptions.defaultSerializer; return { - 'address_id': serializer.toJson(addressId), - 'type': serializer.toJson(type), - 'asset_id': serializer.toJson(assetId), - 'destination': serializer.toJson(destination), - 'label': serializer.toJson(label), - 'updated_at': serializer.toJson(updatedAt), - 'reserve': serializer.toJson(reserve), - 'fee': serializer.toJson(fee), - 'tag': serializer.toJson(tag), - 'dust': serializer.toJson(dust), + 'key': serializer.toJson(key), + 'timestamp': serializer.toJson(timestamp), }; } - Addresse copyWith( - {String? addressId, - String? type, - String? assetId, - String? destination, - String? label, - DateTime? updatedAt, - String? reserve, - String? fee, - Value tag = const Value.absent(), - Value dust = const Value.absent()}) => - Addresse( - addressId: addressId ?? this.addressId, - type: type ?? this.type, - assetId: assetId ?? this.assetId, - destination: destination ?? this.destination, - label: label ?? this.label, - updatedAt: updatedAt ?? this.updatedAt, - reserve: reserve ?? this.reserve, - fee: fee ?? this.fee, - tag: tag.present ? tag.value : this.tag, - dust: dust.present ? dust.value : this.dust, + Offset copyWith({String? key, String? timestamp}) => Offset( + key: key ?? this.key, + timestamp: timestamp ?? this.timestamp, ); @override String toString() { - return (StringBuffer('Addresse(') - ..write('addressId: $addressId, ') - ..write('type: $type, ') - ..write('assetId: $assetId, ') - ..write('destination: $destination, ') - ..write('label: $label, ') - ..write('updatedAt: $updatedAt, ') - ..write('reserve: $reserve, ') - ..write('fee: $fee, ') - ..write('tag: $tag, ') - ..write('dust: $dust') + return (StringBuffer('Offset(') + ..write('key: $key, ') + ..write('timestamp: $timestamp') ..write(')')) .toString(); } @override - int get hashCode => Object.hash(addressId, type, assetId, destination, label, - updatedAt, reserve, fee, tag, dust); + int get hashCode => Object.hash(key, timestamp); @override bool operator ==(Object other) => identical(this, other) || - (other is Addresse && - other.addressId == this.addressId && - other.type == this.type && - other.assetId == this.assetId && - other.destination == this.destination && - other.label == this.label && - other.updatedAt == this.updatedAt && - other.reserve == this.reserve && - other.fee == this.fee && - other.tag == this.tag && - other.dust == this.dust); + (other is Offset && + other.key == this.key && + other.timestamp == this.timestamp); } -class AddressesCompanion extends UpdateCompanion { - final Value addressId; - final Value type; - final Value assetId; - final Value destination; - final Value label; - final Value updatedAt; - final Value reserve; - final Value fee; - final Value tag; - final Value dust; +class OffsetsCompanion extends UpdateCompanion { + final Value key; + final Value timestamp; final Value rowid; - const AddressesCompanion({ - this.addressId = const Value.absent(), - this.type = const Value.absent(), - this.assetId = const Value.absent(), - this.destination = const Value.absent(), - this.label = const Value.absent(), - this.updatedAt = const Value.absent(), - this.reserve = const Value.absent(), - this.fee = const Value.absent(), - this.tag = const Value.absent(), - this.dust = const Value.absent(), + const OffsetsCompanion({ + this.key = const Value.absent(), + this.timestamp = const Value.absent(), this.rowid = const Value.absent(), }); - AddressesCompanion.insert({ - required String addressId, - required String type, - required String assetId, - required String destination, - required String label, - required DateTime updatedAt, - required String reserve, - required String fee, - this.tag = const Value.absent(), - this.dust = const Value.absent(), + OffsetsCompanion.insert({ + required String key, + required String timestamp, this.rowid = const Value.absent(), - }) : addressId = Value(addressId), - type = Value(type), - assetId = Value(assetId), - destination = Value(destination), - label = Value(label), - updatedAt = Value(updatedAt), - reserve = Value(reserve), - fee = Value(fee); - static Insertable custom({ - Expression? addressId, - Expression? type, - Expression? assetId, - Expression? destination, - Expression? label, - Expression? updatedAt, - Expression? reserve, - Expression? fee, - Expression? tag, - Expression? dust, + }) : key = Value(key), + timestamp = Value(timestamp); + static Insertable custom({ + Expression? key, + Expression? timestamp, Expression? rowid, }) { return RawValuesInsertable({ - if (addressId != null) 'address_id': addressId, - if (type != null) 'type': type, - if (assetId != null) 'asset_id': assetId, - if (destination != null) 'destination': destination, - if (label != null) 'label': label, - if (updatedAt != null) 'updated_at': updatedAt, - if (reserve != null) 'reserve': reserve, - if (fee != null) 'fee': fee, - if (tag != null) 'tag': tag, - if (dust != null) 'dust': dust, + if (key != null) 'key': key, + if (timestamp != null) 'timestamp': timestamp, if (rowid != null) 'rowid': rowid, }); } - AddressesCompanion copyWith( - {Value? addressId, - Value? type, - Value? assetId, - Value? destination, - Value? label, - Value? updatedAt, - Value? reserve, - Value? fee, - Value? tag, - Value? dust, - Value? rowid}) { - return AddressesCompanion( - addressId: addressId ?? this.addressId, - type: type ?? this.type, - assetId: assetId ?? this.assetId, - destination: destination ?? this.destination, - label: label ?? this.label, - updatedAt: updatedAt ?? this.updatedAt, - reserve: reserve ?? this.reserve, - fee: fee ?? this.fee, - tag: tag ?? this.tag, - dust: dust ?? this.dust, + OffsetsCompanion copyWith( + {Value? key, Value? timestamp, Value? rowid}) { + return OffsetsCompanion( + key: key ?? this.key, + timestamp: timestamp ?? this.timestamp, rowid: rowid ?? this.rowid, ); } @@ -10172,36 +9101,11 @@ class AddressesCompanion extends UpdateCompanion { @override Map toColumns(bool nullToAbsent) { final map = {}; - if (addressId.present) { - map['address_id'] = Variable(addressId.value); - } - if (type.present) { - map['type'] = Variable(type.value); - } - if (assetId.present) { - map['asset_id'] = Variable(assetId.value); - } - if (destination.present) { - map['destination'] = Variable(destination.value); - } - if (label.present) { - map['label'] = Variable(label.value); - } - if (updatedAt.present) { - final converter = Addresses.$converterupdatedAt; - map['updated_at'] = Variable(converter.toSql(updatedAt.value)); - } - if (reserve.present) { - map['reserve'] = Variable(reserve.value); - } - if (fee.present) { - map['fee'] = Variable(fee.value); - } - if (tag.present) { - map['tag'] = Variable(tag.value); + if (key.present) { + map['key'] = Variable(key.value); } - if (dust.present) { - map['dust'] = Variable(dust.value); + if (timestamp.present) { + map['timestamp'] = Variable(timestamp.value); } if (rowid.present) { map['rowid'] = Variable(rowid.value); @@ -10211,478 +9115,332 @@ class AddressesCompanion extends UpdateCompanion { @override String toString() { - return (StringBuffer('AddressesCompanion(') - ..write('addressId: $addressId, ') - ..write('type: $type, ') - ..write('assetId: $assetId, ') - ..write('destination: $destination, ') - ..write('label: $label, ') - ..write('updatedAt: $updatedAt, ') - ..write('reserve: $reserve, ') - ..write('fee: $fee, ') - ..write('tag: $tag, ') - ..write('dust: $dust, ') + return (StringBuffer('OffsetsCompanion(') + ..write('key: $key, ') + ..write('timestamp: $timestamp, ') ..write('rowid: $rowid') ..write(')')) .toString(); } } -class Jobs extends Table with TableInfo { +class ParticipantSession extends Table + with TableInfo { @override final GeneratedDatabase attachedDatabase; final String? _alias; - Jobs(this.attachedDatabase, [this._alias]); - static const VerificationMeta _jobIdMeta = const VerificationMeta('jobId'); - late final GeneratedColumn jobId = GeneratedColumn( - 'job_id', aliasedName, false, + ParticipantSession(this.attachedDatabase, [this._alias]); + static const VerificationMeta _conversationIdMeta = + const VerificationMeta('conversationId'); + late final GeneratedColumn conversationId = GeneratedColumn( + 'conversation_id', aliasedName, false, type: DriftSqlType.string, requiredDuringInsert: true, $customConstraints: 'NOT NULL'); - static const VerificationMeta _actionMeta = const VerificationMeta('action'); - late final GeneratedColumn action = GeneratedColumn( - 'action', aliasedName, false, + static const VerificationMeta _userIdMeta = const VerificationMeta('userId'); + late final GeneratedColumn userId = GeneratedColumn( + 'user_id', aliasedName, false, type: DriftSqlType.string, requiredDuringInsert: true, $customConstraints: 'NOT NULL'); - static const VerificationMeta _createdAtMeta = - const VerificationMeta('createdAt'); - late final GeneratedColumnWithTypeConverter createdAt = - GeneratedColumn('created_at', aliasedName, false, - type: DriftSqlType.int, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL') - .withConverter(Jobs.$convertercreatedAt); - static const VerificationMeta _orderIdMeta = - const VerificationMeta('orderId'); - late final GeneratedColumn orderId = GeneratedColumn( - 'order_id', aliasedName, true, - type: DriftSqlType.int, - requiredDuringInsert: false, - $customConstraints: ''); - static const VerificationMeta _priorityMeta = - const VerificationMeta('priority'); - late final GeneratedColumn priority = GeneratedColumn( - 'priority', aliasedName, false, - type: DriftSqlType.int, + static const VerificationMeta _sessionIdMeta = + const VerificationMeta('sessionId'); + late final GeneratedColumn sessionId = GeneratedColumn( + 'session_id', aliasedName, false, + type: DriftSqlType.string, requiredDuringInsert: true, $customConstraints: 'NOT NULL'); - static const VerificationMeta _userIdMeta = const VerificationMeta('userId'); - late final GeneratedColumn userId = GeneratedColumn( - 'user_id', aliasedName, true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: ''); - static const VerificationMeta _blazeMessageMeta = - const VerificationMeta('blazeMessage'); - late final GeneratedColumn blazeMessage = GeneratedColumn( - 'blaze_message', aliasedName, true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: ''); - static const VerificationMeta _conversationIdMeta = - const VerificationMeta('conversationId'); - late final GeneratedColumn conversationId = GeneratedColumn( - 'conversation_id', aliasedName, true, - type: DriftSqlType.string, + static const VerificationMeta _sentToServerMeta = + const VerificationMeta('sentToServer'); + late final GeneratedColumn sentToServer = GeneratedColumn( + 'sent_to_server', aliasedName, true, + type: DriftSqlType.int, requiredDuringInsert: false, $customConstraints: ''); - static const VerificationMeta _resendMessageIdMeta = - const VerificationMeta('resendMessageId'); - late final GeneratedColumn resendMessageId = GeneratedColumn( - 'resend_message_id', aliasedName, true, + static const VerificationMeta _createdAtMeta = + const VerificationMeta('createdAt'); + late final GeneratedColumnWithTypeConverter createdAt = + GeneratedColumn('created_at', aliasedName, true, + type: DriftSqlType.int, + requiredDuringInsert: false, + $customConstraints: '') + .withConverter(ParticipantSession.$convertercreatedAtn); + static const VerificationMeta _publicKeyMeta = + const VerificationMeta('publicKey'); + late final GeneratedColumn publicKey = GeneratedColumn( + 'public_key', aliasedName, true, type: DriftSqlType.string, requiredDuringInsert: false, $customConstraints: ''); - static const VerificationMeta _runCountMeta = - const VerificationMeta('runCount'); - late final GeneratedColumn runCount = GeneratedColumn( - 'run_count', aliasedName, false, - type: DriftSqlType.int, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL'); @override - List get $columns => [ - jobId, - action, - createdAt, - orderId, - priority, - userId, - blazeMessage, - conversationId, - resendMessageId, - runCount - ]; + List get $columns => + [conversationId, userId, sessionId, sentToServer, createdAt, publicKey]; @override - String get aliasedName => _alias ?? 'jobs'; + String get aliasedName => _alias ?? 'participant_session'; @override - String get actualTableName => 'jobs'; + String get actualTableName => 'participant_session'; @override - VerificationContext validateIntegrity(Insertable instance, + VerificationContext validateIntegrity( + Insertable instance, {bool isInserting = false}) { final context = VerificationContext(); final data = instance.toColumns(true); - if (data.containsKey('job_id')) { + if (data.containsKey('conversation_id')) { context.handle( - _jobIdMeta, jobId.isAcceptableOrUnknown(data['job_id']!, _jobIdMeta)); - } else if (isInserting) { - context.missing(_jobIdMeta); - } - if (data.containsKey('action')) { - context.handle(_actionMeta, - action.isAcceptableOrUnknown(data['action']!, _actionMeta)); - } else if (isInserting) { - context.missing(_actionMeta); - } - context.handle(_createdAtMeta, const VerificationResult.success()); - if (data.containsKey('order_id')) { - context.handle(_orderIdMeta, - orderId.isAcceptableOrUnknown(data['order_id']!, _orderIdMeta)); - } - if (data.containsKey('priority')) { - context.handle(_priorityMeta, - priority.isAcceptableOrUnknown(data['priority']!, _priorityMeta)); + _conversationIdMeta, + conversationId.isAcceptableOrUnknown( + data['conversation_id']!, _conversationIdMeta)); } else if (isInserting) { - context.missing(_priorityMeta); + context.missing(_conversationIdMeta); } if (data.containsKey('user_id')) { context.handle(_userIdMeta, userId.isAcceptableOrUnknown(data['user_id']!, _userIdMeta)); + } else if (isInserting) { + context.missing(_userIdMeta); } - if (data.containsKey('blaze_message')) { - context.handle( - _blazeMessageMeta, - blazeMessage.isAcceptableOrUnknown( - data['blaze_message']!, _blazeMessageMeta)); - } - if (data.containsKey('conversation_id')) { - context.handle( - _conversationIdMeta, - conversationId.isAcceptableOrUnknown( - data['conversation_id']!, _conversationIdMeta)); + if (data.containsKey('session_id')) { + context.handle(_sessionIdMeta, + sessionId.isAcceptableOrUnknown(data['session_id']!, _sessionIdMeta)); + } else if (isInserting) { + context.missing(_sessionIdMeta); } - if (data.containsKey('resend_message_id')) { + if (data.containsKey('sent_to_server')) { context.handle( - _resendMessageIdMeta, - resendMessageId.isAcceptableOrUnknown( - data['resend_message_id']!, _resendMessageIdMeta)); + _sentToServerMeta, + sentToServer.isAcceptableOrUnknown( + data['sent_to_server']!, _sentToServerMeta)); } - if (data.containsKey('run_count')) { - context.handle(_runCountMeta, - runCount.isAcceptableOrUnknown(data['run_count']!, _runCountMeta)); - } else if (isInserting) { - context.missing(_runCountMeta); + context.handle(_createdAtMeta, const VerificationResult.success()); + if (data.containsKey('public_key')) { + context.handle(_publicKeyMeta, + publicKey.isAcceptableOrUnknown(data['public_key']!, _publicKeyMeta)); } return context; } @override - Set get $primaryKey => {jobId}; + Set get $primaryKey => {conversationId, userId, sessionId}; @override - Job map(Map data, {String? tablePrefix}) { + ParticipantSessionData map(Map data, {String? tablePrefix}) { final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; - return Job( - jobId: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}job_id'])!, - action: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}action'])!, - createdAt: Jobs.$convertercreatedAt.fromSql(attachedDatabase.typeMapping - .read(DriftSqlType.int, data['${effectivePrefix}created_at'])!), - orderId: attachedDatabase.typeMapping - .read(DriftSqlType.int, data['${effectivePrefix}order_id']), - priority: attachedDatabase.typeMapping - .read(DriftSqlType.int, data['${effectivePrefix}priority'])!, + return ParticipantSessionData( + conversationId: attachedDatabase.typeMapping.read( + DriftSqlType.string, data['${effectivePrefix}conversation_id'])!, userId: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}user_id']), - blazeMessage: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}blaze_message']), - conversationId: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}conversation_id']), - resendMessageId: attachedDatabase.typeMapping.read( - DriftSqlType.string, data['${effectivePrefix}resend_message_id']), - runCount: attachedDatabase.typeMapping - .read(DriftSqlType.int, data['${effectivePrefix}run_count'])!, + .read(DriftSqlType.string, data['${effectivePrefix}user_id'])!, + sessionId: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}session_id'])!, + sentToServer: attachedDatabase.typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}sent_to_server']), + createdAt: ParticipantSession.$convertercreatedAtn.fromSql( + attachedDatabase.typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}created_at'])), + publicKey: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}public_key']), ); } @override - Jobs createAlias(String alias) { - return Jobs(attachedDatabase, alias); + ParticipantSession createAlias(String alias) { + return ParticipantSession(attachedDatabase, alias); } static TypeConverter $convertercreatedAt = const MillisDateConverter(); + static TypeConverter $convertercreatedAtn = + NullAwareTypeConverter.wrap($convertercreatedAt); @override - List get customConstraints => const ['PRIMARY KEY(job_id)']; + List get customConstraints => + const ['PRIMARY KEY(conversation_id, user_id, session_id)']; @override bool get dontWriteConstraints => true; } -class Job extends DataClass implements Insertable { - final String jobId; - final String action; - final DateTime createdAt; - final int? orderId; - final int priority; - final String? userId; - final String? blazeMessage; - final String? conversationId; - final String? resendMessageId; - final int runCount; - const Job( - {required this.jobId, - required this.action, - required this.createdAt, - this.orderId, - required this.priority, - this.userId, - this.blazeMessage, - this.conversationId, - this.resendMessageId, - required this.runCount}); +class ParticipantSessionData extends DataClass + implements Insertable { + final String conversationId; + final String userId; + final String sessionId; + final int? sentToServer; + final DateTime? createdAt; + final String? publicKey; + const ParticipantSessionData( + {required this.conversationId, + required this.userId, + required this.sessionId, + this.sentToServer, + this.createdAt, + this.publicKey}); @override Map toColumns(bool nullToAbsent) { final map = {}; - map['job_id'] = Variable(jobId); - map['action'] = Variable(action); - { - final converter = Jobs.$convertercreatedAt; - map['created_at'] = Variable(converter.toSql(createdAt)); - } - if (!nullToAbsent || orderId != null) { - map['order_id'] = Variable(orderId); - } - map['priority'] = Variable(priority); - if (!nullToAbsent || userId != null) { - map['user_id'] = Variable(userId); - } - if (!nullToAbsent || blazeMessage != null) { - map['blaze_message'] = Variable(blazeMessage); + map['conversation_id'] = Variable(conversationId); + map['user_id'] = Variable(userId); + map['session_id'] = Variable(sessionId); + if (!nullToAbsent || sentToServer != null) { + map['sent_to_server'] = Variable(sentToServer); } - if (!nullToAbsent || conversationId != null) { - map['conversation_id'] = Variable(conversationId); + if (!nullToAbsent || createdAt != null) { + final converter = ParticipantSession.$convertercreatedAtn; + map['created_at'] = Variable(converter.toSql(createdAt)); } - if (!nullToAbsent || resendMessageId != null) { - map['resend_message_id'] = Variable(resendMessageId); + if (!nullToAbsent || publicKey != null) { + map['public_key'] = Variable(publicKey); } - map['run_count'] = Variable(runCount); return map; } - JobsCompanion toCompanion(bool nullToAbsent) { - return JobsCompanion( - jobId: Value(jobId), - action: Value(action), - createdAt: Value(createdAt), - orderId: orderId == null && nullToAbsent - ? const Value.absent() - : Value(orderId), - priority: Value(priority), - userId: - userId == null && nullToAbsent ? const Value.absent() : Value(userId), - blazeMessage: blazeMessage == null && nullToAbsent + ParticipantSessionCompanion toCompanion(bool nullToAbsent) { + return ParticipantSessionCompanion( + conversationId: Value(conversationId), + userId: Value(userId), + sessionId: Value(sessionId), + sentToServer: sentToServer == null && nullToAbsent ? const Value.absent() - : Value(blazeMessage), - conversationId: conversationId == null && nullToAbsent + : Value(sentToServer), + createdAt: createdAt == null && nullToAbsent ? const Value.absent() - : Value(conversationId), - resendMessageId: resendMessageId == null && nullToAbsent + : Value(createdAt), + publicKey: publicKey == null && nullToAbsent ? const Value.absent() - : Value(resendMessageId), - runCount: Value(runCount), + : Value(publicKey), ); } - factory Job.fromJson(Map json, + factory ParticipantSessionData.fromJson(Map json, {ValueSerializer? serializer}) { serializer ??= driftRuntimeOptions.defaultSerializer; - return Job( - jobId: serializer.fromJson(json['job_id']), - action: serializer.fromJson(json['action']), - createdAt: serializer.fromJson(json['created_at']), - orderId: serializer.fromJson(json['order_id']), - priority: serializer.fromJson(json['priority']), - userId: serializer.fromJson(json['user_id']), - blazeMessage: serializer.fromJson(json['blaze_message']), - conversationId: serializer.fromJson(json['conversation_id']), - resendMessageId: serializer.fromJson(json['resend_message_id']), - runCount: serializer.fromJson(json['run_count']), + return ParticipantSessionData( + conversationId: serializer.fromJson(json['conversation_id']), + userId: serializer.fromJson(json['user_id']), + sessionId: serializer.fromJson(json['session_id']), + sentToServer: serializer.fromJson(json['sent_to_server']), + createdAt: serializer.fromJson(json['created_at']), + publicKey: serializer.fromJson(json['public_key']), ); } @override Map toJson({ValueSerializer? serializer}) { serializer ??= driftRuntimeOptions.defaultSerializer; return { - 'job_id': serializer.toJson(jobId), - 'action': serializer.toJson(action), - 'created_at': serializer.toJson(createdAt), - 'order_id': serializer.toJson(orderId), - 'priority': serializer.toJson(priority), - 'user_id': serializer.toJson(userId), - 'blaze_message': serializer.toJson(blazeMessage), - 'conversation_id': serializer.toJson(conversationId), - 'resend_message_id': serializer.toJson(resendMessageId), - 'run_count': serializer.toJson(runCount), + 'conversation_id': serializer.toJson(conversationId), + 'user_id': serializer.toJson(userId), + 'session_id': serializer.toJson(sessionId), + 'sent_to_server': serializer.toJson(sentToServer), + 'created_at': serializer.toJson(createdAt), + 'public_key': serializer.toJson(publicKey), }; } - Job copyWith( - {String? jobId, - String? action, - DateTime? createdAt, - Value orderId = const Value.absent(), - int? priority, - Value userId = const Value.absent(), - Value blazeMessage = const Value.absent(), - Value conversationId = const Value.absent(), - Value resendMessageId = const Value.absent(), - int? runCount}) => - Job( - jobId: jobId ?? this.jobId, - action: action ?? this.action, - createdAt: createdAt ?? this.createdAt, - orderId: orderId.present ? orderId.value : this.orderId, - priority: priority ?? this.priority, - userId: userId.present ? userId.value : this.userId, - blazeMessage: - blazeMessage.present ? blazeMessage.value : this.blazeMessage, - conversationId: - conversationId.present ? conversationId.value : this.conversationId, - resendMessageId: resendMessageId.present - ? resendMessageId.value - : this.resendMessageId, - runCount: runCount ?? this.runCount, + ParticipantSessionData copyWith( + {String? conversationId, + String? userId, + String? sessionId, + Value sentToServer = const Value.absent(), + Value createdAt = const Value.absent(), + Value publicKey = const Value.absent()}) => + ParticipantSessionData( + conversationId: conversationId ?? this.conversationId, + userId: userId ?? this.userId, + sessionId: sessionId ?? this.sessionId, + sentToServer: + sentToServer.present ? sentToServer.value : this.sentToServer, + createdAt: createdAt.present ? createdAt.value : this.createdAt, + publicKey: publicKey.present ? publicKey.value : this.publicKey, ); @override String toString() { - return (StringBuffer('Job(') - ..write('jobId: $jobId, ') - ..write('action: $action, ') - ..write('createdAt: $createdAt, ') - ..write('orderId: $orderId, ') - ..write('priority: $priority, ') - ..write('userId: $userId, ') - ..write('blazeMessage: $blazeMessage, ') + return (StringBuffer('ParticipantSessionData(') ..write('conversationId: $conversationId, ') - ..write('resendMessageId: $resendMessageId, ') - ..write('runCount: $runCount') + ..write('userId: $userId, ') + ..write('sessionId: $sessionId, ') + ..write('sentToServer: $sentToServer, ') + ..write('createdAt: $createdAt, ') + ..write('publicKey: $publicKey') ..write(')')) .toString(); } @override - int get hashCode => Object.hash(jobId, action, createdAt, orderId, priority, - userId, blazeMessage, conversationId, resendMessageId, runCount); + int get hashCode => Object.hash( + conversationId, userId, sessionId, sentToServer, createdAt, publicKey); @override bool operator ==(Object other) => identical(this, other) || - (other is Job && - other.jobId == this.jobId && - other.action == this.action && - other.createdAt == this.createdAt && - other.orderId == this.orderId && - other.priority == this.priority && - other.userId == this.userId && - other.blazeMessage == this.blazeMessage && + (other is ParticipantSessionData && other.conversationId == this.conversationId && - other.resendMessageId == this.resendMessageId && - other.runCount == this.runCount); + other.userId == this.userId && + other.sessionId == this.sessionId && + other.sentToServer == this.sentToServer && + other.createdAt == this.createdAt && + other.publicKey == this.publicKey); } -class JobsCompanion extends UpdateCompanion { - final Value jobId; - final Value action; - final Value createdAt; - final Value orderId; - final Value priority; - final Value userId; - final Value blazeMessage; - final Value conversationId; - final Value resendMessageId; - final Value runCount; +class ParticipantSessionCompanion + extends UpdateCompanion { + final Value conversationId; + final Value userId; + final Value sessionId; + final Value sentToServer; + final Value createdAt; + final Value publicKey; final Value rowid; - const JobsCompanion({ - this.jobId = const Value.absent(), - this.action = const Value.absent(), - this.createdAt = const Value.absent(), - this.orderId = const Value.absent(), - this.priority = const Value.absent(), - this.userId = const Value.absent(), - this.blazeMessage = const Value.absent(), + const ParticipantSessionCompanion({ this.conversationId = const Value.absent(), - this.resendMessageId = const Value.absent(), - this.runCount = const Value.absent(), + this.userId = const Value.absent(), + this.sessionId = const Value.absent(), + this.sentToServer = const Value.absent(), + this.createdAt = const Value.absent(), + this.publicKey = const Value.absent(), this.rowid = const Value.absent(), }); - JobsCompanion.insert({ - required String jobId, - required String action, - required DateTime createdAt, - this.orderId = const Value.absent(), - required int priority, - this.userId = const Value.absent(), - this.blazeMessage = const Value.absent(), - this.conversationId = const Value.absent(), - this.resendMessageId = const Value.absent(), - required int runCount, + ParticipantSessionCompanion.insert({ + required String conversationId, + required String userId, + required String sessionId, + this.sentToServer = const Value.absent(), + this.createdAt = const Value.absent(), + this.publicKey = const Value.absent(), this.rowid = const Value.absent(), - }) : jobId = Value(jobId), - action = Value(action), - createdAt = Value(createdAt), - priority = Value(priority), - runCount = Value(runCount); - static Insertable custom({ - Expression? jobId, - Expression? action, - Expression? createdAt, - Expression? orderId, - Expression? priority, - Expression? userId, - Expression? blazeMessage, + }) : conversationId = Value(conversationId), + userId = Value(userId), + sessionId = Value(sessionId); + static Insertable custom({ Expression? conversationId, - Expression? resendMessageId, - Expression? runCount, + Expression? userId, + Expression? sessionId, + Expression? sentToServer, + Expression? createdAt, + Expression? publicKey, Expression? rowid, }) { return RawValuesInsertable({ - if (jobId != null) 'job_id': jobId, - if (action != null) 'action': action, - if (createdAt != null) 'created_at': createdAt, - if (orderId != null) 'order_id': orderId, - if (priority != null) 'priority': priority, - if (userId != null) 'user_id': userId, - if (blazeMessage != null) 'blaze_message': blazeMessage, if (conversationId != null) 'conversation_id': conversationId, - if (resendMessageId != null) 'resend_message_id': resendMessageId, - if (runCount != null) 'run_count': runCount, + if (userId != null) 'user_id': userId, + if (sessionId != null) 'session_id': sessionId, + if (sentToServer != null) 'sent_to_server': sentToServer, + if (createdAt != null) 'created_at': createdAt, + if (publicKey != null) 'public_key': publicKey, if (rowid != null) 'rowid': rowid, }); } - JobsCompanion copyWith( - {Value? jobId, - Value? action, - Value? createdAt, - Value? orderId, - Value? priority, - Value? userId, - Value? blazeMessage, - Value? conversationId, - Value? resendMessageId, - Value? runCount, + ParticipantSessionCompanion copyWith( + {Value? conversationId, + Value? userId, + Value? sessionId, + Value? sentToServer, + Value? createdAt, + Value? publicKey, Value? rowid}) { - return JobsCompanion( - jobId: jobId ?? this.jobId, - action: action ?? this.action, - createdAt: createdAt ?? this.createdAt, - orderId: orderId ?? this.orderId, - priority: priority ?? this.priority, - userId: userId ?? this.userId, - blazeMessage: blazeMessage ?? this.blazeMessage, + return ParticipantSessionCompanion( conversationId: conversationId ?? this.conversationId, - resendMessageId: resendMessageId ?? this.resendMessageId, - runCount: runCount ?? this.runCount, + userId: userId ?? this.userId, + sessionId: sessionId ?? this.sessionId, + sentToServer: sentToServer ?? this.sentToServer, + createdAt: createdAt ?? this.createdAt, + publicKey: publicKey ?? this.publicKey, rowid: rowid ?? this.rowid, ); } @@ -10690,36 +9448,24 @@ class JobsCompanion extends UpdateCompanion { @override Map toColumns(bool nullToAbsent) { final map = {}; - if (jobId.present) { - map['job_id'] = Variable(jobId.value); - } - if (action.present) { - map['action'] = Variable(action.value); - } - if (createdAt.present) { - final converter = Jobs.$convertercreatedAt; - map['created_at'] = Variable(converter.toSql(createdAt.value)); - } - if (orderId.present) { - map['order_id'] = Variable(orderId.value); - } - if (priority.present) { - map['priority'] = Variable(priority.value); + if (conversationId.present) { + map['conversation_id'] = Variable(conversationId.value); } if (userId.present) { map['user_id'] = Variable(userId.value); } - if (blazeMessage.present) { - map['blaze_message'] = Variable(blazeMessage.value); + if (sessionId.present) { + map['session_id'] = Variable(sessionId.value); } - if (conversationId.present) { - map['conversation_id'] = Variable(conversationId.value); + if (sentToServer.present) { + map['sent_to_server'] = Variable(sentToServer.value); } - if (resendMessageId.present) { - map['resend_message_id'] = Variable(resendMessageId.value); + if (createdAt.present) { + final converter = ParticipantSession.$convertercreatedAtn; + map['created_at'] = Variable(converter.toSql(createdAt.value)); } - if (runCount.present) { - map['run_count'] = Variable(runCount.value); + if (publicKey.present) { + map['public_key'] = Variable(publicKey.value); } if (rowid.present) { map['rowid'] = Variable(rowid.value); @@ -10729,155 +9475,258 @@ class JobsCompanion extends UpdateCompanion { @override String toString() { - return (StringBuffer('JobsCompanion(') - ..write('jobId: $jobId, ') - ..write('action: $action, ') - ..write('createdAt: $createdAt, ') - ..write('orderId: $orderId, ') - ..write('priority: $priority, ') - ..write('userId: $userId, ') - ..write('blazeMessage: $blazeMessage, ') + return (StringBuffer('ParticipantSessionCompanion(') ..write('conversationId: $conversationId, ') - ..write('resendMessageId: $resendMessageId, ') - ..write('runCount: $runCount, ') + ..write('userId: $userId, ') + ..write('sessionId: $sessionId, ') + ..write('sentToServer: $sentToServer, ') + ..write('createdAt: $createdAt, ') + ..write('publicKey: $publicKey, ') ..write('rowid: $rowid') ..write(')')) .toString(); } } -class MessagesHistory extends Table - with TableInfo { +class Participants extends Table with TableInfo { @override final GeneratedDatabase attachedDatabase; final String? _alias; - MessagesHistory(this.attachedDatabase, [this._alias]); - static const VerificationMeta _messageIdMeta = - const VerificationMeta('messageId'); - late final GeneratedColumn messageId = GeneratedColumn( - 'message_id', aliasedName, false, + Participants(this.attachedDatabase, [this._alias]); + static const VerificationMeta _conversationIdMeta = + const VerificationMeta('conversationId'); + late final GeneratedColumn conversationId = GeneratedColumn( + 'conversation_id', aliasedName, false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL'); + static const VerificationMeta _userIdMeta = const VerificationMeta('userId'); + late final GeneratedColumn userId = GeneratedColumn( + 'user_id', aliasedName, false, type: DriftSqlType.string, requiredDuringInsert: true, $customConstraints: 'NOT NULL'); + static const VerificationMeta _roleMeta = const VerificationMeta('role'); + late final GeneratedColumnWithTypeConverter role = + GeneratedColumn('role', aliasedName, true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '') + .withConverter(Participants.$converterrole); + static const VerificationMeta _createdAtMeta = + const VerificationMeta('createdAt'); + late final GeneratedColumnWithTypeConverter createdAt = + GeneratedColumn('created_at', aliasedName, false, + type: DriftSqlType.int, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL') + .withConverter(Participants.$convertercreatedAt); @override - List get $columns => [messageId]; + List get $columns => + [conversationId, userId, role, createdAt]; @override - String get aliasedName => _alias ?? 'messages_history'; + String get aliasedName => _alias ?? 'participants'; @override - String get actualTableName => 'messages_history'; + String get actualTableName => 'participants'; @override - VerificationContext validateIntegrity( - Insertable instance, + VerificationContext validateIntegrity(Insertable instance, {bool isInserting = false}) { final context = VerificationContext(); final data = instance.toColumns(true); - if (data.containsKey('message_id')) { - context.handle(_messageIdMeta, - messageId.isAcceptableOrUnknown(data['message_id']!, _messageIdMeta)); + if (data.containsKey('conversation_id')) { + context.handle( + _conversationIdMeta, + conversationId.isAcceptableOrUnknown( + data['conversation_id']!, _conversationIdMeta)); } else if (isInserting) { - context.missing(_messageIdMeta); + context.missing(_conversationIdMeta); + } + if (data.containsKey('user_id')) { + context.handle(_userIdMeta, + userId.isAcceptableOrUnknown(data['user_id']!, _userIdMeta)); + } else if (isInserting) { + context.missing(_userIdMeta); } + context.handle(_roleMeta, const VerificationResult.success()); + context.handle(_createdAtMeta, const VerificationResult.success()); return context; } @override - Set get $primaryKey => {messageId}; + Set get $primaryKey => {conversationId, userId}; @override - MessagesHistoryData map(Map data, {String? tablePrefix}) { + Participant map(Map data, {String? tablePrefix}) { final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; - return MessagesHistoryData( - messageId: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}message_id'])!, + return Participant( + conversationId: attachedDatabase.typeMapping.read( + DriftSqlType.string, data['${effectivePrefix}conversation_id'])!, + userId: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}user_id'])!, + role: Participants.$converterrole.fromSql(attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}role'])), + createdAt: Participants.$convertercreatedAt.fromSql(attachedDatabase + .typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}created_at'])!), ); } @override - MessagesHistory createAlias(String alias) { - return MessagesHistory(attachedDatabase, alias); + Participants createAlias(String alias) { + return Participants(attachedDatabase, alias); } + static TypeConverter $converterrole = + const ParticipantRoleConverter(); + static TypeConverter $convertercreatedAt = + const MillisDateConverter(); @override - List get customConstraints => const ['PRIMARY KEY(message_id)']; + List get customConstraints => const [ + 'PRIMARY KEY(conversation_id, user_id)', + 'FOREIGN KEY(conversation_id)REFERENCES conversations(conversation_id)ON UPDATE NO ACTION ON DELETE CASCADE' + ]; @override bool get dontWriteConstraints => true; } -class MessagesHistoryData extends DataClass - implements Insertable { - final String messageId; - const MessagesHistoryData({required this.messageId}); +class Participant extends DataClass implements Insertable { + final String conversationId; + final String userId; + final ParticipantRole? role; + final DateTime createdAt; + const Participant( + {required this.conversationId, + required this.userId, + this.role, + required this.createdAt}); @override Map toColumns(bool nullToAbsent) { final map = {}; - map['message_id'] = Variable(messageId); + map['conversation_id'] = Variable(conversationId); + map['user_id'] = Variable(userId); + if (!nullToAbsent || role != null) { + final converter = Participants.$converterrole; + map['role'] = Variable(converter.toSql(role)); + } + { + final converter = Participants.$convertercreatedAt; + map['created_at'] = Variable(converter.toSql(createdAt)); + } return map; } - MessagesHistoryCompanion toCompanion(bool nullToAbsent) { - return MessagesHistoryCompanion( - messageId: Value(messageId), + ParticipantsCompanion toCompanion(bool nullToAbsent) { + return ParticipantsCompanion( + conversationId: Value(conversationId), + userId: Value(userId), + role: role == null && nullToAbsent ? const Value.absent() : Value(role), + createdAt: Value(createdAt), ); } - factory MessagesHistoryData.fromJson(Map json, + factory Participant.fromJson(Map json, {ValueSerializer? serializer}) { serializer ??= driftRuntimeOptions.defaultSerializer; - return MessagesHistoryData( - messageId: serializer.fromJson(json['message_id']), + return Participant( + conversationId: serializer.fromJson(json['conversation_id']), + userId: serializer.fromJson(json['user_id']), + role: serializer.fromJson(json['role']), + createdAt: serializer.fromJson(json['created_at']), ); } @override Map toJson({ValueSerializer? serializer}) { serializer ??= driftRuntimeOptions.defaultSerializer; return { - 'message_id': serializer.toJson(messageId), + 'conversation_id': serializer.toJson(conversationId), + 'user_id': serializer.toJson(userId), + 'role': serializer.toJson(role), + 'created_at': serializer.toJson(createdAt), }; } - MessagesHistoryData copyWith({String? messageId}) => MessagesHistoryData( - messageId: messageId ?? this.messageId, + Participant copyWith( + {String? conversationId, + String? userId, + Value role = const Value.absent(), + DateTime? createdAt}) => + Participant( + conversationId: conversationId ?? this.conversationId, + userId: userId ?? this.userId, + role: role.present ? role.value : this.role, + createdAt: createdAt ?? this.createdAt, ); @override String toString() { - return (StringBuffer('MessagesHistoryData(') - ..write('messageId: $messageId') + return (StringBuffer('Participant(') + ..write('conversationId: $conversationId, ') + ..write('userId: $userId, ') + ..write('role: $role, ') + ..write('createdAt: $createdAt') ..write(')')) .toString(); } @override - int get hashCode => messageId.hashCode; + int get hashCode => Object.hash(conversationId, userId, role, createdAt); @override bool operator ==(Object other) => identical(this, other) || - (other is MessagesHistoryData && other.messageId == this.messageId); + (other is Participant && + other.conversationId == this.conversationId && + other.userId == this.userId && + other.role == this.role && + other.createdAt == this.createdAt); } -class MessagesHistoryCompanion extends UpdateCompanion { - final Value messageId; +class ParticipantsCompanion extends UpdateCompanion { + final Value conversationId; + final Value userId; + final Value role; + final Value createdAt; final Value rowid; - const MessagesHistoryCompanion({ - this.messageId = const Value.absent(), + const ParticipantsCompanion({ + this.conversationId = const Value.absent(), + this.userId = const Value.absent(), + this.role = const Value.absent(), + this.createdAt = const Value.absent(), this.rowid = const Value.absent(), }); - MessagesHistoryCompanion.insert({ - required String messageId, + ParticipantsCompanion.insert({ + required String conversationId, + required String userId, + this.role = const Value.absent(), + required DateTime createdAt, this.rowid = const Value.absent(), - }) : messageId = Value(messageId); - static Insertable custom({ - Expression? messageId, - Expression? rowid, - }) { - return RawValuesInsertable({ - if (messageId != null) 'message_id': messageId, + }) : conversationId = Value(conversationId), + userId = Value(userId), + createdAt = Value(createdAt); + static Insertable custom({ + Expression? conversationId, + Expression? userId, + Expression? role, + Expression? createdAt, + Expression? rowid, + }) { + return RawValuesInsertable({ + if (conversationId != null) 'conversation_id': conversationId, + if (userId != null) 'user_id': userId, + if (role != null) 'role': role, + if (createdAt != null) 'created_at': createdAt, if (rowid != null) 'rowid': rowid, }); } - MessagesHistoryCompanion copyWith( - {Value? messageId, Value? rowid}) { - return MessagesHistoryCompanion( - messageId: messageId ?? this.messageId, + ParticipantsCompanion copyWith( + {Value? conversationId, + Value? userId, + Value? role, + Value? createdAt, + Value? rowid}) { + return ParticipantsCompanion( + conversationId: conversationId ?? this.conversationId, + userId: userId ?? this.userId, + role: role ?? this.role, + createdAt: createdAt ?? this.createdAt, rowid: rowid ?? this.rowid, ); } @@ -10885,8 +9734,19 @@ class MessagesHistoryCompanion extends UpdateCompanion { @override Map toColumns(bool nullToAbsent) { final map = {}; - if (messageId.present) { - map['message_id'] = Variable(messageId.value); + if (conversationId.present) { + map['conversation_id'] = Variable(conversationId.value); + } + if (userId.present) { + map['user_id'] = Variable(userId.value); + } + if (role.present) { + final converter = Participants.$converterrole; + map['role'] = Variable(converter.toSql(role.value)); + } + if (createdAt.present) { + final converter = Participants.$convertercreatedAt; + map['created_at'] = Variable(converter.toSql(createdAt.value)); } if (rowid.present) { map['rowid'] = Variable(rowid.value); @@ -10896,173 +9756,290 @@ class MessagesHistoryCompanion extends UpdateCompanion { @override String toString() { - return (StringBuffer('MessagesHistoryCompanion(') - ..write('messageId: $messageId, ') + return (StringBuffer('ParticipantsCompanion(') + ..write('conversationId: $conversationId, ') + ..write('userId: $userId, ') + ..write('role: $role, ') + ..write('createdAt: $createdAt, ') ..write('rowid: $rowid') ..write(')')) .toString(); } } -class Offsets extends Table with TableInfo { +class ResendSessionMessages extends Table + with TableInfo { @override final GeneratedDatabase attachedDatabase; final String? _alias; - Offsets(this.attachedDatabase, [this._alias]); - static const VerificationMeta _keyMeta = const VerificationMeta('key'); - late final GeneratedColumn key = GeneratedColumn( - 'key', aliasedName, false, + ResendSessionMessages(this.attachedDatabase, [this._alias]); + static const VerificationMeta _messageIdMeta = + const VerificationMeta('messageId'); + late final GeneratedColumn messageId = GeneratedColumn( + 'message_id', aliasedName, false, type: DriftSqlType.string, requiredDuringInsert: true, $customConstraints: 'NOT NULL'); - static const VerificationMeta _timestampMeta = - const VerificationMeta('timestamp'); - late final GeneratedColumn timestamp = GeneratedColumn( - 'timestamp', aliasedName, false, + static const VerificationMeta _userIdMeta = const VerificationMeta('userId'); + late final GeneratedColumn userId = GeneratedColumn( + 'user_id', aliasedName, false, type: DriftSqlType.string, requiredDuringInsert: true, $customConstraints: 'NOT NULL'); + static const VerificationMeta _sessionIdMeta = + const VerificationMeta('sessionId'); + late final GeneratedColumn sessionId = GeneratedColumn( + 'session_id', aliasedName, false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL'); + static const VerificationMeta _statusMeta = const VerificationMeta('status'); + late final GeneratedColumn status = GeneratedColumn( + 'status', aliasedName, false, + type: DriftSqlType.int, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL'); + static const VerificationMeta _createdAtMeta = + const VerificationMeta('createdAt'); + late final GeneratedColumnWithTypeConverter createdAt = + GeneratedColumn('created_at', aliasedName, false, + type: DriftSqlType.int, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL') + .withConverter(ResendSessionMessages.$convertercreatedAt); @override - List get $columns => [key, timestamp]; + List get $columns => + [messageId, userId, sessionId, status, createdAt]; @override - String get aliasedName => _alias ?? 'offsets'; + String get aliasedName => _alias ?? 'resend_session_messages'; @override - String get actualTableName => 'offsets'; + String get actualTableName => 'resend_session_messages'; @override - VerificationContext validateIntegrity(Insertable instance, + VerificationContext validateIntegrity( + Insertable instance, {bool isInserting = false}) { final context = VerificationContext(); final data = instance.toColumns(true); - if (data.containsKey('key')) { - context.handle( - _keyMeta, key.isAcceptableOrUnknown(data['key']!, _keyMeta)); + if (data.containsKey('message_id')) { + context.handle(_messageIdMeta, + messageId.isAcceptableOrUnknown(data['message_id']!, _messageIdMeta)); } else if (isInserting) { - context.missing(_keyMeta); + context.missing(_messageIdMeta); } - if (data.containsKey('timestamp')) { - context.handle(_timestampMeta, - timestamp.isAcceptableOrUnknown(data['timestamp']!, _timestampMeta)); + if (data.containsKey('user_id')) { + context.handle(_userIdMeta, + userId.isAcceptableOrUnknown(data['user_id']!, _userIdMeta)); } else if (isInserting) { - context.missing(_timestampMeta); + context.missing(_userIdMeta); + } + if (data.containsKey('session_id')) { + context.handle(_sessionIdMeta, + sessionId.isAcceptableOrUnknown(data['session_id']!, _sessionIdMeta)); + } else if (isInserting) { + context.missing(_sessionIdMeta); + } + if (data.containsKey('status')) { + context.handle(_statusMeta, + status.isAcceptableOrUnknown(data['status']!, _statusMeta)); + } else if (isInserting) { + context.missing(_statusMeta); } + context.handle(_createdAtMeta, const VerificationResult.success()); return context; } @override - Set get $primaryKey => {key}; + Set get $primaryKey => {messageId, userId, sessionId}; @override - Offset map(Map data, {String? tablePrefix}) { + ResendSessionMessage map(Map data, {String? tablePrefix}) { final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; - return Offset( - key: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}key'])!, - timestamp: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}timestamp'])!, + return ResendSessionMessage( + messageId: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}message_id'])!, + userId: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}user_id'])!, + sessionId: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}session_id'])!, + status: attachedDatabase.typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}status'])!, + createdAt: ResendSessionMessages.$convertercreatedAt.fromSql( + attachedDatabase.typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}created_at'])!), ); } @override - Offsets createAlias(String alias) { - return Offsets(attachedDatabase, alias); + ResendSessionMessages createAlias(String alias) { + return ResendSessionMessages(attachedDatabase, alias); } + static TypeConverter $convertercreatedAt = + const MillisDateConverter(); @override - List get customConstraints => const ['PRIMARY KEY("key")']; + List get customConstraints => + const ['PRIMARY KEY(message_id, user_id, session_id)']; @override bool get dontWriteConstraints => true; } -class Offset extends DataClass implements Insertable { - final String key; - final String timestamp; - const Offset({required this.key, required this.timestamp}); +class ResendSessionMessage extends DataClass + implements Insertable { + final String messageId; + final String userId; + final String sessionId; + final int status; + final DateTime createdAt; + const ResendSessionMessage( + {required this.messageId, + required this.userId, + required this.sessionId, + required this.status, + required this.createdAt}); @override Map toColumns(bool nullToAbsent) { final map = {}; - map['key'] = Variable(key); - map['timestamp'] = Variable(timestamp); + map['message_id'] = Variable(messageId); + map['user_id'] = Variable(userId); + map['session_id'] = Variable(sessionId); + map['status'] = Variable(status); + { + final converter = ResendSessionMessages.$convertercreatedAt; + map['created_at'] = Variable(converter.toSql(createdAt)); + } return map; } - OffsetsCompanion toCompanion(bool nullToAbsent) { - return OffsetsCompanion( - key: Value(key), - timestamp: Value(timestamp), + ResendSessionMessagesCompanion toCompanion(bool nullToAbsent) { + return ResendSessionMessagesCompanion( + messageId: Value(messageId), + userId: Value(userId), + sessionId: Value(sessionId), + status: Value(status), + createdAt: Value(createdAt), ); } - factory Offset.fromJson(Map json, + factory ResendSessionMessage.fromJson(Map json, {ValueSerializer? serializer}) { serializer ??= driftRuntimeOptions.defaultSerializer; - return Offset( - key: serializer.fromJson(json['key']), - timestamp: serializer.fromJson(json['timestamp']), + return ResendSessionMessage( + messageId: serializer.fromJson(json['message_id']), + userId: serializer.fromJson(json['user_id']), + sessionId: serializer.fromJson(json['session_id']), + status: serializer.fromJson(json['status']), + createdAt: serializer.fromJson(json['created_at']), ); } @override Map toJson({ValueSerializer? serializer}) { serializer ??= driftRuntimeOptions.defaultSerializer; return { - 'key': serializer.toJson(key), - 'timestamp': serializer.toJson(timestamp), + 'message_id': serializer.toJson(messageId), + 'user_id': serializer.toJson(userId), + 'session_id': serializer.toJson(sessionId), + 'status': serializer.toJson(status), + 'created_at': serializer.toJson(createdAt), }; } - Offset copyWith({String? key, String? timestamp}) => Offset( - key: key ?? this.key, - timestamp: timestamp ?? this.timestamp, + ResendSessionMessage copyWith( + {String? messageId, + String? userId, + String? sessionId, + int? status, + DateTime? createdAt}) => + ResendSessionMessage( + messageId: messageId ?? this.messageId, + userId: userId ?? this.userId, + sessionId: sessionId ?? this.sessionId, + status: status ?? this.status, + createdAt: createdAt ?? this.createdAt, ); @override String toString() { - return (StringBuffer('Offset(') - ..write('key: $key, ') - ..write('timestamp: $timestamp') + return (StringBuffer('ResendSessionMessage(') + ..write('messageId: $messageId, ') + ..write('userId: $userId, ') + ..write('sessionId: $sessionId, ') + ..write('status: $status, ') + ..write('createdAt: $createdAt') ..write(')')) .toString(); } @override - int get hashCode => Object.hash(key, timestamp); + int get hashCode => + Object.hash(messageId, userId, sessionId, status, createdAt); @override bool operator ==(Object other) => identical(this, other) || - (other is Offset && - other.key == this.key && - other.timestamp == this.timestamp); + (other is ResendSessionMessage && + other.messageId == this.messageId && + other.userId == this.userId && + other.sessionId == this.sessionId && + other.status == this.status && + other.createdAt == this.createdAt); } -class OffsetsCompanion extends UpdateCompanion { - final Value key; - final Value timestamp; +class ResendSessionMessagesCompanion + extends UpdateCompanion { + final Value messageId; + final Value userId; + final Value sessionId; + final Value status; + final Value createdAt; final Value rowid; - const OffsetsCompanion({ - this.key = const Value.absent(), - this.timestamp = const Value.absent(), + const ResendSessionMessagesCompanion({ + this.messageId = const Value.absent(), + this.userId = const Value.absent(), + this.sessionId = const Value.absent(), + this.status = const Value.absent(), + this.createdAt = const Value.absent(), this.rowid = const Value.absent(), }); - OffsetsCompanion.insert({ - required String key, - required String timestamp, + ResendSessionMessagesCompanion.insert({ + required String messageId, + required String userId, + required String sessionId, + required int status, + required DateTime createdAt, this.rowid = const Value.absent(), - }) : key = Value(key), - timestamp = Value(timestamp); - static Insertable custom({ - Expression? key, - Expression? timestamp, + }) : messageId = Value(messageId), + userId = Value(userId), + sessionId = Value(sessionId), + status = Value(status), + createdAt = Value(createdAt); + static Insertable custom({ + Expression? messageId, + Expression? userId, + Expression? sessionId, + Expression? status, + Expression? createdAt, Expression? rowid, }) { return RawValuesInsertable({ - if (key != null) 'key': key, - if (timestamp != null) 'timestamp': timestamp, + if (messageId != null) 'message_id': messageId, + if (userId != null) 'user_id': userId, + if (sessionId != null) 'session_id': sessionId, + if (status != null) 'status': status, + if (createdAt != null) 'created_at': createdAt, if (rowid != null) 'rowid': rowid, }); } - OffsetsCompanion copyWith( - {Value? key, Value? timestamp, Value? rowid}) { - return OffsetsCompanion( - key: key ?? this.key, - timestamp: timestamp ?? this.timestamp, + ResendSessionMessagesCompanion copyWith( + {Value? messageId, + Value? userId, + Value? sessionId, + Value? status, + Value? createdAt, + Value? rowid}) { + return ResendSessionMessagesCompanion( + messageId: messageId ?? this.messageId, + userId: userId ?? this.userId, + sessionId: sessionId ?? this.sessionId, + status: status ?? this.status, + createdAt: createdAt ?? this.createdAt, rowid: rowid ?? this.rowid, ); } @@ -11070,11 +10047,21 @@ class OffsetsCompanion extends UpdateCompanion { @override Map toColumns(bool nullToAbsent) { final map = {}; - if (key.present) { - map['key'] = Variable(key.value); + if (messageId.present) { + map['message_id'] = Variable(messageId.value); } - if (timestamp.present) { - map['timestamp'] = Variable(timestamp.value); + if (userId.present) { + map['user_id'] = Variable(userId.value); + } + if (sessionId.present) { + map['session_id'] = Variable(sessionId.value); + } + if (status.present) { + map['status'] = Variable(status.value); + } + if (createdAt.present) { + final converter = ResendSessionMessages.$convertercreatedAt; + map['created_at'] = Variable(converter.toSql(createdAt.value)); } if (rowid.present) { map['rowid'] = Variable(rowid.value); @@ -11084,9 +10071,12 @@ class OffsetsCompanion extends UpdateCompanion { @override String toString() { - return (StringBuffer('OffsetsCompanion(') - ..write('key: $key, ') - ..write('timestamp: $timestamp, ') + return (StringBuffer('ResendSessionMessagesCompanion(') + ..write('messageId: $messageId, ') + ..write('userId: $userId, ') + ..write('sessionId: $sessionId, ') + ..write('status: $status, ') + ..write('createdAt: $createdAt, ') ..write('rowid: $rowid') ..write(')')) .toString(); @@ -11457,43 +10447,28 @@ class SentSessionSenderKeysCompanion } } -class TranscriptMessages extends Table - with TableInfo { +class StickerAlbums extends Table with TableInfo { @override final GeneratedDatabase attachedDatabase; final String? _alias; - TranscriptMessages(this.attachedDatabase, [this._alias]); - static const VerificationMeta _transcriptIdMeta = - const VerificationMeta('transcriptId'); - late final GeneratedColumn transcriptId = GeneratedColumn( - 'transcript_id', aliasedName, false, + StickerAlbums(this.attachedDatabase, [this._alias]); + static const VerificationMeta _albumIdMeta = + const VerificationMeta('albumId'); + late final GeneratedColumn albumId = GeneratedColumn( + 'album_id', aliasedName, false, type: DriftSqlType.string, requiredDuringInsert: true, $customConstraints: 'NOT NULL'); - static const VerificationMeta _messageIdMeta = - const VerificationMeta('messageId'); - late final GeneratedColumn messageId = GeneratedColumn( - 'message_id', aliasedName, false, + static const VerificationMeta _nameMeta = const VerificationMeta('name'); + late final GeneratedColumn name = GeneratedColumn( + 'name', aliasedName, false, type: DriftSqlType.string, requiredDuringInsert: true, $customConstraints: 'NOT NULL'); - static const VerificationMeta _userIdMeta = const VerificationMeta('userId'); - late final GeneratedColumn userId = GeneratedColumn( - 'user_id', aliasedName, true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: ''); - static const VerificationMeta _userFullNameMeta = - const VerificationMeta('userFullName'); - late final GeneratedColumn userFullName = GeneratedColumn( - 'user_full_name', aliasedName, true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: ''); - static const VerificationMeta _categoryMeta = - const VerificationMeta('category'); - late final GeneratedColumn category = GeneratedColumn( - 'category', aliasedName, false, + static const VerificationMeta _iconUrlMeta = + const VerificationMeta('iconUrl'); + late final GeneratedColumn iconUrl = GeneratedColumn( + 'icon_url', aliasedName, false, type: DriftSqlType.string, requiredDuringInsert: true, $customConstraints: 'NOT NULL'); @@ -11504,220 +10479,117 @@ class TranscriptMessages extends Table type: DriftSqlType.int, requiredDuringInsert: true, $customConstraints: 'NOT NULL') - .withConverter(TranscriptMessages.$convertercreatedAt); - static const VerificationMeta _contentMeta = - const VerificationMeta('content'); - late final GeneratedColumn content = GeneratedColumn( - 'content', aliasedName, true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: ''); - static const VerificationMeta _mediaUrlMeta = - const VerificationMeta('mediaUrl'); - late final GeneratedColumn mediaUrl = GeneratedColumn( - 'media_url', aliasedName, true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: ''); - static const VerificationMeta _mediaNameMeta = - const VerificationMeta('mediaName'); - late final GeneratedColumn mediaName = GeneratedColumn( - 'media_name', aliasedName, true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: ''); - static const VerificationMeta _mediaSizeMeta = - const VerificationMeta('mediaSize'); - late final GeneratedColumn mediaSize = GeneratedColumn( - 'media_size', aliasedName, true, - type: DriftSqlType.int, - requiredDuringInsert: false, - $customConstraints: ''); - static const VerificationMeta _mediaWidthMeta = - const VerificationMeta('mediaWidth'); - late final GeneratedColumn mediaWidth = GeneratedColumn( - 'media_width', aliasedName, true, - type: DriftSqlType.int, - requiredDuringInsert: false, - $customConstraints: ''); - static const VerificationMeta _mediaHeightMeta = - const VerificationMeta('mediaHeight'); - late final GeneratedColumn mediaHeight = GeneratedColumn( - 'media_height', aliasedName, true, + .withConverter(StickerAlbums.$convertercreatedAt); + static const VerificationMeta _updateAtMeta = + const VerificationMeta('updateAt'); + late final GeneratedColumnWithTypeConverter updateAt = + GeneratedColumn('update_at', aliasedName, false, + type: DriftSqlType.int, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL') + .withConverter(StickerAlbums.$converterupdateAt); + static const VerificationMeta _orderedAtMeta = + const VerificationMeta('orderedAt'); + late final GeneratedColumn orderedAt = GeneratedColumn( + 'ordered_at', aliasedName, false, type: DriftSqlType.int, requiredDuringInsert: false, - $customConstraints: ''); - static const VerificationMeta _mediaMimeTypeMeta = - const VerificationMeta('mediaMimeType'); - late final GeneratedColumn mediaMimeType = GeneratedColumn( - 'media_mime_type', aliasedName, true, + $customConstraints: 'NOT NULL DEFAULT 0', + defaultValue: const CustomExpression('0')); + static const VerificationMeta _userIdMeta = const VerificationMeta('userId'); + late final GeneratedColumn userId = GeneratedColumn( + 'user_id', aliasedName, false, type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: ''); - static const VerificationMeta _mediaDurationMeta = - const VerificationMeta('mediaDuration'); - late final GeneratedColumn mediaDuration = GeneratedColumn( - 'media_duration', aliasedName, true, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL'); + static const VerificationMeta _categoryMeta = + const VerificationMeta('category'); + late final GeneratedColumn category = GeneratedColumn( + 'category', aliasedName, false, type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: ''); - static const VerificationMeta _mediaStatusMeta = - const VerificationMeta('mediaStatus'); - late final GeneratedColumnWithTypeConverter - mediaStatus = GeneratedColumn('media_status', aliasedName, true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: '') - .withConverter( - TranscriptMessages.$convertermediaStatus); - static const VerificationMeta _mediaWaveformMeta = - const VerificationMeta('mediaWaveform'); - late final GeneratedColumn mediaWaveform = GeneratedColumn( - 'media_waveform', aliasedName, true, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL'); + static const VerificationMeta _descriptionMeta = + const VerificationMeta('description'); + late final GeneratedColumn description = GeneratedColumn( + 'description', aliasedName, false, type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: ''); - static const VerificationMeta _thumbImageMeta = - const VerificationMeta('thumbImage'); - late final GeneratedColumn thumbImage = GeneratedColumn( - 'thumb_image', aliasedName, true, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL'); + static const VerificationMeta _bannerMeta = const VerificationMeta('banner'); + late final GeneratedColumn banner = GeneratedColumn( + 'banner', aliasedName, true, type: DriftSqlType.string, requiredDuringInsert: false, $customConstraints: ''); - static const VerificationMeta _thumbUrlMeta = - const VerificationMeta('thumbUrl'); - late final GeneratedColumn thumbUrl = GeneratedColumn( - 'thumb_url', aliasedName, true, - type: DriftSqlType.string, + static const VerificationMeta _addedMeta = const VerificationMeta('added'); + late final GeneratedColumn added = GeneratedColumn( + 'added', aliasedName, true, + type: DriftSqlType.bool, requiredDuringInsert: false, - $customConstraints: ''); - static const VerificationMeta _mediaKeyMeta = - const VerificationMeta('mediaKey'); - late final GeneratedColumn mediaKey = GeneratedColumn( - 'media_key', aliasedName, true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: ''); - static const VerificationMeta _mediaDigestMeta = - const VerificationMeta('mediaDigest'); - late final GeneratedColumn mediaDigest = GeneratedColumn( - 'media_digest', aliasedName, true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: ''); - static const VerificationMeta _mediaCreatedAtMeta = - const VerificationMeta('mediaCreatedAt'); - late final GeneratedColumnWithTypeConverter mediaCreatedAt = - GeneratedColumn('media_created_at', aliasedName, true, - type: DriftSqlType.int, - requiredDuringInsert: false, - $customConstraints: '') - .withConverter( - TranscriptMessages.$convertermediaCreatedAtn); - static const VerificationMeta _stickerIdMeta = - const VerificationMeta('stickerId'); - late final GeneratedColumn stickerId = GeneratedColumn( - 'sticker_id', aliasedName, true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: ''); - static const VerificationMeta _sharedUserIdMeta = - const VerificationMeta('sharedUserId'); - late final GeneratedColumn sharedUserId = GeneratedColumn( - 'shared_user_id', aliasedName, true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: ''); - static const VerificationMeta _mentionsMeta = - const VerificationMeta('mentions'); - late final GeneratedColumn mentions = GeneratedColumn( - 'mentions', aliasedName, true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: ''); - static const VerificationMeta _quoteIdMeta = - const VerificationMeta('quoteId'); - late final GeneratedColumn quoteId = GeneratedColumn( - 'quote_id', aliasedName, true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: ''); - static const VerificationMeta _quoteContentMeta = - const VerificationMeta('quoteContent'); - late final GeneratedColumn quoteContent = GeneratedColumn( - 'quote_content', aliasedName, true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: ''); - static const VerificationMeta _captionMeta = - const VerificationMeta('caption'); - late final GeneratedColumn caption = GeneratedColumn( - 'caption', aliasedName, true, - type: DriftSqlType.string, + $customConstraints: 'DEFAULT FALSE', + defaultValue: const CustomExpression('FALSE')); + static const VerificationMeta _isVerifiedMeta = + const VerificationMeta('isVerified'); + late final GeneratedColumn isVerified = GeneratedColumn( + 'is_verified', aliasedName, false, + type: DriftSqlType.bool, requiredDuringInsert: false, - $customConstraints: ''); + $customConstraints: 'NOT NULL DEFAULT FALSE', + defaultValue: const CustomExpression('FALSE')); @override List get $columns => [ - transcriptId, - messageId, + albumId, + name, + iconUrl, + createdAt, + updateAt, + orderedAt, userId, - userFullName, category, - createdAt, - content, - mediaUrl, - mediaName, - mediaSize, - mediaWidth, - mediaHeight, - mediaMimeType, - mediaDuration, - mediaStatus, - mediaWaveform, - thumbImage, - thumbUrl, - mediaKey, - mediaDigest, - mediaCreatedAt, - stickerId, - sharedUserId, - mentions, - quoteId, - quoteContent, - caption + description, + banner, + added, + isVerified ]; @override - String get aliasedName => _alias ?? 'transcript_messages'; + String get aliasedName => _alias ?? 'sticker_albums'; @override - String get actualTableName => 'transcript_messages'; + String get actualTableName => 'sticker_albums'; @override - VerificationContext validateIntegrity(Insertable instance, + VerificationContext validateIntegrity(Insertable instance, {bool isInserting = false}) { final context = VerificationContext(); final data = instance.toColumns(true); - if (data.containsKey('transcript_id')) { + if (data.containsKey('album_id')) { + context.handle(_albumIdMeta, + albumId.isAcceptableOrUnknown(data['album_id']!, _albumIdMeta)); + } else if (isInserting) { + context.missing(_albumIdMeta); + } + if (data.containsKey('name')) { context.handle( - _transcriptIdMeta, - transcriptId.isAcceptableOrUnknown( - data['transcript_id']!, _transcriptIdMeta)); + _nameMeta, name.isAcceptableOrUnknown(data['name']!, _nameMeta)); } else if (isInserting) { - context.missing(_transcriptIdMeta); + context.missing(_nameMeta); } - if (data.containsKey('message_id')) { - context.handle(_messageIdMeta, - messageId.isAcceptableOrUnknown(data['message_id']!, _messageIdMeta)); + if (data.containsKey('icon_url')) { + context.handle(_iconUrlMeta, + iconUrl.isAcceptableOrUnknown(data['icon_url']!, _iconUrlMeta)); } else if (isInserting) { - context.missing(_messageIdMeta); + context.missing(_iconUrlMeta); + } + context.handle(_createdAtMeta, const VerificationResult.success()); + context.handle(_updateAtMeta, const VerificationResult.success()); + if (data.containsKey('ordered_at')) { + context.handle(_orderedAtMeta, + orderedAt.isAcceptableOrUnknown(data['ordered_at']!, _orderedAtMeta)); } if (data.containsKey('user_id')) { context.handle(_userIdMeta, userId.isAcceptableOrUnknown(data['user_id']!, _userIdMeta)); - } - if (data.containsKey('user_full_name')) { - context.handle( - _userFullNameMeta, - userFullName.isAcceptableOrUnknown( - data['user_full_name']!, _userFullNameMeta)); + } else if (isInserting) { + context.missing(_userIdMeta); } if (data.containsKey('category')) { context.handle(_categoryMeta, @@ -11725,849 +10597,368 @@ class TranscriptMessages extends Table } else if (isInserting) { context.missing(_categoryMeta); } - context.handle(_createdAtMeta, const VerificationResult.success()); - if (data.containsKey('content')) { - context.handle(_contentMeta, - content.isAcceptableOrUnknown(data['content']!, _contentMeta)); - } - if (data.containsKey('media_url')) { - context.handle(_mediaUrlMeta, - mediaUrl.isAcceptableOrUnknown(data['media_url']!, _mediaUrlMeta)); - } - if (data.containsKey('media_name')) { - context.handle(_mediaNameMeta, - mediaName.isAcceptableOrUnknown(data['media_name']!, _mediaNameMeta)); - } - if (data.containsKey('media_size')) { - context.handle(_mediaSizeMeta, - mediaSize.isAcceptableOrUnknown(data['media_size']!, _mediaSizeMeta)); - } - if (data.containsKey('media_width')) { - context.handle( - _mediaWidthMeta, - mediaWidth.isAcceptableOrUnknown( - data['media_width']!, _mediaWidthMeta)); - } - if (data.containsKey('media_height')) { - context.handle( - _mediaHeightMeta, - mediaHeight.isAcceptableOrUnknown( - data['media_height']!, _mediaHeightMeta)); - } - if (data.containsKey('media_mime_type')) { - context.handle( - _mediaMimeTypeMeta, - mediaMimeType.isAcceptableOrUnknown( - data['media_mime_type']!, _mediaMimeTypeMeta)); - } - if (data.containsKey('media_duration')) { - context.handle( - _mediaDurationMeta, - mediaDuration.isAcceptableOrUnknown( - data['media_duration']!, _mediaDurationMeta)); - } - context.handle(_mediaStatusMeta, const VerificationResult.success()); - if (data.containsKey('media_waveform')) { - context.handle( - _mediaWaveformMeta, - mediaWaveform.isAcceptableOrUnknown( - data['media_waveform']!, _mediaWaveformMeta)); - } - if (data.containsKey('thumb_image')) { - context.handle( - _thumbImageMeta, - thumbImage.isAcceptableOrUnknown( - data['thumb_image']!, _thumbImageMeta)); - } - if (data.containsKey('thumb_url')) { - context.handle(_thumbUrlMeta, - thumbUrl.isAcceptableOrUnknown(data['thumb_url']!, _thumbUrlMeta)); - } - if (data.containsKey('media_key')) { - context.handle(_mediaKeyMeta, - mediaKey.isAcceptableOrUnknown(data['media_key']!, _mediaKeyMeta)); - } - if (data.containsKey('media_digest')) { + if (data.containsKey('description')) { context.handle( - _mediaDigestMeta, - mediaDigest.isAcceptableOrUnknown( - data['media_digest']!, _mediaDigestMeta)); + _descriptionMeta, + description.isAcceptableOrUnknown( + data['description']!, _descriptionMeta)); + } else if (isInserting) { + context.missing(_descriptionMeta); } - context.handle(_mediaCreatedAtMeta, const VerificationResult.success()); - if (data.containsKey('sticker_id')) { - context.handle(_stickerIdMeta, - stickerId.isAcceptableOrUnknown(data['sticker_id']!, _stickerIdMeta)); + if (data.containsKey('banner')) { + context.handle(_bannerMeta, + banner.isAcceptableOrUnknown(data['banner']!, _bannerMeta)); } - if (data.containsKey('shared_user_id')) { + if (data.containsKey('added')) { context.handle( - _sharedUserIdMeta, - sharedUserId.isAcceptableOrUnknown( - data['shared_user_id']!, _sharedUserIdMeta)); - } - if (data.containsKey('mentions')) { - context.handle(_mentionsMeta, - mentions.isAcceptableOrUnknown(data['mentions']!, _mentionsMeta)); - } - if (data.containsKey('quote_id')) { - context.handle(_quoteIdMeta, - quoteId.isAcceptableOrUnknown(data['quote_id']!, _quoteIdMeta)); + _addedMeta, added.isAcceptableOrUnknown(data['added']!, _addedMeta)); } - if (data.containsKey('quote_content')) { + if (data.containsKey('is_verified')) { context.handle( - _quoteContentMeta, - quoteContent.isAcceptableOrUnknown( - data['quote_content']!, _quoteContentMeta)); - } - if (data.containsKey('caption')) { - context.handle(_captionMeta, - caption.isAcceptableOrUnknown(data['caption']!, _captionMeta)); + _isVerifiedMeta, + isVerified.isAcceptableOrUnknown( + data['is_verified']!, _isVerifiedMeta)); } return context; } @override - Set get $primaryKey => {transcriptId, messageId}; + Set get $primaryKey => {albumId}; @override - TranscriptMessage map(Map data, {String? tablePrefix}) { + StickerAlbum map(Map data, {String? tablePrefix}) { final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; - return TranscriptMessage( - transcriptId: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}transcript_id'])!, - messageId: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}message_id'])!, + return StickerAlbum( + albumId: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}album_id'])!, + name: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}name'])!, + iconUrl: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}icon_url'])!, + createdAt: StickerAlbums.$convertercreatedAt.fromSql(attachedDatabase + .typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}created_at'])!), + updateAt: StickerAlbums.$converterupdateAt.fromSql(attachedDatabase + .typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}update_at'])!), + orderedAt: attachedDatabase.typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}ordered_at'])!, userId: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}user_id']), - userFullName: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}user_full_name']), + .read(DriftSqlType.string, data['${effectivePrefix}user_id'])!, category: attachedDatabase.typeMapping .read(DriftSqlType.string, data['${effectivePrefix}category'])!, - createdAt: TranscriptMessages.$convertercreatedAt.fromSql(attachedDatabase - .typeMapping - .read(DriftSqlType.int, data['${effectivePrefix}created_at'])!), - content: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}content']), - mediaUrl: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}media_url']), - mediaName: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}media_name']), - mediaSize: attachedDatabase.typeMapping - .read(DriftSqlType.int, data['${effectivePrefix}media_size']), - mediaWidth: attachedDatabase.typeMapping - .read(DriftSqlType.int, data['${effectivePrefix}media_width']), - mediaHeight: attachedDatabase.typeMapping - .read(DriftSqlType.int, data['${effectivePrefix}media_height']), - mediaMimeType: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}media_mime_type']), - mediaDuration: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}media_duration']), - mediaStatus: TranscriptMessages.$convertermediaStatus.fromSql( - attachedDatabase.typeMapping.read( - DriftSqlType.string, data['${effectivePrefix}media_status'])), - mediaWaveform: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}media_waveform']), - thumbImage: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}thumb_image']), - thumbUrl: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}thumb_url']), - mediaKey: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}media_key']), - mediaDigest: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}media_digest']), - mediaCreatedAt: TranscriptMessages.$convertermediaCreatedAtn.fromSql( - attachedDatabase.typeMapping.read( - DriftSqlType.int, data['${effectivePrefix}media_created_at'])), - stickerId: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}sticker_id']), - sharedUserId: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}shared_user_id']), - mentions: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}mentions']), - quoteId: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}quote_id']), - quoteContent: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}quote_content']), - caption: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}caption']), + description: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}description'])!, + banner: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}banner']), + added: attachedDatabase.typeMapping + .read(DriftSqlType.bool, data['${effectivePrefix}added']), + isVerified: attachedDatabase.typeMapping + .read(DriftSqlType.bool, data['${effectivePrefix}is_verified'])!, ); } @override - TranscriptMessages createAlias(String alias) { - return TranscriptMessages(attachedDatabase, alias); + StickerAlbums createAlias(String alias) { + return StickerAlbums(attachedDatabase, alias); } static TypeConverter $convertercreatedAt = const MillisDateConverter(); - static TypeConverter $convertermediaStatus = - const MediaStatusTypeConverter(); - static TypeConverter $convertermediaCreatedAt = + static TypeConverter $converterupdateAt = const MillisDateConverter(); - static TypeConverter $convertermediaCreatedAtn = - NullAwareTypeConverter.wrap($convertermediaCreatedAt); @override - List get customConstraints => - const ['PRIMARY KEY(transcript_id, message_id)']; + List get customConstraints => const ['PRIMARY KEY(album_id)']; @override bool get dontWriteConstraints => true; } -class TranscriptMessage extends DataClass - implements Insertable { - final String transcriptId; - final String messageId; - final String? userId; - final String? userFullName; - final String category; +class StickerAlbum extends DataClass implements Insertable { + final String albumId; + final String name; + final String iconUrl; final DateTime createdAt; - final String? content; - final String? mediaUrl; - final String? mediaName; - final int? mediaSize; - final int? mediaWidth; - final int? mediaHeight; - final String? mediaMimeType; - final String? mediaDuration; - final MediaStatus? mediaStatus; - final String? mediaWaveform; - final String? thumbImage; - final String? thumbUrl; - final String? mediaKey; - final String? mediaDigest; - final DateTime? mediaCreatedAt; - final String? stickerId; - final String? sharedUserId; - final String? mentions; - final String? quoteId; - final String? quoteContent; - final String? caption; - const TranscriptMessage( - {required this.transcriptId, - required this.messageId, - this.userId, - this.userFullName, - required this.category, + final DateTime updateAt; + final int orderedAt; + final String userId; + final String category; + final String description; + final String? banner; + final bool? added; + final bool isVerified; + const StickerAlbum( + {required this.albumId, + required this.name, + required this.iconUrl, required this.createdAt, - this.content, - this.mediaUrl, - this.mediaName, - this.mediaSize, - this.mediaWidth, - this.mediaHeight, - this.mediaMimeType, - this.mediaDuration, - this.mediaStatus, - this.mediaWaveform, - this.thumbImage, - this.thumbUrl, - this.mediaKey, - this.mediaDigest, - this.mediaCreatedAt, - this.stickerId, - this.sharedUserId, - this.mentions, - this.quoteId, - this.quoteContent, - this.caption}); + required this.updateAt, + required this.orderedAt, + required this.userId, + required this.category, + required this.description, + this.banner, + this.added, + required this.isVerified}); @override Map toColumns(bool nullToAbsent) { final map = {}; - map['transcript_id'] = Variable(transcriptId); - map['message_id'] = Variable(messageId); - if (!nullToAbsent || userId != null) { - map['user_id'] = Variable(userId); - } - if (!nullToAbsent || userFullName != null) { - map['user_full_name'] = Variable(userFullName); - } - map['category'] = Variable(category); + map['album_id'] = Variable(albumId); + map['name'] = Variable(name); + map['icon_url'] = Variable(iconUrl); { - final converter = TranscriptMessages.$convertercreatedAt; + final converter = StickerAlbums.$convertercreatedAt; map['created_at'] = Variable(converter.toSql(createdAt)); } - if (!nullToAbsent || content != null) { - map['content'] = Variable(content); - } - if (!nullToAbsent || mediaUrl != null) { - map['media_url'] = Variable(mediaUrl); - } - if (!nullToAbsent || mediaName != null) { - map['media_name'] = Variable(mediaName); - } - if (!nullToAbsent || mediaSize != null) { - map['media_size'] = Variable(mediaSize); - } - if (!nullToAbsent || mediaWidth != null) { - map['media_width'] = Variable(mediaWidth); - } - if (!nullToAbsent || mediaHeight != null) { - map['media_height'] = Variable(mediaHeight); - } - if (!nullToAbsent || mediaMimeType != null) { - map['media_mime_type'] = Variable(mediaMimeType); - } - if (!nullToAbsent || mediaDuration != null) { - map['media_duration'] = Variable(mediaDuration); - } - if (!nullToAbsent || mediaStatus != null) { - final converter = TranscriptMessages.$convertermediaStatus; - map['media_status'] = Variable(converter.toSql(mediaStatus)); - } - if (!nullToAbsent || mediaWaveform != null) { - map['media_waveform'] = Variable(mediaWaveform); - } - if (!nullToAbsent || thumbImage != null) { - map['thumb_image'] = Variable(thumbImage); - } - if (!nullToAbsent || thumbUrl != null) { - map['thumb_url'] = Variable(thumbUrl); - } - if (!nullToAbsent || mediaKey != null) { - map['media_key'] = Variable(mediaKey); - } - if (!nullToAbsent || mediaDigest != null) { - map['media_digest'] = Variable(mediaDigest); - } - if (!nullToAbsent || mediaCreatedAt != null) { - final converter = TranscriptMessages.$convertermediaCreatedAtn; - map['media_created_at'] = Variable(converter.toSql(mediaCreatedAt)); - } - if (!nullToAbsent || stickerId != null) { - map['sticker_id'] = Variable(stickerId); - } - if (!nullToAbsent || sharedUserId != null) { - map['shared_user_id'] = Variable(sharedUserId); - } - if (!nullToAbsent || mentions != null) { - map['mentions'] = Variable(mentions); + { + final converter = StickerAlbums.$converterupdateAt; + map['update_at'] = Variable(converter.toSql(updateAt)); } - if (!nullToAbsent || quoteId != null) { - map['quote_id'] = Variable(quoteId); + map['ordered_at'] = Variable(orderedAt); + map['user_id'] = Variable(userId); + map['category'] = Variable(category); + map['description'] = Variable(description); + if (!nullToAbsent || banner != null) { + map['banner'] = Variable(banner); } - if (!nullToAbsent || quoteContent != null) { - map['quote_content'] = Variable(quoteContent); - } - if (!nullToAbsent || caption != null) { - map['caption'] = Variable(caption); + if (!nullToAbsent || added != null) { + map['added'] = Variable(added); } + map['is_verified'] = Variable(isVerified); return map; } - TranscriptMessagesCompanion toCompanion(bool nullToAbsent) { - return TranscriptMessagesCompanion( - transcriptId: Value(transcriptId), - messageId: Value(messageId), - userId: - userId == null && nullToAbsent ? const Value.absent() : Value(userId), - userFullName: userFullName == null && nullToAbsent - ? const Value.absent() - : Value(userFullName), - category: Value(category), + StickerAlbumsCompanion toCompanion(bool nullToAbsent) { + return StickerAlbumsCompanion( + albumId: Value(albumId), + name: Value(name), + iconUrl: Value(iconUrl), createdAt: Value(createdAt), - content: content == null && nullToAbsent - ? const Value.absent() - : Value(content), - mediaUrl: mediaUrl == null && nullToAbsent - ? const Value.absent() - : Value(mediaUrl), - mediaName: mediaName == null && nullToAbsent - ? const Value.absent() - : Value(mediaName), - mediaSize: mediaSize == null && nullToAbsent - ? const Value.absent() - : Value(mediaSize), - mediaWidth: mediaWidth == null && nullToAbsent - ? const Value.absent() - : Value(mediaWidth), - mediaHeight: mediaHeight == null && nullToAbsent - ? const Value.absent() - : Value(mediaHeight), - mediaMimeType: mediaMimeType == null && nullToAbsent - ? const Value.absent() - : Value(mediaMimeType), - mediaDuration: mediaDuration == null && nullToAbsent - ? const Value.absent() - : Value(mediaDuration), - mediaStatus: mediaStatus == null && nullToAbsent - ? const Value.absent() - : Value(mediaStatus), - mediaWaveform: mediaWaveform == null && nullToAbsent - ? const Value.absent() - : Value(mediaWaveform), - thumbImage: thumbImage == null && nullToAbsent - ? const Value.absent() - : Value(thumbImage), - thumbUrl: thumbUrl == null && nullToAbsent - ? const Value.absent() - : Value(thumbUrl), - mediaKey: mediaKey == null && nullToAbsent - ? const Value.absent() - : Value(mediaKey), - mediaDigest: mediaDigest == null && nullToAbsent - ? const Value.absent() - : Value(mediaDigest), - mediaCreatedAt: mediaCreatedAt == null && nullToAbsent - ? const Value.absent() - : Value(mediaCreatedAt), - stickerId: stickerId == null && nullToAbsent - ? const Value.absent() - : Value(stickerId), - sharedUserId: sharedUserId == null && nullToAbsent - ? const Value.absent() - : Value(sharedUserId), - mentions: mentions == null && nullToAbsent - ? const Value.absent() - : Value(mentions), - quoteId: quoteId == null && nullToAbsent - ? const Value.absent() - : Value(quoteId), - quoteContent: quoteContent == null && nullToAbsent - ? const Value.absent() - : Value(quoteContent), - caption: caption == null && nullToAbsent - ? const Value.absent() - : Value(caption), + updateAt: Value(updateAt), + orderedAt: Value(orderedAt), + userId: Value(userId), + category: Value(category), + description: Value(description), + banner: + banner == null && nullToAbsent ? const Value.absent() : Value(banner), + added: + added == null && nullToAbsent ? const Value.absent() : Value(added), + isVerified: Value(isVerified), ); } - factory TranscriptMessage.fromJson(Map json, + factory StickerAlbum.fromJson(Map json, {ValueSerializer? serializer}) { serializer ??= driftRuntimeOptions.defaultSerializer; - return TranscriptMessage( - transcriptId: serializer.fromJson(json['transcript_id']), - messageId: serializer.fromJson(json['message_id']), - userId: serializer.fromJson(json['user_id']), - userFullName: serializer.fromJson(json['user_full_name']), - category: serializer.fromJson(json['category']), + return StickerAlbum( + albumId: serializer.fromJson(json['album_id']), + name: serializer.fromJson(json['name']), + iconUrl: serializer.fromJson(json['icon_url']), createdAt: serializer.fromJson(json['created_at']), - content: serializer.fromJson(json['content']), - mediaUrl: serializer.fromJson(json['media_url']), - mediaName: serializer.fromJson(json['media_name']), - mediaSize: serializer.fromJson(json['media_size']), - mediaWidth: serializer.fromJson(json['media_width']), - mediaHeight: serializer.fromJson(json['media_height']), - mediaMimeType: serializer.fromJson(json['media_mime_type']), - mediaDuration: serializer.fromJson(json['media_duration']), - mediaStatus: serializer.fromJson(json['media_status']), - mediaWaveform: serializer.fromJson(json['media_waveform']), - thumbImage: serializer.fromJson(json['thumb_image']), - thumbUrl: serializer.fromJson(json['thumb_url']), - mediaKey: serializer.fromJson(json['media_key']), - mediaDigest: serializer.fromJson(json['media_digest']), - mediaCreatedAt: serializer.fromJson(json['media_created_at']), - stickerId: serializer.fromJson(json['sticker_id']), - sharedUserId: serializer.fromJson(json['shared_user_id']), - mentions: serializer.fromJson(json['mentions']), - quoteId: serializer.fromJson(json['quote_id']), - quoteContent: serializer.fromJson(json['quote_content']), - caption: serializer.fromJson(json['caption']), + updateAt: serializer.fromJson(json['update_at']), + orderedAt: serializer.fromJson(json['ordered_at']), + userId: serializer.fromJson(json['user_id']), + category: serializer.fromJson(json['category']), + description: serializer.fromJson(json['description']), + banner: serializer.fromJson(json['banner']), + added: serializer.fromJson(json['added']), + isVerified: serializer.fromJson(json['is_verified']), ); } @override Map toJson({ValueSerializer? serializer}) { serializer ??= driftRuntimeOptions.defaultSerializer; return { - 'transcript_id': serializer.toJson(transcriptId), - 'message_id': serializer.toJson(messageId), - 'user_id': serializer.toJson(userId), - 'user_full_name': serializer.toJson(userFullName), - 'category': serializer.toJson(category), + 'album_id': serializer.toJson(albumId), + 'name': serializer.toJson(name), + 'icon_url': serializer.toJson(iconUrl), 'created_at': serializer.toJson(createdAt), - 'content': serializer.toJson(content), - 'media_url': serializer.toJson(mediaUrl), - 'media_name': serializer.toJson(mediaName), - 'media_size': serializer.toJson(mediaSize), - 'media_width': serializer.toJson(mediaWidth), - 'media_height': serializer.toJson(mediaHeight), - 'media_mime_type': serializer.toJson(mediaMimeType), - 'media_duration': serializer.toJson(mediaDuration), - 'media_status': serializer.toJson(mediaStatus), - 'media_waveform': serializer.toJson(mediaWaveform), - 'thumb_image': serializer.toJson(thumbImage), - 'thumb_url': serializer.toJson(thumbUrl), - 'media_key': serializer.toJson(mediaKey), - 'media_digest': serializer.toJson(mediaDigest), - 'media_created_at': serializer.toJson(mediaCreatedAt), - 'sticker_id': serializer.toJson(stickerId), - 'shared_user_id': serializer.toJson(sharedUserId), - 'mentions': serializer.toJson(mentions), - 'quote_id': serializer.toJson(quoteId), - 'quote_content': serializer.toJson(quoteContent), - 'caption': serializer.toJson(caption), + 'update_at': serializer.toJson(updateAt), + 'ordered_at': serializer.toJson(orderedAt), + 'user_id': serializer.toJson(userId), + 'category': serializer.toJson(category), + 'description': serializer.toJson(description), + 'banner': serializer.toJson(banner), + 'added': serializer.toJson(added), + 'is_verified': serializer.toJson(isVerified), }; } - TranscriptMessage copyWith( - {String? transcriptId, - String? messageId, - Value userId = const Value.absent(), - Value userFullName = const Value.absent(), - String? category, + StickerAlbum copyWith( + {String? albumId, + String? name, + String? iconUrl, DateTime? createdAt, - Value content = const Value.absent(), - Value mediaUrl = const Value.absent(), - Value mediaName = const Value.absent(), - Value mediaSize = const Value.absent(), - Value mediaWidth = const Value.absent(), - Value mediaHeight = const Value.absent(), - Value mediaMimeType = const Value.absent(), - Value mediaDuration = const Value.absent(), - Value mediaStatus = const Value.absent(), - Value mediaWaveform = const Value.absent(), - Value thumbImage = const Value.absent(), - Value thumbUrl = const Value.absent(), - Value mediaKey = const Value.absent(), - Value mediaDigest = const Value.absent(), - Value mediaCreatedAt = const Value.absent(), - Value stickerId = const Value.absent(), - Value sharedUserId = const Value.absent(), - Value mentions = const Value.absent(), - Value quoteId = const Value.absent(), - Value quoteContent = const Value.absent(), - Value caption = const Value.absent()}) => - TranscriptMessage( - transcriptId: transcriptId ?? this.transcriptId, - messageId: messageId ?? this.messageId, - userId: userId.present ? userId.value : this.userId, - userFullName: - userFullName.present ? userFullName.value : this.userFullName, - category: category ?? this.category, + DateTime? updateAt, + int? orderedAt, + String? userId, + String? category, + String? description, + Value banner = const Value.absent(), + Value added = const Value.absent(), + bool? isVerified}) => + StickerAlbum( + albumId: albumId ?? this.albumId, + name: name ?? this.name, + iconUrl: iconUrl ?? this.iconUrl, createdAt: createdAt ?? this.createdAt, - content: content.present ? content.value : this.content, - mediaUrl: mediaUrl.present ? mediaUrl.value : this.mediaUrl, - mediaName: mediaName.present ? mediaName.value : this.mediaName, - mediaSize: mediaSize.present ? mediaSize.value : this.mediaSize, - mediaWidth: mediaWidth.present ? mediaWidth.value : this.mediaWidth, - mediaHeight: mediaHeight.present ? mediaHeight.value : this.mediaHeight, - mediaMimeType: - mediaMimeType.present ? mediaMimeType.value : this.mediaMimeType, - mediaDuration: - mediaDuration.present ? mediaDuration.value : this.mediaDuration, - mediaStatus: mediaStatus.present ? mediaStatus.value : this.mediaStatus, - mediaWaveform: - mediaWaveform.present ? mediaWaveform.value : this.mediaWaveform, - thumbImage: thumbImage.present ? thumbImage.value : this.thumbImage, - thumbUrl: thumbUrl.present ? thumbUrl.value : this.thumbUrl, - mediaKey: mediaKey.present ? mediaKey.value : this.mediaKey, - mediaDigest: mediaDigest.present ? mediaDigest.value : this.mediaDigest, - mediaCreatedAt: - mediaCreatedAt.present ? mediaCreatedAt.value : this.mediaCreatedAt, - stickerId: stickerId.present ? stickerId.value : this.stickerId, - sharedUserId: - sharedUserId.present ? sharedUserId.value : this.sharedUserId, - mentions: mentions.present ? mentions.value : this.mentions, - quoteId: quoteId.present ? quoteId.value : this.quoteId, - quoteContent: - quoteContent.present ? quoteContent.value : this.quoteContent, - caption: caption.present ? caption.value : this.caption, + updateAt: updateAt ?? this.updateAt, + orderedAt: orderedAt ?? this.orderedAt, + userId: userId ?? this.userId, + category: category ?? this.category, + description: description ?? this.description, + banner: banner.present ? banner.value : this.banner, + added: added.present ? added.value : this.added, + isVerified: isVerified ?? this.isVerified, ); @override String toString() { - return (StringBuffer('TranscriptMessage(') - ..write('transcriptId: $transcriptId, ') - ..write('messageId: $messageId, ') + return (StringBuffer('StickerAlbum(') + ..write('albumId: $albumId, ') + ..write('name: $name, ') + ..write('iconUrl: $iconUrl, ') + ..write('createdAt: $createdAt, ') + ..write('updateAt: $updateAt, ') + ..write('orderedAt: $orderedAt, ') ..write('userId: $userId, ') - ..write('userFullName: $userFullName, ') ..write('category: $category, ') - ..write('createdAt: $createdAt, ') - ..write('content: $content, ') - ..write('mediaUrl: $mediaUrl, ') - ..write('mediaName: $mediaName, ') - ..write('mediaSize: $mediaSize, ') - ..write('mediaWidth: $mediaWidth, ') - ..write('mediaHeight: $mediaHeight, ') - ..write('mediaMimeType: $mediaMimeType, ') - ..write('mediaDuration: $mediaDuration, ') - ..write('mediaStatus: $mediaStatus, ') - ..write('mediaWaveform: $mediaWaveform, ') - ..write('thumbImage: $thumbImage, ') - ..write('thumbUrl: $thumbUrl, ') - ..write('mediaKey: $mediaKey, ') - ..write('mediaDigest: $mediaDigest, ') - ..write('mediaCreatedAt: $mediaCreatedAt, ') - ..write('stickerId: $stickerId, ') - ..write('sharedUserId: $sharedUserId, ') - ..write('mentions: $mentions, ') - ..write('quoteId: $quoteId, ') - ..write('quoteContent: $quoteContent, ') - ..write('caption: $caption') + ..write('description: $description, ') + ..write('banner: $banner, ') + ..write('added: $added, ') + ..write('isVerified: $isVerified') ..write(')')) .toString(); } @override - int get hashCode => Object.hashAll([ - transcriptId, - messageId, - userId, - userFullName, - category, - createdAt, - content, - mediaUrl, - mediaName, - mediaSize, - mediaWidth, - mediaHeight, - mediaMimeType, - mediaDuration, - mediaStatus, - mediaWaveform, - thumbImage, - thumbUrl, - mediaKey, - mediaDigest, - mediaCreatedAt, - stickerId, - sharedUserId, - mentions, - quoteId, - quoteContent, - caption - ]); + int get hashCode => Object.hash(albumId, name, iconUrl, createdAt, updateAt, + orderedAt, userId, category, description, banner, added, isVerified); @override bool operator ==(Object other) => identical(this, other) || - (other is TranscriptMessage && - other.transcriptId == this.transcriptId && - other.messageId == this.messageId && + (other is StickerAlbum && + other.albumId == this.albumId && + other.name == this.name && + other.iconUrl == this.iconUrl && + other.createdAt == this.createdAt && + other.updateAt == this.updateAt && + other.orderedAt == this.orderedAt && other.userId == this.userId && - other.userFullName == this.userFullName && other.category == this.category && - other.createdAt == this.createdAt && - other.content == this.content && - other.mediaUrl == this.mediaUrl && - other.mediaName == this.mediaName && - other.mediaSize == this.mediaSize && - other.mediaWidth == this.mediaWidth && - other.mediaHeight == this.mediaHeight && - other.mediaMimeType == this.mediaMimeType && - other.mediaDuration == this.mediaDuration && - other.mediaStatus == this.mediaStatus && - other.mediaWaveform == this.mediaWaveform && - other.thumbImage == this.thumbImage && - other.thumbUrl == this.thumbUrl && - other.mediaKey == this.mediaKey && - other.mediaDigest == this.mediaDigest && - other.mediaCreatedAt == this.mediaCreatedAt && - other.stickerId == this.stickerId && - other.sharedUserId == this.sharedUserId && - other.mentions == this.mentions && - other.quoteId == this.quoteId && - other.quoteContent == this.quoteContent && - other.caption == this.caption); + other.description == this.description && + other.banner == this.banner && + other.added == this.added && + other.isVerified == this.isVerified); } -class TranscriptMessagesCompanion extends UpdateCompanion { - final Value transcriptId; - final Value messageId; - final Value userId; - final Value userFullName; - final Value category; +class StickerAlbumsCompanion extends UpdateCompanion { + final Value albumId; + final Value name; + final Value iconUrl; final Value createdAt; - final Value content; - final Value mediaUrl; - final Value mediaName; - final Value mediaSize; - final Value mediaWidth; - final Value mediaHeight; - final Value mediaMimeType; - final Value mediaDuration; - final Value mediaStatus; - final Value mediaWaveform; - final Value thumbImage; - final Value thumbUrl; - final Value mediaKey; - final Value mediaDigest; - final Value mediaCreatedAt; - final Value stickerId; - final Value sharedUserId; - final Value mentions; - final Value quoteId; - final Value quoteContent; - final Value caption; + final Value updateAt; + final Value orderedAt; + final Value userId; + final Value category; + final Value description; + final Value banner; + final Value added; + final Value isVerified; final Value rowid; - const TranscriptMessagesCompanion({ - this.transcriptId = const Value.absent(), - this.messageId = const Value.absent(), + const StickerAlbumsCompanion({ + this.albumId = const Value.absent(), + this.name = const Value.absent(), + this.iconUrl = const Value.absent(), + this.createdAt = const Value.absent(), + this.updateAt = const Value.absent(), + this.orderedAt = const Value.absent(), this.userId = const Value.absent(), - this.userFullName = const Value.absent(), this.category = const Value.absent(), - this.createdAt = const Value.absent(), - this.content = const Value.absent(), - this.mediaUrl = const Value.absent(), - this.mediaName = const Value.absent(), - this.mediaSize = const Value.absent(), - this.mediaWidth = const Value.absent(), - this.mediaHeight = const Value.absent(), - this.mediaMimeType = const Value.absent(), - this.mediaDuration = const Value.absent(), - this.mediaStatus = const Value.absent(), - this.mediaWaveform = const Value.absent(), - this.thumbImage = const Value.absent(), - this.thumbUrl = const Value.absent(), - this.mediaKey = const Value.absent(), - this.mediaDigest = const Value.absent(), - this.mediaCreatedAt = const Value.absent(), - this.stickerId = const Value.absent(), - this.sharedUserId = const Value.absent(), - this.mentions = const Value.absent(), - this.quoteId = const Value.absent(), - this.quoteContent = const Value.absent(), - this.caption = const Value.absent(), + this.description = const Value.absent(), + this.banner = const Value.absent(), + this.added = const Value.absent(), + this.isVerified = const Value.absent(), this.rowid = const Value.absent(), }); - TranscriptMessagesCompanion.insert({ - required String transcriptId, - required String messageId, - this.userId = const Value.absent(), - this.userFullName = const Value.absent(), - required String category, + StickerAlbumsCompanion.insert({ + required String albumId, + required String name, + required String iconUrl, required DateTime createdAt, - this.content = const Value.absent(), - this.mediaUrl = const Value.absent(), - this.mediaName = const Value.absent(), - this.mediaSize = const Value.absent(), - this.mediaWidth = const Value.absent(), - this.mediaHeight = const Value.absent(), - this.mediaMimeType = const Value.absent(), - this.mediaDuration = const Value.absent(), - this.mediaStatus = const Value.absent(), - this.mediaWaveform = const Value.absent(), - this.thumbImage = const Value.absent(), - this.thumbUrl = const Value.absent(), - this.mediaKey = const Value.absent(), - this.mediaDigest = const Value.absent(), - this.mediaCreatedAt = const Value.absent(), - this.stickerId = const Value.absent(), - this.sharedUserId = const Value.absent(), - this.mentions = const Value.absent(), - this.quoteId = const Value.absent(), - this.quoteContent = const Value.absent(), - this.caption = const Value.absent(), + required DateTime updateAt, + this.orderedAt = const Value.absent(), + required String userId, + required String category, + required String description, + this.banner = const Value.absent(), + this.added = const Value.absent(), + this.isVerified = const Value.absent(), this.rowid = const Value.absent(), - }) : transcriptId = Value(transcriptId), - messageId = Value(messageId), + }) : albumId = Value(albumId), + name = Value(name), + iconUrl = Value(iconUrl), + createdAt = Value(createdAt), + updateAt = Value(updateAt), + userId = Value(userId), category = Value(category), - createdAt = Value(createdAt); - static Insertable custom({ - Expression? transcriptId, - Expression? messageId, + description = Value(description); + static Insertable custom({ + Expression? albumId, + Expression? name, + Expression? iconUrl, + Expression? createdAt, + Expression? updateAt, + Expression? orderedAt, Expression? userId, - Expression? userFullName, Expression? category, - Expression? createdAt, - Expression? content, - Expression? mediaUrl, - Expression? mediaName, - Expression? mediaSize, - Expression? mediaWidth, - Expression? mediaHeight, - Expression? mediaMimeType, - Expression? mediaDuration, - Expression? mediaStatus, - Expression? mediaWaveform, - Expression? thumbImage, - Expression? thumbUrl, - Expression? mediaKey, - Expression? mediaDigest, - Expression? mediaCreatedAt, - Expression? stickerId, - Expression? sharedUserId, - Expression? mentions, - Expression? quoteId, - Expression? quoteContent, - Expression? caption, + Expression? description, + Expression? banner, + Expression? added, + Expression? isVerified, Expression? rowid, }) { return RawValuesInsertable({ - if (transcriptId != null) 'transcript_id': transcriptId, - if (messageId != null) 'message_id': messageId, + if (albumId != null) 'album_id': albumId, + if (name != null) 'name': name, + if (iconUrl != null) 'icon_url': iconUrl, + if (createdAt != null) 'created_at': createdAt, + if (updateAt != null) 'update_at': updateAt, + if (orderedAt != null) 'ordered_at': orderedAt, if (userId != null) 'user_id': userId, - if (userFullName != null) 'user_full_name': userFullName, if (category != null) 'category': category, - if (createdAt != null) 'created_at': createdAt, - if (content != null) 'content': content, - if (mediaUrl != null) 'media_url': mediaUrl, - if (mediaName != null) 'media_name': mediaName, - if (mediaSize != null) 'media_size': mediaSize, - if (mediaWidth != null) 'media_width': mediaWidth, - if (mediaHeight != null) 'media_height': mediaHeight, - if (mediaMimeType != null) 'media_mime_type': mediaMimeType, - if (mediaDuration != null) 'media_duration': mediaDuration, - if (mediaStatus != null) 'media_status': mediaStatus, - if (mediaWaveform != null) 'media_waveform': mediaWaveform, - if (thumbImage != null) 'thumb_image': thumbImage, - if (thumbUrl != null) 'thumb_url': thumbUrl, - if (mediaKey != null) 'media_key': mediaKey, - if (mediaDigest != null) 'media_digest': mediaDigest, - if (mediaCreatedAt != null) 'media_created_at': mediaCreatedAt, - if (stickerId != null) 'sticker_id': stickerId, - if (sharedUserId != null) 'shared_user_id': sharedUserId, - if (mentions != null) 'mentions': mentions, - if (quoteId != null) 'quote_id': quoteId, - if (quoteContent != null) 'quote_content': quoteContent, - if (caption != null) 'caption': caption, + if (description != null) 'description': description, + if (banner != null) 'banner': banner, + if (added != null) 'added': added, + if (isVerified != null) 'is_verified': isVerified, if (rowid != null) 'rowid': rowid, }); } - TranscriptMessagesCompanion copyWith( - {Value? transcriptId, - Value? messageId, - Value? userId, - Value? userFullName, - Value? category, + StickerAlbumsCompanion copyWith( + {Value? albumId, + Value? name, + Value? iconUrl, Value? createdAt, - Value? content, - Value? mediaUrl, - Value? mediaName, - Value? mediaSize, - Value? mediaWidth, - Value? mediaHeight, - Value? mediaMimeType, - Value? mediaDuration, - Value? mediaStatus, - Value? mediaWaveform, - Value? thumbImage, - Value? thumbUrl, - Value? mediaKey, - Value? mediaDigest, - Value? mediaCreatedAt, - Value? stickerId, - Value? sharedUserId, - Value? mentions, - Value? quoteId, - Value? quoteContent, - Value? caption, + Value? updateAt, + Value? orderedAt, + Value? userId, + Value? category, + Value? description, + Value? banner, + Value? added, + Value? isVerified, Value? rowid}) { - return TranscriptMessagesCompanion( - transcriptId: transcriptId ?? this.transcriptId, - messageId: messageId ?? this.messageId, + return StickerAlbumsCompanion( + albumId: albumId ?? this.albumId, + name: name ?? this.name, + iconUrl: iconUrl ?? this.iconUrl, + createdAt: createdAt ?? this.createdAt, + updateAt: updateAt ?? this.updateAt, + orderedAt: orderedAt ?? this.orderedAt, userId: userId ?? this.userId, - userFullName: userFullName ?? this.userFullName, category: category ?? this.category, - createdAt: createdAt ?? this.createdAt, - content: content ?? this.content, - mediaUrl: mediaUrl ?? this.mediaUrl, - mediaName: mediaName ?? this.mediaName, - mediaSize: mediaSize ?? this.mediaSize, - mediaWidth: mediaWidth ?? this.mediaWidth, - mediaHeight: mediaHeight ?? this.mediaHeight, - mediaMimeType: mediaMimeType ?? this.mediaMimeType, - mediaDuration: mediaDuration ?? this.mediaDuration, - mediaStatus: mediaStatus ?? this.mediaStatus, - mediaWaveform: mediaWaveform ?? this.mediaWaveform, - thumbImage: thumbImage ?? this.thumbImage, - thumbUrl: thumbUrl ?? this.thumbUrl, - mediaKey: mediaKey ?? this.mediaKey, - mediaDigest: mediaDigest ?? this.mediaDigest, - mediaCreatedAt: mediaCreatedAt ?? this.mediaCreatedAt, - stickerId: stickerId ?? this.stickerId, - sharedUserId: sharedUserId ?? this.sharedUserId, - mentions: mentions ?? this.mentions, - quoteId: quoteId ?? this.quoteId, - quoteContent: quoteContent ?? this.quoteContent, - caption: caption ?? this.caption, + description: description ?? this.description, + banner: banner ?? this.banner, + added: added ?? this.added, + isVerified: isVerified ?? this.isVerified, rowid: rowid ?? this.rowid, ); } @@ -12575,91 +10966,43 @@ class TranscriptMessagesCompanion extends UpdateCompanion { @override Map toColumns(bool nullToAbsent) { final map = {}; - if (transcriptId.present) { - map['transcript_id'] = Variable(transcriptId.value); - } - if (messageId.present) { - map['message_id'] = Variable(messageId.value); - } - if (userId.present) { - map['user_id'] = Variable(userId.value); + if (albumId.present) { + map['album_id'] = Variable(albumId.value); } - if (userFullName.present) { - map['user_full_name'] = Variable(userFullName.value); + if (name.present) { + map['name'] = Variable(name.value); } - if (category.present) { - map['category'] = Variable(category.value); + if (iconUrl.present) { + map['icon_url'] = Variable(iconUrl.value); } if (createdAt.present) { - final converter = TranscriptMessages.$convertercreatedAt; + final converter = StickerAlbums.$convertercreatedAt; map['created_at'] = Variable(converter.toSql(createdAt.value)); } - if (content.present) { - map['content'] = Variable(content.value); - } - if (mediaUrl.present) { - map['media_url'] = Variable(mediaUrl.value); - } - if (mediaName.present) { - map['media_name'] = Variable(mediaName.value); - } - if (mediaSize.present) { - map['media_size'] = Variable(mediaSize.value); - } - if (mediaWidth.present) { - map['media_width'] = Variable(mediaWidth.value); - } - if (mediaHeight.present) { - map['media_height'] = Variable(mediaHeight.value); - } - if (mediaMimeType.present) { - map['media_mime_type'] = Variable(mediaMimeType.value); - } - if (mediaDuration.present) { - map['media_duration'] = Variable(mediaDuration.value); - } - if (mediaStatus.present) { - final converter = TranscriptMessages.$convertermediaStatus; - map['media_status'] = - Variable(converter.toSql(mediaStatus.value)); - } - if (mediaWaveform.present) { - map['media_waveform'] = Variable(mediaWaveform.value); - } - if (thumbImage.present) { - map['thumb_image'] = Variable(thumbImage.value); - } - if (thumbUrl.present) { - map['thumb_url'] = Variable(thumbUrl.value); - } - if (mediaKey.present) { - map['media_key'] = Variable(mediaKey.value); - } - if (mediaDigest.present) { - map['media_digest'] = Variable(mediaDigest.value); + if (updateAt.present) { + final converter = StickerAlbums.$converterupdateAt; + map['update_at'] = Variable(converter.toSql(updateAt.value)); } - if (mediaCreatedAt.present) { - final converter = TranscriptMessages.$convertermediaCreatedAtn; - map['media_created_at'] = - Variable(converter.toSql(mediaCreatedAt.value)); + if (orderedAt.present) { + map['ordered_at'] = Variable(orderedAt.value); } - if (stickerId.present) { - map['sticker_id'] = Variable(stickerId.value); + if (userId.present) { + map['user_id'] = Variable(userId.value); } - if (sharedUserId.present) { - map['shared_user_id'] = Variable(sharedUserId.value); + if (category.present) { + map['category'] = Variable(category.value); } - if (mentions.present) { - map['mentions'] = Variable(mentions.value); + if (description.present) { + map['description'] = Variable(description.value); } - if (quoteId.present) { - map['quote_id'] = Variable(quoteId.value); + if (banner.present) { + map['banner'] = Variable(banner.value); } - if (quoteContent.present) { - map['quote_content'] = Variable(quoteContent.value); + if (added.present) { + map['added'] = Variable(added.value); } - if (caption.present) { - map['caption'] = Variable(caption.value); + if (isVerified.present) { + map['is_verified'] = Variable(isVerified.value); } if (rowid.present) { map['rowid'] = Variable(rowid.value); @@ -12669,196 +11012,191 @@ class TranscriptMessagesCompanion extends UpdateCompanion { @override String toString() { - return (StringBuffer('TranscriptMessagesCompanion(') - ..write('transcriptId: $transcriptId, ') - ..write('messageId: $messageId, ') + return (StringBuffer('StickerAlbumsCompanion(') + ..write('albumId: $albumId, ') + ..write('name: $name, ') + ..write('iconUrl: $iconUrl, ') + ..write('createdAt: $createdAt, ') + ..write('updateAt: $updateAt, ') + ..write('orderedAt: $orderedAt, ') ..write('userId: $userId, ') - ..write('userFullName: $userFullName, ') ..write('category: $category, ') - ..write('createdAt: $createdAt, ') - ..write('content: $content, ') - ..write('mediaUrl: $mediaUrl, ') - ..write('mediaName: $mediaName, ') - ..write('mediaSize: $mediaSize, ') - ..write('mediaWidth: $mediaWidth, ') - ..write('mediaHeight: $mediaHeight, ') - ..write('mediaMimeType: $mediaMimeType, ') - ..write('mediaDuration: $mediaDuration, ') - ..write('mediaStatus: $mediaStatus, ') - ..write('mediaWaveform: $mediaWaveform, ') - ..write('thumbImage: $thumbImage, ') - ..write('thumbUrl: $thumbUrl, ') - ..write('mediaKey: $mediaKey, ') - ..write('mediaDigest: $mediaDigest, ') - ..write('mediaCreatedAt: $mediaCreatedAt, ') - ..write('stickerId: $stickerId, ') - ..write('sharedUserId: $sharedUserId, ') - ..write('mentions: $mentions, ') - ..write('quoteId: $quoteId, ') - ..write('quoteContent: $quoteContent, ') - ..write('caption: $caption, ') + ..write('description: $description, ') + ..write('banner: $banner, ') + ..write('added: $added, ') + ..write('isVerified: $isVerified, ') ..write('rowid: $rowid') ..write(')')) .toString(); } } -class Fiats extends Table with TableInfo { +class StickerRelationships extends Table + with TableInfo { @override final GeneratedDatabase attachedDatabase; final String? _alias; - Fiats(this.attachedDatabase, [this._alias]); - static const VerificationMeta _codeMeta = const VerificationMeta('code'); - late final GeneratedColumn code = GeneratedColumn( - 'code', aliasedName, false, + StickerRelationships(this.attachedDatabase, [this._alias]); + static const VerificationMeta _albumIdMeta = + const VerificationMeta('albumId'); + late final GeneratedColumn albumId = GeneratedColumn( + 'album_id', aliasedName, false, type: DriftSqlType.string, requiredDuringInsert: true, $customConstraints: 'NOT NULL'); - static const VerificationMeta _rateMeta = const VerificationMeta('rate'); - late final GeneratedColumn rate = GeneratedColumn( - 'rate', aliasedName, false, - type: DriftSqlType.double, + static const VerificationMeta _stickerIdMeta = + const VerificationMeta('stickerId'); + late final GeneratedColumn stickerId = GeneratedColumn( + 'sticker_id', aliasedName, false, + type: DriftSqlType.string, requiredDuringInsert: true, $customConstraints: 'NOT NULL'); @override - List get $columns => [code, rate]; + List get $columns => [albumId, stickerId]; @override - String get aliasedName => _alias ?? 'fiats'; + String get aliasedName => _alias ?? 'sticker_relationships'; @override - String get actualTableName => 'fiats'; + String get actualTableName => 'sticker_relationships'; @override - VerificationContext validateIntegrity(Insertable instance, + VerificationContext validateIntegrity( + Insertable instance, {bool isInserting = false}) { final context = VerificationContext(); final data = instance.toColumns(true); - if (data.containsKey('code')) { - context.handle( - _codeMeta, code.isAcceptableOrUnknown(data['code']!, _codeMeta)); + if (data.containsKey('album_id')) { + context.handle(_albumIdMeta, + albumId.isAcceptableOrUnknown(data['album_id']!, _albumIdMeta)); } else if (isInserting) { - context.missing(_codeMeta); + context.missing(_albumIdMeta); } - if (data.containsKey('rate')) { - context.handle( - _rateMeta, rate.isAcceptableOrUnknown(data['rate']!, _rateMeta)); + if (data.containsKey('sticker_id')) { + context.handle(_stickerIdMeta, + stickerId.isAcceptableOrUnknown(data['sticker_id']!, _stickerIdMeta)); } else if (isInserting) { - context.missing(_rateMeta); + context.missing(_stickerIdMeta); } return context; } @override - Set get $primaryKey => {code}; + Set get $primaryKey => {albumId, stickerId}; @override - Fiat map(Map data, {String? tablePrefix}) { + StickerRelationship map(Map data, {String? tablePrefix}) { final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; - return Fiat( - code: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}code'])!, - rate: attachedDatabase.typeMapping - .read(DriftSqlType.double, data['${effectivePrefix}rate'])!, + return StickerRelationship( + albumId: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}album_id'])!, + stickerId: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}sticker_id'])!, ); } @override - Fiats createAlias(String alias) { - return Fiats(attachedDatabase, alias); + StickerRelationships createAlias(String alias) { + return StickerRelationships(attachedDatabase, alias); } @override - List get customConstraints => const ['PRIMARY KEY(code)']; + List get customConstraints => + const ['PRIMARY KEY(album_id, sticker_id)']; @override bool get dontWriteConstraints => true; } -class Fiat extends DataClass implements Insertable { - final String code; - final double rate; - const Fiat({required this.code, required this.rate}); +class StickerRelationship extends DataClass + implements Insertable { + final String albumId; + final String stickerId; + const StickerRelationship({required this.albumId, required this.stickerId}); @override Map toColumns(bool nullToAbsent) { final map = {}; - map['code'] = Variable(code); - map['rate'] = Variable(rate); + map['album_id'] = Variable(albumId); + map['sticker_id'] = Variable(stickerId); return map; } - FiatsCompanion toCompanion(bool nullToAbsent) { - return FiatsCompanion( - code: Value(code), - rate: Value(rate), + StickerRelationshipsCompanion toCompanion(bool nullToAbsent) { + return StickerRelationshipsCompanion( + albumId: Value(albumId), + stickerId: Value(stickerId), ); } - factory Fiat.fromJson(Map json, + factory StickerRelationship.fromJson(Map json, {ValueSerializer? serializer}) { serializer ??= driftRuntimeOptions.defaultSerializer; - return Fiat( - code: serializer.fromJson(json['code']), - rate: serializer.fromJson(json['rate']), + return StickerRelationship( + albumId: serializer.fromJson(json['album_id']), + stickerId: serializer.fromJson(json['sticker_id']), ); } @override Map toJson({ValueSerializer? serializer}) { serializer ??= driftRuntimeOptions.defaultSerializer; return { - 'code': serializer.toJson(code), - 'rate': serializer.toJson(rate), + 'album_id': serializer.toJson(albumId), + 'sticker_id': serializer.toJson(stickerId), }; } - Fiat copyWith({String? code, double? rate}) => Fiat( - code: code ?? this.code, - rate: rate ?? this.rate, + StickerRelationship copyWith({String? albumId, String? stickerId}) => + StickerRelationship( + albumId: albumId ?? this.albumId, + stickerId: stickerId ?? this.stickerId, ); @override String toString() { - return (StringBuffer('Fiat(') - ..write('code: $code, ') - ..write('rate: $rate') + return (StringBuffer('StickerRelationship(') + ..write('albumId: $albumId, ') + ..write('stickerId: $stickerId') ..write(')')) .toString(); } @override - int get hashCode => Object.hash(code, rate); + int get hashCode => Object.hash(albumId, stickerId); @override bool operator ==(Object other) => identical(this, other) || - (other is Fiat && other.code == this.code && other.rate == this.rate); + (other is StickerRelationship && + other.albumId == this.albumId && + other.stickerId == this.stickerId); } -class FiatsCompanion extends UpdateCompanion { - final Value code; - final Value rate; +class StickerRelationshipsCompanion + extends UpdateCompanion { + final Value albumId; + final Value stickerId; final Value rowid; - const FiatsCompanion({ - this.code = const Value.absent(), - this.rate = const Value.absent(), + const StickerRelationshipsCompanion({ + this.albumId = const Value.absent(), + this.stickerId = const Value.absent(), this.rowid = const Value.absent(), }); - FiatsCompanion.insert({ - required String code, - required double rate, + StickerRelationshipsCompanion.insert({ + required String albumId, + required String stickerId, this.rowid = const Value.absent(), - }) : code = Value(code), - rate = Value(rate); - static Insertable custom({ - Expression? code, - Expression? rate, + }) : albumId = Value(albumId), + stickerId = Value(stickerId); + static Insertable custom({ + Expression? albumId, + Expression? stickerId, Expression? rowid, }) { return RawValuesInsertable({ - if (code != null) 'code': code, - if (rate != null) 'rate': rate, + if (albumId != null) 'album_id': albumId, + if (stickerId != null) 'sticker_id': stickerId, if (rowid != null) 'rowid': rowid, }); } - FiatsCompanion copyWith( - {Value? code, Value? rate, Value? rowid}) { - return FiatsCompanion( - code: code ?? this.code, - rate: rate ?? this.rate, + StickerRelationshipsCompanion copyWith( + {Value? albumId, Value? stickerId, Value? rowid}) { + return StickerRelationshipsCompanion( + albumId: albumId ?? this.albumId, + stickerId: stickerId ?? this.stickerId, rowid: rowid ?? this.rowid, ); } @@ -12866,11 +11204,11 @@ class FiatsCompanion extends UpdateCompanion { @override Map toColumns(bool nullToAbsent) { final map = {}; - if (code.present) { - map['code'] = Variable(code.value); + if (albumId.present) { + map['album_id'] = Variable(albumId.value); } - if (rate.present) { - map['rate'] = Variable(rate.value); + if (stickerId.present) { + map['sticker_id'] = Variable(stickerId.value); } if (rowid.present) { map['rowid'] = Variable(rowid.value); @@ -12880,4005 +11218,2737 @@ class FiatsCompanion extends UpdateCompanion { @override String toString() { - return (StringBuffer('FiatsCompanion(') - ..write('code: $code, ') - ..write('rate: $rate, ') + return (StringBuffer('StickerRelationshipsCompanion(') + ..write('albumId: $albumId, ') + ..write('stickerId: $stickerId, ') ..write('rowid: $rowid') ..write(')')) .toString(); } } -class Properties extends Table with TableInfo { +class TranscriptMessages extends Table + with TableInfo { @override final GeneratedDatabase attachedDatabase; final String? _alias; - Properties(this.attachedDatabase, [this._alias]); - static const VerificationMeta _keyMeta = const VerificationMeta('key'); - late final GeneratedColumn key = GeneratedColumn( - 'key', aliasedName, false, + TranscriptMessages(this.attachedDatabase, [this._alias]); + static const VerificationMeta _transcriptIdMeta = + const VerificationMeta('transcriptId'); + late final GeneratedColumn transcriptId = GeneratedColumn( + 'transcript_id', aliasedName, false, type: DriftSqlType.string, requiredDuringInsert: true, $customConstraints: 'NOT NULL'); - static const VerificationMeta _groupMeta = const VerificationMeta('group'); - late final GeneratedColumnWithTypeConverter group = - GeneratedColumn('group', aliasedName, false, - type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL') - .withConverter(Properties.$convertergroup); - static const VerificationMeta _valueMeta = const VerificationMeta('value'); - late final GeneratedColumn value = GeneratedColumn( - 'value', aliasedName, false, + static const VerificationMeta _messageIdMeta = + const VerificationMeta('messageId'); + late final GeneratedColumn messageId = GeneratedColumn( + 'message_id', aliasedName, false, type: DriftSqlType.string, requiredDuringInsert: true, $customConstraints: 'NOT NULL'); + static const VerificationMeta _userIdMeta = const VerificationMeta('userId'); + late final GeneratedColumn userId = GeneratedColumn( + 'user_id', aliasedName, true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: ''); + static const VerificationMeta _userFullNameMeta = + const VerificationMeta('userFullName'); + late final GeneratedColumn userFullName = GeneratedColumn( + 'user_full_name', aliasedName, true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: ''); + static const VerificationMeta _categoryMeta = + const VerificationMeta('category'); + late final GeneratedColumn category = GeneratedColumn( + 'category', aliasedName, false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL'); + static const VerificationMeta _createdAtMeta = + const VerificationMeta('createdAt'); + late final GeneratedColumnWithTypeConverter createdAt = + GeneratedColumn('created_at', aliasedName, false, + type: DriftSqlType.int, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL') + .withConverter(TranscriptMessages.$convertercreatedAt); + static const VerificationMeta _contentMeta = + const VerificationMeta('content'); + late final GeneratedColumn content = GeneratedColumn( + 'content', aliasedName, true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: ''); + static const VerificationMeta _mediaUrlMeta = + const VerificationMeta('mediaUrl'); + late final GeneratedColumn mediaUrl = GeneratedColumn( + 'media_url', aliasedName, true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: ''); + static const VerificationMeta _mediaNameMeta = + const VerificationMeta('mediaName'); + late final GeneratedColumn mediaName = GeneratedColumn( + 'media_name', aliasedName, true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: ''); + static const VerificationMeta _mediaSizeMeta = + const VerificationMeta('mediaSize'); + late final GeneratedColumn mediaSize = GeneratedColumn( + 'media_size', aliasedName, true, + type: DriftSqlType.int, + requiredDuringInsert: false, + $customConstraints: ''); + static const VerificationMeta _mediaWidthMeta = + const VerificationMeta('mediaWidth'); + late final GeneratedColumn mediaWidth = GeneratedColumn( + 'media_width', aliasedName, true, + type: DriftSqlType.int, + requiredDuringInsert: false, + $customConstraints: ''); + static const VerificationMeta _mediaHeightMeta = + const VerificationMeta('mediaHeight'); + late final GeneratedColumn mediaHeight = GeneratedColumn( + 'media_height', aliasedName, true, + type: DriftSqlType.int, + requiredDuringInsert: false, + $customConstraints: ''); + static const VerificationMeta _mediaMimeTypeMeta = + const VerificationMeta('mediaMimeType'); + late final GeneratedColumn mediaMimeType = GeneratedColumn( + 'media_mime_type', aliasedName, true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: ''); + static const VerificationMeta _mediaDurationMeta = + const VerificationMeta('mediaDuration'); + late final GeneratedColumn mediaDuration = GeneratedColumn( + 'media_duration', aliasedName, true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: ''); + static const VerificationMeta _mediaStatusMeta = + const VerificationMeta('mediaStatus'); + late final GeneratedColumnWithTypeConverter + mediaStatus = GeneratedColumn('media_status', aliasedName, true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '') + .withConverter( + TranscriptMessages.$convertermediaStatus); + static const VerificationMeta _mediaWaveformMeta = + const VerificationMeta('mediaWaveform'); + late final GeneratedColumn mediaWaveform = GeneratedColumn( + 'media_waveform', aliasedName, true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: ''); + static const VerificationMeta _thumbImageMeta = + const VerificationMeta('thumbImage'); + late final GeneratedColumn thumbImage = GeneratedColumn( + 'thumb_image', aliasedName, true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: ''); + static const VerificationMeta _thumbUrlMeta = + const VerificationMeta('thumbUrl'); + late final GeneratedColumn thumbUrl = GeneratedColumn( + 'thumb_url', aliasedName, true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: ''); + static const VerificationMeta _mediaKeyMeta = + const VerificationMeta('mediaKey'); + late final GeneratedColumn mediaKey = GeneratedColumn( + 'media_key', aliasedName, true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: ''); + static const VerificationMeta _mediaDigestMeta = + const VerificationMeta('mediaDigest'); + late final GeneratedColumn mediaDigest = GeneratedColumn( + 'media_digest', aliasedName, true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: ''); + static const VerificationMeta _mediaCreatedAtMeta = + const VerificationMeta('mediaCreatedAt'); + late final GeneratedColumnWithTypeConverter mediaCreatedAt = + GeneratedColumn('media_created_at', aliasedName, true, + type: DriftSqlType.int, + requiredDuringInsert: false, + $customConstraints: '') + .withConverter( + TranscriptMessages.$convertermediaCreatedAtn); + static const VerificationMeta _stickerIdMeta = + const VerificationMeta('stickerId'); + late final GeneratedColumn stickerId = GeneratedColumn( + 'sticker_id', aliasedName, true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: ''); + static const VerificationMeta _sharedUserIdMeta = + const VerificationMeta('sharedUserId'); + late final GeneratedColumn sharedUserId = GeneratedColumn( + 'shared_user_id', aliasedName, true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: ''); + static const VerificationMeta _mentionsMeta = + const VerificationMeta('mentions'); + late final GeneratedColumn mentions = GeneratedColumn( + 'mentions', aliasedName, true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: ''); + static const VerificationMeta _quoteIdMeta = + const VerificationMeta('quoteId'); + late final GeneratedColumn quoteId = GeneratedColumn( + 'quote_id', aliasedName, true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: ''); + static const VerificationMeta _quoteContentMeta = + const VerificationMeta('quoteContent'); + late final GeneratedColumn quoteContent = GeneratedColumn( + 'quote_content', aliasedName, true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: ''); + static const VerificationMeta _captionMeta = + const VerificationMeta('caption'); + late final GeneratedColumn caption = GeneratedColumn( + 'caption', aliasedName, true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: ''); @override - List get $columns => [key, group, value]; - @override - String get aliasedName => _alias ?? 'properties'; - @override - String get actualTableName => 'properties'; - @override - VerificationContext validateIntegrity(Insertable instance, - {bool isInserting = false}) { - final context = VerificationContext(); - final data = instance.toColumns(true); - if (data.containsKey('key')) { - context.handle( - _keyMeta, key.isAcceptableOrUnknown(data['key']!, _keyMeta)); - } else if (isInserting) { - context.missing(_keyMeta); - } - context.handle(_groupMeta, const VerificationResult.success()); - if (data.containsKey('value')) { - context.handle( - _valueMeta, value.isAcceptableOrUnknown(data['value']!, _valueMeta)); - } else if (isInserting) { - context.missing(_valueMeta); - } - return context; - } - - @override - Set get $primaryKey => {key, group}; - @override - Propertie map(Map data, {String? tablePrefix}) { - final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; - return Propertie( - key: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}key'])!, - group: Properties.$convertergroup.fromSql(attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}group'])!), - value: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}value'])!, - ); - } - - @override - Properties createAlias(String alias) { - return Properties(attachedDatabase, alias); - } - - static TypeConverter $convertergroup = - const PropertyGroupConverter(); - @override - List get customConstraints => const ['PRIMARY KEY("key", "group")']; - @override - bool get dontWriteConstraints => true; -} - -class Propertie extends DataClass implements Insertable { - final String key; - final PropertyGroup group; - final String value; - const Propertie( - {required this.key, required this.group, required this.value}); - @override - Map toColumns(bool nullToAbsent) { - final map = {}; - map['key'] = Variable(key); - { - final converter = Properties.$convertergroup; - map['group'] = Variable(converter.toSql(group)); - } - map['value'] = Variable(value); - return map; - } - - PropertiesCompanion toCompanion(bool nullToAbsent) { - return PropertiesCompanion( - key: Value(key), - group: Value(group), - value: Value(value), - ); - } - - factory Propertie.fromJson(Map json, - {ValueSerializer? serializer}) { - serializer ??= driftRuntimeOptions.defaultSerializer; - return Propertie( - key: serializer.fromJson(json['key']), - group: serializer.fromJson(json['group']), - value: serializer.fromJson(json['value']), - ); - } + List get $columns => [ + transcriptId, + messageId, + userId, + userFullName, + category, + createdAt, + content, + mediaUrl, + mediaName, + mediaSize, + mediaWidth, + mediaHeight, + mediaMimeType, + mediaDuration, + mediaStatus, + mediaWaveform, + thumbImage, + thumbUrl, + mediaKey, + mediaDigest, + mediaCreatedAt, + stickerId, + sharedUserId, + mentions, + quoteId, + quoteContent, + caption + ]; @override - Map toJson({ValueSerializer? serializer}) { - serializer ??= driftRuntimeOptions.defaultSerializer; - return { - 'key': serializer.toJson(key), - 'group': serializer.toJson(group), - 'value': serializer.toJson(value), - }; - } - - Propertie copyWith({String? key, PropertyGroup? group, String? value}) => - Propertie( - key: key ?? this.key, - group: group ?? this.group, - value: value ?? this.value, - ); + String get aliasedName => _alias ?? 'transcript_messages'; @override - String toString() { - return (StringBuffer('Propertie(') - ..write('key: $key, ') - ..write('group: $group, ') - ..write('value: $value') - ..write(')')) - .toString(); - } - - @override - int get hashCode => Object.hash(key, group, value); - @override - bool operator ==(Object other) => - identical(this, other) || - (other is Propertie && - other.key == this.key && - other.group == this.group && - other.value == this.value); -} - -class PropertiesCompanion extends UpdateCompanion { - final Value key; - final Value group; - final Value value; - final Value rowid; - const PropertiesCompanion({ - this.key = const Value.absent(), - this.group = const Value.absent(), - this.value = const Value.absent(), - this.rowid = const Value.absent(), - }); - PropertiesCompanion.insert({ - required String key, - required PropertyGroup group, - required String value, - this.rowid = const Value.absent(), - }) : key = Value(key), - group = Value(group), - value = Value(value); - static Insertable custom({ - Expression? key, - Expression? group, - Expression? value, - Expression? rowid, - }) { - return RawValuesInsertable({ - if (key != null) 'key': key, - if (group != null) 'group': group, - if (value != null) 'value': value, - if (rowid != null) 'rowid': rowid, - }); - } - - PropertiesCompanion copyWith( - {Value? key, - Value? group, - Value? value, - Value? rowid}) { - return PropertiesCompanion( - key: key ?? this.key, - group: group ?? this.group, - value: value ?? this.value, - rowid: rowid ?? this.rowid, - ); - } - + String get actualTableName => 'transcript_messages'; @override - Map toColumns(bool nullToAbsent) { - final map = {}; - if (key.present) { - map['key'] = Variable(key.value); + VerificationContext validateIntegrity(Insertable instance, + {bool isInserting = false}) { + final context = VerificationContext(); + final data = instance.toColumns(true); + if (data.containsKey('transcript_id')) { + context.handle( + _transcriptIdMeta, + transcriptId.isAcceptableOrUnknown( + data['transcript_id']!, _transcriptIdMeta)); + } else if (isInserting) { + context.missing(_transcriptIdMeta); } - if (group.present) { - final converter = Properties.$convertergroup; - map['group'] = Variable(converter.toSql(group.value)); + if (data.containsKey('message_id')) { + context.handle(_messageIdMeta, + messageId.isAcceptableOrUnknown(data['message_id']!, _messageIdMeta)); + } else if (isInserting) { + context.missing(_messageIdMeta); } - if (value.present) { - map['value'] = Variable(value.value); + if (data.containsKey('user_id')) { + context.handle(_userIdMeta, + userId.isAcceptableOrUnknown(data['user_id']!, _userIdMeta)); } - if (rowid.present) { - map['rowid'] = Variable(rowid.value); + if (data.containsKey('user_full_name')) { + context.handle( + _userFullNameMeta, + userFullName.isAcceptableOrUnknown( + data['user_full_name']!, _userFullNameMeta)); } - return map; + if (data.containsKey('category')) { + context.handle(_categoryMeta, + category.isAcceptableOrUnknown(data['category']!, _categoryMeta)); + } else if (isInserting) { + context.missing(_categoryMeta); + } + context.handle(_createdAtMeta, const VerificationResult.success()); + if (data.containsKey('content')) { + context.handle(_contentMeta, + content.isAcceptableOrUnknown(data['content']!, _contentMeta)); + } + if (data.containsKey('media_url')) { + context.handle(_mediaUrlMeta, + mediaUrl.isAcceptableOrUnknown(data['media_url']!, _mediaUrlMeta)); + } + if (data.containsKey('media_name')) { + context.handle(_mediaNameMeta, + mediaName.isAcceptableOrUnknown(data['media_name']!, _mediaNameMeta)); + } + if (data.containsKey('media_size')) { + context.handle(_mediaSizeMeta, + mediaSize.isAcceptableOrUnknown(data['media_size']!, _mediaSizeMeta)); + } + if (data.containsKey('media_width')) { + context.handle( + _mediaWidthMeta, + mediaWidth.isAcceptableOrUnknown( + data['media_width']!, _mediaWidthMeta)); + } + if (data.containsKey('media_height')) { + context.handle( + _mediaHeightMeta, + mediaHeight.isAcceptableOrUnknown( + data['media_height']!, _mediaHeightMeta)); + } + if (data.containsKey('media_mime_type')) { + context.handle( + _mediaMimeTypeMeta, + mediaMimeType.isAcceptableOrUnknown( + data['media_mime_type']!, _mediaMimeTypeMeta)); + } + if (data.containsKey('media_duration')) { + context.handle( + _mediaDurationMeta, + mediaDuration.isAcceptableOrUnknown( + data['media_duration']!, _mediaDurationMeta)); + } + context.handle(_mediaStatusMeta, const VerificationResult.success()); + if (data.containsKey('media_waveform')) { + context.handle( + _mediaWaveformMeta, + mediaWaveform.isAcceptableOrUnknown( + data['media_waveform']!, _mediaWaveformMeta)); + } + if (data.containsKey('thumb_image')) { + context.handle( + _thumbImageMeta, + thumbImage.isAcceptableOrUnknown( + data['thumb_image']!, _thumbImageMeta)); + } + if (data.containsKey('thumb_url')) { + context.handle(_thumbUrlMeta, + thumbUrl.isAcceptableOrUnknown(data['thumb_url']!, _thumbUrlMeta)); + } + if (data.containsKey('media_key')) { + context.handle(_mediaKeyMeta, + mediaKey.isAcceptableOrUnknown(data['media_key']!, _mediaKeyMeta)); + } + if (data.containsKey('media_digest')) { + context.handle( + _mediaDigestMeta, + mediaDigest.isAcceptableOrUnknown( + data['media_digest']!, _mediaDigestMeta)); + } + context.handle(_mediaCreatedAtMeta, const VerificationResult.success()); + if (data.containsKey('sticker_id')) { + context.handle(_stickerIdMeta, + stickerId.isAcceptableOrUnknown(data['sticker_id']!, _stickerIdMeta)); + } + if (data.containsKey('shared_user_id')) { + context.handle( + _sharedUserIdMeta, + sharedUserId.isAcceptableOrUnknown( + data['shared_user_id']!, _sharedUserIdMeta)); + } + if (data.containsKey('mentions')) { + context.handle(_mentionsMeta, + mentions.isAcceptableOrUnknown(data['mentions']!, _mentionsMeta)); + } + if (data.containsKey('quote_id')) { + context.handle(_quoteIdMeta, + quoteId.isAcceptableOrUnknown(data['quote_id']!, _quoteIdMeta)); + } + if (data.containsKey('quote_content')) { + context.handle( + _quoteContentMeta, + quoteContent.isAcceptableOrUnknown( + data['quote_content']!, _quoteContentMeta)); + } + if (data.containsKey('caption')) { + context.handle(_captionMeta, + caption.isAcceptableOrUnknown(data['caption']!, _captionMeta)); + } + return context; } @override - String toString() { - return (StringBuffer('PropertiesCompanion(') - ..write('key: $key, ') - ..write('group: $group, ') - ..write('value: $value, ') - ..write('rowid: $rowid') - ..write(')')) - .toString(); - } -} - -abstract class _$MixinDatabase extends GeneratedDatabase { - _$MixinDatabase(QueryExecutor e) : super(e); - late final FavoriteApps favoriteApps = FavoriteApps(this); - late final Apps apps = Apps(this); - late final StickerRelationships stickerRelationships = - StickerRelationships(this); - late final StickerAlbums stickerAlbums = StickerAlbums(this); - late final PinMessages pinMessages = PinMessages(this); - late final Conversations conversations = Conversations(this); - late final Messages messages = Messages(this); - late final Users users = Users(this); - late final Snapshots snapshots = Snapshots(this); - late final Assets assets = Assets(this); - late final Chains chains = Chains(this); - late final Stickers stickers = Stickers(this); - late final Hyperlinks hyperlinks = Hyperlinks(this); - late final MessageMentions messageMentions = MessageMentions(this); - late final ExpiredMessages expiredMessages = ExpiredMessages(this); - late final FloodMessages floodMessages = FloodMessages(this); - late final Circles circles = Circles(this); - late final CircleConversations circleConversations = - CircleConversations(this); - late final Participants participants = Participants(this); - late final ParticipantSession participantSession = ParticipantSession(this); - late final ResendSessionMessages resendSessionMessages = - ResendSessionMessages(this); - late final Addresses addresses = Addresses(this); - late final Jobs jobs = Jobs(this); - late final MessagesHistory messagesHistory = MessagesHistory(this); - late final Offsets offsets = Offsets(this); - late final SentSessionSenderKeys sentSessionSenderKeys = - SentSessionSenderKeys(this); - late final TranscriptMessages transcriptMessages = TranscriptMessages(this); - late final Fiats fiats = Fiats(this); - late final Properties properties = Properties(this); - late final Index indexConversationsCategoryStatus = Index( - 'index_conversations_category_status', - 'CREATE INDEX IF NOT EXISTS index_conversations_category_status ON conversations (category, status)'); - late final Index indexConversationsMuteUntil = Index( - 'index_conversations_mute_until', - 'CREATE INDEX IF NOT EXISTS index_conversations_mute_until ON conversations (mute_until)'); - late final Index indexFloodMessagesCreatedAt = Index( - 'index_flood_messages_created_at', - 'CREATE INDEX IF NOT EXISTS index_flood_messages_created_at ON flood_messages (created_at)'); - late final Index indexJobsAction = Index('index_jobs_action', - 'CREATE INDEX IF NOT EXISTS index_jobs_action ON jobs ("action")'); - late final Index indexMessageMentionsConversationIdHasRead = Index( - 'index_message_mentions_conversation_id_has_read', - 'CREATE INDEX IF NOT EXISTS index_message_mentions_conversation_id_has_read ON message_mentions (conversation_id, has_read)'); - late final Index indexParticipantsConversationIdCreatedAt = Index( - 'index_participants_conversation_id_created_at', - 'CREATE INDEX IF NOT EXISTS index_participants_conversation_id_created_at ON participants (conversation_id, created_at)'); - late final Index indexStickerAlbumsCategoryCreatedAt = Index( - 'index_sticker_albums_category_created_at', - 'CREATE INDEX IF NOT EXISTS index_sticker_albums_category_created_at ON sticker_albums (category, created_at DESC)'); - late final Index indexPinMessagesConversationId = Index( - 'index_pin_messages_conversation_id', - 'CREATE INDEX IF NOT EXISTS index_pin_messages_conversation_id ON pin_messages (conversation_id)'); - late final Index indexUsersIdentityNumber = Index( - 'index_users_identity_number', - 'CREATE INDEX IF NOT EXISTS index_users_identity_number ON users (identity_number)'); - late final Index indexMessagesConversationIdCreatedAt = Index( - 'index_messages_conversation_id_created_at', - 'CREATE INDEX IF NOT EXISTS index_messages_conversation_id_created_at ON messages (conversation_id, created_at DESC)'); - late final Index indexMessagesConversationIdCategoryCreatedAt = Index( - 'index_messages_conversation_id_category_created_at', - 'CREATE INDEX IF NOT EXISTS index_messages_conversation_id_category_created_at ON messages (conversation_id, category, created_at DESC)'); - late final Index indexMessageConversationIdStatusUserId = Index( - 'index_message_conversation_id_status_user_id', - 'CREATE INDEX IF NOT EXISTS index_message_conversation_id_status_user_id ON messages (conversation_id, status, user_id)'); - late final Index indexMessagesConversationIdQuoteMessageId = Index( - 'index_messages_conversation_id_quote_message_id', - 'CREATE INDEX IF NOT EXISTS index_messages_conversation_id_quote_message_id ON messages (conversation_id, quote_message_id)'); - late final AddressDao addressDao = AddressDao(this as MixinDatabase); - late final AppDao appDao = AppDao(this as MixinDatabase); - late final AssetDao assetDao = AssetDao(this as MixinDatabase); - late final CircleConversationDao circleConversationDao = - CircleConversationDao(this as MixinDatabase); - late final CircleDao circleDao = CircleDao(this as MixinDatabase); - late final ConversationDao conversationDao = - ConversationDao(this as MixinDatabase); - late final FloodMessageDao floodMessageDao = - FloodMessageDao(this as MixinDatabase); - late final HyperlinkDao hyperlinkDao = HyperlinkDao(this as MixinDatabase); - late final JobDao jobDao = JobDao(this as MixinDatabase); - late final MessageMentionDao messageMentionDao = - MessageMentionDao(this as MixinDatabase); - late final MessageDao messageDao = MessageDao(this as MixinDatabase); - late final MessageHistoryDao messageHistoryDao = - MessageHistoryDao(this as MixinDatabase); - late final OffsetDao offsetDao = OffsetDao(this as MixinDatabase); - late final ParticipantDao participantDao = - ParticipantDao(this as MixinDatabase); - late final ParticipantSessionDao participantSessionDao = - ParticipantSessionDao(this as MixinDatabase); - late final ResendSessionMessageDao resendSessionMessageDao = - ResendSessionMessageDao(this as MixinDatabase); - late final SentSessionSenderKeyDao sentSessionSenderKeyDao = - SentSessionSenderKeyDao(this as MixinDatabase); - late final SnapshotDao snapshotDao = SnapshotDao(this as MixinDatabase); - late final StickerDao stickerDao = StickerDao(this as MixinDatabase); - late final StickerAlbumDao stickerAlbumDao = - StickerAlbumDao(this as MixinDatabase); - late final StickerRelationshipDao stickerRelationshipDao = - StickerRelationshipDao(this as MixinDatabase); - late final UserDao userDao = UserDao(this as MixinDatabase); - late final PinMessageDao pinMessageDao = PinMessageDao(this as MixinDatabase); - late final FiatDao fiatDao = FiatDao(this as MixinDatabase); - late final FavoriteAppDao favoriteAppDao = - FavoriteAppDao(this as MixinDatabase); - late final ExpiredMessageDao expiredMessageDao = - ExpiredMessageDao(this as MixinDatabase); - late final ChainDao chainDao = ChainDao(this as MixinDatabase); - late final PropertyDao propertyDao = PropertyDao(this as MixinDatabase); - Future deleteFavoriteAppByAppIdAndUserId(String appId, String userId) { - return customUpdate( - 'DELETE FROM favorite_apps WHERE app_id = ?1 AND user_id = ?2', - variables: [Variable(appId), Variable(userId)], - updates: {favoriteApps}, - updateKind: UpdateKind.delete, - ); - } - - Future deleteFavoriteAppByUserId(String userId) { - return customUpdate( - 'DELETE FROM favorite_apps WHERE user_id = ?1', - variables: [Variable(userId)], - updates: {favoriteApps}, - updateKind: UpdateKind.delete, + Set get $primaryKey => {transcriptId, messageId}; + @override + TranscriptMessage map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return TranscriptMessage( + transcriptId: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}transcript_id'])!, + messageId: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}message_id'])!, + userId: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}user_id']), + userFullName: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}user_full_name']), + category: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}category'])!, + createdAt: TranscriptMessages.$convertercreatedAt.fromSql(attachedDatabase + .typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}created_at'])!), + content: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}content']), + mediaUrl: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}media_url']), + mediaName: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}media_name']), + mediaSize: attachedDatabase.typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}media_size']), + mediaWidth: attachedDatabase.typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}media_width']), + mediaHeight: attachedDatabase.typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}media_height']), + mediaMimeType: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}media_mime_type']), + mediaDuration: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}media_duration']), + mediaStatus: TranscriptMessages.$convertermediaStatus.fromSql( + attachedDatabase.typeMapping.read( + DriftSqlType.string, data['${effectivePrefix}media_status'])), + mediaWaveform: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}media_waveform']), + thumbImage: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}thumb_image']), + thumbUrl: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}thumb_url']), + mediaKey: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}media_key']), + mediaDigest: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}media_digest']), + mediaCreatedAt: TranscriptMessages.$convertermediaCreatedAtn.fromSql( + attachedDatabase.typeMapping.read( + DriftSqlType.int, data['${effectivePrefix}media_created_at'])), + stickerId: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}sticker_id']), + sharedUserId: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}shared_user_id']), + mentions: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}mentions']), + quoteId: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}quote_id']), + quoteContent: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}quote_content']), + caption: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}caption']), ); } - Selectable getFavoriteAppByUserId(String userId) { - return customSelect( - 'SELECT a.* FROM favorite_apps AS fa INNER JOIN apps AS a ON fa.app_id = a.app_id WHERE fa.user_id = ?1', - variables: [ - Variable(userId) - ], - readsFrom: { - favoriteApps, - apps, - }).asyncMap(apps.mapFromRow); - } - - Selectable stickerSystemAlbumId(String stickerId) { - return customSelect( - 'SELECT sa.album_id FROM sticker_relationships AS sr INNER JOIN sticker_albums AS sa ON sr.album_id = sa.album_id WHERE sr.sticker_id = ?1 AND sa.category = \'SYSTEM\' LIMIT 1', - variables: [ - Variable(stickerId) - ], - readsFrom: { - stickerAlbums, - stickerRelationships, - }).map((QueryRow row) => row.read('album_id')); + @override + TranscriptMessages createAlias(String alias) { + return TranscriptMessages(attachedDatabase, alias); } - Selectable stickerSystemAlbum(String stickerId) { - return customSelect( - 'SELECT sa.* FROM sticker_relationships AS sr INNER JOIN sticker_albums AS sa ON sr.album_id = sa.album_id WHERE sr.sticker_id = ?1 AND sa.category = \'SYSTEM\' LIMIT 1', - variables: [ - Variable(stickerId) - ], - readsFrom: { - stickerRelationships, - stickerAlbums, - }).asyncMap(stickerAlbums.mapFromRow); - } + static TypeConverter $convertercreatedAt = + const MillisDateConverter(); + static TypeConverter $convertermediaStatus = + const MediaStatusTypeConverter(); + static TypeConverter $convertermediaCreatedAt = + const MillisDateConverter(); + static TypeConverter $convertermediaCreatedAtn = + NullAwareTypeConverter.wrap($convertermediaCreatedAt); + @override + List get customConstraints => + const ['PRIMARY KEY(transcript_id, message_id)']; + @override + bool get dontWriteConstraints => true; +} - Selectable basePinMessageItems(String conversationId, - BasePinMessageItems$order order, BasePinMessageItems$limit limit) { - var $arrayStartIndex = 2; - final generatedorder = $write( - order?.call( - alias(this.pinMessages, 'pinMessage'), - alias(this.messages, 'message'), - alias(this.users, 'sender'), - alias(this.users, 'participant'), - alias(this.snapshots, 'snapshot'), - alias(this.assets, 'asset'), - alias(this.chains, 'chain'), - alias(this.stickers, 'sticker'), - alias(this.hyperlinks, 'hyperlink'), - alias(this.users, 'sharedUser'), - alias(this.conversations, 'conversation'), - alias(this.messageMentions, 'messageMention'), - alias(this.expiredMessages, 'em')) ?? - const OrderBy.nothing(), - hasMultipleTables: true, - startIndex: $arrayStartIndex); - $arrayStartIndex += generatedorder.amountOfVariables; - final generatedlimit = $write( - limit( - alias(this.pinMessages, 'pinMessage'), - alias(this.messages, 'message'), - alias(this.users, 'sender'), - alias(this.users, 'participant'), - alias(this.snapshots, 'snapshot'), - alias(this.assets, 'asset'), - alias(this.chains, 'chain'), - alias(this.stickers, 'sticker'), - alias(this.hyperlinks, 'hyperlink'), - alias(this.users, 'sharedUser'), - alias(this.conversations, 'conversation'), - alias(this.messageMentions, 'messageMention'), - alias(this.expiredMessages, 'em')), - hasMultipleTables: true, - startIndex: $arrayStartIndex); - $arrayStartIndex += generatedlimit.amountOfVariables; - return customSelect( - 'SELECT message.message_id AS messageId, message.conversation_id AS conversationId, message.category AS type, message.content AS content, message.created_at AS createdAt, message.status AS status, message.media_status AS mediaStatus, message.media_waveform AS mediaWaveform, message.name AS mediaName, message.media_mime_type AS mediaMimeType, message.media_size AS mediaSize, message.media_width AS mediaWidth, message.media_height AS mediaHeight, message.thumb_image AS thumbImage, message.thumb_url AS thumbUrl, message.media_url AS mediaUrl, message.media_duration AS mediaDuration, message.quote_message_id AS quoteId, message.quote_content AS quoteContent, message."action" AS actionName, message.shared_user_id AS sharedUserId, sender.user_id AS userId, sender.full_name AS userFullName, sender.identity_number AS userIdentityNumber, sender.app_id AS appId, sender.relationship AS relationship, sender.avatar_url AS avatarUrl, sharedUser.full_name AS sharedUserFullName, sharedUser.identity_number AS sharedUserIdentityNumber, sharedUser.avatar_url AS sharedUserAvatarUrl, sharedUser.is_verified AS sharedUserIsVerified, sharedUser.app_id AS sharedUserAppId, conversation.owner_id AS conversationOwnerId, conversation.category AS conversionCategory, conversation.name AS groupName, sticker.asset_url AS assetUrl, sticker.asset_width AS assetWidth, sticker.asset_height AS assetHeight, sticker.sticker_id AS stickerId, sticker.name AS assetName, sticker.asset_type AS assetType, participant.full_name AS participantFullName, participant.user_id AS participantUserId, snapshot.snapshot_id AS snapshotId, snapshot.type AS snapshotType, snapshot.amount AS snapshotAmount, snapshot.asset_id AS assetId, asset.symbol AS assetSymbol, asset.icon_url AS assetIcon, chain.icon_url AS chainIcon, hyperlink.site_name AS siteName, hyperlink.site_title AS siteTitle, hyperlink.site_description AS siteDescription, hyperlink.site_image AS siteImage, messageMention.has_read AS mentionRead, em.expire_in AS expireIn, CASE WHEN pinMessage.message_id IS NOT NULL THEN TRUE ELSE FALSE END AS pinned FROM pin_messages AS pinMessage INNER JOIN messages AS message ON message.message_id = pinMessage.message_id INNER JOIN users AS sender ON message.user_id = sender.user_id LEFT JOIN users AS participant ON message.participant_id = participant.user_id LEFT JOIN snapshots AS snapshot ON message.snapshot_id = snapshot.snapshot_id LEFT JOIN assets AS asset ON snapshot.asset_id = asset.asset_id LEFT JOIN chains AS chain ON asset.chain_id = chain.chain_id LEFT JOIN stickers AS sticker ON sticker.sticker_id = message.sticker_id LEFT JOIN hyperlinks AS hyperlink ON message.hyperlink = hyperlink.hyperlink LEFT JOIN users AS sharedUser ON message.shared_user_id = sharedUser.user_id LEFT JOIN conversations AS conversation ON message.conversation_id = conversation.conversation_id LEFT JOIN message_mentions AS messageMention ON message.message_id = messageMention.message_id LEFT JOIN expired_messages AS em ON message.message_id = em.message_id WHERE pinMessage.conversation_id = ?1 ${generatedorder.sql} ${generatedlimit.sql}', - variables: [ - Variable(conversationId), - ...generatedorder.introducedVariables, - ...generatedlimit.introducedVariables - ], - readsFrom: { - messages, - users, - conversations, - stickers, - snapshots, - assets, - chains, - hyperlinks, - messageMentions, - expiredMessages, - pinMessages, - ...generatedorder.watchedTables, - ...generatedlimit.watchedTables, - }).map((QueryRow row) { - return MessageItem( - messageId: row.read('messageId'), - conversationId: row.read('conversationId'), - type: row.read('type'), - content: row.readNullable('content'), - createdAt: - Messages.$convertercreatedAt.fromSql(row.read('createdAt')), - status: Messages.$converterstatus.fromSql(row.read('status')), - mediaStatus: Messages.$convertermediaStatus - .fromSql(row.readNullable('mediaStatus')), - mediaWaveform: row.readNullable('mediaWaveform'), - mediaName: row.readNullable('mediaName'), - mediaMimeType: row.readNullable('mediaMimeType'), - mediaSize: row.readNullable('mediaSize'), - mediaWidth: row.readNullable('mediaWidth'), - mediaHeight: row.readNullable('mediaHeight'), - thumbImage: row.readNullable('thumbImage'), - thumbUrl: row.readNullable('thumbUrl'), - mediaUrl: row.readNullable('mediaUrl'), - mediaDuration: row.readNullable('mediaDuration'), - quoteId: row.readNullable('quoteId'), - quoteContent: row.readNullable('quoteContent'), - actionName: row.readNullable('actionName'), - sharedUserId: row.readNullable('sharedUserId'), - userId: row.read('userId'), - userFullName: row.readNullable('userFullName'), - userIdentityNumber: row.read('userIdentityNumber'), - appId: row.readNullable('appId'), - relationship: Users.$converterrelationship - .fromSql(row.readNullable('relationship')), - avatarUrl: row.readNullable('avatarUrl'), - sharedUserFullName: row.readNullable('sharedUserFullName'), - sharedUserIdentityNumber: - row.readNullable('sharedUserIdentityNumber'), - sharedUserAvatarUrl: row.readNullable('sharedUserAvatarUrl'), - sharedUserIsVerified: row.readNullable('sharedUserIsVerified'), - sharedUserAppId: row.readNullable('sharedUserAppId'), - conversationOwnerId: row.readNullable('conversationOwnerId'), - conversionCategory: Conversations.$convertercategory - .fromSql(row.readNullable('conversionCategory')), - groupName: row.readNullable('groupName'), - assetUrl: row.readNullable('assetUrl'), - assetWidth: row.readNullable('assetWidth'), - assetHeight: row.readNullable('assetHeight'), - stickerId: row.readNullable('stickerId'), - assetName: row.readNullable('assetName'), - assetType: row.readNullable('assetType'), - participantFullName: row.readNullable('participantFullName'), - participantUserId: row.readNullable('participantUserId'), - snapshotId: row.readNullable('snapshotId'), - snapshotType: row.readNullable('snapshotType'), - snapshotAmount: row.readNullable('snapshotAmount'), - assetId: row.readNullable('assetId'), - assetSymbol: row.readNullable('assetSymbol'), - assetIcon: row.readNullable('assetIcon'), - chainIcon: row.readNullable('chainIcon'), - siteName: row.readNullable('siteName'), - siteTitle: row.readNullable('siteTitle'), - siteDescription: row.readNullable('siteDescription'), - siteImage: row.readNullable('siteImage'), - mentionRead: row.readNullable('mentionRead'), - expireIn: row.readNullable('expireIn'), - pinned: row.read('pinned'), - ); - }); - } - - Selectable pinMessageItem( - String messageId, String conversationId) { - return customSelect( - 'SELECT message.content AS content, sender.full_name AS userFullName FROM messages AS message INNER JOIN pin_messages AS pinMessage ON ?1 = pinMessage.message_id INNER JOIN users AS sender ON message.user_id = sender.user_id WHERE message.conversation_id = ?2 AND message.category = \'MESSAGE_PIN\' AND message.quote_message_id = ?1 ORDER BY message.created_at DESC LIMIT 1', - variables: [ - Variable(messageId), - Variable(conversationId) - ], - readsFrom: { - messages, - users, - pinMessages, - }).map((QueryRow row) { - return PinMessageItemResult( - content: row.readNullable('content'), - userFullName: row.readNullable('userFullName'), - ); - }); - } - - Selectable pinMessageIds(String conversationId) { - return customSelect( - 'SELECT pinMessage.message_id FROM pin_messages AS pinMessage INNER JOIN messages AS message ON message.message_id = pinMessage.message_id WHERE pinMessage.conversation_id = ?1 ORDER BY message.created_at DESC', - variables: [ - Variable(conversationId) - ], - readsFrom: { - pinMessages, - messages, - }).map((QueryRow row) => row.read('message_id')); - } - - Selectable countPinMessages() { - return customSelect('SELECT COUNT(1) AS _c0 FROM pin_messages', - variables: [], - readsFrom: { - pinMessages, - }).map((QueryRow row) => row.read('_c0')); - } - - Selectable getLastBlazeMessageCreatedAt() { - return customSelect( - 'SELECT created_at FROM flood_messages ORDER BY created_at DESC LIMIT 1', - variables: [], - readsFrom: { - floodMessages, - }).map((QueryRow row) => - FloodMessages.$convertercreatedAt.fromSql(row.read('created_at'))); - } - - Selectable allCircles() { - return customSelect( - 'SELECT ci.circle_id, ci.name, ci.created_at, ci.ordered_at, COUNT(c.conversation_id) AS count, IFNULL(SUM(CASE WHEN IFNULL(c.unseen_message_count, 0) > 0 THEN 1 ELSE 0 END), 0) AS unseen_conversation_count, IFNULL(SUM(CASE WHEN(CASE WHEN c.category = \'GROUP\' THEN c.mute_until ELSE owner.mute_until END)>=(strftime(\'%s\', \'now\') * 1000)AND IFNULL(c.unseen_message_count, 0) > 0 THEN 1 ELSE 0 END), 0) AS unseen_muted_conversation_count FROM circles AS ci LEFT JOIN circle_conversations AS cc ON ci.circle_id = cc.circle_id LEFT JOIN conversations AS c ON c.conversation_id = cc.conversation_id LEFT JOIN users AS owner ON owner.user_id = c.owner_id GROUP BY ci.circle_id ORDER BY ci.ordered_at ASC, ci.created_at ASC', - variables: [], - readsFrom: { - circles, - conversations, - users, - circleConversations, - }).map((QueryRow row) { - return ConversationCircleItem( - circleId: row.read('circle_id'), - name: row.read('name'), - createdAt: - Circles.$convertercreatedAt.fromSql(row.read('created_at')), - orderedAt: NullAwareTypeConverter.wrapFromSql( - Circles.$converterorderedAt, row.readNullable('ordered_at')), - count: row.read('count'), - unseenConversationCount: row.read('unseen_conversation_count'), - unseenMutedConversationCount: - row.read('unseen_muted_conversation_count'), - ); - }); - } - - Selectable circleByConversationId( - String? conversationId) { - return customSelect( - 'SELECT ci.circle_id, ci.name, COUNT(c.conversation_id) AS count FROM circles AS ci LEFT JOIN circle_conversations AS cc ON ci.circle_id = cc.circle_id LEFT JOIN conversations AS c ON c.conversation_id = cc.conversation_id WHERE ci.circle_id IN (SELECT cir.circle_id FROM circles AS cir LEFT JOIN circle_conversations AS ccr ON cir.circle_id = ccr.circle_id WHERE ccr.conversation_id = ?1) GROUP BY ci.circle_id ORDER BY ci.ordered_at ASC, ci.created_at ASC', - variables: [ - Variable(conversationId) - ], - readsFrom: { - circles, - conversations, - circleConversations, - }).map((QueryRow row) { - return ConversationCircleManagerItem( - circleId: row.read('circle_id'), - name: row.read('name'), - count: row.read('count'), - ); - }); - } - - Selectable otherCircleByConversationId( - String? conversationId) { - return customSelect( - 'SELECT ci.circle_id, ci.name, COUNT(c.conversation_id) AS count FROM circles AS ci LEFT JOIN circle_conversations AS cc ON ci.circle_id = cc.circle_id LEFT JOIN conversations AS c ON c.conversation_id = cc.conversation_id WHERE ci.circle_id NOT IN (SELECT cir.circle_id FROM circles AS cir LEFT JOIN circle_conversations AS ccr ON cir.circle_id = ccr.circle_id WHERE ccr.conversation_id = ?1) GROUP BY ci.circle_id ORDER BY ci.ordered_at ASC, ci.created_at ASC', - variables: [ - Variable(conversationId) - ], - readsFrom: { - circles, - conversations, - circleConversations, - }).map((QueryRow row) { - return ConversationCircleManagerItem( - circleId: row.read('circle_id'), - name: row.read('name'), - count: row.read('count'), - ); - }); - } - - Selectable circlesNameByConversationId(String? conversationId) { - return customSelect( - 'SELECT ci.name FROM circles AS ci LEFT JOIN circle_conversations AS cc ON ci.circle_id = cc.circle_id LEFT JOIN conversations AS c ON c.conversation_id = cc.conversation_id WHERE cc.conversation_id = ?1', - variables: [ - Variable(conversationId) - ], - readsFrom: { - circles, - circleConversations, - conversations, - }).map((QueryRow row) => row.read('name')); - } - - Future deleteByCircleId(String circleId) { - return customUpdate( - 'DELETE FROM circle_conversations WHERE circle_id = ?1', - variables: [Variable(circleId)], - updates: {circleConversations}, - updateKind: UpdateKind.delete, - ); - } - - Future deleteByIds(String conversationId, String circleId) { - return customUpdate( - 'DELETE FROM circle_conversations WHERE conversation_id = ?1 AND circle_id = ?2', - variables: [Variable(conversationId), Variable(circleId)], - updates: {circleConversations}, - updateKind: UpdateKind.delete, - ); - } - - Selectable fuzzySearchBotGroupUser(String conversationId, - DateTime createdAt, String id, String username, String identityNumber) { - return customSelect( - 'SELECT u.* FROM users AS u WHERE(u.user_id IN (SELECT m.user_id FROM messages AS m WHERE conversation_id = ?1 AND m.created_at > ?2) OR u.user_id IN (SELECT f.user_id FROM users AS f WHERE relationship = \'FRIEND\'))AND u.user_id != ?3 AND u.identity_number != 0 AND(u.full_name LIKE \'%\' || ?4 || \'%\' ESCAPE \'\\\' OR u.identity_number LIKE \'%\' || ?5 || \'%\' ESCAPE \'\\\')ORDER BY CASE u.relationship WHEN \'FRIEND\' THEN 1 ELSE 2 END, u.relationship OR u.full_name = ?4 COLLATE NOCASE OR u.identity_number = ?5 COLLATE NOCASE DESC', - variables: [ - Variable(conversationId), - Variable(Messages.$convertercreatedAt.toSql(createdAt)), - Variable(id), - Variable(username), - Variable(identityNumber) - ], - readsFrom: { - users, - messages, - }).asyncMap(users.mapFromRow); - } - - Selectable fuzzySearchGroupUser(String id, String conversationId, - String username, String identityNumber) { - return customSelect( - 'SELECT u.* FROM participants AS p,users AS u WHERE u.user_id != ?1 AND p.conversation_id = ?2 AND p.user_id = u.user_id AND(u.full_name LIKE \'%\' || ?3 || \'%\' ESCAPE \'\\\' OR u.identity_number LIKE \'%\' || ?4 || \'%\' ESCAPE \'\\\')ORDER BY u.full_name = ?3 COLLATE NOCASE OR u.identity_number = ?4 COLLATE NOCASE DESC', - variables: [ - Variable(id), - Variable(conversationId), - Variable(username), - Variable(identityNumber) - ], - readsFrom: { - participants, - users, - }).asyncMap(users.mapFromRow); - } - - Selectable groupParticipants(String conversationId) { - return customSelect( - 'SELECT u.* FROM participants AS p,users AS u WHERE p.conversation_id = ?1 AND p.user_id = u.user_id', - variables: [ - Variable(conversationId) - ], - readsFrom: { - participants, - users, - }).asyncMap(users.mapFromRow); - } - - Selectable notInFriends(List filterIds) { - var $arrayStartIndex = 1; - final expandedfilterIds = $expandVar($arrayStartIndex, filterIds.length); - $arrayStartIndex += filterIds.length; - return customSelect( - 'SELECT * FROM users WHERE relationship = \'FRIEND\' AND user_id NOT IN ($expandedfilterIds) ORDER BY full_name, user_id ASC', - variables: [ - for (var $ in filterIds) Variable($) - ], - readsFrom: { - users, - }).asyncMap(users.mapFromRow); - } - - Selectable usersByIn(List userIds) { - var $arrayStartIndex = 1; - final expandeduserIds = $expandVar($arrayStartIndex, userIds.length); - $arrayStartIndex += userIds.length; - return customSelect( - 'SELECT * FROM users WHERE user_id IN ($expandeduserIds)', - variables: [ - for (var $ in userIds) Variable($) - ], - readsFrom: { - users, - }).asyncMap(users.mapFromRow); - } - - Selectable userIdsByIn(List userIds) { - var $arrayStartIndex = 1; - final expandeduserIds = $expandVar($arrayStartIndex, userIds.length); - $arrayStartIndex += userIds.length; - return customSelect( - 'SELECT user_id FROM users WHERE user_id IN ($expandeduserIds)', - variables: [ - for (var $ in userIds) Variable($) - ], - readsFrom: { - users, - }).map((QueryRow row) => row.read('user_id')); - } - - Selectable fuzzySearchUser( - FuzzySearchUser$firstFilter firstFilter, - String id, - String username, - String identityNumber, - FuzzySearchUser$lastFilter lastFilter) { - var $arrayStartIndex = 4; - final generatedfirstFilter = $write( - firstFilter(this.users, this.conversations), - hasMultipleTables: true, - startIndex: $arrayStartIndex); - $arrayStartIndex += generatedfirstFilter.amountOfVariables; - final generatedlastFilter = $write( - lastFilter(this.users, this.conversations), - hasMultipleTables: true, - startIndex: $arrayStartIndex); - $arrayStartIndex += generatedlastFilter.amountOfVariables; - return customSelect( - 'SELECT users.* FROM users LEFT JOIN conversations ON conversations.owner_id = user_id WHERE ${generatedfirstFilter.sql} AND user_id != ?1 AND relationship = \'FRIEND\' AND(full_name LIKE \'%\' || ?2 || \'%\' ESCAPE \'\\\' OR identity_number LIKE \' %\' || ?3 || \' %\' ESCAPE \'\\\')AND ${generatedlastFilter.sql} GROUP BY user_id ORDER BY full_name = ?2 COLLATE nocase OR identity_number = ?3 COLLATE nocase DESC', - variables: [ - Variable(id), - Variable(username), - Variable(identityNumber), - ...generatedfirstFilter.introducedVariables, - ...generatedlastFilter.introducedVariables - ], - readsFrom: { - users, - conversations, - ...generatedfirstFilter.watchedTables, - ...generatedlastFilter.watchedTables, - }).asyncMap(users.mapFromRow); - } - - Selectable fuzzySearchUserInCircle( - FuzzySearchUserInCircle$filter filter, - String id, - String username, - String identityNumber, - String? circleId) { - var $arrayStartIndex = 5; - final generatedfilter = $write( - filter(this.users, this.conversations, - alias(this.circleConversations, 'circleConversation')), - hasMultipleTables: true, - startIndex: $arrayStartIndex); - $arrayStartIndex += generatedfilter.amountOfVariables; - return customSelect( - 'SELECT users.* FROM users LEFT JOIN conversations ON conversations.owner_id = users.user_id LEFT JOIN circle_conversations AS circleConversation ON circleConversation.user_id = users.user_id WHERE ${generatedfilter.sql} AND users.user_id != ?1 AND relationship = \'FRIEND\' AND(full_name LIKE \'%\' || ?2 || \'%\' ESCAPE \'\\\' OR identity_number LIKE \' %\' || ?3 || \' %\' ESCAPE \'\\\')AND circleConversation.circle_id = ?4 GROUP BY users.user_id ORDER BY full_name = ?2 COLLATE nocase OR identity_number = ?3 COLLATE nocase DESC', - variables: [ - Variable(id), - Variable(username), - Variable(identityNumber), - Variable(circleId), - ...generatedfilter.introducedVariables - ], - readsFrom: { - users, - conversations, - circleConversations, - ...generatedfilter.watchedTables, - }).asyncMap(users.mapFromRow); - } - - Selectable biographyByIdentityNumber(String userId) { - return customSelect('SELECT biography FROM users WHERE user_id = ?1', - variables: [ - Variable(userId) - ], - readsFrom: { - users, - }).map((QueryRow row) => row.readNullable('biography')); - } - - Selectable userByIdentityNumbers(List numbers) { - var $arrayStartIndex = 1; - final expandednumbers = $expandVar($arrayStartIndex, numbers.length); - $arrayStartIndex += numbers.length; - return customSelect( - 'SELECT user_id, identity_number, full_name FROM users WHERE identity_number IN ($expandednumbers)', - variables: [ - for (var $ in numbers) Variable($) - ], - readsFrom: { - users, - }).map((QueryRow row) { - return MentionUser( - userId: row.read('user_id'), - identityNumber: row.read('identity_number'), - fullName: row.readNullable('full_name'), - ); - }); - } - - Selectable countUsers() { - return customSelect('SELECT COUNT(*) AS _c0 FROM users', - variables: [], - readsFrom: { - users, - }).map((QueryRow row) => row.read('_c0')); - } - - Selectable recentUsedStickers() { - return customSelect( - 'SELECT * FROM stickers WHERE last_use_at > 0 ORDER BY last_use_at DESC LIMIT 20', - variables: [], - readsFrom: { - stickers, - }).asyncMap(stickers.mapFromRow); - } - - Selectable stickersByCategory(String category) { - return customSelect( - 'SELECT s.* FROM sticker_albums AS sa INNER JOIN sticker_relationships AS sr ON sr.album_id = sa.album_id INNER JOIN stickers AS s ON sr.sticker_id = s.sticker_id WHERE sa.category = ?1 ORDER BY s.created_at DESC', - variables: [ - Variable(category) - ], - readsFrom: { - stickerAlbums, - stickerRelationships, - stickers, - }).asyncMap(stickers.mapFromRow); - } - - Selectable countStickers() { - return customSelect('SELECT COUNT(1) AS _c0 FROM stickers', - variables: [], - readsFrom: { - stickers, - }).map((QueryRow row) => row.read('_c0')); - } - - Selectable participantsAvatar(String conversationId) { - return customSelect( - 'SELECT user.* FROM participants AS participant INNER JOIN users AS user ON participant.user_id = user.user_id WHERE participant.conversation_id = ?1 ORDER BY participant.created_at ASC LIMIT 4', - variables: [ - Variable(conversationId) - ], - readsFrom: { - participants, - users, - }).asyncMap(users.mapFromRow); - } - - Selectable participantSessionKeyWithoutSelf( - String conversationId, String userId) { - return customSelect( - 'SELECT conversation_id, user_id, session_id, public_key FROM participant_session WHERE conversation_id = ?1 AND user_id != ?2 LIMIT 1', - variables: [ - Variable(conversationId), - Variable(userId) - ], - readsFrom: { - participantSession, - }).map((QueryRow row) { - return ParticipantSessionKey( - conversationId: row.read('conversation_id'), - userId: row.read('user_id'), - sessionId: row.read('session_id'), - publicKey: row.readNullable('public_key'), - ); - }); - } - - Selectable otherParticipantSessionKey( - String conversationId, String userId, String sessionId) { - return customSelect( - 'SELECT conversation_id, user_id, session_id, public_key FROM participant_session WHERE conversation_id = ?1 AND user_id == ?2 AND session_id != ?3 ORDER BY created_at DESC LIMIT 1', - variables: [ - Variable(conversationId), - Variable(userId), - Variable(sessionId) - ], - readsFrom: { - participantSession, - }).map((QueryRow row) { - return ParticipantSessionKey( - conversationId: row.read('conversation_id'), - userId: row.read('user_id'), - sessionId: row.read('session_id'), - publicKey: row.readNullable('public_key'), - ); - }); - } - - Selectable notSendSessionParticipants( - String conversationId, String sessionId) { - return customSelect( - 'SELECT p.* FROM participant_session AS p LEFT JOIN users AS u ON p.user_id = u.user_id WHERE p.conversation_id = ?1 AND p.session_id != ?2 AND u.app_id IS NULL AND p.sent_to_server IS NULL', - variables: [ - Variable(conversationId), - Variable(sessionId) - ], - readsFrom: { - participantSession, - users, - }).asyncMap(participantSession.mapFromRow); - } - - Selectable participantSessionKeyBySessionId( - String conversationId, String sessionId) { - return customSelect( - 'SELECT * FROM participant_session WHERE conversation_id = ?1 AND session_id == ?2', - variables: [ - Variable(conversationId), - Variable(sessionId) - ], - readsFrom: { - participantSession, - }).asyncMap(participantSession.mapFromRow); - } - - Selectable groupParticipantsByConversationId( - String conversationId) { - return customSelect( - 'SELECT p.conversation_id AS conversationId, p.role AS role, p.created_at AS createdAt, u.user_id AS userId, u.identity_number AS identityNumber, u.relationship AS relationship, u.biography AS biography, u.full_name AS fullName, u.avatar_url AS avatarUrl, u.phone AS phone, u.is_verified AS isVerified, u.created_at AS userCreatedAt, u.mute_until AS muteUntil, u.has_pin AS hasPin, u.app_id AS appId, u.is_scam AS isScam FROM participants AS p,users AS u WHERE p.conversation_id = ?1 AND p.user_id = u.user_id ORDER BY p.created_at DESC', - variables: [ - Variable(conversationId) - ], - readsFrom: { - participants, - users, - }).map((QueryRow row) { - return ParticipantUser( - conversationId: row.read('conversationId'), - role: Participants.$converterrole - .fromSql(row.readNullable('role')), - createdAt: Participants.$convertercreatedAt - .fromSql(row.read('createdAt')), - userId: row.read('userId'), - identityNumber: row.read('identityNumber'), - relationship: Users.$converterrelationship - .fromSql(row.readNullable('relationship')), - biography: row.readNullable('biography'), - fullName: row.readNullable('fullName'), - avatarUrl: row.readNullable('avatarUrl'), - phone: row.readNullable('phone'), - isVerified: row.readNullable('isVerified'), - userCreatedAt: NullAwareTypeConverter.wrapFromSql( - Users.$convertercreatedAt, row.readNullable('userCreatedAt')), - muteUntil: NullAwareTypeConverter.wrapFromSql( - Users.$convertermuteUntil, row.readNullable('muteUntil')), - hasPin: row.readNullable('hasPin'), - appId: row.readNullable('appId'), - isScam: row.readNullable('isScam'), - ); - }); - } - - Selectable userIdByIdentityNumber( - String conversationId, String identityNumber) { - return customSelect( - 'SELECT u.user_id FROM users AS u INNER JOIN participants AS p ON p.user_id = u.user_id WHERE p.conversation_id = ?1 AND u.identity_number = ?2', - variables: [ - Variable(conversationId), - Variable(identityNumber) - ], - readsFrom: { - users, - participants, - }).map((QueryRow row) => row.read('user_id')); - } - - Selectable countParticipants() { - return customSelect('SELECT COUNT(1) AS _c0 FROM participants', - variables: [], - readsFrom: { - participants, - }).map((QueryRow row) => row.read('_c0')); - } - - Selectable baseMessageItems(BaseMessageItems$where where, - BaseMessageItems$order order, BaseMessageItems$limit limit) { - var $arrayStartIndex = 1; - final generatedwhere = $write( - where( - alias(this.messages, 'message'), - alias(this.users, 'sender'), - alias(this.users, 'participant'), - alias(this.snapshots, 'snapshot'), - alias(this.assets, 'asset'), - alias(this.chains, 'chain'), - alias(this.stickers, 'sticker'), - alias(this.hyperlinks, 'hyperlink'), - alias(this.users, 'sharedUser'), - alias(this.conversations, 'conversation'), - alias(this.messageMentions, 'messageMention'), - alias(this.pinMessages, 'pinMessage'), - alias(this.expiredMessages, 'em')), - hasMultipleTables: true, - startIndex: $arrayStartIndex); - $arrayStartIndex += generatedwhere.amountOfVariables; - final generatedorder = $write( - order?.call( - alias(this.messages, 'message'), - alias(this.users, 'sender'), - alias(this.users, 'participant'), - alias(this.snapshots, 'snapshot'), - alias(this.assets, 'asset'), - alias(this.chains, 'chain'), - alias(this.stickers, 'sticker'), - alias(this.hyperlinks, 'hyperlink'), - alias(this.users, 'sharedUser'), - alias(this.conversations, 'conversation'), - alias(this.messageMentions, 'messageMention'), - alias(this.pinMessages, 'pinMessage'), - alias(this.expiredMessages, 'em')) ?? - const OrderBy.nothing(), - hasMultipleTables: true, - startIndex: $arrayStartIndex); - $arrayStartIndex += generatedorder.amountOfVariables; - final generatedlimit = $write( - limit( - alias(this.messages, 'message'), - alias(this.users, 'sender'), - alias(this.users, 'participant'), - alias(this.snapshots, 'snapshot'), - alias(this.assets, 'asset'), - alias(this.chains, 'chain'), - alias(this.stickers, 'sticker'), - alias(this.hyperlinks, 'hyperlink'), - alias(this.users, 'sharedUser'), - alias(this.conversations, 'conversation'), - alias(this.messageMentions, 'messageMention'), - alias(this.pinMessages, 'pinMessage'), - alias(this.expiredMessages, 'em')), - hasMultipleTables: true, - startIndex: $arrayStartIndex); - $arrayStartIndex += generatedlimit.amountOfVariables; - return customSelect( - 'SELECT message.message_id AS messageId, message.conversation_id AS conversationId, message.category AS type, message.content AS content, message.created_at AS createdAt, message.status AS status, message.media_status AS mediaStatus, message.media_waveform AS mediaWaveform, message.name AS mediaName, message.media_mime_type AS mediaMimeType, message.media_size AS mediaSize, message.media_width AS mediaWidth, message.media_height AS mediaHeight, message.thumb_image AS thumbImage, message.thumb_url AS thumbUrl, message.media_url AS mediaUrl, message.media_duration AS mediaDuration, message.quote_message_id AS quoteId, message.quote_content AS quoteContent, message."action" AS actionName, message.shared_user_id AS sharedUserId, message.sticker_id AS stickerId, sender.user_id AS userId, sender.full_name AS userFullName, sender.identity_number AS userIdentityNumber, sender.app_id AS appId, sender.relationship AS relationship, sender.avatar_url AS avatarUrl, sharedUser.full_name AS sharedUserFullName, sharedUser.identity_number AS sharedUserIdentityNumber, sharedUser.avatar_url AS sharedUserAvatarUrl, sharedUser.is_verified AS sharedUserIsVerified, sharedUser.app_id AS sharedUserAppId, conversation.owner_id AS conversationOwnerId, conversation.category AS conversionCategory, conversation.name AS groupName, sticker.asset_url AS assetUrl, sticker.asset_width AS assetWidth, sticker.asset_height AS assetHeight, sticker.name AS assetName, sticker.asset_type AS assetType, participant.full_name AS participantFullName, participant.user_id AS participantUserId, snapshot.snapshot_id AS snapshotId, snapshot.type AS snapshotType, snapshot.amount AS snapshotAmount, snapshot.asset_id AS assetId, asset.symbol AS assetSymbol, asset.icon_url AS assetIcon, chain.icon_url AS chainIcon, hyperlink.site_name AS siteName, hyperlink.site_title AS siteTitle, hyperlink.site_description AS siteDescription, hyperlink.site_image AS siteImage, messageMention.has_read AS mentionRead, em.expire_in AS expireIn, CASE WHEN pinMessage.message_id IS NOT NULL THEN TRUE ELSE FALSE END AS pinned FROM messages AS message INNER JOIN users AS sender ON message.user_id = sender.user_id LEFT JOIN users AS participant ON message.participant_id = participant.user_id LEFT JOIN snapshots AS snapshot ON message.snapshot_id = snapshot.snapshot_id LEFT JOIN assets AS asset ON snapshot.asset_id = asset.asset_id LEFT JOIN chains AS chain ON asset.chain_id = chain.chain_id LEFT JOIN stickers AS sticker ON sticker.sticker_id = message.sticker_id LEFT JOIN hyperlinks AS hyperlink ON message.hyperlink = hyperlink.hyperlink LEFT JOIN users AS sharedUser ON message.shared_user_id = sharedUser.user_id LEFT JOIN conversations AS conversation ON message.conversation_id = conversation.conversation_id LEFT JOIN message_mentions AS messageMention ON message.message_id = messageMention.message_id LEFT JOIN pin_messages AS pinMessage ON message.message_id = pinMessage.message_id LEFT JOIN expired_messages AS em ON message.message_id = em.message_id WHERE ${generatedwhere.sql} ${generatedorder.sql} ${generatedlimit.sql}', - variables: [ - ...generatedwhere.introducedVariables, - ...generatedorder.introducedVariables, - ...generatedlimit.introducedVariables - ], - readsFrom: { - messages, - users, - conversations, - stickers, - snapshots, - assets, - chains, - hyperlinks, - messageMentions, - expiredMessages, - pinMessages, - ...generatedwhere.watchedTables, - ...generatedorder.watchedTables, - ...generatedlimit.watchedTables, - }).map((QueryRow row) { - return MessageItem( - messageId: row.read('messageId'), - conversationId: row.read('conversationId'), - type: row.read('type'), - content: row.readNullable('content'), - createdAt: - Messages.$convertercreatedAt.fromSql(row.read('createdAt')), - status: Messages.$converterstatus.fromSql(row.read('status')), - mediaStatus: Messages.$convertermediaStatus - .fromSql(row.readNullable('mediaStatus')), - mediaWaveform: row.readNullable('mediaWaveform'), - mediaName: row.readNullable('mediaName'), - mediaMimeType: row.readNullable('mediaMimeType'), - mediaSize: row.readNullable('mediaSize'), - mediaWidth: row.readNullable('mediaWidth'), - mediaHeight: row.readNullable('mediaHeight'), - thumbImage: row.readNullable('thumbImage'), - thumbUrl: row.readNullable('thumbUrl'), - mediaUrl: row.readNullable('mediaUrl'), - mediaDuration: row.readNullable('mediaDuration'), - quoteId: row.readNullable('quoteId'), - quoteContent: row.readNullable('quoteContent'), - actionName: row.readNullable('actionName'), - sharedUserId: row.readNullable('sharedUserId'), - userId: row.read('userId'), - userFullName: row.readNullable('userFullName'), - userIdentityNumber: row.read('userIdentityNumber'), - appId: row.readNullable('appId'), - relationship: Users.$converterrelationship - .fromSql(row.readNullable('relationship')), - avatarUrl: row.readNullable('avatarUrl'), - sharedUserFullName: row.readNullable('sharedUserFullName'), - sharedUserIdentityNumber: - row.readNullable('sharedUserIdentityNumber'), - sharedUserAvatarUrl: row.readNullable('sharedUserAvatarUrl'), - sharedUserIsVerified: row.readNullable('sharedUserIsVerified'), - sharedUserAppId: row.readNullable('sharedUserAppId'), - conversationOwnerId: row.readNullable('conversationOwnerId'), - conversionCategory: Conversations.$convertercategory - .fromSql(row.readNullable('conversionCategory')), - groupName: row.readNullable('groupName'), - assetUrl: row.readNullable('assetUrl'), - assetWidth: row.readNullable('assetWidth'), - assetHeight: row.readNullable('assetHeight'), - stickerId: row.readNullable('stickerId'), - assetName: row.readNullable('assetName'), - assetType: row.readNullable('assetType'), - participantFullName: row.readNullable('participantFullName'), - participantUserId: row.readNullable('participantUserId'), - snapshotId: row.readNullable('snapshotId'), - snapshotType: row.readNullable('snapshotType'), - snapshotAmount: row.readNullable('snapshotAmount'), - assetId: row.readNullable('assetId'), - assetSymbol: row.readNullable('assetSymbol'), - assetIcon: row.readNullable('assetIcon'), - chainIcon: row.readNullable('chainIcon'), - siteName: row.readNullable('siteName'), - siteTitle: row.readNullable('siteTitle'), - siteDescription: row.readNullable('siteDescription'), - siteImage: row.readNullable('siteImage'), - mentionRead: row.readNullable('mentionRead'), - expireIn: row.readNullable('expireIn'), - pinned: row.read('pinned'), - ); - }); - } - - Selectable baseQuoteMessageItem( - BaseQuoteMessageItem$where where, - BaseQuoteMessageItem$order order, - BaseQuoteMessageItem$limit limit) { - var $arrayStartIndex = 1; - final generatedwhere = $write( - where( - alias(this.messages, 'message'), - alias(this.users, 'sender'), - alias(this.stickers, 'sticker'), - alias(this.users, 'shareUser'), - alias(this.messageMentions, 'messageMention')), - hasMultipleTables: true, - startIndex: $arrayStartIndex); - $arrayStartIndex += generatedwhere.amountOfVariables; - final generatedorder = $write( - order?.call( - alias(this.messages, 'message'), - alias(this.users, 'sender'), - alias(this.stickers, 'sticker'), - alias(this.users, 'shareUser'), - alias(this.messageMentions, 'messageMention')) ?? - const OrderBy.nothing(), - hasMultipleTables: true, - startIndex: $arrayStartIndex); - $arrayStartIndex += generatedorder.amountOfVariables; - final generatedlimit = $write( - limit( - alias(this.messages, 'message'), - alias(this.users, 'sender'), - alias(this.stickers, 'sticker'), - alias(this.users, 'shareUser'), - alias(this.messageMentions, 'messageMention')), - hasMultipleTables: true, - startIndex: $arrayStartIndex); - $arrayStartIndex += generatedlimit.amountOfVariables; - return customSelect( - 'SELECT message.message_id AS messageId, message.conversation_id AS conversationId, sender.user_id AS userId, sender.full_name AS userFullName, sender.identity_number AS userIdentityNumber, sender.app_id AS appId, message.category AS type, message.content AS content, message.created_at AS createdAt, message.status AS status, message.media_status AS mediaStatus, message.media_waveform AS mediaWaveform, message.name AS mediaName, message.media_mime_type AS mediaMimeType, message.media_size AS mediaSize, message.media_width AS mediaWidth, message.media_height AS mediaHeight, message.thumb_image AS thumbImage, message.thumb_url AS thumbUrl, message.media_url AS mediaUrl, message.media_duration AS mediaDuration, message.sticker_id AS stickerId, sticker.asset_url AS assetUrl, sticker.asset_width AS assetWidth, sticker.asset_height AS assetHeight, sticker.name AS assetName, sticker.asset_type AS assetType, message.shared_user_id AS sharedUserId, shareUser.full_name AS sharedUserFullName, shareUser.identity_number AS sharedUserIdentityNumber, shareUser.avatar_url AS sharedUserAvatarUrl, shareUser.is_verified AS sharedUserIsVerified, shareUser.app_id AS sharedUserAppId FROM messages AS message INNER JOIN users AS sender ON message.user_id = sender.user_id LEFT JOIN stickers AS sticker ON sticker.sticker_id = message.sticker_id LEFT JOIN users AS shareUser ON message.shared_user_id = shareUser.user_id LEFT JOIN message_mentions AS messageMention ON message.message_id = messageMention.message_id WHERE ${generatedwhere.sql} ${generatedorder.sql} ${generatedlimit.sql}', - variables: [ - ...generatedwhere.introducedVariables, - ...generatedorder.introducedVariables, - ...generatedlimit.introducedVariables - ], - readsFrom: { - messages, - users, - stickers, - messageMentions, - ...generatedwhere.watchedTables, - ...generatedorder.watchedTables, - ...generatedlimit.watchedTables, - }).map((QueryRow row) { - return QuoteMessageItem( - messageId: row.read('messageId'), - conversationId: row.read('conversationId'), - userId: row.read('userId'), - userFullName: row.readNullable('userFullName'), - userIdentityNumber: row.read('userIdentityNumber'), - appId: row.readNullable('appId'), - type: row.read('type'), - content: row.readNullable('content'), - createdAt: - Messages.$convertercreatedAt.fromSql(row.read('createdAt')), - status: Messages.$converterstatus.fromSql(row.read('status')), - mediaStatus: Messages.$convertermediaStatus - .fromSql(row.readNullable('mediaStatus')), - mediaWaveform: row.readNullable('mediaWaveform'), - mediaName: row.readNullable('mediaName'), - mediaMimeType: row.readNullable('mediaMimeType'), - mediaSize: row.readNullable('mediaSize'), - mediaWidth: row.readNullable('mediaWidth'), - mediaHeight: row.readNullable('mediaHeight'), - thumbImage: row.readNullable('thumbImage'), - thumbUrl: row.readNullable('thumbUrl'), - mediaUrl: row.readNullable('mediaUrl'), - mediaDuration: row.readNullable('mediaDuration'), - stickerId: row.readNullable('stickerId'), - assetUrl: row.readNullable('assetUrl'), - assetWidth: row.readNullable('assetWidth'), - assetHeight: row.readNullable('assetHeight'), - assetName: row.readNullable('assetName'), - assetType: row.readNullable('assetType'), - sharedUserId: row.readNullable('sharedUserId'), - sharedUserFullName: row.readNullable('sharedUserFullName'), - sharedUserIdentityNumber: - row.readNullable('sharedUserIdentityNumber'), - sharedUserAvatarUrl: row.readNullable('sharedUserAvatarUrl'), - sharedUserIsVerified: row.readNullable('sharedUserIsVerified'), - sharedUserAppId: row.readNullable('sharedUserAppId'), - ); - }); - } - - Selectable findMessageStatusById(String messageId) { - return customSelect( - 'SELECT status FROM messages WHERE message_id = ?1 LIMIT 1', - variables: [ - Variable(messageId) - ], - readsFrom: { - messages, - }).map((QueryRow row) => - Messages.$converterstatus.fromSql(row.read('status'))); - } - - Selectable sendingMessage(String messageId) { - return customSelect( - 'SELECT m.message_id, m.conversation_id, m.user_id, m.category, m.content, m.media_url, m.media_mime_type, m.media_size, m.media_duration, m.media_width, m.media_height, m.media_hash, m.thumb_image, m.media_key, m.media_digest, m.media_status, m.status, m.created_at, m."action", m.participant_id, m.snapshot_id, m.hyperlink, m.name, m.album_id, m.sticker_id, m.shared_user_id, m.media_waveform, m.quote_message_id, m.quote_content, rm.status AS resend_status, rm.user_id AS resend_user_id, rm.session_id AS resend_session_id FROM messages AS m LEFT JOIN resend_session_messages AS rm ON m.message_id = rm.message_id WHERE m.message_id = ?1 AND(m.status = \'SENDING\' OR rm.status = 1)AND m.content IS NOT NULL LIMIT 1', - variables: [ - Variable(messageId) - ], - readsFrom: { - messages, - resendSessionMessages, - }).map((QueryRow row) { - return SendingMessage( - messageId: row.read('message_id'), - conversationId: row.read('conversation_id'), - userId: row.read('user_id'), - category: row.read('category'), - content: row.readNullable('content'), - mediaUrl: row.readNullable('media_url'), - mediaMimeType: row.readNullable('media_mime_type'), - mediaSize: row.readNullable('media_size'), - mediaDuration: row.readNullable('media_duration'), - mediaWidth: row.readNullable('media_width'), - mediaHeight: row.readNullable('media_height'), - mediaHash: row.readNullable('media_hash'), - thumbImage: row.readNullable('thumb_image'), - mediaKey: row.readNullable('media_key'), - mediaDigest: row.readNullable('media_digest'), - mediaStatus: Messages.$convertermediaStatus - .fromSql(row.readNullable('media_status')), - status: Messages.$converterstatus.fromSql(row.read('status')), - createdAt: - Messages.$convertercreatedAt.fromSql(row.read('created_at')), - action: row.readNullable('action'), - participantId: row.readNullable('participant_id'), - snapshotId: row.readNullable('snapshot_id'), - hyperlink: row.readNullable('hyperlink'), - name: row.readNullable('name'), - albumId: row.readNullable('album_id'), - stickerId: row.readNullable('sticker_id'), - sharedUserId: row.readNullable('shared_user_id'), - mediaWaveform: row.readNullable('media_waveform'), - quoteMessageId: row.readNullable('quote_message_id'), - quoteContent: row.readNullable('quote_content'), - resendStatus: row.readNullable('resend_status'), - resendUserId: row.readNullable('resend_user_id'), - resendSessionId: row.readNullable('resend_session_id'), - ); - }); - } - - Selectable notificationMessage(List messageId) { - var $arrayStartIndex = 1; - final expandedmessageId = $expandVar($arrayStartIndex, messageId.length); - $arrayStartIndex += messageId.length; - return customSelect( - 'SELECT m.message_id AS messageId, m.conversation_id AS conversationId, sender.user_id AS senderId, sender.full_name AS senderFullName, m.category AS type, m.content AS content, m.quote_content AS quoteContent, m.status AS status, c.name AS groupName, c.mute_until AS muteUntil, conversationOwner.mute_until AS ownerMuteUntil, conversationOwner.user_id AS ownerUserId, conversationOwner.full_name AS ownerFullName, m.created_at AS createdAt, c.category AS category, m."action" AS actionName, conversationOwner.relationship AS relationship, pu.full_name AS participantFullName, pu.user_id AS participantUserId FROM messages AS m INNER JOIN users AS sender ON m.user_id = sender.user_id LEFT JOIN conversations AS c ON m.conversation_id = c.conversation_id LEFT JOIN users AS conversationOwner ON c.owner_id = conversationOwner.user_id LEFT JOIN message_mentions AS mm ON m.message_id = mm.message_id LEFT JOIN users AS pu ON pu.user_id = m.participant_id WHERE m.message_id IN ($expandedmessageId) ORDER BY m.created_at DESC', - variables: [ - for (var $ in messageId) Variable($) - ], - readsFrom: { - messages, - users, - conversations, - messageMentions, - }).map((QueryRow row) { - return NotificationMessage( - messageId: row.read('messageId'), - conversationId: row.read('conversationId'), - senderId: row.read('senderId'), - senderFullName: row.readNullable('senderFullName'), - type: row.read('type'), - content: row.readNullable('content'), - quoteContent: row.readNullable('quoteContent'), - status: Messages.$converterstatus.fromSql(row.read('status')), - groupName: row.readNullable('groupName'), - muteUntil: NullAwareTypeConverter.wrapFromSql( - Conversations.$convertermuteUntil, - row.readNullable('muteUntil')), - ownerMuteUntil: NullAwareTypeConverter.wrapFromSql( - Users.$convertermuteUntil, row.readNullable('ownerMuteUntil')), - ownerUserId: row.readNullable('ownerUserId'), - ownerFullName: row.readNullable('ownerFullName'), - createdAt: - Messages.$convertercreatedAt.fromSql(row.read('createdAt')), - category: Conversations.$convertercategory - .fromSql(row.readNullable('category')), - actionName: row.readNullable('actionName'), - relationship: Users.$converterrelationship - .fromSql(row.readNullable('relationship')), - participantFullName: row.readNullable('participantFullName'), - participantUserId: row.readNullable('participantUserId'), - ); - }); - } - - Future updateUnseenMessageCountAndLastMessageId(String conversationId, - String userId, String? lastMessageId, DateTime? lastMessageCreatedAt) { - return customUpdate( - 'UPDATE conversations SET unseen_message_count = (SELECT count(1) FROM messages WHERE conversation_id = ?1 AND status IN (\'SENT\', \'DELIVERED\') AND user_id != ?2), last_message_id = ?3, last_message_created_at = ?4 WHERE conversation_id = ?1', - variables: [ - Variable(conversationId), - Variable(userId), - Variable(lastMessageId), - Variable(NullAwareTypeConverter.wrapToSql( - Conversations.$converterlastMessageCreatedAt, lastMessageCreatedAt)) - ], - updates: {conversations}, - updateKind: UpdateKind.update, - ); - } - - Selectable getSearchMessageByIds( - List messageIds) { - var $arrayStartIndex = 1; - final expandedmessageIds = $expandVar($arrayStartIndex, messageIds.length); - $arrayStartIndex += messageIds.length; - return customSelect( - 'SELECT m.message_id AS messageId, u.user_id AS senderId, u.avatar_url AS senderAvatarUrl, u.full_name AS senderFullName, m.status AS status, m.category AS type, m.content AS content, m.created_at AS createdAt, m.name AS mediaName, u.app_id AS appId, u.is_verified AS verified, c.owner_id AS ownerId, c.icon_url AS groupIconUrl, c.category AS category, c.name AS groupName, c.conversation_id AS conversationId, owner.full_name AS ownerFullName, owner.avatar_url AS ownerAvatarUrl FROM messages AS m INNER JOIN conversations AS c ON c.conversation_id = m.conversation_id INNER JOIN users AS u ON m.user_id = u.user_id INNER JOIN users AS owner ON c.owner_id = owner.user_id WHERE m.message_id IN ($expandedmessageIds) ORDER BY m.created_at DESC, m."rowid" DESC', - variables: [ - for (var $ in messageIds) Variable($) - ], - readsFrom: { - messages, - users, - conversations, - }).map((QueryRow row) { - return SearchMessageDetailItem( - messageId: row.read('messageId'), - senderId: row.read('senderId'), - senderAvatarUrl: row.readNullable('senderAvatarUrl'), - senderFullName: row.readNullable('senderFullName'), - status: Messages.$converterstatus.fromSql(row.read('status')), - type: row.read('type'), - content: row.readNullable('content'), - createdAt: - Messages.$convertercreatedAt.fromSql(row.read('createdAt')), - mediaName: row.readNullable('mediaName'), - appId: row.readNullable('appId'), - verified: row.readNullable('verified'), - ownerId: row.readNullable('ownerId'), - groupIconUrl: row.readNullable('groupIconUrl'), - category: Conversations.$convertercategory - .fromSql(row.readNullable('category')), - groupName: row.readNullable('groupName'), - conversationId: row.read('conversationId'), - ownerFullName: row.readNullable('ownerFullName'), - ownerAvatarUrl: row.readNullable('ownerAvatarUrl'), - ); - }); - } - - Selectable miniMessageByIds(List messageIds) { - var $arrayStartIndex = 1; - final expandedmessageIds = $expandVar($arrayStartIndex, messageIds.length); - $arrayStartIndex += messageIds.length; - return customSelect( - 'SELECT conversation_id AS conversationId, message_id AS messageId FROM messages WHERE message_id IN ($expandedmessageIds)', - variables: [ - for (var $ in messageIds) Variable($) - ], - readsFrom: { - messages, - }).map((QueryRow row) { - return MiniMessageItem( - conversationId: row.read('conversationId'), - messageId: row.read('messageId'), - ); - }); - } - - Selectable searchMessage( - SearchMessage$where where, SearchMessage$limit limit) { - var $arrayStartIndex = 1; - final generatedwhere = $write( - where(alias(this.messages, 'm'), alias(this.conversations, 'c'), - alias(this.users, 'u'), alias(this.users, 'owner')), - hasMultipleTables: true, - startIndex: $arrayStartIndex); - $arrayStartIndex += generatedwhere.amountOfVariables; - final generatedlimit = $write( - limit(alias(this.messages, 'm'), alias(this.conversations, 'c'), - alias(this.users, 'u'), alias(this.users, 'owner')), - hasMultipleTables: true, - startIndex: $arrayStartIndex); - $arrayStartIndex += generatedlimit.amountOfVariables; - return customSelect( - 'SELECT m.message_id AS messageId, u.user_id AS senderId, u.avatar_url AS senderAvatarUrl, u.full_name AS senderFullName, m.status AS status, m.category AS type, m.content AS content, m.created_at AS createdAt, m.name AS mediaName, u.app_id AS appId, u.is_verified AS verified, c.owner_id AS ownerId, c.icon_url AS groupIconUrl, c.category AS category, c.name AS groupName, c.conversation_id AS conversationId, owner.full_name AS ownerFullName, owner.avatar_url AS ownerAvatarUrl FROM messages AS m INNER JOIN conversations AS c ON c.conversation_id = m.conversation_id INNER JOIN users AS u ON m.user_id = u.user_id INNER JOIN users AS owner ON c.owner_id = owner.user_id WHERE ${generatedwhere.sql} ORDER BY m.created_at DESC, m."rowid" DESC ${generatedlimit.sql}', - variables: [ - ...generatedwhere.introducedVariables, - ...generatedlimit.introducedVariables - ], - readsFrom: { - messages, - users, - conversations, - ...generatedwhere.watchedTables, - ...generatedlimit.watchedTables, - }).map((QueryRow row) { - return SearchMessageDetailItem( - messageId: row.read('messageId'), - senderId: row.read('senderId'), - senderAvatarUrl: row.readNullable('senderAvatarUrl'), - senderFullName: row.readNullable('senderFullName'), - status: Messages.$converterstatus.fromSql(row.read('status')), - type: row.read('type'), - content: row.readNullable('content'), - createdAt: - Messages.$convertercreatedAt.fromSql(row.read('createdAt')), - mediaName: row.readNullable('mediaName'), - appId: row.readNullable('appId'), - verified: row.readNullable('verified'), - ownerId: row.readNullable('ownerId'), - groupIconUrl: row.readNullable('groupIconUrl'), - category: Conversations.$convertercategory - .fromSql(row.readNullable('category')), - groupName: row.readNullable('groupName'), - conversationId: row.read('conversationId'), - ownerFullName: row.readNullable('ownerFullName'), - ownerAvatarUrl: row.readNullable('ownerAvatarUrl'), - ); - }); - } - - Selectable countMessages() { - return customSelect('SELECT count(1) AS _c0 FROM messages', - variables: [], - readsFrom: { - messages, - }).map((QueryRow row) => row.read('_c0')); - } - - Selectable countMediaMessages() { - return customSelect( - 'SELECT count(1) AS _c0 FROM messages WHERE category IN (\'SIGNAL_IMAGE\', \'SIGNAL_VIDEO\', \'SIGNAL_DATA\', \'SIGNAL_AUDIO\', \'PLAIN_IMAGE\', \'PLAIN_VIDEO\', \'PLAIN_DATA\', \'PLAIN_AUDIO\', \'ENCRYPTED_IMAGE\', \'ENCRYPTED_VIDEO\', \'ENCRYPTED_DATA\', \'ENCRYPTED_AUDIO\')', - variables: [], - readsFrom: { - messages, - }).map((QueryRow row) => row.read('_c0')); - } - - Selectable findBigQuoteMessage(int rowId, int limit) { - return customSelect( - 'SELECT "rowid", conversation_id, quote_message_id FROM messages WHERE "rowid" > ?1 AND quote_message_id IS NOT NULL AND quote_message_id != \'\' AND length(quote_content) > 10240 GROUP BY quote_message_id ORDER BY "rowid" ASC LIMIT ?2', - variables: [ - Variable(rowId), - Variable(limit) - ], - readsFrom: { - messages, - }).map((QueryRow row) { - return QuoteMinimal( - rowid: row.read('rowid'), - conversationId: row.read('conversation_id'), - quoteMessageId: row.readNullable('quote_message_id'), - ); - }); - } - - Selectable baseConversationItemCount( - BaseConversationItemCount$where where) { - var $arrayStartIndex = 1; - final generatedwhere = $write( - where( - alias(this.conversations, 'conversation'), - alias(this.users, 'owner'), - alias(this.circleConversations, 'circleConversation')), - hasMultipleTables: true, - startIndex: $arrayStartIndex); - $arrayStartIndex += generatedwhere.amountOfVariables; - return customSelect( - 'SELECT COUNT(DISTINCT conversation.conversation_id) AS _c0 FROM conversations AS conversation INNER JOIN users AS owner ON owner.user_id = conversation.owner_id LEFT JOIN circle_conversations AS circleConversation ON conversation.conversation_id = circleConversation.conversation_id WHERE ${generatedwhere.sql}', - variables: [ - ...generatedwhere.introducedVariables - ], - readsFrom: { - conversations, - users, - circleConversations, - ...generatedwhere.watchedTables, - }).map((QueryRow row) => row.read('_c0')); - } - - Selectable baseConversationItems( - BaseConversationItems$where where, - BaseConversationItems$order order, - BaseConversationItems$limit limit) { - var $arrayStartIndex = 1; - final generatedwhere = $write( - where( - alias(this.conversations, 'conversation'), - alias(this.users, 'owner'), - alias(this.messages, 'lastMessage'), - alias(this.users, 'lastMessageSender'), - alias(this.snapshots, 'snapshot'), - alias(this.users, 'participant'), - alias(this.expiredMessages, 'em')), - hasMultipleTables: true, - startIndex: $arrayStartIndex); - $arrayStartIndex += generatedwhere.amountOfVariables; - final generatedorder = $write( - order?.call( - alias(this.conversations, 'conversation'), - alias(this.users, 'owner'), - alias(this.messages, 'lastMessage'), - alias(this.users, 'lastMessageSender'), - alias(this.snapshots, 'snapshot'), - alias(this.users, 'participant'), - alias(this.expiredMessages, 'em')) ?? - const OrderBy.nothing(), - hasMultipleTables: true, - startIndex: $arrayStartIndex); - $arrayStartIndex += generatedorder.amountOfVariables; - final generatedlimit = $write( - limit( - alias(this.conversations, 'conversation'), - alias(this.users, 'owner'), - alias(this.messages, 'lastMessage'), - alias(this.users, 'lastMessageSender'), - alias(this.snapshots, 'snapshot'), - alias(this.users, 'participant'), - alias(this.expiredMessages, 'em')), - hasMultipleTables: true, - startIndex: $arrayStartIndex); - $arrayStartIndex += generatedlimit.amountOfVariables; - return customSelect( - 'SELECT conversation.conversation_id AS conversationId, conversation.icon_url AS groupIconUrl, conversation.category AS category, conversation.draft AS draft, conversation.name AS groupName, conversation.status AS status, conversation.last_read_message_id AS lastReadMessageId, conversation.unseen_message_count AS unseenMessageCount, conversation.owner_id AS ownerId, conversation.pin_time AS pinTime, conversation.mute_until AS muteUntil, conversation.expire_in AS expireIn, owner.avatar_url AS avatarUrl, owner.full_name AS name, owner.is_verified AS ownerVerified, owner.identity_number AS ownerIdentityNumber, owner.mute_until AS ownerMuteUntil, owner.app_id AS appId, lastMessage.content AS content, lastMessage.category AS contentType, conversation.created_at AS createdAt, lastMessage.created_at AS lastMessageCreatedAt, lastMessage.media_url AS mediaUrl, lastMessage.user_id AS senderId, lastMessage."action" AS actionName, lastMessage.status AS messageStatus, lastMessageSender.full_name AS senderFullName, snapshot.type AS SnapshotType, participant.full_name AS participantFullName, participant.user_id AS participantUserId, em.expire_in AS messageExpireIn, (SELECT COUNT(1) FROM message_mentions AS messageMention WHERE messageMention.conversation_id = conversation.conversation_id AND messageMention.has_read = 0) AS mentionCount, owner.relationship AS relationship FROM conversations AS conversation INNER JOIN users AS owner ON owner.user_id = conversation.owner_id LEFT JOIN messages AS lastMessage ON conversation.last_message_id = lastMessage.message_id LEFT JOIN users AS lastMessageSender ON lastMessageSender.user_id = lastMessage.user_id LEFT JOIN snapshots AS snapshot ON snapshot.snapshot_id = lastMessage.snapshot_id LEFT JOIN users AS participant ON participant.user_id = lastMessage.participant_id LEFT JOIN expired_messages AS em ON lastMessage.message_id = em.message_id WHERE ${generatedwhere.sql} ${generatedorder.sql} ${generatedlimit.sql}', - variables: [ - ...generatedwhere.introducedVariables, - ...generatedorder.introducedVariables, - ...generatedlimit.introducedVariables - ], - readsFrom: { - conversations, - users, - messages, - snapshots, - expiredMessages, - messageMentions, - ...generatedwhere.watchedTables, - ...generatedorder.watchedTables, - ...generatedlimit.watchedTables, - }).map((QueryRow row) { - return ConversationItem( - conversationId: row.read('conversationId'), - groupIconUrl: row.readNullable('groupIconUrl'), - category: Conversations.$convertercategory - .fromSql(row.readNullable('category')), - draft: row.readNullable('draft'), - groupName: row.readNullable('groupName'), - status: Conversations.$converterstatus.fromSql(row.read('status')), - lastReadMessageId: row.readNullable('lastReadMessageId'), - unseenMessageCount: row.readNullable('unseenMessageCount'), - ownerId: row.readNullable('ownerId'), - pinTime: NullAwareTypeConverter.wrapFromSql( - Conversations.$converterpinTime, row.readNullable('pinTime')), - muteUntil: NullAwareTypeConverter.wrapFromSql( - Conversations.$convertermuteUntil, - row.readNullable('muteUntil')), - expireIn: row.readNullable('expireIn'), - avatarUrl: row.readNullable('avatarUrl'), - name: row.readNullable('name'), - ownerVerified: row.readNullable('ownerVerified'), - ownerIdentityNumber: row.read('ownerIdentityNumber'), - ownerMuteUntil: NullAwareTypeConverter.wrapFromSql( - Users.$convertermuteUntil, row.readNullable('ownerMuteUntil')), - appId: row.readNullable('appId'), - content: row.readNullable('content'), - contentType: row.readNullable('contentType'), - createdAt: Conversations.$convertercreatedAt - .fromSql(row.read('createdAt')), - lastMessageCreatedAt: NullAwareTypeConverter.wrapFromSql( - Messages.$convertercreatedAt, - row.readNullable('lastMessageCreatedAt')), - mediaUrl: row.readNullable('mediaUrl'), - senderId: row.readNullable('senderId'), - actionName: row.readNullable('actionName'), - messageStatus: NullAwareTypeConverter.wrapFromSql( - Messages.$converterstatus, - row.readNullable('messageStatus')), - senderFullName: row.readNullable('senderFullName'), - snapshotType: row.readNullable('SnapshotType'), - participantFullName: row.readNullable('participantFullName'), - participantUserId: row.readNullable('participantUserId'), - messageExpireIn: row.readNullable('messageExpireIn'), - mentionCount: row.read('mentionCount'), - relationship: Users.$converterrelationship - .fromSql(row.readNullable('relationship')), - ); - }); - } - - Selectable baseConversationItemsByCircleId( - BaseConversationItemsByCircleId$where where, - BaseConversationItemsByCircleId$order order, - BaseConversationItemsByCircleId$limit limit) { - var $arrayStartIndex = 1; - final generatedwhere = $write( - where( - alias(this.conversations, 'conversation'), - alias(this.users, 'owner'), - alias(this.circleConversations, 'circleConversation'), - alias(this.messages, 'lastMessage'), - alias(this.users, 'lastMessageSender'), - alias(this.snapshots, 'snapshot'), - alias(this.users, 'participant'), - alias(this.expiredMessages, 'em')), - hasMultipleTables: true, - startIndex: $arrayStartIndex); - $arrayStartIndex += generatedwhere.amountOfVariables; - final generatedorder = $write( - order?.call( - alias(this.conversations, 'conversation'), - alias(this.users, 'owner'), - alias(this.circleConversations, 'circleConversation'), - alias(this.messages, 'lastMessage'), - alias(this.users, 'lastMessageSender'), - alias(this.snapshots, 'snapshot'), - alias(this.users, 'participant'), - alias(this.expiredMessages, 'em')) ?? - const OrderBy.nothing(), - hasMultipleTables: true, - startIndex: $arrayStartIndex); - $arrayStartIndex += generatedorder.amountOfVariables; - final generatedlimit = $write( - limit( - alias(this.conversations, 'conversation'), - alias(this.users, 'owner'), - alias(this.circleConversations, 'circleConversation'), - alias(this.messages, 'lastMessage'), - alias(this.users, 'lastMessageSender'), - alias(this.snapshots, 'snapshot'), - alias(this.users, 'participant'), - alias(this.expiredMessages, 'em')), - hasMultipleTables: true, - startIndex: $arrayStartIndex); - $arrayStartIndex += generatedlimit.amountOfVariables; - return customSelect( - 'SELECT conversation.conversation_id AS conversationId, conversation.icon_url AS groupIconUrl, conversation.category AS category, conversation.draft AS draft, conversation.name AS groupName, conversation.status AS status, conversation.last_read_message_id AS lastReadMessageId, conversation.unseen_message_count AS unseenMessageCount, conversation.owner_id AS ownerId, conversation.pin_time AS pinTime, conversation.mute_until AS muteUntil, conversation.expire_in AS expireIn, owner.avatar_url AS avatarUrl, owner.full_name AS name, owner.is_verified AS ownerVerified, owner.identity_number AS ownerIdentityNumber, owner.mute_until AS ownerMuteUntil, owner.app_id AS appId, lastMessage.content AS content, lastMessage.category AS contentType, conversation.created_at AS createdAt, lastMessage.created_at AS lastMessageCreatedAt, lastMessage.media_url AS mediaUrl, lastMessage.user_id AS senderId, lastMessage."action" AS actionName, lastMessage.status AS messageStatus, lastMessageSender.full_name AS senderFullName, snapshot.type AS SnapshotType, participant.full_name AS participantFullName, participant.user_id AS participantUserId, em.expire_in AS messageExpireIn, (SELECT COUNT(1) FROM message_mentions AS messageMention WHERE messageMention.conversation_id = conversation.conversation_id AND messageMention.has_read = 0) AS mentionCount, owner.relationship AS relationship FROM conversations AS conversation INNER JOIN users AS owner ON owner.user_id = conversation.owner_id LEFT JOIN circle_conversations AS circleConversation ON conversation.conversation_id = circleConversation.conversation_id LEFT JOIN messages AS lastMessage ON conversation.last_message_id = lastMessage.message_id LEFT JOIN users AS lastMessageSender ON lastMessageSender.user_id = lastMessage.user_id LEFT JOIN snapshots AS snapshot ON snapshot.snapshot_id = lastMessage.snapshot_id LEFT JOIN users AS participant ON participant.user_id = lastMessage.participant_id LEFT JOIN expired_messages AS em ON lastMessage.message_id = em.message_id WHERE ${generatedwhere.sql} ${generatedorder.sql} ${generatedlimit.sql}', - variables: [ - ...generatedwhere.introducedVariables, - ...generatedorder.introducedVariables, - ...generatedlimit.introducedVariables - ], - readsFrom: { - conversations, - users, - messages, - snapshots, - expiredMessages, - messageMentions, - circleConversations, - ...generatedwhere.watchedTables, - ...generatedorder.watchedTables, - ...generatedlimit.watchedTables, - }).map((QueryRow row) { - return ConversationItem( - conversationId: row.read('conversationId'), - groupIconUrl: row.readNullable('groupIconUrl'), - category: Conversations.$convertercategory - .fromSql(row.readNullable('category')), - draft: row.readNullable('draft'), - groupName: row.readNullable('groupName'), - status: Conversations.$converterstatus.fromSql(row.read('status')), - lastReadMessageId: row.readNullable('lastReadMessageId'), - unseenMessageCount: row.readNullable('unseenMessageCount'), - ownerId: row.readNullable('ownerId'), - pinTime: NullAwareTypeConverter.wrapFromSql( - Conversations.$converterpinTime, row.readNullable('pinTime')), - muteUntil: NullAwareTypeConverter.wrapFromSql( - Conversations.$convertermuteUntil, - row.readNullable('muteUntil')), - expireIn: row.readNullable('expireIn'), - avatarUrl: row.readNullable('avatarUrl'), - name: row.readNullable('name'), - ownerVerified: row.readNullable('ownerVerified'), - ownerIdentityNumber: row.read('ownerIdentityNumber'), - ownerMuteUntil: NullAwareTypeConverter.wrapFromSql( - Users.$convertermuteUntil, row.readNullable('ownerMuteUntil')), - appId: row.readNullable('appId'), - content: row.readNullable('content'), - contentType: row.readNullable('contentType'), - createdAt: Conversations.$convertercreatedAt - .fromSql(row.read('createdAt')), - lastMessageCreatedAt: NullAwareTypeConverter.wrapFromSql( - Messages.$convertercreatedAt, - row.readNullable('lastMessageCreatedAt')), - mediaUrl: row.readNullable('mediaUrl'), - senderId: row.readNullable('senderId'), - actionName: row.readNullable('actionName'), - messageStatus: NullAwareTypeConverter.wrapFromSql( - Messages.$converterstatus, - row.readNullable('messageStatus')), - senderFullName: row.readNullable('senderFullName'), - snapshotType: row.readNullable('SnapshotType'), - participantFullName: row.readNullable('participantFullName'), - participantUserId: row.readNullable('participantUserId'), - messageExpireIn: row.readNullable('messageExpireIn'), - mentionCount: row.read('mentionCount'), - relationship: Users.$converterrelationship - .fromSql(row.readNullable('relationship')), - ); - }); - } - - Selectable baseUnseenMessageCount(BaseUnseenMessageCount$where where) { - var $arrayStartIndex = 1; - final generatedwhere = $write( - where( - alias(this.conversations, 'conversation'), - alias(this.users, 'owner'), - alias(this.circleConversations, 'circleConversation')), - hasMultipleTables: true, - startIndex: $arrayStartIndex); - $arrayStartIndex += generatedwhere.amountOfVariables; - return customSelect( - 'SELECT IFNULL(SUM(unseen_message_count), 0) AS _c0 FROM conversations AS conversation INNER JOIN users AS owner ON owner.user_id = conversation.owner_id LEFT JOIN circle_conversations AS circleConversation ON conversation.conversation_id = circleConversation.conversation_id WHERE ${generatedwhere.sql} LIMIT 1', - variables: [ - ...generatedwhere.introducedVariables - ], - readsFrom: { - conversations, - users, - circleConversations, - ...generatedwhere.watchedTables, - }).map((QueryRow row) => row.read('_c0')); - } - - Selectable baseUnseenConversationCount( - BaseUnseenConversationCount$where where) { - var $arrayStartIndex = 1; - final generatedwhere = $write( - where(alias(this.conversations, 'conversation'), - alias(this.users, 'owner')), - hasMultipleTables: true, - startIndex: $arrayStartIndex); - $arrayStartIndex += generatedwhere.amountOfVariables; - return customSelect( - 'SELECT COUNT(1) AS unseen_conversation_count, IFNULL(SUM(CASE WHEN(CASE WHEN conversation.category = \'GROUP\' THEN conversation.mute_until ELSE owner.mute_until END)>=(strftime(\'%s\', \'now\') * 1000)AND IFNULL(conversation.unseen_message_count, 0) > 0 THEN 1 ELSE 0 END), 0) AS unseen_muted_conversation_count FROM conversations AS conversation INNER JOIN users AS owner ON owner.user_id = conversation.owner_id WHERE ${generatedwhere.sql} LIMIT 1', - variables: [ - ...generatedwhere.introducedVariables - ], - readsFrom: { - conversations, - users, - ...generatedwhere.watchedTables, - }).map((QueryRow row) { - return BaseUnseenConversationCountResult( - unseenConversationCount: row.read('unseen_conversation_count'), - unseenMutedConversationCount: - row.read('unseen_muted_conversation_count'), - ); - }); - } - - Selectable fuzzySearchConversation( - String query, - FuzzySearchConversation$where where, - FuzzySearchConversation$limit limit) { - var $arrayStartIndex = 2; - final generatedwhere = $write( - where( - alias(this.conversations, 'conversation'), - alias(this.users, 'owner'), - alias(this.messages, 'message'), - alias(this.users, 'lastMessageSender'), - alias(this.users, 'participant')), - hasMultipleTables: true, - startIndex: $arrayStartIndex); - $arrayStartIndex += generatedwhere.amountOfVariables; - final generatedlimit = $write( - limit( - alias(this.conversations, 'conversation'), - alias(this.users, 'owner'), - alias(this.messages, 'message'), - alias(this.users, 'lastMessageSender'), - alias(this.users, 'participant')), - hasMultipleTables: true, - startIndex: $arrayStartIndex); - $arrayStartIndex += generatedlimit.amountOfVariables; - return customSelect( - 'SELECT conversation.conversation_id AS conversationId, conversation.icon_url AS groupIconUrl, conversation.category AS category, conversation.name AS groupName, conversation.pin_time AS pinTime, conversation.mute_until AS muteUntil, conversation.owner_id AS ownerId, owner.mute_until AS ownerMuteUntil, owner.identity_number AS ownerIdentityNumber, owner.full_name AS fullName, owner.avatar_url AS avatarUrl, owner.is_verified AS isVerified, owner.app_id AS appId, message.status AS messageStatus, message.content AS content, message.category AS contentType, message.user_id AS senderId, message."action" AS actionName, lastMessageSender.full_name AS senderFullName, participant.user_id AS participantUserId, participant.full_name AS participantFullName FROM conversations AS conversation INNER JOIN users AS owner ON owner.user_id = conversation.owner_id LEFT JOIN messages AS message ON conversation.last_message_id = message.message_id LEFT JOIN users AS lastMessageSender ON lastMessageSender.user_id = message.user_id LEFT JOIN users AS participant ON participant.user_id = message.participant_id WHERE((conversation.category = \'GROUP\' AND conversation.name LIKE \'%\' || ?1 || \'%\' ESCAPE \'\\\')OR(conversation.category = \'CONTACT\' AND(owner.full_name LIKE \'%\' || ?1 || \'%\' ESCAPE \'\\\' OR owner.identity_number LIKE \'%\' || ?1 || \'%\' ESCAPE \'\\\')))AND ${generatedwhere.sql} ORDER BY(conversation.category = \'GROUP\' AND conversation.name = ?1 COLLATE NOCASE)OR(conversation.category = \'CONTACT\' AND(owner.full_name = ?1 COLLATE NOCASE OR owner.identity_number = ?1 COLLATE NOCASE))DESC, conversation.pin_time DESC, message.created_at DESC ${generatedlimit.sql}', - variables: [ - Variable(query), - ...generatedwhere.introducedVariables, - ...generatedlimit.introducedVariables - ], - readsFrom: { - conversations, - users, - messages, - ...generatedwhere.watchedTables, - ...generatedlimit.watchedTables, - }).map((QueryRow row) { - return SearchConversationItem( - conversationId: row.read('conversationId'), - groupIconUrl: row.readNullable('groupIconUrl'), - category: Conversations.$convertercategory - .fromSql(row.readNullable('category')), - groupName: row.readNullable('groupName'), - pinTime: NullAwareTypeConverter.wrapFromSql( - Conversations.$converterpinTime, row.readNullable('pinTime')), - muteUntil: NullAwareTypeConverter.wrapFromSql( - Conversations.$convertermuteUntil, - row.readNullable('muteUntil')), - ownerId: row.readNullable('ownerId'), - ownerMuteUntil: NullAwareTypeConverter.wrapFromSql( - Users.$convertermuteUntil, row.readNullable('ownerMuteUntil')), - ownerIdentityNumber: row.read('ownerIdentityNumber'), - fullName: row.readNullable('fullName'), - avatarUrl: row.readNullable('avatarUrl'), - isVerified: row.readNullable('isVerified'), - appId: row.readNullable('appId'), - messageStatus: NullAwareTypeConverter.wrapFromSql( - Messages.$converterstatus, - row.readNullable('messageStatus')), - content: row.readNullable('content'), - contentType: row.readNullable('contentType'), - senderId: row.readNullable('senderId'), - actionName: row.readNullable('actionName'), - senderFullName: row.readNullable('senderFullName'), - participantUserId: row.readNullable('participantUserId'), - participantFullName: row.readNullable('participantFullName'), - ); - }); - } - - Selectable searchConversationItemByIn( - List ids, SearchConversationItemByIn$order order) { - var $arrayStartIndex = 1; - final expandedids = $expandVar($arrayStartIndex, ids.length); - $arrayStartIndex += ids.length; - final generatedorder = $write( - order?.call( - alias(this.conversations, 'conversation'), - alias(this.users, 'owner'), - alias(this.messages, 'message'), - alias(this.users, 'lastMessageSender'), - alias(this.users, 'participant')) ?? - const OrderBy.nothing(), - hasMultipleTables: true, - startIndex: $arrayStartIndex); - $arrayStartIndex += generatedorder.amountOfVariables; - return customSelect( - 'SELECT conversation.conversation_id AS conversationId, conversation.icon_url AS groupIconUrl, conversation.category AS category, conversation.name AS groupName, conversation.pin_time AS pinTime, conversation.mute_until AS muteUntil, conversation.owner_id AS ownerId, owner.mute_until AS ownerMuteUntil, owner.identity_number AS ownerIdentityNumber, owner.full_name AS fullName, owner.avatar_url AS avatarUrl, owner.is_verified AS isVerified, owner.app_id AS appId, message.status AS messageStatus, message.content AS content, message.category AS contentType, message.user_id AS senderId, message."action" AS actionName, lastMessageSender.full_name AS senderFullName, participant.user_id AS participantUserId, participant.full_name AS participantFullName FROM conversations AS conversation INNER JOIN users AS owner ON owner.user_id = conversation.owner_id LEFT JOIN messages AS message ON conversation.last_message_id = message.message_id LEFT JOIN users AS lastMessageSender ON lastMessageSender.user_id = message.user_id LEFT JOIN users AS participant ON participant.user_id = message.participant_id WHERE conversation.conversation_id IN ($expandedids) ${generatedorder.sql}', - variables: [ - for (var $ in ids) Variable($), - ...generatedorder.introducedVariables - ], - readsFrom: { - conversations, - users, - messages, - ...generatedorder.watchedTables, - }).map((QueryRow row) { - return SearchConversationItem( - conversationId: row.read('conversationId'), - groupIconUrl: row.readNullable('groupIconUrl'), - category: Conversations.$convertercategory - .fromSql(row.readNullable('category')), - groupName: row.readNullable('groupName'), - pinTime: NullAwareTypeConverter.wrapFromSql( - Conversations.$converterpinTime, row.readNullable('pinTime')), - muteUntil: NullAwareTypeConverter.wrapFromSql( - Conversations.$convertermuteUntil, - row.readNullable('muteUntil')), - ownerId: row.readNullable('ownerId'), - ownerMuteUntil: NullAwareTypeConverter.wrapFromSql( - Users.$convertermuteUntil, row.readNullable('ownerMuteUntil')), - ownerIdentityNumber: row.read('ownerIdentityNumber'), - fullName: row.readNullable('fullName'), - avatarUrl: row.readNullable('avatarUrl'), - isVerified: row.readNullable('isVerified'), - appId: row.readNullable('appId'), - messageStatus: NullAwareTypeConverter.wrapFromSql( - Messages.$converterstatus, - row.readNullable('messageStatus')), - content: row.readNullable('content'), - contentType: row.readNullable('contentType'), - senderId: row.readNullable('senderId'), - actionName: row.readNullable('actionName'), - senderFullName: row.readNullable('senderFullName'), - participantUserId: row.readNullable('participantUserId'), - participantFullName: row.readNullable('participantFullName'), - ); - }); - } - - Selectable fuzzySearchConversationInCircle( - String query, - String? circleId, - FuzzySearchConversationInCircle$where where, - FuzzySearchConversationInCircle$limit limit) { - var $arrayStartIndex = 3; - final generatedwhere = $write( - where( - alias(this.conversations, 'conversation'), - alias(this.users, 'owner'), - alias(this.messages, 'message'), - alias(this.users, 'lastMessageSender'), - alias(this.circleConversations, 'circleConversation'), - alias(this.users, 'participant')), - hasMultipleTables: true, - startIndex: $arrayStartIndex); - $arrayStartIndex += generatedwhere.amountOfVariables; - final generatedlimit = $write( - limit( - alias(this.conversations, 'conversation'), - alias(this.users, 'owner'), - alias(this.messages, 'message'), - alias(this.users, 'lastMessageSender'), - alias(this.circleConversations, 'circleConversation'), - alias(this.users, 'participant')), - hasMultipleTables: true, - startIndex: $arrayStartIndex); - $arrayStartIndex += generatedlimit.amountOfVariables; - return customSelect( - 'SELECT conversation.conversation_id AS conversationId, conversation.icon_url AS groupIconUrl, conversation.category AS category, conversation.name AS groupName, conversation.pin_time AS pinTime, conversation.mute_until AS muteUntil, conversation.owner_id AS ownerId, owner.mute_until AS ownerMuteUntil, owner.identity_number AS ownerIdentityNumber, owner.full_name AS fullName, owner.avatar_url AS avatarUrl, owner.is_verified AS isVerified, owner.app_id AS appId, message.status AS messageStatus, message.content AS content, message.category AS contentType, message.user_id AS senderId, message."action" AS actionName, lastMessageSender.full_name AS senderFullName, participant.user_id AS participantUserId, participant.full_name AS participantFullName FROM conversations AS conversation INNER JOIN users AS owner ON owner.user_id = conversation.owner_id LEFT JOIN messages AS message ON conversation.last_message_id = message.message_id LEFT JOIN users AS lastMessageSender ON lastMessageSender.user_id = message.user_id LEFT JOIN circle_conversations AS circleConversation ON conversation.conversation_id = circleConversation.conversation_id LEFT JOIN users AS participant ON participant.user_id = message.participant_id WHERE((conversation.category = \'GROUP\' AND conversation.name LIKE \'%\' || ?1 || \'%\' ESCAPE \'\\\')OR(conversation.category = \'CONTACT\' AND(owner.full_name LIKE \'%\' || ?1 || \'%\' ESCAPE \'\\\' OR owner.identity_number LIKE \'%\' || ?1 || \'%\' ESCAPE \'\\\')))AND circleConversation.circle_id = ?2 AND ${generatedwhere.sql} ORDER BY(conversation.category = \'GROUP\' AND conversation.name = ?1 COLLATE NOCASE)OR(conversation.category = \'CONTACT\' AND(owner.full_name = ?1 COLLATE NOCASE OR owner.identity_number = ?1 COLLATE NOCASE))DESC, conversation.pin_time DESC, message.created_at DESC ${generatedlimit.sql}', - variables: [ - Variable(query), - Variable(circleId), - ...generatedwhere.introducedVariables, - ...generatedlimit.introducedVariables - ], - readsFrom: { - conversations, - users, - messages, - circleConversations, - ...generatedwhere.watchedTables, - ...generatedlimit.watchedTables, - }).map((QueryRow row) { - return SearchConversationItem( - conversationId: row.read('conversationId'), - groupIconUrl: row.readNullable('groupIconUrl'), - category: Conversations.$convertercategory - .fromSql(row.readNullable('category')), - groupName: row.readNullable('groupName'), - pinTime: NullAwareTypeConverter.wrapFromSql( - Conversations.$converterpinTime, row.readNullable('pinTime')), - muteUntil: NullAwareTypeConverter.wrapFromSql( - Conversations.$convertermuteUntil, - row.readNullable('muteUntil')), - ownerId: row.readNullable('ownerId'), - ownerMuteUntil: NullAwareTypeConverter.wrapFromSql( - Users.$convertermuteUntil, row.readNullable('ownerMuteUntil')), - ownerIdentityNumber: row.read('ownerIdentityNumber'), - fullName: row.readNullable('fullName'), - avatarUrl: row.readNullable('avatarUrl'), - isVerified: row.readNullable('isVerified'), - appId: row.readNullable('appId'), - messageStatus: NullAwareTypeConverter.wrapFromSql( - Messages.$converterstatus, - row.readNullable('messageStatus')), - content: row.readNullable('content'), - contentType: row.readNullable('contentType'), - senderId: row.readNullable('senderId'), - actionName: row.readNullable('actionName'), - senderFullName: row.readNullable('senderFullName'), - participantUserId: row.readNullable('participantUserId'), - participantFullName: row.readNullable('participantFullName'), - ); - }); - } - - Selectable conversationParticipantsCount(String conversationId) { - return customSelect( - 'SELECT COUNT(1) AS _c0 FROM participants WHERE conversation_id = ?1', - variables: [ - Variable(conversationId) - ], - readsFrom: { - participants, - }).map((QueryRow row) => row.read('_c0')); - } - - Selectable conversationStorageUsage() { - return customSelect( - 'SELECT c.conversation_id, c.owner_id, c.category, c.icon_url, c.name, u.identity_number, u.full_name, u.avatar_url, u.is_verified FROM conversations AS c INNER JOIN users AS u ON u.user_id = c.owner_id WHERE c.category IS NOT NULL', - variables: [], - readsFrom: { - conversations, - users, - }).map((QueryRow row) { - return ConversationStorageUsage( - conversationId: row.read('conversation_id'), - ownerId: row.readNullable('owner_id'), - category: Conversations.$convertercategory - .fromSql(row.readNullable('category')), - iconUrl: row.readNullable('icon_url'), - name: row.readNullable('name'), - identityNumber: row.read('identity_number'), - fullName: row.readNullable('full_name'), - avatarUrl: row.readNullable('avatar_url'), - isVerified: row.readNullable('is_verified'), - ); - }); - } - - Selectable findSameConversations(String selfId, String userId) { - return customSelect( - 'SELECT c.conversation_id AS conversationId, c.icon_url AS groupIconUrl, c.name AS groupName, (SELECT count(user_id) FROM participants WHERE conversation_id = c.conversation_id) AS memberCount FROM participants AS p INNER JOIN conversations AS c ON c.conversation_id = p.conversation_id WHERE p.user_id IN (?1, ?2) AND c.status = 2 AND c.category = \'GROUP\' GROUP BY c.conversation_id HAVING count(p.user_id) = 2 ORDER BY c.last_message_created_at DESC', - variables: [ - Variable(selfId), - Variable(userId) - ], - readsFrom: { - conversations, - participants, - }).map((QueryRow row) { - return GroupMinimal( - conversationId: row.read('conversationId'), - groupIconUrl: row.readNullable('groupIconUrl'), - groupName: row.readNullable('groupName'), - memberCount: row.read('memberCount'), - ); - }); - } - - Selectable countConversations() { - return customSelect('SELECT COUNT(1) AS _c0 FROM conversations', - variables: [], - readsFrom: { - conversations, - }).map((QueryRow row) => row.read('_c0')); - } - - @override - Iterable> get allTables => - allSchemaEntities.whereType>(); - @override - List get allSchemaEntities => [ - favoriteApps, - apps, - stickerRelationships, - stickerAlbums, - pinMessages, - conversations, - messages, - users, - snapshots, - assets, - chains, - stickers, - hyperlinks, - messageMentions, - expiredMessages, - floodMessages, - circles, - circleConversations, - participants, - participantSession, - resendSessionMessages, - addresses, - jobs, - messagesHistory, - offsets, - sentSessionSenderKeys, - transcriptMessages, - fiats, - properties, - indexConversationsCategoryStatus, - indexConversationsMuteUntil, - indexFloodMessagesCreatedAt, - indexJobsAction, - indexMessageMentionsConversationIdHasRead, - indexParticipantsConversationIdCreatedAt, - indexStickerAlbumsCategoryCreatedAt, - indexPinMessagesConversationId, - indexUsersIdentityNumber, - indexMessagesConversationIdCreatedAt, - indexMessagesConversationIdCategoryCreatedAt, - indexMessageConversationIdStatusUserId, - indexMessagesConversationIdQuoteMessageId - ]; - @override - StreamQueryUpdateRules get streamUpdateRules => const StreamQueryUpdateRules( - [ - WritePropagation( - on: TableUpdateQuery.onTableName('conversations', - limitUpdateKind: UpdateKind.delete), - result: [ - TableUpdate('messages', kind: UpdateKind.delete), - ], - ), - WritePropagation( - on: TableUpdateQuery.onTableName('conversations', - limitUpdateKind: UpdateKind.delete), - result: [ - TableUpdate('participants', kind: UpdateKind.delete), - ], - ), - ], - ); -} - -class MessageItem { - final String messageId; - final String conversationId; - final String type; - final String? content; - final DateTime createdAt; - final MessageStatus status; - final MediaStatus? mediaStatus; - final String? mediaWaveform; - final String? mediaName; - final String? mediaMimeType; - final int? mediaSize; - final int? mediaWidth; - final int? mediaHeight; - final String? thumbImage; - final String? thumbUrl; - final String? mediaUrl; - final String? mediaDuration; - final String? quoteId; - final String? quoteContent; - final String? actionName; - final String? sharedUserId; - final String userId; - final String? userFullName; - final String userIdentityNumber; - final String? appId; - final UserRelationship? relationship; - final String? avatarUrl; - final String? sharedUserFullName; - final String? sharedUserIdentityNumber; - final String? sharedUserAvatarUrl; - final bool? sharedUserIsVerified; - final String? sharedUserAppId; - final String? conversationOwnerId; - final ConversationCategory? conversionCategory; - final String? groupName; - final String? assetUrl; - final int? assetWidth; - final int? assetHeight; - final String? stickerId; - final String? assetName; - final String? assetType; - final String? participantFullName; - final String? participantUserId; - final String? snapshotId; - final String? snapshotType; - final String? snapshotAmount; - final String? assetId; - final String? assetSymbol; - final String? assetIcon; - final String? chainIcon; - final String? siteName; - final String? siteTitle; - final String? siteDescription; - final String? siteImage; - final bool? mentionRead; - final int? expireIn; - final bool pinned; - MessageItem({ - required this.messageId, - required this.conversationId, - required this.type, - this.content, - required this.createdAt, - required this.status, - this.mediaStatus, - this.mediaWaveform, - this.mediaName, - this.mediaMimeType, - this.mediaSize, - this.mediaWidth, - this.mediaHeight, - this.thumbImage, - this.thumbUrl, - this.mediaUrl, - this.mediaDuration, - this.quoteId, - this.quoteContent, - this.actionName, - this.sharedUserId, - required this.userId, - this.userFullName, - required this.userIdentityNumber, - this.appId, - this.relationship, - this.avatarUrl, - this.sharedUserFullName, - this.sharedUserIdentityNumber, - this.sharedUserAvatarUrl, - this.sharedUserIsVerified, - this.sharedUserAppId, - this.conversationOwnerId, - this.conversionCategory, - this.groupName, - this.assetUrl, - this.assetWidth, - this.assetHeight, - this.stickerId, - this.assetName, - this.assetType, - this.participantFullName, - this.participantUserId, - this.snapshotId, - this.snapshotType, - this.snapshotAmount, - this.assetId, - this.assetSymbol, - this.assetIcon, - this.chainIcon, - this.siteName, - this.siteTitle, - this.siteDescription, - this.siteImage, - this.mentionRead, - this.expireIn, - required this.pinned, - }); - @override - int get hashCode => Object.hashAll([ - messageId, - conversationId, - type, - content, - createdAt, - status, - mediaStatus, - mediaWaveform, - mediaName, - mediaMimeType, - mediaSize, - mediaWidth, - mediaHeight, - thumbImage, - thumbUrl, - mediaUrl, - mediaDuration, - quoteId, - quoteContent, - actionName, - sharedUserId, - userId, - userFullName, - userIdentityNumber, - appId, - relationship, - avatarUrl, - sharedUserFullName, - sharedUserIdentityNumber, - sharedUserAvatarUrl, - sharedUserIsVerified, - sharedUserAppId, - conversationOwnerId, - conversionCategory, - groupName, - assetUrl, - assetWidth, - assetHeight, - stickerId, - assetName, - assetType, - participantFullName, - participantUserId, - snapshotId, - snapshotType, - snapshotAmount, - assetId, - assetSymbol, - assetIcon, - chainIcon, - siteName, - siteTitle, - siteDescription, - siteImage, - mentionRead, - expireIn, - pinned - ]); - @override - bool operator ==(Object other) => - identical(this, other) || - (other is MessageItem && - other.messageId == this.messageId && - other.conversationId == this.conversationId && - other.type == this.type && - other.content == this.content && - other.createdAt == this.createdAt && - other.status == this.status && - other.mediaStatus == this.mediaStatus && - other.mediaWaveform == this.mediaWaveform && - other.mediaName == this.mediaName && - other.mediaMimeType == this.mediaMimeType && - other.mediaSize == this.mediaSize && - other.mediaWidth == this.mediaWidth && - other.mediaHeight == this.mediaHeight && - other.thumbImage == this.thumbImage && - other.thumbUrl == this.thumbUrl && - other.mediaUrl == this.mediaUrl && - other.mediaDuration == this.mediaDuration && - other.quoteId == this.quoteId && - other.quoteContent == this.quoteContent && - other.actionName == this.actionName && - other.sharedUserId == this.sharedUserId && - other.userId == this.userId && - other.userFullName == this.userFullName && - other.userIdentityNumber == this.userIdentityNumber && - other.appId == this.appId && - other.relationship == this.relationship && - other.avatarUrl == this.avatarUrl && - other.sharedUserFullName == this.sharedUserFullName && - other.sharedUserIdentityNumber == this.sharedUserIdentityNumber && - other.sharedUserAvatarUrl == this.sharedUserAvatarUrl && - other.sharedUserIsVerified == this.sharedUserIsVerified && - other.sharedUserAppId == this.sharedUserAppId && - other.conversationOwnerId == this.conversationOwnerId && - other.conversionCategory == this.conversionCategory && - other.groupName == this.groupName && - other.assetUrl == this.assetUrl && - other.assetWidth == this.assetWidth && - other.assetHeight == this.assetHeight && - other.stickerId == this.stickerId && - other.assetName == this.assetName && - other.assetType == this.assetType && - other.participantFullName == this.participantFullName && - other.participantUserId == this.participantUserId && - other.snapshotId == this.snapshotId && - other.snapshotType == this.snapshotType && - other.snapshotAmount == this.snapshotAmount && - other.assetId == this.assetId && - other.assetSymbol == this.assetSymbol && - other.assetIcon == this.assetIcon && - other.chainIcon == this.chainIcon && - other.siteName == this.siteName && - other.siteTitle == this.siteTitle && - other.siteDescription == this.siteDescription && - other.siteImage == this.siteImage && - other.mentionRead == this.mentionRead && - other.expireIn == this.expireIn && - other.pinned == this.pinned); - @override - String toString() { - return (StringBuffer('MessageItem(') - ..write('messageId: $messageId, ') - ..write('conversationId: $conversationId, ') - ..write('type: $type, ') - ..write('content: $content, ') - ..write('createdAt: $createdAt, ') - ..write('status: $status, ') - ..write('mediaStatus: $mediaStatus, ') - ..write('mediaWaveform: $mediaWaveform, ') - ..write('mediaName: $mediaName, ') - ..write('mediaMimeType: $mediaMimeType, ') - ..write('mediaSize: $mediaSize, ') - ..write('mediaWidth: $mediaWidth, ') - ..write('mediaHeight: $mediaHeight, ') - ..write('thumbImage: $thumbImage, ') - ..write('thumbUrl: $thumbUrl, ') - ..write('mediaUrl: $mediaUrl, ') - ..write('mediaDuration: $mediaDuration, ') - ..write('quoteId: $quoteId, ') - ..write('quoteContent: $quoteContent, ') - ..write('actionName: $actionName, ') - ..write('sharedUserId: $sharedUserId, ') - ..write('userId: $userId, ') - ..write('userFullName: $userFullName, ') - ..write('userIdentityNumber: $userIdentityNumber, ') - ..write('appId: $appId, ') - ..write('relationship: $relationship, ') - ..write('avatarUrl: $avatarUrl, ') - ..write('sharedUserFullName: $sharedUserFullName, ') - ..write('sharedUserIdentityNumber: $sharedUserIdentityNumber, ') - ..write('sharedUserAvatarUrl: $sharedUserAvatarUrl, ') - ..write('sharedUserIsVerified: $sharedUserIsVerified, ') - ..write('sharedUserAppId: $sharedUserAppId, ') - ..write('conversationOwnerId: $conversationOwnerId, ') - ..write('conversionCategory: $conversionCategory, ') - ..write('groupName: $groupName, ') - ..write('assetUrl: $assetUrl, ') - ..write('assetWidth: $assetWidth, ') - ..write('assetHeight: $assetHeight, ') - ..write('stickerId: $stickerId, ') - ..write('assetName: $assetName, ') - ..write('assetType: $assetType, ') - ..write('participantFullName: $participantFullName, ') - ..write('participantUserId: $participantUserId, ') - ..write('snapshotId: $snapshotId, ') - ..write('snapshotType: $snapshotType, ') - ..write('snapshotAmount: $snapshotAmount, ') - ..write('assetId: $assetId, ') - ..write('assetSymbol: $assetSymbol, ') - ..write('assetIcon: $assetIcon, ') - ..write('chainIcon: $chainIcon, ') - ..write('siteName: $siteName, ') - ..write('siteTitle: $siteTitle, ') - ..write('siteDescription: $siteDescription, ') - ..write('siteImage: $siteImage, ') - ..write('mentionRead: $mentionRead, ') - ..write('expireIn: $expireIn, ') - ..write('pinned: $pinned') - ..write(')')) - .toString(); - } -} - -typedef BasePinMessageItems$order = OrderBy Function( - PinMessages pinMessage, - Messages message, - Users sender, - Users participant, - Snapshots snapshot, - Assets asset, - Chains chain, - Stickers sticker, - Hyperlinks hyperlink, - Users sharedUser, - Conversations conversation, - MessageMentions messageMention, - ExpiredMessages em); -typedef BasePinMessageItems$limit = Limit Function( - PinMessages pinMessage, - Messages message, - Users sender, - Users participant, - Snapshots snapshot, - Assets asset, - Chains chain, - Stickers sticker, - Hyperlinks hyperlink, - Users sharedUser, - Conversations conversation, - MessageMentions messageMention, - ExpiredMessages em); - -class PinMessageItemResult { - final String? content; +class TranscriptMessage extends DataClass + implements Insertable { + final String transcriptId; + final String messageId; + final String? userId; final String? userFullName; - PinMessageItemResult({ - this.content, - this.userFullName, - }); - @override - int get hashCode => Object.hash(content, userFullName); - @override - bool operator ==(Object other) => - identical(this, other) || - (other is PinMessageItemResult && - other.content == this.content && - other.userFullName == this.userFullName); - @override - String toString() { - return (StringBuffer('PinMessageItemResult(') - ..write('content: $content, ') - ..write('userFullName: $userFullName') - ..write(')')) - .toString(); - } -} - -class ConversationCircleItem { - final String circleId; - final String name; + final String category; final DateTime createdAt; - final DateTime? orderedAt; - final int count; - final int unseenConversationCount; - final int unseenMutedConversationCount; - ConversationCircleItem({ - required this.circleId, - required this.name, - required this.createdAt, - this.orderedAt, - required this.count, - required this.unseenConversationCount, - required this.unseenMutedConversationCount, - }); - @override - int get hashCode => Object.hash(circleId, name, createdAt, orderedAt, count, - unseenConversationCount, unseenMutedConversationCount); - @override - bool operator ==(Object other) => - identical(this, other) || - (other is ConversationCircleItem && - other.circleId == this.circleId && - other.name == this.name && - other.createdAt == this.createdAt && - other.orderedAt == this.orderedAt && - other.count == this.count && - other.unseenConversationCount == this.unseenConversationCount && - other.unseenMutedConversationCount == - this.unseenMutedConversationCount); + final String? content; + final String? mediaUrl; + final String? mediaName; + final int? mediaSize; + final int? mediaWidth; + final int? mediaHeight; + final String? mediaMimeType; + final String? mediaDuration; + final MediaStatus? mediaStatus; + final String? mediaWaveform; + final String? thumbImage; + final String? thumbUrl; + final String? mediaKey; + final String? mediaDigest; + final DateTime? mediaCreatedAt; + final String? stickerId; + final String? sharedUserId; + final String? mentions; + final String? quoteId; + final String? quoteContent; + final String? caption; + const TranscriptMessage( + {required this.transcriptId, + required this.messageId, + this.userId, + this.userFullName, + required this.category, + required this.createdAt, + this.content, + this.mediaUrl, + this.mediaName, + this.mediaSize, + this.mediaWidth, + this.mediaHeight, + this.mediaMimeType, + this.mediaDuration, + this.mediaStatus, + this.mediaWaveform, + this.thumbImage, + this.thumbUrl, + this.mediaKey, + this.mediaDigest, + this.mediaCreatedAt, + this.stickerId, + this.sharedUserId, + this.mentions, + this.quoteId, + this.quoteContent, + this.caption}); @override - String toString() { - return (StringBuffer('ConversationCircleItem(') - ..write('circleId: $circleId, ') - ..write('name: $name, ') - ..write('createdAt: $createdAt, ') - ..write('orderedAt: $orderedAt, ') - ..write('count: $count, ') - ..write('unseenConversationCount: $unseenConversationCount, ') - ..write('unseenMutedConversationCount: $unseenMutedConversationCount') - ..write(')')) - .toString(); + Map toColumns(bool nullToAbsent) { + final map = {}; + map['transcript_id'] = Variable(transcriptId); + map['message_id'] = Variable(messageId); + if (!nullToAbsent || userId != null) { + map['user_id'] = Variable(userId); + } + if (!nullToAbsent || userFullName != null) { + map['user_full_name'] = Variable(userFullName); + } + map['category'] = Variable(category); + { + final converter = TranscriptMessages.$convertercreatedAt; + map['created_at'] = Variable(converter.toSql(createdAt)); + } + if (!nullToAbsent || content != null) { + map['content'] = Variable(content); + } + if (!nullToAbsent || mediaUrl != null) { + map['media_url'] = Variable(mediaUrl); + } + if (!nullToAbsent || mediaName != null) { + map['media_name'] = Variable(mediaName); + } + if (!nullToAbsent || mediaSize != null) { + map['media_size'] = Variable(mediaSize); + } + if (!nullToAbsent || mediaWidth != null) { + map['media_width'] = Variable(mediaWidth); + } + if (!nullToAbsent || mediaHeight != null) { + map['media_height'] = Variable(mediaHeight); + } + if (!nullToAbsent || mediaMimeType != null) { + map['media_mime_type'] = Variable(mediaMimeType); + } + if (!nullToAbsent || mediaDuration != null) { + map['media_duration'] = Variable(mediaDuration); + } + if (!nullToAbsent || mediaStatus != null) { + final converter = TranscriptMessages.$convertermediaStatus; + map['media_status'] = Variable(converter.toSql(mediaStatus)); + } + if (!nullToAbsent || mediaWaveform != null) { + map['media_waveform'] = Variable(mediaWaveform); + } + if (!nullToAbsent || thumbImage != null) { + map['thumb_image'] = Variable(thumbImage); + } + if (!nullToAbsent || thumbUrl != null) { + map['thumb_url'] = Variable(thumbUrl); + } + if (!nullToAbsent || mediaKey != null) { + map['media_key'] = Variable(mediaKey); + } + if (!nullToAbsent || mediaDigest != null) { + map['media_digest'] = Variable(mediaDigest); + } + if (!nullToAbsent || mediaCreatedAt != null) { + final converter = TranscriptMessages.$convertermediaCreatedAtn; + map['media_created_at'] = Variable(converter.toSql(mediaCreatedAt)); + } + if (!nullToAbsent || stickerId != null) { + map['sticker_id'] = Variable(stickerId); + } + if (!nullToAbsent || sharedUserId != null) { + map['shared_user_id'] = Variable(sharedUserId); + } + if (!nullToAbsent || mentions != null) { + map['mentions'] = Variable(mentions); + } + if (!nullToAbsent || quoteId != null) { + map['quote_id'] = Variable(quoteId); + } + if (!nullToAbsent || quoteContent != null) { + map['quote_content'] = Variable(quoteContent); + } + if (!nullToAbsent || caption != null) { + map['caption'] = Variable(caption); + } + return map; } -} -class ConversationCircleManagerItem { - final String circleId; - final String name; - final int count; - ConversationCircleManagerItem({ - required this.circleId, - required this.name, - required this.count, - }); - @override - int get hashCode => Object.hash(circleId, name, count); - @override - bool operator ==(Object other) => - identical(this, other) || - (other is ConversationCircleManagerItem && - other.circleId == this.circleId && - other.name == this.name && - other.count == this.count); - @override - String toString() { - return (StringBuffer('ConversationCircleManagerItem(') - ..write('circleId: $circleId, ') - ..write('name: $name, ') - ..write('count: $count') - ..write(')')) - .toString(); + TranscriptMessagesCompanion toCompanion(bool nullToAbsent) { + return TranscriptMessagesCompanion( + transcriptId: Value(transcriptId), + messageId: Value(messageId), + userId: + userId == null && nullToAbsent ? const Value.absent() : Value(userId), + userFullName: userFullName == null && nullToAbsent + ? const Value.absent() + : Value(userFullName), + category: Value(category), + createdAt: Value(createdAt), + content: content == null && nullToAbsent + ? const Value.absent() + : Value(content), + mediaUrl: mediaUrl == null && nullToAbsent + ? const Value.absent() + : Value(mediaUrl), + mediaName: mediaName == null && nullToAbsent + ? const Value.absent() + : Value(mediaName), + mediaSize: mediaSize == null && nullToAbsent + ? const Value.absent() + : Value(mediaSize), + mediaWidth: mediaWidth == null && nullToAbsent + ? const Value.absent() + : Value(mediaWidth), + mediaHeight: mediaHeight == null && nullToAbsent + ? const Value.absent() + : Value(mediaHeight), + mediaMimeType: mediaMimeType == null && nullToAbsent + ? const Value.absent() + : Value(mediaMimeType), + mediaDuration: mediaDuration == null && nullToAbsent + ? const Value.absent() + : Value(mediaDuration), + mediaStatus: mediaStatus == null && nullToAbsent + ? const Value.absent() + : Value(mediaStatus), + mediaWaveform: mediaWaveform == null && nullToAbsent + ? const Value.absent() + : Value(mediaWaveform), + thumbImage: thumbImage == null && nullToAbsent + ? const Value.absent() + : Value(thumbImage), + thumbUrl: thumbUrl == null && nullToAbsent + ? const Value.absent() + : Value(thumbUrl), + mediaKey: mediaKey == null && nullToAbsent + ? const Value.absent() + : Value(mediaKey), + mediaDigest: mediaDigest == null && nullToAbsent + ? const Value.absent() + : Value(mediaDigest), + mediaCreatedAt: mediaCreatedAt == null && nullToAbsent + ? const Value.absent() + : Value(mediaCreatedAt), + stickerId: stickerId == null && nullToAbsent + ? const Value.absent() + : Value(stickerId), + sharedUserId: sharedUserId == null && nullToAbsent + ? const Value.absent() + : Value(sharedUserId), + mentions: mentions == null && nullToAbsent + ? const Value.absent() + : Value(mentions), + quoteId: quoteId == null && nullToAbsent + ? const Value.absent() + : Value(quoteId), + quoteContent: quoteContent == null && nullToAbsent + ? const Value.absent() + : Value(quoteContent), + caption: caption == null && nullToAbsent + ? const Value.absent() + : Value(caption), + ); } -} - -typedef FuzzySearchUser$firstFilter = Expression Function( - Users users, Conversations conversations); -typedef FuzzySearchUser$lastFilter = Expression Function( - Users users, Conversations conversations); -typedef FuzzySearchUserInCircle$filter = Expression Function(Users users, - Conversations conversations, CircleConversations circleConversation); -class MentionUser { - final String userId; - final String identityNumber; - final String? fullName; - MentionUser({ - required this.userId, - required this.identityNumber, - this.fullName, - }); - @override - int get hashCode => Object.hash(userId, identityNumber, fullName); - @override - bool operator ==(Object other) => - identical(this, other) || - (other is MentionUser && - other.userId == this.userId && - other.identityNumber == this.identityNumber && - other.fullName == this.fullName); + factory TranscriptMessage.fromJson(Map json, + {ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return TranscriptMessage( + transcriptId: serializer.fromJson(json['transcript_id']), + messageId: serializer.fromJson(json['message_id']), + userId: serializer.fromJson(json['user_id']), + userFullName: serializer.fromJson(json['user_full_name']), + category: serializer.fromJson(json['category']), + createdAt: serializer.fromJson(json['created_at']), + content: serializer.fromJson(json['content']), + mediaUrl: serializer.fromJson(json['media_url']), + mediaName: serializer.fromJson(json['media_name']), + mediaSize: serializer.fromJson(json['media_size']), + mediaWidth: serializer.fromJson(json['media_width']), + mediaHeight: serializer.fromJson(json['media_height']), + mediaMimeType: serializer.fromJson(json['media_mime_type']), + mediaDuration: serializer.fromJson(json['media_duration']), + mediaStatus: serializer.fromJson(json['media_status']), + mediaWaveform: serializer.fromJson(json['media_waveform']), + thumbImage: serializer.fromJson(json['thumb_image']), + thumbUrl: serializer.fromJson(json['thumb_url']), + mediaKey: serializer.fromJson(json['media_key']), + mediaDigest: serializer.fromJson(json['media_digest']), + mediaCreatedAt: serializer.fromJson(json['media_created_at']), + stickerId: serializer.fromJson(json['sticker_id']), + sharedUserId: serializer.fromJson(json['shared_user_id']), + mentions: serializer.fromJson(json['mentions']), + quoteId: serializer.fromJson(json['quote_id']), + quoteContent: serializer.fromJson(json['quote_content']), + caption: serializer.fromJson(json['caption']), + ); + } @override - String toString() { - return (StringBuffer('MentionUser(') - ..write('userId: $userId, ') - ..write('identityNumber: $identityNumber, ') - ..write('fullName: $fullName') - ..write(')')) - .toString(); + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'transcript_id': serializer.toJson(transcriptId), + 'message_id': serializer.toJson(messageId), + 'user_id': serializer.toJson(userId), + 'user_full_name': serializer.toJson(userFullName), + 'category': serializer.toJson(category), + 'created_at': serializer.toJson(createdAt), + 'content': serializer.toJson(content), + 'media_url': serializer.toJson(mediaUrl), + 'media_name': serializer.toJson(mediaName), + 'media_size': serializer.toJson(mediaSize), + 'media_width': serializer.toJson(mediaWidth), + 'media_height': serializer.toJson(mediaHeight), + 'media_mime_type': serializer.toJson(mediaMimeType), + 'media_duration': serializer.toJson(mediaDuration), + 'media_status': serializer.toJson(mediaStatus), + 'media_waveform': serializer.toJson(mediaWaveform), + 'thumb_image': serializer.toJson(thumbImage), + 'thumb_url': serializer.toJson(thumbUrl), + 'media_key': serializer.toJson(mediaKey), + 'media_digest': serializer.toJson(mediaDigest), + 'media_created_at': serializer.toJson(mediaCreatedAt), + 'sticker_id': serializer.toJson(stickerId), + 'shared_user_id': serializer.toJson(sharedUserId), + 'mentions': serializer.toJson(mentions), + 'quote_id': serializer.toJson(quoteId), + 'quote_content': serializer.toJson(quoteContent), + 'caption': serializer.toJson(caption), + }; } -} -class ParticipantSessionKey { - final String conversationId; - final String userId; - final String sessionId; - final String? publicKey; - ParticipantSessionKey({ - required this.conversationId, - required this.userId, - required this.sessionId, - this.publicKey, - }); - @override - int get hashCode => Object.hash(conversationId, userId, sessionId, publicKey); - @override - bool operator ==(Object other) => - identical(this, other) || - (other is ParticipantSessionKey && - other.conversationId == this.conversationId && - other.userId == this.userId && - other.sessionId == this.sessionId && - other.publicKey == this.publicKey); + TranscriptMessage copyWith( + {String? transcriptId, + String? messageId, + Value userId = const Value.absent(), + Value userFullName = const Value.absent(), + String? category, + DateTime? createdAt, + Value content = const Value.absent(), + Value mediaUrl = const Value.absent(), + Value mediaName = const Value.absent(), + Value mediaSize = const Value.absent(), + Value mediaWidth = const Value.absent(), + Value mediaHeight = const Value.absent(), + Value mediaMimeType = const Value.absent(), + Value mediaDuration = const Value.absent(), + Value mediaStatus = const Value.absent(), + Value mediaWaveform = const Value.absent(), + Value thumbImage = const Value.absent(), + Value thumbUrl = const Value.absent(), + Value mediaKey = const Value.absent(), + Value mediaDigest = const Value.absent(), + Value mediaCreatedAt = const Value.absent(), + Value stickerId = const Value.absent(), + Value sharedUserId = const Value.absent(), + Value mentions = const Value.absent(), + Value quoteId = const Value.absent(), + Value quoteContent = const Value.absent(), + Value caption = const Value.absent()}) => + TranscriptMessage( + transcriptId: transcriptId ?? this.transcriptId, + messageId: messageId ?? this.messageId, + userId: userId.present ? userId.value : this.userId, + userFullName: + userFullName.present ? userFullName.value : this.userFullName, + category: category ?? this.category, + createdAt: createdAt ?? this.createdAt, + content: content.present ? content.value : this.content, + mediaUrl: mediaUrl.present ? mediaUrl.value : this.mediaUrl, + mediaName: mediaName.present ? mediaName.value : this.mediaName, + mediaSize: mediaSize.present ? mediaSize.value : this.mediaSize, + mediaWidth: mediaWidth.present ? mediaWidth.value : this.mediaWidth, + mediaHeight: mediaHeight.present ? mediaHeight.value : this.mediaHeight, + mediaMimeType: + mediaMimeType.present ? mediaMimeType.value : this.mediaMimeType, + mediaDuration: + mediaDuration.present ? mediaDuration.value : this.mediaDuration, + mediaStatus: mediaStatus.present ? mediaStatus.value : this.mediaStatus, + mediaWaveform: + mediaWaveform.present ? mediaWaveform.value : this.mediaWaveform, + thumbImage: thumbImage.present ? thumbImage.value : this.thumbImage, + thumbUrl: thumbUrl.present ? thumbUrl.value : this.thumbUrl, + mediaKey: mediaKey.present ? mediaKey.value : this.mediaKey, + mediaDigest: mediaDigest.present ? mediaDigest.value : this.mediaDigest, + mediaCreatedAt: + mediaCreatedAt.present ? mediaCreatedAt.value : this.mediaCreatedAt, + stickerId: stickerId.present ? stickerId.value : this.stickerId, + sharedUserId: + sharedUserId.present ? sharedUserId.value : this.sharedUserId, + mentions: mentions.present ? mentions.value : this.mentions, + quoteId: quoteId.present ? quoteId.value : this.quoteId, + quoteContent: + quoteContent.present ? quoteContent.value : this.quoteContent, + caption: caption.present ? caption.value : this.caption, + ); @override String toString() { - return (StringBuffer('ParticipantSessionKey(') - ..write('conversationId: $conversationId, ') + return (StringBuffer('TranscriptMessage(') + ..write('transcriptId: $transcriptId, ') + ..write('messageId: $messageId, ') ..write('userId: $userId, ') - ..write('sessionId: $sessionId, ') - ..write('publicKey: $publicKey') - ..write(')')) - .toString(); - } -} - -class ParticipantUser { - final String conversationId; - final ParticipantRole? role; - final DateTime createdAt; - final String userId; - final String identityNumber; - final UserRelationship? relationship; - final String? biography; - final String? fullName; - final String? avatarUrl; - final String? phone; - final bool? isVerified; - final DateTime? userCreatedAt; - final DateTime? muteUntil; - final int? hasPin; - final String? appId; - final int? isScam; - ParticipantUser({ - required this.conversationId, - this.role, - required this.createdAt, - required this.userId, - required this.identityNumber, - this.relationship, - this.biography, - this.fullName, - this.avatarUrl, - this.phone, - this.isVerified, - this.userCreatedAt, - this.muteUntil, - this.hasPin, - this.appId, - this.isScam, - }); - @override - int get hashCode => Object.hash( - conversationId, - role, - createdAt, - userId, - identityNumber, - relationship, - biography, - fullName, - avatarUrl, - phone, - isVerified, - userCreatedAt, - muteUntil, - hasPin, - appId, - isScam); - @override - bool operator ==(Object other) => - identical(this, other) || - (other is ParticipantUser && - other.conversationId == this.conversationId && - other.role == this.role && - other.createdAt == this.createdAt && - other.userId == this.userId && - other.identityNumber == this.identityNumber && - other.relationship == this.relationship && - other.biography == this.biography && - other.fullName == this.fullName && - other.avatarUrl == this.avatarUrl && - other.phone == this.phone && - other.isVerified == this.isVerified && - other.userCreatedAt == this.userCreatedAt && - other.muteUntil == this.muteUntil && - other.hasPin == this.hasPin && - other.appId == this.appId && - other.isScam == this.isScam); - @override - String toString() { - return (StringBuffer('ParticipantUser(') - ..write('conversationId: $conversationId, ') - ..write('role: $role, ') + ..write('userFullName: $userFullName, ') + ..write('category: $category, ') ..write('createdAt: $createdAt, ') - ..write('userId: $userId, ') - ..write('identityNumber: $identityNumber, ') - ..write('relationship: $relationship, ') - ..write('biography: $biography, ') - ..write('fullName: $fullName, ') - ..write('avatarUrl: $avatarUrl, ') - ..write('phone: $phone, ') - ..write('isVerified: $isVerified, ') - ..write('userCreatedAt: $userCreatedAt, ') - ..write('muteUntil: $muteUntil, ') - ..write('hasPin: $hasPin, ') - ..write('appId: $appId, ') - ..write('isScam: $isScam') + ..write('content: $content, ') + ..write('mediaUrl: $mediaUrl, ') + ..write('mediaName: $mediaName, ') + ..write('mediaSize: $mediaSize, ') + ..write('mediaWidth: $mediaWidth, ') + ..write('mediaHeight: $mediaHeight, ') + ..write('mediaMimeType: $mediaMimeType, ') + ..write('mediaDuration: $mediaDuration, ') + ..write('mediaStatus: $mediaStatus, ') + ..write('mediaWaveform: $mediaWaveform, ') + ..write('thumbImage: $thumbImage, ') + ..write('thumbUrl: $thumbUrl, ') + ..write('mediaKey: $mediaKey, ') + ..write('mediaDigest: $mediaDigest, ') + ..write('mediaCreatedAt: $mediaCreatedAt, ') + ..write('stickerId: $stickerId, ') + ..write('sharedUserId: $sharedUserId, ') + ..write('mentions: $mentions, ') + ..write('quoteId: $quoteId, ') + ..write('quoteContent: $quoteContent, ') + ..write('caption: $caption') ..write(')')) .toString(); } -} - -typedef BaseMessageItems$where = Expression Function( - Messages message, - Users sender, - Users participant, - Snapshots snapshot, - Assets asset, - Chains chain, - Stickers sticker, - Hyperlinks hyperlink, - Users sharedUser, - Conversations conversation, - MessageMentions messageMention, - PinMessages pinMessage, - ExpiredMessages em); -typedef BaseMessageItems$order = OrderBy Function( - Messages message, - Users sender, - Users participant, - Snapshots snapshot, - Assets asset, - Chains chain, - Stickers sticker, - Hyperlinks hyperlink, - Users sharedUser, - Conversations conversation, - MessageMentions messageMention, - PinMessages pinMessage, - ExpiredMessages em); -typedef BaseMessageItems$limit = Limit Function( - Messages message, - Users sender, - Users participant, - Snapshots snapshot, - Assets asset, - Chains chain, - Stickers sticker, - Hyperlinks hyperlink, - Users sharedUser, - Conversations conversation, - MessageMentions messageMention, - PinMessages pinMessage, - ExpiredMessages em); -class QuoteMessageItem { - final String messageId; - final String conversationId; - final String userId; - final String? userFullName; - final String userIdentityNumber; - final String? appId; - final String type; - final String? content; - final DateTime createdAt; - final MessageStatus status; - final MediaStatus? mediaStatus; - final String? mediaWaveform; - final String? mediaName; - final String? mediaMimeType; - final int? mediaSize; - final int? mediaWidth; - final int? mediaHeight; - final String? thumbImage; - final String? thumbUrl; - final String? mediaUrl; - final String? mediaDuration; - final String? stickerId; - final String? assetUrl; - final int? assetWidth; - final int? assetHeight; - final String? assetName; - final String? assetType; - final String? sharedUserId; - final String? sharedUserFullName; - final String? sharedUserIdentityNumber; - final String? sharedUserAvatarUrl; - final bool? sharedUserIsVerified; - final String? sharedUserAppId; - QuoteMessageItem({ - required this.messageId, - required this.conversationId, - required this.userId, - this.userFullName, - required this.userIdentityNumber, - this.appId, - required this.type, - this.content, - required this.createdAt, - required this.status, - this.mediaStatus, - this.mediaWaveform, - this.mediaName, - this.mediaMimeType, - this.mediaSize, - this.mediaWidth, - this.mediaHeight, - this.thumbImage, - this.thumbUrl, - this.mediaUrl, - this.mediaDuration, - this.stickerId, - this.assetUrl, - this.assetWidth, - this.assetHeight, - this.assetName, - this.assetType, - this.sharedUserId, - this.sharedUserFullName, - this.sharedUserIdentityNumber, - this.sharedUserAvatarUrl, - this.sharedUserIsVerified, - this.sharedUserAppId, - }); @override int get hashCode => Object.hashAll([ + transcriptId, messageId, - conversationId, userId, userFullName, - userIdentityNumber, - appId, - type, - content, + category, createdAt, - status, - mediaStatus, - mediaWaveform, + content, + mediaUrl, mediaName, - mediaMimeType, mediaSize, mediaWidth, mediaHeight, + mediaMimeType, + mediaDuration, + mediaStatus, + mediaWaveform, thumbImage, thumbUrl, - mediaUrl, - mediaDuration, + mediaKey, + mediaDigest, + mediaCreatedAt, stickerId, - assetUrl, - assetWidth, - assetHeight, - assetName, - assetType, sharedUserId, - sharedUserFullName, - sharedUserIdentityNumber, - sharedUserAvatarUrl, - sharedUserIsVerified, - sharedUserAppId + mentions, + quoteId, + quoteContent, + caption ]); @override bool operator ==(Object other) => identical(this, other) || - (other is QuoteMessageItem && + (other is TranscriptMessage && + other.transcriptId == this.transcriptId && other.messageId == this.messageId && - other.conversationId == this.conversationId && other.userId == this.userId && other.userFullName == this.userFullName && - other.userIdentityNumber == this.userIdentityNumber && - other.appId == this.appId && - other.type == this.type && - other.content == this.content && + other.category == this.category && other.createdAt == this.createdAt && - other.status == this.status && - other.mediaStatus == this.mediaStatus && - other.mediaWaveform == this.mediaWaveform && + other.content == this.content && + other.mediaUrl == this.mediaUrl && other.mediaName == this.mediaName && - other.mediaMimeType == this.mediaMimeType && other.mediaSize == this.mediaSize && other.mediaWidth == this.mediaWidth && other.mediaHeight == this.mediaHeight && + other.mediaMimeType == this.mediaMimeType && + other.mediaDuration == this.mediaDuration && + other.mediaStatus == this.mediaStatus && + other.mediaWaveform == this.mediaWaveform && other.thumbImage == this.thumbImage && other.thumbUrl == this.thumbUrl && - other.mediaUrl == this.mediaUrl && - other.mediaDuration == this.mediaDuration && + other.mediaKey == this.mediaKey && + other.mediaDigest == this.mediaDigest && + other.mediaCreatedAt == this.mediaCreatedAt && other.stickerId == this.stickerId && - other.assetUrl == this.assetUrl && - other.assetWidth == this.assetWidth && - other.assetHeight == this.assetHeight && - other.assetName == this.assetName && - other.assetType == this.assetType && other.sharedUserId == this.sharedUserId && - other.sharedUserFullName == this.sharedUserFullName && - other.sharedUserIdentityNumber == this.sharedUserIdentityNumber && - other.sharedUserAvatarUrl == this.sharedUserAvatarUrl && - other.sharedUserIsVerified == this.sharedUserIsVerified && - other.sharedUserAppId == this.sharedUserAppId); - @override - String toString() { - return (StringBuffer('QuoteMessageItem(') - ..write('messageId: $messageId, ') - ..write('conversationId: $conversationId, ') - ..write('userId: $userId, ') - ..write('userFullName: $userFullName, ') - ..write('userIdentityNumber: $userIdentityNumber, ') - ..write('appId: $appId, ') - ..write('type: $type, ') - ..write('content: $content, ') - ..write('createdAt: $createdAt, ') - ..write('status: $status, ') - ..write('mediaStatus: $mediaStatus, ') - ..write('mediaWaveform: $mediaWaveform, ') - ..write('mediaName: $mediaName, ') - ..write('mediaMimeType: $mediaMimeType, ') - ..write('mediaSize: $mediaSize, ') - ..write('mediaWidth: $mediaWidth, ') - ..write('mediaHeight: $mediaHeight, ') - ..write('thumbImage: $thumbImage, ') - ..write('thumbUrl: $thumbUrl, ') - ..write('mediaUrl: $mediaUrl, ') - ..write('mediaDuration: $mediaDuration, ') - ..write('stickerId: $stickerId, ') - ..write('assetUrl: $assetUrl, ') - ..write('assetWidth: $assetWidth, ') - ..write('assetHeight: $assetHeight, ') - ..write('assetName: $assetName, ') - ..write('assetType: $assetType, ') - ..write('sharedUserId: $sharedUserId, ') - ..write('sharedUserFullName: $sharedUserFullName, ') - ..write('sharedUserIdentityNumber: $sharedUserIdentityNumber, ') - ..write('sharedUserAvatarUrl: $sharedUserAvatarUrl, ') - ..write('sharedUserIsVerified: $sharedUserIsVerified, ') - ..write('sharedUserAppId: $sharedUserAppId') - ..write(')')) - .toString(); + other.mentions == this.mentions && + other.quoteId == this.quoteId && + other.quoteContent == this.quoteContent && + other.caption == this.caption); +} + +class TranscriptMessagesCompanion extends UpdateCompanion { + final Value transcriptId; + final Value messageId; + final Value userId; + final Value userFullName; + final Value category; + final Value createdAt; + final Value content; + final Value mediaUrl; + final Value mediaName; + final Value mediaSize; + final Value mediaWidth; + final Value mediaHeight; + final Value mediaMimeType; + final Value mediaDuration; + final Value mediaStatus; + final Value mediaWaveform; + final Value thumbImage; + final Value thumbUrl; + final Value mediaKey; + final Value mediaDigest; + final Value mediaCreatedAt; + final Value stickerId; + final Value sharedUserId; + final Value mentions; + final Value quoteId; + final Value quoteContent; + final Value caption; + final Value rowid; + const TranscriptMessagesCompanion({ + this.transcriptId = const Value.absent(), + this.messageId = const Value.absent(), + this.userId = const Value.absent(), + this.userFullName = const Value.absent(), + this.category = const Value.absent(), + this.createdAt = const Value.absent(), + this.content = const Value.absent(), + this.mediaUrl = const Value.absent(), + this.mediaName = const Value.absent(), + this.mediaSize = const Value.absent(), + this.mediaWidth = const Value.absent(), + this.mediaHeight = const Value.absent(), + this.mediaMimeType = const Value.absent(), + this.mediaDuration = const Value.absent(), + this.mediaStatus = const Value.absent(), + this.mediaWaveform = const Value.absent(), + this.thumbImage = const Value.absent(), + this.thumbUrl = const Value.absent(), + this.mediaKey = const Value.absent(), + this.mediaDigest = const Value.absent(), + this.mediaCreatedAt = const Value.absent(), + this.stickerId = const Value.absent(), + this.sharedUserId = const Value.absent(), + this.mentions = const Value.absent(), + this.quoteId = const Value.absent(), + this.quoteContent = const Value.absent(), + this.caption = const Value.absent(), + this.rowid = const Value.absent(), + }); + TranscriptMessagesCompanion.insert({ + required String transcriptId, + required String messageId, + this.userId = const Value.absent(), + this.userFullName = const Value.absent(), + required String category, + required DateTime createdAt, + this.content = const Value.absent(), + this.mediaUrl = const Value.absent(), + this.mediaName = const Value.absent(), + this.mediaSize = const Value.absent(), + this.mediaWidth = const Value.absent(), + this.mediaHeight = const Value.absent(), + this.mediaMimeType = const Value.absent(), + this.mediaDuration = const Value.absent(), + this.mediaStatus = const Value.absent(), + this.mediaWaveform = const Value.absent(), + this.thumbImage = const Value.absent(), + this.thumbUrl = const Value.absent(), + this.mediaKey = const Value.absent(), + this.mediaDigest = const Value.absent(), + this.mediaCreatedAt = const Value.absent(), + this.stickerId = const Value.absent(), + this.sharedUserId = const Value.absent(), + this.mentions = const Value.absent(), + this.quoteId = const Value.absent(), + this.quoteContent = const Value.absent(), + this.caption = const Value.absent(), + this.rowid = const Value.absent(), + }) : transcriptId = Value(transcriptId), + messageId = Value(messageId), + category = Value(category), + createdAt = Value(createdAt); + static Insertable custom({ + Expression? transcriptId, + Expression? messageId, + Expression? userId, + Expression? userFullName, + Expression? category, + Expression? createdAt, + Expression? content, + Expression? mediaUrl, + Expression? mediaName, + Expression? mediaSize, + Expression? mediaWidth, + Expression? mediaHeight, + Expression? mediaMimeType, + Expression? mediaDuration, + Expression? mediaStatus, + Expression? mediaWaveform, + Expression? thumbImage, + Expression? thumbUrl, + Expression? mediaKey, + Expression? mediaDigest, + Expression? mediaCreatedAt, + Expression? stickerId, + Expression? sharedUserId, + Expression? mentions, + Expression? quoteId, + Expression? quoteContent, + Expression? caption, + Expression? rowid, + }) { + return RawValuesInsertable({ + if (transcriptId != null) 'transcript_id': transcriptId, + if (messageId != null) 'message_id': messageId, + if (userId != null) 'user_id': userId, + if (userFullName != null) 'user_full_name': userFullName, + if (category != null) 'category': category, + if (createdAt != null) 'created_at': createdAt, + if (content != null) 'content': content, + if (mediaUrl != null) 'media_url': mediaUrl, + if (mediaName != null) 'media_name': mediaName, + if (mediaSize != null) 'media_size': mediaSize, + if (mediaWidth != null) 'media_width': mediaWidth, + if (mediaHeight != null) 'media_height': mediaHeight, + if (mediaMimeType != null) 'media_mime_type': mediaMimeType, + if (mediaDuration != null) 'media_duration': mediaDuration, + if (mediaStatus != null) 'media_status': mediaStatus, + if (mediaWaveform != null) 'media_waveform': mediaWaveform, + if (thumbImage != null) 'thumb_image': thumbImage, + if (thumbUrl != null) 'thumb_url': thumbUrl, + if (mediaKey != null) 'media_key': mediaKey, + if (mediaDigest != null) 'media_digest': mediaDigest, + if (mediaCreatedAt != null) 'media_created_at': mediaCreatedAt, + if (stickerId != null) 'sticker_id': stickerId, + if (sharedUserId != null) 'shared_user_id': sharedUserId, + if (mentions != null) 'mentions': mentions, + if (quoteId != null) 'quote_id': quoteId, + if (quoteContent != null) 'quote_content': quoteContent, + if (caption != null) 'caption': caption, + if (rowid != null) 'rowid': rowid, + }); + } + + TranscriptMessagesCompanion copyWith( + {Value? transcriptId, + Value? messageId, + Value? userId, + Value? userFullName, + Value? category, + Value? createdAt, + Value? content, + Value? mediaUrl, + Value? mediaName, + Value? mediaSize, + Value? mediaWidth, + Value? mediaHeight, + Value? mediaMimeType, + Value? mediaDuration, + Value? mediaStatus, + Value? mediaWaveform, + Value? thumbImage, + Value? thumbUrl, + Value? mediaKey, + Value? mediaDigest, + Value? mediaCreatedAt, + Value? stickerId, + Value? sharedUserId, + Value? mentions, + Value? quoteId, + Value? quoteContent, + Value? caption, + Value? rowid}) { + return TranscriptMessagesCompanion( + transcriptId: transcriptId ?? this.transcriptId, + messageId: messageId ?? this.messageId, + userId: userId ?? this.userId, + userFullName: userFullName ?? this.userFullName, + category: category ?? this.category, + createdAt: createdAt ?? this.createdAt, + content: content ?? this.content, + mediaUrl: mediaUrl ?? this.mediaUrl, + mediaName: mediaName ?? this.mediaName, + mediaSize: mediaSize ?? this.mediaSize, + mediaWidth: mediaWidth ?? this.mediaWidth, + mediaHeight: mediaHeight ?? this.mediaHeight, + mediaMimeType: mediaMimeType ?? this.mediaMimeType, + mediaDuration: mediaDuration ?? this.mediaDuration, + mediaStatus: mediaStatus ?? this.mediaStatus, + mediaWaveform: mediaWaveform ?? this.mediaWaveform, + thumbImage: thumbImage ?? this.thumbImage, + thumbUrl: thumbUrl ?? this.thumbUrl, + mediaKey: mediaKey ?? this.mediaKey, + mediaDigest: mediaDigest ?? this.mediaDigest, + mediaCreatedAt: mediaCreatedAt ?? this.mediaCreatedAt, + stickerId: stickerId ?? this.stickerId, + sharedUserId: sharedUserId ?? this.sharedUserId, + mentions: mentions ?? this.mentions, + quoteId: quoteId ?? this.quoteId, + quoteContent: quoteContent ?? this.quoteContent, + caption: caption ?? this.caption, + rowid: rowid ?? this.rowid, + ); } -} - -typedef BaseQuoteMessageItem$where = Expression Function( - Messages message, - Users sender, - Stickers sticker, - Users shareUser, - MessageMentions messageMention); -typedef BaseQuoteMessageItem$order = OrderBy Function( - Messages message, - Users sender, - Stickers sticker, - Users shareUser, - MessageMentions messageMention); -typedef BaseQuoteMessageItem$limit = Limit Function( - Messages message, - Users sender, - Stickers sticker, - Users shareUser, - MessageMentions messageMention); -class SendingMessage { - final String messageId; - final String conversationId; - final String userId; - final String category; - final String? content; - final String? mediaUrl; - final String? mediaMimeType; - final int? mediaSize; - final String? mediaDuration; - final int? mediaWidth; - final int? mediaHeight; - final String? mediaHash; - final String? thumbImage; - final String? mediaKey; - final String? mediaDigest; - final MediaStatus? mediaStatus; - final MessageStatus status; - final DateTime createdAt; - final String? action; - final String? participantId; - final String? snapshotId; - final String? hyperlink; - final String? name; - final String? albumId; - final String? stickerId; - final String? sharedUserId; - final String? mediaWaveform; - final String? quoteMessageId; - final String? quoteContent; - final int? resendStatus; - final String? resendUserId; - final String? resendSessionId; - SendingMessage({ - required this.messageId, - required this.conversationId, - required this.userId, - required this.category, - this.content, - this.mediaUrl, - this.mediaMimeType, - this.mediaSize, - this.mediaDuration, - this.mediaWidth, - this.mediaHeight, - this.mediaHash, - this.thumbImage, - this.mediaKey, - this.mediaDigest, - this.mediaStatus, - required this.status, - required this.createdAt, - this.action, - this.participantId, - this.snapshotId, - this.hyperlink, - this.name, - this.albumId, - this.stickerId, - this.sharedUserId, - this.mediaWaveform, - this.quoteMessageId, - this.quoteContent, - this.resendStatus, - this.resendUserId, - this.resendSessionId, - }); - @override - int get hashCode => Object.hashAll([ - messageId, - conversationId, - userId, - category, - content, - mediaUrl, - mediaMimeType, - mediaSize, - mediaDuration, - mediaWidth, - mediaHeight, - mediaHash, - thumbImage, - mediaKey, - mediaDigest, - mediaStatus, - status, - createdAt, - action, - participantId, - snapshotId, - hyperlink, - name, - albumId, - stickerId, - sharedUserId, - mediaWaveform, - quoteMessageId, - quoteContent, - resendStatus, - resendUserId, - resendSessionId - ]); @override - bool operator ==(Object other) => - identical(this, other) || - (other is SendingMessage && - other.messageId == this.messageId && - other.conversationId == this.conversationId && - other.userId == this.userId && - other.category == this.category && - other.content == this.content && - other.mediaUrl == this.mediaUrl && - other.mediaMimeType == this.mediaMimeType && - other.mediaSize == this.mediaSize && - other.mediaDuration == this.mediaDuration && - other.mediaWidth == this.mediaWidth && - other.mediaHeight == this.mediaHeight && - other.mediaHash == this.mediaHash && - other.thumbImage == this.thumbImage && - other.mediaKey == this.mediaKey && - other.mediaDigest == this.mediaDigest && - other.mediaStatus == this.mediaStatus && - other.status == this.status && - other.createdAt == this.createdAt && - other.action == this.action && - other.participantId == this.participantId && - other.snapshotId == this.snapshotId && - other.hyperlink == this.hyperlink && - other.name == this.name && - other.albumId == this.albumId && - other.stickerId == this.stickerId && - other.sharedUserId == this.sharedUserId && - other.mediaWaveform == this.mediaWaveform && - other.quoteMessageId == this.quoteMessageId && - other.quoteContent == this.quoteContent && - other.resendStatus == this.resendStatus && - other.resendUserId == this.resendUserId && - other.resendSessionId == this.resendSessionId); + Map toColumns(bool nullToAbsent) { + final map = {}; + if (transcriptId.present) { + map['transcript_id'] = Variable(transcriptId.value); + } + if (messageId.present) { + map['message_id'] = Variable(messageId.value); + } + if (userId.present) { + map['user_id'] = Variable(userId.value); + } + if (userFullName.present) { + map['user_full_name'] = Variable(userFullName.value); + } + if (category.present) { + map['category'] = Variable(category.value); + } + if (createdAt.present) { + final converter = TranscriptMessages.$convertercreatedAt; + map['created_at'] = Variable(converter.toSql(createdAt.value)); + } + if (content.present) { + map['content'] = Variable(content.value); + } + if (mediaUrl.present) { + map['media_url'] = Variable(mediaUrl.value); + } + if (mediaName.present) { + map['media_name'] = Variable(mediaName.value); + } + if (mediaSize.present) { + map['media_size'] = Variable(mediaSize.value); + } + if (mediaWidth.present) { + map['media_width'] = Variable(mediaWidth.value); + } + if (mediaHeight.present) { + map['media_height'] = Variable(mediaHeight.value); + } + if (mediaMimeType.present) { + map['media_mime_type'] = Variable(mediaMimeType.value); + } + if (mediaDuration.present) { + map['media_duration'] = Variable(mediaDuration.value); + } + if (mediaStatus.present) { + final converter = TranscriptMessages.$convertermediaStatus; + map['media_status'] = + Variable(converter.toSql(mediaStatus.value)); + } + if (mediaWaveform.present) { + map['media_waveform'] = Variable(mediaWaveform.value); + } + if (thumbImage.present) { + map['thumb_image'] = Variable(thumbImage.value); + } + if (thumbUrl.present) { + map['thumb_url'] = Variable(thumbUrl.value); + } + if (mediaKey.present) { + map['media_key'] = Variable(mediaKey.value); + } + if (mediaDigest.present) { + map['media_digest'] = Variable(mediaDigest.value); + } + if (mediaCreatedAt.present) { + final converter = TranscriptMessages.$convertermediaCreatedAtn; + map['media_created_at'] = + Variable(converter.toSql(mediaCreatedAt.value)); + } + if (stickerId.present) { + map['sticker_id'] = Variable(stickerId.value); + } + if (sharedUserId.present) { + map['shared_user_id'] = Variable(sharedUserId.value); + } + if (mentions.present) { + map['mentions'] = Variable(mentions.value); + } + if (quoteId.present) { + map['quote_id'] = Variable(quoteId.value); + } + if (quoteContent.present) { + map['quote_content'] = Variable(quoteContent.value); + } + if (caption.present) { + map['caption'] = Variable(caption.value); + } + if (rowid.present) { + map['rowid'] = Variable(rowid.value); + } + return map; + } + @override String toString() { - return (StringBuffer('SendingMessage(') + return (StringBuffer('TranscriptMessagesCompanion(') + ..write('transcriptId: $transcriptId, ') ..write('messageId: $messageId, ') - ..write('conversationId: $conversationId, ') ..write('userId: $userId, ') + ..write('userFullName: $userFullName, ') ..write('category: $category, ') + ..write('createdAt: $createdAt, ') ..write('content: $content, ') ..write('mediaUrl: $mediaUrl, ') - ..write('mediaMimeType: $mediaMimeType, ') + ..write('mediaName: $mediaName, ') ..write('mediaSize: $mediaSize, ') - ..write('mediaDuration: $mediaDuration, ') ..write('mediaWidth: $mediaWidth, ') ..write('mediaHeight: $mediaHeight, ') - ..write('mediaHash: $mediaHash, ') + ..write('mediaMimeType: $mediaMimeType, ') + ..write('mediaDuration: $mediaDuration, ') + ..write('mediaStatus: $mediaStatus, ') + ..write('mediaWaveform: $mediaWaveform, ') ..write('thumbImage: $thumbImage, ') + ..write('thumbUrl: $thumbUrl, ') ..write('mediaKey: $mediaKey, ') ..write('mediaDigest: $mediaDigest, ') - ..write('mediaStatus: $mediaStatus, ') - ..write('status: $status, ') - ..write('createdAt: $createdAt, ') - ..write('action: $action, ') - ..write('participantId: $participantId, ') - ..write('snapshotId: $snapshotId, ') - ..write('hyperlink: $hyperlink, ') - ..write('name: $name, ') - ..write('albumId: $albumId, ') + ..write('mediaCreatedAt: $mediaCreatedAt, ') ..write('stickerId: $stickerId, ') ..write('sharedUserId: $sharedUserId, ') - ..write('mediaWaveform: $mediaWaveform, ') - ..write('quoteMessageId: $quoteMessageId, ') + ..write('mentions: $mentions, ') + ..write('quoteId: $quoteId, ') ..write('quoteContent: $quoteContent, ') - ..write('resendStatus: $resendStatus, ') - ..write('resendUserId: $resendUserId, ') - ..write('resendSessionId: $resendSessionId') + ..write('caption: $caption, ') + ..write('rowid: $rowid') + ..write(')')) + .toString(); + } +} + +class Fiats extends Table with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + Fiats(this.attachedDatabase, [this._alias]); + static const VerificationMeta _codeMeta = const VerificationMeta('code'); + late final GeneratedColumn code = GeneratedColumn( + 'code', aliasedName, false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL'); + static const VerificationMeta _rateMeta = const VerificationMeta('rate'); + late final GeneratedColumn rate = GeneratedColumn( + 'rate', aliasedName, false, + type: DriftSqlType.double, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL'); + @override + List get $columns => [code, rate]; + @override + String get aliasedName => _alias ?? 'fiats'; + @override + String get actualTableName => 'fiats'; + @override + VerificationContext validateIntegrity(Insertable instance, + {bool isInserting = false}) { + final context = VerificationContext(); + final data = instance.toColumns(true); + if (data.containsKey('code')) { + context.handle( + _codeMeta, code.isAcceptableOrUnknown(data['code']!, _codeMeta)); + } else if (isInserting) { + context.missing(_codeMeta); + } + if (data.containsKey('rate')) { + context.handle( + _rateMeta, rate.isAcceptableOrUnknown(data['rate']!, _rateMeta)); + } else if (isInserting) { + context.missing(_rateMeta); + } + return context; + } + + @override + Set get $primaryKey => {code}; + @override + Fiat map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return Fiat( + code: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}code'])!, + rate: attachedDatabase.typeMapping + .read(DriftSqlType.double, data['${effectivePrefix}rate'])!, + ); + } + + @override + Fiats createAlias(String alias) { + return Fiats(attachedDatabase, alias); + } + + @override + List get customConstraints => const ['PRIMARY KEY(code)']; + @override + bool get dontWriteConstraints => true; +} + +class Fiat extends DataClass implements Insertable { + final String code; + final double rate; + const Fiat({required this.code, required this.rate}); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['code'] = Variable(code); + map['rate'] = Variable(rate); + return map; + } + + FiatsCompanion toCompanion(bool nullToAbsent) { + return FiatsCompanion( + code: Value(code), + rate: Value(rate), + ); + } + + factory Fiat.fromJson(Map json, + {ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return Fiat( + code: serializer.fromJson(json['code']), + rate: serializer.fromJson(json['rate']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'code': serializer.toJson(code), + 'rate': serializer.toJson(rate), + }; + } + + Fiat copyWith({String? code, double? rate}) => Fiat( + code: code ?? this.code, + rate: rate ?? this.rate, + ); + @override + String toString() { + return (StringBuffer('Fiat(') + ..write('code: $code, ') + ..write('rate: $rate') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash(code, rate); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is Fiat && other.code == this.code && other.rate == this.rate); +} + +class FiatsCompanion extends UpdateCompanion { + final Value code; + final Value rate; + final Value rowid; + const FiatsCompanion({ + this.code = const Value.absent(), + this.rate = const Value.absent(), + this.rowid = const Value.absent(), + }); + FiatsCompanion.insert({ + required String code, + required double rate, + this.rowid = const Value.absent(), + }) : code = Value(code), + rate = Value(rate); + static Insertable custom({ + Expression? code, + Expression? rate, + Expression? rowid, + }) { + return RawValuesInsertable({ + if (code != null) 'code': code, + if (rate != null) 'rate': rate, + if (rowid != null) 'rowid': rowid, + }); + } + + FiatsCompanion copyWith( + {Value? code, Value? rate, Value? rowid}) { + return FiatsCompanion( + code: code ?? this.code, + rate: rate ?? this.rate, + rowid: rowid ?? this.rowid, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (code.present) { + map['code'] = Variable(code.value); + } + if (rate.present) { + map['rate'] = Variable(rate.value); + } + if (rowid.present) { + map['rowid'] = Variable(rowid.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('FiatsCompanion(') + ..write('code: $code, ') + ..write('rate: $rate, ') + ..write('rowid: $rowid') ..write(')')) .toString(); } } -class NotificationMessage { - final String messageId; - final String conversationId; - final String senderId; - final String? senderFullName; - final String type; - final String? content; - final String? quoteContent; - final MessageStatus status; - final String? groupName; - final DateTime? muteUntil; - final DateTime? ownerMuteUntil; - final String? ownerUserId; - final String? ownerFullName; +class FavoriteApps extends Table with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + FavoriteApps(this.attachedDatabase, [this._alias]); + static const VerificationMeta _appIdMeta = const VerificationMeta('appId'); + late final GeneratedColumn appId = GeneratedColumn( + 'app_id', aliasedName, false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL'); + static const VerificationMeta _userIdMeta = const VerificationMeta('userId'); + late final GeneratedColumn userId = GeneratedColumn( + 'user_id', aliasedName, false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL'); + static const VerificationMeta _createdAtMeta = + const VerificationMeta('createdAt'); + late final GeneratedColumnWithTypeConverter createdAt = + GeneratedColumn('created_at', aliasedName, false, + type: DriftSqlType.int, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL') + .withConverter(FavoriteApps.$convertercreatedAt); + @override + List get $columns => [appId, userId, createdAt]; + @override + String get aliasedName => _alias ?? 'favorite_apps'; + @override + String get actualTableName => 'favorite_apps'; + @override + VerificationContext validateIntegrity(Insertable instance, + {bool isInserting = false}) { + final context = VerificationContext(); + final data = instance.toColumns(true); + if (data.containsKey('app_id')) { + context.handle( + _appIdMeta, appId.isAcceptableOrUnknown(data['app_id']!, _appIdMeta)); + } else if (isInserting) { + context.missing(_appIdMeta); + } + if (data.containsKey('user_id')) { + context.handle(_userIdMeta, + userId.isAcceptableOrUnknown(data['user_id']!, _userIdMeta)); + } else if (isInserting) { + context.missing(_userIdMeta); + } + context.handle(_createdAtMeta, const VerificationResult.success()); + return context; + } + + @override + Set get $primaryKey => {appId, userId}; + @override + FavoriteApp map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return FavoriteApp( + appId: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}app_id'])!, + userId: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}user_id'])!, + createdAt: FavoriteApps.$convertercreatedAt.fromSql(attachedDatabase + .typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}created_at'])!), + ); + } + + @override + FavoriteApps createAlias(String alias) { + return FavoriteApps(attachedDatabase, alias); + } + + static TypeConverter $convertercreatedAt = + const MillisDateConverter(); + @override + List get customConstraints => const ['PRIMARY KEY(app_id, user_id)']; + @override + bool get dontWriteConstraints => true; +} + +class FavoriteApp extends DataClass implements Insertable { + final String appId; + final String userId; final DateTime createdAt; - final ConversationCategory? category; - final String? actionName; - final UserRelationship? relationship; - final String? participantFullName; - final String? participantUserId; - NotificationMessage({ - required this.messageId, - required this.conversationId, - required this.senderId, - this.senderFullName, - required this.type, - this.content, - this.quoteContent, - required this.status, - this.groupName, - this.muteUntil, - this.ownerMuteUntil, - this.ownerUserId, - this.ownerFullName, - required this.createdAt, - this.category, - this.actionName, - this.relationship, - this.participantFullName, - this.participantUserId, - }); + const FavoriteApp( + {required this.appId, required this.userId, required this.createdAt}); @override - int get hashCode => Object.hash( - messageId, - conversationId, - senderId, - senderFullName, - type, - content, - quoteContent, - status, - groupName, - muteUntil, - ownerMuteUntil, - ownerUserId, - ownerFullName, - createdAt, - category, - actionName, - relationship, - participantFullName, - participantUserId); + Map toColumns(bool nullToAbsent) { + final map = {}; + map['app_id'] = Variable(appId); + map['user_id'] = Variable(userId); + { + final converter = FavoriteApps.$convertercreatedAt; + map['created_at'] = Variable(converter.toSql(createdAt)); + } + return map; + } + + FavoriteAppsCompanion toCompanion(bool nullToAbsent) { + return FavoriteAppsCompanion( + appId: Value(appId), + userId: Value(userId), + createdAt: Value(createdAt), + ); + } + + factory FavoriteApp.fromJson(Map json, + {ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return FavoriteApp( + appId: serializer.fromJson(json['app_id']), + userId: serializer.fromJson(json['user_id']), + createdAt: serializer.fromJson(json['created_at']), + ); + } @override - bool operator ==(Object other) => - identical(this, other) || - (other is NotificationMessage && - other.messageId == this.messageId && - other.conversationId == this.conversationId && - other.senderId == this.senderId && - other.senderFullName == this.senderFullName && - other.type == this.type && - other.content == this.content && - other.quoteContent == this.quoteContent && - other.status == this.status && - other.groupName == this.groupName && - other.muteUntil == this.muteUntil && - other.ownerMuteUntil == this.ownerMuteUntil && - other.ownerUserId == this.ownerUserId && - other.ownerFullName == this.ownerFullName && - other.createdAt == this.createdAt && - other.category == this.category && - other.actionName == this.actionName && - other.relationship == this.relationship && - other.participantFullName == this.participantFullName && - other.participantUserId == this.participantUserId); + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'app_id': serializer.toJson(appId), + 'user_id': serializer.toJson(userId), + 'created_at': serializer.toJson(createdAt), + }; + } + + FavoriteApp copyWith({String? appId, String? userId, DateTime? createdAt}) => + FavoriteApp( + appId: appId ?? this.appId, + userId: userId ?? this.userId, + createdAt: createdAt ?? this.createdAt, + ); @override String toString() { - return (StringBuffer('NotificationMessage(') - ..write('messageId: $messageId, ') - ..write('conversationId: $conversationId, ') - ..write('senderId: $senderId, ') - ..write('senderFullName: $senderFullName, ') - ..write('type: $type, ') - ..write('content: $content, ') - ..write('quoteContent: $quoteContent, ') - ..write('status: $status, ') - ..write('groupName: $groupName, ') - ..write('muteUntil: $muteUntil, ') - ..write('ownerMuteUntil: $ownerMuteUntil, ') - ..write('ownerUserId: $ownerUserId, ') - ..write('ownerFullName: $ownerFullName, ') - ..write('createdAt: $createdAt, ') - ..write('category: $category, ') - ..write('actionName: $actionName, ') - ..write('relationship: $relationship, ') - ..write('participantFullName: $participantFullName, ') - ..write('participantUserId: $participantUserId') + return (StringBuffer('FavoriteApp(') + ..write('appId: $appId, ') + ..write('userId: $userId, ') + ..write('createdAt: $createdAt') ..write(')')) .toString(); } -} -class SearchMessageDetailItem { - final String messageId; - final String senderId; - final String? senderAvatarUrl; - final String? senderFullName; - final MessageStatus status; - final String type; - final String? content; - final DateTime createdAt; - final String? mediaName; - final String? appId; - final bool? verified; - final String? ownerId; - final String? groupIconUrl; - final ConversationCategory? category; - final String? groupName; - final String conversationId; - final String? ownerFullName; - final String? ownerAvatarUrl; - SearchMessageDetailItem({ - required this.messageId, - required this.senderId, - this.senderAvatarUrl, - this.senderFullName, - required this.status, - required this.type, - this.content, - required this.createdAt, - this.mediaName, - this.appId, - this.verified, - this.ownerId, - this.groupIconUrl, - this.category, - this.groupName, - required this.conversationId, - this.ownerFullName, - this.ownerAvatarUrl, - }); @override - int get hashCode => Object.hash( - messageId, - senderId, - senderAvatarUrl, - senderFullName, - status, - type, - content, - createdAt, - mediaName, - appId, - verified, - ownerId, - groupIconUrl, - category, - groupName, - conversationId, - ownerFullName, - ownerAvatarUrl); + int get hashCode => Object.hash(appId, userId, createdAt); @override bool operator ==(Object other) => identical(this, other) || - (other is SearchMessageDetailItem && - other.messageId == this.messageId && - other.senderId == this.senderId && - other.senderAvatarUrl == this.senderAvatarUrl && - other.senderFullName == this.senderFullName && - other.status == this.status && - other.type == this.type && - other.content == this.content && - other.createdAt == this.createdAt && - other.mediaName == this.mediaName && + (other is FavoriteApp && other.appId == this.appId && - other.verified == this.verified && - other.ownerId == this.ownerId && - other.groupIconUrl == this.groupIconUrl && - other.category == this.category && - other.groupName == this.groupName && - other.conversationId == this.conversationId && - other.ownerFullName == this.ownerFullName && - other.ownerAvatarUrl == this.ownerAvatarUrl); + other.userId == this.userId && + other.createdAt == this.createdAt); +} + +class FavoriteAppsCompanion extends UpdateCompanion { + final Value appId; + final Value userId; + final Value createdAt; + final Value rowid; + const FavoriteAppsCompanion({ + this.appId = const Value.absent(), + this.userId = const Value.absent(), + this.createdAt = const Value.absent(), + this.rowid = const Value.absent(), + }); + FavoriteAppsCompanion.insert({ + required String appId, + required String userId, + required DateTime createdAt, + this.rowid = const Value.absent(), + }) : appId = Value(appId), + userId = Value(userId), + createdAt = Value(createdAt); + static Insertable custom({ + Expression? appId, + Expression? userId, + Expression? createdAt, + Expression? rowid, + }) { + return RawValuesInsertable({ + if (appId != null) 'app_id': appId, + if (userId != null) 'user_id': userId, + if (createdAt != null) 'created_at': createdAt, + if (rowid != null) 'rowid': rowid, + }); + } + + FavoriteAppsCompanion copyWith( + {Value? appId, + Value? userId, + Value? createdAt, + Value? rowid}) { + return FavoriteAppsCompanion( + appId: appId ?? this.appId, + userId: userId ?? this.userId, + createdAt: createdAt ?? this.createdAt, + rowid: rowid ?? this.rowid, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (appId.present) { + map['app_id'] = Variable(appId.value); + } + if (userId.present) { + map['user_id'] = Variable(userId.value); + } + if (createdAt.present) { + final converter = FavoriteApps.$convertercreatedAt; + map['created_at'] = Variable(converter.toSql(createdAt.value)); + } + if (rowid.present) { + map['rowid'] = Variable(rowid.value); + } + return map; + } + @override String toString() { - return (StringBuffer('SearchMessageDetailItem(') - ..write('messageId: $messageId, ') - ..write('senderId: $senderId, ') - ..write('senderAvatarUrl: $senderAvatarUrl, ') - ..write('senderFullName: $senderFullName, ') - ..write('status: $status, ') - ..write('type: $type, ') - ..write('content: $content, ') - ..write('createdAt: $createdAt, ') - ..write('mediaName: $mediaName, ') + return (StringBuffer('FavoriteAppsCompanion(') ..write('appId: $appId, ') - ..write('verified: $verified, ') - ..write('ownerId: $ownerId, ') - ..write('groupIconUrl: $groupIconUrl, ') - ..write('category: $category, ') - ..write('groupName: $groupName, ') - ..write('conversationId: $conversationId, ') - ..write('ownerFullName: $ownerFullName, ') - ..write('ownerAvatarUrl: $ownerAvatarUrl') + ..write('userId: $userId, ') + ..write('createdAt: $createdAt, ') + ..write('rowid: $rowid') ..write(')')) .toString(); } } -class MiniMessageItem { - final String conversationId; - final String messageId; - MiniMessageItem({ - required this.conversationId, - required this.messageId, - }); +class Properties extends Table with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + Properties(this.attachedDatabase, [this._alias]); + static const VerificationMeta _keyMeta = const VerificationMeta('key'); + late final GeneratedColumn key = GeneratedColumn( + 'key', aliasedName, false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL'); + static const VerificationMeta _groupMeta = const VerificationMeta('group'); + late final GeneratedColumnWithTypeConverter group = + GeneratedColumn('group', aliasedName, false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL') + .withConverter(Properties.$convertergroup); + static const VerificationMeta _valueMeta = const VerificationMeta('value'); + late final GeneratedColumn value = GeneratedColumn( + 'value', aliasedName, false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL'); @override - int get hashCode => Object.hash(conversationId, messageId); + List get $columns => [key, group, value]; @override - bool operator ==(Object other) => - identical(this, other) || - (other is MiniMessageItem && - other.conversationId == this.conversationId && - other.messageId == this.messageId); + String get aliasedName => _alias ?? 'properties'; @override - String toString() { - return (StringBuffer('MiniMessageItem(') - ..write('conversationId: $conversationId, ') - ..write('messageId: $messageId') - ..write(')')) - .toString(); + String get actualTableName => 'properties'; + @override + VerificationContext validateIntegrity(Insertable instance, + {bool isInserting = false}) { + final context = VerificationContext(); + final data = instance.toColumns(true); + if (data.containsKey('key')) { + context.handle( + _keyMeta, key.isAcceptableOrUnknown(data['key']!, _keyMeta)); + } else if (isInserting) { + context.missing(_keyMeta); + } + context.handle(_groupMeta, const VerificationResult.success()); + if (data.containsKey('value')) { + context.handle( + _valueMeta, value.isAcceptableOrUnknown(data['value']!, _valueMeta)); + } else if (isInserting) { + context.missing(_valueMeta); + } + return context; } -} -typedef SearchMessage$where = Expression Function( - Messages m, Conversations c, Users u, Users owner); -typedef SearchMessage$limit = Limit Function( - Messages m, Conversations c, Users u, Users owner); + @override + Set get $primaryKey => {key, group}; + @override + Propertie map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return Propertie( + key: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}key'])!, + group: Properties.$convertergroup.fromSql(attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}group'])!), + value: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}value'])!, + ); + } -class QuoteMinimal { - final int rowid; - final String conversationId; - final String? quoteMessageId; - QuoteMinimal({ - required this.rowid, - required this.conversationId, - this.quoteMessageId, - }); @override - int get hashCode => Object.hash(rowid, conversationId, quoteMessageId); + Properties createAlias(String alias) { + return Properties(attachedDatabase, alias); + } + + static TypeConverter $convertergroup = + const PropertyGroupConverter(); @override - bool operator ==(Object other) => - identical(this, other) || - (other is QuoteMinimal && - other.rowid == this.rowid && - other.conversationId == this.conversationId && - other.quoteMessageId == this.quoteMessageId); + List get customConstraints => const ['PRIMARY KEY("key", "group")']; + @override + bool get dontWriteConstraints => true; +} + +class Propertie extends DataClass implements Insertable { + final String key; + final PropertyGroup group; + final String value; + const Propertie( + {required this.key, required this.group, required this.value}); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['key'] = Variable(key); + { + final converter = Properties.$convertergroup; + map['group'] = Variable(converter.toSql(group)); + } + map['value'] = Variable(value); + return map; + } + + PropertiesCompanion toCompanion(bool nullToAbsent) { + return PropertiesCompanion( + key: Value(key), + group: Value(group), + value: Value(value), + ); + } + + factory Propertie.fromJson(Map json, + {ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return Propertie( + key: serializer.fromJson(json['key']), + group: serializer.fromJson(json['group']), + value: serializer.fromJson(json['value']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'key': serializer.toJson(key), + 'group': serializer.toJson(group), + 'value': serializer.toJson(value), + }; + } + + Propertie copyWith({String? key, PropertyGroup? group, String? value}) => + Propertie( + key: key ?? this.key, + group: group ?? this.group, + value: value ?? this.value, + ); @override String toString() { - return (StringBuffer('QuoteMinimal(') - ..write('rowid: $rowid, ') - ..write('conversationId: $conversationId, ') - ..write('quoteMessageId: $quoteMessageId') + return (StringBuffer('Propertie(') + ..write('key: $key, ') + ..write('group: $group, ') + ..write('value: $value') ..write(')')) .toString(); } -} -typedef BaseConversationItemCount$where = Expression Function( - Conversations conversation, - Users owner, - CircleConversations circleConversation); + @override + int get hashCode => Object.hash(key, group, value); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is Propertie && + other.key == this.key && + other.group == this.group && + other.value == this.value); +} -class ConversationItem { - final String conversationId; - final String? groupIconUrl; - final ConversationCategory? category; - final String? draft; - final String? groupName; - final ConversationStatus status; - final String? lastReadMessageId; - final int? unseenMessageCount; - final String? ownerId; - final DateTime? pinTime; - final DateTime? muteUntil; - final int? expireIn; - final String? avatarUrl; - final String? name; - final bool? ownerVerified; - final String ownerIdentityNumber; - final DateTime? ownerMuteUntil; - final String? appId; - final String? content; - final String? contentType; - final DateTime createdAt; - final DateTime? lastMessageCreatedAt; - final String? mediaUrl; - final String? senderId; - final String? actionName; - final MessageStatus? messageStatus; - final String? senderFullName; - final String? snapshotType; - final String? participantFullName; - final String? participantUserId; - final int? messageExpireIn; - final int mentionCount; - final UserRelationship? relationship; - ConversationItem({ - required this.conversationId, - this.groupIconUrl, - this.category, - this.draft, - this.groupName, - required this.status, - this.lastReadMessageId, - this.unseenMessageCount, - this.ownerId, - this.pinTime, - this.muteUntil, - this.expireIn, - this.avatarUrl, - this.name, - this.ownerVerified, - required this.ownerIdentityNumber, - this.ownerMuteUntil, - this.appId, - this.content, - this.contentType, - required this.createdAt, - this.lastMessageCreatedAt, - this.mediaUrl, - this.senderId, - this.actionName, - this.messageStatus, - this.senderFullName, - this.snapshotType, - this.participantFullName, - this.participantUserId, - this.messageExpireIn, - required this.mentionCount, - this.relationship, +class PropertiesCompanion extends UpdateCompanion { + final Value key; + final Value group; + final Value value; + final Value rowid; + const PropertiesCompanion({ + this.key = const Value.absent(), + this.group = const Value.absent(), + this.value = const Value.absent(), + this.rowid = const Value.absent(), }); + PropertiesCompanion.insert({ + required String key, + required PropertyGroup group, + required String value, + this.rowid = const Value.absent(), + }) : key = Value(key), + group = Value(group), + value = Value(value); + static Insertable custom({ + Expression? key, + Expression? group, + Expression? value, + Expression? rowid, + }) { + return RawValuesInsertable({ + if (key != null) 'key': key, + if (group != null) 'group': group, + if (value != null) 'value': value, + if (rowid != null) 'rowid': rowid, + }); + } + + PropertiesCompanion copyWith( + {Value? key, + Value? group, + Value? value, + Value? rowid}) { + return PropertiesCompanion( + key: key ?? this.key, + group: group ?? this.group, + value: value ?? this.value, + rowid: rowid ?? this.rowid, + ); + } + @override - int get hashCode => Object.hashAll([ - conversationId, - groupIconUrl, - category, - draft, - groupName, - status, - lastReadMessageId, - unseenMessageCount, - ownerId, - pinTime, - muteUntil, - expireIn, - avatarUrl, - name, - ownerVerified, - ownerIdentityNumber, - ownerMuteUntil, - appId, - content, - contentType, - createdAt, - lastMessageCreatedAt, - mediaUrl, - senderId, - actionName, - messageStatus, - senderFullName, - snapshotType, - participantFullName, - participantUserId, - messageExpireIn, - mentionCount, - relationship - ]); - @override - bool operator ==(Object other) => - identical(this, other) || - (other is ConversationItem && - other.conversationId == this.conversationId && - other.groupIconUrl == this.groupIconUrl && - other.category == this.category && - other.draft == this.draft && - other.groupName == this.groupName && - other.status == this.status && - other.lastReadMessageId == this.lastReadMessageId && - other.unseenMessageCount == this.unseenMessageCount && - other.ownerId == this.ownerId && - other.pinTime == this.pinTime && - other.muteUntil == this.muteUntil && - other.expireIn == this.expireIn && - other.avatarUrl == this.avatarUrl && - other.name == this.name && - other.ownerVerified == this.ownerVerified && - other.ownerIdentityNumber == this.ownerIdentityNumber && - other.ownerMuteUntil == this.ownerMuteUntil && - other.appId == this.appId && - other.content == this.content && - other.contentType == this.contentType && - other.createdAt == this.createdAt && - other.lastMessageCreatedAt == this.lastMessageCreatedAt && - other.mediaUrl == this.mediaUrl && - other.senderId == this.senderId && - other.actionName == this.actionName && - other.messageStatus == this.messageStatus && - other.senderFullName == this.senderFullName && - other.snapshotType == this.snapshotType && - other.participantFullName == this.participantFullName && - other.participantUserId == this.participantUserId && - other.messageExpireIn == this.messageExpireIn && - other.mentionCount == this.mentionCount && - other.relationship == this.relationship); + Map toColumns(bool nullToAbsent) { + final map = {}; + if (key.present) { + map['key'] = Variable(key.value); + } + if (group.present) { + final converter = Properties.$convertergroup; + map['group'] = Variable(converter.toSql(group.value)); + } + if (value.present) { + map['value'] = Variable(value.value); + } + if (rowid.present) { + map['rowid'] = Variable(rowid.value); + } + return map; + } + @override String toString() { - return (StringBuffer('ConversationItem(') - ..write('conversationId: $conversationId, ') - ..write('groupIconUrl: $groupIconUrl, ') - ..write('category: $category, ') - ..write('draft: $draft, ') - ..write('groupName: $groupName, ') - ..write('status: $status, ') - ..write('lastReadMessageId: $lastReadMessageId, ') - ..write('unseenMessageCount: $unseenMessageCount, ') - ..write('ownerId: $ownerId, ') - ..write('pinTime: $pinTime, ') - ..write('muteUntil: $muteUntil, ') - ..write('expireIn: $expireIn, ') - ..write('avatarUrl: $avatarUrl, ') - ..write('name: $name, ') - ..write('ownerVerified: $ownerVerified, ') - ..write('ownerIdentityNumber: $ownerIdentityNumber, ') - ..write('ownerMuteUntil: $ownerMuteUntil, ') - ..write('appId: $appId, ') - ..write('content: $content, ') - ..write('contentType: $contentType, ') - ..write('createdAt: $createdAt, ') - ..write('lastMessageCreatedAt: $lastMessageCreatedAt, ') - ..write('mediaUrl: $mediaUrl, ') - ..write('senderId: $senderId, ') - ..write('actionName: $actionName, ') - ..write('messageStatus: $messageStatus, ') - ..write('senderFullName: $senderFullName, ') - ..write('snapshotType: $snapshotType, ') - ..write('participantFullName: $participantFullName, ') - ..write('participantUserId: $participantUserId, ') - ..write('messageExpireIn: $messageExpireIn, ') - ..write('mentionCount: $mentionCount, ') - ..write('relationship: $relationship') + return (StringBuffer('PropertiesCompanion(') + ..write('key: $key, ') + ..write('group: $group, ') + ..write('value: $value, ') + ..write('rowid: $rowid') ..write(')')) .toString(); } -} +} + +abstract class _$MixinDatabase extends GeneratedDatabase { + _$MixinDatabase(QueryExecutor e) : super(e); + late final Conversations conversations = Conversations(this); + late final Messages messages = Messages(this); + late final Users users = Users(this); + late final Snapshots snapshots = Snapshots(this); + late final Assets assets = Assets(this); + late final Chains chains = Chains(this); + late final Stickers stickers = Stickers(this); + late final Hyperlinks hyperlinks = Hyperlinks(this); + late final MessageMentions messageMentions = MessageMentions(this); + late final PinMessages pinMessages = PinMessages(this); + late final ExpiredMessages expiredMessages = ExpiredMessages(this); + late final Addresses addresses = Addresses(this); + late final Apps apps = Apps(this); + late final CircleConversations circleConversations = + CircleConversations(this); + late final Circles circles = Circles(this); + late final FloodMessages floodMessages = FloodMessages(this); + late final Jobs jobs = Jobs(this); + late final MessagesHistory messagesHistory = MessagesHistory(this); + late final Offsets offsets = Offsets(this); + late final ParticipantSession participantSession = ParticipantSession(this); + late final Participants participants = Participants(this); + late final ResendSessionMessages resendSessionMessages = + ResendSessionMessages(this); + late final SentSessionSenderKeys sentSessionSenderKeys = + SentSessionSenderKeys(this); + late final StickerAlbums stickerAlbums = StickerAlbums(this); + late final StickerRelationships stickerRelationships = + StickerRelationships(this); + late final TranscriptMessages transcriptMessages = TranscriptMessages(this); + late final Fiats fiats = Fiats(this); + late final FavoriteApps favoriteApps = FavoriteApps(this); + late final Properties properties = Properties(this); + late final Index indexConversationsCategoryStatus = Index( + 'index_conversations_category_status', + 'CREATE INDEX IF NOT EXISTS index_conversations_category_status ON conversations (category, status)'); + late final Index indexConversationsMuteUntil = Index( + 'index_conversations_mute_until', + 'CREATE INDEX IF NOT EXISTS index_conversations_mute_until ON conversations (mute_until)'); + late final Index indexFloodMessagesCreatedAt = Index( + 'index_flood_messages_created_at', + 'CREATE INDEX IF NOT EXISTS index_flood_messages_created_at ON flood_messages (created_at)'); + late final Index indexJobsAction = Index('index_jobs_action', + 'CREATE INDEX IF NOT EXISTS index_jobs_action ON jobs ("action")'); + late final Index indexMessageMentionsConversationIdHasRead = Index( + 'index_message_mentions_conversation_id_has_read', + 'CREATE INDEX IF NOT EXISTS index_message_mentions_conversation_id_has_read ON message_mentions (conversation_id, has_read)'); + late final Index indexParticipantsConversationIdCreatedAt = Index( + 'index_participants_conversation_id_created_at', + 'CREATE INDEX IF NOT EXISTS index_participants_conversation_id_created_at ON participants (conversation_id, created_at)'); + late final Index indexStickerAlbumsCategoryCreatedAt = Index( + 'index_sticker_albums_category_created_at', + 'CREATE INDEX IF NOT EXISTS index_sticker_albums_category_created_at ON sticker_albums (category, created_at DESC)'); + late final Index indexPinMessagesConversationId = Index( + 'index_pin_messages_conversation_id', + 'CREATE INDEX IF NOT EXISTS index_pin_messages_conversation_id ON pin_messages (conversation_id)'); + late final Index indexUsersIdentityNumber = Index( + 'index_users_identity_number', + 'CREATE INDEX IF NOT EXISTS index_users_identity_number ON users (identity_number)'); + late final Index indexMessagesConversationIdCreatedAt = Index( + 'index_messages_conversation_id_created_at', + 'CREATE INDEX IF NOT EXISTS index_messages_conversation_id_created_at ON messages (conversation_id, created_at DESC)'); + late final Index indexMessagesConversationIdCategoryCreatedAt = Index( + 'index_messages_conversation_id_category_created_at', + 'CREATE INDEX IF NOT EXISTS index_messages_conversation_id_category_created_at ON messages (conversation_id, category, created_at DESC)'); + late final Index indexMessageConversationIdStatusUserId = Index( + 'index_message_conversation_id_status_user_id', + 'CREATE INDEX IF NOT EXISTS index_message_conversation_id_status_user_id ON messages (conversation_id, status, user_id)'); + late final Index indexMessagesConversationIdQuoteMessageId = Index( + 'index_messages_conversation_id_quote_message_id', + 'CREATE INDEX IF NOT EXISTS index_messages_conversation_id_quote_message_id ON messages (conversation_id, quote_message_id)'); + late final AddressDao addressDao = AddressDao(this as MixinDatabase); + late final AppDao appDao = AppDao(this as MixinDatabase); + late final AssetDao assetDao = AssetDao(this as MixinDatabase); + late final CircleConversationDao circleConversationDao = + CircleConversationDao(this as MixinDatabase); + late final CircleDao circleDao = CircleDao(this as MixinDatabase); + late final ConversationDao conversationDao = + ConversationDao(this as MixinDatabase); + late final FloodMessageDao floodMessageDao = + FloodMessageDao(this as MixinDatabase); + late final HyperlinkDao hyperlinkDao = HyperlinkDao(this as MixinDatabase); + late final JobDao jobDao = JobDao(this as MixinDatabase); + late final MessageMentionDao messageMentionDao = + MessageMentionDao(this as MixinDatabase); + late final MessageDao messageDao = MessageDao(this as MixinDatabase); + late final MessageHistoryDao messageHistoryDao = + MessageHistoryDao(this as MixinDatabase); + late final OffsetDao offsetDao = OffsetDao(this as MixinDatabase); + late final ParticipantDao participantDao = + ParticipantDao(this as MixinDatabase); + late final ParticipantSessionDao participantSessionDao = + ParticipantSessionDao(this as MixinDatabase); + late final ResendSessionMessageDao resendSessionMessageDao = + ResendSessionMessageDao(this as MixinDatabase); + late final SentSessionSenderKeyDao sentSessionSenderKeyDao = + SentSessionSenderKeyDao(this as MixinDatabase); + late final SnapshotDao snapshotDao = SnapshotDao(this as MixinDatabase); + late final StickerDao stickerDao = StickerDao(this as MixinDatabase); + late final StickerAlbumDao stickerAlbumDao = + StickerAlbumDao(this as MixinDatabase); + late final StickerRelationshipDao stickerRelationshipDao = + StickerRelationshipDao(this as MixinDatabase); + late final UserDao userDao = UserDao(this as MixinDatabase); + late final PinMessageDao pinMessageDao = PinMessageDao(this as MixinDatabase); + late final FiatDao fiatDao = FiatDao(this as MixinDatabase); + late final FavoriteAppDao favoriteAppDao = + FavoriteAppDao(this as MixinDatabase); + late final ExpiredMessageDao expiredMessageDao = + ExpiredMessageDao(this as MixinDatabase); + late final ChainDao chainDao = ChainDao(this as MixinDatabase); + late final PropertyDao propertyDao = PropertyDao(this as MixinDatabase); + late final TranscriptMessageDao transcriptMessageDao = + TranscriptMessageDao(this as MixinDatabase); + Selectable baseMessageItems(BaseMessageItems$where where, + BaseMessageItems$order order, BaseMessageItems$limit limit) { + var $arrayStartIndex = 1; + final generatedwhere = $write( + where( + alias(this.messages, 'message'), + alias(this.users, 'sender'), + alias(this.users, 'participant'), + alias(this.snapshots, 'snapshot'), + alias(this.assets, 'asset'), + alias(this.chains, 'chain'), + alias(this.stickers, 'sticker'), + alias(this.hyperlinks, 'hyperlink'), + alias(this.users, 'sharedUser'), + alias(this.conversations, 'conversation'), + alias(this.messageMentions, 'messageMention'), + alias(this.pinMessages, 'pinMessage'), + alias(this.expiredMessages, 'em')), + hasMultipleTables: true, + startIndex: $arrayStartIndex); + $arrayStartIndex += generatedwhere.amountOfVariables; + final generatedorder = $write( + order?.call( + alias(this.messages, 'message'), + alias(this.users, 'sender'), + alias(this.users, 'participant'), + alias(this.snapshots, 'snapshot'), + alias(this.assets, 'asset'), + alias(this.chains, 'chain'), + alias(this.stickers, 'sticker'), + alias(this.hyperlinks, 'hyperlink'), + alias(this.users, 'sharedUser'), + alias(this.conversations, 'conversation'), + alias(this.messageMentions, 'messageMention'), + alias(this.pinMessages, 'pinMessage'), + alias(this.expiredMessages, 'em')) ?? + const OrderBy.nothing(), + hasMultipleTables: true, + startIndex: $arrayStartIndex); + $arrayStartIndex += generatedorder.amountOfVariables; + final generatedlimit = $write( + limit( + alias(this.messages, 'message'), + alias(this.users, 'sender'), + alias(this.users, 'participant'), + alias(this.snapshots, 'snapshot'), + alias(this.assets, 'asset'), + alias(this.chains, 'chain'), + alias(this.stickers, 'sticker'), + alias(this.hyperlinks, 'hyperlink'), + alias(this.users, 'sharedUser'), + alias(this.conversations, 'conversation'), + alias(this.messageMentions, 'messageMention'), + alias(this.pinMessages, 'pinMessage'), + alias(this.expiredMessages, 'em')), + hasMultipleTables: true, + startIndex: $arrayStartIndex); + $arrayStartIndex += generatedlimit.amountOfVariables; + return customSelect( + 'SELECT message.message_id AS messageId, message.conversation_id AS conversationId, message.category AS type, message.content AS content, message.created_at AS createdAt, message.status AS status, message.media_status AS mediaStatus, message.media_waveform AS mediaWaveform, message.name AS mediaName, message.media_mime_type AS mediaMimeType, message.media_size AS mediaSize, message.media_width AS mediaWidth, message.media_height AS mediaHeight, message.thumb_image AS thumbImage, message.thumb_url AS thumbUrl, message.media_url AS mediaUrl, message.media_duration AS mediaDuration, message.quote_message_id AS quoteId, message.quote_content AS quoteContent, message."action" AS actionName, message.shared_user_id AS sharedUserId, message.sticker_id AS stickerId, sender.user_id AS userId, sender.full_name AS userFullName, sender.identity_number AS userIdentityNumber, sender.app_id AS appId, sender.relationship AS relationship, sender.avatar_url AS avatarUrl, sharedUser.full_name AS sharedUserFullName, sharedUser.identity_number AS sharedUserIdentityNumber, sharedUser.avatar_url AS sharedUserAvatarUrl, sharedUser.is_verified AS sharedUserIsVerified, sharedUser.app_id AS sharedUserAppId, conversation.owner_id AS conversationOwnerId, conversation.category AS conversionCategory, conversation.name AS groupName, sticker.asset_url AS assetUrl, sticker.asset_width AS assetWidth, sticker.asset_height AS assetHeight, sticker.name AS assetName, sticker.asset_type AS assetType, participant.full_name AS participantFullName, participant.user_id AS participantUserId, snapshot.snapshot_id AS snapshotId, snapshot.type AS snapshotType, snapshot.amount AS snapshotAmount, snapshot.asset_id AS assetId, asset.symbol AS assetSymbol, asset.icon_url AS assetIcon, chain.icon_url AS chainIcon, hyperlink.site_name AS siteName, hyperlink.site_title AS siteTitle, hyperlink.site_description AS siteDescription, hyperlink.site_image AS siteImage, messageMention.has_read AS mentionRead, em.expire_in AS expireIn, CASE WHEN pinMessage.message_id IS NOT NULL THEN TRUE ELSE FALSE END AS pinned FROM messages AS message INNER JOIN users AS sender ON message.user_id = sender.user_id LEFT JOIN users AS participant ON message.participant_id = participant.user_id LEFT JOIN snapshots AS snapshot ON message.snapshot_id = snapshot.snapshot_id LEFT JOIN assets AS asset ON snapshot.asset_id = asset.asset_id LEFT JOIN chains AS chain ON asset.chain_id = chain.chain_id LEFT JOIN stickers AS sticker ON sticker.sticker_id = message.sticker_id LEFT JOIN hyperlinks AS hyperlink ON message.hyperlink = hyperlink.hyperlink LEFT JOIN users AS sharedUser ON message.shared_user_id = sharedUser.user_id LEFT JOIN conversations AS conversation ON message.conversation_id = conversation.conversation_id LEFT JOIN message_mentions AS messageMention ON message.message_id = messageMention.message_id LEFT JOIN pin_messages AS pinMessage ON message.message_id = pinMessage.message_id LEFT JOIN expired_messages AS em ON message.message_id = em.message_id WHERE ${generatedwhere.sql} ${generatedorder.sql} ${generatedlimit.sql}', + variables: [ + ...generatedwhere.introducedVariables, + ...generatedorder.introducedVariables, + ...generatedlimit.introducedVariables + ], + readsFrom: { + messages, + users, + conversations, + stickers, + snapshots, + assets, + chains, + hyperlinks, + messageMentions, + expiredMessages, + pinMessages, + ...generatedwhere.watchedTables, + ...generatedorder.watchedTables, + ...generatedlimit.watchedTables, + }).map((QueryRow row) { + return MessageItem( + messageId: row.read('messageId'), + conversationId: row.read('conversationId'), + type: row.read('type'), + content: row.readNullable('content'), + createdAt: + Messages.$convertercreatedAt.fromSql(row.read('createdAt')), + status: Messages.$converterstatus.fromSql(row.read('status')), + mediaStatus: Messages.$convertermediaStatus + .fromSql(row.readNullable('mediaStatus')), + mediaWaveform: row.readNullable('mediaWaveform'), + mediaName: row.readNullable('mediaName'), + mediaMimeType: row.readNullable('mediaMimeType'), + mediaSize: row.readNullable('mediaSize'), + mediaWidth: row.readNullable('mediaWidth'), + mediaHeight: row.readNullable('mediaHeight'), + thumbImage: row.readNullable('thumbImage'), + thumbUrl: row.readNullable('thumbUrl'), + mediaUrl: row.readNullable('mediaUrl'), + mediaDuration: row.readNullable('mediaDuration'), + quoteId: row.readNullable('quoteId'), + quoteContent: row.readNullable('quoteContent'), + actionName: row.readNullable('actionName'), + sharedUserId: row.readNullable('sharedUserId'), + stickerId: row.readNullable('stickerId'), + userId: row.read('userId'), + userFullName: row.readNullable('userFullName'), + userIdentityNumber: row.read('userIdentityNumber'), + appId: row.readNullable('appId'), + relationship: Users.$converterrelationship + .fromSql(row.readNullable('relationship')), + avatarUrl: row.readNullable('avatarUrl'), + sharedUserFullName: row.readNullable('sharedUserFullName'), + sharedUserIdentityNumber: + row.readNullable('sharedUserIdentityNumber'), + sharedUserAvatarUrl: row.readNullable('sharedUserAvatarUrl'), + sharedUserIsVerified: row.readNullable('sharedUserIsVerified'), + sharedUserAppId: row.readNullable('sharedUserAppId'), + conversationOwnerId: row.readNullable('conversationOwnerId'), + conversionCategory: Conversations.$convertercategory + .fromSql(row.readNullable('conversionCategory')), + groupName: row.readNullable('groupName'), + assetUrl: row.readNullable('assetUrl'), + assetWidth: row.readNullable('assetWidth'), + assetHeight: row.readNullable('assetHeight'), + assetName: row.readNullable('assetName'), + assetType: row.readNullable('assetType'), + participantFullName: row.readNullable('participantFullName'), + participantUserId: row.readNullable('participantUserId'), + snapshotId: row.readNullable('snapshotId'), + snapshotType: row.readNullable('snapshotType'), + snapshotAmount: row.readNullable('snapshotAmount'), + assetId: row.readNullable('assetId'), + assetSymbol: row.readNullable('assetSymbol'), + assetIcon: row.readNullable('assetIcon'), + chainIcon: row.readNullable('chainIcon'), + siteName: row.readNullable('siteName'), + siteTitle: row.readNullable('siteTitle'), + siteDescription: row.readNullable('siteDescription'), + siteImage: row.readNullable('siteImage'), + mentionRead: row.readNullable('mentionRead'), + expireIn: row.readNullable('expireIn'), + pinned: row.read('pinned'), + ); + }); + } + + Selectable basePinMessageItems(String conversationId, + BasePinMessageItems$order order, BasePinMessageItems$limit limit) { + var $arrayStartIndex = 2; + final generatedorder = $write( + order?.call( + alias(this.pinMessages, 'pinMessage'), + alias(this.messages, 'message'), + alias(this.users, 'sender'), + alias(this.users, 'participant'), + alias(this.snapshots, 'snapshot'), + alias(this.assets, 'asset'), + alias(this.chains, 'chain'), + alias(this.stickers, 'sticker'), + alias(this.hyperlinks, 'hyperlink'), + alias(this.users, 'sharedUser'), + alias(this.conversations, 'conversation'), + alias(this.messageMentions, 'messageMention'), + alias(this.expiredMessages, 'em')) ?? + const OrderBy.nothing(), + hasMultipleTables: true, + startIndex: $arrayStartIndex); + $arrayStartIndex += generatedorder.amountOfVariables; + final generatedlimit = $write( + limit( + alias(this.pinMessages, 'pinMessage'), + alias(this.messages, 'message'), + alias(this.users, 'sender'), + alias(this.users, 'participant'), + alias(this.snapshots, 'snapshot'), + alias(this.assets, 'asset'), + alias(this.chains, 'chain'), + alias(this.stickers, 'sticker'), + alias(this.hyperlinks, 'hyperlink'), + alias(this.users, 'sharedUser'), + alias(this.conversations, 'conversation'), + alias(this.messageMentions, 'messageMention'), + alias(this.expiredMessages, 'em')), + hasMultipleTables: true, + startIndex: $arrayStartIndex); + $arrayStartIndex += generatedlimit.amountOfVariables; + return customSelect( + 'SELECT message.message_id AS messageId, message.conversation_id AS conversationId, message.category AS type, message.content AS content, message.created_at AS createdAt, message.status AS status, message.media_status AS mediaStatus, message.media_waveform AS mediaWaveform, message.name AS mediaName, message.media_mime_type AS mediaMimeType, message.media_size AS mediaSize, message.media_width AS mediaWidth, message.media_height AS mediaHeight, message.thumb_image AS thumbImage, message.thumb_url AS thumbUrl, message.media_url AS mediaUrl, message.media_duration AS mediaDuration, message.quote_message_id AS quoteId, message.quote_content AS quoteContent, message."action" AS actionName, message.shared_user_id AS sharedUserId, sender.user_id AS userId, sender.full_name AS userFullName, sender.identity_number AS userIdentityNumber, sender.app_id AS appId, sender.relationship AS relationship, sender.avatar_url AS avatarUrl, sharedUser.full_name AS sharedUserFullName, sharedUser.identity_number AS sharedUserIdentityNumber, sharedUser.avatar_url AS sharedUserAvatarUrl, sharedUser.is_verified AS sharedUserIsVerified, sharedUser.app_id AS sharedUserAppId, conversation.owner_id AS conversationOwnerId, conversation.category AS conversionCategory, conversation.name AS groupName, sticker.asset_url AS assetUrl, sticker.asset_width AS assetWidth, sticker.asset_height AS assetHeight, sticker.sticker_id AS stickerId, sticker.name AS assetName, sticker.asset_type AS assetType, participant.full_name AS participantFullName, participant.user_id AS participantUserId, snapshot.snapshot_id AS snapshotId, snapshot.type AS snapshotType, snapshot.amount AS snapshotAmount, snapshot.asset_id AS assetId, asset.symbol AS assetSymbol, asset.icon_url AS assetIcon, chain.icon_url AS chainIcon, hyperlink.site_name AS siteName, hyperlink.site_title AS siteTitle, hyperlink.site_description AS siteDescription, hyperlink.site_image AS siteImage, messageMention.has_read AS mentionRead, em.expire_in AS expireIn, CASE WHEN pinMessage.message_id IS NOT NULL THEN TRUE ELSE FALSE END AS pinned FROM pin_messages AS pinMessage INNER JOIN messages AS message ON message.message_id = pinMessage.message_id INNER JOIN users AS sender ON message.user_id = sender.user_id LEFT JOIN users AS participant ON message.participant_id = participant.user_id LEFT JOIN snapshots AS snapshot ON message.snapshot_id = snapshot.snapshot_id LEFT JOIN assets AS asset ON snapshot.asset_id = asset.asset_id LEFT JOIN chains AS chain ON asset.chain_id = chain.chain_id LEFT JOIN stickers AS sticker ON sticker.sticker_id = message.sticker_id LEFT JOIN hyperlinks AS hyperlink ON message.hyperlink = hyperlink.hyperlink LEFT JOIN users AS sharedUser ON message.shared_user_id = sharedUser.user_id LEFT JOIN conversations AS conversation ON message.conversation_id = conversation.conversation_id LEFT JOIN message_mentions AS messageMention ON message.message_id = messageMention.message_id LEFT JOIN expired_messages AS em ON message.message_id = em.message_id WHERE pinMessage.conversation_id = ?1 ${generatedorder.sql} ${generatedlimit.sql}', + variables: [ + Variable(conversationId), + ...generatedorder.introducedVariables, + ...generatedlimit.introducedVariables + ], + readsFrom: { + messages, + users, + conversations, + stickers, + snapshots, + assets, + chains, + hyperlinks, + messageMentions, + expiredMessages, + pinMessages, + ...generatedorder.watchedTables, + ...generatedlimit.watchedTables, + }).map((QueryRow row) { + return MessageItem( + messageId: row.read('messageId'), + conversationId: row.read('conversationId'), + type: row.read('type'), + content: row.readNullable('content'), + createdAt: + Messages.$convertercreatedAt.fromSql(row.read('createdAt')), + status: Messages.$converterstatus.fromSql(row.read('status')), + mediaStatus: Messages.$convertermediaStatus + .fromSql(row.readNullable('mediaStatus')), + mediaWaveform: row.readNullable('mediaWaveform'), + mediaName: row.readNullable('mediaName'), + mediaMimeType: row.readNullable('mediaMimeType'), + mediaSize: row.readNullable('mediaSize'), + mediaWidth: row.readNullable('mediaWidth'), + mediaHeight: row.readNullable('mediaHeight'), + thumbImage: row.readNullable('thumbImage'), + thumbUrl: row.readNullable('thumbUrl'), + mediaUrl: row.readNullable('mediaUrl'), + mediaDuration: row.readNullable('mediaDuration'), + quoteId: row.readNullable('quoteId'), + quoteContent: row.readNullable('quoteContent'), + actionName: row.readNullable('actionName'), + sharedUserId: row.readNullable('sharedUserId'), + stickerId: row.readNullable('stickerId'), + userId: row.read('userId'), + userFullName: row.readNullable('userFullName'), + userIdentityNumber: row.read('userIdentityNumber'), + appId: row.readNullable('appId'), + relationship: Users.$converterrelationship + .fromSql(row.readNullable('relationship')), + avatarUrl: row.readNullable('avatarUrl'), + sharedUserFullName: row.readNullable('sharedUserFullName'), + sharedUserIdentityNumber: + row.readNullable('sharedUserIdentityNumber'), + sharedUserAvatarUrl: row.readNullable('sharedUserAvatarUrl'), + sharedUserIsVerified: row.readNullable('sharedUserIsVerified'), + sharedUserAppId: row.readNullable('sharedUserAppId'), + conversationOwnerId: row.readNullable('conversationOwnerId'), + conversionCategory: Conversations.$convertercategory + .fromSql(row.readNullable('conversionCategory')), + groupName: row.readNullable('groupName'), + assetUrl: row.readNullable('assetUrl'), + assetWidth: row.readNullable('assetWidth'), + assetHeight: row.readNullable('assetHeight'), + assetName: row.readNullable('assetName'), + assetType: row.readNullable('assetType'), + participantFullName: row.readNullable('participantFullName'), + participantUserId: row.readNullable('participantUserId'), + snapshotId: row.readNullable('snapshotId'), + snapshotType: row.readNullable('snapshotType'), + snapshotAmount: row.readNullable('snapshotAmount'), + assetId: row.readNullable('assetId'), + assetSymbol: row.readNullable('assetSymbol'), + assetIcon: row.readNullable('assetIcon'), + chainIcon: row.readNullable('chainIcon'), + siteName: row.readNullable('siteName'), + siteTitle: row.readNullable('siteTitle'), + siteDescription: row.readNullable('siteDescription'), + siteImage: row.readNullable('siteImage'), + mentionRead: row.readNullable('mentionRead'), + expireIn: row.readNullable('expireIn'), + pinned: row.read('pinned'), + ); + }); + } -typedef BaseConversationItems$where = Expression Function( - Conversations conversation, - Users owner, - Messages lastMessage, - Users lastMessageSender, - Snapshots snapshot, - Users participant, - ExpiredMessages em); -typedef BaseConversationItems$order = OrderBy Function( - Conversations conversation, - Users owner, - Messages lastMessage, - Users lastMessageSender, - Snapshots snapshot, - Users participant, - ExpiredMessages em); -typedef BaseConversationItems$limit = Limit Function( - Conversations conversation, - Users owner, - Messages lastMessage, - Users lastMessageSender, - Snapshots snapshot, - Users participant, - ExpiredMessages em); -typedef BaseConversationItemsByCircleId$where = Expression Function( - Conversations conversation, - Users owner, - CircleConversations circleConversation, - Messages lastMessage, - Users lastMessageSender, - Snapshots snapshot, - Users participant, - ExpiredMessages em); -typedef BaseConversationItemsByCircleId$order = OrderBy Function( - Conversations conversation, - Users owner, - CircleConversations circleConversation, - Messages lastMessage, - Users lastMessageSender, - Snapshots snapshot, - Users participant, - ExpiredMessages em); -typedef BaseConversationItemsByCircleId$limit = Limit Function( - Conversations conversation, - Users owner, - CircleConversations circleConversation, - Messages lastMessage, - Users lastMessageSender, - Snapshots snapshot, - Users participant, - ExpiredMessages em); -typedef BaseUnseenMessageCount$where = Expression Function( - Conversations conversation, - Users owner, - CircleConversations circleConversation); - -class BaseUnseenConversationCountResult { - final int unseenConversationCount; - final int unseenMutedConversationCount; - BaseUnseenConversationCountResult({ - required this.unseenConversationCount, - required this.unseenMutedConversationCount, - }); @override - int get hashCode => - Object.hash(unseenConversationCount, unseenMutedConversationCount); + Iterable> get allTables => + allSchemaEntities.whereType>(); @override - bool operator ==(Object other) => - identical(this, other) || - (other is BaseUnseenConversationCountResult && - other.unseenConversationCount == this.unseenConversationCount && - other.unseenMutedConversationCount == - this.unseenMutedConversationCount); + List get allSchemaEntities => [ + conversations, + messages, + users, + snapshots, + assets, + chains, + stickers, + hyperlinks, + messageMentions, + pinMessages, + expiredMessages, + addresses, + apps, + circleConversations, + circles, + floodMessages, + jobs, + messagesHistory, + offsets, + participantSession, + participants, + resendSessionMessages, + sentSessionSenderKeys, + stickerAlbums, + stickerRelationships, + transcriptMessages, + fiats, + favoriteApps, + properties, + indexConversationsCategoryStatus, + indexConversationsMuteUntil, + indexFloodMessagesCreatedAt, + indexJobsAction, + indexMessageMentionsConversationIdHasRead, + indexParticipantsConversationIdCreatedAt, + indexStickerAlbumsCategoryCreatedAt, + indexPinMessagesConversationId, + indexUsersIdentityNumber, + indexMessagesConversationIdCreatedAt, + indexMessagesConversationIdCategoryCreatedAt, + indexMessageConversationIdStatusUserId, + indexMessagesConversationIdQuoteMessageId + ]; @override - String toString() { - return (StringBuffer('BaseUnseenConversationCountResult(') - ..write('unseenConversationCount: $unseenConversationCount, ') - ..write('unseenMutedConversationCount: $unseenMutedConversationCount') - ..write(')')) - .toString(); - } + StreamQueryUpdateRules get streamUpdateRules => const StreamQueryUpdateRules( + [ + WritePropagation( + on: TableUpdateQuery.onTableName('conversations', + limitUpdateKind: UpdateKind.delete), + result: [ + TableUpdate('messages', kind: UpdateKind.delete), + ], + ), + WritePropagation( + on: TableUpdateQuery.onTableName('conversations', + limitUpdateKind: UpdateKind.delete), + result: [ + TableUpdate('participants', kind: UpdateKind.delete), + ], + ), + ], + ); } -typedef BaseUnseenConversationCount$where = Expression Function( - Conversations conversation, Users owner); - -class SearchConversationItem { +class MessageItem { + final String messageId; final String conversationId; - final String? groupIconUrl; - final ConversationCategory? category; - final String? groupName; - final DateTime? pinTime; - final DateTime? muteUntil; - final String? ownerId; - final DateTime? ownerMuteUntil; - final String ownerIdentityNumber; - final String? fullName; - final String? avatarUrl; - final bool? isVerified; - final String? appId; - final MessageStatus? messageStatus; + final String type; final String? content; - final String? contentType; - final String? senderId; + final DateTime createdAt; + final MessageStatus status; + final MediaStatus? mediaStatus; + final String? mediaWaveform; + final String? mediaName; + final String? mediaMimeType; + final int? mediaSize; + final int? mediaWidth; + final int? mediaHeight; + final String? thumbImage; + final String? thumbUrl; + final String? mediaUrl; + final String? mediaDuration; + final String? quoteId; + final String? quoteContent; final String? actionName; - final String? senderFullName; - final String? participantUserId; + final String? sharedUserId; + final String? stickerId; + final String userId; + final String? userFullName; + final String userIdentityNumber; + final String? appId; + final UserRelationship? relationship; + final String? avatarUrl; + final String? sharedUserFullName; + final String? sharedUserIdentityNumber; + final String? sharedUserAvatarUrl; + final bool? sharedUserIsVerified; + final String? sharedUserAppId; + final String? conversationOwnerId; + final ConversationCategory? conversionCategory; + final String? groupName; + final String? assetUrl; + final int? assetWidth; + final int? assetHeight; + final String? assetName; + final String? assetType; final String? participantFullName; - SearchConversationItem({ + final String? participantUserId; + final String? snapshotId; + final String? snapshotType; + final String? snapshotAmount; + final String? assetId; + final String? assetSymbol; + final String? assetIcon; + final String? chainIcon; + final String? siteName; + final String? siteTitle; + final String? siteDescription; + final String? siteImage; + final bool? mentionRead; + final int? expireIn; + final bool pinned; + MessageItem({ + required this.messageId, required this.conversationId, - this.groupIconUrl, - this.category, - this.groupName, - this.pinTime, - this.muteUntil, - this.ownerId, - this.ownerMuteUntil, - required this.ownerIdentityNumber, - this.fullName, - this.avatarUrl, - this.isVerified, - this.appId, - this.messageStatus, + required this.type, this.content, - this.contentType, - this.senderId, + required this.createdAt, + required this.status, + this.mediaStatus, + this.mediaWaveform, + this.mediaName, + this.mediaMimeType, + this.mediaSize, + this.mediaWidth, + this.mediaHeight, + this.thumbImage, + this.thumbUrl, + this.mediaUrl, + this.mediaDuration, + this.quoteId, + this.quoteContent, this.actionName, - this.senderFullName, - this.participantUserId, + this.sharedUserId, + this.stickerId, + required this.userId, + this.userFullName, + required this.userIdentityNumber, + this.appId, + this.relationship, + this.avatarUrl, + this.sharedUserFullName, + this.sharedUserIdentityNumber, + this.sharedUserAvatarUrl, + this.sharedUserIsVerified, + this.sharedUserAppId, + this.conversationOwnerId, + this.conversionCategory, + this.groupName, + this.assetUrl, + this.assetWidth, + this.assetHeight, + this.assetName, + this.assetType, this.participantFullName, + this.participantUserId, + this.snapshotId, + this.snapshotType, + this.snapshotAmount, + this.assetId, + this.assetSymbol, + this.assetIcon, + this.chainIcon, + this.siteName, + this.siteTitle, + this.siteDescription, + this.siteImage, + this.mentionRead, + this.expireIn, + required this.pinned, }); @override int get hashCode => Object.hashAll([ + messageId, conversationId, - groupIconUrl, - category, - groupName, - pinTime, - muteUntil, - ownerId, - ownerMuteUntil, - ownerIdentityNumber, - fullName, - avatarUrl, - isVerified, - appId, - messageStatus, + type, content, - contentType, - senderId, + createdAt, + status, + mediaStatus, + mediaWaveform, + mediaName, + mediaMimeType, + mediaSize, + mediaWidth, + mediaHeight, + thumbImage, + thumbUrl, + mediaUrl, + mediaDuration, + quoteId, + quoteContent, actionName, - senderFullName, + sharedUserId, + stickerId, + userId, + userFullName, + userIdentityNumber, + appId, + relationship, + avatarUrl, + sharedUserFullName, + sharedUserIdentityNumber, + sharedUserAvatarUrl, + sharedUserIsVerified, + sharedUserAppId, + conversationOwnerId, + conversionCategory, + groupName, + assetUrl, + assetWidth, + assetHeight, + assetName, + assetType, + participantFullName, participantUserId, - participantFullName + snapshotId, + snapshotType, + snapshotAmount, + assetId, + assetSymbol, + assetIcon, + chainIcon, + siteName, + siteTitle, + siteDescription, + siteImage, + mentionRead, + expireIn, + pinned ]); @override bool operator ==(Object other) => identical(this, other) || - (other is SearchConversationItem && + (other is MessageItem && + other.messageId == this.messageId && other.conversationId == this.conversationId && - other.groupIconUrl == this.groupIconUrl && - other.category == this.category && - other.groupName == this.groupName && - other.pinTime == this.pinTime && - other.muteUntil == this.muteUntil && - other.ownerId == this.ownerId && - other.ownerMuteUntil == this.ownerMuteUntil && - other.ownerIdentityNumber == this.ownerIdentityNumber && - other.fullName == this.fullName && - other.avatarUrl == this.avatarUrl && - other.isVerified == this.isVerified && - other.appId == this.appId && - other.messageStatus == this.messageStatus && + other.type == this.type && other.content == this.content && - other.contentType == this.contentType && - other.senderId == this.senderId && + other.createdAt == this.createdAt && + other.status == this.status && + other.mediaStatus == this.mediaStatus && + other.mediaWaveform == this.mediaWaveform && + other.mediaName == this.mediaName && + other.mediaMimeType == this.mediaMimeType && + other.mediaSize == this.mediaSize && + other.mediaWidth == this.mediaWidth && + other.mediaHeight == this.mediaHeight && + other.thumbImage == this.thumbImage && + other.thumbUrl == this.thumbUrl && + other.mediaUrl == this.mediaUrl && + other.mediaDuration == this.mediaDuration && + other.quoteId == this.quoteId && + other.quoteContent == this.quoteContent && other.actionName == this.actionName && - other.senderFullName == this.senderFullName && + other.sharedUserId == this.sharedUserId && + other.stickerId == this.stickerId && + other.userId == this.userId && + other.userFullName == this.userFullName && + other.userIdentityNumber == this.userIdentityNumber && + other.appId == this.appId && + other.relationship == this.relationship && + other.avatarUrl == this.avatarUrl && + other.sharedUserFullName == this.sharedUserFullName && + other.sharedUserIdentityNumber == this.sharedUserIdentityNumber && + other.sharedUserAvatarUrl == this.sharedUserAvatarUrl && + other.sharedUserIsVerified == this.sharedUserIsVerified && + other.sharedUserAppId == this.sharedUserAppId && + other.conversationOwnerId == this.conversationOwnerId && + other.conversionCategory == this.conversionCategory && + other.groupName == this.groupName && + other.assetUrl == this.assetUrl && + other.assetWidth == this.assetWidth && + other.assetHeight == this.assetHeight && + other.assetName == this.assetName && + other.assetType == this.assetType && + other.participantFullName == this.participantFullName && other.participantUserId == this.participantUserId && - other.participantFullName == this.participantFullName); + other.snapshotId == this.snapshotId && + other.snapshotType == this.snapshotType && + other.snapshotAmount == this.snapshotAmount && + other.assetId == this.assetId && + other.assetSymbol == this.assetSymbol && + other.assetIcon == this.assetIcon && + other.chainIcon == this.chainIcon && + other.siteName == this.siteName && + other.siteTitle == this.siteTitle && + other.siteDescription == this.siteDescription && + other.siteImage == this.siteImage && + other.mentionRead == this.mentionRead && + other.expireIn == this.expireIn && + other.pinned == this.pinned); @override String toString() { - return (StringBuffer('SearchConversationItem(') + return (StringBuffer('MessageItem(') + ..write('messageId: $messageId, ') ..write('conversationId: $conversationId, ') - ..write('groupIconUrl: $groupIconUrl, ') - ..write('category: $category, ') - ..write('groupName: $groupName, ') - ..write('pinTime: $pinTime, ') - ..write('muteUntil: $muteUntil, ') - ..write('ownerId: $ownerId, ') - ..write('ownerMuteUntil: $ownerMuteUntil, ') - ..write('ownerIdentityNumber: $ownerIdentityNumber, ') - ..write('fullName: $fullName, ') - ..write('avatarUrl: $avatarUrl, ') - ..write('isVerified: $isVerified, ') - ..write('appId: $appId, ') - ..write('messageStatus: $messageStatus, ') + ..write('type: $type, ') ..write('content: $content, ') - ..write('contentType: $contentType, ') - ..write('senderId: $senderId, ') + ..write('createdAt: $createdAt, ') + ..write('status: $status, ') + ..write('mediaStatus: $mediaStatus, ') + ..write('mediaWaveform: $mediaWaveform, ') + ..write('mediaName: $mediaName, ') + ..write('mediaMimeType: $mediaMimeType, ') + ..write('mediaSize: $mediaSize, ') + ..write('mediaWidth: $mediaWidth, ') + ..write('mediaHeight: $mediaHeight, ') + ..write('thumbImage: $thumbImage, ') + ..write('thumbUrl: $thumbUrl, ') + ..write('mediaUrl: $mediaUrl, ') + ..write('mediaDuration: $mediaDuration, ') + ..write('quoteId: $quoteId, ') + ..write('quoteContent: $quoteContent, ') ..write('actionName: $actionName, ') - ..write('senderFullName: $senderFullName, ') + ..write('sharedUserId: $sharedUserId, ') + ..write('stickerId: $stickerId, ') + ..write('userId: $userId, ') + ..write('userFullName: $userFullName, ') + ..write('userIdentityNumber: $userIdentityNumber, ') + ..write('appId: $appId, ') + ..write('relationship: $relationship, ') + ..write('avatarUrl: $avatarUrl, ') + ..write('sharedUserFullName: $sharedUserFullName, ') + ..write('sharedUserIdentityNumber: $sharedUserIdentityNumber, ') + ..write('sharedUserAvatarUrl: $sharedUserAvatarUrl, ') + ..write('sharedUserIsVerified: $sharedUserIsVerified, ') + ..write('sharedUserAppId: $sharedUserAppId, ') + ..write('conversationOwnerId: $conversationOwnerId, ') + ..write('conversionCategory: $conversionCategory, ') + ..write('groupName: $groupName, ') + ..write('assetUrl: $assetUrl, ') + ..write('assetWidth: $assetWidth, ') + ..write('assetHeight: $assetHeight, ') + ..write('assetName: $assetName, ') + ..write('assetType: $assetType, ') + ..write('participantFullName: $participantFullName, ') ..write('participantUserId: $participantUserId, ') - ..write('participantFullName: $participantFullName') + ..write('snapshotId: $snapshotId, ') + ..write('snapshotType: $snapshotType, ') + ..write('snapshotAmount: $snapshotAmount, ') + ..write('assetId: $assetId, ') + ..write('assetSymbol: $assetSymbol, ') + ..write('assetIcon: $assetIcon, ') + ..write('chainIcon: $chainIcon, ') + ..write('siteName: $siteName, ') + ..write('siteTitle: $siteTitle, ') + ..write('siteDescription: $siteDescription, ') + ..write('siteImage: $siteImage, ') + ..write('mentionRead: $mentionRead, ') + ..write('expireIn: $expireIn, ') + ..write('pinned: $pinned') ..write(')')) .toString(); } } -typedef FuzzySearchConversation$where = Expression Function( - Conversations conversation, - Users owner, +typedef BaseMessageItems$where = Expression Function( Messages message, - Users lastMessageSender, - Users participant); -typedef FuzzySearchConversation$limit = Limit Function( + Users sender, + Users participant, + Snapshots snapshot, + Assets asset, + Chains chain, + Stickers sticker, + Hyperlinks hyperlink, + Users sharedUser, Conversations conversation, - Users owner, + MessageMentions messageMention, + PinMessages pinMessage, + ExpiredMessages em); +typedef BaseMessageItems$order = OrderBy Function( Messages message, - Users lastMessageSender, - Users participant); -typedef SearchConversationItemByIn$order = OrderBy Function( + Users sender, + Users participant, + Snapshots snapshot, + Assets asset, + Chains chain, + Stickers sticker, + Hyperlinks hyperlink, + Users sharedUser, Conversations conversation, - Users owner, + MessageMentions messageMention, + PinMessages pinMessage, + ExpiredMessages em); +typedef BaseMessageItems$limit = Limit Function( Messages message, - Users lastMessageSender, - Users participant); -typedef FuzzySearchConversationInCircle$where = Expression Function( + Users sender, + Users participant, + Snapshots snapshot, + Assets asset, + Chains chain, + Stickers sticker, + Hyperlinks hyperlink, + Users sharedUser, Conversations conversation, - Users owner, + MessageMentions messageMention, + PinMessages pinMessage, + ExpiredMessages em); +typedef BasePinMessageItems$order = OrderBy Function( + PinMessages pinMessage, Messages message, - Users lastMessageSender, - CircleConversations circleConversation, - Users participant); -typedef FuzzySearchConversationInCircle$limit = Limit Function( + Users sender, + Users participant, + Snapshots snapshot, + Assets asset, + Chains chain, + Stickers sticker, + Hyperlinks hyperlink, + Users sharedUser, Conversations conversation, - Users owner, + MessageMentions messageMention, + ExpiredMessages em); +typedef BasePinMessageItems$limit = Limit Function( + PinMessages pinMessage, Messages message, - Users lastMessageSender, - CircleConversations circleConversation, - Users participant); - -class ConversationStorageUsage { - final String conversationId; - final String? ownerId; - final ConversationCategory? category; - final String? iconUrl; - final String? name; - final String identityNumber; - final String? fullName; - final String? avatarUrl; - final bool? isVerified; - ConversationStorageUsage({ - required this.conversationId, - this.ownerId, - this.category, - this.iconUrl, - this.name, - required this.identityNumber, - this.fullName, - this.avatarUrl, - this.isVerified, - }); - @override - int get hashCode => Object.hash(conversationId, ownerId, category, iconUrl, - name, identityNumber, fullName, avatarUrl, isVerified); - @override - bool operator ==(Object other) => - identical(this, other) || - (other is ConversationStorageUsage && - other.conversationId == this.conversationId && - other.ownerId == this.ownerId && - other.category == this.category && - other.iconUrl == this.iconUrl && - other.name == this.name && - other.identityNumber == this.identityNumber && - other.fullName == this.fullName && - other.avatarUrl == this.avatarUrl && - other.isVerified == this.isVerified); - @override - String toString() { - return (StringBuffer('ConversationStorageUsage(') - ..write('conversationId: $conversationId, ') - ..write('ownerId: $ownerId, ') - ..write('category: $category, ') - ..write('iconUrl: $iconUrl, ') - ..write('name: $name, ') - ..write('identityNumber: $identityNumber, ') - ..write('fullName: $fullName, ') - ..write('avatarUrl: $avatarUrl, ') - ..write('isVerified: $isVerified') - ..write(')')) - .toString(); - } -} - -class GroupMinimal { - final String conversationId; - final String? groupIconUrl; - final String? groupName; - final int memberCount; - GroupMinimal({ - required this.conversationId, - this.groupIconUrl, - this.groupName, - required this.memberCount, - }); - @override - int get hashCode => - Object.hash(conversationId, groupIconUrl, groupName, memberCount); - @override - bool operator ==(Object other) => - identical(this, other) || - (other is GroupMinimal && - other.conversationId == this.conversationId && - other.groupIconUrl == this.groupIconUrl && - other.groupName == this.groupName && - other.memberCount == this.memberCount); - @override - String toString() { - return (StringBuffer('GroupMinimal(') - ..write('conversationId: $conversationId, ') - ..write('groupIconUrl: $groupIconUrl, ') - ..write('groupName: $groupName, ') - ..write('memberCount: $memberCount') - ..write(')')) - .toString(); - } -} + Users sender, + Users participant, + Snapshots snapshot, + Assets asset, + Chains chain, + Stickers sticker, + Hyperlinks hyperlink, + Users sharedUser, + Conversations conversation, + MessageMentions messageMention, + ExpiredMessages em); diff --git a/lib/db/moor/dao/circle.drift b/lib/db/moor/dao/circle.drift index ae79abb2f3..4dc7974b15 100644 --- a/lib/db/moor/dao/circle.drift +++ b/lib/db/moor/dao/circle.drift @@ -53,15 +53,3 @@ SELECT ci.circle_id, ci.name, COUNT(c.conversation_id) AS count FROM circles ci SELECT cir.circle_id FROM circles cir LEFT JOIN circle_conversations ccr ON cir.circle_id = ccr.circle_id WHERE ccr.conversation_id = :conversationId) GROUP BY ci.circle_id ORDER BY ci.ordered_at ASC, ci.created_at ASC; - -circlesNameByConversationId: -SELECT ci.name FROM circles ci - LEFT JOIN circle_conversations cc ON ci.circle_id = cc.circle_id - LEFT JOIN conversations c ON c.conversation_id = cc.conversation_id - WHERE cc.conversation_id = :conversationId; - -deleteByCircleId: -DELETE FROM circle_conversations WHERE circle_id = :circleId; - -deleteByIds: -DELETE FROM circle_conversations WHERE conversation_id = :conversationId AND circle_id = :circleId; diff --git a/lib/db/moor/dao/circle_conversation.drift b/lib/db/moor/dao/circle_conversation.drift new file mode 100644 index 0000000000..895863043c --- /dev/null +++ b/lib/db/moor/dao/circle_conversation.drift @@ -0,0 +1,7 @@ +import '../mixin.drift'; + +_deleteByCircleId: +DELETE FROM circle_conversations WHERE circle_id = :circleId; + +_deleteByIds: +DELETE FROM circle_conversations WHERE conversation_id = :conversationId AND circle_id = :circleId; diff --git a/lib/db/moor/dao/common.drift b/lib/db/moor/dao/common.drift new file mode 100644 index 0000000000..ca4541df24 --- /dev/null +++ b/lib/db/moor/dao/common.drift @@ -0,0 +1,151 @@ +import '../mixin.drift'; + +baseMessageItems AS MessageItem: +SELECT message.message_id AS messageId, + message.conversation_id AS conversationId, + message.category AS type, + message.content AS content, + message.created_at AS createdAt, + message.status AS status, + message.media_status AS mediaStatus, + message.media_waveform AS mediaWaveform, + message.name AS mediaName, + message.media_mime_type AS mediaMimeType, + message.media_size AS mediaSize, + message.media_width AS mediaWidth, + message.media_height AS mediaHeight, + message.thumb_image AS thumbImage, + message.thumb_url AS thumbUrl, message.media_url AS mediaUrl, + message.media_duration AS mediaDuration, + message.quote_message_id AS quoteId, + message.quote_content AS quoteContent, + message.action AS actionName, + message.shared_user_id AS sharedUserId, + message.sticker_id AS stickerId, + sender.user_id AS userId, + sender.full_name AS userFullName, + sender.identity_number AS userIdentityNumber, + sender.app_id AS appId, + sender.relationship AS relationship, + sender.avatar_url AS avatarUrl, + sharedUser.full_name AS sharedUserFullName, + sharedUser.identity_number AS sharedUserIdentityNumber, + sharedUser.avatar_url AS sharedUserAvatarUrl, + sharedUser.is_verified AS sharedUserIsVerified, + sharedUser.app_id AS sharedUserAppId, + conversation.owner_id AS conversationOwnerId, + conversation.category AS conversionCategory, + conversation.name AS groupName, + sticker.asset_url AS assetUrl, + sticker.asset_width AS assetWidth, + sticker.asset_height AS assetHeight, + sticker.name AS assetName, + sticker.asset_type AS assetType, + participant.full_name AS participantFullName, + participant.user_id AS participantUserId, + snapshot.snapshot_id AS snapshotId, + snapshot.type AS snapshotType, + snapshot.amount AS snapshotAmount, + snapshot.asset_id AS assetId, + asset.symbol AS assetSymbol, + asset.icon_url AS assetIcon, + chain.icon_url AS chainIcon, + hyperlink.site_name AS siteName, + hyperlink.site_title AS siteTitle, + hyperlink.site_description AS siteDescription, + hyperlink.site_image AS siteImage, + messageMention.has_read AS mentionRead, + em.expire_in AS expireIn, + CASE WHEN pinMessage.message_id IS NOT NULL THEN TRUE ELSE FALSE END AS pinned +FROM messages message + INNER JOIN users sender ON message.user_id = sender.user_id + LEFT JOIN users participant ON message.participant_id = participant.user_id + LEFT JOIN snapshots snapshot ON message.snapshot_id = snapshot.snapshot_id + LEFT JOIN assets asset ON snapshot.asset_id = asset.asset_id + LEFT JOIN chains chain ON asset.chain_id = chain.chain_id + LEFT JOIN stickers sticker ON sticker.sticker_id = message.sticker_id + LEFT JOIN hyperlinks hyperlink ON message.hyperlink = hyperlink.hyperlink + LEFT JOIN users sharedUser ON message.shared_user_id = sharedUser.user_id + LEFT JOIN conversations conversation +ON message.conversation_id = conversation.conversation_id + LEFT JOIN message_mentions messageMention ON message.message_id = messageMention.message_id + LEFT JOIN pin_messages pinMessage on message.message_id = pinMessage.message_id + LEFT JOIN expired_messages em ON message.message_id = em.message_id +WHERE $where +ORDER BY $order +LIMIT $limit; + +basePinMessageItems AS MessageItem: +SELECT message.message_id AS messageId, + message.conversation_id AS conversationId, + message.category AS type, + message.content AS content, + message.created_at AS createdAt, + message.status AS status, + message.media_status AS mediaStatus, + message.media_waveform AS mediaWaveform, + message.name AS mediaName, + message.media_mime_type AS mediaMimeType, + message.media_size AS mediaSize, + message.media_width AS mediaWidth, + message.media_height AS mediaHeight, + message.thumb_image AS thumbImage, + message.thumb_url AS thumbUrl, message.media_url AS mediaUrl, + message.media_duration AS mediaDuration, + message.quote_message_id AS quoteId, + message.quote_content AS quoteContent, + message.action AS actionName, + message.shared_user_id AS sharedUserId, + sender.user_id AS userId, + sender.full_name AS userFullName, + sender.identity_number AS userIdentityNumber, + sender.app_id AS appId, + sender.relationship AS relationship, + sender.avatar_url AS avatarUrl, + sharedUser.full_name AS sharedUserFullName, + sharedUser.identity_number AS sharedUserIdentityNumber, + sharedUser.avatar_url AS sharedUserAvatarUrl, + sharedUser.is_verified AS sharedUserIsVerified, + sharedUser.app_id AS sharedUserAppId, + conversation.owner_id AS conversationOwnerId, + conversation.category AS conversionCategory, + conversation.name AS groupName, + sticker.asset_url AS assetUrl, + sticker.asset_width AS assetWidth, + sticker.asset_height AS assetHeight, + sticker.sticker_id AS stickerId, + sticker.name AS assetName, + sticker.asset_type AS assetType, + participant.full_name AS participantFullName, + participant.user_id AS participantUserId, + snapshot.snapshot_id AS snapshotId, + snapshot.type AS snapshotType, + snapshot.amount AS snapshotAmount, + snapshot.asset_id AS assetId, + asset.symbol AS assetSymbol, + asset.icon_url AS assetIcon, + chain.icon_url AS chainIcon, + hyperlink.site_name AS siteName, + hyperlink.site_title AS siteTitle, + hyperlink.site_description AS siteDescription, + hyperlink.site_image AS siteImage, + messageMention.has_read AS mentionRead, + em.expire_in AS expireIn, + CASE WHEN pinMessage.message_id IS NOT NULL THEN TRUE ELSE FALSE END AS pinned +FROM pin_messages pinMessage + INNER JOIN messages message ON message.message_id = pinMessage.message_id + INNER JOIN users sender ON message.user_id = sender.user_id + LEFT JOIN users participant ON message.participant_id = participant.user_id + LEFT JOIN snapshots snapshot ON message.snapshot_id = snapshot.snapshot_id + LEFT JOIN assets asset ON snapshot.asset_id = asset.asset_id + LEFT JOIN chains chain ON asset.chain_id = chain.chain_id + LEFT JOIN stickers sticker ON sticker.sticker_id = message.sticker_id + LEFT JOIN hyperlinks hyperlink ON message.hyperlink = hyperlink.hyperlink + LEFT JOIN users sharedUser ON message.shared_user_id = sharedUser.user_id + LEFT JOIN conversations conversation +ON message.conversation_id = conversation.conversation_id + LEFT JOIN message_mentions messageMention ON message.message_id = messageMention.message_id + LEFT JOIN expired_messages em ON message.message_id = em.message_id +WHERE pinMessage.conversation_id = :conversationId +ORDER BY $order +LIMIT $limit; diff --git a/lib/db/moor/dao/conversation.drift b/lib/db/moor/dao/conversation.drift index f7227dadfe..1bbd40b9ce 100644 --- a/lib/db/moor/dao/conversation.drift +++ b/lib/db/moor/dao/conversation.drift @@ -1,13 +1,13 @@ import '../mixin.drift'; -baseConversationItemCount: +_baseConversationItemCount: SELECT COUNT(DISTINCT conversation.conversation_id) FROM conversations conversation INNER JOIN users owner ON owner.user_id = conversation.owner_id LEFT JOIN circle_conversations circleConversation ON conversation.conversation_id = circleConversation.conversation_id WHERE $where; -baseConversationItems AS ConversationItem: +_baseConversationItems AS ConversationItem: SELECT conversation.conversation_id AS conversationId, conversation.icon_url AS groupIconUrl, conversation.category AS category, conversation.draft AS draft, conversation.name AS groupName, conversation.status AS status, @@ -42,7 +42,7 @@ WHERE $where ORDER BY $order LIMIT $limit; -baseConversationItemsByCircleId AS ConversationItem: +_baseConversationItemsByCircleId AS ConversationItem: SELECT conversation.conversation_id AS conversationId, conversation.icon_url AS groupIconUrl, conversation.category AS category, conversation.draft AS draft, conversation.name AS groupName, conversation.status AS status, @@ -79,7 +79,7 @@ ORDER BY $order LIMIT $limit; -baseUnseenMessageCount: +_baseUnseenMessageCount: SELECT IFNULL(SUM(unseen_message_count), 0) FROM conversations conversation INNER JOIN users owner ON owner.user_id = conversation.owner_id @@ -87,7 +87,7 @@ FROM conversations conversation WHERE $where LIMIT 1; -baseUnseenConversationCount: +_baseUnseenConversationCount: SELECT COUNT(1) AS unseen_conversation_count, IFNULL( SUM( @@ -109,7 +109,7 @@ FROM conversations AS conversation WHERE $where LIMIT 1; -fuzzySearchConversation AS SearchConversationItem: +_fuzzySearchConversation AS SearchConversationItem: SELECT conversation.conversation_id AS conversationId, conversation.icon_url AS groupIconUrl, conversation.category AS category, @@ -152,7 +152,7 @@ ORDER BY (conversation.category = 'GROUP' AND conversation.name = :query COLLATE message.created_at DESC limit $limit; -searchConversationItemByIn AS SearchConversationItem: +_searchConversationItemByIn AS SearchConversationItem: SELECT conversation.conversation_id AS conversationId, conversation.icon_url AS groupIconUrl, conversation.category AS category, @@ -182,7 +182,7 @@ FROM conversations conversation WHERE conversation.conversation_id IN :ids ORDER BY $order; -fuzzySearchConversationInCircle AS SearchConversationItem: +_fuzzySearchConversationInCircle AS SearchConversationItem: SELECT conversation.conversation_id AS conversationId, conversation.icon_url AS groupIconUrl, conversation.category AS category, @@ -223,9 +223,6 @@ ORDER BY (conversation.category = 'GROUP' AND conversation.name = :query COLLATE message.created_at DESC limit $limit; -conversationParticipantsCount: -SELECT COUNT(1) FROM participants WHERE conversation_id = :conversationId; - conversationStorageUsage AS ConversationStorageUsage: SELECT c.conversation_id, c.owner_id, c.category, c.icon_url, c.name, u.identity_number, u.full_name, u.avatar_url, u.is_verified @@ -247,4 +244,11 @@ ORDER BY c.last_message_created_at DESC; countConversations: -SELECT COUNT(1) FROM conversations; \ No newline at end of file +SELECT COUNT(1) FROM conversations; + +_updateUnseenMessageCountAndLastMessageId: +UPDATE conversations SET unseen_message_count + = (SELECT count(1) FROM messages WHERE conversation_id = :conversationId AND status IN ('SENT', 'DELIVERED') AND user_id != :userId), + last_message_id = :lastMessageId, + last_message_created_at = :lastMessageCreatedAt + WHERE conversation_id = :conversationId; diff --git a/lib/db/moor/dao/favorite_app.drift b/lib/db/moor/dao/favorite_app.drift index abd6768954..63135a71c4 100644 --- a/lib/db/moor/dao/favorite_app.drift +++ b/lib/db/moor/dao/favorite_app.drift @@ -1,10 +1,7 @@ import '../mixin.drift'; -deleteFavoriteAppByAppIdAndUserId: -DELETE FROM favorite_apps WHERE app_id = :appId AND user_id = :userId; - -deleteFavoriteAppByUserId: +_deleteFavoriteAppByUserId: DELETE FROM favorite_apps WHERE user_id = :userId; -getFavoriteAppByUserId: -SELECT a.* FROM favorite_apps fa INNER JOIN apps a ON fa.app_id = a.app_id WHERE fa.user_id =:userId; \ No newline at end of file +getFavoriteAppsByUserId: +SELECT a.* FROM favorite_apps fa INNER JOIN apps a ON fa.app_id = a.app_id WHERE fa.user_id =:userId; diff --git a/lib/db/moor/dao/flood.drift b/lib/db/moor/dao/flood.drift index 6f8ce3d2cb..276f884a4c 100644 --- a/lib/db/moor/dao/flood.drift +++ b/lib/db/moor/dao/flood.drift @@ -1,4 +1,4 @@ import '../mixin.drift'; -getLastBlazeMessageCreatedAt: +_getLastBlazeMessageCreatedAt: SELECT created_at FROM flood_messages ORDER BY created_at DESC limit 1; diff --git a/lib/db/moor/dao/message.drift b/lib/db/moor/dao/message.drift index 62d0d447e7..c36eb9232a 100644 --- a/lib/db/moor/dao/message.drift +++ b/lib/db/moor/dao/message.drift @@ -1,81 +1,6 @@ import '../mixin.drift'; -baseMessageItems AS MessageItem: -SELECT message.message_id AS messageId, - message.conversation_id AS conversationId, - message.category AS type, - message.content AS content, - message.created_at AS createdAt, - message.status AS status, - message.media_status AS mediaStatus, - message.media_waveform AS mediaWaveform, - message.name AS mediaName, - message.media_mime_type AS mediaMimeType, - message.media_size AS mediaSize, - message.media_width AS mediaWidth, - message.media_height AS mediaHeight, - message.thumb_image AS thumbImage, - message.thumb_url AS thumbUrl, message.media_url AS mediaUrl, - message.media_duration AS mediaDuration, - message.quote_message_id AS quoteId, - message.quote_content AS quoteContent, - message.action AS actionName, - message.shared_user_id AS sharedUserId, - message.sticker_id AS stickerId, - sender.user_id AS userId, - sender.full_name AS userFullName, - sender.identity_number AS userIdentityNumber, - sender.app_id AS appId, - sender.relationship AS relationship, - sender.avatar_url AS avatarUrl, - sharedUser.full_name AS sharedUserFullName, - sharedUser.identity_number AS sharedUserIdentityNumber, - sharedUser.avatar_url AS sharedUserAvatarUrl, - sharedUser.is_verified AS sharedUserIsVerified, - sharedUser.app_id AS sharedUserAppId, - conversation.owner_id AS conversationOwnerId, - conversation.category AS conversionCategory, - conversation.name AS groupName, - sticker.asset_url AS assetUrl, - sticker.asset_width AS assetWidth, - sticker.asset_height AS assetHeight, - sticker.name AS assetName, - sticker.asset_type AS assetType, - participant.full_name AS participantFullName, - participant.user_id AS participantUserId, - snapshot.snapshot_id AS snapshotId, - snapshot.type AS snapshotType, - snapshot.amount AS snapshotAmount, - snapshot.asset_id AS assetId, - asset.symbol AS assetSymbol, - asset.icon_url AS assetIcon, - chain.icon_url AS chainIcon, - hyperlink.site_name AS siteName, - hyperlink.site_title AS siteTitle, - hyperlink.site_description AS siteDescription, - hyperlink.site_image AS siteImage, - messageMention.has_read AS mentionRead, - em.expire_in AS expireIn, - CASE WHEN pinMessage.message_id IS NOT NULL THEN TRUE ELSE FALSE END AS pinned -FROM messages message - INNER JOIN users sender ON message.user_id = sender.user_id - LEFT JOIN users participant ON message.participant_id = participant.user_id - LEFT JOIN snapshots snapshot ON message.snapshot_id = snapshot.snapshot_id - LEFT JOIN assets asset ON snapshot.asset_id = asset.asset_id - LEFT JOIN chains chain ON asset.chain_id = chain.chain_id - LEFT JOIN stickers sticker ON sticker.sticker_id = message.sticker_id - LEFT JOIN hyperlinks hyperlink ON message.hyperlink = hyperlink.hyperlink - LEFT JOIN users sharedUser ON message.shared_user_id = sharedUser.user_id - LEFT JOIN conversations conversation -ON message.conversation_id = conversation.conversation_id - LEFT JOIN message_mentions messageMention ON message.message_id = messageMention.message_id - LEFT JOIN pin_messages pinMessage on message.message_id = pinMessage.message_id - LEFT JOIN expired_messages em ON message.message_id = em.message_id -WHERE $where -ORDER BY $order -LIMIT $limit; - -baseQuoteMessageItem AS QuoteMessageItem: +_baseQuoteMessageItem AS QuoteMessageItem: SELECT message.message_id AS messageId, message.conversation_id AS conversationId, sender.user_id AS userId, sender.full_name AS userFullName, sender.identity_number AS userIdentityNumber, @@ -106,7 +31,7 @@ WHERE $where ORDER BY $order LIMIT $limit; -findMessageStatusById: +messageStatusById: SELECT status FROM messages WHERE message_id = :messageId LIMIT 1; sendingMessage AS SendingMessage: @@ -155,14 +80,7 @@ WHERE m.message_id in :messageId ORDER BY m.created_at DESC; -updateUnseenMessageCountAndLastMessageId: -UPDATE conversations SET unseen_message_count - = (SELECT count(1) FROM messages WHERE conversation_id = :conversationId AND status IN ('SENT', 'DELIVERED') AND user_id != :userId), - last_message_id = :lastMessageId, - last_message_created_at = :lastMessageCreatedAt - WHERE conversation_id = :conversationId; - -getSearchMessageByIds AS SearchMessageDetailItem: +searchMessageByIds AS SearchMessageDetailItem: SELECT m.message_id messageId, u.user_id AS senderId, u.avatar_url AS senderAvatarUrl, u.full_name AS senderFullName, m.status AS status, m.category AS type, m.content AS content, m.created_at AS createdAt, m.name AS mediaName, u.app_id AS appId, u.is_verified AS verified, c.owner_id AS ownerId, c.icon_url AS groupIconUrl, c.category AS category, c.name AS groupName, c.conversation_id AS conversationId, owner.full_name AS ownerFullName, owner.avatar_url AS ownerAvatarUrl @@ -176,7 +94,7 @@ SELECT m.message_id messageId, u.user_id AS senderId, u.avatar_url AS senderAvat miniMessageByIds AS MiniMessageItem: SELECT conversation_id as conversationId, message_id as messageId FROM messages WHERE message_id IN :messageIds; -searchMessage AS SearchMessageDetailItem: +_searchMessage AS SearchMessageDetailItem: SELECT m.message_id messageId, u.user_id AS senderId, u.avatar_url AS senderAvatarUrl, u.full_name AS senderFullName, m.status AS status, m.category AS type, m.content AS content, m.created_at AS createdAt, m.name AS mediaName, u.app_id AS appId, u.is_verified AS verified, c.owner_id AS ownerId, c.icon_url AS groupIconUrl, c.category AS category, c.name AS groupName, c.conversation_id AS conversationId, owner.full_name AS ownerFullName, owner.avatar_url AS ownerAvatarUrl @@ -194,5 +112,5 @@ SELECT count(1) FROM messages; countMediaMessages: SELECT count(1) FROM messages WHERE category IN ('SIGNAL_IMAGE', 'SIGNAL_VIDEO', 'SIGNAL_DATA', 'SIGNAL_AUDIO', 'PLAIN_IMAGE', 'PLAIN_VIDEO', 'PLAIN_DATA', 'PLAIN_AUDIO', 'ENCRYPTED_IMAGE', 'ENCRYPTED_VIDEO', 'ENCRYPTED_DATA', 'ENCRYPTED_AUDIO'); -findBigQuoteMessage as QuoteMinimal: +bigQuoteMessage as QuoteMinimal: SELECT rowid, conversation_id, quote_message_id FROM messages WHERE rowid > :rowId AND quote_message_id IS NOT NULL AND quote_message_id != '' AND length(quote_content) > 10240 GROUP BY quote_message_id ORDER BY rowid ASC LIMIT :limit; diff --git a/lib/db/moor/dao/participant.drift b/lib/db/moor/dao/participant.drift index 37fd1c074f..8a6d620ce1 100644 --- a/lib/db/moor/dao/participant.drift +++ b/lib/db/moor/dao/participant.drift @@ -8,18 +8,6 @@ WHERE participant.conversation_id = :conversationId ORDER BY participant.created_at ASC LIMIT 4; -participantSessionKeyWithoutSelf AS ParticipantSessionKey: -SELECT conversation_id, user_id, session_id, public_key FROM participant_session WHERE conversation_id = :conversationId AND user_id != :userId LIMIT 1; - -otherParticipantSessionKey AS ParticipantSessionKey: -SELECT conversation_id, user_id, session_id, public_key FROM participant_session WHERE conversation_id = :conversationId AND user_id == :userId AND session_id != :sessionId ORDER BY created_at DESC LIMIT 1; - -notSendSessionParticipants: -SELECT p.* FROM participant_session p LEFT JOIN users u ON p.user_id = u.user_id WHERE p.conversation_id = :conversationId AND p.session_id != :sessionId AND u.app_id IS NULL AND p.sent_to_server IS NULL; - -participantSessionKeyBySessionId: -SELECT * FROM participant_session WHERE conversation_id = :conversationId AND session_id == :sessionId; - groupParticipantsByConversationId AS ParticipantUser: SELECT p.conversation_id AS conversationId, p.role AS role, p.created_at AS createdAt, u.user_id AS userId, u.identity_number AS identityNumber, u.relationship AS relationship, u.biography AS biography, u.full_name AS fullName, @@ -35,4 +23,10 @@ SELECT u.user_id FROM users u INNER JOIN participants p ON p.user_id = u.user_id WHERE p.conversation_id = :conversationId AND u.identity_number = :identityNumber; countParticipants: -SELECT COUNT(1) FROM participants; \ No newline at end of file +SELECT COUNT(1) FROM participants; + +conversationParticipantsCount: +SELECT COUNT(1) FROM participants WHERE conversation_id = :conversationId; + +_joinedConversationId: +SELECT p.conversation_id FROM participants p, conversations c WHERE p.user_id = :userId AND p.conversation_id = c.conversation_id AND c.status = 2 LIMIT 1; diff --git a/lib/db/moor/dao/participant_session.drift b/lib/db/moor/dao/participant_session.drift new file mode 100644 index 0000000000..aaa2f4e08b --- /dev/null +++ b/lib/db/moor/dao/participant_session.drift @@ -0,0 +1,10 @@ +import '../mixin.drift'; + +participantSessionKeyWithoutSelf AS ParticipantSessionKey: +SELECT conversation_id, user_id, session_id, public_key FROM participant_session WHERE conversation_id = :conversationId AND user_id != :userId LIMIT 1; + +otherParticipantSessionKey AS ParticipantSessionKey: +SELECT conversation_id, user_id, session_id, public_key FROM participant_session WHERE conversation_id = :conversationId AND user_id == :userId AND session_id != :sessionId ORDER BY created_at DESC LIMIT 1; + +notSendSessionParticipants: +SELECT p.* FROM participant_session p LEFT JOIN users u ON p.user_id = u.user_id WHERE p.conversation_id = :conversationId AND p.session_id != :sessionId AND u.app_id IS NULL AND p.sent_to_server IS NULL; diff --git a/lib/db/moor/dao/pin_message.drift b/lib/db/moor/dao/pin_message.drift index 295504ca5b..7d876e3a6e 100644 --- a/lib/db/moor/dao/pin_message.drift +++ b/lib/db/moor/dao/pin_message.drift @@ -1,81 +1,5 @@ import '../mixin.drift'; - -basePinMessageItems AS MessageItem: -SELECT message.message_id AS messageId, - message.conversation_id AS conversationId, - message.category AS type, - message.content AS content, - message.created_at AS createdAt, - message.status AS status, - message.media_status AS mediaStatus, - message.media_waveform AS mediaWaveform, - message.name AS mediaName, - message.media_mime_type AS mediaMimeType, - message.media_size AS mediaSize, - message.media_width AS mediaWidth, - message.media_height AS mediaHeight, - message.thumb_image AS thumbImage, - message.thumb_url AS thumbUrl, message.media_url AS mediaUrl, - message.media_duration AS mediaDuration, - message.quote_message_id AS quoteId, - message.quote_content AS quoteContent, - message.action AS actionName, - message.shared_user_id AS sharedUserId, - sender.user_id AS userId, - sender.full_name AS userFullName, - sender.identity_number AS userIdentityNumber, - sender.app_id AS appId, - sender.relationship AS relationship, - sender.avatar_url AS avatarUrl, - sharedUser.full_name AS sharedUserFullName, - sharedUser.identity_number AS sharedUserIdentityNumber, - sharedUser.avatar_url AS sharedUserAvatarUrl, - sharedUser.is_verified AS sharedUserIsVerified, - sharedUser.app_id AS sharedUserAppId, - conversation.owner_id AS conversationOwnerId, - conversation.category AS conversionCategory, - conversation.name AS groupName, - sticker.asset_url AS assetUrl, - sticker.asset_width AS assetWidth, - sticker.asset_height AS assetHeight, - sticker.sticker_id AS stickerId, - sticker.name AS assetName, - sticker.asset_type AS assetType, - participant.full_name AS participantFullName, - participant.user_id AS participantUserId, - snapshot.snapshot_id AS snapshotId, - snapshot.type AS snapshotType, - snapshot.amount AS snapshotAmount, - snapshot.asset_id AS assetId, - asset.symbol AS assetSymbol, - asset.icon_url AS assetIcon, - chain.icon_url AS chainIcon, - hyperlink.site_name AS siteName, - hyperlink.site_title AS siteTitle, - hyperlink.site_description AS siteDescription, - hyperlink.site_image AS siteImage, - messageMention.has_read AS mentionRead, - em.expire_in AS expireIn, - CASE WHEN pinMessage.message_id IS NOT NULL THEN TRUE ELSE FALSE END AS pinned -FROM pin_messages pinMessage - INNER JOIN messages message ON message.message_id = pinMessage.message_id - INNER JOIN users sender ON message.user_id = sender.user_id - LEFT JOIN users participant ON message.participant_id = participant.user_id - LEFT JOIN snapshots snapshot ON message.snapshot_id = snapshot.snapshot_id - LEFT JOIN assets asset ON snapshot.asset_id = asset.asset_id - LEFT JOIN chains chain ON asset.chain_id = chain.chain_id - LEFT JOIN stickers sticker ON sticker.sticker_id = message.sticker_id - LEFT JOIN hyperlinks hyperlink ON message.hyperlink = hyperlink.hyperlink - LEFT JOIN users sharedUser ON message.shared_user_id = sharedUser.user_id - LEFT JOIN conversations conversation -ON message.conversation_id = conversation.conversation_id - LEFT JOIN message_mentions messageMention ON message.message_id = messageMention.message_id - LEFT JOIN expired_messages em ON message.message_id = em.message_id -WHERE pinMessage.conversation_id = :conversationId -ORDER BY $order -LIMIT $limit; - pinMessageItem: SELECT message.content AS content, diff --git a/lib/db/moor/dao/sticker.drift b/lib/db/moor/dao/sticker.drift index 8f90b34d13..4c956923f3 100644 --- a/lib/db/moor/dao/sticker.drift +++ b/lib/db/moor/dao/sticker.drift @@ -3,7 +3,7 @@ import '../mixin.drift'; recentUsedStickers: SELECT * FROM stickers WHERE last_use_at > 0 ORDER BY last_use_at DESC LIMIT 20; -stickersByCategory: +_stickersByCategory: SELECT s.* FROM sticker_albums sa INNER JOIN sticker_relationships sr @@ -14,4 +14,4 @@ WHERE sa.category = :category ORDER BY s.created_at DESC; countStickers: -SELECT COUNT(1) FROM stickers; \ No newline at end of file +SELECT COUNT(1) FROM stickers; diff --git a/lib/db/moor/dao/sticker_album.drift b/lib/db/moor/dao/sticker_album.drift index b375c34c17..5a13dbc1da 100644 --- a/lib/db/moor/dao/sticker_album.drift +++ b/lib/db/moor/dao/sticker_album.drift @@ -1,3 +1 @@ import '../mixin.drift'; - - diff --git a/lib/db/moor/dao/user.drift b/lib/db/moor/dao/user.drift index 41a1595e2b..7fe717583a 100644 --- a/lib/db/moor/dao/user.drift +++ b/lib/db/moor/dao/user.drift @@ -1,6 +1,6 @@ import '../mixin.drift'; -fuzzySearchBotGroupUser: +_fuzzySearchBotGroupUser: SELECT u.* FROM users u WHERE (u.user_id in (SELECT m.user_id FROM messages m WHERE conversation_id = :conversationId AND m.created_at > :createdAt) OR u.user_id in (SELECT f.user_id FROM users f WHERE relationship = 'FRIEND')) @@ -12,10 +12,10 @@ SELECT u.* FROM users u fuzzySearchGroupUser: SELECT u.* FROM participants p, users u - WHERE u.user_id != :id + WHERE u.user_id != :currentUserId AND p.conversation_id = :conversationId AND p.user_id = u.user_id - AND (u.full_name LIKE '%' || :username || '%' ESCAPE '\' OR u.identity_number like '%' || :identityNumber || '%' ESCAPE '\') - ORDER BY u.full_name = :username COLLATE NOCASE OR u.identity_number = :identityNumber COLLATE NOCASE DESC; + AND (u.full_name LIKE '%' || :keyword || '%' ESCAPE '\' OR u.identity_number like '%' || :keyword || '%' ESCAPE '\') + ORDER BY u.full_name = :keyword COLLATE NOCASE OR u.identity_number = :keyword COLLATE NOCASE DESC; groupParticipants: SELECT u.* FROM participants p, users u WHERE p.conversation_id = :conversationId AND p.user_id = u.user_id; @@ -29,7 +29,7 @@ SELECT * FROM users WHERE user_id IN :userIds; userIdsByIn: SELECT user_id FROM users WHERE user_id IN :userIds; -fuzzySearchUser: +_fuzzySearchUser: SELECT users.* FROM users LEFT JOIN conversations ON conversations.owner_id = user_id @@ -43,7 +43,7 @@ WHERE $firstFilter ORDER BY full_name = :username COLLATE nocase OR identity_number = :identityNumber COLLATE nocase DESC; -fuzzySearchUserInCircle: +_fuzzySearchUserInCircle: SELECT users.* FROM users LEFT JOIN conversations ON conversations.owner_id = users.user_id @@ -65,4 +65,4 @@ userByIdentityNumbers AS MentionUser: SELECT user_id, identity_number, full_name FROM users WHERE identity_number IN :numbers; countUsers: -SELECT COUNT(*) FROM users; \ No newline at end of file +SELECT COUNT(*) FROM users; diff --git a/lib/ui/home/bloc/conversation_cubit.dart b/lib/ui/home/bloc/conversation_cubit.dart index ed4fccd42e..e9174cf80d 100644 --- a/lib/ui/home/bloc/conversation_cubit.dart +++ b/lib/ui/home/bloc/conversation_cubit.dart @@ -9,6 +9,7 @@ import '../../../account/account_server.dart'; import '../../../bloc/simple_cubit.dart'; import '../../../bloc/subscribe_mixin.dart'; import '../../../crypto/uuid/uuid.dart'; +import '../../../db/dao/conversation_dao.dart'; import '../../../db/database_event_bus.dart'; import '../../../db/mixin_database.dart'; import '../../../enum/encrypt_category.dart'; diff --git a/lib/ui/home/bloc/conversation_list_bloc.dart b/lib/ui/home/bloc/conversation_list_bloc.dart index 1493b942c5..0498022781 100644 --- a/lib/ui/home/bloc/conversation_list_bloc.dart +++ b/lib/ui/home/bloc/conversation_list_bloc.dart @@ -7,9 +7,9 @@ import 'package:scrollable_positioned_list/scrollable_positioned_list.dart'; import '../../../bloc/paging/paging_bloc.dart'; import '../../../bloc/subscribe_mixin.dart'; +import '../../../db/dao/conversation_dao.dart'; import '../../../db/database.dart'; import '../../../db/database_event_bus.dart'; -import '../../../db/mixin_database.dart'; import '../../../utils/extension/extension.dart'; import '../../../utils/logger.dart'; import '../../../utils/platform.dart'; @@ -100,7 +100,7 @@ class ConversationListBloc extends Cubit> limit ?? kDefaultLimit, () => dao.conversationCountByCategory(state.type), (limit, offset) => - dao.conversationItemsByCategory(state.type, limit, offset), + dao.conversationItemsByCategory(state.type, limit, offset).get(), updateEvent, mentionCache, () => dao.conversationHasDataByCategory(state.type), diff --git a/lib/ui/home/bloc/mention_cubit.dart b/lib/ui/home/bloc/mention_cubit.dart index a13045f2b7..ef10db7f83 100644 --- a/lib/ui/home/bloc/mention_cubit.dart +++ b/lib/ui/home/bloc/mention_cubit.dart @@ -84,8 +84,7 @@ class MentionCubit extends Cubit with SubscribeMixin { } if (conversationState.isGroup ?? false) { return userDao - .groupParticipants( - conversationId: conversationState.conversationId) + .groupParticipants(conversationState.conversationId) .watchWithStream( eventStreams: [ DataBaseEventBus.instance.watchUpdateParticipantStream( @@ -121,9 +120,9 @@ class MentionCubit extends Cubit with SubscribeMixin { if (conversationState.isGroup ?? false) { return userDao .fuzzySearchGroupUser( - currentUserId: multiAuthCubit.state.currentUserId ?? '', - conversationId: conversationState.conversationId, - keyword: keyword, + multiAuthCubit.state.currentUserId ?? '', + conversationState.conversationId, + keyword, ) .watchWithStream( eventStreams: [ diff --git a/lib/ui/home/bloc/search_message_cubit.dart b/lib/ui/home/bloc/search_message_cubit.dart index 55e0fa0c3d..bfc7afe51b 100644 --- a/lib/ui/home/bloc/search_message_cubit.dart +++ b/lib/ui/home/bloc/search_message_cubit.dart @@ -2,8 +2,8 @@ import 'package:bloc/bloc.dart'; import 'package:equatable/equatable.dart'; import 'package:scrollable_positioned_list/scrollable_positioned_list.dart'; +import '../../../db/dao/message_dao.dart'; import '../../../db/database.dart'; -import '../../../db/mixin_database.dart'; import '../../../utils/extension/extension.dart'; import '../../../utils/logger.dart'; import 'slide_category_cubit.dart'; diff --git a/lib/ui/home/chat_slide_page/chat_info_page.dart b/lib/ui/home/chat_slide_page/chat_info_page.dart index 7a41e19c37..f99749ca25 100644 --- a/lib/ui/home/chat_slide_page/chat_info_page.dart +++ b/lib/ui/home/chat_slide_page/chat_info_page.dart @@ -589,7 +589,9 @@ class ConversationBio extends HookWidget { duration: kVerySlowThrottleDuration, ); } - return database.userDao.biography(userId!).watchSingleWithStream( + return database.userDao + .biographyByIdentityNumber(userId!) + .watchSingleWithStream( eventStreams: [ DataBaseEventBus.instance.watchUpdateUserStream([userId!]) ], diff --git a/lib/ui/home/chat_slide_page/circle_manager_page.dart b/lib/ui/home/chat_slide_page/circle_manager_page.dart index 541a416d48..30a4e897ce 100644 --- a/lib/ui/home/chat_slide_page/circle_manager_page.dart +++ b/lib/ui/home/chat_slide_page/circle_manager_page.dart @@ -4,8 +4,8 @@ import 'package:flutter_svg/svg.dart'; import 'package:mixin_bot_sdk_dart/mixin_bot_sdk_dart.dart'; import '../../../constants/resources.dart'; +import '../../../db/dao/circle_dao.dart'; import '../../../db/database_event_bus.dart'; -import '../../../db/mixin_database.dart'; import '../../../utils/color_utils.dart'; import '../../../utils/extension/extension.dart'; diff --git a/lib/ui/home/chat_slide_page/group_participants_page.dart b/lib/ui/home/chat_slide_page/group_participants_page.dart index a021fd276a..bd8f202f8d 100644 --- a/lib/ui/home/chat_slide_page/group_participants_page.dart +++ b/lib/ui/home/chat_slide_page/group_participants_page.dart @@ -4,8 +4,8 @@ import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:mixin_bot_sdk_dart/mixin_bot_sdk_dart.dart'; import '../../../constants/resources.dart'; +import '../../../db/dao/participant_dao.dart'; import '../../../db/database_event_bus.dart'; -import '../../../db/mixin_database.dart'; import '../../../utils/extension/extension.dart'; import '../../../utils/hook.dart'; import '../../../widgets/action_button.dart'; diff --git a/lib/ui/home/chat_slide_page/groups_in_common_page.dart b/lib/ui/home/chat_slide_page/groups_in_common_page.dart index 80862428f6..0f5b104e35 100644 --- a/lib/ui/home/chat_slide_page/groups_in_common_page.dart +++ b/lib/ui/home/chat_slide_page/groups_in_common_page.dart @@ -4,7 +4,7 @@ import 'package:flutter_svg/svg.dart'; import 'package:mixin_bot_sdk_dart/mixin_bot_sdk_dart.dart'; import '../../../constants/resources.dart'; -import '../../../db/mixin_database.dart'; +import '../../../db/dao/conversation_dao.dart'; import '../../../utils/extension/extension.dart'; import '../../../utils/hook.dart'; import '../../../widgets/app_bar.dart'; @@ -45,7 +45,7 @@ class _ConversationList extends HookWidget { final conversationList = useMemoizedFuture(() { final selfId = context.accountServer.userId; return context.accountServer.database.conversationDao - .findTheSameConversations(selfId, userId) + .findSameConversations(selfId, userId) .get(); }, [], keys: [userId]).data; diff --git a/lib/ui/home/chat_slide_page/pin_messages_page.dart b/lib/ui/home/chat_slide_page/pin_messages_page.dart index c02f7d7e2c..aa00d2e528 100644 --- a/lib/ui/home/chat_slide_page/pin_messages_page.dart +++ b/lib/ui/home/chat_slide_page/pin_messages_page.dart @@ -36,7 +36,9 @@ class PinMessagesPage extends HookWidget { eventStreams: [ DataBaseEventBus.instance.watchPinMessageStream( conversationIds: [conversationId], - ) + ), + DataBaseEventBus.instance.updateAssetStream, + DataBaseEventBus.instance.updateStickerStream, ], duration: kSlowThrottleDuration, ), diff --git a/lib/ui/home/chat_slide_page/search_message_page.dart b/lib/ui/home/chat_slide_page/search_message_page.dart index 6aee9f9fab..98a0cefe1d 100644 --- a/lib/ui/home/chat_slide_page/search_message_page.dart +++ b/lib/ui/home/chat_slide_page/search_message_page.dart @@ -369,7 +369,7 @@ class _SearchParticipantList extends HookWidget { if (value.isEmpty) { return userDao - .groupParticipants(conversationId: conversationId) + .groupParticipants(conversationId) .watchWithStream( eventStreams: [ DataBaseEventBus.instance.watchUpdateParticipantStream( @@ -381,9 +381,9 @@ class _SearchParticipantList extends HookWidget { } return userDao .fuzzySearchGroupUser( - currentUserId: context.multiAuthState.currentUserId ?? '', - conversationId: conversationId, - keyword: value, + context.multiAuthState.currentUserId ?? '', + conversationId, + value, ) .watchWithStream( eventStreams: [ diff --git a/lib/ui/home/conversation/audio_player_bar.dart b/lib/ui/home/conversation/audio_player_bar.dart index f58091d639..6e46bad898 100644 --- a/lib/ui/home/conversation/audio_player_bar.dart +++ b/lib/ui/home/conversation/audio_player_bar.dart @@ -3,6 +3,7 @@ import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:flutter_svg/flutter_svg.dart'; import '../../../constants/resources.dart'; +import '../../../db/dao/conversation_dao.dart'; import '../../../db/database_event_bus.dart'; import '../../../db/mixin_database.dart'; import '../../../utils/audio_message_player/audio_message_service.dart'; diff --git a/lib/ui/home/conversation/conversation_list.dart b/lib/ui/home/conversation/conversation_list.dart index 88894bc2c3..93ea903dbc 100644 --- a/lib/ui/home/conversation/conversation_list.dart +++ b/lib/ui/home/conversation/conversation_list.dart @@ -9,7 +9,7 @@ import '../../../bloc/bloc_converter.dart'; import '../../../bloc/minute_timer_cubit.dart'; import '../../../bloc/paging/paging_bloc.dart'; import '../../../constants/resources.dart'; -import '../../../db/mixin_database.dart'; +import '../../../db/dao/conversation_dao.dart'; import '../../../enum/message_category.dart'; import '../../../utils/extension/extension.dart'; import '../../../utils/hook.dart'; diff --git a/lib/ui/home/conversation/menu_wrapper.dart b/lib/ui/home/conversation/menu_wrapper.dart index 32502e3bb9..861148553f 100644 --- a/lib/ui/home/conversation/menu_wrapper.dart +++ b/lib/ui/home/conversation/menu_wrapper.dart @@ -3,8 +3,8 @@ import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:mixin_bot_sdk_dart/mixin_bot_sdk_dart.dart'; import '../../../constants/resources.dart'; +import '../../../db/dao/conversation_dao.dart'; import '../../../db/extension/conversation.dart'; -import '../../../db/mixin_database.dart'; import '../../../utils/extension/extension.dart'; import '../../../utils/hook.dart'; import '../../../widgets/conversation/mute_dialog.dart'; diff --git a/lib/ui/home/conversation/search_list.dart b/lib/ui/home/conversation/search_list.dart index 68f4352f44..9aa6604946 100644 --- a/lib/ui/home/conversation/search_list.dart +++ b/lib/ui/home/conversation/search_list.dart @@ -13,6 +13,8 @@ import '../../../blaze/vo/pin_message_minimal.dart'; import '../../../bloc/bloc_converter.dart'; import '../../../bloc/keyword_cubit.dart'; import '../../../bloc/minute_timer_cubit.dart'; +import '../../../db/dao/conversation_dao.dart'; +import '../../../db/dao/message_dao.dart'; import '../../../db/database_event_bus.dart'; import '../../../db/extension/conversation.dart'; import '../../../db/mixin_database.dart'; diff --git a/lib/ui/home/conversation/unseen_conversation_list.dart b/lib/ui/home/conversation/unseen_conversation_list.dart index 7d199ea976..9c4197a0e4 100644 --- a/lib/ui/home/conversation/unseen_conversation_list.dart +++ b/lib/ui/home/conversation/unseen_conversation_list.dart @@ -3,8 +3,8 @@ import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:rxdart/rxdart.dart'; import 'package:scrollable_positioned_list/scrollable_positioned_list.dart'; +import '../../../db/dao/conversation_dao.dart'; import '../../../db/database_event_bus.dart'; -import '../../../db/mixin_database.dart'; import '../../../utils/extension/extension.dart'; import '../../../utils/hook.dart'; import '../bloc/conversation_cubit.dart'; diff --git a/lib/ui/home/slide_page.dart b/lib/ui/home/slide_page.dart index cc43ef0368..64ca2af903 100644 --- a/lib/ui/home/slide_page.dart +++ b/lib/ui/home/slide_page.dart @@ -9,8 +9,9 @@ import 'package:mixin_bot_sdk_dart/mixin_bot_sdk_dart.dart'; import '../../bloc/bloc_converter.dart'; import '../../bloc/setting_cubit.dart'; import '../../constants/resources.dart'; +import '../../db/dao/circle_dao.dart'; +import '../../db/dao/conversation_dao.dart'; import '../../db/database_event_bus.dart'; -import '../../db/mixin_database.dart'; import '../../generated/l10n.dart'; import '../../utils/color_utils.dart'; import '../../utils/extension/extension.dart'; diff --git a/lib/ui/setting/storage_usage_list_page.dart b/lib/ui/setting/storage_usage_list_page.dart index 5a9fbd01f5..29c51906c2 100644 --- a/lib/ui/setting/storage_usage_list_page.dart +++ b/lib/ui/setting/storage_usage_list_page.dart @@ -4,8 +4,8 @@ import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:watcher/watcher.dart'; +import '../../db/dao/conversation_dao.dart'; import '../../db/extension/conversation.dart'; -import '../../db/mixin_database.dart'; import '../../utils/extension/extension.dart'; import '../../utils/hook.dart'; import '../../widgets/app_bar.dart'; diff --git a/lib/utils/device_transfer/device_transfer_sender.dart b/lib/utils/device_transfer/device_transfer_sender.dart index a84cd0e1f9..e2d37931b7 100644 --- a/lib/utils/device_transfer/device_transfer_sender.dart +++ b/lib/utils/device_transfer/device_transfer_sender.dart @@ -210,15 +210,15 @@ class DeviceTransferSender { // send total count await runWithLog((socket) async { final db = database.mixinDatabase; - final count = await db.countMediaMessages().getSingle() + - await db.countMessages().getSingle() + - await db.countStickers().getSingle() + + final count = await db.messageDao.countMediaMessages().getSingle() + + await db.messageDao.countMessages().getSingle() + + await db.stickerDao.countStickers().getSingle() + await db.assetDao.countAssets().getSingle() + await db.snapshotDao.countSnapshots().getSingle() + - await db.countUsers().getSingle() + - await db.countConversations().getSingle() + - await db.countParticipants().getSingle() + - await db.countPinMessages().getSingle() + + await db.userDao.countUsers().getSingle() + + await db.conversationDao.countConversations().getSingle() + + await db.participantDao.countParticipants().getSingle() + + await db.pinMessageDao.countPinMessages().getSingle() + await database.transcriptMessageDao .countTranscriptMessages() .getSingle() + diff --git a/lib/utils/extension/extension.dart b/lib/utils/extension/extension.dart index a413b52d4f..d12d85cfe1 100644 --- a/lib/utils/extension/extension.dart +++ b/lib/utils/extension/extension.dart @@ -29,6 +29,7 @@ import '../audio_message_player/audio_message_service.dart'; import '../platform.dart'; import '../synchronized.dart'; +export 'package:collection/collection.dart' show IterableNullableExtension; export 'package:mixin_bot_sdk_dart/mixin_bot_sdk_dart.dart' show UuidHashcodeExtension; export 'package:provider/provider.dart' show ReadContext, WatchContext; diff --git a/lib/utils/extension/src/iterable.dart b/lib/utils/extension/src/iterable.dart index 90a3630df1..70a424dd2d 100644 --- a/lib/utils/extension/src/iterable.dart +++ b/lib/utils/extension/src/iterable.dart @@ -5,10 +5,6 @@ extension IterableExtension on Iterable { cast().firstWhere(test, orElse: () => null); } -extension IterableExtenstionNull on Iterable { - Iterable whereNotNull() => where((e) => e != null).cast(); -} - extension ListExtension on List { List joinList(T separator) { final iterator = this.iterator; diff --git a/lib/widgets/actions/command_palette_action.dart b/lib/widgets/actions/command_palette_action.dart index b9d5b11a6a..0160648ddc 100644 --- a/lib/widgets/actions/command_palette_action.dart +++ b/lib/widgets/actions/command_palette_action.dart @@ -6,6 +6,7 @@ import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:flutter_svg/svg.dart'; import '../../constants/resources.dart'; +import '../../db/dao/conversation_dao.dart'; import '../../db/database_event_bus.dart'; import '../../db/extension/conversation.dart'; import '../../db/mixin_database.dart'; diff --git a/lib/widgets/avatar_view/avatar_view.dart b/lib/widgets/avatar_view/avatar_view.dart index 520ede2820..ba9ca0a051 100644 --- a/lib/widgets/avatar_view/avatar_view.dart +++ b/lib/widgets/avatar_view/avatar_view.dart @@ -4,6 +4,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:mixin_bot_sdk_dart/mixin_bot_sdk_dart.dart' hide User; +import '../../db/dao/conversation_dao.dart'; import '../../db/database_event_bus.dart'; import '../../db/mixin_database.dart'; import '../../utils/color_utils.dart'; diff --git a/lib/widgets/message/item/text/mention_builder.dart b/lib/widgets/message/item/text/mention_builder.dart index ce26ae61bd..77cdaafd40 100644 --- a/lib/widgets/message/item/text/mention_builder.dart +++ b/lib/widgets/message/item/text/mention_builder.dart @@ -3,7 +3,6 @@ import 'package:flutter/widgets.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; import '../../../../db/dao/user_dao.dart'; -import '../../../../db/mixin_database.dart'; import '../../../../utils/extension/extension.dart'; import '../../../../utils/hook.dart'; import '../../../../utils/reg_exp_utils.dart'; diff --git a/lib/widgets/message/item/transcript_message.dart b/lib/widgets/message/item/transcript_message.dart index d7d4d594f1..631d437427 100644 --- a/lib/widgets/message/item/transcript_message.dart +++ b/lib/widgets/message/item/transcript_message.dart @@ -230,6 +230,7 @@ class TranscriptPage extends HookWidget { DataBaseEventBus.instance.watchUpdateTranscriptMessageStream( transcriptIds: [transcriptMessage.messageId]), DataBaseEventBus.instance.updateAssetStream, + DataBaseEventBus.instance.updateStickerStream, ], duration: kDefaultThrottleDuration, ).map((list) => list diff --git a/lib/widgets/user_selector/bloc/conversation_filter_cubit.dart b/lib/widgets/user_selector/bloc/conversation_filter_cubit.dart index 8e2e882633..a93e955f77 100644 --- a/lib/widgets/user_selector/bloc/conversation_filter_cubit.dart +++ b/lib/widgets/user_selector/bloc/conversation_filter_cubit.dart @@ -1,11 +1,10 @@ import 'package:bloc/bloc.dart'; -import 'package:collection/collection.dart'; import 'package:equatable/equatable.dart'; import '../../../account/account_server.dart'; -import '../../../db/extension/conversation.dart'; -import '../../../db/extension/user.dart'; +import '../../../db/dao/conversation_dao.dart'; import '../../../db/mixin_database.dart'; +import '../../../utils/extension/extension.dart'; import '../../../utils/sort.dart'; part 'conversation_filter_state.dart'; @@ -36,7 +35,8 @@ class ConversationFilterCubit extends Cubit { contactConversationIds = conversations .where((element) => element.isContactConversation && element.ownerId != null) - .map((e) => e.ownerId!) + .map((e) => e.ownerId) + .whereNotNull() .toSet(); botConversationIds = conversations .where((element) => element.isBotConversation) diff --git a/lib/widgets/user_selector/conversation_selector.dart b/lib/widgets/user_selector/conversation_selector.dart index 0cf553732d..b062b33eeb 100644 --- a/lib/widgets/user_selector/conversation_selector.dart +++ b/lib/widgets/user_selector/conversation_selector.dart @@ -10,6 +10,7 @@ import '../../constants/brightness_theme_data.dart'; import '../../constants/constants.dart'; import '../../constants/resources.dart'; import '../../crypto/uuid/uuid.dart'; +import '../../db/dao/conversation_dao.dart'; import '../../db/mixin_database.dart'; import '../../enum/encrypt_category.dart'; import '../../utils/extension/extension.dart'; diff --git a/lib/workers/decrypt_message.dart b/lib/workers/decrypt_message.dart index 8783bdc904..5277dbf262 100644 --- a/lib/workers/decrypt_message.dart +++ b/lib/workers/decrypt_message.dart @@ -26,6 +26,7 @@ import '../crypto/signal/signal_database.dart'; import '../crypto/signal/signal_key_util.dart'; import '../crypto/signal/signal_protocol.dart'; import '../crypto/uuid/uuid.dart'; +import '../db/dao/message_dao.dart'; import '../db/database.dart'; import '../db/extension/job.dart'; import '../db/mixin_database.dart' as db; @@ -101,7 +102,7 @@ class DecryptMessage extends Injector { return true; } final messageHistory = - await database.messagesHistoryDao.findMessageHistoryById(messageId); + await database.messageHistoryDao.findMessageHistoryById(messageId); return messageHistory != null; } @@ -146,7 +147,7 @@ class DecryptMessage extends Injector { d('DecryptMessage isSignal'); if (data.category == MessageCategory.signalKey) { _remoteStatus = MessageStatus.read; - await database.messagesHistoryDao + await database.messageHistoryDao .insert(MessagesHistoryData(messageId: data.messageId)); } await _processSignalMessage(data); @@ -212,7 +213,7 @@ class DecryptMessage extends Injector { if (composeMessageData.resendMessageId != null) { await _processReDecryptMessage( data, composeMessageData.resendMessageId!, plain); - await database.messagesHistoryDao + await database.messageHistoryDao .insert(MessagesHistoryData(messageId: data.messageId)); } else { try { @@ -280,7 +281,7 @@ class DecryptMessage extends Injector { i('on device transfer command: $command'); _deviceTransfer?.handleRemoteCommand(command); } - await database.messagesHistoryDao + await database.messageHistoryDao .insert(MessagesHistoryData(messageId: data.messageId)); } else if (data.category == MessageCategory.plainText || data.category == MessageCategory.plainImage || @@ -479,7 +480,7 @@ class DecryptMessage extends Injector { await database.pinMessageDao.deleteByIds(pinMessage.messageIds); } - await database.messagesHistoryDao + await database.messageHistoryDao .insert(MessagesHistoryData(messageId: data.messageId)); } @@ -526,7 +527,7 @@ class DecryptMessage extends Injector { messageId: recallMessage.messageId, conversationId: data.conversationId, )), - database.messagesHistoryDao + database.messageHistoryDao .insert(MessagesHistoryData(messageId: data.messageId)), ]); } diff --git a/lib/workers/job/cleanup_quote_content_job.dart b/lib/workers/job/cleanup_quote_content_job.dart index 9909f3e105..3f1eca8b78 100644 --- a/lib/workers/job/cleanup_quote_content_job.dart +++ b/lib/workers/job/cleanup_quote_content_job.dart @@ -15,9 +15,8 @@ class CleanupQuoteContentJob extends BaseMigrationJob { Future migration(Job job) async { var rowId = -1; while (true) { - final messages = await database.messageDao - .findBigQuoteMessage(rowId, _kQueryMax) - .get(); + final messages = + await database.messageDao.bigQuoteMessage(rowId, _kQueryMax).get(); for (final message in messages) { final quoteMessageId = message.quoteMessageId; if (quoteMessageId == null) { diff --git a/lib/workers/job/sending_job.dart b/lib/workers/job/sending_job.dart index bd3ef18c0d..406c4387f2 100644 --- a/lib/workers/job/sending_job.dart +++ b/lib/workers/job/sending_job.dart @@ -15,6 +15,7 @@ import '../../crypto/encrypted/encrypted_protocol.dart'; import '../../crypto/signal/signal_protocol.dart'; import '../../db/converter/utc_value_serializer.dart'; import '../../db/dao/job_dao.dart'; +import '../../db/dao/message_dao.dart'; import '../../db/extension/message.dart'; import '../../db/mixin_database.dart'; import '../../enum/message_category.dart'; @@ -136,7 +137,8 @@ class SendingJob extends JobQueue> { messageId = job.blazeMessage!; } - var message = await database.messageDao.sendingMessage(messageId); + var message = + await database.messageDao.sendingMessage(messageId).getSingleOrNull(); if (message == null) { await database.jobDao.deleteJobById(job.jobId); return; @@ -358,13 +360,15 @@ class SendingJob extends JobQueue> { required int expireIn, }) async { var participantSessionKey = await database.participantSessionDao - .getParticipantSessionKeyWithoutSelf(message.conversationId, userId); + .participantSessionKeyWithoutSelf(message.conversationId, userId) + .getSingleOrNull(); if (participantSessionKey == null || participantSessionKey.publicKey.isNullOrBlank()) { await sender.syncConversation(message.conversationId); participantSessionKey = await database.participantSessionDao - .getParticipantSessionKeyWithoutSelf(message.conversationId, userId); + .participantSessionKeyWithoutSelf(message.conversationId, userId) + .getSingleOrNull(); } // Workaround no session key, can't encrypt message @@ -374,8 +378,8 @@ class SendingJob extends JobQueue> { } final otherSessionKey = await database.participantSessionDao - .getOtherParticipantSessionKey( - message.conversationId, userId, sessionId); + .otherParticipantSessionKey(message.conversationId, userId, sessionId) + .getSingleOrNull(); final plaintext = message.category.isAttachment || message.category.isSticker || diff --git a/lib/workers/sender.dart b/lib/workers/sender.dart index fcb57b5161..3906ade248 100644 --- a/lib/workers/sender.dart +++ b/lib/workers/sender.dart @@ -118,7 +118,8 @@ class Sender { Future checkSessionSenderKey(String conversationId) async { final participants = await database.participantSessionDao - .getNotSendSessionParticipants(conversationId, sessionId); + .notSendSessionParticipants(conversationId, sessionId) + .get(); if (participants.isEmpty) { return; } @@ -199,7 +200,7 @@ class Sender { if (result.success) { final messageIds = signalKeyMessages .map((e) => db.MessagesHistoryData(messageId: e.messageId)); - await database.messagesHistoryDao.insertList(messageIds); + await database.messageHistoryDao.insertList(messageIds); final sentSenderKeys = signalKeyMessages .map((e) => db.ParticipantSessionData(