1
0
mirror of https://github.com/immich-app/immich.git synced 2025-07-15 07:14:42 +02:00

feat(web/server) Add more options to public shared link (#1348)

* Added migration files

* Added logic for shared album level

* Added permission for EXIF

* Update shared link response dto

* Added condition to show download button

* Create and edit link with new parameter:

* Remove deadcode

* PR feedback

* More refactor

* Move logic of allow original file to service

* Simplify

* Wording
This commit is contained in:
Alex
2023-01-21 22:15:16 -06:00
committed by GitHub
parent 4cfac47674
commit b07891089f
41 changed files with 520 additions and 73 deletions

View File

@ -16,6 +16,8 @@ class CreateAlbumShareLinkDto {
required this.albumId,
this.expiredAt,
this.allowUpload,
this.allowDownload,
this.showExif,
this.description,
});
@ -37,6 +39,22 @@ class CreateAlbumShareLinkDto {
///
bool? allowUpload;
///
/// Please note: This property should have been non-nullable! Since the specification file
/// does not include a default value (using the "default:" property), however, the generated
/// source code must fall back to having a nullable type.
/// Consider adding a "default:" property in the specification file to hide this note.
///
bool? allowDownload;
///
/// Please note: This property should have been non-nullable! Since the specification file
/// does not include a default value (using the "default:" property), however, the generated
/// 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;
///
/// Please note: This property should have been non-nullable! Since the specification file
/// does not include a default value (using the "default:" property), however, the generated
@ -50,6 +68,8 @@ class CreateAlbumShareLinkDto {
other.albumId == albumId &&
other.expiredAt == expiredAt &&
other.allowUpload == allowUpload &&
other.allowDownload == allowDownload &&
other.showExif == showExif &&
other.description == description;
@override
@ -58,10 +78,12 @@ class CreateAlbumShareLinkDto {
(albumId.hashCode) +
(expiredAt == null ? 0 : expiredAt!.hashCode) +
(allowUpload == null ? 0 : allowUpload!.hashCode) +
(allowDownload == null ? 0 : allowDownload!.hashCode) +
(showExif == null ? 0 : showExif!.hashCode) +
(description == null ? 0 : description!.hashCode);
@override
String toString() => 'CreateAlbumShareLinkDto[albumId=$albumId, expiredAt=$expiredAt, allowUpload=$allowUpload, description=$description]';
String toString() => 'CreateAlbumShareLinkDto[albumId=$albumId, expiredAt=$expiredAt, allowUpload=$allowUpload, allowDownload=$allowDownload, showExif=$showExif, description=$description]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
@ -76,6 +98,16 @@ class CreateAlbumShareLinkDto {
} else {
// json[r'allowUpload'] = null;
}
if (this.allowDownload != null) {
json[r'allowDownload'] = this.allowDownload;
} else {
// json[r'allowDownload'] = null;
}
if (this.showExif != null) {
json[r'showExif'] = this.showExif;
} else {
// json[r'showExif'] = null;
}
if (this.description != null) {
json[r'description'] = this.description;
} else {
@ -106,6 +138,8 @@ class CreateAlbumShareLinkDto {
albumId: mapValueOfType<String>(json, r'albumId')!,
expiredAt: mapValueOfType<String>(json, r'expiredAt'),
allowUpload: mapValueOfType<bool>(json, r'allowUpload'),
allowDownload: mapValueOfType<bool>(json, r'allowDownload'),
showExif: mapValueOfType<bool>(json, r'showExif'),
description: mapValueOfType<String>(json, r'description'),
);
}

View File

@ -16,6 +16,8 @@ class CreateAssetsShareLinkDto {
this.assetIds = const [],
this.expiredAt,
this.allowUpload,
this.allowDownload,
this.showExif,
this.description,
});
@ -37,6 +39,22 @@ class CreateAssetsShareLinkDto {
///
bool? allowUpload;
///
/// Please note: This property should have been non-nullable! Since the specification file
/// does not include a default value (using the "default:" property), however, the generated
/// source code must fall back to having a nullable type.
/// Consider adding a "default:" property in the specification file to hide this note.
///
bool? allowDownload;
///
/// Please note: This property should have been non-nullable! Since the specification file
/// does not include a default value (using the "default:" property), however, the generated
/// 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;
///
/// Please note: This property should have been non-nullable! Since the specification file
/// does not include a default value (using the "default:" property), however, the generated
@ -50,6 +68,8 @@ class CreateAssetsShareLinkDto {
other.assetIds == assetIds &&
other.expiredAt == expiredAt &&
other.allowUpload == allowUpload &&
other.allowDownload == allowDownload &&
other.showExif == showExif &&
other.description == description;
@override
@ -58,10 +78,12 @@ class CreateAssetsShareLinkDto {
(assetIds.hashCode) +
(expiredAt == null ? 0 : expiredAt!.hashCode) +
(allowUpload == null ? 0 : allowUpload!.hashCode) +
(allowDownload == null ? 0 : allowDownload!.hashCode) +
(showExif == null ? 0 : showExif!.hashCode) +
(description == null ? 0 : description!.hashCode);
@override
String toString() => 'CreateAssetsShareLinkDto[assetIds=$assetIds, expiredAt=$expiredAt, allowUpload=$allowUpload, description=$description]';
String toString() => 'CreateAssetsShareLinkDto[assetIds=$assetIds, expiredAt=$expiredAt, allowUpload=$allowUpload, allowDownload=$allowDownload, showExif=$showExif, description=$description]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
@ -76,6 +98,16 @@ class CreateAssetsShareLinkDto {
} else {
// json[r'allowUpload'] = null;
}
if (this.allowDownload != null) {
json[r'allowDownload'] = this.allowDownload;
} else {
// json[r'allowDownload'] = null;
}
if (this.showExif != null) {
json[r'showExif'] = this.showExif;
} else {
// json[r'showExif'] = null;
}
if (this.description != null) {
json[r'description'] = this.description;
} else {
@ -108,6 +140,8 @@ class CreateAssetsShareLinkDto {
: const [],
expiredAt: mapValueOfType<String>(json, r'expiredAt'),
allowUpload: mapValueOfType<bool>(json, r'allowUpload'),
allowDownload: mapValueOfType<bool>(json, r'allowDownload'),
showExif: mapValueOfType<bool>(json, r'showExif'),
description: mapValueOfType<String>(json, r'description'),
);
}

View File

@ -16,6 +16,8 @@ class EditSharedLinkDto {
this.description,
this.expiredAt,
this.allowUpload,
this.allowDownload,
this.showExif,
this.isEditExpireTime,
});
@ -43,6 +45,22 @@ class EditSharedLinkDto {
///
bool? allowUpload;
///
/// Please note: This property should have been non-nullable! Since the specification file
/// does not include a default value (using the "default:" property), however, the generated
/// source code must fall back to having a nullable type.
/// Consider adding a "default:" property in the specification file to hide this note.
///
bool? allowDownload;
///
/// Please note: This property should have been non-nullable! Since the specification file
/// does not include a default value (using the "default:" property), however, the generated
/// 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;
///
/// Please note: This property should have been non-nullable! Since the specification file
/// does not include a default value (using the "default:" property), however, the generated
@ -56,6 +74,8 @@ class EditSharedLinkDto {
other.description == description &&
other.expiredAt == expiredAt &&
other.allowUpload == allowUpload &&
other.allowDownload == allowDownload &&
other.showExif == showExif &&
other.isEditExpireTime == isEditExpireTime;
@override
@ -64,10 +84,12 @@ class EditSharedLinkDto {
(description == null ? 0 : description!.hashCode) +
(expiredAt == null ? 0 : expiredAt!.hashCode) +
(allowUpload == null ? 0 : allowUpload!.hashCode) +
(allowDownload == null ? 0 : allowDownload!.hashCode) +
(showExif == null ? 0 : showExif!.hashCode) +
(isEditExpireTime == null ? 0 : isEditExpireTime!.hashCode);
@override
String toString() => 'EditSharedLinkDto[description=$description, expiredAt=$expiredAt, allowUpload=$allowUpload, isEditExpireTime=$isEditExpireTime]';
String toString() => 'EditSharedLinkDto[description=$description, expiredAt=$expiredAt, allowUpload=$allowUpload, allowDownload=$allowDownload, showExif=$showExif, isEditExpireTime=$isEditExpireTime]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
@ -86,6 +108,16 @@ class EditSharedLinkDto {
} else {
// json[r'allowUpload'] = null;
}
if (this.allowDownload != null) {
json[r'allowDownload'] = this.allowDownload;
} else {
// json[r'allowDownload'] = null;
}
if (this.showExif != null) {
json[r'showExif'] = this.showExif;
} else {
// json[r'showExif'] = null;
}
if (this.isEditExpireTime != null) {
json[r'isEditExpireTime'] = this.isEditExpireTime;
} else {
@ -116,6 +148,8 @@ class EditSharedLinkDto {
description: mapValueOfType<String>(json, r'description'),
expiredAt: mapValueOfType<String>(json, r'expiredAt'),
allowUpload: mapValueOfType<bool>(json, r'allowUpload'),
allowDownload: mapValueOfType<bool>(json, r'allowDownload'),
showExif: mapValueOfType<bool>(json, r'showExif'),
isEditExpireTime: mapValueOfType<bool>(json, r'isEditExpireTime'),
);
}

View File

@ -23,6 +23,8 @@ class SharedLinkResponseDto {
this.assets = const [],
this.album,
required this.allowUpload,
required this.allowDownload,
required this.showExif,
});
SharedLinkType type;
@ -57,6 +59,10 @@ class SharedLinkResponseDto {
bool allowUpload;
bool allowDownload;
bool showExif;
@override
bool operator ==(Object other) => identical(this, other) || other is SharedLinkResponseDto &&
other.type == type &&
@ -68,7 +74,9 @@ class SharedLinkResponseDto {
other.expiresAt == expiresAt &&
other.assets == assets &&
other.album == album &&
other.allowUpload == allowUpload;
other.allowUpload == allowUpload &&
other.allowDownload == allowDownload &&
other.showExif == showExif;
@override
int get hashCode =>
@ -82,10 +90,12 @@ class SharedLinkResponseDto {
(expiresAt == null ? 0 : expiresAt!.hashCode) +
(assets.hashCode) +
(album == null ? 0 : album!.hashCode) +
(allowUpload.hashCode);
(allowUpload.hashCode) +
(allowDownload.hashCode) +
(showExif.hashCode);
@override
String toString() => 'SharedLinkResponseDto[type=$type, id=$id, description=$description, userId=$userId, key=$key, createdAt=$createdAt, expiresAt=$expiresAt, assets=$assets, album=$album, allowUpload=$allowUpload]';
String toString() => 'SharedLinkResponseDto[type=$type, id=$id, description=$description, userId=$userId, key=$key, createdAt=$createdAt, expiresAt=$expiresAt, assets=$assets, album=$album, allowUpload=$allowUpload, allowDownload=$allowDownload, showExif=$showExif]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
@ -111,6 +121,8 @@ class SharedLinkResponseDto {
// json[r'album'] = null;
}
json[r'allowUpload'] = this.allowUpload;
json[r'allowDownload'] = this.allowDownload;
json[r'showExif'] = this.showExif;
return json;
}
@ -143,6 +155,8 @@ class SharedLinkResponseDto {
assets: AssetResponseDto.listFromJson(json[r'assets'])!,
album: AlbumResponseDto.fromJson(json[r'album']),
allowUpload: mapValueOfType<bool>(json, r'allowUpload')!,
allowDownload: mapValueOfType<bool>(json, r'allowDownload')!,
showExif: mapValueOfType<bool>(json, r'showExif')!,
);
}
return null;
@ -200,6 +214,8 @@ class SharedLinkResponseDto {
'expiresAt',
'assets',
'allowUpload',
'allowDownload',
'showExif',
};
}