π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Delete memory shares on account deletion
Yugiecb6f6d8ce21
diff --git a/server/cmd/museum/main.go b/server/cmd/museum/main.goindex f8b7e757bb..b1892f9b46 100644--- a/server/cmd/museum/main.go+++ b/server/cmd/museum/main.go@@ -378,6 +378,7 @@ func main() {EmailNotificationCtrl: emailNotificationCtrl,CollectionLinkRepo: collectionLinkRepo,FileLinkRepo: fileLinkRepo,+ MemoryShareRepo: memoryShareRepo,CollectionRepo: collectionRepo,UserRepo: userRepo,JwtSecret: jwtSecretBytes,diff --git a/server/pkg/controller/public/collection_link.go b/server/pkg/controller/public/collection_link.goindex 9c030e5591..842c0ef5a7 100644--- a/server/pkg/controller/public/collection_link.go+++ b/server/pkg/controller/public/collection_link.go@@ -43,6 +43,7 @@ type CollectionLinkController struct {EmailNotificationCtrl *emailCtrl.EmailNotificationControllerCollectionLinkRepo *public.CollectionLinkRepoFileLinkRepo *public.FileLinkRepository+ MemoryShareRepo *repo.MemoryShareRepositoryCollectionRepo *repo.CollectionRepositoryUserRepo *repo.UserRepositoryJwtSecret []byte@@ -212,7 +213,11 @@ func (c *CollectionLinkController) HandleAccountDeletion(ctx context.Context, usreturn stacktrace.Propagate(err, "")}}- return c.FileLinkRepo.DisableLinksForUser(ctx, userID)+ err = c.FileLinkRepo.DisableLinksForUser(ctx, userID)+ if err != nil {+ return stacktrace.Propagate(err, "")+ }+ return c.MemoryShareRepo.DeleteForUser(ctx, userID)}func (c *CollectionLinkController) GetPublicCollection(ctx *gin.Context, mustAllowCollect bool) (ente.Collection, error) {diff --git a/server/pkg/repo/memory_share.go b/server/pkg/repo/memory_share.goindex 89201a0da9..d2c733f902 100644--- a/server/pkg/repo/memory_share.go+++ b/server/pkg/repo/memory_share.go@@ -255,6 +255,14 @@ func (r *MemoryShareRepository) Delete(ctx context.Context, shareID int64, userIreturn nil}+func (r *MemoryShareRepository) DeleteForUser(ctx context.Context, userID int64) error {+ _, err := r.DB.ExecContext(ctx, `+ UPDATE memory_shares SET is_deleted = true, updated_at = $1+ WHERE user_id = $2 AND is_deleted = false`,+ time.Microseconds(), userID)+ return stacktrace.Propagate(err, "failed to delete memory shares for user")+}+func (r *MemoryShareRepository) GetFileOwnerMap(ctx context.Context, shareID int64) (map[int64]int64, error) {rows, err := r.DB.QueryContext(ctx, `SELECT file_id, file_owner_id FROM memory_share_files WHERE memory_share_id = $1`, shareID)