π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Refresh collection information during view
Neeraj Guptab7fa85e3eaaf
diff --git a/mobile/apps/photos/lib/ui/sharing/album_participants_page.dart b/mobile/apps/photos/lib/ui/sharing/album_participants_page.dartindex 24ab4e96c4..c6df48038d 100644--- a/mobile/apps/photos/lib/ui/sharing/album_participants_page.dart+++ b/mobile/apps/photos/lib/ui/sharing/album_participants_page.dart@@ -30,12 +30,27 @@ class AlbumParticipantsPage extends StatefulWidget {class _AlbumParticipantsPageState extends State<AlbumParticipantsPage> {late int currentUserID;+ late Collection _collection;final GlobalKey _sendLinkButtonKey = GlobalKey();@overridevoid initState() {- currentUserID = Configuration.instance.getUserID()!;super.initState();+ currentUserID = Configuration.instance.getUserID()!;+ _collection = widget.collection;+ _refreshCollection();+ }++ Future<void> _refreshCollection() async {+ try {+ final latest =+ await collectionsService.fetchCollectionByID(widget.collection.id);+ if (mounted) {+ setState(() {+ _collection = latest;+ });+ }+ } catch (_) {}}Future<void> _navigateToManageUser(User user) async {@@ -44,41 +59,37 @@ class _AlbumParticipantsPageState extends State<AlbumParticipantsPage> {}await routeToPage(context,- ManageIndividualParticipant(collection: widget.collection, user: user),+ ManageIndividualParticipant(collection: _collection, user: user),);- if (mounted) {- setState(() => {});- }+ await _refreshCollection();}Future<void> _navigateToAddUser(List<ActionTypesToShow> actions) async {await routeToPage(context,- AddParticipantPage([widget.collection], actions),+ AddParticipantPage([_collection], actions),);- if (mounted) {- setState(() => {});- }+ await _refreshCollection();}@overrideWidget build(BuildContext context) {final currentUserID = Configuration.instance.getUserID()!;- final role = widget.collection.getRole(currentUserID);+ final role = _collection.getRole(currentUserID);final bool adminRoleEnabled = flagService.enableAdminRole;final bool isOwner = role == CollectionParticipantRole.owner;final bool isAdmin = role == CollectionParticipantRole.admin;final bool canManageParticipants = isOwner || (adminRoleEnabled && isAdmin);- final bool hasActivePublicLink = widget.collection.hasLink &&- !(widget.collection.publicURLs.firstOrNull?.isExpired ?? true);+ final bool hasActivePublicLink = _collection.hasLink &&+ !(_collection.publicURLs.firstOrNull?.isExpired ?? true);final bool shouldShowPublicLink = !isOwner && hasActivePublicLink;final colorScheme = getEnteColorScheme(context);- final int participants = 1 + widget.collection.getSharees().length;- final User owner = widget.collection.owner;+ final int participants = 1 + _collection.getSharees().length;+ final User owner = _collection.owner;if (owner.id == currentUserID && owner.email == "") {owner.email = Configuration.instance.getEmail()!;}- final List<User> allSharees = widget.collection.getSharees();+ final List<User> allSharees = _collection.getSharees();final List<User> admins = [];final List<User> collaborators = [];final List<User> viewers = [];@@ -123,7 +134,7 @@ class _AlbumParticipantsPageState extends State<AlbumParticipantsPage> {slivers: <Widget>[TitleBarWidget(flexibleSpaceTitle: TitleBarTitleWidget(- title: widget.collection.displayName,+ title: _collection.displayName,),flexibleSpaceCaption: AppLocalizations.of(context,@@ -141,7 +152,7 @@ class _AlbumParticipantsPageState extends State<AlbumParticipantsPage> {iconData: Icons.public,),PublicLinkEnabledActionsWidget(- collection: widget.collection,+ collection: _collection,sendLinkButtonKey: _sendLinkButtonKey,),const SizedBox(height: 24),@@ -167,7 +178,7 @@ class _AlbumParticipantsPageState extends State<AlbumParticipantsPage> {title: isOwner? AppLocalizations.of(context).you: _nameIfAvailableElseEmail(- widget.collection.owner,+ _collection.owner,),makeTextBold: isOwner,),diff --git a/server/pkg/controller/access/collection.go b/server/pkg/controller/access/collection.goindex ecb1f8f8cb..9c6d42f9e8 100644--- a/server/pkg/controller/access/collection.go+++ b/server/pkg/controller/access/collection.go@@ -41,12 +41,7 @@ func (c controllerImpl) GetCollection(ctx *gin.Context, req *GetCollectionParamsif err != nil {return nil, stacktrace.Propagate(err, "")}- // Hide public URL info for non-collection owners- if shareeRole == nil {- return nil, stacktrace.Propagate(ente.ErrPermissionDenied, "")- }roleValue := *shareeRole- collection.PublicURLs = ente.FilterPublicURLsForRole(collection.PublicURLs, roleValue)role = roleValue} else {role = ente.OWNERdiff --git a/server/pkg/controller/collections/collection.go b/server/pkg/controller/collections/collection.goindex 5b86d38d0a..1f824fd721 100644--- a/server/pkg/controller/collections/collection.go+++ b/server/pkg/controller/collections/collection.go@@ -81,7 +81,15 @@ func (c *CollectionController) GetCollection(ctx *gin.Context, userID int64, cIDif err != nil {return ente.Collection{}, stacktrace.Propagate(err, "")}- return resp.Collection, nil+ collection, err := c.CollectionRepo.GetWithSharingDetails(cID)+ if err != nil {+ role := ente.UNKNOWN+ if resp.Role != nil {+ role = *resp.Role+ }+ collection.PublicURLs = ente.FilterPublicURLsForRole(collection.PublicURLs, role)+ }+ return collection, err}func (c *CollectionController) GetFile(ctx *gin.Context, collectionID int64, fileID int64) (*ente.File, error) {diff --git a/server/pkg/repo/collection.go b/server/pkg/repo/collection.goindex be4a02e573..2982a604d7 100644--- a/server/pkg/repo/collection.go+++ b/server/pkg/repo/collection.go@@ -88,6 +88,37 @@ func (repo *CollectionRepository) Get(collectionID int64) (ente.Collection, erro}return c, nil}++// GetWithSharingDetails returns the collection along with sharees, active public URLs, and decrypted owner email.+func (repo *CollectionRepository) GetWithSharingDetails(collectionID int64) (ente.Collection, error) {+ c, err := repo.Get(collectionID)+ if err != nil {+ return c, stacktrace.Propagate(err, "")+ }+ sharees, err := repo.GetSharees(collectionID)+ if err != nil {+ return ente.Collection{}, stacktrace.Propagate(err, "failed to get sharees info")+ }+ c.Sharees = sharees++ var encryptedEmail, nonce []byte+ err = repo.DB.QueryRow(`SELECT encrypted_email, email_decryption_nonce FROM users WHERE user_id = $1`, c.Owner.ID).+ Scan(&encryptedEmail, &nonce)+ if err != nil {+ if err == sql.ErrNoRows {+ return c, nil+ }+ return ente.Collection{}, stacktrace.Propagate(err, "failed to fetch owner email")+ }+ if len(encryptedEmail) > 0 && len(nonce) > 0 {+ email, err := crypto.Decrypt(encryptedEmail, repo.SecretEncryptionKey, nonce)+ if err != nil {+ return ente.Collection{}, stacktrace.Propagate(err, "failed to decrypt owner email")+ }+ c.Owner.Email = email+ }+ return c, nil+}func (repo *CollectionRepository) GetCollectionByType(userID int64, collectionType string) (ente.Collection, error) {row := repo.DB.QueryRow(`SELECT collection_id, owner_id, encrypted_key, key_decryption_nonce, name, encrypted_name, name_decryption_nonce, type, attributes, updation_time, is_deleted, magic_metadataFROM collections