diff --git a/app/lib/entity/file.dart b/app/lib/entity/file.dart index 92403c0d..c54e8761 100644 --- a/app/lib/entity/file.dart +++ b/app/lib/entity/file.dart @@ -231,6 +231,7 @@ class File with EquatableMixin { this.fileId, this.isFavorite, this.ownerId, + this.ownerDisplayName, this.metadata, this.isArchived, this.overrideDateTime, @@ -268,6 +269,7 @@ class File with EquatableMixin { fileId: json["fileId"], isFavorite: json_util.boolFromJson(json["isFavorite"]), ownerId: json["ownerId"] == null ? null : CiString(json["ownerId"]), + ownerDisplayName: json["ownerDisplayName"], trashbinFilename: json["trashbinFilename"], trashbinOriginalLocation: json["trashbinOriginalLocation"], trashbinDeletionTime: json["trashbinDeletionTime"] == null @@ -327,6 +329,9 @@ class File with EquatableMixin { if (ownerId != null) { product += "ownerId: '$ownerId', "; } + if (ownerDisplayName != null) { + product += "ownerDisplayName: '$ownerDisplayName', "; + } if (trashbinFilename != null) { product += "trashbinFilename: '$trashbinFilename', "; } @@ -362,6 +367,7 @@ class File with EquatableMixin { if (fileId != null) "fileId": fileId, if (isFavorite != null) "isFavorite": json_util.boolToJson(isFavorite), if (ownerId != null) "ownerId": ownerId.toString(), + if (ownerDisplayName != null) "ownerDisplayName": ownerDisplayName, if (trashbinFilename != null) "trashbinFilename": trashbinFilename, if (trashbinOriginalLocation != null) "trashbinOriginalLocation": trashbinOriginalLocation, @@ -386,6 +392,7 @@ class File with EquatableMixin { int? fileId, bool? isFavorite, CiString? ownerId, + String? ownerDisplayName, String? trashbinFilename, String? trashbinOriginalLocation, DateTime? trashbinDeletionTime, @@ -405,6 +412,7 @@ class File with EquatableMixin { fileId: fileId ?? this.fileId, isFavorite: isFavorite ?? this.isFavorite, ownerId: ownerId ?? this.ownerId, + ownerDisplayName: ownerDisplayName ?? this.ownerDisplayName, trashbinFilename: trashbinFilename ?? this.trashbinFilename, trashbinOriginalLocation: trashbinOriginalLocation ?? this.trashbinOriginalLocation, @@ -430,6 +438,7 @@ class File with EquatableMixin { fileId, isFavorite, ownerId, + ownerDisplayName, trashbinFilename, trashbinOriginalLocation, trashbinDeletionTime, @@ -449,6 +458,7 @@ class File with EquatableMixin { final int? fileId; final bool? isFavorite; final CiString? ownerId; + final String? ownerDisplayName; final String? trashbinFilename; final String? trashbinOriginalLocation; final DateTime? trashbinDeletionTime; diff --git a/app/lib/entity/file/data_source.dart b/app/lib/entity/file/data_source.dart index f5f7c567..74cb506d 100644 --- a/app/lib/entity/file/data_source.dart +++ b/app/lib/entity/file/data_source.dart @@ -45,6 +45,7 @@ class FileWebdavDataSource implements FileDataSource { fileid: 1, favorite: 1, ownerId: 1, + ownerDisplayName: 1, trashbinFilename: 1, trashbinOriginalLocation: 1, trashbinDeletionTime: 1, diff --git a/app/lib/entity/sqlite_table.dart b/app/lib/entity/sqlite_table.dart index 1719cbaf..30d4eb3b 100644 --- a/app/lib/entity/sqlite_table.dart +++ b/app/lib/entity/sqlite_table.dart @@ -36,6 +36,7 @@ class Files extends Table { IntColumn get usedBytes => integer().nullable()(); BoolColumn get hasPreview => boolean().nullable()(); TextColumn get ownerId => text().nullable()(); + TextColumn get ownerDisplayName => text().nullable()(); @override get uniqueKeys => [ diff --git a/app/lib/entity/sqlite_table.g.dart b/app/lib/entity/sqlite_table.g.dart index a16991bb..fa4d81ea 100644 --- a/app/lib/entity/sqlite_table.g.dart +++ b/app/lib/entity/sqlite_table.g.dart @@ -406,6 +406,7 @@ class File extends DataClass implements Insertable { final int? usedBytes; final bool? hasPreview; final String? ownerId; + final String? ownerDisplayName; File( {required this.rowId, required this.server, @@ -417,7 +418,8 @@ class File extends DataClass implements Insertable { this.isCollection, this.usedBytes, this.hasPreview, - this.ownerId}); + this.ownerId, + this.ownerDisplayName}); factory File.fromData(Map data, {String? prefix}) { final effectivePrefix = prefix ?? ''; return File( @@ -443,6 +445,8 @@ class File extends DataClass implements Insertable { .mapFromDatabaseResponse(data['${effectivePrefix}has_preview']), ownerId: const StringType() .mapFromDatabaseResponse(data['${effectivePrefix}owner_id']), + ownerDisplayName: const StringType().mapFromDatabaseResponse( + data['${effectivePrefix}owner_display_name']), ); } @override @@ -477,6 +481,9 @@ class File extends DataClass implements Insertable { if (!nullToAbsent || ownerId != null) { map['owner_id'] = Variable(ownerId); } + if (!nullToAbsent || ownerDisplayName != null) { + map['owner_display_name'] = Variable(ownerDisplayName); + } return map; } @@ -507,6 +514,9 @@ class File extends DataClass implements Insertable { ownerId: ownerId == null && nullToAbsent ? const Value.absent() : Value(ownerId), + ownerDisplayName: ownerDisplayName == null && nullToAbsent + ? const Value.absent() + : Value(ownerDisplayName), ); } @@ -525,6 +535,7 @@ class File extends DataClass implements Insertable { usedBytes: serializer.fromJson(json['usedBytes']), hasPreview: serializer.fromJson(json['hasPreview']), ownerId: serializer.fromJson(json['ownerId']), + ownerDisplayName: serializer.fromJson(json['ownerDisplayName']), ); } @override @@ -542,6 +553,7 @@ class File extends DataClass implements Insertable { 'usedBytes': serializer.toJson(usedBytes), 'hasPreview': serializer.toJson(hasPreview), 'ownerId': serializer.toJson(ownerId), + 'ownerDisplayName': serializer.toJson(ownerDisplayName), }; } @@ -556,7 +568,8 @@ class File extends DataClass implements Insertable { Value isCollection = const Value.absent(), Value usedBytes = const Value.absent(), Value hasPreview = const Value.absent(), - Value ownerId = const Value.absent()}) => + Value ownerId = const Value.absent(), + Value ownerDisplayName = const Value.absent()}) => File( rowId: rowId ?? this.rowId, server: server ?? this.server, @@ -572,6 +585,9 @@ class File extends DataClass implements Insertable { usedBytes: usedBytes.present ? usedBytes.value : this.usedBytes, hasPreview: hasPreview.present ? hasPreview.value : this.hasPreview, ownerId: ownerId.present ? ownerId.value : this.ownerId, + ownerDisplayName: ownerDisplayName.present + ? ownerDisplayName.value + : this.ownerDisplayName, ); @override String toString() { @@ -586,7 +602,8 @@ class File extends DataClass implements Insertable { ..write('isCollection: $isCollection, ') ..write('usedBytes: $usedBytes, ') ..write('hasPreview: $hasPreview, ') - ..write('ownerId: $ownerId') + ..write('ownerId: $ownerId, ') + ..write('ownerDisplayName: $ownerDisplayName') ..write(')')) .toString(); } @@ -603,7 +620,8 @@ class File extends DataClass implements Insertable { isCollection, usedBytes, hasPreview, - ownerId); + ownerId, + ownerDisplayName); @override bool operator ==(Object other) => identical(this, other) || @@ -618,7 +636,8 @@ class File extends DataClass implements Insertable { other.isCollection == this.isCollection && other.usedBytes == this.usedBytes && other.hasPreview == this.hasPreview && - other.ownerId == this.ownerId); + other.ownerId == this.ownerId && + other.ownerDisplayName == this.ownerDisplayName); } class FilesCompanion extends UpdateCompanion { @@ -633,6 +652,7 @@ class FilesCompanion extends UpdateCompanion { final Value usedBytes; final Value hasPreview; final Value ownerId; + final Value ownerDisplayName; const FilesCompanion({ this.rowId = const Value.absent(), this.server = const Value.absent(), @@ -645,6 +665,7 @@ class FilesCompanion extends UpdateCompanion { this.usedBytes = const Value.absent(), this.hasPreview = const Value.absent(), this.ownerId = const Value.absent(), + this.ownerDisplayName = const Value.absent(), }); FilesCompanion.insert({ this.rowId = const Value.absent(), @@ -658,6 +679,7 @@ class FilesCompanion extends UpdateCompanion { this.usedBytes = const Value.absent(), this.hasPreview = const Value.absent(), this.ownerId = const Value.absent(), + this.ownerDisplayName = const Value.absent(), }) : server = Value(server), fileId = Value(fileId); static Insertable custom({ @@ -672,6 +694,7 @@ class FilesCompanion extends UpdateCompanion { Expression? usedBytes, Expression? hasPreview, Expression? ownerId, + Expression? ownerDisplayName, }) { return RawValuesInsertable({ if (rowId != null) 'row_id': rowId, @@ -685,6 +708,7 @@ class FilesCompanion extends UpdateCompanion { if (usedBytes != null) 'used_bytes': usedBytes, if (hasPreview != null) 'has_preview': hasPreview, if (ownerId != null) 'owner_id': ownerId, + if (ownerDisplayName != null) 'owner_display_name': ownerDisplayName, }); } @@ -699,7 +723,8 @@ class FilesCompanion extends UpdateCompanion { Value? isCollection, Value? usedBytes, Value? hasPreview, - Value? ownerId}) { + Value? ownerId, + Value? ownerDisplayName}) { return FilesCompanion( rowId: rowId ?? this.rowId, server: server ?? this.server, @@ -712,6 +737,7 @@ class FilesCompanion extends UpdateCompanion { usedBytes: usedBytes ?? this.usedBytes, hasPreview: hasPreview ?? this.hasPreview, ownerId: ownerId ?? this.ownerId, + ownerDisplayName: ownerDisplayName ?? this.ownerDisplayName, ); } @@ -753,6 +779,9 @@ class FilesCompanion extends UpdateCompanion { if (ownerId.present) { map['owner_id'] = Variable(ownerId.value); } + if (ownerDisplayName.present) { + map['owner_display_name'] = Variable(ownerDisplayName.value); + } return map; } @@ -769,7 +798,8 @@ class FilesCompanion extends UpdateCompanion { ..write('isCollection: $isCollection, ') ..write('usedBytes: $usedBytes, ') ..write('hasPreview: $hasPreview, ') - ..write('ownerId: $ownerId') + ..write('ownerId: $ownerId, ') + ..write('ownerDisplayName: $ownerDisplayName') ..write(')')) .toString(); } @@ -849,6 +879,12 @@ class $FilesTable extends Files with TableInfo<$FilesTable, File> { late final GeneratedColumn ownerId = GeneratedColumn( 'owner_id', aliasedName, true, type: const StringType(), requiredDuringInsert: false); + final VerificationMeta _ownerDisplayNameMeta = + const VerificationMeta('ownerDisplayName'); + @override + late final GeneratedColumn ownerDisplayName = + GeneratedColumn('owner_display_name', aliasedName, true, + type: const StringType(), requiredDuringInsert: false); @override List get $columns => [ rowId, @@ -861,7 +897,8 @@ class $FilesTable extends Files with TableInfo<$FilesTable, File> { isCollection, usedBytes, hasPreview, - ownerId + ownerId, + ownerDisplayName ]; @override String get aliasedName => _alias ?? 'files'; @@ -925,6 +962,12 @@ class $FilesTable extends Files with TableInfo<$FilesTable, File> { context.handle(_ownerIdMeta, ownerId.isAcceptableOrUnknown(data['owner_id']!, _ownerIdMeta)); } + if (data.containsKey('owner_display_name')) { + context.handle( + _ownerDisplayNameMeta, + ownerDisplayName.isAcceptableOrUnknown( + data['owner_display_name']!, _ownerDisplayNameMeta)); + } return context; } diff --git a/app/lib/entity/sqlite_table_converter.dart b/app/lib/entity/sqlite_table_converter.dart index 994d9715..f3ec1dd1 100644 --- a/app/lib/entity/sqlite_table_converter.dart +++ b/app/lib/entity/sqlite_table_converter.dart @@ -92,6 +92,7 @@ class SqliteFileConverter { fileId: f.file.fileId, isFavorite: f.accountFile.isFavorite, ownerId: f.file.ownerId?.toCi(), + ownerDisplayName: f.file.ownerDisplayName, trashbinFilename: f.trash?.filename, trashbinOriginalLocation: f.trash?.originalLocation, trashbinDeletionTime: f.trash?.deletionTime, @@ -113,6 +114,7 @@ class SqliteFileConverter { usedBytes: Value(file.usedBytes), hasPreview: Value(file.hasPreview), ownerId: Value(file.ownerId!.toCaseInsensitiveString()), + ownerDisplayName: Value(file.ownerDisplayName), ); final dbAccountFile = sql.AccountFilesCompanion( account: account == null ? const Value.absent() : Value(account.rowId), diff --git a/app/lib/entity/webdav_response_parser.dart b/app/lib/entity/webdav_response_parser.dart index 7952ba49..ec2ef5e6 100644 --- a/app/lib/entity/webdav_response_parser.dart +++ b/app/lib/entity/webdav_response_parser.dart @@ -94,6 +94,7 @@ class WebdavResponseParser { int? fileId; bool? isFavorite; CiString? ownerId; + String? ownerDisplayName; Metadata? metadata; bool? isArchived; DateTime? overrideDateTime; @@ -131,6 +132,7 @@ class WebdavResponseParser { fileId = propParser.fileId; isFavorite = propParser.isFavorite; ownerId = propParser.ownerId; + ownerDisplayName = propParser.ownerDisplayName; metadata = propParser.metadata; isArchived = propParser.isArchived; overrideDateTime = propParser.overrideDateTime; @@ -152,6 +154,7 @@ class WebdavResponseParser { fileId: fileId, isFavorite: isFavorite, ownerId: ownerId, + ownerDisplayName: ownerDisplayName, metadata: metadata, isArchived: isArchived, overrideDateTime: overrideDateTime, @@ -338,6 +341,9 @@ class _FilePropParser { } else if (child.matchQualifiedName("owner-id", prefix: "http://owncloud.org/ns", namespaces: namespaces)) { _ownerId = child.innerText.toCi(); + } else if (child.matchQualifiedName("owner-display-name", + prefix: "http://owncloud.org/ns", namespaces: namespaces)) { + _ownerDisplayName = child.innerText; } else if (child.matchQualifiedName("trashbin-filename", prefix: "http://nextcloud.org/ns", namespaces: namespaces)) { _trashbinFilename = child.innerText; @@ -385,6 +391,7 @@ class _FilePropParser { int? get fileId => _fileId; bool? get isFavorite => _isFavorite; CiString? get ownerId => _ownerId; + String? get ownerDisplayName => _ownerDisplayName; Metadata? get metadata => _metadata; bool? get isArchived => _isArchived; DateTime? get overrideDateTime => _overrideDateTime; @@ -407,6 +414,7 @@ class _FilePropParser { int? _fileId; bool? _isFavorite; CiString? _ownerId; + String? _ownerDisplayName; Metadata? _metadata; bool? _isArchived; DateTime? _overrideDateTime; diff --git a/app/lib/widget/viewer_detail_pane.dart b/app/lib/widget/viewer_detail_pane.dart index 7c6a34a4..be6bb233 100644 --- a/app/lib/widget/viewer_detail_pane.dart +++ b/app/lib/widget/viewer_detail_pane.dart @@ -203,7 +203,8 @@ class _ViewerDetailPaneState extends State { color: AppTheme.getSecondaryTextColor(context), ), ), - title: Text(widget.file.ownerId!.toString()), + title: Text(widget.file.ownerDisplayName ?? + widget.file.ownerId!.toString()), subtitle: Text(L10n.global().fileSharedByDescription), ), if (_tags.isNotEmpty) diff --git a/app/test/test_util.dart b/app/test/test_util.dart index ad5213ac..bd9bd9c4 100644 --- a/app/test/test_util.dart +++ b/app/test/test_util.dart @@ -39,6 +39,7 @@ class FilesBuilder { bool isCollection = false, bool hasPreview = true, String ownerId = "admin", + String? ownerDisplayName, Metadata? metadata, }) { files.add(File( @@ -52,6 +53,7 @@ class FilesBuilder { hasPreview: hasPreview, fileId: fileId++, ownerId: ownerId.toCi(), + ownerDisplayName: ownerDisplayName ?? ownerId.toString(), metadata: metadata, )); } @@ -64,6 +66,7 @@ class FilesBuilder { DateTime? lastModified, bool hasPreview = true, String ownerId = "admin", + String? ownerDisplayName, }) => add( relativePath, @@ -73,6 +76,7 @@ class FilesBuilder { lastModified: lastModified, hasPreview: hasPreview, ownerId: ownerId, + ownerDisplayName: ownerDisplayName, ); void addJpeg( @@ -82,6 +86,7 @@ class FilesBuilder { DateTime? lastModified, bool hasPreview = true, String ownerId = "admin", + String? ownerDisplayName, OrNull? metadata, }) => add( @@ -92,6 +97,7 @@ class FilesBuilder { lastModified: lastModified, hasPreview: hasPreview, ownerId: ownerId, + ownerDisplayName: ownerDisplayName, metadata: metadata?.obj ?? Metadata( lastUpdated: DateTime.utc(2020, 1, 2, 3, 4, 5), @@ -106,6 +112,7 @@ class FilesBuilder { String? etag, DateTime? lastModified, String ownerId = "admin", + String? ownerDisplayName, }) => add( relativePath, @@ -114,6 +121,7 @@ class FilesBuilder { isCollection: true, hasPreview: false, ownerId: ownerId, + ownerDisplayName: ownerDisplayName, ); void addAlbumJson( @@ -123,6 +131,7 @@ class FilesBuilder { String? etag, DateTime? lastModified, String ownerId = "admin", + String? ownerDisplayName, }) => add( "$homeDir/.com.nkming.nc_photos/albums/$filename.nc_album.json", @@ -132,6 +141,7 @@ class FilesBuilder { lastModified: lastModified, hasPreview: false, ownerId: ownerId, + ownerDisplayName: ownerDisplayName, ); final files = []; @@ -302,6 +312,7 @@ File buildAlbumFile({ DateTime? lastModified, required int fileId, String ownerId = "admin", + String? ownerDisplayName, }) => File( path: path, @@ -312,6 +323,7 @@ File buildAlbumFile({ hasPreview: false, fileId: fileId, ownerId: ownerId.toCi(), + ownerDisplayName: ownerDisplayName ?? ownerId.toString(), ); String buildAlbumFilePath( @@ -341,6 +353,7 @@ File buildJpegFile({ bool hasPreview = true, required int fileId, String ownerId = "admin", + String? ownerDisplayName, }) => File( path: path, @@ -351,6 +364,7 @@ File buildJpegFile({ hasPreview: hasPreview, fileId: fileId, ownerId: ownerId.toCi(), + ownerDisplayName: ownerDisplayName ?? ownerId.toString(), ); Share buildShare({