feat: shared links custom URL (#19999)

* feat: custom url for shared links

* feat: use a separate route and query param

---------

Co-authored-by: Jason Rasmussen <jason@rasm.me>
This commit is contained in:
Jed-Giblin 2025-07-28 14:16:55 -04:00 committed by GitHub
parent 16b14b390f
commit 9b3718120b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
65 changed files with 947 additions and 432 deletions

View file

@ -21,6 +21,7 @@ class SharedLinkCreateDto {
this.expiresAt,
this.password,
this.showMetadata = true,
this.slug,
required this.type,
});
@ -44,26 +45,16 @@ class SharedLinkCreateDto {
List<String> assetIds;
///
/// 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.
///
String? description;
DateTime? expiresAt;
///
/// 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.
///
String? password;
bool showMetadata;
String? slug;
SharedLinkType type;
@override
@ -76,6 +67,7 @@ class SharedLinkCreateDto {
other.expiresAt == expiresAt &&
other.password == password &&
other.showMetadata == showMetadata &&
other.slug == slug &&
other.type == type;
@override
@ -89,10 +81,11 @@ class SharedLinkCreateDto {
(expiresAt == null ? 0 : expiresAt!.hashCode) +
(password == null ? 0 : password!.hashCode) +
(showMetadata.hashCode) +
(slug == null ? 0 : slug!.hashCode) +
(type.hashCode);
@override
String toString() => 'SharedLinkCreateDto[albumId=$albumId, allowDownload=$allowDownload, allowUpload=$allowUpload, assetIds=$assetIds, description=$description, expiresAt=$expiresAt, password=$password, showMetadata=$showMetadata, type=$type]';
String toString() => 'SharedLinkCreateDto[albumId=$albumId, allowDownload=$allowDownload, allowUpload=$allowUpload, assetIds=$assetIds, description=$description, expiresAt=$expiresAt, password=$password, showMetadata=$showMetadata, slug=$slug, type=$type]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
@ -124,6 +117,11 @@ class SharedLinkCreateDto {
// json[r'password'] = null;
}
json[r'showMetadata'] = this.showMetadata;
if (this.slug != null) {
json[r'slug'] = this.slug;
} else {
// json[r'slug'] = null;
}
json[r'type'] = this.type;
return json;
}
@ -147,6 +145,7 @@ class SharedLinkCreateDto {
expiresAt: mapDateTime(json, r'expiresAt', r''),
password: mapValueOfType<String>(json, r'password'),
showMetadata: mapValueOfType<bool>(json, r'showMetadata') ?? true,
slug: mapValueOfType<String>(json, r'slug'),
type: SharedLinkType.fromJson(json[r'type'])!,
);
}

View file

@ -20,6 +20,7 @@ class SharedLinkEditDto {
this.expiresAt,
this.password,
this.showMetadata,
this.slug,
});
///
@ -47,22 +48,10 @@ class SharedLinkEditDto {
///
bool? changeExpiryTime;
///
/// 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.
///
String? description;
DateTime? expiresAt;
///
/// 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.
///
String? password;
///
@ -73,6 +62,8 @@ class SharedLinkEditDto {
///
bool? showMetadata;
String? slug;
@override
bool operator ==(Object other) => identical(this, other) || other is SharedLinkEditDto &&
other.allowDownload == allowDownload &&
@ -81,7 +72,8 @@ class SharedLinkEditDto {
other.description == description &&
other.expiresAt == expiresAt &&
other.password == password &&
other.showMetadata == showMetadata;
other.showMetadata == showMetadata &&
other.slug == slug;
@override
int get hashCode =>
@ -92,10 +84,11 @@ class SharedLinkEditDto {
(description == null ? 0 : description!.hashCode) +
(expiresAt == null ? 0 : expiresAt!.hashCode) +
(password == null ? 0 : password!.hashCode) +
(showMetadata == null ? 0 : showMetadata!.hashCode);
(showMetadata == null ? 0 : showMetadata!.hashCode) +
(slug == null ? 0 : slug!.hashCode);
@override
String toString() => 'SharedLinkEditDto[allowDownload=$allowDownload, allowUpload=$allowUpload, changeExpiryTime=$changeExpiryTime, description=$description, expiresAt=$expiresAt, password=$password, showMetadata=$showMetadata]';
String toString() => 'SharedLinkEditDto[allowDownload=$allowDownload, allowUpload=$allowUpload, changeExpiryTime=$changeExpiryTime, description=$description, expiresAt=$expiresAt, password=$password, showMetadata=$showMetadata, slug=$slug]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
@ -134,6 +127,11 @@ class SharedLinkEditDto {
} else {
// json[r'showMetadata'] = null;
}
if (this.slug != null) {
json[r'slug'] = this.slug;
} else {
// json[r'slug'] = null;
}
return json;
}
@ -153,6 +151,7 @@ class SharedLinkEditDto {
expiresAt: mapDateTime(json, r'expiresAt', r''),
password: mapValueOfType<String>(json, r'password'),
showMetadata: mapValueOfType<bool>(json, r'showMetadata'),
slug: mapValueOfType<String>(json, r'slug'),
);
}
return null;

View file

@ -24,6 +24,7 @@ class SharedLinkResponseDto {
required this.key,
required this.password,
required this.showMetadata,
required this.slug,
this.token,
required this.type,
required this.userId,
@ -57,6 +58,8 @@ class SharedLinkResponseDto {
bool showMetadata;
String? slug;
String? token;
SharedLinkType type;
@ -76,6 +79,7 @@ class SharedLinkResponseDto {
other.key == key &&
other.password == password &&
other.showMetadata == showMetadata &&
other.slug == slug &&
other.token == token &&
other.type == type &&
other.userId == userId;
@ -94,12 +98,13 @@ class SharedLinkResponseDto {
(key.hashCode) +
(password == null ? 0 : password!.hashCode) +
(showMetadata.hashCode) +
(slug == null ? 0 : slug!.hashCode) +
(token == null ? 0 : token!.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, password=$password, showMetadata=$showMetadata, token=$token, 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, password=$password, showMetadata=$showMetadata, slug=$slug, token=$token, type=$type, userId=$userId]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
@ -130,6 +135,11 @@ class SharedLinkResponseDto {
// json[r'password'] = null;
}
json[r'showMetadata'] = this.showMetadata;
if (this.slug != null) {
json[r'slug'] = this.slug;
} else {
// json[r'slug'] = null;
}
if (this.token != null) {
json[r'token'] = this.token;
} else {
@ -160,6 +170,7 @@ class SharedLinkResponseDto {
key: mapValueOfType<String>(json, r'key')!,
password: mapValueOfType<String>(json, r'password'),
showMetadata: mapValueOfType<bool>(json, r'showMetadata')!,
slug: mapValueOfType<String>(json, r'slug'),
token: mapValueOfType<String>(json, r'token'),
type: SharedLinkType.fromJson(json[r'type'])!,
userId: mapValueOfType<String>(json, r'userId')!,
@ -220,6 +231,7 @@ class SharedLinkResponseDto {
'key',
'password',
'showMetadata',
'slug',
'type',
'userId',
};