💚 End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Prune server utility comments
Manav Rathieb92d5ef0afc
diff --git a/server/cmd/museum/main.go b/server/cmd/museum/main.goindex d5a4b61ab0..1a19414d34 100644--- a/server/cmd/museum/main.go+++ b/server/cmd/museum/main.go@@ -415,7 +415,6 @@ func main() {ReactionsRepo: reactionsRepo,}- // Pending actions' controller/handlercollectionActionsController := &controller.CollectionActionsController{Repo: collectionActionRepo,}@@ -741,7 +740,6 @@ func main() {Controller: collectionController,}storageAPI.POST("/collections", collectionHandler.Create)- // Collection actions (exposed for clients to fetch suggestions/removals)storageAPI.GET("/collection-actions/pending-remove", collectionActionsHandler.ListPendingRemove)storageAPI.GET("/collection-actions/delete-suggestions", collectionActionsHandler.ListDeleteSuggestions)storageAPI.POST("/collection-actions/reject-delete-suggestions", collectionActionsHandler.RejectDeleteSuggestions)@@ -1103,10 +1101,8 @@ func main() {trashController, pushController, objectController, dataCleanupController, storageBonusCtrl, emergencyCtrl,embeddingController, healthCheckHandler, castDb, inactiveUserOrchestrator, spaceDripController)- // Create new collectors, the names will be used as labels on the metricsprimaryDBCollector := sqlstats.NewStatsCollector("prod_db", db)latencySensitiveDBCollector := sqlstats.NewStatsCollector("latency_sensitive_db", latencySensitiveDB)- // Register them with Prometheusprometheus.MustRegister(primaryDBCollector, latencySensitiveDBCollector)http.Handle("/metrics", promhttp.Handler())@@ -1319,8 +1315,7 @@ func setupAndStartCrons(userAuthRepo *repo.UserAuthRepository, collectionLinkRepschedule(c, "@every 1m", func() {_ = twoFactorRepo.RemoveExpiredTwoFactorSessions()- // Clean up used OTP codes older than 90 seconds- _ = twoFactorRepo.RemoveExpiredUsedOTPCodes(90 * 1000 * 1000) // 90 seconds in microseconds+ _ = twoFactorRepo.RemoveExpiredUsedOTPCodes(90 * 1000 * 1000)})schedule(c, "@every 1m", func() {_ = twoFactorRepo.RemoveExpiredTempTwoFactorSecrets()@@ -1378,7 +1373,6 @@ func setupAndStartCrons(userAuthRepo *repo.UserAuthRepository, collectionLinkRep})schedule(c, "@every 45m", func() {- // delete unclaimed codes older than 60 minutes_ = castDb.DeleteUnclaimedCodes(context.Background(), timeUtil.MicrosecondsBeforeMinutes(60))dataCleanupCtrl.DeleteDataCron()})@@ -1495,12 +1489,10 @@ func setKnownAPIs(routes []gin.RouteInfo) {}}-// Schedule a cron jobfunc schedule(c *cron.Cron, spec string, cmd func()) (cron.EntryID, error) {return c.AddFunc(spec, cmd)}-// Schedule a cron job, and run it once immediately too.func scheduleAndRun(c *cron.Cron, spec string, cmd func()) (cron.EntryID, error) {go cmd()return schedule(c, spec, cmd)diff --git a/server/ente/collection.go b/server/ente/collection.goindex 4846549696..0ccb04eaff 100644--- a/server/ente/collection.go+++ b/server/ente/collection.go@@ -165,7 +165,6 @@ type RemoveFilesRequest struct {FileIDs []int64 `json:"fileIDs"`}-// RemoveFilesV3Request represents request payload for v3 version of removing files from collection// In V3, only those files are allowed to be removed from collection which don't belong to the collection owner.// If collection owner wants to remove files owned by them, the client should move those files to other collections// owned by the collection user. Also, See [Collection Delete Versions] for additional context.@@ -175,7 +174,6 @@ type RemoveFilesV3Request struct {FileIDs []int64 `json:"fileIDs" binding:"required"`}-// SuggestDeleteRequest represents a request to suggest deletion of files in a shared collection.// Only collection owner or admins can suggest deletion for files owned by others (not the acting user).type SuggestDeleteRequest struct {CollectionID int64 `json:"collectionID" binding:"required"`diff --git a/server/ente/embedding.go b/server/ente/embedding.goindex 44d276f023..667e232b5f 100644--- a/server/ente/embedding.go+++ b/server/ente/embedding.go@@ -51,13 +51,9 @@ type GetFilesEmbeddingResponse struct {type Model stringconst (- OnnxClip Model = "onnx-clip"- GgmlClip Model = "ggml-clip"-- // Derived inference from a file, including metadata are stored as this type- Derived = "derived"-- // FileMlClipFace is a model for face embeddings, it is used in request validation.+ OnnxClip Model = "onnx-clip"+ GgmlClip Model = "ggml-clip"+ Derived = "derived"FileMlClipFace Model = "file-ml-clip-face")diff --git a/server/ente/file.go b/server/ente/file.goindex b80cc75cb9..2d2f5e054a 100644--- a/server/ente/file.go+++ b/server/ente/file.go@@ -106,10 +106,8 @@ type MagicMetadata struct {Version int `json:"version,omitempty" binding:"required"`// Count indicates number of keys in the json presentation of magic attributes.// On edit/update, this number should be >= previous version.- Count int `json:"count,omitempty" binding:"required"`- // Data represents the encrypted blob for jsonEncoded attributes using file key.- Data string `json:"data,omitempty" binding:"required"`- // Header used for decrypting the encrypted attr on the client.+ Count int `json:"count,omitempty" binding:"required"`+ Data string `json:"data,omitempty" binding:"required"`Header string `json:"header,omitempty" binding:"required"`}diff --git a/server/ente/jwt/jwt.go b/server/ente/jwt/jwt.goindex adbae41472..73c2e2a149 100644--- a/server/ente/jwt/jwt.go+++ b/server/ente/jwt/jwt.go@@ -43,7 +43,6 @@ func (w WebCommonJWTClaim) Valid() error {return nil}-// LinkPasswordClaim refer to token granted post link password verificationtype LinkPasswordClaim struct {PassHash string `json:"passKey"`ExpiryTime int64 `json:"expiryTime"`@@ -56,7 +55,6 @@ func (c LinkPasswordClaim) Valid() error {return nil}-// PasteGuardClaim gates one-time paste consumption.type PasteGuardClaim struct {AccessToken string `json:"accessToken"`UserAgentHash string `json:"userAgentHash"`diff --git a/server/ente/storagebonus/errors.go b/server/ente/storagebonus/errors.goindex 30e689eb18..e06780ff40 100644--- a/server/ente/storagebonus/errors.go+++ b/server/ente/storagebonus/errors.go@@ -13,7 +13,6 @@ const (accountNotEligible ente.ErrorCode = "ACCOUNT_NOT_ELIGIBLE")-// InvalidCodeErr is thrown when user gives a code which either doesn't exist or belong to a now deleted uservar InvalidCodeErr = &ente.ApiError{Code: invalid,Message: "Invalid code",diff --git a/server/ente/trash.go b/server/ente/trash.goindex 437d075f82..e92096a6a2 100644--- a/server/ente/trash.go+++ b/server/ente/trash.go@@ -22,7 +22,6 @@ type EmptyTrashRequest struct {LastUpdatedAt int64 `json:"lastUpdatedAt" binding:"required"`}-// TrashCollectionV3Request represents the request for trashing/deleting a collection.// In V3, while trashing/deleting any album, the user can decide to either keep or delete the all files which are// present in to the trash. When user wants to keep the files, the clients are expected to move all the files from// the underlying collection to any other collection owned by the user, inlcuding uncategorized.diff --git a/server/ente/user.go b/server/ente/user.goindex ded0712a55..da33bd3c30 100644--- a/server/ente/user.go+++ b/server/ente/user.go@@ -49,14 +49,13 @@ type EmailVerificationResponse struct {// EmailAuthorizationResponse represents the response after user has verified his email,// if two factor enabled just `TwoFactorSessionID` is sent else the keyAttributes and encryptedTokentype EmailAuthorizationResponse struct {- ID int64 `json:"id"`- KeyAttributes *KeyAttributes `json:"keyAttributes,omitempty"`- EncryptedToken string `json:"encryptedToken,omitempty"`- Token string `json:"token,omitempty"`- PasskeySessionID string `json:"passkeySessionID"`- // AccountsUrl is the url used for passkey validation- AccountsUrl string `json:"accountsUrl"`- TwoFactorSessionID string `json:"twoFactorSessionID"`+ ID int64 `json:"id"`+ KeyAttributes *KeyAttributes `json:"keyAttributes,omitempty"`+ EncryptedToken string `json:"encryptedToken,omitempty"`+ Token string `json:"token,omitempty"`+ PasskeySessionID string `json:"passkeySessionID"`+ AccountsUrl string `json:"accountsUrl"`+ TwoFactorSessionID string `json:"twoFactorSessionID"`// TwoFactorSessionIDV2 is set only if user has both passkey and two factor enabled.// This is to ensure older clients keep using passkey flow when both are set. We can remove// This field once the clients starts surface both options for performing 2fadiff --git a/server/pkg/api/billing.go b/server/pkg/api/billing.goindex 5aa71adf1b..1c5127d73d 100644--- a/server/pkg/api/billing.go+++ b/server/pkg/api/billing.go@@ -85,7 +85,6 @@ func (h *BillingHandler) GetStripeAccountCountry(c *gin.Context) {// Deprecated:// GetUsage returns the storage usage for the requesting userfunc (h *BillingHandler) GetUsage(c *gin.Context) {- // status code to indicate that endpoint is deprecatedc.JSON(http.StatusGone, gin.H{"message": "This endpoint is deprecated.",})diff --git a/server/pkg/api/trash.go b/server/pkg/api/trash.goindex 564f579966..cb14139001 100644--- a/server/pkg/api/trash.go+++ b/server/pkg/api/trash.go@@ -49,7 +49,6 @@ func (t *TrashHandler) GetDiffV2(c *gin.Context) {})}-// Delete files permanently, queues up the file for deletion & free up the space based on file's object sizefunc (t *TrashHandler) Delete(c *gin.Context) {userID := auth.GetUserID(c.Request.Header)var request ente.DeleteTrashFilesRequestdiff --git a/server/pkg/controller/billing.go b/server/pkg/controller/billing.goindex 3361b87e9d..36e6866793 100644--- a/server/pkg/controller/billing.go+++ b/server/pkg/controller/billing.go@@ -98,7 +98,6 @@ func (c *BillingController) GetUserPlans(ctx *gin.Context, userID int64) ([]enteif err != nil {return []ente.BillingPlan{}, stacktrace.Propagate(err, "Failed to get user's country stripe account")}- // always return the plans based on the user's country determined by the IPreturn c.GetPlansV2(network.GetClientCountry(ctx), stripeAccountCountry), nil}@@ -300,7 +299,6 @@ func (c *BillingController) getAllPlans(countryCode string, stripeAccountCountryif plans, found := countryWisePlans[countryCode]; found {return plans}- // unable to find plans for given country code, return plans for default countrydefaultCountry := billing.GetDefaultPlanCountry()return countryWisePlans[defaultCountry]}@@ -364,7 +362,6 @@ func (c *BillingController) HandleAccountDeletion(ctx context.Context, userID inreturn false, stacktrace.NewError("unexpected product id %s", subscription.ProductID)}isCancelled = subscription.Attributes.IsCancelled- // delete customer data from Stripe if user is on paid plan.if subscription.PaymentProvider == ente.Stripe {err = c.StripeController.CancelSubAndDeleteCustomer(subscription, billingLogger)if err != nil {diff --git a/server/pkg/controller/collections/collection.go b/server/pkg/controller/collections/collection.goindex 7c182feaaa..a75e5a1559 100644--- a/server/pkg/controller/collections/collection.go+++ b/server/pkg/controller/collections/collection.go@@ -152,7 +152,6 @@ func (c *CollectionController) TrashV3(ctx *gin.Context, req ente.TrashCollectio}if *req.KeepFiles {- // Verify that all files from this particular collections have been removed.count, err := c.CollectionRepo.GetCollectionsFilesCount(cID)if err != nil {return stacktrace.Propagate(err, "")diff --git a/server/pkg/controller/commonbilling/controller.go b/server/pkg/controller/commonbilling/controller.goindex 72f27c0e68..b6ba248d01 100644--- a/server/pkg/controller/commonbilling/controller.go+++ b/server/pkg/controller/commonbilling/controller.go@@ -49,8 +49,6 @@ func (c *Controller) CanDowngradeToGivenStorage(newStorage int64, userID int64)if err != nil {return false, stacktrace.Propagate(err, "")}- // newStore + addOnStorage + referralStorage should not be greater than usage.-if usage > (newStorage + bonusStorage.GetUsableBonus(newStorage)) {logrus.Infof("user with %d usage and %d bonus, can not downgrade to %d", usage, bonusStorage.GetUsableBonus(newStorage), newStorage)return false, nildiff --git a/server/pkg/controller/file.go b/server/pkg/controller/file.goindex 9efd598b07..93c5c8a2a1 100644--- a/server/pkg/controller/file.go+++ b/server/pkg/controller/file.go@@ -748,7 +748,6 @@ func (c *FileController) UpdateThumbnail(ctx *gin.Context, fileID int64, newThum}var oldObject *stringif existingThumbnailObjectKey != newThumbnail.ObjectKey {- // delete old object only if newThumbnail object key different.oldObject = &existingThumbnailObjectKey}err = c.FileRepo.UpdateThumbnail(ctx, fileID, userID, newThumbnail, newThumbnailSize, diff, oldObject)@@ -831,7 +830,6 @@ func (c *FileController) validateUpdateMetadataRequest(ctx *gin.Context, req ent// cold storage (if replicated)func (c *FileController) CleanupDeletedFiles() {log.Info("Cleaning up deleted files")- // If cleanup is already running, avoiding concurrent runs to avoid concurrent issuesif c.cleanupCronRunning {log.Info("Skipping CleanupDeletedFiles cron run as another instance is still running")return@@ -966,7 +964,6 @@ func (c *FileController) sizeOf(objectKey string) (int64, error) {bucket := c.S3Config.GetHotBucket()var head *s3.HeadObjectOutputvar err error- // Retry twice with a delay of 500ms and 1000msfor i := 0; i < 3; i++ {head, err = s3Client.HeadObject(&s3.HeadObjectInput{Key: &objectKey,@@ -995,11 +992,9 @@ func (c *FileController) onDuplicateObjectDetected(ctx *gin.Context, file ente.Ffile.Metadata.EncryptedData == existing.Metadata.EncryptedData &&file.Metadata.DecryptionHeader == existing.Metadata.DecryptionHeader &&file.OwnerID == existing.OwnerID {- // Already uploaded filefile.ID = existing.IDreturn file, nil} else {- // Overwrote an existing file or thumbnailgo c.onExistingObjectsReplaced(ctx, file, hotDC)return ente.File{}, ente.ErrBadRequest}diff --git a/server/pkg/controller/filedata/delete.go b/server/pkg/controller/filedata/delete.goindex 674da15a34..693b88732e 100644--- a/server/pkg/controller/filedata/delete.go+++ b/server/pkg/controller/filedata/delete.go@@ -23,19 +23,11 @@ func (c *Controller) startDeleteWorkers(n int) {for i := 0; i < n; i++ {go c.delete(i)- // Stagger the workerstime.Sleep(time.Duration(2*i+1) * time.Minute)}}-// i is an arbitrary index of the current routine.func (c *Controller) delete(i int) {- // This is just- //- // while (true) { delete() }- //- // but with an extra sleep for a bit if nothing got deleted - both when- // something's wrong, or there's nothing to do.for {err := c.tryDelete()if err != nil {diff --git a/server/pkg/controller/filedata/preview_files.go b/server/pkg/controller/filedata/preview_files.goindex baf926bbae..1454bc707b 100644--- a/server/pkg/controller/filedata/preview_files.go+++ b/server/pkg/controller/filedata/preview_files.go@@ -42,7 +42,6 @@ func (c *Controller) PreviewUploadURL(ctx *gin.Context, request filedata.Previewreturn nil, stacktrace.Propagate(err, "")}id := filedata.NewUploadID(request.Type)- // note: instead of the final url, give a temp url for upload purpose.objectKey := filedata.ObjectKey(request.FileID, fileOwnerID, request.Type, &id)bucketID := c.S3Config.GetBucketID(request.Type)if request.IsMultiPart {diff --git a/server/pkg/controller/filedata/replicate.go b/server/pkg/controller/filedata/replicate.goindex a2b47e0a70..8f311d675d 100644--- a/server/pkg/controller/filedata/replicate.go+++ b/server/pkg/controller/filedata/replicate.go@@ -65,12 +65,10 @@ func (c *Controller) startWorkers(n int) {for i := 0; i < n; i++ {go c.replicate(i)- // Stagger the workerstime.Sleep(time.Duration(2*i+1) * time.Second)}}-// i is an arbitrary index of the current routine.func (c *Controller) replicate(i int) {for {err := c.tryReplicate()@@ -104,7 +102,6 @@ func (c *Controller) tryReplicate() error {}).Errorf("Could not replicate file data: %s", err)return err} else {- // If the replication was completed without any errors, we can reset the lock timereturn c.Repo.ResetSyncLock(ctx, *row, newLockTime)}}diff --git a/server/pkg/controller/filedata/video.go b/server/pkg/controller/filedata/video.goindex 6606b4bae2..b992295565 100644--- a/server/pkg/controller/filedata/video.go+++ b/server/pkg/controller/filedata/video.go@@ -63,7 +63,6 @@ func (c *Controller) InsertVideoPreview(ctx *gin.Context, req *filedata.VidPreviisDuplicate, checkErr := c._checkIfDuplicateRequest(ctx, row, fileObjectKey)if checkErr != nil {logger.WithError(checkErr).Error("failed to check for duplicate request")- // continue with existing dbInsertErr}if isDuplicate {logger.Info("duplicate put request detected, ignoring")diff --git a/server/pkg/controller/object_cleanup.go b/server/pkg/controller/object_cleanup.goindex 59cb11663f..b4c080e723 100644--- a/server/pkg/controller/object_cleanup.go+++ b/server/pkg/controller/object_cleanup.go@@ -68,7 +68,6 @@ func (c *ObjectCleanupController) StartRemovingUnreportedObjects() {}}-// i is an arbitrary index for the current goroutine.func (c *ObjectCleanupController) removeUnreportedObjectsWorker(i int) {for {count := c.removeUnreportedObjects()@@ -310,25 +309,6 @@ func (c *ObjectCleanupController) abortMultipartUpload(objectKey string, uploadIreturn nil}-// The original code here checked for NoSuchUpload, presumably because that is-// the error that B2 returns.-//-// Wasabi returns something similar:-//-// <Error>-// <Code>NoSuchUpload</Code>-// <Message>The specified upload does not exist. The upload ID may be invalid,-// or the upload may have been aborted or completed.</Message>-// ...-//-// However, Scaleway returns a different error, NoSuchKey-//-// <Error>-// <Code>NoSuchKey</Code>-// <Message>The specified key does not exist.</Message>-// ...-//-// This method returns true if either of these occur.func isUnknownUploadError(err error) bool {// B2, Wasabiif strings.Contains(err.Error(), "NoSuchUpload") {diff --git a/server/pkg/controller/passkeys.go b/server/pkg/controller/passkeys.goindex 2fceba7ce8..3cc7ab9d72 100644--- a/server/pkg/controller/passkeys.go+++ b/server/pkg/controller/passkeys.go@@ -53,7 +53,6 @@ func (c *PasskeyController) DeletePasskey(userID int64, passkeyID uuid.UUID) (erreturn c.Repo.DeletePasskey(&user, passkeyID)}-// RemovePasskey2FA removes all the user's passkeys to disable passkey 2FA and fall back to TOTP based 2FA if enabled.func (c *PasskeyController) RemovePasskey2FA(userID int64) (err error) {passkeys, err := c.GetPasskeys(userID)if err != nil {diff --git a/server/pkg/controller/push_test.go b/server/pkg/controller/push_test.goindex 614b015b45..39328c3d53 100644--- a/server/pkg/controller/push_test.go+++ b/server/pkg/controller/push_test.go@@ -28,8 +28,6 @@ func jsonResponse(status int, body string) *http.Response {}}-// wireMsg mirrors the FCM HTTP v1 request body so tests can assert the exact-// JSON we put on the wire.type wireMsg struct {Message struct {Token string `json:"token"`diff --git a/server/pkg/controller/replication3.go b/server/pkg/controller/replication3.goindex 76d4548d26..c5a77e797f 100644--- a/server/pkg/controller/replication3.go+++ b/server/pkg/controller/replication3.go@@ -50,14 +50,14 @@ type ReplicationController3 struct {ObjectRepo *repo.ObjectRepositoryObjectCopiesRepo *repo.ObjectCopiesRepositoryDiscordController *discord.DiscordController- workerURL string- tempStorage string- mUploadSuccess *prometheus.CounterVec- mUploadFailure *prometheus.CounterVec- b2Client *s3.S3- b2Bucket *string- wasabiDest *UploadDestination- scwDest *UploadDestination+ workerURL string+ tempStorage string+ mUploadSuccess *prometheus.CounterVec+ mUploadFailure *prometheus.CounterVec+ b2Client *s3.S3+ b2Bucket *string+ wasabiDest *UploadDestination+ scwDest *UploadDestination}type UploadDestination struct {@@ -65,10 +65,10 @@ type UploadDestination struct {Client *s3.S3Uploader *s3manager.UploaderBucket *string- Label string+ Label string// If true, we should ignore Wasabi 403 errors. See "Reuploads".HasComplianceHold bool- IsGlacier bool+ IsGlacier bool}// StartReplication starts the background replication process.@@ -113,7 +113,6 @@ func (c *ReplicationController3) startWorkers(n int) {for i := 0; i < n; i++ {go c.replicate(i)- // Stagger the workerstime.Sleep(time.Duration(2*i+1) * time.Second)}}@@ -192,14 +191,7 @@ func (c *ReplicationController3) createDestinations() {}}-// i is an arbitrary index of the current routine.func (c *ReplicationController3) replicate(i int) {- // This is just- //- // while (true) { replicate() }- //- // but with an extra sleep for a bit if nothing got replicated - both when- // something's wrong, or there's nothing to do.for {err := c.tryReplicate()if err != nil {diff --git a/server/pkg/controller/usage.go b/server/pkg/controller/usage.goindex 63f399655d..61766d62cd 100644--- a/server/pkg/controller/usage.go+++ b/server/pkg/controller/usage.go@@ -173,7 +173,6 @@ func (c *UsageController) canUploadFile(ctx context.Context, userID int64, size}var eligibleBonus = bonus.GetUsableBonus(subStorage)if newUsage > (subStorage + eligibleBonus) {- // fetch lockerUsage if it's null. We need to discount locker usage while checking storage limitif lockerUsage == nil && lUsageErr == nil {lockerUsage, lUsageErr = c.UsageRepo.GetLockerUsage(ctx, subscriptionUserIDs)if lUsageErr != nil {@@ -186,8 +185,6 @@ func (c *UsageController) canUploadFile(ctx context.Context, userID int64, size}}- // Get particular member's storage and check if the file size is larger than the size of the storage allocated- // to the Member and fail if it's too large.if subscriptionAdminID != userID && memberStorageLimit != nil {memberUsage, memberUsageErr := c.UsageRepo.GetUsage(userID)if memberUsageErr != nil {@@ -196,7 +193,6 @@ func (c *UsageController) canUploadFile(ctx context.Context, userID int64, sizeif size != nil {memberUsage += *size}- // Upload fail if memberStorageLimit > memberUsage ((fileSize + total Usage) + StorageOverflowAboveSubscriptionLimit (50mb))if memberUsage > (*memberStorageLimit + StorageOverflowAboveSubscriptionLimit) {return stacktrace.Propagate(ente.ErrStorageLimitExceeded, "member Storage Limit Exceeded (limit %d, usage %d)", *memberStorageLimit, memberUsage)diff --git a/server/pkg/controller/user/user.go b/server/pkg/controller/user/user.goindex 626d3798ec..ed9e577589 100644--- a/server/pkg/controller/user/user.go+++ b/server/pkg/controller/user/user.go@@ -195,7 +195,6 @@ func (c *UserController) UpdateEmailMFA(context *gin.Context, userID int64, isEnif err != nil {return stacktrace.Propagate(err, "")}- // if SRP is not setup, then we can not disable email MFAif !isSrpSetupDone {return stacktrace.Propagate(ente.NewConflictError("SRP setup incomplete"), "can not disable email MFA before SRP is setup")}diff --git a/server/pkg/controller/user_lookup.go b/server/pkg/controller/user_lookup.goindex 02fa51e78d..c27d7e69fc 100644--- a/server/pkg/controller/user_lookup.go+++ b/server/pkg/controller/user_lookup.go@@ -20,13 +20,11 @@ type potentialAbuseNotifier interface {NotifyPotentialAbuse(message string)}-// UserLookup applies the shared authenticated email-discovery policy.type UserLookup interface {LookupUserID(requesterUserID int64, email string) (int64, error)VerifyUserID(requesterUserID int64, email string, expectedUserID int64) error}-// UserLookupController limits email discovery before querying the user repository.type UserLookupController struct {userRepo userLookupRepositorynotifier potentialAbuseNotifier@@ -47,8 +45,6 @@ func (c *UserLookupController) LookupUserID(requesterUserID int64, email string)return c.lookupUserID(requesterUserID, email, nil)}-// VerifyUserID applies the shared lookup policy and verifies that email still-// identifies expectedUserID.func (c *UserLookupController) VerifyUserID(requesterUserID int64,email string,diff --git a/server/pkg/external/listmonk/api.go b/server/pkg/external/listmonk/api.goindex 5652ed0d07..0deb1eae21 100644--- a/server/pkg/external/listmonk/api.go+++ b/server/pkg/external/listmonk/api.go@@ -15,11 +15,6 @@ import ("github.com/ente/stacktrace")-// Listmonk credentials to interact with the Listmonk API.-// It specifies BaseURL (url of the running listmonk server,-// Listmonk Username and Password.-// Visit https://listmonk.app/ to learn more about running-// Listmonk locallytype Credentials struct {BaseURL stringUsername string@@ -30,13 +25,11 @@ const listmonkRequestTimeout = 60 * time.Secondvar ErrSubscriberNotFound = errors.New("subscriber not found")-// Subscriber captures a listmonk subscriber record required by museum.type Subscriber struct {Email stringListIDs []int}-// SubscribersPage represents one paginated subscribers page from listmonk.type SubscribersPage struct {Results []SubscriberTotal int@@ -44,12 +37,7 @@ type SubscribersPage struct {PerPage int}-// GetSubscriberID returns subscriber id of the provided email address,-// else returns an error if email was not foundfunc GetSubscriberID(endpoint string, username string, password string, subscriberEmail string) (int, error) {- // Struct for the received API response.- // Can define other fields as well that can be- // extracted from response JSONtype SubscriberResponse struct {Data struct {Results []struct {@@ -58,13 +46,11 @@ func GetSubscriberID(endpoint string, username string, password string, subscrib} `json:"data"`}- // Constructing query parameters// Escape single quotes to prevent SQL-like injection in Listmonk's query syntaxsanitizedEmail := strings.ReplaceAll(subscriberEmail, "'", "''")queryParams := url.Values{}queryParams.Set("query", fmt.Sprintf("subscribers.email = '%s'", sanitizedEmail))- // Constructing the URL with query parametersendpointURL, err := url.Parse(endpoint)if err != nil {return 0, stacktrace.Propagate(err, "")@@ -78,7 +64,6 @@ func GetSubscriberID(endpoint string, username string, password string, subscribreq.SetBasicAuth(username, password)- // Sending the HTTP requestclient := &http.Client{Timeout: listmonkRequestTimeout}resp, err := client.Do(req)if err != nil {@@ -86,7 +71,6 @@ func GetSubscriberID(endpoint string, username string, password string, subscrib}defer resp.Body.Close()- // Reading the response bodybody, err := io.ReadAll(resp.Body)if err != nil {return 0, stacktrace.Propagate(err, "")@@ -98,24 +82,20 @@ func GetSubscriberID(endpoint string, username string, password string, subscrib)}- // Parsing the JSON responsevar subscriberResp SubscriberResponseif err := json.Unmarshal(body, &subscriberResp); err != nil {return 0, stacktrace.Propagate(err, "")}- // Checking if there are any subscribers foundif len(subscriberResp.Data.Results) == 0 {return 0, stacktrace.Propagate(ErrSubscriberNotFound, "")}- // Extracting the ID from the responseid := subscriberResp.Data.Results[0].IDreturn id, nil}-// ListSubscribers returns one paginated subscribers page from listmonk.func ListSubscribers(endpoint string, username string, password string, page int, perPage int) (SubscribersPage, error) {type subscriberResponse struct {Data struct {@@ -262,9 +242,6 @@ func decodeListIDs(raw json.RawMessage) ([]int, error) {return nil, errors.New("unsupported list ids format")}-// SendRequest sends a request to the specified Listmonk API endpoint-// with the provided method and data-// after authentication with the provided credentials (username, password)func SendRequest(method string, url string, data interface{}, username string, password string) error {jsonData, err := json.Marshal(data)if err != nil {@@ -280,7 +257,6 @@ func SendRequest(method string, url string, data interface{}, username string, preq.SetBasicAuth(username, password)req.Header.Set("Content-Type", "application/json")- // Send requestresp, err := client.Do(req)if err != nil {return stacktrace.Propagate(err, "")diff --git a/server/pkg/external/wasabi/compliance.go b/server/pkg/external/wasabi/compliance.goindex 1c991378fa..78e116ce0d 100644--- a/server/pkg/external/wasabi/compliance.go+++ b/server/pkg/external/wasabi/compliance.go@@ -16,33 +16,6 @@// There are compliance settings on a bucket level, which apply the policy that// is applied to all objects added to that bucket. In addition, there are also// compliance settings at the object level.-//-// Operations-//-// - GetBucketCompliance-//-// - PutBucketCompliance-//-// - GetObjectCompliance-//-// - PutObjectCompliance-//-// References-//-// - Blog post: Custom S3 requests with AWS Go SDK-// https://ente.com/blog/tech/custom-s3-requests/-//-// - AWS Go SDK examples:-// https://docs.aws.amazon.com/sdk-for-go/v1/developer-guide/common-examples.html-//-// - AWS Go SDK API template:-// https://github.com/aws/aws-sdk-go/blob/main/service/s3/api.go-//-// - Wasabi Compliance:-// https://wasabi.com/wp-content/themes/wasabi/docs/API_Guide/index.html#t=topics%2FCompliance.htm&rhsyns=%20-//-// - Wasabi Compliance - Operations on objects:-// https://wasabi.com/wp-content/themes/wasabi/docs/API_Guide/index.html#t=topics%2FCompliance1.htm%23XREF_26008_Compliance&rhsyns=%20package wasabiimport (@@ -51,32 +24,18 @@ import ("github.com/aws/aws-sdk-go/service/s3")-// newRequest creates a new request for a S3 operation and runs any-// custom request initialization.func newRequest(c *s3.S3, op *request.Operation, params, data interface{}) *request.Request {req := c.NewRequest(op, params, data)-- // Run custom request initialization if present- // if initRequest != nil {- // initRequest(req)- // }-return req}const opGetBucketCompliance = "GetBucketCompliance"-// GetBucketCompliance API operation for Wasabi S3 API.-//-// Returns the compliance state of a bucket.-//-// See also: Wasabi compliancefunc GetBucketCompliance(c *s3.S3, input *GetBucketComplianceInput) (*GetBucketComplianceOutput, error) {req, out := GetBucketComplianceRequest(c, input)return out, req.Send()}-// See also: GetBucketCompliance, Wasabi compliancefunc GetBucketComplianceRequest(c *s3.S3, input *GetBucketComplianceInput) (req *request.Request, output *GetBucketComplianceOutput) {op := &request.Operation{Name: opGetBucketCompliance,@@ -96,23 +55,17 @@ func GetBucketComplianceRequest(c *s3.S3, input *GetBucketComplianceInput) (reqtype GetBucketComplianceInput struct {_ struct{} `locationName:"GetBucketComplianceRequest" type:"structure"`- // The name of the bucket for which to get the compliance information.- //- // Bucket is a required fieldBucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"`}-// String returns the string representation.func (s GetBucketComplianceInput) String() string {return awsutil.Prettify(s)}-// GoString returns the string representation.func (s GetBucketComplianceInput) GoString() string {return s.String()}-// Validate inspects the fields of the type to determine if they are valid.func (s *GetBucketComplianceInput) Validate() error {invalidParams := request.ErrInvalidParams{Context: "GetBucketComplianceInput"}if s.Bucket == nil {@@ -128,92 +81,64 @@ func (s *GetBucketComplianceInput) Validate() error {return nil}-// SetBucket sets the Bucket field's value.func (s *GetBucketComplianceInput) SetBucket(v string) *GetBucketComplianceInput {s.Bucket = &vreturn s}-// Example response:-//-// <BucketComplianceConfiguration xml ns="http://s3.amazonaws.com/doc/2006-03-01/">-// <Status>enabled</Status>-// <LockTime>2016-11-07T15:08:05Z</LockTime>-// <IsLocked>false</IsLocked>-// <RetentionDays>0</RetentionDays>-// <ConditionalHold>false</ConditionalHold>-// <DeleteAfterRetention>false</DeleteAfterRetention>-// </BucketComplianceConfiguration>type GetBucketComplianceOutput struct {_ struct{} `type:"structure"`- // The compliance state of the bucket.Status *string `type:"string" enum:"BucketComplianceStatus"`- // The time at which the compliance settings are "locked".LockTime *string `type:"string"`- // Minimum number of days that objects are retained after their creation- // date or release from conditional hold.RetentionDays *int64 `type:"integer"`- // Indicates if newly created objects are placed on conditional hold.ConditionalHold *bool `type:"boolean"`- // Indicates if objects should be deleted automatically at the end of the- // retention period.DeleteAfterRetention *bool `type:"boolean"`}-// String returns the string representation.func (s GetBucketComplianceOutput) String() string {return awsutil.Prettify(s)}-// GoString returns the string representation.func (s GetBucketComplianceOutput) GoString() string {return s.String()}-// SetStatus sets the Status field's value.func (s *GetBucketComplianceOutput) SetStatus(v string) *GetBucketComplianceOutput {s.Status = &vreturn s}-// SetLockTime sets the LockTime field's value.func (s *GetBucketComplianceOutput) SetLockTime(v string) *GetBucketComplianceOutput {s.LockTime = &vreturn s}-// SetRetentionDays sets the RetentionDays field's value.func (s *GetBucketComplianceOutput) SetRetentionDays(v int64) *GetBucketComplianceOutput {s.RetentionDays = &vreturn s}-// SetConditionalHold sets the ConditionalHold field's value.func (s *GetBucketComplianceOutput) SetConditionalHold(v bool) *GetBucketComplianceOutput {s.ConditionalHold = &vreturn s}-// SetDeleteAfterRetention sets the DeleteAfterRetention field's value.func (s *GetBucketComplianceOutput) SetDeleteAfterRetention(v bool) *GetBucketComplianceOutput {s.DeleteAfterRetention = &vreturn s}const (- // BucketComplianceStatusEnabled is a BucketComplianceStatus enum valueBucketComplianceStatusEnabled = "enabled"- // BucketVersioningStatusDisabled is a BucketComplianceStatus enum valueBucketComplianceStatusDisabled = "disabled")-// BucketComplianceStatus_Values returns all elements of the BucketComplianceStatus enumfunc BucketComplianceStatus_Values() []string {return []string{BucketComplianceStatusEnabled,@@ -223,34 +148,11 @@ func BucketComplianceStatus_Values() []string {const opPutBucketCompliance = "PutBucketCompliance"-// PutBucketCompliance API operation for Wasabi.-//-// Sets the compliance state of an existing bucket.-//-// The compliance settings for a bucket are specified using the "?compliance"-// query string along with the comÂpliance settings as the XML body in the-// request. For example:-//-// PUT http://s3.wasabisys.com/my-bucket?compliance HTTP/1.1-//-// <BucketComplianceConfiguration>-// <Status>enabled</Status>-// <LockTime>off</LockTime>-// <RetentionDays>365</RetentionDays>-// <DeleteAfterRetention>true</DeleteAfterRetention>-// </BucketComplianceConfiguration>-//-// After compliance is enabled for a bucket, the policy is immediately applied-// to all objects in the bucket. An attempt to delete an object before the-// retention period will return an error.-//-// See also: Wasabi compliancefunc PutBucketCompliance(c *s3.S3, input *PutBucketComplianceInput) (*PutBucketComplianceOutput, error) {req, out := PutBucketComplianceRequest(c, input)return out, req.Send()}-// See also: PutBucketCompliance, Wasabi compliancefunc PutBucketComplianceRequest(c *s3.S3, input *PutBucketComplianceInput) (req *request.Request, output *PutBucketComplianceOutput) {op := &request.Operation{Name: opPutBucketCompliance,@@ -264,29 +166,17 @@ func PutBucketComplianceRequest(c *s3.S3, input *PutBucketComplianceInput) (reqoutput = &PutBucketComplianceOutput{}req = newRequest(c, op, input, output)- // req.Handlers.Unmarshal.Swap(restxml.UnmarshalHandler.Name, protocol.UnmarshalDiscardBodyHandler)- // req.Handlers.Build.PushBackNamed(request.NamedHandler{- // Name: "contentMd5Handler",- // Fn: checksum.AddBodyContentMD5Handler,- // })return}type PutBucketComplianceInput struct {_ struct{} `locationName:"PutBucketComplianceRequest" type:"structure" payload:"BucketComplianceConfiguration"`- // The bucket name.- //- // Bucket is a required fieldBucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"`- // A container for the compliance configuration.- //- // BucketComplianceConfiguration is a required fieldBucketComplianceConfiguration *BucketComplianceConfiguration `locationName:"BucketComplianceConfiguration" type:"structure" required:"true"`}-// A container for the bucket compliance configuration.type BucketComplianceConfiguration struct {_ struct{} `type:"structure"`@@ -339,17 +229,14 @@ type BucketComplianceConfiguration struct {DeleteAfterRetention *bool `type:"boolean"`}-// String returns the string representation.func (s PutBucketComplianceInput) String() string {return awsutil.Prettify(s)}-// GoString returns the string representation.func (s PutBucketComplianceInput) GoString() string {return s.String()}-// Validate inspects the fields of the type to determine if they are valid.func (s *PutBucketComplianceInput) Validate() error {invalidParams := request.ErrInvalidParams{Context: "PutBucketComplianceInput"}if s.Bucket == nil {@@ -373,29 +260,24 @@ func (s *PutBucketComplianceInput) Validate() error {return nil}-// SetBucket sets the Bucket field's value.func (s *PutBucketComplianceInput) SetBucket(v string) *PutBucketComplianceInput {s.Bucket = &vreturn s}-// SetBucket sets the BucketComplianceConfiguration field's value.func (s *PutBucketComplianceInput) SetBucketComplianceConfiguration(v BucketComplianceConfiguration) *PutBucketComplianceInput {s.BucketComplianceConfiguration = &vreturn s}-// String returns the string representation.func (s BucketComplianceConfiguration) String() string {return awsutil.Prettify(s)}-// GoString returns the string representation.func (s BucketComplianceConfiguration) GoString() string {return s.String()}-// Validate inspects the fields of the type to determine if they are valid.func (s *BucketComplianceConfiguration) Validate() error {invalidParams := request.ErrInvalidParams{Context: "BucketComplianceConfiguration"}if s.RetentionDays == nil {@@ -408,31 +290,26 @@ func (s *BucketComplianceConfiguration) Validate() error {return nil}-// SetStatus sets the Status field's value.func (s *BucketComplianceConfiguration) SetStatus(v string) *BucketComplianceConfiguration {s.Status = &vreturn s}-// SetLockTime sets the LockTime field's value.func (s *BucketComplianceConfiguration) SetLockTime(v string) *BucketComplianceConfiguration {s.LockTime = &vreturn s}-// SetRetentionDays sets the RetentionDays field's value.func (s *BucketComplianceConfiguration) SetRetentionDays(v int64) *BucketComplianceConfiguration {s.RetentionDays = &vreturn s}-// SetConditionalHold sets the ConditionalHold field's value.func (s *BucketComplianceConfiguration) SetConditionalHold(v bool) *BucketComplianceConfiguration {s.ConditionalHold = &vreturn s}-// SetDeleteAfterRetention sets the DeleteAfterRetention field's value.func (s *BucketComplianceConfiguration) SetDeleteAfterRetention(v bool) *BucketComplianceConfiguration {s.DeleteAfterRetention = &vreturn s@@ -442,47 +319,21 @@ type PutBucketComplianceOutput struct {_ struct{} `type:"structure"`}-// String returns the string representation.func (s PutBucketComplianceOutput) String() string {return awsutil.Prettify(s)}-// GoString returns the string representation.func (s PutBucketComplianceOutput) GoString() string {return s.String()}const opGetObjectCompliance = "GetObjectCompliance"-// GetObjectCompliance API operation for Wasabi S3 API.-//-// Returns the compliance state of an object.-//-// The compliance settings for any specific object can also be retrieved using-// the "?compliance" query string. In addition to the object compliance settings-// above, the query returns the calculated SHA256 hash for the object, which can-// be used to determine that the object has not been modified. Note that the-// SHA256 value is only available for objects that are uploaded as a single-// object and is not available for multi-part or composed objects.-//-// The following is an example of getting the compliance on an object:-//-// GET http://s3.wasabisys.com/my-bucket/my-object?compliance HTTP/1.1-//-// <ObjectComplianceConfiguration xml ns="http://s3.amazonaws.com/doc/2006-03-01/">-// <RetentionTime>2016-10-31T15:08:05Z</RetentionTime>-// <ConditionalHold>false</ConditionalHold>-// <LegalHold>false</LegalHold>-// <SHA256>14b4be3894e92166b508007b6c2e4fb6e88d3d0ad652c76475089a50ebe6e33b</SHA256>-// </ObjectComplianceConfiguration>-//-// See also: Wasabi compliancefunc GetObjectCompliance(c *s3.S3, input *GetObjectComplianceInput) (*GetObjectComplianceOutput, error) {req, out := GetObjectComplianceRequest(c, input)return out, req.Send()}-// See also: GetObjectCompliance, Wasabi compliancefunc GetObjectComplianceRequest(c *s3.S3, input *GetObjectComplianceInput) (req *request.Request, output *GetObjectComplianceOutput) {op := &request.Operation{Name: opGetObjectCompliance,@@ -502,28 +353,19 @@ func GetObjectComplianceRequest(c *s3.S3, input *GetObjectComplianceInput) (reqtype GetObjectComplianceInput struct {_ struct{} `locationName:"GetObjectComplianceRequest" type:"structure"`- // The bucket name of the bucket containing the object.- //- // Bucket is a required fieldBucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"`- // Key name of the object to get the compliance information of.- //- // Key is a required fieldKey *string `location:"uri" locationName:"Key" min:"1" type:"string" required:"true"`}-// String returns the string representation.func (s GetObjectComplianceInput) String() string {return awsutil.Prettify(s)}-// GoString returns the string representation.func (s GetObjectComplianceInput) GoString() string {return s.String()}-// Validate inspects the fields of the type to determine if they are valid.func (s *GetObjectComplianceInput) Validate() error {invalidParams := request.ErrInvalidParams{Context: "GetObjectComplianceInput"}if s.Bucket == nil {@@ -545,64 +387,51 @@ func (s *GetObjectComplianceInput) Validate() error {return nil}-// SetBucket sets the Bucket field's value.func (s *GetObjectComplianceInput) SetBucket(v string) *GetObjectComplianceInput {s.Bucket = &vreturn s}-// SetKey sets the Key field's value.func (s *GetObjectComplianceInput) SetKey(v string) *GetObjectComplianceInput {s.Key = &vreturn s}-// See also: PutObjectComplianceInputtype GetObjectComplianceOutput struct {_ struct{} `type:"structure"`- // The time before which the object cannot be deleted.RetentionTime *string `type:"string"`- // Indicates if the object is under conditional hold.ConditionalHold *bool `type:"boolean"`- // Indicates if the object is under legal hold.LegalHold *bool `type:"boolean"`- // The calculated SHA256 hash for the objectSHA256 *string `type:"string"`}-// String returns the string representation.func (s GetObjectComplianceOutput) String() string {return awsutil.Prettify(s)}-// GoString returns the string representation.func (s GetObjectComplianceOutput) GoString() string {return s.String()}-// SetRetentionTime sets the RetentionTime field's value.func (s *GetObjectComplianceOutput) SetRetentionTime(v string) *GetObjectComplianceOutput {s.RetentionTime = &vreturn s}-// SetConditionalHold sets the ConditionalHold field's value.func (s *GetObjectComplianceOutput) SetConditionalHold(v bool) *GetObjectComplianceOutput {s.ConditionalHold = &vreturn s}-// SetConditionalHold sets the ConditionalHold field's value.func (s *GetObjectComplianceOutput) SetLegalHold(v bool) *GetObjectComplianceOutput {s.LegalHold = &vreturn s}-// SetRetentionTime sets the SHA256 field's value.func (s *GetObjectComplianceOutput) SetSHA256(v string) *GetObjectComplianceOutput {s.SHA256 = &vreturn s@@ -610,20 +439,11 @@ func (s *GetObjectComplianceOutput) SetSHA256(v string) *GetObjectComplianceOutpconst opPutObjectCompliance = "PutObjectCompliance"-// PutObjectCompliance API operation for Wasabi.-//-// Sets the compliance state of an existing object.-//-// The compliance settings for any one object in a bucket with compliance can-// also be changed within the limÂits of the compliance on the bucket.-//-// See also: PutObjectComplianceInput, Wasabi compliancefunc PutObjectCompliance(c *s3.S3, input *PutObjectComplianceInput) (*PutObjectComplianceOutput, error) {req, out := PutObjectComplianceRequest(c, input)return out, req.Send()}-// See also: PutObjectCompliance, Wasabi compliancefunc PutObjectComplianceRequest(c *s3.S3, input *PutObjectComplianceInput) (req *request.Request, output *PutObjectComplianceOutput) {op := &request.Operation{Name: opPutObjectCompliance,@@ -637,42 +457,19 @@ func PutObjectComplianceRequest(c *s3.S3, input *PutObjectComplianceInput) (reqoutput = &PutObjectComplianceOutput{}req = newRequest(c, op, input, output)- // req.Handlers.Unmarshal.Swap(restxml.UnmarshalHandler.Name, protocol.UnmarshalDiscardBodyHandler)- // req.Handlers.Build.PushBackNamed(request.NamedHandler{- // Name: "contentMd5Handler",- // Fn: checksum.AddBodyContentMD5Handler,- // })return}-// The following is an example of setting the compliance on an object:-//-// PUT http://s3.wasabisys.com/my-bucket/my-object?compliance HTTP/1.1-//-// <ObjectComplianceConfiguration>-// <ConditionalHold>false</ConditionalHold>-// <RetentionTime>2018-03-13T10:45:00Z</RetentionTime>-// </ObjectComplianceConfiguration>type PutObjectComplianceInput struct {_ struct{} `locationName:"PutObjectComplianceRequest" type:"structure" payload:"ObjectComplianceConfiguration"`- // The bucket name of the bucket containing the object.- //- // Bucket is a required fieldBucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"`- // Key name of the object to put the compliance information to.- //- // Key is a required fieldKey *string `location:"uri" locationName:"Key" min:"1" type:"string" required:"true"`- // A container for object compliance configuration.- //- // ObjectComplianceConfiguration is a required fieldObjectComplianceConfiguration *ObjectComplianceConfiguration `locationName:"ObjectComplianceConfiguration" type:"structure" required:"true"`}-// A container for object compliance configuration.type ObjectComplianceConfiguration struct {_ struct{} `type:"structure"`@@ -695,17 +492,14 @@ type ObjectComplianceConfiguration struct {LegalHold *bool `type:"boolean"`}-// String returns the string representation.func (s PutObjectComplianceInput) String() string {return awsutil.Prettify(s)}-// GoString returns the string representation.func (s PutObjectComplianceInput) GoString() string {return s.String()}-// Validate inspects the fields of the type to determine if they are valid.func (s *PutObjectComplianceInput) Validate() error {invalidParams := request.ErrInvalidParams{Context: "PutObjectComplianceInput"}if s.Bucket == nil {@@ -735,46 +529,38 @@ func (s *PutObjectComplianceInput) Validate() error {return nil}-// SetBucket sets the Bucket field's value.func (s *PutObjectComplianceInput) SetBucket(v string) *PutObjectComplianceInput {s.Bucket = &vreturn s}-// SetKey sets the Key field's value.func (s *PutObjectComplianceInput) SetKey(v string) *PutObjectComplianceInput {s.Key = &vreturn s}-// String returns the string representation.func (s ObjectComplianceConfiguration) String() string {return awsutil.Prettify(s)}-// GoString returns the string representation.func (s ObjectComplianceConfiguration) GoString() string {return s.String()}-// Validate inspects the fields of the type to determine if they are valid.func (s *ObjectComplianceConfiguration) Validate() error {return nil}-// SetRetentionTime sets the RetentionTime field's value.func (s *ObjectComplianceConfiguration) SetRetentionTime(v string) *ObjectComplianceConfiguration {s.RetentionTime = &vreturn s}-// SetConditionalHold sets the ConditionalHold field's value.func (s *ObjectComplianceConfiguration) SetConditionalHold(v bool) *ObjectComplianceConfiguration {s.ConditionalHold = &vreturn s}-// SetLegalHold sets the LegalHold field's value.func (s *ObjectComplianceConfiguration) SetLegalHold(v bool) *ObjectComplianceConfiguration {s.LegalHold = &vreturn s@@ -784,12 +570,10 @@ type PutObjectComplianceOutput struct {_ struct{} `type:"structure"`}-// String returns the string representation.func (s PutObjectComplianceOutput) String() string {return awsutil.Prettify(s)}-// GoString returns the string representation.func (s PutObjectComplianceOutput) GoString() string {return s.String()}diff --git a/server/pkg/middleware/auth.go b/server/pkg/middleware/auth.goindex 7be36a7559..8a0b05e33d 100644--- a/server/pkg/middleware/auth.go+++ b/server/pkg/middleware/auth.go@@ -21,17 +21,12 @@ import ("github.com/spf13/viper")-// AuthMiddleware intercepts and authenticates incoming requeststype AuthMiddleware struct {UserAuthRepo *repo.UserAuthRepositoryCache *cache.CacheUserController *user.UserController}-// TokenAuthMiddleware returns a middle ware that extracts the `X-AuthToken`-// within the header of a request and uses it to authenticate and insert the-// authenticated user to the request's `X-Auth-User-ID` field.-// If isJWT is true we use JWT token validationfunc (m *AuthMiddleware) TokenAuthMiddleware(jwtClaimScope *jwt.ClaimScope) gin.HandlerFunc {return func(c *gin.Context) {token := auth.GetToken(c)@@ -92,8 +87,6 @@ func (m *AuthMiddleware) TokenAuthMiddleware(jwtClaimScope *jwt.ClaimScope) gin.}}-// TokenOrJWTAuthMiddleware authenticates either a user session token or a JWT-// with the given claim scope.func (m *AuthMiddleware) TokenOrJWTAuthMiddleware(jwtClaimScope jwt.ClaimScope) gin.HandlerFunc {userAuth := m.TokenAuthMiddleware(nil)jwtAuth := m.TokenAuthMiddleware(jwtClaimScope.Ptr())@@ -122,8 +115,6 @@ func RejectAuthApp() gin.HandlerFunc {}}-// AdminAuthMiddleware returns a middle ware that extracts the `userID` added by the TokenAuthMiddleware-// within the header of a request and uses it to check admin status// NOTE: Should be added after TokenAuthMiddleware middlewarefunc (m *AuthMiddleware) AdminAuthMiddleware() gin.HandlerFunc {return func(c *gin.Context) {diff --git a/server/pkg/middleware/cast_auth.go b/server/pkg/middleware/cast_auth.goindex 7325cb3a1a..4821a83d69 100644--- a/server/pkg/middleware/cast_auth.go+++ b/server/pkg/middleware/cast_auth.go@@ -9,16 +9,11 @@ import ("net/http")-// CastMiddleware intercepts and authenticates incoming requeststype CastMiddleware struct {Cache *cache.CacheCastCtrl *castCtrl.Controller}-// CastAuthMiddleware returns a middle ware that extracts the `X-AuthToken`-// within the header of a request and uses it to authenticate and insert the-// authenticated user to the request's `X-Auth-User-ID` field.-// If isJWT is true we use JWT token validationfunc (m *CastMiddleware) CastAuthMiddleware() gin.HandlerFunc {return func(c *gin.Context) {token := auth.GetCastToken(c)diff --git a/server/pkg/middleware/collection_link.go b/server/pkg/middleware/collection_link.goindex 5ec2621350..7a864eeab0 100644--- a/server/pkg/middleware/collection_link.go+++ b/server/pkg/middleware/collection_link.go@@ -38,7 +38,6 @@ import (var passwordWhiteListedURLs = []string{"/public-collection/info", "/public-collection/verify-password"}-// CollectionLinkMiddleware intercepts and authenticates incoming requeststype CollectionLinkMiddleware struct {CollectionLinkRepo *public.CollectionLinkRepoPublicCollectionCtrl *public2.CollectionLinkController@@ -51,9 +50,6 @@ type CollectionLinkMiddleware struct {AnonIdentitySecret []byte}-// Authenticate returns a middle ware that extracts the `X-Auth-Access-Token`-// within the header of a request and uses it to validate the access token and set the-// ente.PublicAccessContext with auth.PublicAccessKey as keyfunc (m *CollectionLinkMiddleware) Authenticate(urlSanitizer func(_ *gin.Context) string) gin.HandlerFunc {return func(c *gin.Context) {accessToken := auth.GetAccessToken(c)@@ -85,14 +81,12 @@ func (m *CollectionLinkMiddleware) Authenticate(urlSanitizer func(_ *gin.Contextc.AbortWithStatusJSON(http.StatusGone, gin.H{"error": "disabled token"})return}- // validate if user still has active paid subscriptionisFreeUser, err := m.validateOwnersSubscription(c, publicCollectionSummary.CollectionID)if err != nil {logrus.WithError(err).Warn("failed to verify active paid subscription")c.AbortWithStatusJSON(http.StatusGone, gin.H{"error": "no active subscription"})return}- // Override device limit to 5 for free usersif isFreeUser {publicCollectionSummary.DeviceLimit = public2.FreeUserDeviceLimit}@@ -139,7 +133,6 @@ func (m *CollectionLinkMiddleware) Authenticate(urlSanitizer func(_ *gin.Contextreturn}- // checks password protected public collectionif !passwordValidated && publicCollectionSummary.PassHash != nil && *publicCollectionSummary.PassHash != "" {if err = m.validatePassword(c, reqPath, publicCollectionSummary); err != nil {logrus.WithError(err).Warn("password validation failed")@@ -272,7 +265,6 @@ func (m *CollectionLinkMiddleware) isDeviceLimitReached(ctx context.Context,return false, stacktrace.Propagate(err, "failed to record access history")}-// validatePassword will verify if the user is provided correct password for the public albumfunc (m *CollectionLinkMiddleware) validatePassword(c *gin.Context, reqPath string,collectionSummary ente.PublicCollectionSummary) error {// /public-collection/info is allowed before password unlock so clients candiff --git a/server/pkg/middleware/file_link.go b/server/pkg/middleware/file_link.goindex df36f530ed..ed7a2ad4de 100644--- a/server/pkg/middleware/file_link.go+++ b/server/pkg/middleware/file_link.go@@ -23,7 +23,6 @@ import (var filePasswordWhiteListedURLs = []string{"/file-link/pass-info", "/file-link/verify-password"}-// FileLinkMiddleware intercepts and authenticates incoming requeststype FileLinkMiddleware struct {FileLinkRepo *public.FileLinkRepositoryFileLinkCtrl *publicCtrl.FileLinkController@@ -32,9 +31,6 @@ type FileLinkMiddleware struct {DiscordController *discord.DiscordController}-// Authenticate returns a middle ware that extracts the `X-Auth-Access-Token`-// within the header of a request and uses it to validate the access token and set the-// ente.PublicAccessContext with auth.PublicAccessKey as keyfunc (m *FileLinkMiddleware) Authenticate(urlSanitizer func(_ *gin.Context) string) gin.HandlerFunc {return func(c *gin.Context) {accessToken := auth.GetAccessToken(c)@@ -108,7 +104,6 @@ func (m *FileLinkMiddleware) Authenticate(urlSanitizer func(_ *gin.Context) strireturn}- // checks password protected public collectionif !passwordValidated && fileLinkRow.PassHash != nil && *fileLinkRow.PassHash != "" {if err = m.validatePassword(c, reqPath, fileLinkRow); err != nil {logrus.WithError(err).Warn("password validation failed")@@ -198,7 +193,6 @@ func (m *FileLinkMiddleware) isDeviceLimitReached(ctx context.Context,return false, stacktrace.Propagate(err, "failed to record access history")}-// validatePassword will verify if the user is provided correct password for the public albumfunc (m *FileLinkMiddleware) validatePassword(c *gin.Context,reqPath string,diff --git a/server/pkg/middleware/memory_share.go b/server/pkg/middleware/memory_share.goindex 9abb6c7851..35d3f15d51 100644--- a/server/pkg/middleware/memory_share.go+++ b/server/pkg/middleware/memory_share.go@@ -10,14 +10,10 @@ import ("github.com/gin-gonic/gin")-// MemoryShareMiddleware intercepts and authenticates incoming requests for public memory sharestype MemoryShareMiddleware struct {Repo *repo.MemoryShareRepository}-// Authenticate returns a middleware that extracts the `X-Auth-Access-Token`-// within the header of a request and uses it to validate the access token and set the-// ente.MemoryShareAccessContext with auth.MemoryShareAccessKey as keyfunc (m *MemoryShareMiddleware) Authenticate(urlSanitizer func(_ *gin.Context) string) gin.HandlerFunc {return func(c *gin.Context) {_ = urlSanitizer@@ -45,7 +41,6 @@ func (m *MemoryShareMiddleware) Authenticate(urlSanitizer func(_ *gin.Context) sreturn}- // Set context for handlersaccessCtx := ente.MemoryShareAccessContext{ID: share.ID,ShareID: share.ID,diff --git a/server/pkg/middleware/rate_limit.go b/server/pkg/middleware/rate_limit.goindex e72d1cf60c..76b166b37b 100644--- a/server/pkg/middleware/rate_limit.go+++ b/server/pkg/middleware/rate_limit.go@@ -19,7 +19,7 @@ import ()type RateLimitMiddleware struct {- count int64 // Use int64 for atomic operations+ count int64limit int64reset time.Durationticker *time.Ticker@@ -51,26 +51,21 @@ func NewRateLimitMiddleware(discordCtrl *discord.DiscordController, limit int64,}go func() {for range rl.ticker.C {- atomic.StoreInt64(&rl.count, 0) // Reset the count every reset interval+ atomic.StoreInt64(&rl.count, 0)}}()return rl}-// Increment increments the counter in a thread-safe manner.-// Returns true if the increment was within the rate limit, false if the rate limit was exceeded.func (r *RateLimitMiddleware) Increment() bool {- // Atomically increment the countnewCount := atomic.AddInt64(&r.count, 1)return newCount <= r.limit}-// Stop the internal ticker, effectively stopping the rate limiter.func (r *RateLimitMiddleware) Stop() {r.ticker.Stop()}-// GlobalRateLimiter rate limits all requests to the server, regardless of the endpoint.func (r *RateLimitMiddleware) GlobalRateLimiter() gin.HandlerFunc {return func(c *gin.Context) {if !r.Increment() {@@ -84,8 +79,6 @@ func (r *RateLimitMiddleware) GlobalRateLimiter() gin.HandlerFunc {}}-// APIRateLimitMiddleware only rate limits sensitive public endpoints which have a higher risk-// of abuse by any bad actor.func (r *RateLimitMiddleware) APIRateLimitMiddleware(urlSanitizer func(_ *gin.Context) string) gin.HandlerFunc {return func(c *gin.Context) {requestPath := urlSanitizer(c)@@ -107,8 +100,6 @@ func (r *RateLimitMiddleware) APIRateLimitMiddleware(urlSanitizer func(_ *gin.Co}}-// APIRateLimitForUserMiddleware only rate limits sensitive authenticated endpoints which have a higher risk-// of abuse by any bad actor.func (r *RateLimitMiddleware) APIRateLimitForUserMiddleware(urlSanitizer func(_ *gin.Context) string) gin.HandlerFunc {return func(c *gin.Context) {requestPath := urlSanitizer(c)@@ -149,9 +140,6 @@ func (r *RateLimitMiddleware) isRateLimited(c *gin.Context, rateLimiter *limiterreturn true}-// getGlobalLimiter, based on reqPath & reqMethod, returns a limiter that should-// be applied globally for requests matching the route. It returns nil if no-// global route-specific limit should be applied.func (r *RateLimitMiddleware) getGlobalLimiter(reqPath string, reqMethod string) *limiter.Limiter {if isEventURLPath(reqPath) {return r.limit120ReqPerHour@@ -210,8 +198,6 @@ func isSpaceViewerReadURLPath(reqPath string) bool {reqPath == "/spaces/:spaceID/versions"}-// getLimiter, based on reqPath & reqMethod, return instance of limiter.Limiter which needs to-// be applied for a request. It returns nil if the request is not rate limitedfunc (r *RateLimitMiddleware) getLimiter(reqPath string, reqMethod string) *limiter.Limiter {if strings.HasPrefix(reqPath, "/files/preview/") ||strings.HasPrefix(reqPath, "/files/thumbnail/") {diff --git a/server/pkg/middleware/request_logger.go b/server/pkg/middleware/request_logger.goindex de3bc1b5be..c81860dc59 100644--- a/server/pkg/middleware/request_logger.go+++ b/server/pkg/middleware/request_logger.go@@ -70,7 +70,6 @@ func shouldSkipBodyLog(method string, path string) bool {return false}-// Logger logs the details regarding an incoming requestfunc Logger(urlSanitizer func(_ *gin.Context) string) gin.HandlerFunc {return func(c *gin.Context) {startTime := time.Now()@@ -80,7 +79,6 @@ func Logger(urlSanitizer func(_ *gin.Context) string) gin.HandlerFunc {handler.Error(c, err)}rdr1 := io.NopCloser(bytes.NewBuffer(buf))- // Creating a new Buffer, because rdr1 will be readrdr2 := io.NopCloser(bytes.NewBuffer(buf))userAgent := c.GetHeader("User-Agent")@@ -116,7 +114,6 @@ func Logger(urlSanitizer func(_ *gin.Context) string) gin.HandlerFunc {}reqContextLogger.Info("incoming")c.Request.Body = rdr2- // Processing requestc.Next()statusCode := c.Writer.Status()latencyTime := time.Since(startTime)diff --git a/server/pkg/repo/collection_actions.go b/server/pkg/repo/collection_actions.goindex 5ef907afa4..04c8b17a88 100644--- a/server/pkg/repo/collection_actions.go+++ b/server/pkg/repo/collection_actions.go@@ -28,7 +28,6 @@ func (r *CollectionActionsRepository) Create(ctx context.Context, userID int64,return id, stacktrace.Propagate(err, "")}-// CreateBulk inserts multiple collection actions that only differ by fileID.func (r *CollectionActionsRepository) CreateBulk(ctx context.Context, userID int64, actorUserID int64, collectionID int64, fileIDs []int64, data map[string]interface{}, action string, isPending bool) error {if len(fileIDs) == 0 {return nildiff --git a/server/pkg/repo/emergency/recovery.go b/server/pkg/repo/emergency/recovery.goindex ab2ebfd976..991314a680 100644--- a/server/pkg/repo/emergency/recovery.go+++ b/server/pkg/repo/emergency/recovery.go@@ -40,11 +40,9 @@ func (repo *Repository) InsertIntoRecovery(ctx *gin.Context, contact ente.Contacreturn false, ente.NewBadRequestWithMessage("notice period should be greater than 24 hours")}waitTime := time.MicrosecondsAfterHours(contactRow.NoticePeriodInHrs)- // remind after 7 days.nextReminder := time.MicrosecondsAfterHours(24 * 7)if nextReminder >= waitTime {logrus.Warn("initial reminder is greater than wait time")- // remind in 1 day if notice period is less than 7 days.nextReminder = time.MicrosecondsAfterHours(24 * 1)}result, err := repo.DB.ExecContext(ctx, `INSERT INTO emergency_recovery (id,user_id, emergency_contact_id, status, wait_till, next_reminder_at) VALUES ($1, $2, $3, $4, $5, $6) on conflict DO NOTHING`,diff --git a/server/pkg/repo/emergency/repository.go b/server/pkg/repo/emergency/repository.goindex 711c7e6852..108b1ad557 100644--- a/server/pkg/repo/emergency/repository.go+++ b/server/pkg/repo/emergency/repository.go@@ -20,8 +20,6 @@ type ContactRow struct {EncryptedKey *string}-// HasActiveLegacyContact returns true when the user has at least one accepted-// legacy contact configured on their account.func (r *Repository) HasActiveLegacyContact(ctx context.Context, userID int64) (bool, error) {var exists boolerr := r.DB.QueryRowContext(ctx,diff --git a/server/pkg/repo/file.go b/server/pkg/repo/file.goindex d52808c07f..4f64862620 100644--- a/server/pkg/repo/file.go+++ b/server/pkg/repo/file.go@@ -364,8 +364,6 @@ func (repo *FileRepository) Update(file ente.File, fileSize int64, thumbnailSizereturn stacktrace.Propagate(err, "")}-// UpdateMagicAttributes updates the magic attributes for the list of files and update collection_files & collection-// which have this file.func (repo *FileRepository) UpdateMagicAttributes(ctx context.Context,fileUpdates []ente.UpdateMagicMetadata,diff --git a/server/pkg/repo/filedata/repository.go b/server/pkg/repo/filedata/repository.goindex d70773c4a4..fc3e17e059 100644--- a/server/pkg/repo/filedata/repository.go+++ b/server/pkg/repo/filedata/repository.go@@ -231,7 +231,6 @@ func (r *Repository) MoveBetweenBuckets(row filedata.Row, bucketID string, sourc// GetPendingSyncDataAndExtendLock in a transaction gets single file data row that has been deleted and pending sync is true and sync_lock_till is less than now_utc_micro_seconds() and extends the lock till newSyncLockTime// This is used to lock the file data row for deletion and extendfunc (r *Repository) GetPendingSyncDataAndExtendLock(ctx context.Context, newSyncLockTime int64, forDeletion bool) (*filedata.Row, error) {- // ensure newSyncLockTime is in the futureif newSyncLockTime < time.Now().Add(5*time.Minute).UnixMicro() {return nil, stacktrace.NewError("newSyncLockTime should be at least 5min in the future")}diff --git a/server/pkg/repo/trash.go b/server/pkg/repo/trash.goindex df3d97c344..a89dcfca77 100644--- a/server/pkg/repo/trash.go+++ b/server/pkg/repo/trash.go@@ -394,17 +394,6 @@ func (t *TrashRepository) GetUserIDToFileIDsMapForDeletion() (map[int64][]int64,// This delay ensures compliance with deletion locks.// The method orders the results by the 'updated_at' field in ascending order and limits the results to 'TrashDiffLimit' + 1.// If multiple files have the same 'updated_at' timestamp and are at the limit boundary, they are excluded to prevent partial scrubbing.-//-// Parameters:-//-// sinceUpdatedAt: The timestamp (in microseconds) to filter files that were deleted after this time.-//-// Returns:-//-// A slice of FileWithUpdatedAt: Each item contains a file ID and its corresponding 'updated_at' timestamp.-// error: If there is any issue in executing the query, an error is returned.-//-// Note: The method returns an empty slice if no matching files are found.func (t *TrashRepository) GetFileIdsForDroppingMetadata(sinceUpdatedAt int64) ([]FileWithUpdatedAt, error) {rows, err := t.DB.Query(`select file_id, updated_at from trash where is_deleted=true AND updated_at > $1diff --git a/server/pkg/repo/user.go b/server/pkg/repo/user.goindex 36a825330b..955e830af8 100644--- a/server/pkg/repo/user.go+++ b/server/pkg/repo/user.go@@ -455,7 +455,6 @@ func (repo *UserRepository) GetUsersWithIndividualPlanWhoHaveExceededStorageQuotif err != nil {return users, stacktrace.Propagate(err, "")}- // ignore deleted usersif strings.EqualFold(user.Hash, fmt.Sprintf(DELETED_EMAIL_HASH_FORMAT, &user.ID)) || len(encryptedEmail) == 0 {continue}diff --git a/server/pkg/utils/array/array.go b/server/pkg/utils/array/array.goindex ef18f05b07..346a710480 100644--- a/server/pkg/utils/array/array.go+++ b/server/pkg/utils/array/array.go@@ -1,22 +1,17 @@package array-// UniqueInt64 returns unique elements in the input arrayfunc UniqueInt64(input []int64) []int64 {visited := map[int64]bool{}var result []int64for _, value := range input {- // check if already the mapped- // variable is set to true or notif !visited[value] {visited[value] = true- // Append to result slice.result = append(result, value)}}return result}-// ContainsDuplicateInInt64Array returns true if the array contains duplicate elements.func ContainsDuplicateInInt64Array(input []int64) bool {visited := map[int64]bool{}for _, value := range input {@@ -28,14 +23,6 @@ func ContainsDuplicateInInt64Array(input []int64) bool {return false}-// FindMissingElementsInSecondList identifies elements in 'sourceList' that are not present in 'targetList'.-// Returns:-// - A slice of int64 representing the elements found in 'sourceList' but not in 'targetList'.-// If all elements of 'sourceList' are present in 'targetList', an empty slice is returned.-//-// Example usage:-// missingElements := FindMissingElementsInSecondList([]int64{1, 2, 3, 4}, []int64{2, 4, 6})-// fmt.Println(missingElements) // Output: [1, 3]func FindMissingElementsInSecondList(sourceList []int64, targetList []int64) []int64 {targetSet := make(map[int64]struct{})for _, item := range targetList {diff --git a/server/pkg/utils/auth/auth.go b/server/pkg/utils/auth/auth.goindex 16be3fdc7b..4ffa6d650e 100644--- a/server/pkg/utils/auth/auth.go+++ b/server/pkg/utils/auth/auth.go@@ -30,17 +30,12 @@ const (LinkDeviceTokenResponseKey = "linkDeviceToken")-// GenerateRandomBytes returns securely generated random bytes.func GenerateRandomBytes(n int) []byte {b := make([]byte, n)rand.Read(b)return b}-// GenerateRandomInt returns a securely generated random integer in [0, n).-//-// It will return an error if the system's secure random number generator fails-// to function correctly, in which case the caller should not continue.func GenerateRandomInt(n int64) (int64, error) {r, err := rand.Int(rand.Reader, big.NewInt(n))if err != nil {@@ -49,13 +44,10 @@ func GenerateRandomInt(n int64) (int64, error) {return r.Int64(), nil}-// GenerateURLSafeRandomString returns a URL-safe, base64 encoded-// securely generated random string.func GenerateURLSafeRandomString(s int) string {return base64.URLEncoding.EncodeToString(GenerateRandomBytes(s))}-// GetHashedPassword returns the has of a specified passwordfunc GetHashedPassword(password string) (string, error) {saltedBytes := []byte(password)hashedBytes, err := bcrypt.GenerateFromPassword(saltedBytes, bcrypt.DefaultCost)@@ -67,15 +59,12 @@ func GetHashedPassword(password string) (string, error) {return hash, nil}-// CompareHashes compares a bcrypt hashed password with its possible plaintext-// equivalent. Returns nil on success, or an error on failure.func CompareHashes(hash string, s string) error {existing := []byte(hash)incoming := []byte(s)return bcrypt.CompareHashAndPassword(existing, incoming)}-// GetUserID fetches the userID embedded in a request headerfunc GetUserID(header http.Header) int64 {userID, _ := strconv.ParseInt(header.Get("X-Auth-User-ID"), 10, 64)return userID@@ -126,8 +115,6 @@ func GetCastToken(c *gin.Context) string {return token}-// GetAccessTokenJWT fetches the JWT access token from the request header or query parameters.-// This token is issued by server on password verification of links that are protected by password.func GetAccessTokenJWT(c *gin.Context) string {token := c.GetHeader("X-Auth-Access-Token-JWT")if token == "" {diff --git a/server/pkg/utils/billing/billing.go b/server/pkg/utils/billing/billing.goindex 231b32c809..eccb721de7 100644--- a/server/pkg/utils/billing/billing.go+++ b/server/pkg/utils/billing/billing.go@@ -49,7 +49,6 @@ var CountriesInEU = []string{"SK",}-// GetPlans returns current billing plansfunc GetPlans() ente.BillingPlansPerAccount {var plans = make(ente.BillingPlansPerAccount)plans[ente.StripeIN] = getPlansIN()@@ -57,7 +56,6 @@ func GetPlans() ente.BillingPlansPerAccount {return plans}-// GetStripeClients returns stripe clients for all accountsfunc GetStripeClients() ente.StripeClientPerAccount {stripeClients := make(ente.StripeClientPerAccount)stripeClients[ente.StripeIN] = getStripeClient(viper.GetString("stripe.in.key"))@@ -101,7 +99,6 @@ func parsePricingFile(fileName string) ente.BillingPlansPerCountry {return plansPerCountry}-// GetFreeSubscription return a free subscription for a new signed up userfunc GetFreeSubscription(userID int64) ente.Subscription {return ente.Subscription{UserID: userID,diff --git a/server/pkg/utils/byteMarshaller/b64.go b/server/pkg/utils/byteMarshaller/b64.goindex 5b627098a6..e688bd2e6d 100644--- a/server/pkg/utils/byteMarshaller/b64.go+++ b/server/pkg/utils/byteMarshaller/b64.go@@ -5,17 +5,14 @@ import ("strings")-// Encode a [][]byte into a single string.func EncodeSlices(slices [][]byte) string {var strSlices []stringfor _, slice := range slices {strSlices = append(strSlices, base64.StdEncoding.EncodeToString(slice))}- // Join the encoded strings with a comma, which is not in the base64 alphabet.return strings.Join(strSlices, ",")}-// Decode a string back into a [][]byte.func DecodeString(encoded string) ([][]byte, error) {var byteSlices [][]bytefor str := range strings.SplitSeq(encoded, ",") {diff --git a/server/pkg/utils/config/config.go b/server/pkg/utils/config/config.goindex dcd733d75d..130d5a4376 100644--- a/server/pkg/utils/config/config.go+++ b/server/pkg/utils/config/config.go@@ -1,27 +1,3 @@-// The config package contains functions for configuring Viper.-//-// # Configuration-//-// We use the Viper package to read in configuration from YAML files. In-// addition, we also read in values from the OS environment. These values-// override the ones in the config files.-//-// The names of the OS environment variables should be-//-// - prefixed with 'ENTE_',-//-// - uppercased versions of the config file variable names,-//-// - dashes are replaced with '_',-//-// - for nested config variables, dots should be replaced with '_'.-//-// For example, the environment variable corresponding to-//-// foo:-// bar-baz: quux-//-// would be `ENTE_FOO_BAR_BAZ`.package configimport (@@ -35,14 +11,8 @@ import ()func ConfigureViper(environment string) error {- // Ask Viper to read in values from the environment. These values will- // override the values specified in the config files.viper.AutomaticEnv()- // Set the prefix for the environment variables that Viper will look for.viper.SetEnvPrefix("ENTE")- // Ask Viper to look for underscores (instead of dots) for nested configs.- // Also replace "-" with underscores since "-" cannot be used in environment- // variable names.viper.SetEnvKeyReplacer(strings.NewReplacer(".", "_", "-", "_"))viper.SetConfigFile("configurations/" + environment + ".yaml")@@ -122,13 +92,6 @@ func IsLocalEnvironment() bool {return evn == "" || evn == "local"}-// CredentialFilePath returns the path to an existing file in the credentials-// directory.-//-// This file must exist if we're running in a non-local configuration.-//-// By default, it search in the credentials/ directory, but that can be-// customized using the "credentials-dir" config option.func CredentialFilePath(name string) (string, error) {credentialsDir := viper.GetString("credentials-dir")if credentialsDir == "" {@@ -139,13 +102,6 @@ func CredentialFilePath(name string) (string, error) {return productionFilePath(path)}-// BillingConfigFilePath returns the path to an existing file in the-// billing directory.-//-// This file must exist if we're running in a non-local configuration.-//-// By default, it search in the data/billing directory, but that can be-// customized using the "billing-config-dir" config option.func BillingConfigFilePath(name string) (string, error) {billingConfigDir := viper.GetString("billing-config-dir")if billingConfigDir == "" {@@ -164,8 +120,6 @@ func productionFilePath(path string) (string, error) {if pathExists {return path, nil}- // The path must exist if we're running in production (or more precisely, in- // any non-local environment).if IsLocalEnvironment() {return "", nil}diff --git a/server/pkg/utils/email/email.go b/server/pkg/utils/email/email.goindex 0dc2dd8107..e2f1dccb26 100644--- a/server/pkg/utils/email/email.go+++ b/server/pkg/utils/email/email.go@@ -1,7 +1,3 @@-// The email package contains functions for directly sending emails.-//-// These functions can be used for directly sending emails to given email-// addresses. This is used for transactional emails, for example OTP requests.package emailimport (@@ -28,7 +24,6 @@ var knownInvalidEmailErrors = []string{"Invalid domain name",}-// NormalizeEmail returns a canonical form for case-insensitive email lookup and hashing.func NormalizeEmail(email string) string {return strings.ToLower(strings.TrimSpace(email))}@@ -36,8 +31,6 @@ func NormalizeEmail(email string) string {// https://datatracker.ietf.org/doc/html/rfc5322#section-2.1.1const base64LineLength = 900 // standard MIME line length for base64 content-// sanitizeHeaderValue removes CR/LF and other control characters from header values-// to prevent header injection and ensures values are single-line.func sanitizeHeaderValue(s string) string {if s == "" {return s@@ -45,11 +38,9 @@ func sanitizeHeaderValue(s string) string {var b strings.Builderb.Grow(len(s))for _, r := range s {- // Disallow CR and LF entirely in header valuesif r == '\r' || r == '\n' {continue}- // Strip other ASCII control chars except tabif r < 0x20 && r != '\t' {continue}@@ -58,7 +49,6 @@ func sanitizeHeaderValue(s string) string {return strings.TrimSpace(b.String())}-// containsCRLF checks for raw CR/LF which must not appear in addressesfunc containsCRLF(s string) bool {return strings.ContainsRune(s, '\r') || strings.ContainsRune(s, '\n')}@@ -68,14 +58,12 @@ func wrapToMaxLineLength(s string, maxLen int) string {if maxLen <= 0 {return s}- // Remove existing line breaks so we can re-wrap deterministically.clean := strings.ReplaceAll(strings.ReplaceAll(s, "\r", ""), "\n", "")if len(clean) <= maxLen {return clean}var b strings.Builder- // Grow buffer to avoid re-allocations; add extra space for newline characters.b.Grow(len(clean) + len(clean)/maxLen)for i := 0; i < len(clean); i += maxLen {end := min(i+maxLen, len(clean))@@ -102,7 +90,6 @@ func buildHTMLMIMEPart(htmlBody string) (string, error) {encodedBody.String() + "\n", nil}-// Send sends an emailfunc Send(toEmails []string, fromName string, fromEmail string, subject string, htmlBody string, inlineImages []map[string]interface{}) error {if len(toEmails) == 0 {return ente.ErrBadRequest@@ -129,7 +116,6 @@ func sendViaSMTP(toEmails []string, fromName string, fromEmail string, subject sauth = smtp.PlainAuth("", smtpUsername, smtpPassword, smtpServer)}- // Validate that no envelope addresses contain CR/LFif containsCRLF(fromEmail) {return stacktrace.Propagate(ente.ErrBadRequest, "invalid from email")}@@ -137,21 +123,17 @@ func sendViaSMTP(toEmails []string, fromName string, fromEmail string, subject sreturn stacktrace.Propagate(ente.ErrBadRequest, "invalid recipient email")}- // If a sender email is provided use it instead of the fromEmail.if smtpEmail != "" {fromEmail = smtpEmail}- // If a sender name is provided use it instead of the fromName.if smtpSenderName != "" {fromName = smtpSenderName}- // Sanitize header fields to prevent header injectioncleanFromName := sanitizeHeaderValue(fromName)cleanFromEmail := sanitizeHeaderValue(fromEmail)cleanSubject := sanitizeHeaderValue(subject)- // Construct 'emailAddresses' with comma-separated sanitized email addresses for headervar emailAddresses stringfor i, addr := range toEmails {if i != 0 {@@ -195,7 +177,6 @@ func sendViaSMTP(toEmails []string, fromName string, fromEmail string, subject semailMessage += "--boundary--"}- // Send the email to each recipientfor _, toEmail := range toEmails {err := sendMailWithEncryption(smtpServer, smtpPort, auth, fromEmail, []string{toEmail}, []byte(emailMessage), smtpEncryption)if err != nil {@@ -212,16 +193,11 @@ func sendViaSMTP(toEmails []string, fromName string, fromEmail string, subject sreturn nil}-// sendMailWithEncryption sends an email with the specified encryption type-// encryption can be one of:-// - "tls" or "ssl": Uses TLS/SSL encryption for the entire connection-// - "" (empty string) or any other value: No encryptionfunc sendMailWithEncryption(host, port string, auth smtp.Auth, from string, to []string, msg []byte, encryption string) error {addr := net.JoinHostPort(host, port)switch strings.ToLower(encryption) {case "tls", "ssl":- // For TLS/SSL, establish a secure connection directlytlsConfig := &tls.Config{ServerName: host,MinVersion: tls.VersionTLS12,@@ -241,12 +217,10 @@ func sendMailWithEncryption(host, port string, auth smtp.Auth, from string, to [return sendWithClient(client, auth, from, to, msg)default:- // No encryption, use standard SendMailreturn smtp.SendMail(addr, auth, from, to, msg)}}-// sendWithClient sends an email using an established SMTP clientfunc sendWithClient(client *smtp.Client, auth smtp.Auth, from string, to []string, msg []byte) error {if auth != nil {if err := client.Auth(auth); err != nil {@@ -311,13 +285,10 @@ func GetMaskedEmail(email string) string {}return maskedUsername + "@" + domain} else {- // Should ideally never happen, there should always be an @ symbolreturn "[invalid_email]"}}-// GetMaskedEmailForPublic masks an email for public display.-// Format: first 2 chars of username + masked remainder + @ + first char of domain + masked middle + last char of domainfunc GetMaskedEmailForPublic(email string) string {email = strings.TrimSpace(email)at := strings.LastIndex(email, "@")@@ -333,8 +304,6 @@ func GetMaskedEmailForPublic(email string) string {return maskedUsername + "@" + maskedDomain}-// maskForPublicUsername masks a username keeping the first 2 runes visible.-// Remaining runes are replaced with asterisks.func maskForPublicUsername(s string) string {runes := []rune(s)if len(runes) <= 2 {@@ -343,8 +312,6 @@ func maskForPublicUsername(s string) string {return string(runes[:2]) + strings.Repeat("*", len(runes)-2)}-// maskForPublicDomain masks a domain showing first and last rune.-// Middle runes are replaced with asterisks.func maskForPublicDomain(domain string) string {runes := []rune(domain)if len(runes) <= 2 {@@ -353,7 +320,6 @@ func maskForPublicDomain(domain string) string {return string(runes[0]) + strings.Repeat("*", len(runes)-2) + string(runes[len(runes)-1])}-// GetMaskedEmailWithHint masks both the username and non-TLD domain segments while keeping helpful hints.func GetMaskedEmailWithHint(email string) string {email = strings.TrimSpace(email)at := strings.LastIndex(email, "@")@@ -395,7 +361,6 @@ func maskEmailSegment(segment string) string {return segment[:1] + strings.Repeat("*", len(segment)-2) + segment[len(segment)-1:]}-// getMailBody generates the mail html body from provided template and datafunc getMailBody(templateName string, templateData map[string]interface{}) (string, error) {htmlbody := new(bytes.Buffer)t := template.Must(template.New(templateName).ParseFiles("mail-templates/" + templateName))@@ -406,11 +371,9 @@ func getMailBody(templateName string, templateData map[string]interface{}) (strireturn htmlbody.String(), nil}-// getMailBody generates the mail HTML body from the provided template and data, supporting inheritancefunc getMailBodyWithBase(baseTemplateName, templateName string, templateData map[string]interface{}) (string, error) {htmlBody := new(bytes.Buffer)- // Define paths for the base template and the specific templatebaseTemplate := "mail-templates/" + baseTemplateNamespecificTemplate := "mail-templates/" + templateName@@ -418,13 +381,11 @@ func getMailBodyWithBase(baseTemplateName, templateName string, templateData maplastPart := parts[len(parts)-1]baseTemplateID := strings.TrimSuffix(lastPart, path.Ext(lastPart))- // Parse the base and specific templates togethert, err := template.ParseFiles(baseTemplate, specificTemplate)if err != nil {return "", stacktrace.Propagate(err, "failed to parse templates")}- // Execute the base template with the provided dataerr = t.ExecuteTemplate(htmlBody, baseTemplateID, templateData)if err != nil {return "", stacktrace.Propagate(err, "failed to execute template")diff --git a/server/pkg/utils/file/file.go b/server/pkg/utils/file/file.goindex 9481d00782..24e9d4c4a6 100644--- a/server/pkg/utils/file/file.go+++ b/server/pkg/utils/file/file.go@@ -28,7 +28,6 @@ func DeleteAllFilesInDirectory(path string) error {return stacktrace.Propagate(err, "")}-// FreeSpace returns the free space in bytes on the disk where path is mounted.func FreeSpace(path string) (uint64, error) {var fs syscall.Statfs_terr := syscall.Statfs(path, &fs)@@ -38,9 +37,6 @@ func FreeSpace(path string) (uint64, error) {return fs.Bfree * uint64(fs.Bsize), nil}-// EnsureSufficientSpace Return an error if we risk running out of disk space if we try to download-// and write a file of size.-// This function keeps a buffer of 2 GB free space in its calculations.func EnsureSufficientSpace(size int64) error {if size < 0 {return fmt.Errorf("invalid file size: %d (must be non-negative)", size)@@ -54,7 +50,6 @@ func EnsureSufficientSpace(size int64) error {gb := uint64(1024) * 1024 * 1024bufferSpace := 2 * gb- // Check for potential overflow before additionif uint64(size) > (^uint64(0) - bufferSpace) {return fmt.Errorf("file size too large: %d bytes", size)}@@ -67,12 +62,8 @@ func EnsureSufficientSpace(size int64) error {return nil}-// Validate that fileName only contains alphanumeric characters, underscores, and hyphensvar validFileName = regexp.MustCompile(`^[a-zA-Z0-9_-]+$`)-// CreateTemporaryFile Create a file, and return both the path to the-// file, and the handle to the file.-// The caller must Close() the returned file if it is not nil.func CreateTemporaryFile(tempStorage string, tempFileName string) (string, *os.File, error) {fileName := strings.ReplaceAll(tempFileName, "/", "_")@@ -80,7 +71,6 @@ func CreateTemporaryFile(tempStorage string, tempFileName string) (string, *os.Freturn "", nil, fmt.Errorf("invalid filename after sanitization: contains non-alphanumeric characters (except _ and -)")}- // Use filepath.Join for safe path constructionfilePath := filepath.Join(tempStorage, fileName)f, err := os.Create(filePath)diff --git a/server/pkg/utils/handler/handler.go b/server/pkg/utils/handler/handler.goindex d892453afa..83782f5eda 100644--- a/server/pkg/utils/handler/handler.go+++ b/server/pkg/utils/handler/handler.go@@ -41,8 +41,6 @@ func BindJSON(c *gin.Context, obj any) error {return nil}-// Error parses the error, translates it into an HTTP response and aborts-// the requestfunc Error(c *gin.Context, err error) {unWrappedErr := errors.Unwrap(err)if unWrappedErr == nil {@@ -98,16 +96,11 @@ func logLevel(level log.Level) *log.Level {}func isRequestIOError(err error) bool {- // Tip: To trigger the "unexpected EOF" error, connect with:- //- // echo "GET /ping HTTP/1.0\r\nContent-Length: 300\r\n\r\n" | nc localhost 8080return errors.Is(err, io.ErrUnexpectedEOF) ||errors.Is(err, syscall.EPIPE) ||errors.Is(err, syscall.ECONNRESET)}-// If `err` directly maps to an HTTP status code, return the HTTP status code.-// Otherwise return 0.func httpStatusCode(err error) int {switch {case errors.Is(err, ente.ErrNotFound) ||diff --git a/server/pkg/utils/network/network.go b/server/pkg/utils/network/network.goindex 54aa32397d..ba6ea444f1 100644--- a/server/pkg/utils/network/network.go+++ b/server/pkg/utils/network/network.go@@ -31,7 +31,6 @@ func GetPrettyUA(ua string) string {return parsedUA.UserAgent.Family + ", " + parsedUA.Os.ToString()}-// GetClientInfo returns the client package and version from the request headersfunc GetClientInfo(gin *gin.Context) string {client := gin.GetHeader("X-Client-Package")version := gin.GetHeader("X-Client-Version")diff --git a/server/pkg/utils/random/generate.go b/server/pkg/utils/random/generate.goindex 56a5990de5..4918f088ee 100644--- a/server/pkg/utils/random/generate.go+++ b/server/pkg/utils/random/generate.go@@ -15,23 +15,15 @@ func GenerateSixDigitOtp() (string, error) {return fmt.Sprintf("%06d", n), nil}-// GenerateAlphaNumString returns AlphaNumeric code of given length-// which exclude number 0 and letter O. The code always starts with an-// alphabetfunc GenerateAlphaNumString(length int) (string, error) {- // Define the alphabet and numbers to be used in the string.alphabet := "ABCDEFGHIJKLMNPQRSTUVWXYZ"- // Define the alphabet and numbers to be used in the string.alphaNum := fmt.Sprintf("%s123456789", alphabet)- // Allocate a byte slice with the desired length.result := make([]byte, length)- // Generate the first letter as an alphabet.r0, err := auth.GenerateRandomInt(int64(len(alphabet)))if err != nil {return "", stacktrace.Propagate(err, "")}result[0] = alphabet[r0]- // Generate the remaining characters as alphanumeric.for i := 1; i < length; i++ {ri, err := auth.GenerateRandomInt(int64(len(alphaNum)))if err != nil {diff --git a/server/pkg/utils/rate_limit.go b/server/pkg/utils/rate_limit.goindex f699297d04..f8d58136b6 100644--- a/server/pkg/utils/rate_limit.go+++ b/server/pkg/utils/rate_limit.go@@ -4,10 +4,6 @@ import ("github.com/ulule/limiter/v3")-// NewRateLimiter will return instance of limiter.Limiter based on internal <limit>-<period>-// Examples: 5 reqs/sec: "5-S", 10 reqs/min: "10-M"-// 1000 reqs/hour: "1000-H", 2000 reqs/day: "2000-D"-// https://github.com/ulule/limiter/func NewRateLimiter(interval string) *limiter.Limiter {rate, err := limiter.NewRateFromFormatted(interval)if err != nil {diff --git a/server/pkg/utils/recover/wrap.go b/server/pkg/utils/recover/wrap.goindex d194a79aa6..da750e5216 100644--- a/server/pkg/utils/recover/wrap.go+++ b/server/pkg/utils/recover/wrap.go@@ -8,8 +8,6 @@ import (type Int64ToInt64DataFn func(userID int64) (int64, error)-// Int64ToInt64RecoverWrapper is a helper method to wrap a function of Int64ToInt64DataFn syntax with recover.-// This wrapper helps us in avoiding boilerplate code for panic recovery while invoking the input fn in a new goroutinefunc Int64ToInt64RecoverWrapper(input int64,fn Int64ToInt64DataFn,@@ -17,7 +15,6 @@ func Int64ToInt64RecoverWrapper() (err error) {defer func() {if x := recover(); x != nil {- // https://stackoverflow.com/questions/33167282/how-to-return-a-value-in-a-go-function-that-panics/33167433#33167433// we need to use named params if we want to return panic as errerr = stacktrace.Propagate(fmt.Errorf("%+v", x), "panic during GoInt64ToInt64Data")}diff --git a/server/pkg/utils/rollout/percentage.go b/server/pkg/utils/rollout/percentage.goindex 53c6d28177..975a7c0655 100644--- a/server/pkg/utils/rollout/percentage.go+++ b/server/pkg/utils/rollout/percentage.go@@ -6,7 +6,6 @@ import ("fmt")-// IsInPercentageRollout deterministically decides whether a user belongs to a rollout bucket.// nonce should remain constant for a given experiment so the same users stay opted-in.func IsInPercentageRollout(userID int64, nonce string, percentage int) bool {switch {diff --git a/server/pkg/utils/s3config/s3config.go b/server/pkg/utils/s3config/s3config.goindex 0b0df5ef03..6e20454bda 100644--- a/server/pkg/utils/s3config/s3config.go+++ b/server/pkg/utils/s3config/s3config.go@@ -13,8 +13,6 @@ import ("github.com/spf13/viper")-// S3Config is the file which abstracts away s3 related configs for clients.-//// Objects are replicated in multiple "data centers". Each data center is an// S3-compatible provider, and has an associated "bucket".//@@ -24,31 +22,22 @@ import (// centers. So as such, the constants used to specify these data centers in the// YAML configuration matter.type S3Config struct {- // A map from data centers to the name of the bucket used in that DC.- buckets map[string]string- // Primary (hot) data center- hotDC string- // Secondary (hot) data center- secondaryHotDC string- //Derived data data center for derived files like ml embeddings & preview files- derivedStorageDC string- // A map from data centers to S3 configurations- s3Configs map[string]*aws.Config- // A map from data centers to pre-created S3 clients- s3Clients map[string]s3.S3- // Indicates if compliance is enabled for the Wasabi DC.+ buckets map[string]string+ hotDC string+ secondaryHotDC string+ derivedStorageDC string+ s3Configs map[string]*aws.Config+ s3Clients map[string]s3.S3isWasabiComplianceEnabled bool// Indicates if local minio buckets are being used. Enables various// debugging workarounds; not tested/intended for production.areLocalBuckets bool- // FileDataConfig is the configuration for various file data.// If for particular object type, the bucket is not specified, it will// default to hotDC as the bucket with no replicas. Initially, this config won't support// existing objectType (file, thumbnail) and will be used for new objectTypes. In the future,// we can migrate existing objectTypes to this config.fileDataConfig FileDataConfig- // attachmentConfig is the configuration for contact and future user attachments.// If no explicit config is present, attachments default to hot storage with no replicas.attachmentConfig AttachmentConfig}@@ -253,12 +242,10 @@ func (config *S3Config) GetDerivedStorageS3Client() *s3.S3 {return &s3Client}-// Return the name of the hot Backblaze data centerfunc (config *S3Config) GetHotBackblazeDC() string {return dcB2EuropeCentral}-// Return the name of the hot Wasabi data centerfunc (config *S3Config) GetHotWasabiDC() string {return dcWasabiEuropeCentral_v3}@@ -267,7 +254,6 @@ func (config *S3Config) GetWasabiDerivedDC() string {return dcWasabiEuropeCentralDerived}-// Return the name of the cold Scaleway data centerfunc (config *S3Config) GetColdScalewayDC() string {return dcSCWEuropeFrance_v3}@@ -281,8 +267,6 @@ func (config *S3Config) ShouldDeleteFromDataCenter(dc string) bool {return dc != dcSCWEuropeFranceDeprecated && dc != dcSCWEuropeFranceLockedDeprecated && dc != dcWasabiEuropeCentralDeprecated}-// Return the name of the Wasabi DC if objects in that DC are kept under the-// Wasabi compliance lock. Otherwise return the empty string.func (config *S3Config) WasabiComplianceDC() string {if config.isWasabiComplianceEnabled {return dcWasabiEuropeCentral_v3diff --git a/server/pkg/utils/string/string.go b/server/pkg/utils/string/string.goindex 6244ca8f6b..3b42c05a6c 100644--- a/server/pkg/utils/string/string.go+++ b/server/pkg/utils/string/string.go@@ -1,7 +1,5 @@package string-// EmptyIfNil returns either the dereferenced string, or "" if the pointer is-// nil.func EmptyIfNil(sp *string) string {if sp == nil {return ""diff --git a/server/pkg/utils/time/time.go b/server/pkg/utils/time/time.goindex 362deb5983..9c25154ab3 100644--- a/server/pkg/utils/time/time.go+++ b/server/pkg/utils/time/time.go@@ -18,32 +18,26 @@ const (hoursInOneDay = 24)-// Microseconds returns the time in micro secondsfunc Microseconds() int64 {return time.Now().UnixNano() / 1000}-// Nanoseconds returns the time in nano secondsfunc Nanoseconds() int64 {return time.Now().UnixNano()}-// MicrosecondsAfterHours returns the time in micro seconds after noOfHoursfunc MicrosecondsAfterHours(noOfHours int32) int64 {return Microseconds() + int64(noOfHours)*MicroSecondsInOneHour}-// MicrosecondsAfterDays returns the time in micro seconds after noOfDaysfunc MicrosecondsAfterDays(noOfDays int) int64 {return Microseconds() + int64(noOfDays*24)*MicroSecondsInOneHour}-// MicrosecondsBeforeDays returns the time in micro seconds before noOfDaysfunc MicrosecondsBeforeDays(noOfDays int) int64 {return Microseconds() - int64(noOfDays*24)*MicroSecondsInOneHour}-// NDaysFromNow returns the time n days from now in micro secondsfunc NDaysFromNow(n int) int64 {return time.Now().AddDate(0, 0, n).UnixNano() / 1000}@@ -52,17 +46,14 @@ func NYearsFromNow(n int) int64 {return time.Now().AddDate(n, 0, 0).UnixNano() / 1000}-// NMinFromNow returns the time n min from now in micro secondsfunc NMinFromNow(n int64) int64 {return time.Now().Add(time.Minute*time.Duration(n)).UnixNano() / 1000}-// MicrosecondsBeforeMinutes returns the unix time n minutes before now in micro secondsfunc MicrosecondsBeforeMinutes(noOfMinutes int64) int64 {return Microseconds() - (MicroSecondsInOneMinute * noOfMinutes)}-// MicrosecondsAfterMinutes returns the unix time n minutes from now in micro secondsfunc MicrosecondsAfterMinutes(noOfMinutes int64) int64 {return Microseconds() + (MicroSecondsInOneMinute * noOfMinutes)}diff --git a/server/pkg/utils/ua/ua.go b/server/pkg/utils/ua/ua.goindex 6232d89f95..c7056ee2e2 100644--- a/server/pkg/utils/ua/ua.go+++ b/server/pkg/utils/ua/ua.go@@ -18,9 +18,6 @@ var (detectorErr error)-// Returns the type of device based on the user agent.-// Example: Desktop, Mobile, Tablet, TV, etc.-// Returns empty string if the user agent is invalid or the device type is not found, or err is not nil.func GetDeviceType(userAgent string) (string, error) {dd, err := getDetector()if err != nil {diff --git a/server/space/repo/web_push.go b/server/space/repo/web_push.goindex 83a71e5325..7a2eb29ac3 100644--- a/server/space/repo/web_push.go+++ b/server/space/repo/web_push.go@@ -12,7 +12,6 @@ import (const spaceWebPushLinkSubscriptionLimit = 10000-// ErrSpaceWebPushLinkSubscriptionLimit prevents an individual public link from growing without bound.var ErrSpaceWebPushLinkSubscriptionLimit = errors.New("space web push link subscription limit reached")func (r *WebPushRepository) UpsertAccountSubscription(diff --git a/server/tools/abort-unfinished-multipart-uploads/main.go b/server/tools/abort-unfinished-multipart-uploads/main.goindex b328af4c99..81b97b268b 100644--- a/server/tools/abort-unfinished-multipart-uploads/main.go+++ b/server/tools/abort-unfinished-multipart-uploads/main.go@@ -32,9 +32,6 @@ func main() {s3Client := s3.New(sess)- // - List all multipart uploads- // - Delete the ones that are older than x days (but only if `--confirm` is specified)-listOut, err := s3Client.ListMultipartUploads(&s3.ListMultipartUploadsInput{Bucket: aws.String(bucket),})@@ -49,7 +46,6 @@ func main() {fmt.Printf("Warning: Found more than 1000 pending multipart uploads. We were not expecting this many.")}- // 20 days agocutoff := time.Now().AddDate(0, 0, -20)fmt.Printf("Cutoff: %v\n", cutoff)diff --git a/server/tools/pkg/cli/aws.go b/server/tools/pkg/cli/aws.goindex 599e3543a1..9007591c2e 100644--- a/server/tools/pkg/cli/aws.go+++ b/server/tools/pkg/cli/aws.go@@ -9,50 +9,6 @@ import ("github.com/aws/aws-sdk-go/aws/session")-// ParseAndCreateSession returns a Session object, emulating AWS CLI-// configuration.-//-// This is a convenience method to create CLI tools that behave similar to AWS-// CLI tools in where they pick up their configuration and credential from.-//-// It'll add and parse two command line flags: `--profile` and `--endpoint-url`.-//-// Beyond that, the method will pick up the S3 configuration and credentials-// from the same standard places where aws-cli looks for them:-//-// https://docs.aws.amazon.com/sdk-for-go/v1/developer-guide/configuring-sdk.html-//-// As a tldr, the easiest way to use this might be to add a new AWS profile:-//-// # ~/.aws/config-// [profile wasabi-test-compliance]-// region = eu-central-2-//-// # ~/.aws/credentials-// [wasabi-test-compliance]-// aws_access_key_id = test-// aws_secret_access_key = test-//-// And `export AWS_PROFILE=wasabi-test-compliance`, or provide it to the-// commands via the `--profile` flag.-//-// Alternatively, if you don't wish to use AWS profiles, then you can provide-// these values using the standard AWS environment variables.-//-// export AWS_REGION=eu-central-2-// export AWS_ACCESS_KEY_ID=test-// export AWS_SECRET_ACCESS_KEY=test-//-// > Tip: If your shell is configured to do so, you can add a leading space `-//-// export AWS_SECRET_....` to avoid preserving these secrets in your shell-// history.-//-// The endpoint to connect to can be either passed as an (optional) method-// parameter, or can be specified at runtime using the `--endpoint-url` flag.-//-// S3ForcePathStyle can be set to true when connecting to locally running MinIO-// instances where each bucket will not have a DNS.func ParseAndCreateSession(endpointURL string, S3ForcePathStyle bool) (*session.Session, error) {logLevel := aws.LogDebugWithHTTPBodycliProfile := flag.String("profile", "AWS_PROFILE",@@ -66,7 +22,6 @@ func ParseAndCreateSession(endpointURL string, S3ForcePathStyle bool) (*session.profile = os.Getenv("AWS_PROFILE")}- // Override the passed in value with the CLI always.if *cliEndpointURL != "" {endpointURL = *cliEndpointURL}diff --git a/server/tools/test-wasabi-compliance/main.go b/server/tools/test-wasabi-compliance/main.goindex 6a3ddc0e65..14d99f7f3d 100644--- a/server/tools/test-wasabi-compliance/main.go+++ b/server/tools/test-wasabi-compliance/main.go@@ -19,7 +19,6 @@ const ()func main() {- // Can be overridden on the command line with `--endpoint-url`endpointURL := "https://s3.eu-central-2.wasabisys.com"onlyDelete := false@@ -45,17 +44,6 @@ func main() {fmt.Println("Checklist completed successfully")}-// # Sequence 1-//-// - Get and print the current compliance settings for the test Wasabi bucket.-// - Update the compliance settings to set RetentionDays = 1.-// - Get and verify the updated settings.-// - Put an object into the bucket.-// - Ensure it cannot be deleted or overwritten.-// - Get and print the compliance settings for the test object in this bucket.-// - Disable the conditional hold for the object.-// - Ensure it still cannot be deleted (we'll need to wait for a day).-// - Print and verify the updated compliance settings.func sequence1(s3Client *s3.S3) error {_, err := getAndPrintBucketCompliance(s3Client)if err != nil {@@ -110,10 +98,6 @@ func sequence1(s3Client *s3.S3) error {return nil}-// # Sequence 2-//-// - Get and print the object's info.-// - Delete the object. This time it should succeed.func sequence2(s3Client *s3.S3) error {_, err := getAndPrintObjectCompliance(s3Client)if err != nil {@@ -128,8 +112,6 @@ func sequence2(s3Client *s3.S3) error {return nil}-// Operations-func getAndPrintBucketCompliance(s3Client *s3.S3) (*wasabi.GetBucketComplianceOutput, error) {out, err := wasabi.GetBucketCompliance(s3Client, &wasabi.GetBucketComplianceInput{Bucket: aws.String(bucket),