fix(server,web): correctly remove metadata from shared links (#4464)

* wip: strip metadata

* fix: authenticate time buckets

* hide detail panel

* fix tests

* fix lint

* add e2e tests

* chore: open api

* fix web compilation error

* feat: test with asset with gps position

* fix: only import fs.promises.cp

* fix: cleanup mapasset

* fix: format

---------

Co-authored-by: Alex Tran <alex.tran1502@gmail.com>
This commit is contained in:
Jonathan Jogenfors
2023-10-14 03:46:30 +02:00
committed by GitHub
parent 4a9f58bf9b
commit dadcf49eca
39 changed files with 332 additions and 150 deletions

View File

@@ -20,6 +20,7 @@ class AssetResponseDto {
this.exifInfo,
required this.fileCreatedAt,
required this.fileModifiedAt,
required this.hasMetadata,
required this.id,
required this.isArchived,
required this.isExternal,
@@ -64,6 +65,8 @@ class AssetResponseDto {
DateTime fileModifiedAt;
bool hasMetadata;
String id;
bool isArchived;
@@ -112,7 +115,6 @@ class AssetResponseDto {
List<TagResponseDto> tags;
/// base64 encoded thumbhash
String? thumbhash;
AssetTypeEnum type;
@@ -128,6 +130,7 @@ class AssetResponseDto {
other.exifInfo == exifInfo &&
other.fileCreatedAt == fileCreatedAt &&
other.fileModifiedAt == fileModifiedAt &&
other.hasMetadata == hasMetadata &&
other.id == id &&
other.isArchived == isArchived &&
other.isExternal == isExternal &&
@@ -160,6 +163,7 @@ class AssetResponseDto {
(exifInfo == null ? 0 : exifInfo!.hashCode) +
(fileCreatedAt.hashCode) +
(fileModifiedAt.hashCode) +
(hasMetadata.hashCode) +
(id.hashCode) +
(isArchived.hashCode) +
(isExternal.hashCode) +
@@ -183,7 +187,7 @@ class AssetResponseDto {
(updatedAt.hashCode);
@override
String toString() => 'AssetResponseDto[checksum=$checksum, deviceAssetId=$deviceAssetId, deviceId=$deviceId, duration=$duration, exifInfo=$exifInfo, fileCreatedAt=$fileCreatedAt, fileModifiedAt=$fileModifiedAt, id=$id, isArchived=$isArchived, isExternal=$isExternal, isFavorite=$isFavorite, isOffline=$isOffline, isReadOnly=$isReadOnly, isTrashed=$isTrashed, libraryId=$libraryId, livePhotoVideoId=$livePhotoVideoId, localDateTime=$localDateTime, originalFileName=$originalFileName, originalPath=$originalPath, owner=$owner, ownerId=$ownerId, people=$people, resized=$resized, smartInfo=$smartInfo, tags=$tags, thumbhash=$thumbhash, type=$type, updatedAt=$updatedAt]';
String toString() => 'AssetResponseDto[checksum=$checksum, deviceAssetId=$deviceAssetId, deviceId=$deviceId, duration=$duration, exifInfo=$exifInfo, fileCreatedAt=$fileCreatedAt, fileModifiedAt=$fileModifiedAt, hasMetadata=$hasMetadata, id=$id, isArchived=$isArchived, isExternal=$isExternal, isFavorite=$isFavorite, isOffline=$isOffline, isReadOnly=$isReadOnly, isTrashed=$isTrashed, libraryId=$libraryId, livePhotoVideoId=$livePhotoVideoId, localDateTime=$localDateTime, originalFileName=$originalFileName, originalPath=$originalPath, owner=$owner, ownerId=$ownerId, people=$people, resized=$resized, smartInfo=$smartInfo, tags=$tags, thumbhash=$thumbhash, type=$type, updatedAt=$updatedAt]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
@@ -198,6 +202,7 @@ class AssetResponseDto {
}
json[r'fileCreatedAt'] = this.fileCreatedAt.toUtc().toIso8601String();
json[r'fileModifiedAt'] = this.fileModifiedAt.toUtc().toIso8601String();
json[r'hasMetadata'] = this.hasMetadata;
json[r'id'] = this.id;
json[r'isArchived'] = this.isArchived;
json[r'isExternal'] = this.isExternal;
@@ -253,6 +258,7 @@ class AssetResponseDto {
exifInfo: ExifResponseDto.fromJson(json[r'exifInfo']),
fileCreatedAt: mapDateTime(json, r'fileCreatedAt', '')!,
fileModifiedAt: mapDateTime(json, r'fileModifiedAt', '')!,
hasMetadata: mapValueOfType<bool>(json, r'hasMetadata')!,
id: mapValueOfType<String>(json, r'id')!,
isArchived: mapValueOfType<bool>(json, r'isArchived')!,
isExternal: mapValueOfType<bool>(json, r'isExternal')!,
@@ -327,6 +333,7 @@ class AssetResponseDto {
'duration',
'fileCreatedAt',
'fileModifiedAt',
'hasMetadata',
'id',
'isArchived',
'isExternal',

View File

@@ -19,7 +19,7 @@ class SharedLinkCreateDto {
this.assetIds = const [],
this.description,
this.expiresAt,
this.showExif = true,
this.showMetadata = true,
required this.type,
});
@@ -47,7 +47,7 @@ class SharedLinkCreateDto {
DateTime? expiresAt;
bool showExif;
bool showMetadata;
SharedLinkType type;
@@ -59,7 +59,7 @@ class SharedLinkCreateDto {
other.assetIds == assetIds &&
other.description == description &&
other.expiresAt == expiresAt &&
other.showExif == showExif &&
other.showMetadata == showMetadata &&
other.type == type;
@override
@@ -71,11 +71,11 @@ class SharedLinkCreateDto {
(assetIds.hashCode) +
(description == null ? 0 : description!.hashCode) +
(expiresAt == null ? 0 : expiresAt!.hashCode) +
(showExif.hashCode) +
(showMetadata.hashCode) +
(type.hashCode);
@override
String toString() => 'SharedLinkCreateDto[albumId=$albumId, allowDownload=$allowDownload, allowUpload=$allowUpload, assetIds=$assetIds, description=$description, expiresAt=$expiresAt, showExif=$showExif, type=$type]';
String toString() => 'SharedLinkCreateDto[albumId=$albumId, allowDownload=$allowDownload, allowUpload=$allowUpload, assetIds=$assetIds, description=$description, expiresAt=$expiresAt, showMetadata=$showMetadata, type=$type]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
@@ -97,7 +97,7 @@ class SharedLinkCreateDto {
} else {
// json[r'expiresAt'] = null;
}
json[r'showExif'] = this.showExif;
json[r'showMetadata'] = this.showMetadata;
json[r'type'] = this.type;
return json;
}
@@ -118,7 +118,7 @@ class SharedLinkCreateDto {
: const [],
description: mapValueOfType<String>(json, r'description'),
expiresAt: mapDateTime(json, r'expiresAt', ''),
showExif: mapValueOfType<bool>(json, r'showExif') ?? true,
showMetadata: mapValueOfType<bool>(json, r'showMetadata') ?? true,
type: SharedLinkType.fromJson(json[r'type'])!,
);
}

View File

@@ -17,7 +17,7 @@ class SharedLinkEditDto {
this.allowUpload,
this.description,
this.expiresAt,
this.showExif,
this.showMetadata,
});
///
@@ -52,7 +52,7 @@ class SharedLinkEditDto {
/// source code must fall back to having a nullable type.
/// Consider adding a "default:" property in the specification file to hide this note.
///
bool? showExif;
bool? showMetadata;
@override
bool operator ==(Object other) => identical(this, other) || other is SharedLinkEditDto &&
@@ -60,7 +60,7 @@ class SharedLinkEditDto {
other.allowUpload == allowUpload &&
other.description == description &&
other.expiresAt == expiresAt &&
other.showExif == showExif;
other.showMetadata == showMetadata;
@override
int get hashCode =>
@@ -69,10 +69,10 @@ class SharedLinkEditDto {
(allowUpload == null ? 0 : allowUpload!.hashCode) +
(description == null ? 0 : description!.hashCode) +
(expiresAt == null ? 0 : expiresAt!.hashCode) +
(showExif == null ? 0 : showExif!.hashCode);
(showMetadata == null ? 0 : showMetadata!.hashCode);
@override
String toString() => 'SharedLinkEditDto[allowDownload=$allowDownload, allowUpload=$allowUpload, description=$description, expiresAt=$expiresAt, showExif=$showExif]';
String toString() => 'SharedLinkEditDto[allowDownload=$allowDownload, allowUpload=$allowUpload, description=$description, expiresAt=$expiresAt, showMetadata=$showMetadata]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
@@ -96,10 +96,10 @@ class SharedLinkEditDto {
} else {
// json[r'expiresAt'] = null;
}
if (this.showExif != null) {
json[r'showExif'] = this.showExif;
if (this.showMetadata != null) {
json[r'showMetadata'] = this.showMetadata;
} else {
// json[r'showExif'] = null;
// json[r'showMetadata'] = null;
}
return json;
}
@@ -116,7 +116,7 @@ class SharedLinkEditDto {
allowUpload: mapValueOfType<bool>(json, r'allowUpload'),
description: mapValueOfType<String>(json, r'description'),
expiresAt: mapDateTime(json, r'expiresAt', ''),
showExif: mapValueOfType<bool>(json, r'showExif'),
showMetadata: mapValueOfType<bool>(json, r'showMetadata'),
);
}
return null;

View File

@@ -22,7 +22,7 @@ class SharedLinkResponseDto {
required this.expiresAt,
required this.id,
required this.key,
required this.showExif,
required this.showMetadata,
required this.type,
required this.userId,
});
@@ -51,7 +51,7 @@ class SharedLinkResponseDto {
String key;
bool showExif;
bool showMetadata;
SharedLinkType type;
@@ -68,7 +68,7 @@ class SharedLinkResponseDto {
other.expiresAt == expiresAt &&
other.id == id &&
other.key == key &&
other.showExif == showExif &&
other.showMetadata == showMetadata &&
other.type == type &&
other.userId == userId;
@@ -84,12 +84,12 @@ class SharedLinkResponseDto {
(expiresAt == null ? 0 : expiresAt!.hashCode) +
(id.hashCode) +
(key.hashCode) +
(showExif.hashCode) +
(showMetadata.hashCode) +
(type.hashCode) +
(userId.hashCode);
@override
String toString() => 'SharedLinkResponseDto[album=$album, allowDownload=$allowDownload, allowUpload=$allowUpload, assets=$assets, createdAt=$createdAt, description=$description, expiresAt=$expiresAt, id=$id, key=$key, showExif=$showExif, type=$type, userId=$userId]';
String toString() => 'SharedLinkResponseDto[album=$album, allowDownload=$allowDownload, allowUpload=$allowUpload, assets=$assets, createdAt=$createdAt, description=$description, expiresAt=$expiresAt, id=$id, key=$key, showMetadata=$showMetadata, type=$type, userId=$userId]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
@@ -114,7 +114,7 @@ class SharedLinkResponseDto {
}
json[r'id'] = this.id;
json[r'key'] = this.key;
json[r'showExif'] = this.showExif;
json[r'showMetadata'] = this.showMetadata;
json[r'type'] = this.type;
json[r'userId'] = this.userId;
return json;
@@ -137,7 +137,7 @@ class SharedLinkResponseDto {
expiresAt: mapDateTime(json, r'expiresAt', ''),
id: mapValueOfType<String>(json, r'id')!,
key: mapValueOfType<String>(json, r'key')!,
showExif: mapValueOfType<bool>(json, r'showExif')!,
showMetadata: mapValueOfType<bool>(json, r'showMetadata')!,
type: SharedLinkType.fromJson(json[r'type'])!,
userId: mapValueOfType<String>(json, r'userId')!,
);
@@ -195,7 +195,7 @@ class SharedLinkResponseDto {
'expiresAt',
'id',
'key',
'showExif',
'showMetadata',
'type',
'userId',
};