Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[mob][photos] Updated public_url to save shared public link data

Aman Raj Singh Mourya71e87ad2aabe
diff --git a/mobile/lib/models/api/collection/public_url.dart b/mobile/lib/models/api/collection/public_url.dart
index 6c72bda8d7..a8a31740d9 100644
--- a/mobile/lib/models/api/collection/public_url.dart
+++ b/mobile/lib/models/api/collection/public_url.dart
@@ -1,3 +1,33 @@
+class SharedPublicURL {
+ String? nonce;
+ int? opsLimit;
+ int? memLimit;
+
+ SharedPublicURL({
+ this.nonce,
+ this.opsLimit,
+ this.memLimit,
+ });
+
+ Map<String, dynamic> toMap() {
+ return {
+ 'nonce': nonce,
+ 'opsLimit': opsLimit,
+ 'memLimit': memLimit,
+ };
+ }
+
+ static SharedPublicURL? fromMap(Map<String, dynamic>? map) {
+ if (map == null) return null;
+
+ return SharedPublicURL(
+ nonce: map['nonce'],
+ opsLimit: map['opsLimit'],
+ memLimit: map['memLimit'],
+ );
+ }
+}
+
class PublicURL {
String url;
int deviceLimit;
@@ -8,6 +38,7 @@ class PublicURL {
String? nonce;
int? opsLimit;
int? memLimit;
+ SharedPublicURL? sharedPublicURL;
PublicURL({
required this.url,
@@ -19,6 +50,7 @@ class PublicURL {
this.nonce,
this.opsLimit,
this.memLimit,
+ this.sharedPublicURL,
});
Map<String, dynamic> toMap() {
@@ -32,6 +64,7 @@ class PublicURL {
'nonce': nonce,
'memLimit': memLimit,
'opsLimit': opsLimit,
+ 'sharedPublicURL': sharedPublicURL?.toMap(),
};
}
@@ -54,6 +87,7 @@ class PublicURL {
nonce: map['nonce'],
opsLimit: map['opsLimit'],
memLimit: map['memLimit'],
+ sharedPublicURL: SharedPublicURL.fromMap(map),
);
}
}
diff --git a/mobile/lib/models/collection/collection.dart b/mobile/lib/models/collection/collection.dart
index 4414c53182..40cf30b5db 100644
--- a/mobile/lib/models/collection/collection.dart
+++ b/mobile/lib/models/collection/collection.dart
@@ -137,6 +137,20 @@ class Collection {
return (owner?.id ?? 0) == userID;
}
+ bool isPublicDownload() {
+ if (publicURLs == null || publicURLs!.isEmpty) {
+ return false;
+ }
+ return publicURLs?.first?.enableDownload ?? true;
+ }
+
+ bool isEnableCollect() {
+ if (publicURLs == null || publicURLs!.isEmpty) {
+ return false;
+ }
+ return publicURLs?.first?.enableDownload ?? false;
+ }
+
CollectionParticipantRole getRole(int userID) {
if (isOwner(userID)) {
return CollectionParticipantRole.owner;