feat: Also migrate inbound group sessions

For users who do not use the chat backup this could be useful.
This commit is contained in:
Christian Pauly 2021-06-19 11:03:52 +02:00
parent 4dc62f6150
commit a7ffe4835d
7 changed files with 273 additions and 251 deletions

View File

@ -2141,6 +2141,27 @@ sort order of ${prevState.sortOrder}. This should never happen...''');
await database.storeUserDeviceKeysInfo( await database.storeUserDeviceKeysInfo(
_id, userId, deviceKeysList.outdated); _id, userId, deviceKeysList.outdated);
} }
Logs().d('Migrate inbound group sessions...');
try {
final sessions = await legacyDatabase.getAllInboundGroupSessions(_id);
for (var i = 0; i < sessions.length; i++) {
Logs().d('$i / ${sessions.length}');
final session = sessions[i];
await database.storeInboundGroupSession(
_id,
session.roomId,
session.sessionId,
session.pickle,
session.content,
session.indexes,
session.allowedAtIndex,
session.senderKey,
session.senderClaimedKeys,
);
}
} catch (e, s) {
Logs().e('Unable to migrate inbound group sessions!', e, s);
}
await legacyDatabase.clear(_id); await legacyDatabase.clear(_id);
await legacyDatabaseDestroyer?.call(this); await legacyDatabaseDestroyer?.call(this);

View File

@ -256,6 +256,19 @@ class Database extends _$Database implements DatabaseApi {
return OutboundGroupSession.fromJson(res.single.toJson(), userId); return OutboundGroupSession.fromJson(res.single.toJson(), userId);
} }
@override
Future<List<StoredInboundGroupSession>> getAllInboundGroupSessions(
int clientId,
) async {
final res = await dbGetAllInboundGroupSessions(clientId).get();
if (res.isEmpty) {
return [];
}
return res
.map((res) => StoredInboundGroupSession.fromJson(res.toJson()))
.toList();
}
@override @override
Future<StoredInboundGroupSession> getInboundGroupSession( Future<StoredInboundGroupSession> getInboundGroupSession(
int clientId, int clientId,

View File

@ -32,27 +32,26 @@ class DbClient extends DataClass implements Insertable<DbClient> {
factory DbClient.fromData(Map<String, dynamic> data, GeneratedDatabase db, factory DbClient.fromData(Map<String, dynamic> data, GeneratedDatabase db,
{String prefix}) { {String prefix}) {
final effectivePrefix = prefix ?? ''; final effectivePrefix = prefix ?? '';
final intType = db.typeSystem.forDartType<int>();
final stringType = db.typeSystem.forDartType<String>();
return DbClient( return DbClient(
clientId: clientId: const IntType()
intType.mapFromDatabaseResponse(data['${effectivePrefix}client_id']), .mapFromDatabaseResponse(data['${effectivePrefix}client_id']),
name: stringType.mapFromDatabaseResponse(data['${effectivePrefix}name']), name: const StringType()
homeserverUrl: stringType .mapFromDatabaseResponse(data['${effectivePrefix}name']),
homeserverUrl: const StringType()
.mapFromDatabaseResponse(data['${effectivePrefix}homeserver_url']), .mapFromDatabaseResponse(data['${effectivePrefix}homeserver_url']),
token: token: const StringType()
stringType.mapFromDatabaseResponse(data['${effectivePrefix}token']), .mapFromDatabaseResponse(data['${effectivePrefix}token']),
userId: userId: const StringType()
stringType.mapFromDatabaseResponse(data['${effectivePrefix}user_id']), .mapFromDatabaseResponse(data['${effectivePrefix}user_id']),
deviceId: stringType deviceId: const StringType()
.mapFromDatabaseResponse(data['${effectivePrefix}device_id']), .mapFromDatabaseResponse(data['${effectivePrefix}device_id']),
deviceName: stringType deviceName: const StringType()
.mapFromDatabaseResponse(data['${effectivePrefix}device_name']), .mapFromDatabaseResponse(data['${effectivePrefix}device_name']),
prevBatch: stringType prevBatch: const StringType()
.mapFromDatabaseResponse(data['${effectivePrefix}prev_batch']), .mapFromDatabaseResponse(data['${effectivePrefix}prev_batch']),
syncFilterId: stringType syncFilterId: const StringType()
.mapFromDatabaseResponse(data['${effectivePrefix}sync_filter_id']), .mapFromDatabaseResponse(data['${effectivePrefix}sync_filter_id']),
olmAccount: stringType olmAccount: const StringType()
.mapFromDatabaseResponse(data['${effectivePrefix}olm_account']), .mapFromDatabaseResponse(data['${effectivePrefix}olm_account']),
); );
} }
@ -216,7 +215,7 @@ class DbClient extends DataClass implements Insertable<DbClient> {
$mrjc(syncFilterId.hashCode, $mrjc(syncFilterId.hashCode,
olmAccount.hashCode)))))))))); olmAccount.hashCode))))))))));
@override @override
bool operator ==(dynamic other) => bool operator ==(Object other) =>
identical(this, other) || identical(this, other) ||
(other is DbClient && (other is DbClient &&
other.clientId == this.clientId && other.clientId == this.clientId &&
@ -551,8 +550,8 @@ class Clients extends Table with TableInfo<Clients, DbClient> {
Set<GeneratedColumn> get $primaryKey => {clientId}; Set<GeneratedColumn> get $primaryKey => {clientId};
@override @override
DbClient map(Map<String, dynamic> data, {String tablePrefix}) { DbClient map(Map<String, dynamic> data, {String tablePrefix}) {
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : null; return DbClient.fromData(data, _db,
return DbClient.fromData(data, _db, prefix: effectivePrefix); prefix: tablePrefix != null ? '$tablePrefix.' : null);
} }
@override @override
@ -576,16 +575,13 @@ class DbUserDeviceKey extends DataClass implements Insertable<DbUserDeviceKey> {
Map<String, dynamic> data, GeneratedDatabase db, Map<String, dynamic> data, GeneratedDatabase db,
{String prefix}) { {String prefix}) {
final effectivePrefix = prefix ?? ''; final effectivePrefix = prefix ?? '';
final intType = db.typeSystem.forDartType<int>();
final stringType = db.typeSystem.forDartType<String>();
final boolType = db.typeSystem.forDartType<bool>();
return DbUserDeviceKey( return DbUserDeviceKey(
clientId: clientId: const IntType()
intType.mapFromDatabaseResponse(data['${effectivePrefix}client_id']), .mapFromDatabaseResponse(data['${effectivePrefix}client_id']),
userId: userId: const StringType()
stringType.mapFromDatabaseResponse(data['${effectivePrefix}user_id']), .mapFromDatabaseResponse(data['${effectivePrefix}user_id']),
outdated: outdated: const BoolType()
boolType.mapFromDatabaseResponse(data['${effectivePrefix}outdated']), .mapFromDatabaseResponse(data['${effectivePrefix}outdated']),
); );
} }
@override @override
@ -655,7 +651,7 @@ class DbUserDeviceKey extends DataClass implements Insertable<DbUserDeviceKey> {
int get hashCode => $mrjf( int get hashCode => $mrjf(
$mrjc(clientId.hashCode, $mrjc(userId.hashCode, outdated.hashCode))); $mrjc(clientId.hashCode, $mrjc(userId.hashCode, outdated.hashCode)));
@override @override
bool operator ==(dynamic other) => bool operator ==(Object other) =>
identical(this, other) || identical(this, other) ||
(other is DbUserDeviceKey && (other is DbUserDeviceKey &&
other.clientId == this.clientId && other.clientId == this.clientId &&
@ -791,8 +787,8 @@ class UserDeviceKeys extends Table
Set<GeneratedColumn> get $primaryKey => <GeneratedColumn>{}; Set<GeneratedColumn> get $primaryKey => <GeneratedColumn>{};
@override @override
DbUserDeviceKey map(Map<String, dynamic> data, {String tablePrefix}) { DbUserDeviceKey map(Map<String, dynamic> data, {String tablePrefix}) {
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : null; return DbUserDeviceKey.fromData(data, _db,
return DbUserDeviceKey.fromData(data, _db, prefix: effectivePrefix); prefix: tablePrefix != null ? '$tablePrefix.' : null);
} }
@override @override
@ -829,25 +825,22 @@ class DbUserDeviceKeysKey extends DataClass
Map<String, dynamic> data, GeneratedDatabase db, Map<String, dynamic> data, GeneratedDatabase db,
{String prefix}) { {String prefix}) {
final effectivePrefix = prefix ?? ''; final effectivePrefix = prefix ?? '';
final intType = db.typeSystem.forDartType<int>();
final stringType = db.typeSystem.forDartType<String>();
final boolType = db.typeSystem.forDartType<bool>();
return DbUserDeviceKeysKey( return DbUserDeviceKeysKey(
clientId: clientId: const IntType()
intType.mapFromDatabaseResponse(data['${effectivePrefix}client_id']), .mapFromDatabaseResponse(data['${effectivePrefix}client_id']),
userId: userId: const StringType()
stringType.mapFromDatabaseResponse(data['${effectivePrefix}user_id']), .mapFromDatabaseResponse(data['${effectivePrefix}user_id']),
deviceId: stringType deviceId: const StringType()
.mapFromDatabaseResponse(data['${effectivePrefix}device_id']), .mapFromDatabaseResponse(data['${effectivePrefix}device_id']),
content: content: const StringType()
stringType.mapFromDatabaseResponse(data['${effectivePrefix}content']), .mapFromDatabaseResponse(data['${effectivePrefix}content']),
verified: verified: const BoolType()
boolType.mapFromDatabaseResponse(data['${effectivePrefix}verified']), .mapFromDatabaseResponse(data['${effectivePrefix}verified']),
blocked: blocked: const BoolType()
boolType.mapFromDatabaseResponse(data['${effectivePrefix}blocked']), .mapFromDatabaseResponse(data['${effectivePrefix}blocked']),
lastActive: intType lastActive: const IntType()
.mapFromDatabaseResponse(data['${effectivePrefix}last_active']), .mapFromDatabaseResponse(data['${effectivePrefix}last_active']),
lastSentMessage: stringType lastSentMessage: const StringType()
.mapFromDatabaseResponse(data['${effectivePrefix}last_sent_message']), .mapFromDatabaseResponse(data['${effectivePrefix}last_sent_message']),
); );
} }
@ -988,7 +981,7 @@ class DbUserDeviceKeysKey extends DataClass
$mrjc(lastActive.hashCode, $mrjc(lastActive.hashCode,
lastSentMessage.hashCode)))))))); lastSentMessage.hashCode))))))));
@override @override
bool operator ==(dynamic other) => bool operator ==(Object other) =>
identical(this, other) || identical(this, other) ||
(other is DbUserDeviceKeysKey && (other is DbUserDeviceKeysKey &&
other.clientId == this.clientId && other.clientId == this.clientId &&
@ -1269,8 +1262,8 @@ class UserDeviceKeysKey extends Table
Set<GeneratedColumn> get $primaryKey => <GeneratedColumn>{}; Set<GeneratedColumn> get $primaryKey => <GeneratedColumn>{};
@override @override
DbUserDeviceKeysKey map(Map<String, dynamic> data, {String tablePrefix}) { DbUserDeviceKeysKey map(Map<String, dynamic> data, {String tablePrefix}) {
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : null; return DbUserDeviceKeysKey.fromData(data, _db,
return DbUserDeviceKeysKey.fromData(data, _db, prefix: effectivePrefix); prefix: tablePrefix != null ? '$tablePrefix.' : null);
} }
@override @override
@ -1304,22 +1297,19 @@ class DbUserCrossSigningKey extends DataClass
Map<String, dynamic> data, GeneratedDatabase db, Map<String, dynamic> data, GeneratedDatabase db,
{String prefix}) { {String prefix}) {
final effectivePrefix = prefix ?? ''; final effectivePrefix = prefix ?? '';
final intType = db.typeSystem.forDartType<int>();
final stringType = db.typeSystem.forDartType<String>();
final boolType = db.typeSystem.forDartType<bool>();
return DbUserCrossSigningKey( return DbUserCrossSigningKey(
clientId: clientId: const IntType()
intType.mapFromDatabaseResponse(data['${effectivePrefix}client_id']), .mapFromDatabaseResponse(data['${effectivePrefix}client_id']),
userId: userId: const StringType()
stringType.mapFromDatabaseResponse(data['${effectivePrefix}user_id']), .mapFromDatabaseResponse(data['${effectivePrefix}user_id']),
publicKey: stringType publicKey: const StringType()
.mapFromDatabaseResponse(data['${effectivePrefix}public_key']), .mapFromDatabaseResponse(data['${effectivePrefix}public_key']),
content: content: const StringType()
stringType.mapFromDatabaseResponse(data['${effectivePrefix}content']), .mapFromDatabaseResponse(data['${effectivePrefix}content']),
verified: verified: const BoolType()
boolType.mapFromDatabaseResponse(data['${effectivePrefix}verified']), .mapFromDatabaseResponse(data['${effectivePrefix}verified']),
blocked: blocked: const BoolType()
boolType.mapFromDatabaseResponse(data['${effectivePrefix}blocked']), .mapFromDatabaseResponse(data['${effectivePrefix}blocked']),
); );
} }
@override @override
@ -1431,7 +1421,7 @@ class DbUserCrossSigningKey extends DataClass
$mrjc(content.hashCode, $mrjc(content.hashCode,
$mrjc(verified.hashCode, blocked.hashCode)))))); $mrjc(verified.hashCode, blocked.hashCode))))));
@override @override
bool operator ==(dynamic other) => bool operator ==(Object other) =>
identical(this, other) || identical(this, other) ||
(other is DbUserCrossSigningKey && (other is DbUserCrossSigningKey &&
other.clientId == this.clientId && other.clientId == this.clientId &&
@ -1651,8 +1641,8 @@ class UserCrossSigningKeys extends Table
Set<GeneratedColumn> get $primaryKey => <GeneratedColumn>{}; Set<GeneratedColumn> get $primaryKey => <GeneratedColumn>{};
@override @override
DbUserCrossSigningKey map(Map<String, dynamic> data, {String tablePrefix}) { DbUserCrossSigningKey map(Map<String, dynamic> data, {String tablePrefix}) {
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : null; return DbUserCrossSigningKey.fromData(data, _db,
return DbUserCrossSigningKey.fromData(data, _db, prefix: effectivePrefix); prefix: tablePrefix != null ? '$tablePrefix.' : null);
} }
@override @override
@ -1683,18 +1673,16 @@ class DbOlmSessions extends DataClass implements Insertable<DbOlmSessions> {
Map<String, dynamic> data, GeneratedDatabase db, Map<String, dynamic> data, GeneratedDatabase db,
{String prefix}) { {String prefix}) {
final effectivePrefix = prefix ?? ''; final effectivePrefix = prefix ?? '';
final intType = db.typeSystem.forDartType<int>();
final stringType = db.typeSystem.forDartType<String>();
return DbOlmSessions( return DbOlmSessions(
clientId: clientId: const IntType()
intType.mapFromDatabaseResponse(data['${effectivePrefix}client_id']), .mapFromDatabaseResponse(data['${effectivePrefix}client_id']),
identityKey: stringType identityKey: const StringType()
.mapFromDatabaseResponse(data['${effectivePrefix}identity_key']), .mapFromDatabaseResponse(data['${effectivePrefix}identity_key']),
sessionId: stringType sessionId: const StringType()
.mapFromDatabaseResponse(data['${effectivePrefix}session_id']), .mapFromDatabaseResponse(data['${effectivePrefix}session_id']),
pickle: pickle: const StringType()
stringType.mapFromDatabaseResponse(data['${effectivePrefix}pickle']), .mapFromDatabaseResponse(data['${effectivePrefix}pickle']),
lastReceived: intType lastReceived: const IntType()
.mapFromDatabaseResponse(data['${effectivePrefix}last_received']), .mapFromDatabaseResponse(data['${effectivePrefix}last_received']),
); );
} }
@ -1794,7 +1782,7 @@ class DbOlmSessions extends DataClass implements Insertable<DbOlmSessions> {
$mrjc(sessionId.hashCode, $mrjc(sessionId.hashCode,
$mrjc(pickle.hashCode, lastReceived.hashCode))))); $mrjc(pickle.hashCode, lastReceived.hashCode)))));
@override @override
bool operator ==(dynamic other) => bool operator ==(Object other) =>
identical(this, other) || identical(this, other) ||
(other is DbOlmSessions && (other is DbOlmSessions &&
other.clientId == this.clientId && other.clientId == this.clientId &&
@ -1993,8 +1981,8 @@ class OlmSessions extends Table with TableInfo<OlmSessions, DbOlmSessions> {
Set<GeneratedColumn> get $primaryKey => <GeneratedColumn>{}; Set<GeneratedColumn> get $primaryKey => <GeneratedColumn>{};
@override @override
DbOlmSessions map(Map<String, dynamic> data, {String tablePrefix}) { DbOlmSessions map(Map<String, dynamic> data, {String tablePrefix}) {
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : null; return DbOlmSessions.fromData(data, _db,
return DbOlmSessions.fromData(data, _db, prefix: effectivePrefix); prefix: tablePrefix != null ? '$tablePrefix.' : null);
} }
@override @override
@ -2028,20 +2016,18 @@ class DbOutboundGroupSession extends DataClass
Map<String, dynamic> data, GeneratedDatabase db, Map<String, dynamic> data, GeneratedDatabase db,
{String prefix}) { {String prefix}) {
final effectivePrefix = prefix ?? ''; final effectivePrefix = prefix ?? '';
final intType = db.typeSystem.forDartType<int>();
final stringType = db.typeSystem.forDartType<String>();
return DbOutboundGroupSession( return DbOutboundGroupSession(
clientId: clientId: const IntType()
intType.mapFromDatabaseResponse(data['${effectivePrefix}client_id']), .mapFromDatabaseResponse(data['${effectivePrefix}client_id']),
roomId: roomId: const StringType()
stringType.mapFromDatabaseResponse(data['${effectivePrefix}room_id']), .mapFromDatabaseResponse(data['${effectivePrefix}room_id']),
pickle: pickle: const StringType()
stringType.mapFromDatabaseResponse(data['${effectivePrefix}pickle']), .mapFromDatabaseResponse(data['${effectivePrefix}pickle']),
deviceIds: stringType deviceIds: const StringType()
.mapFromDatabaseResponse(data['${effectivePrefix}device_ids']), .mapFromDatabaseResponse(data['${effectivePrefix}device_ids']),
creationTime: intType creationTime: const IntType()
.mapFromDatabaseResponse(data['${effectivePrefix}creation_time']), .mapFromDatabaseResponse(data['${effectivePrefix}creation_time']),
sentMessages: intType sentMessages: const IntType()
.mapFromDatabaseResponse(data['${effectivePrefix}sent_messages']), .mapFromDatabaseResponse(data['${effectivePrefix}sent_messages']),
); );
} }
@ -2153,7 +2139,7 @@ class DbOutboundGroupSession extends DataClass
$mrjc(deviceIds.hashCode, $mrjc(deviceIds.hashCode,
$mrjc(creationTime.hashCode, sentMessages.hashCode)))))); $mrjc(creationTime.hashCode, sentMessages.hashCode))))));
@override @override
bool operator ==(dynamic other) => bool operator ==(Object other) =>
identical(this, other) || identical(this, other) ||
(other is DbOutboundGroupSession && (other is DbOutboundGroupSession &&
other.clientId == this.clientId && other.clientId == this.clientId &&
@ -2383,8 +2369,8 @@ class OutboundGroupSessions extends Table
Set<GeneratedColumn> get $primaryKey => <GeneratedColumn>{}; Set<GeneratedColumn> get $primaryKey => <GeneratedColumn>{};
@override @override
DbOutboundGroupSession map(Map<String, dynamic> data, {String tablePrefix}) { DbOutboundGroupSession map(Map<String, dynamic> data, {String tablePrefix}) {
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : null; return DbOutboundGroupSession.fromData(data, _db,
return DbOutboundGroupSession.fromData(data, _db, prefix: effectivePrefix); prefix: tablePrefix != null ? '$tablePrefix.' : null);
} }
@override @override
@ -2425,29 +2411,26 @@ class DbInboundGroupSession extends DataClass
Map<String, dynamic> data, GeneratedDatabase db, Map<String, dynamic> data, GeneratedDatabase db,
{String prefix}) { {String prefix}) {
final effectivePrefix = prefix ?? ''; final effectivePrefix = prefix ?? '';
final intType = db.typeSystem.forDartType<int>();
final stringType = db.typeSystem.forDartType<String>();
final boolType = db.typeSystem.forDartType<bool>();
return DbInboundGroupSession( return DbInboundGroupSession(
clientId: clientId: const IntType()
intType.mapFromDatabaseResponse(data['${effectivePrefix}client_id']), .mapFromDatabaseResponse(data['${effectivePrefix}client_id']),
roomId: roomId: const StringType()
stringType.mapFromDatabaseResponse(data['${effectivePrefix}room_id']), .mapFromDatabaseResponse(data['${effectivePrefix}room_id']),
sessionId: stringType sessionId: const StringType()
.mapFromDatabaseResponse(data['${effectivePrefix}session_id']), .mapFromDatabaseResponse(data['${effectivePrefix}session_id']),
pickle: pickle: const StringType()
stringType.mapFromDatabaseResponse(data['${effectivePrefix}pickle']), .mapFromDatabaseResponse(data['${effectivePrefix}pickle']),
content: content: const StringType()
stringType.mapFromDatabaseResponse(data['${effectivePrefix}content']), .mapFromDatabaseResponse(data['${effectivePrefix}content']),
indexes: indexes: const StringType()
stringType.mapFromDatabaseResponse(data['${effectivePrefix}indexes']), .mapFromDatabaseResponse(data['${effectivePrefix}indexes']),
allowedAtIndex: stringType allowedAtIndex: const StringType()
.mapFromDatabaseResponse(data['${effectivePrefix}allowed_at_index']), .mapFromDatabaseResponse(data['${effectivePrefix}allowed_at_index']),
uploaded: uploaded: const BoolType()
boolType.mapFromDatabaseResponse(data['${effectivePrefix}uploaded']), .mapFromDatabaseResponse(data['${effectivePrefix}uploaded']),
senderKey: stringType senderKey: const StringType()
.mapFromDatabaseResponse(data['${effectivePrefix}sender_key']), .mapFromDatabaseResponse(data['${effectivePrefix}sender_key']),
senderClaimedKeys: stringType.mapFromDatabaseResponse( senderClaimedKeys: const StringType().mapFromDatabaseResponse(
data['${effectivePrefix}sender_claimed_keys']), data['${effectivePrefix}sender_claimed_keys']),
); );
} }
@ -2614,7 +2597,7 @@ class DbInboundGroupSession extends DataClass
$mrjc(senderKey.hashCode, $mrjc(senderKey.hashCode,
senderClaimedKeys.hashCode)))))))))); senderClaimedKeys.hashCode))))))))));
@override @override
bool operator ==(dynamic other) => bool operator ==(Object other) =>
identical(this, other) || identical(this, other) ||
(other is DbInboundGroupSession && (other is DbInboundGroupSession &&
other.clientId == this.clientId && other.clientId == this.clientId &&
@ -2947,8 +2930,8 @@ class InboundGroupSessions extends Table
Set<GeneratedColumn> get $primaryKey => <GeneratedColumn>{}; Set<GeneratedColumn> get $primaryKey => <GeneratedColumn>{};
@override @override
DbInboundGroupSession map(Map<String, dynamic> data, {String tablePrefix}) { DbInboundGroupSession map(Map<String, dynamic> data, {String tablePrefix}) {
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : null; return DbInboundGroupSession.fromData(data, _db,
return DbInboundGroupSession.fromData(data, _db, prefix: effectivePrefix); prefix: tablePrefix != null ? '$tablePrefix.' : null);
} }
@override @override
@ -2990,32 +2973,29 @@ class DbRoom extends DataClass implements Insertable<DbRoom> {
factory DbRoom.fromData(Map<String, dynamic> data, GeneratedDatabase db, factory DbRoom.fromData(Map<String, dynamic> data, GeneratedDatabase db,
{String prefix}) { {String prefix}) {
final effectivePrefix = prefix ?? ''; final effectivePrefix = prefix ?? '';
final intType = db.typeSystem.forDartType<int>();
final stringType = db.typeSystem.forDartType<String>();
final doubleType = db.typeSystem.forDartType<double>();
return DbRoom( return DbRoom(
clientId: clientId: const IntType()
intType.mapFromDatabaseResponse(data['${effectivePrefix}client_id']), .mapFromDatabaseResponse(data['${effectivePrefix}client_id']),
roomId: roomId: const StringType()
stringType.mapFromDatabaseResponse(data['${effectivePrefix}room_id']), .mapFromDatabaseResponse(data['${effectivePrefix}room_id']),
membership: stringType membership: const StringType()
.mapFromDatabaseResponse(data['${effectivePrefix}membership']), .mapFromDatabaseResponse(data['${effectivePrefix}membership']),
highlightCount: intType highlightCount: const IntType()
.mapFromDatabaseResponse(data['${effectivePrefix}highlight_count']), .mapFromDatabaseResponse(data['${effectivePrefix}highlight_count']),
notificationCount: intType.mapFromDatabaseResponse( notificationCount: const IntType().mapFromDatabaseResponse(
data['${effectivePrefix}notification_count']), data['${effectivePrefix}notification_count']),
prevBatch: stringType prevBatch: const StringType()
.mapFromDatabaseResponse(data['${effectivePrefix}prev_batch']), .mapFromDatabaseResponse(data['${effectivePrefix}prev_batch']),
joinedMemberCount: intType.mapFromDatabaseResponse( joinedMemberCount: const IntType().mapFromDatabaseResponse(
data['${effectivePrefix}joined_member_count']), data['${effectivePrefix}joined_member_count']),
invitedMemberCount: intType.mapFromDatabaseResponse( invitedMemberCount: const IntType().mapFromDatabaseResponse(
data['${effectivePrefix}invited_member_count']), data['${effectivePrefix}invited_member_count']),
newestSortOrder: doubleType newestSortOrder: const RealType()
.mapFromDatabaseResponse(data['${effectivePrefix}newest_sort_order']), .mapFromDatabaseResponse(data['${effectivePrefix}newest_sort_order']),
oldestSortOrder: doubleType oldestSortOrder: const RealType()
.mapFromDatabaseResponse(data['${effectivePrefix}oldest_sort_order']), .mapFromDatabaseResponse(data['${effectivePrefix}oldest_sort_order']),
heroes: heroes: const StringType()
stringType.mapFromDatabaseResponse(data['${effectivePrefix}heroes']), .mapFromDatabaseResponse(data['${effectivePrefix}heroes']),
); );
} }
@override @override
@ -3194,7 +3174,7 @@ class DbRoom extends DataClass implements Insertable<DbRoom> {
$mrjc(oldestSortOrder.hashCode, $mrjc(oldestSortOrder.hashCode,
heroes.hashCode))))))))))); heroes.hashCode)))))))))));
@override @override
bool operator ==(dynamic other) => bool operator ==(Object other) =>
identical(this, other) || identical(this, other) ||
(other is DbRoom && (other is DbRoom &&
other.clientId == this.clientId && other.clientId == this.clientId &&
@ -3572,8 +3552,8 @@ class Rooms extends Table with TableInfo<Rooms, DbRoom> {
Set<GeneratedColumn> get $primaryKey => <GeneratedColumn>{}; Set<GeneratedColumn> get $primaryKey => <GeneratedColumn>{};
@override @override
DbRoom map(Map<String, dynamic> data, {String tablePrefix}) { DbRoom map(Map<String, dynamic> data, {String tablePrefix}) {
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : null; return DbRoom.fromData(data, _db,
return DbRoom.fromData(data, _db, prefix: effectivePrefix); prefix: tablePrefix != null ? '$tablePrefix.' : null);
} }
@override @override
@ -3616,32 +3596,31 @@ class DbEvent extends DataClass implements Insertable<DbEvent> {
factory DbEvent.fromData(Map<String, dynamic> data, GeneratedDatabase db, factory DbEvent.fromData(Map<String, dynamic> data, GeneratedDatabase db,
{String prefix}) { {String prefix}) {
final effectivePrefix = prefix ?? ''; final effectivePrefix = prefix ?? '';
final intType = db.typeSystem.forDartType<int>();
final stringType = db.typeSystem.forDartType<String>();
final doubleType = db.typeSystem.forDartType<double>();
return DbEvent( return DbEvent(
clientId: clientId: const IntType()
intType.mapFromDatabaseResponse(data['${effectivePrefix}client_id']), .mapFromDatabaseResponse(data['${effectivePrefix}client_id']),
eventId: stringType eventId: const StringType()
.mapFromDatabaseResponse(data['${effectivePrefix}event_id']), .mapFromDatabaseResponse(data['${effectivePrefix}event_id']),
roomId: roomId: const StringType()
stringType.mapFromDatabaseResponse(data['${effectivePrefix}room_id']), .mapFromDatabaseResponse(data['${effectivePrefix}room_id']),
sortOrder: doubleType sortOrder: const RealType()
.mapFromDatabaseResponse(data['${effectivePrefix}sort_order']), .mapFromDatabaseResponse(data['${effectivePrefix}sort_order']),
originServerTs: intType originServerTs: const IntType()
.mapFromDatabaseResponse(data['${effectivePrefix}origin_server_ts']), .mapFromDatabaseResponse(data['${effectivePrefix}origin_server_ts']),
sender: sender: const StringType()
stringType.mapFromDatabaseResponse(data['${effectivePrefix}sender']), .mapFromDatabaseResponse(data['${effectivePrefix}sender']),
type: stringType.mapFromDatabaseResponse(data['${effectivePrefix}type']), type: const StringType()
unsigned: stringType .mapFromDatabaseResponse(data['${effectivePrefix}type']),
unsigned: const StringType()
.mapFromDatabaseResponse(data['${effectivePrefix}unsigned']), .mapFromDatabaseResponse(data['${effectivePrefix}unsigned']),
content: content: const StringType()
stringType.mapFromDatabaseResponse(data['${effectivePrefix}content']), .mapFromDatabaseResponse(data['${effectivePrefix}content']),
prevContent: stringType prevContent: const StringType()
.mapFromDatabaseResponse(data['${effectivePrefix}prev_content']), .mapFromDatabaseResponse(data['${effectivePrefix}prev_content']),
stateKey: stringType stateKey: const StringType()
.mapFromDatabaseResponse(data['${effectivePrefix}state_key']), .mapFromDatabaseResponse(data['${effectivePrefix}state_key']),
status: intType.mapFromDatabaseResponse(data['${effectivePrefix}status']), status: const IntType()
.mapFromDatabaseResponse(data['${effectivePrefix}status']),
); );
} }
@override @override
@ -3829,7 +3808,7 @@ class DbEvent extends DataClass implements Insertable<DbEvent> {
$mrjc(stateKey.hashCode, $mrjc(stateKey.hashCode,
status.hashCode)))))))))))); status.hashCode))))))))))));
@override @override
bool operator ==(dynamic other) => bool operator ==(Object other) =>
identical(this, other) || identical(this, other) ||
(other is DbEvent && (other is DbEvent &&
other.clientId == this.clientId && other.clientId == this.clientId &&
@ -4217,8 +4196,8 @@ class Events extends Table with TableInfo<Events, DbEvent> {
Set<GeneratedColumn> get $primaryKey => <GeneratedColumn>{}; Set<GeneratedColumn> get $primaryKey => <GeneratedColumn>{};
@override @override
DbEvent map(Map<String, dynamic> data, {String tablePrefix}) { DbEvent map(Map<String, dynamic> data, {String tablePrefix}) {
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : null; return DbEvent.fromData(data, _db,
return DbEvent.fromData(data, _db, prefix: effectivePrefix); prefix: tablePrefix != null ? '$tablePrefix.' : null);
} }
@override @override
@ -4260,30 +4239,28 @@ class DbRoomState extends DataClass implements Insertable<DbRoomState> {
factory DbRoomState.fromData(Map<String, dynamic> data, GeneratedDatabase db, factory DbRoomState.fromData(Map<String, dynamic> data, GeneratedDatabase db,
{String prefix}) { {String prefix}) {
final effectivePrefix = prefix ?? ''; final effectivePrefix = prefix ?? '';
final intType = db.typeSystem.forDartType<int>();
final stringType = db.typeSystem.forDartType<String>();
final doubleType = db.typeSystem.forDartType<double>();
return DbRoomState( return DbRoomState(
clientId: clientId: const IntType()
intType.mapFromDatabaseResponse(data['${effectivePrefix}client_id']), .mapFromDatabaseResponse(data['${effectivePrefix}client_id']),
eventId: stringType eventId: const StringType()
.mapFromDatabaseResponse(data['${effectivePrefix}event_id']), .mapFromDatabaseResponse(data['${effectivePrefix}event_id']),
roomId: roomId: const StringType()
stringType.mapFromDatabaseResponse(data['${effectivePrefix}room_id']), .mapFromDatabaseResponse(data['${effectivePrefix}room_id']),
sortOrder: doubleType sortOrder: const RealType()
.mapFromDatabaseResponse(data['${effectivePrefix}sort_order']), .mapFromDatabaseResponse(data['${effectivePrefix}sort_order']),
originServerTs: intType originServerTs: const IntType()
.mapFromDatabaseResponse(data['${effectivePrefix}origin_server_ts']), .mapFromDatabaseResponse(data['${effectivePrefix}origin_server_ts']),
sender: sender: const StringType()
stringType.mapFromDatabaseResponse(data['${effectivePrefix}sender']), .mapFromDatabaseResponse(data['${effectivePrefix}sender']),
type: stringType.mapFromDatabaseResponse(data['${effectivePrefix}type']), type: const StringType()
unsigned: stringType .mapFromDatabaseResponse(data['${effectivePrefix}type']),
unsigned: const StringType()
.mapFromDatabaseResponse(data['${effectivePrefix}unsigned']), .mapFromDatabaseResponse(data['${effectivePrefix}unsigned']),
content: content: const StringType()
stringType.mapFromDatabaseResponse(data['${effectivePrefix}content']), .mapFromDatabaseResponse(data['${effectivePrefix}content']),
prevContent: stringType prevContent: const StringType()
.mapFromDatabaseResponse(data['${effectivePrefix}prev_content']), .mapFromDatabaseResponse(data['${effectivePrefix}prev_content']),
stateKey: stringType stateKey: const StringType()
.mapFromDatabaseResponse(data['${effectivePrefix}state_key']), .mapFromDatabaseResponse(data['${effectivePrefix}state_key']),
); );
} }
@ -4460,7 +4437,7 @@ class DbRoomState extends DataClass implements Insertable<DbRoomState> {
$mrjc(prevContent.hashCode, $mrjc(prevContent.hashCode,
stateKey.hashCode))))))))))); stateKey.hashCode)))))))))));
@override @override
bool operator ==(dynamic other) => bool operator ==(Object other) =>
identical(this, other) || identical(this, other) ||
(other is DbRoomState && (other is DbRoomState &&
other.clientId == this.clientId && other.clientId == this.clientId &&
@ -4826,8 +4803,8 @@ class RoomStates extends Table with TableInfo<RoomStates, DbRoomState> {
Set<GeneratedColumn> get $primaryKey => <GeneratedColumn>{}; Set<GeneratedColumn> get $primaryKey => <GeneratedColumn>{};
@override @override
DbRoomState map(Map<String, dynamic> data, {String tablePrefix}) { DbRoomState map(Map<String, dynamic> data, {String tablePrefix}) {
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : null; return DbRoomState.fromData(data, _db,
return DbRoomState.fromData(data, _db, prefix: effectivePrefix); prefix: tablePrefix != null ? '$tablePrefix.' : null);
} }
@override @override
@ -4853,14 +4830,13 @@ class DbAccountData extends DataClass implements Insertable<DbAccountData> {
Map<String, dynamic> data, GeneratedDatabase db, Map<String, dynamic> data, GeneratedDatabase db,
{String prefix}) { {String prefix}) {
final effectivePrefix = prefix ?? ''; final effectivePrefix = prefix ?? '';
final intType = db.typeSystem.forDartType<int>();
final stringType = db.typeSystem.forDartType<String>();
return DbAccountData( return DbAccountData(
clientId: clientId: const IntType()
intType.mapFromDatabaseResponse(data['${effectivePrefix}client_id']), .mapFromDatabaseResponse(data['${effectivePrefix}client_id']),
type: stringType.mapFromDatabaseResponse(data['${effectivePrefix}type']), type: const StringType()
content: .mapFromDatabaseResponse(data['${effectivePrefix}type']),
stringType.mapFromDatabaseResponse(data['${effectivePrefix}content']), content: const StringType()
.mapFromDatabaseResponse(data['${effectivePrefix}content']),
); );
} }
@override @override
@ -4929,7 +4905,7 @@ class DbAccountData extends DataClass implements Insertable<DbAccountData> {
int get hashCode => int get hashCode =>
$mrjf($mrjc(clientId.hashCode, $mrjc(type.hashCode, content.hashCode))); $mrjf($mrjc(clientId.hashCode, $mrjc(type.hashCode, content.hashCode)));
@override @override
bool operator ==(dynamic other) => bool operator ==(Object other) =>
identical(this, other) || identical(this, other) ||
(other is DbAccountData && (other is DbAccountData &&
other.clientId == this.clientId && other.clientId == this.clientId &&
@ -5063,8 +5039,8 @@ class AccountData extends Table with TableInfo<AccountData, DbAccountData> {
Set<GeneratedColumn> get $primaryKey => <GeneratedColumn>{}; Set<GeneratedColumn> get $primaryKey => <GeneratedColumn>{};
@override @override
DbAccountData map(Map<String, dynamic> data, {String tablePrefix}) { DbAccountData map(Map<String, dynamic> data, {String tablePrefix}) {
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : null; return DbAccountData.fromData(data, _db,
return DbAccountData.fromData(data, _db, prefix: effectivePrefix); prefix: tablePrefix != null ? '$tablePrefix.' : null);
} }
@override @override
@ -5093,16 +5069,15 @@ class DbRoomAccountData extends DataClass
Map<String, dynamic> data, GeneratedDatabase db, Map<String, dynamic> data, GeneratedDatabase db,
{String prefix}) { {String prefix}) {
final effectivePrefix = prefix ?? ''; final effectivePrefix = prefix ?? '';
final intType = db.typeSystem.forDartType<int>();
final stringType = db.typeSystem.forDartType<String>();
return DbRoomAccountData( return DbRoomAccountData(
clientId: clientId: const IntType()
intType.mapFromDatabaseResponse(data['${effectivePrefix}client_id']), .mapFromDatabaseResponse(data['${effectivePrefix}client_id']),
type: stringType.mapFromDatabaseResponse(data['${effectivePrefix}type']), type: const StringType()
roomId: .mapFromDatabaseResponse(data['${effectivePrefix}type']),
stringType.mapFromDatabaseResponse(data['${effectivePrefix}room_id']), roomId: const StringType()
content: .mapFromDatabaseResponse(data['${effectivePrefix}room_id']),
stringType.mapFromDatabaseResponse(data['${effectivePrefix}content']), content: const StringType()
.mapFromDatabaseResponse(data['${effectivePrefix}content']),
); );
} }
@override @override
@ -5181,7 +5156,7 @@ class DbRoomAccountData extends DataClass
int get hashCode => $mrjf($mrjc(clientId.hashCode, int get hashCode => $mrjf($mrjc(clientId.hashCode,
$mrjc(type.hashCode, $mrjc(roomId.hashCode, content.hashCode)))); $mrjc(type.hashCode, $mrjc(roomId.hashCode, content.hashCode))));
@override @override
bool operator ==(dynamic other) => bool operator ==(Object other) =>
identical(this, other) || identical(this, other) ||
(other is DbRoomAccountData && (other is DbRoomAccountData &&
other.clientId == this.clientId && other.clientId == this.clientId &&
@ -5345,8 +5320,8 @@ class RoomAccountData extends Table
Set<GeneratedColumn> get $primaryKey => <GeneratedColumn>{}; Set<GeneratedColumn> get $primaryKey => <GeneratedColumn>{};
@override @override
DbRoomAccountData map(Map<String, dynamic> data, {String tablePrefix}) { DbRoomAccountData map(Map<String, dynamic> data, {String tablePrefix}) {
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : null; return DbRoomAccountData.fromData(data, _db,
return DbRoomAccountData.fromData(data, _db, prefix: effectivePrefix); prefix: tablePrefix != null ? '$tablePrefix.' : null);
} }
@override @override
@ -5374,16 +5349,15 @@ class DbPresence extends DataClass implements Insertable<DbPresence> {
factory DbPresence.fromData(Map<String, dynamic> data, GeneratedDatabase db, factory DbPresence.fromData(Map<String, dynamic> data, GeneratedDatabase db,
{String prefix}) { {String prefix}) {
final effectivePrefix = prefix ?? ''; final effectivePrefix = prefix ?? '';
final intType = db.typeSystem.forDartType<int>();
final stringType = db.typeSystem.forDartType<String>();
return DbPresence( return DbPresence(
clientId: clientId: const IntType()
intType.mapFromDatabaseResponse(data['${effectivePrefix}client_id']), .mapFromDatabaseResponse(data['${effectivePrefix}client_id']),
type: stringType.mapFromDatabaseResponse(data['${effectivePrefix}type']), type: const StringType()
sender: .mapFromDatabaseResponse(data['${effectivePrefix}type']),
stringType.mapFromDatabaseResponse(data['${effectivePrefix}sender']), sender: const StringType()
content: .mapFromDatabaseResponse(data['${effectivePrefix}sender']),
stringType.mapFromDatabaseResponse(data['${effectivePrefix}content']), content: const StringType()
.mapFromDatabaseResponse(data['${effectivePrefix}content']),
); );
} }
@override @override
@ -5462,7 +5436,7 @@ class DbPresence extends DataClass implements Insertable<DbPresence> {
int get hashCode => $mrjf($mrjc(clientId.hashCode, int get hashCode => $mrjf($mrjc(clientId.hashCode,
$mrjc(type.hashCode, $mrjc(sender.hashCode, content.hashCode)))); $mrjc(type.hashCode, $mrjc(sender.hashCode, content.hashCode))));
@override @override
bool operator ==(dynamic other) => bool operator ==(Object other) =>
identical(this, other) || identical(this, other) ||
(other is DbPresence && (other is DbPresence &&
other.clientId == this.clientId && other.clientId == this.clientId &&
@ -5625,8 +5599,8 @@ class Presences extends Table with TableInfo<Presences, DbPresence> {
Set<GeneratedColumn> get $primaryKey => <GeneratedColumn>{}; Set<GeneratedColumn> get $primaryKey => <GeneratedColumn>{};
@override @override
DbPresence map(Map<String, dynamic> data, {String tablePrefix}) { DbPresence map(Map<String, dynamic> data, {String tablePrefix}) {
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : null; return DbPresence.fromData(data, _db,
return DbPresence.fromData(data, _db, prefix: effectivePrefix); prefix: tablePrefix != null ? '$tablePrefix.' : null);
} }
@override @override
@ -5657,17 +5631,16 @@ class DbToDeviceQueue extends DataClass implements Insertable<DbToDeviceQueue> {
Map<String, dynamic> data, GeneratedDatabase db, Map<String, dynamic> data, GeneratedDatabase db,
{String prefix}) { {String prefix}) {
final effectivePrefix = prefix ?? ''; final effectivePrefix = prefix ?? '';
final intType = db.typeSystem.forDartType<int>();
final stringType = db.typeSystem.forDartType<String>();
return DbToDeviceQueue( return DbToDeviceQueue(
clientId: clientId: const IntType()
intType.mapFromDatabaseResponse(data['${effectivePrefix}client_id']), .mapFromDatabaseResponse(data['${effectivePrefix}client_id']),
id: intType.mapFromDatabaseResponse(data['${effectivePrefix}id']), id: const IntType().mapFromDatabaseResponse(data['${effectivePrefix}id']),
type: stringType.mapFromDatabaseResponse(data['${effectivePrefix}type']), type: const StringType()
txnId: .mapFromDatabaseResponse(data['${effectivePrefix}type']),
stringType.mapFromDatabaseResponse(data['${effectivePrefix}txn_id']), txnId: const StringType()
content: .mapFromDatabaseResponse(data['${effectivePrefix}txn_id']),
stringType.mapFromDatabaseResponse(data['${effectivePrefix}content']), content: const StringType()
.mapFromDatabaseResponse(data['${effectivePrefix}content']),
); );
} }
@override @override
@ -5756,7 +5729,7 @@ class DbToDeviceQueue extends DataClass implements Insertable<DbToDeviceQueue> {
$mrjc(id.hashCode, $mrjc(id.hashCode,
$mrjc(type.hashCode, $mrjc(txnId.hashCode, content.hashCode))))); $mrjc(type.hashCode, $mrjc(txnId.hashCode, content.hashCode)))));
@override @override
bool operator ==(dynamic other) => bool operator ==(Object other) =>
identical(this, other) || identical(this, other) ||
(other is DbToDeviceQueue && (other is DbToDeviceQueue &&
other.clientId == this.clientId && other.clientId == this.clientId &&
@ -5948,8 +5921,8 @@ class ToDeviceQueue extends Table
Set<GeneratedColumn> get $primaryKey => {id}; Set<GeneratedColumn> get $primaryKey => {id};
@override @override
DbToDeviceQueue map(Map<String, dynamic> data, {String tablePrefix}) { DbToDeviceQueue map(Map<String, dynamic> data, {String tablePrefix}) {
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : null; return DbToDeviceQueue.fromData(data, _db,
return DbToDeviceQueue.fromData(data, _db, prefix: effectivePrefix); prefix: tablePrefix != null ? '$tablePrefix.' : null);
} }
@override @override
@ -5976,18 +5949,17 @@ class DbSSSSCache extends DataClass implements Insertable<DbSSSSCache> {
factory DbSSSSCache.fromData(Map<String, dynamic> data, GeneratedDatabase db, factory DbSSSSCache.fromData(Map<String, dynamic> data, GeneratedDatabase db,
{String prefix}) { {String prefix}) {
final effectivePrefix = prefix ?? ''; final effectivePrefix = prefix ?? '';
final intType = db.typeSystem.forDartType<int>();
final stringType = db.typeSystem.forDartType<String>();
return DbSSSSCache( return DbSSSSCache(
clientId: clientId: const IntType()
intType.mapFromDatabaseResponse(data['${effectivePrefix}client_id']), .mapFromDatabaseResponse(data['${effectivePrefix}client_id']),
type: stringType.mapFromDatabaseResponse(data['${effectivePrefix}type']), type: const StringType()
keyId: .mapFromDatabaseResponse(data['${effectivePrefix}type']),
stringType.mapFromDatabaseResponse(data['${effectivePrefix}key_id']), keyId: const StringType()
ciphertext: stringType .mapFromDatabaseResponse(data['${effectivePrefix}key_id']),
ciphertext: const StringType()
.mapFromDatabaseResponse(data['${effectivePrefix}ciphertext']), .mapFromDatabaseResponse(data['${effectivePrefix}ciphertext']),
content: content: const StringType()
stringType.mapFromDatabaseResponse(data['${effectivePrefix}content']), .mapFromDatabaseResponse(data['${effectivePrefix}content']),
); );
} }
@override @override
@ -6084,7 +6056,7 @@ class DbSSSSCache extends DataClass implements Insertable<DbSSSSCache> {
$mrjc( $mrjc(
keyId.hashCode, $mrjc(ciphertext.hashCode, content.hashCode))))); keyId.hashCode, $mrjc(ciphertext.hashCode, content.hashCode)))));
@override @override
bool operator ==(dynamic other) => bool operator ==(Object other) =>
identical(this, other) || identical(this, other) ||
(other is DbSSSSCache && (other is DbSSSSCache &&
other.clientId == this.clientId && other.clientId == this.clientId &&
@ -6280,8 +6252,8 @@ class SsssCache extends Table with TableInfo<SsssCache, DbSSSSCache> {
Set<GeneratedColumn> get $primaryKey => <GeneratedColumn>{}; Set<GeneratedColumn> get $primaryKey => <GeneratedColumn>{};
@override @override
DbSSSSCache map(Map<String, dynamic> data, {String tablePrefix}) { DbSSSSCache map(Map<String, dynamic> data, {String tablePrefix}) {
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : null; return DbSSSSCache.fromData(data, _db,
return DbSSSSCache.fromData(data, _db, prefix: effectivePrefix); prefix: tablePrefix != null ? '$tablePrefix.' : null);
} }
@override @override
@ -6303,16 +6275,13 @@ class DbFile extends DataClass implements Insertable<DbFile> {
factory DbFile.fromData(Map<String, dynamic> data, GeneratedDatabase db, factory DbFile.fromData(Map<String, dynamic> data, GeneratedDatabase db,
{String prefix}) { {String prefix}) {
final effectivePrefix = prefix ?? ''; final effectivePrefix = prefix ?? '';
final stringType = db.typeSystem.forDartType<String>();
final uint8ListType = db.typeSystem.forDartType<Uint8List>();
final intType = db.typeSystem.forDartType<int>();
return DbFile( return DbFile(
mxcUri: mxcUri: const StringType()
stringType.mapFromDatabaseResponse(data['${effectivePrefix}mxc_uri']), .mapFromDatabaseResponse(data['${effectivePrefix}mxc_uri']),
bytes: uint8ListType bytes: const BlobType()
.mapFromDatabaseResponse(data['${effectivePrefix}bytes']), .mapFromDatabaseResponse(data['${effectivePrefix}bytes']),
savedAt: savedAt: const IntType()
intType.mapFromDatabaseResponse(data['${effectivePrefix}saved_at']), .mapFromDatabaseResponse(data['${effectivePrefix}saved_at']),
); );
} }
@override @override
@ -6380,7 +6349,7 @@ class DbFile extends DataClass implements Insertable<DbFile> {
int get hashCode => int get hashCode =>
$mrjf($mrjc(mxcUri.hashCode, $mrjc(bytes.hashCode, savedAt.hashCode))); $mrjf($mrjc(mxcUri.hashCode, $mrjc(bytes.hashCode, savedAt.hashCode)));
@override @override
bool operator ==(dynamic other) => bool operator ==(Object other) =>
identical(this, other) || identical(this, other) ||
(other is DbFile && (other is DbFile &&
other.mxcUri == this.mxcUri && other.mxcUri == this.mxcUri &&
@ -6511,8 +6480,8 @@ class Files extends Table with TableInfo<Files, DbFile> {
Set<GeneratedColumn> get $primaryKey => {mxcUri}; Set<GeneratedColumn> get $primaryKey => {mxcUri};
@override @override
DbFile map(Map<String, dynamic> data, {String tablePrefix}) { DbFile map(Map<String, dynamic> data, {String tablePrefix}) {
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : null; return DbFile.fromData(data, _db,
return DbFile.fromData(data, _db, prefix: effectivePrefix); prefix: tablePrefix != null ? '$tablePrefix.' : null);
} }
@override @override
@ -6817,7 +6786,8 @@ abstract class _$Database extends GeneratedDatabase {
readsFrom: {inboundGroupSessions}).map(inboundGroupSessions.mapFromRow); readsFrom: {inboundGroupSessions}).map(inboundGroupSessions.mapFromRow);
} }
Selectable<DbInboundGroupSession> getAllInboundGroupSessions(int client_id) { Selectable<DbInboundGroupSession> dbGetAllInboundGroupSessions(
int client_id) {
return customSelect( return customSelect(
'SELECT * FROM inbound_group_sessions WHERE client_id = :client_id', 'SELECT * FROM inbound_group_sessions WHERE client_id = :client_id',
variables: [Variable<int>(client_id)], variables: [Variable<int>(client_id)],
@ -7032,7 +7002,7 @@ abstract class _$Database extends GeneratedDatabase {
], ],
readsFrom: { readsFrom: {
userDeviceKeysKey userDeviceKeysKey
}).map((QueryRow row) => row.readString('last_sent_message')); }).map((QueryRow row) => row.read<String>('last_sent_message'));
} }
Future<int> setVerifiedUserCrossSigningKey( Future<int> setVerifiedUserCrossSigningKey(

View File

@ -204,7 +204,7 @@ storeOutboundGroupSession: INSERT OR REPLACE INTO outbound_group_sessions (clien
removeOutboundGroupSession: DELETE FROM outbound_group_sessions WHERE client_id = :client_id AND room_id = :room_id; removeOutboundGroupSession: DELETE FROM outbound_group_sessions WHERE client_id = :client_id AND room_id = :room_id;
dbGetInboundGroupSessionKey: SELECT * FROM inbound_group_sessions WHERE client_id = :client_id AND room_id = :room_id AND session_id = :session_id; dbGetInboundGroupSessionKey: SELECT * FROM inbound_group_sessions WHERE client_id = :client_id AND room_id = :room_id AND session_id = :session_id;
dbGetInboundGroupSessionKeys: SELECT * FROM inbound_group_sessions WHERE client_id = :client_id AND room_id = :room_id; dbGetInboundGroupSessionKeys: SELECT * FROM inbound_group_sessions WHERE client_id = :client_id AND room_id = :room_id;
getAllInboundGroupSessions: SELECT * FROM inbound_group_sessions WHERE client_id = :client_id; dbGetAllInboundGroupSessions: SELECT * FROM inbound_group_sessions WHERE client_id = :client_id;
storeInboundGroupSession: INSERT OR REPLACE INTO inbound_group_sessions (client_id, room_id, session_id, pickle, content, indexes, allowed_at_index, sender_key, sender_claimed_keys) VALUES (:client_id, :room_id, :session_id, :pickle, :content, :indexes, :allowed_at_index, :sender_key, :sender_claimed_keys); storeInboundGroupSession: INSERT OR REPLACE INTO inbound_group_sessions (client_id, room_id, session_id, pickle, content, indexes, allowed_at_index, sender_key, sender_claimed_keys) VALUES (:client_id, :room_id, :session_id, :pickle, :content, :indexes, :allowed_at_index, :sender_key, :sender_claimed_keys);
updateInboundGroupSessionIndexes: UPDATE inbound_group_sessions SET indexes = :indexes WHERE client_id = :client_id AND room_id = :room_id AND session_id = :session_id; updateInboundGroupSessionIndexes: UPDATE inbound_group_sessions SET indexes = :indexes WHERE client_id = :client_id AND room_id = :room_id AND session_id = :session_id;
updateInboundGroupSessionAllowedAtIndex: UPDATE inbound_group_sessions SET allowed_at_index = :allowed_at_index WHERE client_id = :client_id AND room_id = :room_id AND session_id = :session_id; updateInboundGroupSessionAllowedAtIndex: UPDATE inbound_group_sessions SET allowed_at_index = :allowed_at_index WHERE client_id = :client_id AND room_id = :room_id AND session_id = :session_id;

View File

@ -98,6 +98,10 @@ abstract class DatabaseApi {
String userId, String userId,
); );
Future<List<StoredInboundGroupSession>> getAllInboundGroupSessions(
int clientId,
);
Future<StoredInboundGroupSession> getInboundGroupSession( Future<StoredInboundGroupSession> getInboundGroupSession(
int clientId, int clientId,
String roomId, String roomId,

View File

@ -1029,6 +1029,16 @@ class FamedlySdkHiveDatabase extends DatabaseApi {
await _roomsBox.put(roomId.toHiveKey, raw); await _roomsBox.put(roomId.toHiveKey, raw);
return; return;
} }
@override
Future<List<StoredInboundGroupSession>> getAllInboundGroupSessions(
int clientId) async {
final rawSessions = await Future.wait(_inboundGroupSessionsBox.keys
.map((key) => _inboundGroupSessionsBox.get(key)));
return rawSessions
.map((raw) => StoredInboundGroupSession.fromJson(convertToJson(raw)))
.toList();
}
} }
Map<String, dynamic> convertToJson(Map map) { Map<String, dynamic> convertToJson(Map map) {

View File

@ -211,6 +211,10 @@ void testDatabase(Future<DatabaseApi> futureDatabase, int clientId) {
clientId, '\$event:example.com', Room(id: '!testroom:example.com')); clientId, '\$event:example.com', Room(id: '!testroom:example.com'));
expect(event, null); expect(event, null);
}); });
test('getAllInboundGroupSessions', () async {
final result = await database.getAllInboundGroupSessions(clientId);
expect(result.isEmpty, true);
});
test('getInboundGroupSession', () async { test('getInboundGroupSession', () async {
await database.getInboundGroupSession( await database.getInboundGroupSession(
clientId, '!testroom:example.com', 'sessionId'); clientId, '!testroom:example.com', 'sessionId');