π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Support edidting enable comment
Neeraj Guptabd1c30b94715
diff --git a/server/pkg/controller/public/collection_link.go b/server/pkg/controller/public/collection_link.goindex 3750b4e58c..2fe9033436 100644--- a/server/pkg/controller/public/collection_link.go+++ b/server/pkg/controller/public/collection_link.go@@ -50,7 +50,7 @@ func (c *CollectionLinkController) CreateLink(ctx *gin.Context, req ente.CreatePfor attempt := 0; attempt < 5; attempt++ {accessToken := strings.ToUpper(shortuuid.New()[0:AccessTokenLength])err := c.CollectionLinkRepo.- Insert(ctx, req.CollectionID, accessToken, req.ValidTill, req.DeviceLimit, req.EnableCollect, req.EnableJoin)+ Insert(ctx, req.CollectionID, accessToken, req.ValidTill, req.DeviceLimit, req.EnableCollect, req.EnableComment, req.EnableJoin)if errors.Is(err, ente.ErrAccessTokenInUse) {continue}@@ -81,6 +81,7 @@ func (c *CollectionLinkController) CreateLink(ctx *gin.Context, req ente.CreatePDeviceLimit: req.DeviceLimit,EnableDownload: true,EnableCollect: req.EnableCollect,+ EnableComment: req.EnableComment,EnableJoin: enableJoin,PasswordEnabled: false,MinRole: nil,@@ -151,6 +152,9 @@ func (c *CollectionLinkController) UpdateSharedUrl(ctx *gin.Context, req ente.Upif req.EnableCollect != nil {publicCollectionToken.EnableCollect = *req.EnableCollect}+ if req.EnableComment != nil {+ publicCollectionToken.EnableComment = *req.EnableComment+ }if req.EnableJoin != nil {publicCollectionToken.EnableJoin = *req.EnableJoin}@@ -170,6 +174,7 @@ func (c *CollectionLinkController) UpdateSharedUrl(ctx *gin.Context, req ente.UpValidTill: publicCollectionToken.ValidTill,EnableDownload: publicCollectionToken.EnableDownload,EnableCollect: publicCollectionToken.EnableCollect,+ EnableComment: publicCollectionToken.EnableComment,EnableJoin: publicCollectionToken.EnableJoin,MinRole: publicCollectionToken.MinRole,PasswordEnabled: publicCollectionToken.PassHash != nil && *publicCollectionToken.PassHash != "",@@ -231,6 +236,7 @@ func (c *CollectionLinkController) GetPublicCollection(ctx *gin.Context, mustAllpublicURLsWithLimitedInfo = append(publicURLsWithLimitedInfo, ente.PublicURL{EnableDownload: publicUrl.EnableDownload,EnableCollect: publicUrl.EnableCollect,+ EnableComment: publicUrl.EnableComment,PasswordEnabled: publicUrl.PasswordEnabled,Nonce: publicUrl.Nonce,MemLimit: publicUrl.MemLimit,diff --git a/server/pkg/repo/collection.go b/server/pkg/repo/collection.goindex ac3b782d99..b683d47597 100644--- a/server/pkg/repo/collection.go+++ b/server/pkg/repo/collection.go@@ -157,7 +157,7 @@ func (repo *CollectionRepository) GetCollectionsOwnedByUserV2(userID int64, updaSELECTc.collection_id, c.owner_id, c.encrypted_key,c.key_decryption_nonce, c.name, c.encrypted_name, c.name_decryption_nonce, c.type, c.app, c.attributes, c.updation_time, c.is_deleted, c.magic_metadata, c.pub_magic_metadata,users.user_id, users.encrypted_email, users.email_decryption_nonce, cs.role_type,-pct.access_token, pct.valid_till, pct.device_limit, pct.created_at, pct.updated_at, pct.pw_hash, pct.pw_nonce, pct.mem_limit, pct.ops_limit, pct.enable_download, pct.enable_collect, pct.enable_join, pct.min_role+pct.access_token, pct.valid_till, pct.device_limit, pct.created_at, pct.updated_at, pct.pw_hash, pct.pw_nonce, pct.mem_limit, pct.ops_limit, pct.enable_download, pct.enable_collect, pct.enable_comment, pct.enable_join, pct.min_roleFROM collections cLEFT JOIN collection_shares csON (cs.collection_id = c.collection_id AND cs.is_deleted = false)@@ -184,14 +184,14 @@ pct.access_token, pct.valid_till, pct.device_limit, pct.created_at, pct.updated_var c ente.Collectionvar name, encryptedName, nameDecryptionNonce sql.NullStringvar pctDeviceLimit sql.NullInt32- var pctEnableDownload, pctEnableCollect, pctEnableJoin sql.NullBool+ var pctEnableDownload, pctEnableCollect, pctEnableComment, pctEnableJoin sql.NullBoolvar shareUserID, pctValidTill, pctCreatedAt, pctUpdatedAt, pctMemLimit, pctOpsLimit sql.NullInt64var encryptedEmail, nonce []bytevar shareeRoleType, pctToken, pctPwHash, pctPwNonce, pctMinRole sql.NullStringif err := rows.Scan(&c.ID, &c.Owner.ID, &c.EncryptedKey, &c.KeyDecryptionNonce, &name, &encryptedName, &nameDecryptionNonce, &c.Type, &c.App, &c.Attributes, &c.UpdationTime, &c.IsDeleted, &c.MagicMetadata, &c.PublicMagicMetadata,&shareUserID, &encryptedEmail, &nonce, &shareeRoleType,- &pctToken, &pctValidTill, &pctDeviceLimit, &pctCreatedAt, &pctUpdatedAt, &pctPwHash, &pctPwNonce, &pctMemLimit, &pctOpsLimit, &pctEnableDownload, &pctEnableCollect, &pctEnableJoin, &pctMinRole); err != nil {+ &pctToken, &pctValidTill, &pctDeviceLimit, &pctCreatedAt, &pctUpdatedAt, &pctPwHash, &pctPwNonce, &pctMemLimit, &pctOpsLimit, &pctEnableDownload, &pctEnableCollect, &pctEnableComment, &pctEnableJoin, &pctMinRole); err != nil {return nil, stacktrace.Propagate(err, "")}@@ -230,6 +230,7 @@ pct.access_token, pct.valid_till, pct.device_limit, pct.created_at, pct.updated_ValidTill: pctValidTill.Int64,EnableDownload: pctEnableDownload.Bool,EnableCollect: pctEnableCollect.Bool,+ EnableComment: pctEnableComment.Bool,PasswordEnabled: pctPwNonce.Valid,EnableJoin: pctEnableJoin.Bool,}diff --git a/server/pkg/repo/public/collection_link.go b/server/pkg/repo/public/collection_link.goindex cda8afb817..c385512a35 100644--- a/server/pkg/repo/public/collection_link.go+++ b/server/pkg/repo/public/collection_link.go@@ -44,7 +44,7 @@ func (pcr *CollectionLinkRepo) GetAlbumUrl(app ente.App, token string) string {}func (pcr *CollectionLinkRepo) Insert(ctx context.Context,- cID int64, token string, validTill int64, deviceLimit int, enableCollect bool, enableJoin *bool) error {+ cID int64, token string, validTill int64, deviceLimit int, enableCollect bool, enableComment bool, enableJoin *bool) error {// default value for enableJoin is truejoin := trueif enableJoin != nil {@@ -61,8 +61,8 @@ func (pcr *CollectionLinkRepo) Insert(ctx context.Context,}_, err = tx.ExecContext(ctx, `INSERT INTO public_collection_tokens- (collection_id, access_token, valid_till, device_limit, enable_collect, enable_join) VALUES ($1, $2, $3, $4, $5, $6)`,- cID, token, validTill, deviceLimit, enableCollect, join)+ (collection_id, access_token, valid_till, device_limit, enable_collect, enable_comment, enable_join) VALUES ($1, $2, $3, $4, $5, $6, $7)`,+ cID, token, validTill, deviceLimit, enableCollect, enableComment, join)if err != nil && err.Error() == "pq: duplicate key value violates unique constraint \"public_active_collection_unique_idx\"" {return ente.ErrActiveLinkAlreadyExists}@@ -85,7 +85,7 @@ func (pcr *CollectionLinkRepo) DisableSharing(ctx context.Context, cID int64) er// GetCollectionToActivePublicURLMap will return map of collectionID to PublicURLs which are not disabled yet.// Note: The url could be expired or deviceLimit is already reachedfunc (pcr *CollectionLinkRepo) GetCollectionToActivePublicURLMap(ctx context.Context, collectionIDs []int64, app ente.App) (map[int64][]ente.PublicURL, error) {- rows, err := pcr.DB.QueryContext(ctx, `SELECT collection_id, access_token, valid_till, device_limit, enable_download, enable_collect, enable_join, min_role, pw_nonce, mem_limit, ops_limit FROM+ rows, err := pcr.DB.QueryContext(ctx, `SELECT collection_id, access_token, valid_till, device_limit, enable_download, enable_collect, enable_comment, enable_join, min_role, pw_nonce, mem_limit, ops_limit FROMpublic_collection_tokens WHERE collection_id = ANY($1) and is_disabled = FALSE`,pq.Array(collectionIDs))if err != nil {@@ -103,7 +103,7 @@ func (pcr *CollectionLinkRepo) GetCollectionToActivePublicURLMap(ctx context.Convar nonce *stringvar opsLimit, memLimit *int64var minRole sql.NullString- if err = rows.Scan(&collectionID, &accessToken, &publicUrl.ValidTill, &publicUrl.DeviceLimit, &publicUrl.EnableDownload, &publicUrl.EnableCollect, &publicUrl.EnableJoin, &minRole, &nonce, &memLimit, &opsLimit); err != nil {+ if err = rows.Scan(&collectionID, &accessToken, &publicUrl.ValidTill, &publicUrl.DeviceLimit, &publicUrl.EnableDownload, &publicUrl.EnableCollect, &publicUrl.EnableComment, &publicUrl.EnableJoin, &minRole, &nonce, &memLimit, &opsLimit); err != nil {return nil, stacktrace.Propagate(err, "")}publicUrl.URL = pcr.GetAlbumUrl(app, accessToken)@@ -127,7 +127,7 @@ func (pcr *CollectionLinkRepo) GetCollectionToActivePublicURLMap(ctx context.Con// Note: The token could be expired or deviceLimit is already reachedfunc (pcr *CollectionLinkRepo) GetActiveCollectionLinkRow(ctx context.Context, collectionID int64) (ente.CollectionLinkRow, error) {row := pcr.DB.QueryRowContext(ctx, `SELECT id, collection_id, access_token, valid_till, device_limit,- is_disabled, pw_hash, pw_nonce, mem_limit, ops_limit, enable_download, enable_collect, enable_join, min_role FROM+ is_disabled, pw_hash, pw_nonce, mem_limit, ops_limit, enable_download, enable_collect, enable_comment, enable_join, min_role FROMpublic_collection_tokens WHERE collection_id = $1 and is_disabled = FALSE`,collectionID)@@ -135,7 +135,7 @@ func (pcr *CollectionLinkRepo) GetActiveCollectionLinkRow(ctx context.Context, cret := ente.CollectionLinkRow{}var minRole sql.NullStringerr := row.Scan(&ret.ID, &ret.CollectionID, &ret.Token, &ret.ValidTill, &ret.DeviceLimit,- &ret.IsDisabled, &ret.PassHash, &ret.Nonce, &ret.MemLimit, &ret.OpsLimit, &ret.EnableDownload, &ret.EnableCollect, &ret.EnableJoin, &minRole)+ &ret.IsDisabled, &ret.PassHash, &ret.Nonce, &ret.MemLimit, &ret.OpsLimit, &ret.EnableDownload, &ret.EnableCollect, &ret.EnableComment, &ret.EnableJoin, &minRole)if err != nil {return ente.CollectionLinkRow{}, stacktrace.Propagate(err, "")}@@ -154,9 +154,9 @@ func (pcr *CollectionLinkRepo) UpdatePublicCollectionToken(ctx context.Context,minRole = string(*pct.MinRole)}_, err := pcr.DB.ExecContext(ctx, `UPDATE public_collection_tokens SET valid_till = $1, device_limit = $2,- pw_hash = $3, pw_nonce = $4, mem_limit = $5, ops_limit = $6, enable_download = $7, enable_collect = $8, enable_join = $9, min_role = $10- where id = $11`,- pct.ValidTill, pct.DeviceLimit, pct.PassHash, pct.Nonce, pct.MemLimit, pct.OpsLimit, pct.EnableDownload, pct.EnableCollect, pct.EnableJoin, minRole, pct.ID)+ pw_hash = $3, pw_nonce = $4, mem_limit = $5, ops_limit = $6, enable_download = $7, enable_collect = $8, enable_comment = $9, enable_join = $10, min_role = $11+ where id = $12`,+ pct.ValidTill, pct.DeviceLimit, pct.PassHash, pct.Nonce, pct.MemLimit, pct.OpsLimit, pct.EnableDownload, pct.EnableCollect, pct.EnableComment, pct.EnableJoin, minRole, pct.ID)return stacktrace.Propagate(err, "failed to update public collection token")}