Skip to content

armgit / ente

Public Imported from GitHub
0

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

Prune server API comments

Manav Rathif232726ec4bd
diff --git a/server/pkg/api/admin.go b/server/pkg/api/admin.go
index 543596e9fa..ad83d591db 100644
--- a/server/pkg/api/admin.go
+++ b/server/pkg/api/admin.go
@@ -37,7 +37,6 @@ import (
"github.com/gin-gonic/gin"
)
-// AdminHandler exposes request handlers for all admin related requests
type AdminHandler struct {
QueueRepo *repo.QueueRepository
UserRepo *repo.UserRepository
@@ -59,7 +58,6 @@ type AdminHandler struct {
StorageBonusCtl *storagebonusCtrl.Controller
}
-// Duration for which an admin's token is considered valid
const AdminTokenValidityInMinutes = 10
func (h *AdminHandler) SendMail(c *gin.Context) {
diff --git a/server/pkg/api/authenticator.go b/server/pkg/api/authenticator.go
index 9c92386ef5..0bf81a72dd 100644
--- a/server/pkg/api/authenticator.go
+++ b/server/pkg/api/authenticator.go
@@ -13,12 +13,10 @@ import (
"github.com/google/uuid"
)
-// AuthenticatorHandler expose request handlers authenticator related endpoints
type AuthenticatorHandler struct {
Controller *authenticaor.Controller
}
-// CreateKey...
func (h *AuthenticatorHandler) CreateKey(c *gin.Context) {
var request model.CreateKeyRequest
if err := handler.BindJSON(c, &request); err != nil {
@@ -33,7 +31,6 @@ func (h *AuthenticatorHandler) CreateKey(c *gin.Context) {
c.Status(http.StatusOK)
}
-// GetKey...
func (h *AuthenticatorHandler) GetKey(c *gin.Context) {
resp, err := h.Controller.GetKey(c)
if err != nil {
@@ -43,7 +40,6 @@ func (h *AuthenticatorHandler) GetKey(c *gin.Context) {
c.JSON(http.StatusOK, resp)
}
-// CreateEntity...
func (h *AuthenticatorHandler) CreateEntity(c *gin.Context) {
var request model.CreateEntityRequest
if err := handler.BindJSON(c, &request); err != nil {
@@ -58,7 +54,6 @@ func (h *AuthenticatorHandler) CreateEntity(c *gin.Context) {
c.JSON(http.StatusOK, resp)
}
-// UpdateEntity...
func (h *AuthenticatorHandler) UpdateEntity(c *gin.Context) {
var request model.UpdateEntityRequest
if err := handler.BindJSON(c, &request); err != nil {
@@ -73,7 +68,6 @@ func (h *AuthenticatorHandler) UpdateEntity(c *gin.Context) {
c.Status(http.StatusOK)
}
-// DeleteEntity...
func (h *AuthenticatorHandler) DeleteEntity(c *gin.Context) {
id, err := uuid.Parse(c.Query("id"))
if err != nil {
@@ -88,7 +82,6 @@ func (h *AuthenticatorHandler) DeleteEntity(c *gin.Context) {
c.Status(http.StatusOK)
}
-// GetDiff...
func (h *AuthenticatorHandler) GetDiff(c *gin.Context) {
var request model.GetEntityDiffRequest
if err := c.ShouldBindQuery(&request); err != nil {
diff --git a/server/pkg/api/billing.go b/server/pkg/api/billing.go
index 62dc1f5587..5aa71adf1b 100644
--- a/server/pkg/api/billing.go
+++ b/server/pkg/api/billing.go
@@ -25,7 +25,6 @@ import (
"github.com/gin-gonic/gin"
)
-// BillingHandler exposes request handlers for all billing related requests
type BillingHandler struct {
Controller *controller.BillingController
AppStoreController *controller.AppStoreController
@@ -33,7 +32,6 @@ type BillingHandler struct {
StripeController *controller.StripeController
}
-// GetPlansV2 returns the available default Stripe account subscription plans for the country the client request came from the
func (h *BillingHandler) GetPlansV2(c *gin.Context) {
plans := h.Controller.GetPlansV2(network.GetClientCountry(c), ente.DefaultStripeAccountCountry)
freePlan := billing.GetFreePlan()
@@ -50,7 +48,6 @@ func (h *BillingHandler) GetPlansV2(c *gin.Context) {
})
}
-// GetUserPlans returns the available plans from the stripe account and the country the user's existing plan is from
func (h *BillingHandler) GetUserPlans(c *gin.Context) {
userID := auth.GetUserID(c.Request.Header)
plans, err := h.Controller.GetUserPlans(c, userID)
@@ -73,8 +70,6 @@ func (h *BillingHandler) GetUserPlans(c *gin.Context) {
})
}
-// GetStripeAccountCountry returns the stripe account country the user's existing plan is from
-// if he doesn't have default stripe account country is returned
func (h *BillingHandler) GetStripeAccountCountry(c *gin.Context) {
userID := auth.GetUserID(c.Request.Header)
stripeAccountCountry, err := h.Controller.GetStripeAccountCountry(userID)
@@ -96,7 +91,6 @@ func (h *BillingHandler) GetUsage(c *gin.Context) {
})
}
-// GetSubscription returns the current subscription for a user if any
func (h *BillingHandler) GetSubscription(c *gin.Context) {
userID := auth.GetUserID(c.Request.Header)
subscription, err := h.Controller.GetSubscription(c, userID)
@@ -109,7 +103,6 @@ func (h *BillingHandler) GetSubscription(c *gin.Context) {
})
}
-// VerifySubscription verifies and returns the verified subscription
func (h *BillingHandler) VerifySubscription(c *gin.Context) {
userID := auth.GetUserID(c.Request.Header)
var request ente.SubscriptionVerificationRequest
@@ -128,7 +121,6 @@ func (h *BillingHandler) VerifySubscription(c *gin.Context) {
})
}
-// AndroidNotificationHandler handles the notifications from PlayStore
func (h *BillingHandler) AndroidNotificationHandler(c *gin.Context) {
var request ente.AndroidNotification
if err := handler.BindJSON(c, &request); err != nil {
@@ -159,7 +151,6 @@ func (h *BillingHandler) AndroidNotificationHandler(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{})
}
-// IOSNotificationHandler handles the notifications from AppStore
func (h *BillingHandler) IOSNotificationHandler(c *gin.Context) {
var notification appstore.SubscriptionNotification
if err := handler.BindJSON(c, &notification); err != nil {
@@ -176,7 +167,6 @@ func (h *BillingHandler) IOSNotificationHandler(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{})
}
-// GetCheckoutSession generates and returns stripe checkout session for subscription purchase
func (h *BillingHandler) GetCheckoutSession(c *gin.Context) {
userID := auth.GetUserID(c.Request.Header)
productID := c.Query("productID")
@@ -227,7 +217,6 @@ func (h *BillingHandler) StripeUSNotificationHandler(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{})
}
-// StripeUpdateSubscription handles stripe subscription updates requests
func (h *BillingHandler) StripeUpdateSubscription(c *gin.Context) {
userID := auth.GetUserID(c.Request.Header)
var request ente.StripeUpdateRequest
@@ -243,7 +232,6 @@ func (h *BillingHandler) StripeUpdateSubscription(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{"result": s})
}
-// StripeCancelSubscription handles stripe subscription cancel requests
func (h *BillingHandler) StripeCancelSubscription(c *gin.Context) {
userID := auth.GetUserID(c.Request.Header)
subscription, err := h.StripeController.UpdateSubscriptionCancellationStatus(userID, true)
@@ -254,7 +242,6 @@ func (h *BillingHandler) StripeCancelSubscription(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{"subscription": subscription})
}
-// StripeActivateSubscription handles stripe subscription activation requests
func (h *BillingHandler) StripeActivateSubscription(c *gin.Context) {
userID := auth.GetUserID(c.Request.Header)
subscription, err := h.StripeController.UpdateSubscriptionCancellationStatus(userID, false)
@@ -265,7 +252,6 @@ func (h *BillingHandler) StripeActivateSubscription(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{"subscription": subscription})
}
-// GetStripeCustomerPortal handles stripe customer portal url retrieval request
func (h *BillingHandler) GetStripeCustomerPortal(c *gin.Context) {
userID := auth.GetUserID(c.Request.Header)
redirectRootURL, err := h.Controller.GetRedirectURL(c)
diff --git a/server/pkg/api/cast.go b/server/pkg/api/cast.go
index 032434b751..de40bc222f 100644
--- a/server/pkg/api/cast.go
+++ b/server/pkg/api/cast.go
@@ -17,7 +17,6 @@ import (
"github.com/google/uuid"
)
-// CastHandler exposes request handlers for publicly accessible collections
type CastHandler struct {
FileCtrl *controller.FileController
CollectionCtrl *collections.CollectionController
@@ -98,7 +97,6 @@ func (h *CastHandler) InsertCastData(c *gin.Context) {
})
}
-// RevokeAllToken disable all active cast token for a user
func (h *CastHandler) RevokeAllToken(c *gin.Context) {
err := h.Ctrl.RevokeAllToken(c)
if err != nil {
@@ -121,12 +119,10 @@ func (h *CastHandler) GetCastData(c *gin.Context) {
}
-// GetFile redirects the request to the file location
func (h *CastHandler) GetFile(c *gin.Context) {
h.getFileForType(c, ente.FILE)
}
-// GetThumbnail redirects the request to the file's thumbnail location
func (h *CastHandler) GetThumbnail(c *gin.Context) {
h.getFileForType(c, ente.THUMBNAIL)
}
@@ -143,7 +139,6 @@ func (h *CastHandler) GetThumbnailURLV3(c *gin.Context) {
writeFileURLV3(c, url, err)
}
-// GetCollection redirects the request to the collection location
func (h *CastHandler) GetCollection(c *gin.Context) {
collection, err := h.CollectionCtrl.GetCastCollection(c)
if err != nil {
@@ -155,7 +150,6 @@ func (h *CastHandler) GetCollection(c *gin.Context) {
})
}
-// GetDiff returns the diff within a collection since a timestamp
func (h *CastHandler) GetDiff(c *gin.Context) {
sinceTime, err := strconv.ParseInt(c.Query("sinceTime"), 10, 64)
if err != nil {
diff --git a/server/pkg/api/collection.go b/server/pkg/api/collection.go
index 0baa50b5a8..21c6183257 100644
--- a/server/pkg/api/collection.go
+++ b/server/pkg/api/collection.go
@@ -15,12 +15,10 @@ import (
"github.com/gin-gonic/gin"
)
-// CollectionHandler exposes request handlers for all collection related requests
type CollectionHandler struct {
Controller *collections.CollectionController
}
-// Create creates a collection
func (h *CollectionHandler) Create(c *gin.Context) {
log.Info("Collection create")
var collection ente.Collection
@@ -42,7 +40,6 @@ func (h *CollectionHandler) Create(c *gin.Context) {
})
}
-// GetCollectionByID returns the collection for given ID.
func (h *CollectionHandler) GetCollectionByID(c *gin.Context) {
cID, err := strconv.ParseInt(c.Param("collectionID"), 10, 64)
if err != nil {
@@ -61,12 +58,10 @@ func (h *CollectionHandler) GetCollectionByID(c *gin.Context) {
}
// Deprecated: Remove once rps goes to 0.
-// Get returns the list of collections accessible to a user.
func (h *CollectionHandler) Get(c *gin.Context) {
h.GetV2(c)
}
-// GetV2 returns the list of collections accessible to a user
func (h *CollectionHandler) GetV2(c *gin.Context) {
userID := auth.GetUserID(c.Request.Header)
sinceTime, _ := strconv.ParseInt(c.Query("sinceTime"), 10, 64)
@@ -86,7 +81,6 @@ func (h *CollectionHandler) GetV2(c *gin.Context) {
})
}
-// GetWithLimit returns owned and shared collections accessible to a user
func (h *CollectionHandler) GetWithLimit(c *gin.Context) {
userID := auth.GetUserID(c.Request.Header)
sinceTime, _ := strconv.ParseInt(c.Query("sinceTime"), 10, 64)
@@ -115,7 +109,6 @@ func (h *CollectionHandler) GetWithLimit(c *gin.Context) {
})
}
-// Share shares a collection with a user
func (h *CollectionHandler) Share(c *gin.Context) {
var request ente.AlterShareRequest
if err := handler.BindJSON(c, &request); err != nil {
@@ -132,7 +125,6 @@ func (h *CollectionHandler) Share(c *gin.Context) {
})
}
-// BulkShare shares up to 100 collections with one user.
func (h *CollectionHandler) BulkShare(c *gin.Context) {
var request ente.BulkCollectionShareRequest
if err := handler.BindJSON(c, &request); err != nil {
@@ -161,7 +153,6 @@ func (h *CollectionHandler) JoinLink(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{})
}
-// ShareURL generates a publicly sharable url
func (h *CollectionHandler) ShareURL(c *gin.Context) {
var request ente.CreatePublicAccessTokenRequest
if err := handler.BindJSON(c, &request); err != nil {
@@ -178,7 +169,6 @@ func (h *CollectionHandler) ShareURL(c *gin.Context) {
})
}
-// UpdateShareURL generates a publicly sharable url
func (h *CollectionHandler) UpdateShareURL(c *gin.Context) {
var req ente.UpdatePublicAccessTokenRequest
if err := handler.BindJSON(c, &req); err != nil {
@@ -195,7 +185,6 @@ func (h *CollectionHandler) UpdateShareURL(c *gin.Context) {
})
}
-// UnShareURL disable all shared urls for the given collectionID
func (h *CollectionHandler) UnShareURL(c *gin.Context) {
cID, err := strconv.ParseInt(c.Param("collectionID"), 10, 64)
if err != nil {
@@ -211,7 +200,6 @@ func (h *CollectionHandler) UnShareURL(c *gin.Context) {
c.Status(http.StatusOK)
}
-// UnShare unshares a collection with a user
func (h *CollectionHandler) UnShare(c *gin.Context) {
var request ente.AlterShareRequest
if err := handler.BindJSON(c, &request); err != nil {
@@ -228,7 +216,6 @@ func (h *CollectionHandler) UnShare(c *gin.Context) {
})
}
-// BulkUnShare revokes one user's access to up to 100 collections.
func (h *CollectionHandler) BulkUnShare(c *gin.Context) {
var request ente.BulkCollectionUnshareRequest
if err := handler.BindJSON(c, &request); err != nil {
@@ -243,7 +230,6 @@ func (h *CollectionHandler) BulkUnShare(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{"results": results})
}
-// Leave allows user to leave a shared collection, which is not owned by them
func (h *CollectionHandler) Leave(c *gin.Context) {
cID, err := strconv.ParseInt(c.Param("collectionID"), 10, 64)
if err != nil {
@@ -258,7 +244,6 @@ func (h *CollectionHandler) Leave(c *gin.Context) {
c.Status(http.StatusOK)
}
-// AddFiles adds files to a collection
func (h *CollectionHandler) AddFiles(c *gin.Context) {
var request ente.AddFilesRequest
if err := handler.BindJSON(c, &request); err != nil {
@@ -277,7 +262,6 @@ func (h *CollectionHandler) AddFiles(c *gin.Context) {
c.Status(http.StatusOK)
}
-// RestoreFiles adds files from trash to given collection
func (h *CollectionHandler) RestoreFiles(c *gin.Context) {
var request ente.AddFilesRequest
if err := handler.BindJSON(c, &request); err != nil {
@@ -297,7 +281,6 @@ func (h *CollectionHandler) RestoreFiles(c *gin.Context) {
c.Status(http.StatusOK)
}
-// Movefiles from one collection to another
func (h *CollectionHandler) MoveFiles(c *gin.Context) {
var request ente.MoveFilesRequest
if err := handler.BindJSON(c, &request); err != nil {
@@ -320,7 +303,6 @@ func (h *CollectionHandler) MoveFiles(c *gin.Context) {
c.Status(http.StatusOK)
}
-// RemoveFilesV3 allow removing files from a collection when files and collection belong to two different users
func (h *CollectionHandler) RemoveFilesV3(c *gin.Context) {
var request ente.RemoveFilesV3Request
if err := handler.BindJSON(c, &request); err != nil {
@@ -358,7 +340,6 @@ func (h *CollectionHandler) SuggestDeleteInSharedCollection(c *gin.Context) {
c.Status(http.StatusOK)
}
-// GetDiffV2 returns the diff within a collection since a timestamp
func (h *CollectionHandler) GetDiffV2(c *gin.Context) {
userID := auth.GetUserID(c.Request.Header)
cID, _ := strconv.ParseInt(c.Query("collectionID"), 10, 64)
@@ -374,7 +355,6 @@ func (h *CollectionHandler) GetDiffV2(c *gin.Context) {
})
}
-// GetFile returns the diff within a collection since a timestamp
func (h *CollectionHandler) GetFile(c *gin.Context) {
cID, _ := strconv.ParseInt(c.Query("collectionID"), 10, 64)
fileID, _ := strconv.ParseInt(c.Query("fileID"), 10, 64)
@@ -388,7 +368,6 @@ func (h *CollectionHandler) GetFile(c *gin.Context) {
})
}
-// GetSharees returns the list of users a collection has been shared with
func (h *CollectionHandler) GetSharees(c *gin.Context) {
userID := auth.GetUserID(c.Request.Header)
cID, _ := strconv.ParseInt(c.Query("collectionID"), 10, 64)
@@ -418,7 +397,6 @@ func (h *CollectionHandler) TrashV3(c *gin.Context) {
c.Status(http.StatusOK)
}
-// Rename updates the collection's name
func (h *CollectionHandler) Rename(c *gin.Context) {
var request ente.RenameRequest
if err := handler.BindJSON(c, &request); err != nil {
@@ -432,7 +410,6 @@ func (h *CollectionHandler) Rename(c *gin.Context) {
c.Status(http.StatusOK)
}
-// Updates the magic metadata for a collection
func (h *CollectionHandler) PrivateMagicMetadataUpdate(c *gin.Context) {
var request ente.UpdateCollectionMagicMetadata
if err := handler.BindJSON(c, &request); err != nil {
@@ -446,7 +423,6 @@ func (h *CollectionHandler) PrivateMagicMetadataUpdate(c *gin.Context) {
c.Status(http.StatusOK)
}
-// PublicMagicMetadataUpdate updates the public magic metadata for a collection
func (h *CollectionHandler) PublicMagicMetadataUpdate(c *gin.Context) {
var request ente.UpdateCollectionMagicMetadata
if err := handler.BindJSON(c, &request); err != nil {
@@ -460,7 +436,6 @@ func (h *CollectionHandler) PublicMagicMetadataUpdate(c *gin.Context) {
c.Status(http.StatusOK)
}
-// ShareeMagicMetadataUpdate updates sharees magic metadata for shared collection.
func (h *CollectionHandler) ShareeMagicMetadataUpdate(c *gin.Context) {
var request ente.UpdateCollectionMagicMetadata
if err := handler.BindJSON(c, &request); err != nil {
diff --git a/server/pkg/api/collection_actions.go b/server/pkg/api/collection_actions.go
index 7ce727e9f2..14490565e6 100644
--- a/server/pkg/api/collection_actions.go
+++ b/server/pkg/api/collection_actions.go
@@ -19,7 +19,6 @@ type CollectionActionsHandler struct {
const collectionActionsLimit = 2000
-// ListPendingRemove returns pending REMOVE actions after the provided updatedAt timestamp
func (h *CollectionActionsHandler) ListPendingRemove(c *gin.Context) {
userID := auth.GetUserID(c.Request.Header)
updatedAfter, err := parseSinceTime(c.Query("sinceTime"))
@@ -38,7 +37,6 @@ func (h *CollectionActionsHandler) ListPendingRemove(c *gin.Context) {
})
}
-// ListDeleteSuggestions returns pending DELETE_SUGGESTED actions for the actor.
func (h *CollectionActionsHandler) ListDeleteSuggestions(c *gin.Context) {
userID := auth.GetUserID(c.Request.Header)
updatedAfter, err := parseSinceTime(c.Query("sinceTime"))
@@ -61,7 +59,6 @@ type rejectDeleteSuggestionsRequest struct {
FileIDs []int64 `json:"fileIDs" binding:"required"`
}
-// RejectDeleteSuggestions clears pending DELETE_SUGGESTED actions for the provided file IDs.
func (h *CollectionActionsHandler) RejectDeleteSuggestions(c *gin.Context) {
userID := auth.GetUserID(c.Request.Header)
var req rejectDeleteSuggestionsRequest
diff --git a/server/pkg/api/comments.go b/server/pkg/api/comments.go
index 049e779935..5de1fe6f9a 100644
--- a/server/pkg/api/comments.go
+++ b/server/pkg/api/comments.go
@@ -14,7 +14,6 @@ import (
const maxCommentPayloadBytes = 20 * 1024
-// CommentsHandler exposes authenticated comment APIs.
type CommentsHandler struct {
Controller *social.CommentsController
}
diff --git a/server/pkg/api/emergency.go b/server/pkg/api/emergency.go
index 2075937787..601e88b16c 100644
--- a/server/pkg/api/emergency.go
+++ b/server/pkg/api/emergency.go
@@ -11,12 +11,10 @@ import (
"net/http"
)
-// EmergencyHandler contains handlers for managing emergency contacts
type EmergencyHandler struct {
Controller *emergency.Controller
}
-// AddContact adds a new emergency contact for current user
func (h *EmergencyHandler) AddContact(c *gin.Context) {
var request ente.AddContact
if err := handler.BindJSON(c, &request); err != nil {
diff --git a/server/pkg/api/family.go b/server/pkg/api/family.go
index 83baf0ed61..2cec6dee48 100644
--- a/server/pkg/api/family.go
+++ b/server/pkg/api/family.go
@@ -7,23 +7,16 @@ import (
"github.com/ente/stacktrace"
"github.com/google/uuid"
- // "github.com/gin-contrib/requestid"
- // log "github.com/sirupsen/logrus"
-
"github.com/ente/museum/ente"
"github.com/ente/museum/pkg/utils/auth"
"github.com/ente/museum/pkg/utils/handler"
-
- // "github.com/ente/museum/pkg/utils/time"
"github.com/gin-gonic/gin"
)
-// FamilyHandler contains handlers for managing family plans
type FamilyHandler struct {
Controller *family.Controller
}
-// CreateFamily creates a family with current user as admin member
func (h *FamilyHandler) CreateFamily(c *gin.Context) {
err := h.Controller.CreateFamily(c, auth.GetUserID(c.Request.Header))
@@ -34,7 +27,6 @@ func (h *FamilyHandler) CreateFamily(c *gin.Context) {
c.Status(http.StatusOK)
}
-// InviteMember sends out invitation to a user for joining acting user's family plan
func (h *FamilyHandler) InviteMember(c *gin.Context) {
var request ente.InviteMemberRequest
if err := handler.BindJSON(c, &request); err != nil {
@@ -50,7 +42,6 @@ func (h *FamilyHandler) InviteMember(c *gin.Context) {
c.Status(http.StatusOK)
}
-// FetchMembers returns information about members who have been invited (only for admin) or are part of family plan
func (h *FamilyHandler) FetchMembers(c *gin.Context) {
members, err := h.Controller.FetchMembers(c, auth.GetUserID(c.Request.Header))
@@ -61,7 +52,6 @@ func (h *FamilyHandler) FetchMembers(c *gin.Context) {
c.JSON(http.StatusOK, members)
}
-// RemoveMember removes the member from the family group
func (h *FamilyHandler) RemoveMember(c *gin.Context) {
familyMembershipID, err := uuid.Parse(c.Param("id"))
if err != nil {
@@ -77,7 +67,6 @@ func (h *FamilyHandler) RemoveMember(c *gin.Context) {
c.Status(http.StatusOK)
}
-// Leave family
func (h *FamilyHandler) Leave(c *gin.Context) {
err := h.Controller.LeaveFamily(c, auth.GetUserID(c.Request.Header))
if err != nil {
@@ -87,7 +76,6 @@ func (h *FamilyHandler) Leave(c *gin.Context) {
c.Status(http.StatusOK)
}
-// RevokeInvite removes the invite for given user as long it's still in invite state
func (h *FamilyHandler) RevokeInvite(c *gin.Context) {
familyMembershipID, err := uuid.Parse(c.Param("id"))
if err != nil {
@@ -104,7 +92,6 @@ func (h *FamilyHandler) RevokeInvite(c *gin.Context) {
c.Status(http.StatusOK)
}
-// AcceptInvite allows user to join the family based on the token
func (h *FamilyHandler) AcceptInvite(c *gin.Context) {
var request ente.AcceptInviteRequest
if err := handler.BindJSON(c, &request); err != nil {
@@ -120,7 +107,6 @@ func (h *FamilyHandler) AcceptInvite(c *gin.Context) {
c.JSON(http.StatusOK, response)
}
-// ModifyStorageLimit allows adminUser to Modify the storage for a member in the Family.
func (h *FamilyHandler) ModifyStorageLimit(c *gin.Context) {
var request ente.ModifyMemberStorage
if err := handler.BindJSON(c, &request); err != nil {
@@ -136,7 +122,6 @@ func (h *FamilyHandler) ModifyStorageLimit(c *gin.Context) {
c.Status(http.StatusOK)
}
-// GetInviteInfo returns basic information about invitor/admin as long as the invite is valid
func (h *FamilyHandler) GetInviteInfo(c *gin.Context) {
inviteToken := c.Param("token")
response, err := h.Controller.InviteInfo(c, inviteToken)
diff --git a/server/pkg/api/file.go b/server/pkg/api/file.go
index 912c66bae8..b74211fff8 100644
--- a/server/pkg/api/file.go
+++ b/server/pkg/api/file.go
@@ -25,7 +25,6 @@ import (
"github.com/gin-gonic/gin"
)
-// FileHandler exposes request handlers for all encrypted file related requests
type FileHandler struct {
Controller *controller.FileController
FileUrlCtrl *public.FileLinkController
@@ -33,11 +32,9 @@ type FileHandler struct {
FileDataCtrl *filedata.Controller
}
-// DefaultMaxBatchSize is the default maximum API batch size unless specified otherwise
const DefaultMaxBatchSize = 1000
const DefaultCopyBatchSize = 100
-// CreateOrUpdate creates an entry for a file
func (h *FileHandler) CreateOrUpdate(c *gin.Context) {
userID := auth.GetUserID(c.Request.Header)
var file ente.File
@@ -47,7 +44,6 @@ func (h *FileHandler) CreateOrUpdate(c *gin.Context) {
}
file.UpdationTime = time.Microseconds()
- // get an ente.App from the ?app= query parameter with a default of photos
enteApp := auth.GetApp(c)
if file.ID == 0 {
@@ -69,7 +65,6 @@ func (h *FileHandler) CreateOrUpdate(c *gin.Context) {
c.JSON(http.StatusOK, response)
}
-// CreateMetaFile creates an entry for a file
func (h *FileHandler) CreateMetaFile(c *gin.Context) {
userID := auth.GetUserID(c.Request.Header)
var file ente.MetaFile
@@ -94,7 +89,6 @@ func (h *FileHandler) CreateMetaFile(c *gin.Context) {
c.JSON(http.StatusOK, resp)
}
-// CopyFiles copies files that are owned by another user
func (h *FileHandler) CopyFiles(c *gin.Context) {
var req ente.CopyFileSyncRequest
if err := handler.BindJSON(c, &req); err != nil {
@@ -113,7 +107,6 @@ func (h *FileHandler) CopyFiles(c *gin.Context) {
c.JSON(http.StatusOK, response)
}
-// Update updates already existing file
func (h *FileHandler) Update(c *gin.Context) {
enteApp := auth.GetApp(c)
@@ -136,7 +129,6 @@ func (h *FileHandler) Update(c *gin.Context) {
c.JSON(http.StatusOK, response)
}
-// GetUploadURLs returns a bunch of urls where in the user can upload objects
func (h *FileHandler) GetUploadURLs(c *gin.Context) {
enteApp := auth.GetApp(c)
@@ -152,7 +144,6 @@ func (h *FileHandler) GetUploadURLs(c *gin.Context) {
})
}
-// ValidateUploadEligibility verifies that the user can upload without minting upload URLs.
func (h *FileHandler) ValidateUploadEligibility(c *gin.Context) {
enteApp := auth.GetApp(c)
userID := auth.GetUserID(c.Request.Header)
@@ -163,7 +154,6 @@ func (h *FileHandler) ValidateUploadEligibility(c *gin.Context) {
c.Status(http.StatusOK)
}
-// GetUploadURLV2 returns a single upload URL that enforces checksum + content-length headers
func (h *FileHandler) GetUploadURLV2(c *gin.Context) {
enteApp := auth.GetApp(c)
userID := auth.GetUserID(c.Request.Header)
@@ -180,7 +170,6 @@ func (h *FileHandler) GetUploadURLV2(c *gin.Context) {
c.JSON(http.StatusOK, url)
}
-// GetMultipartUploadURLs returns an array of PartUpload PresignedURLs
func (h *FileHandler) GetMultipartUploadURLs(c *gin.Context) {
enteApp := auth.GetApp(c)
@@ -196,7 +185,6 @@ func (h *FileHandler) GetMultipartUploadURLs(c *gin.Context) {
})
}
-// GetMultipartUploadURLV2 returns multipart upload URLs for a single object with enforced metadata
func (h *FileHandler) GetMultipartUploadURLV2(c *gin.Context) {
enteApp := auth.GetApp(c)
userID := auth.GetUserID(c.Request.Header)
@@ -213,7 +201,6 @@ func (h *FileHandler) GetMultipartUploadURLV2(c *gin.Context) {
c.JSON(http.StatusOK, upload)
}
-// Get redirects the request to the file location
func (h *FileHandler) Get(c *gin.Context) {
userID, fileID := getUserAndFileIDs(c)
url, err := h.Controller.GetFileURL(c, userID, fileID)
@@ -225,7 +212,6 @@ func (h *FileHandler) Get(c *gin.Context) {
c.Redirect(http.StatusTemporaryRedirect, url)
}
-// GetURL returns the URL of the file to the client.
func (h *FileHandler) GetURL(c *gin.Context) {
userID, fileID := getUserAndFileIDs(c)
url, err := h.Controller.GetFileURL(c, userID, fileID)
@@ -243,7 +229,6 @@ func (h *FileHandler) GetURLV3(c *gin.Context) {
writeFileURLV3(c, url, err)
}
-// GetThumbnail redirects the request to the file's thumbnail location
func (h *FileHandler) GetThumbnail(c *gin.Context) {
userID, fileID := getUserAndFileIDs(c)
url, err := h.Controller.GetThumbnailURL(c, userID, fileID)
@@ -255,7 +240,6 @@ func (h *FileHandler) GetThumbnail(c *gin.Context) {
c.Redirect(http.StatusTemporaryRedirect, url)
}
-// GetThumbnailURL returns the URL of the thumbnail to the client.
func (h *FileHandler) GetThumbnailURL(c *gin.Context) {
userID, fileID := getUserAndFileIDs(c)
url, err := h.Controller.GetThumbnailURL(c, userID, fileID)
@@ -294,7 +278,6 @@ func fileURLV3Error(err error) error {
return err
}
-// Trash moves the given files to the trash bin
func (h *FileHandler) Trash(c *gin.Context) {
var request ente.TrashRequest
if err := handler.BindJSON(c, &request); err != nil {
@@ -315,7 +298,6 @@ func (h *FileHandler) Trash(c *gin.Context) {
}
}
-// GetSize returns the size of files indicated by fileIDs
func (h *FileHandler) GetSize(c *gin.Context) {
var request ente.FileIDsRequest
if err := handler.BindJSON(c, &request); err != nil {
@@ -343,7 +325,6 @@ func (h *FileHandler) GetSize(c *gin.Context) {
}
}
-// GetInfo returns the FileInfo of files indicated by fileIDs
func (h *FileHandler) GetInfo(c *gin.Context) {
var request ente.FileIDsRequest
if err := handler.BindJSON(c, &request); err != nil {
@@ -385,12 +366,10 @@ func shouldRejectRequest(c *gin.Context) (bool, error) {
}
minorVersion, err := strconv.Atoi(versionSplit[1])
if err != nil {
- // avoid reject when parsing fails
return false, nil
}
patchVersion, err := strconv.Atoi(versionSplit[2])
if err != nil {
- // avoid reject when parsing fails
return false, nil
}
shouldReject := minorVersion <= 5 && patchVersion <= 35
@@ -400,7 +379,6 @@ func shouldRejectRequest(c *gin.Context) (bool, error) {
return shouldReject, nil
}
-// GetDuplicates returns the list of files of the same size
func (h *FileHandler) GetDuplicates(c *gin.Context) {
userID := auth.GetUserID(c.Request.Header)
dupes, err := h.Controller.GetDuplicates(userID)
@@ -413,7 +391,6 @@ func (h *FileHandler) GetDuplicates(c *gin.Context) {
})
}
-// UpdateMagicMetadata updates magic metadata for a list of files.
func (h *FileHandler) UpdateMagicMetadata(c *gin.Context) {
var request ente.UpdateMultipleMagicMetadataRequest
if err := handler.BindJSON(c, &request); err != nil {
@@ -432,7 +409,6 @@ func (h *FileHandler) UpdateMagicMetadata(c *gin.Context) {
c.Status(http.StatusOK)
}
-// UpdatePublicMagicMetadata updates public magic metadata for a list of files.
func (h *FileHandler) UpdatePublicMagicMetadata(c *gin.Context) {
var request ente.UpdateMultipleMagicMetadataRequest
if err := handler.BindJSON(c, &request); err != nil {
@@ -447,7 +423,6 @@ func (h *FileHandler) UpdatePublicMagicMetadata(c *gin.Context) {
c.Status(http.StatusOK)
}
-// UpdateThumbnail updates thumbnail of a file
func (h *FileHandler) UpdateThumbnail(c *gin.Context) {
enteApp := auth.GetApp(c)
@@ -481,7 +456,6 @@ func getUserAndFileIDs(c *gin.Context) (int64, int64) {
return userID, fileID
}
-// logBadRedirect will log the request id if we are redirecting to another url with the auth-token in header
func (h *FileHandler) logBadRedirect(c *gin.Context) {
if len(c.GetHeader("X-Auth-Token")) != 0 && os.Getenv("ENVIRONMENT") != "" {
log.WithField("req_id", requestid.Get(c)).Error("critical: sending token to another service")
diff --git a/server/pkg/api/file_link.go b/server/pkg/api/file_link.go
index 4d2b6708ad..318d138962 100644
--- a/server/pkg/api/file_link.go
+++ b/server/pkg/api/file_link.go
@@ -10,7 +10,6 @@ import (
"strconv"
)
-// ShareUrl a sharable url for the file
func (h *FileHandler) ShareUrl(c *gin.Context) {
var file ente.CreateFileUrl
if err := handler.BindJSON(c, &file); err != nil {
@@ -131,7 +130,6 @@ func (h *FileHandler) GetUrls(c *gin.Context) {
})
}
-// VerifyPassword verifies the password for given link access token and return signed jwt token if it's valid
func (h *FileHandler) VerifyPassword(c *gin.Context) {
var req ente.VerifyPasswordRequest
if err := handler.BindJSON(c, &req); err != nil {
@@ -146,7 +144,6 @@ func (h *FileHandler) VerifyPassword(c *gin.Context) {
c.JSON(http.StatusOK, resp)
}
-// UpdateFileURL updates the share URL for a file
func (h *FileHandler) UpdateFileURL(c *gin.Context) {
var req ente.UpdateFileUrl
if err := handler.BindJSON(c, &req); err != nil {
diff --git a/server/pkg/api/memory_share.go b/server/pkg/api/memory_share.go
index ca534edc6c..750d726602 100644
--- a/server/pkg/api/memory_share.go
+++ b/server/pkg/api/memory_share.go
@@ -12,12 +12,10 @@ import (
"github.com/gin-gonic/gin"
)
-// MemoryShareHandler exposes request handlers for memory share operations
type MemoryShareHandler struct {
Controller *memory_share.Controller
}
-// Create creates a new memory share
func (h *MemoryShareHandler) Create(c *gin.Context) {
var req ente.CreateMemoryShareRequest
if err := handler.BindJSON(c, &req); err != nil {
@@ -35,7 +33,6 @@ func (h *MemoryShareHandler) Create(c *gin.Context) {
c.JSON(http.StatusOK, resp)
}
-// List returns all memory shares for the authenticated user
func (h *MemoryShareHandler) List(c *gin.Context) {
userID := auth.GetUserID(c.Request.Header)
resp, err := h.Controller.List(c, userID)
@@ -47,7 +44,6 @@ func (h *MemoryShareHandler) List(c *gin.Context) {
c.JSON(http.StatusOK, resp)
}
-// Delete soft-deletes a memory share
func (h *MemoryShareHandler) Delete(c *gin.Context) {
shareID, err := strconv.ParseInt(c.Param("shareID"), 10, 64)
if err != nil {
@@ -65,7 +61,6 @@ func (h *MemoryShareHandler) Delete(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{})
}
-// GetByID returns a memory share by ID (for owner only)
func (h *MemoryShareHandler) GetByID(c *gin.Context) {
shareID, err := strconv.ParseInt(c.Param("shareID"), 10, 64)
if err != nil {
diff --git a/server/pkg/api/offer.go b/server/pkg/api/offer.go
index 4fe61ddfe6..3e1cae806f 100644
--- a/server/pkg/api/offer.go
+++ b/server/pkg/api/offer.go
@@ -7,7 +7,6 @@ import (
"github.com/gin-gonic/gin"
)
-// OfferHandler expose request handlers to all offer related requests
type OfferHandler struct {
Controller *offer.OfferController
}
diff --git a/server/pkg/api/public_collection.go b/server/pkg/api/public_collection.go
index 3747eb23f1..38c441cbdd 100644
--- a/server/pkg/api/public_collection.go
+++ b/server/pkg/api/public_collection.go
@@ -20,7 +20,6 @@ import (
"github.com/gin-gonic/gin"
)
-// PublicCollectionHandler exposes request handlers for publicly accessible collections
type PublicCollectionHandler struct {
Controller *public.CollectionLinkController
FileCtrl *controller.FileController
@@ -29,12 +28,10 @@ type PublicCollectionHandler struct {
StorageBonusController *storagebonus.Controller
}
-// GetThumbnail redirects the request to the file's thumbnail location
func (h *PublicCollectionHandler) GetThumbnail(c *gin.Context) {
h.getFileForType(c, ente.THUMBNAIL)
}
-// GetFile redirects the request to the file location
func (h *PublicCollectionHandler) GetFile(c *gin.Context) {
h.getFileForType(c, ente.FILE)
}
@@ -114,7 +111,6 @@ func (h *PublicCollectionHandler) getCollectionOwnerAndVerifyAccess(c *gin.Conte
return &collection.Owner.ID, nil
}
-// GetCollection redirects the request to the collection location
func (h *PublicCollectionHandler) GetCollection(c *gin.Context) {
collection, err := h.Controller.GetPublicCollection(c, false)
if err != nil {
@@ -134,7 +130,6 @@ func (h *PublicCollectionHandler) GetCollection(c *gin.Context) {
c.JSON(http.StatusOK, response)
}
-// GetUploadURLV2 returns a single upload URL that enforces checksum + content-length headers
func (h *PublicCollectionHandler) GetUploadURLV2(c *gin.Context) {
enteApp := auth.GetApp(c)
var req ente.UploadURLRequest
@@ -155,7 +150,6 @@ func (h *PublicCollectionHandler) GetUploadURLV2(c *gin.Context) {
c.JSON(http.StatusOK, url)
}
-// GetMultipartUploadURLV2 returns multipart upload URLs for a single object with enforced metadata
func (h *PublicCollectionHandler) GetMultipartUploadURLV2(c *gin.Context) {
enteApp := auth.GetApp(c)
var req ente.MultipartUploadURLRequest
@@ -181,7 +175,6 @@ func (h *PublicCollectionHandler) GetMultipartUploadURLV2(c *gin.Context) {
c.JSON(http.StatusOK, upload)
}
-// CreateFile create a new file inside the collection corresponding to the public accessToken
func (h *PublicCollectionHandler) CreateFile(c *gin.Context) {
var file ente.File
if err := handler.BindJSON(c, &file); err != nil {
@@ -204,7 +197,6 @@ func (h *PublicCollectionHandler) CreateFile(c *gin.Context) {
c.JSON(http.StatusOK, fileRes)
}
-// VerifyPassword verifies the password for given public access token and return signed jwt token if it's valid
func (h *PublicCollectionHandler) VerifyPassword(c *gin.Context) {
var req ente.VerifyPasswordRequest
if err := handler.BindJSON(c, &req); err != nil {
@@ -219,9 +211,6 @@ func (h *PublicCollectionHandler) VerifyPassword(c *gin.Context) {
c.JSON(http.StatusOK, resp)
}
-// ReportAbuse endpoint removed
-
-// GetDiff returns the diff within a collection since a timestamp
func (h *PublicCollectionHandler) GetDiff(c *gin.Context) {
sinceTime, err := strconv.ParseInt(c.Query("sinceTime"), 10, 64)
if err != nil {
diff --git a/server/pkg/api/public_comments.go b/server/pkg/api/public_comments.go
index 8dd6c6f2c2..40014fa5c5 100644
--- a/server/pkg/api/public_comments.go
+++ b/server/pkg/api/public_comments.go
@@ -11,7 +11,6 @@ import (
"github.com/gin-gonic/gin"
)
-// PublicCommentsHandler handles public collection social APIs.
type PublicCommentsHandler struct {
CommentsCtrl *public.CommentsController
ReactionsCtrl *public.ReactionsController
@@ -325,7 +324,6 @@ func (h *PublicCommentsHandler) AnonProfiles(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{"profiles": profiles})
}
-// SocialDiff returns both comments and reactions in a single response.
func (h *PublicCommentsHandler) SocialDiff(c *gin.Context) {
if !ensurePublicCommentsEnabled(c) {
return
diff --git a/server/pkg/api/public_memory_share.go b/server/pkg/api/public_memory_share.go
index 4abf5e2f19..bce89df597 100644
--- a/server/pkg/api/public_memory_share.go
+++ b/server/pkg/api/public_memory_share.go
@@ -14,13 +14,11 @@ import (
"github.com/gin-gonic/gin"
)
-// PublicMemoryShareHandler exposes request handlers for publicly accessible memory shares
type PublicMemoryShareHandler struct {
PublicCtrl *public.MemoryShareController
FileDataCtrl *filedata.Controller
}
-// GetInfo returns the public memory share metadata
func (h *PublicMemoryShareHandler) GetInfo(c *gin.Context) {
accessCtx := auth.MustGetMemoryShareAccessContext(c)
@@ -35,7 +33,6 @@ func (h *PublicMemoryShareHandler) GetInfo(c *gin.Context) {
})
}
-// GetFiles returns the files in a public memory share
func (h *PublicMemoryShareHandler) GetFiles(c *gin.Context) {
accessCtx := auth.MustGetMemoryShareAccessContext(c)
@@ -48,12 +45,10 @@ func (h *PublicMemoryShareHandler) GetFiles(c *gin.Context) {
c.JSON(http.StatusOK, resp)
}
-// GetThumbnail redirects to the file's thumbnail location
func (h *PublicMemoryShareHandler) GetThumbnail(c *gin.Context) {
h.getFileForType(c, ente.THUMBNAIL)
}
-// GetFile redirects to the file's full location
func (h *PublicMemoryShareHandler) GetFile(c *gin.Context) {
h.getFileForType(c, ente.FILE)
}
@@ -70,7 +65,6 @@ func (h *PublicMemoryShareHandler) GetFileURLV3(c *gin.Context) {
writeFileURLV3(c, url, err)
}
-// GetFileData returns HLS playlist data for video streaming
func (h *PublicMemoryShareHandler) GetFileData(c *gin.Context) {
var req fileData.GetFileData
if err := c.ShouldBindQuery(&req); err != nil {
@@ -101,7 +95,6 @@ func (h *PublicMemoryShareHandler) GetFileData(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{"data": resp})
}
-// GetPreviewURL returns pre-signed URL for video preview data
func (h *PublicMemoryShareHandler) GetPreviewURL(c *gin.Context) {
var req fileData.GetPreviewURLRequest
if err := c.ShouldBindQuery(&req); err != nil {
diff --git a/server/pkg/api/push.go b/server/pkg/api/push.go
index 8f327da2a7..7142cb55f7 100644
--- a/server/pkg/api/push.go
+++ b/server/pkg/api/push.go
@@ -11,7 +11,6 @@ import (
"github.com/gin-gonic/gin"
)
-// PushHandler exposes request handlers for all push related requests
type PushHandler struct {
PushController *controller.PushController
}
diff --git a/server/pkg/api/reactions.go b/server/pkg/api/reactions.go
index 57c87a6007..2cfcddc755 100644
--- a/server/pkg/api/reactions.go
+++ b/server/pkg/api/reactions.go
@@ -14,7 +14,6 @@ import (
const reactionCipherLength = 156
-// ReactionsHandler exposes authenticated reaction APIs.
type ReactionsHandler struct {
Controller *social.ReactionsController
}
diff --git a/server/pkg/api/remotestore.go b/server/pkg/api/remotestore.go
index d85ee28964..6d56375795 100644
--- a/server/pkg/api/remotestore.go
+++ b/server/pkg/api/remotestore.go
@@ -10,12 +10,10 @@ import (
"github.com/gin-gonic/gin"
)
-// RemoteStoreHandler expose request handlers to all remote store
type RemoteStoreHandler struct {
Controller *remotestore.Controller
}
-// InsertOrUpdate handler for inserting or updating key
func (h *RemoteStoreHandler) InsertOrUpdate(c *gin.Context) {
var request ente.UpdateKeyValueRequest
if err := handler.BindJSON(c, &request); err != nil {
@@ -45,7 +43,6 @@ func (h *RemoteStoreHandler) RemoveKey(c *gin.Context) {
c.Status(http.StatusOK)
}
-// GetKey handler for fetching a value for particular key
func (h *RemoteStoreHandler) GetKey(c *gin.Context) {
var request ente.GetValueRequest
if err := c.ShouldBindQuery(&request); err != nil {
@@ -62,7 +59,6 @@ func (h *RemoteStoreHandler) GetKey(c *gin.Context) {
c.JSON(http.StatusOK, resp)
}
-// GetFeatureFlags returns all the feature flags and value for given user
func (h *RemoteStoreHandler) GetFeatureFlags(c *gin.Context) {
resp, err := h.Controller.GetFeatureFlags(c)
if err != nil {
diff --git a/server/pkg/api/social.go b/server/pkg/api/social.go
index d90c27c4c9..4a8f8535ce 100644
--- a/server/pkg/api/social.go
+++ b/server/pkg/api/social.go
@@ -12,7 +12,6 @@ import (
"github.com/gin-gonic/gin"
)
-// SocialHandler exposes unified diff and counts endpoints.
type SocialHandler struct {
Controller *social.Controller
}
diff --git a/server/pkg/api/trash.go b/server/pkg/api/trash.go
index c48c86d7b9..564f579966 100644
--- a/server/pkg/api/trash.go
+++ b/server/pkg/api/trash.go
@@ -12,13 +12,10 @@ import (
"github.com/gin-gonic/gin"
)
-// TrashHandler handles endpoints related to trash/restore etc
type TrashHandler struct {
Controller *controller.TrashController
}
-// GetDiff returns the list of trashed files for the user that
-// have changed sinceTime.
// Deprecated, shutdown when there's no traffic for 30 days
func (t *TrashHandler) GetDiff(c *gin.Context) {
enteApp := auth.GetApp(c)
@@ -69,7 +66,6 @@ func (t *TrashHandler) Delete(c *gin.Context) {
c.Status(http.StatusOK)
}
-// Empty deletes eligible files from the trash
func (t *TrashHandler) Empty(c *gin.Context) {
userID := auth.GetUserID(c.Request.Header)
enteApp := auth.GetApp(c)
diff --git a/server/pkg/api/user.go b/server/pkg/api/user.go
index 5658720da6..5b08f04986 100644
--- a/server/pkg/api/user.go
+++ b/server/pkg/api/user.go
@@ -21,13 +21,11 @@ import (
"github.com/google/uuid"
)
-// UserHandler exposes request handlers for all user related requests
type UserHandler struct {
UserController *user.UserController
EmergencyController *emergency.Controller
}
-// SendOTT generates and sends an OTT to the provided email address
func (h *UserHandler) SendOTT(c *gin.Context) {
var request ente.SendOTTRequest
if err := handler.BindJSON(c, &request); err != nil {
@@ -48,7 +46,6 @@ func (h *UserHandler) SendOTT(c *gin.Context) {
}
}
-// Logout removes the auth token from (instance) cache & database.
func (h *UserHandler) Logout(c *gin.Context) {
err := h.UserController.Logout(c)
if err != nil {
@@ -58,7 +55,6 @@ func (h *UserHandler) Logout(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{})
}
-// GetDetailsV2 returns details about the requesting user
func (h *UserHandler) GetDetailsV2(c *gin.Context) {
userID := auth.GetUserID(c.Request.Header)
fetchMemoryCount, _ := strconv.ParseBool(c.DefaultQuery("memoryCount", "true"))
@@ -73,7 +69,6 @@ func (h *UserHandler) GetDetailsV2(c *gin.Context) {
c.JSON(http.StatusOK, details)
}
-// GetAccountDeletionSummary returns counts for data that will be deleted.
func (h *UserHandler) GetAccountDeletionSummary(c *gin.Context) {
userID := auth.GetUserID(c.Request.Header)
summary, err := h.UserController.GetAccountDeletionSummary(c.Request.Context(), userID)
@@ -84,7 +79,6 @@ func (h *UserHandler) GetAccountDeletionSummary(c *gin.Context) {
c.JSON(http.StatusOK, summary)
}
-// GetLockerUsage returns locker usage details for the requesting user.
func (h *UserHandler) GetLockerUsage(c *gin.Context) {
userID := auth.GetUserID(c.Request.Header)
@@ -96,7 +90,6 @@ func (h *UserHandler) GetLockerUsage(c *gin.Context) {
c.JSON(http.StatusOK, lockerUsage)
}
-// SetAttributes sets the attributes for a user
func (h *UserHandler) SetAttributes(c *gin.Context) {
userID := auth.GetUserID(c.Request.Header)
var request ente.SetUserAttributesRequest
@@ -131,7 +124,6 @@ func (h *UserHandler) UpdateEmailMFA(c *gin.Context) {
c.Status(http.StatusOK)
}
-// SetRecoveryKey sets the recovery key attributes for a user.
func (h *UserHandler) SetRecoveryKey(c *gin.Context) {
userID := auth.GetUserID(c.Request.Header)
var request ente.SetRecoveryKeyRequest
@@ -147,7 +139,6 @@ func (h *UserHandler) SetRecoveryKey(c *gin.Context) {
c.Status(http.StatusOK)
}
-// GetPublicKey returns the public key of a user
func (h *UserHandler) GetPublicKey(c *gin.Context) {
publicKey, err := h.UserController.GetPublicKey(
auth.GetUserID(c.Request.Header),
@@ -162,7 +153,6 @@ func (h *UserHandler) GetPublicKey(c *gin.Context) {
})
}
-// GetSessionValidityV2 verifies the user's session token and returns if the user has set their keys or not
func (h *UserHandler) GetSessionValidityV2(c *gin.Context) {
userID := auth.GetUserID(c.Request.Header)
keyAttributes, err := h.UserController.GetAttributes(userID)
@@ -182,8 +172,6 @@ func (h *UserHandler) GetSessionValidityV2(c *gin.Context) {
}
}
-// VerifyEmail validates that the OTT provided in the request is valid for the
-// provided email address and if yes returns the users credentials
func (h *UserHandler) VerifyEmail(c *gin.Context) {
var request ente.EmailVerificationRequest
if err := handler.BindJSON(c, &request); err != nil {
@@ -198,8 +186,6 @@ func (h *UserHandler) VerifyEmail(c *gin.Context) {
c.JSON(http.StatusOK, response)
}
-// ChangeEmail validates that the OTT provided in the request is valid for the
-// provided email address and if yes updates the user's existing email address
func (h *UserHandler) ChangeEmail(c *gin.Context) {
var request ente.EmailVerificationRequest
if err := handler.BindJSON(c, &request); err != nil {
@@ -214,7 +200,6 @@ func (h *UserHandler) ChangeEmail(c *gin.Context) {
c.Status(http.StatusOK)
}
-// GetTwoFactorStatus returns a user's two factor status
func (h *UserHandler) GetTwoFactorStatus(c *gin.Context) {
userID := auth.GetUserID(c.Request.Header)
status, err := h.UserController.GetTwoFactorStatus(userID)
@@ -234,8 +219,6 @@ func (h *UserHandler) GetTwoFactorRecoveryStatus(c *gin.Context) {
c.JSON(http.StatusOK, res)
}
-// ConfigurePasskeyRecovery configures the passkey skip challenge for a user. In case the user does not
-// have access to passkey, the user can bypass the passkey by providing the recovery key
func (h *UserHandler) ConfigurePasskeyRecovery(c *gin.Context) {
var request ente.SetPasskeyRecoveryRequest
if err := handler.BindJSON(c, &request); err != nil {
@@ -250,7 +233,6 @@ func (h *UserHandler) ConfigurePasskeyRecovery(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{})
}
-// SetupTwoFactor generates a two factor secret and sends it to user to setup his authenticator app with
func (h *UserHandler) SetupTwoFactor(c *gin.Context) {
userID := auth.GetUserID(c.Request.Header)
response, err := h.UserController.SetupTwoFactor(userID)
@@ -261,7 +243,6 @@ func (h *UserHandler) SetupTwoFactor(c *gin.Context) {
c.JSON(http.StatusOK, response)
}
-// EnableTwoFactor handles the two factor activation request after user has setup his two factor by validing a totp request
func (h *UserHandler) EnableTwoFactor(c *gin.Context) {
userID := auth.GetUserID(c.Request.Header)
var request ente.TwoFactorEnableRequest
@@ -277,7 +258,6 @@ func (h *UserHandler) EnableTwoFactor(c *gin.Context) {
c.Status(http.StatusOK)
}
-// VerifyTwoFactor handles the two factor validation request
func (h *UserHandler) VerifyTwoFactor(c *gin.Context) {
var request ente.TwoFactorVerificationRequest
if err := handler.BindJSON(c, &request); err != nil {
@@ -292,7 +272,6 @@ func (h *UserHandler) VerifyTwoFactor(c *gin.Context) {
c.JSON(http.StatusOK, response)
}
-// BeginPasskeyRegistrationCeremony handles the request to begin the passkey registration ceremony
func (h *UserHandler) BeginPasskeyAuthenticationCeremony(c *gin.Context) {
var request ente.PasskeyTwoFactorBeginAuthenticationCeremonyRequest
if err := handler.BindJSON(c, &request); err != nil {
@@ -403,7 +382,6 @@ func (h *UserHandler) IsPasskeyRecoveryEnabled(c *gin.Context) {
c.JSON(http.StatusOK, response)
}
-// DisableTwoFactor disables the two factor authentication for a user
func (h *UserHandler) DisableTwoFactor(c *gin.Context) {
userID := auth.GetUserID(c.Request.Header)
err := h.UserController.DisableTwoFactor(userID)
@@ -414,8 +392,6 @@ func (h *UserHandler) DisableTwoFactor(c *gin.Context) {
c.Status(http.StatusOK)
}
-// RecoverTwoFactor handles the two factor recovery request by sending the
-// recoveryKeyEncryptedTwoFactorSecret for the user to decrypt it and make twoFactor removal api call
func (h *UserHandler) RecoverTwoFactor(c *gin.Context) {
sessionID := c.Query("sessionID")
twoFactorType := c.Query("twoFactorType")
@@ -433,8 +409,6 @@ func (h *UserHandler) RecoverTwoFactor(c *gin.Context) {
c.JSON(http.StatusOK, response)
}
-// RemoveTwoFactor handles two factor deactivation request if user lost his device
-// by authenticating him using his twoFactorsessionToken and twoFactor secret
func (h *UserHandler) RemoveTwoFactor(c *gin.Context) {
var request ente.TwoFactorRemovalRequest
if err := handler.BindJSON(c, &request); err != nil {
@@ -519,7 +493,6 @@ func (h *UserHandler) GetActiveSessions(c *gin.Context) {
})
}
-// TerminateSession removes the auth token from (instance) cache & database.
func (h *UserHandler) TerminateSession(c *gin.Context) {
userID := auth.GetUserID(c.Request.Header)
token := c.Query("token")
@@ -531,9 +504,6 @@ func (h *UserHandler) TerminateSession(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{})
}
-// GetDeleteChallenge responds with flag to indicate if account deletion is enabled.
-// When enabled, it returns a challenge/encrypted token which clients need to decrypt
-// and send-back while confirming deletion
func (h *UserHandler) GetDeleteChallenge(c *gin.Context) {
response, err := h.UserController.GetDeleteChallengeToken(c)
if err != nil {
@@ -543,7 +513,6 @@ func (h *UserHandler) GetDeleteChallenge(c *gin.Context) {
c.JSON(http.StatusOK, response)
}
-// DeleteUser api for deleting a user
func (h *UserHandler) DeleteUser(c *gin.Context) {
var request ente.DeleteAccountRequest
if err := handler.BindJSON(c, &request); err != nil {
@@ -615,7 +584,6 @@ func (h *UserHandler) RecoverSelfAccount(c *gin.Context) {
c.JSON(http.StatusOK, response)
}
-// GetSRPAttributes returns the SRP attributes for a user
func (h *UserHandler) GetSRPAttributes(c *gin.Context) {
var request ente.GetSRPAttributesRequest
if err := c.ShouldBindQuery(&request); err != nil {
@@ -635,7 +603,6 @@ func (h *UserHandler) GetSRPAttributes(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{"attributes": response})
}
-// SetupSRP sets the SRP attributes for a user
func (h *UserHandler) SetupSRP(c *gin.Context) {
var request ente.SetupSRPRequest
if err := handler.BindJSON(c, &request); err != nil {
@@ -651,7 +618,6 @@ func (h *UserHandler) SetupSRP(c *gin.Context) {
c.JSON(http.StatusOK, resp)
}
-// CompleteSRPSetup completes the SRP setup for a user
func (h *UserHandler) CompleteSRPSetup(c *gin.Context) {
var request ente.CompleteSRPSetupRequest
if err := handler.BindJSON(c, &request); err != nil {
@@ -666,7 +632,6 @@ func (h *UserHandler) CompleteSRPSetup(c *gin.Context) {
c.JSON(http.StatusOK, resp)
}
-// UpdateSrpAndKeyAttributes updates the SRP setup for a user and key attributes
func (h *UserHandler) UpdateSrpAndKeyAttributes(c *gin.Context) {
var request ente.UpdateSRPAndKeysRequest
if err := handler.BindJSON(c, &request); err != nil {
@@ -674,7 +639,6 @@ func (h *UserHandler) UpdateSrpAndKeyAttributes(c *gin.Context) {
return
}
userID := auth.GetUserID(c.Request.Header)
- // default to true
clearTokens := true
if request.LogOutOtherDevices != nil {
clearTokens = *request.LogOutOtherDevices
@@ -687,7 +651,6 @@ func (h *UserHandler) UpdateSrpAndKeyAttributes(c *gin.Context) {
c.JSON(http.StatusOK, resp)
}
-// CreateSRPSession set the SRP A value on the server and returns the SRP B value to the client
func (h *UserHandler) CreateSRPSession(c *gin.Context) {
var request ente.CreateSRPSessionRequest
if err := handler.BindJSON(c, &request); err != nil {
@@ -702,7 +665,6 @@ func (h *UserHandler) CreateSRPSession(c *gin.Context) {
c.JSON(http.StatusOK, resp)
}
-// VerifySRPSession checks the M1 value to determine if user actually knows the password
func (h *UserHandler) VerifySRPSession(c *gin.Context) {
var request ente.VerifySRPSessionRequest
if err := handler.BindJSON(c, &request); err != nil {
diff --git a/server/pkg/api/userentity.go b/server/pkg/api/userentity.go
index 35eb6dccb1..426f4fd6aa 100644
--- a/server/pkg/api/userentity.go
+++ b/server/pkg/api/userentity.go
@@ -11,12 +11,10 @@ import (
"github.com/gin-gonic/gin"
)
-// UserEntityHandler expose request handlers for various operations on user entity
type UserEntityHandler struct {
Controller *userentity.Controller
}
-// CreateKey...
func (h *UserEntityHandler) CreateKey(c *gin.Context) {
var request model.EntityKeyRequest
if err := handler.BindJSON(c, &request); err != nil {
@@ -55,7 +53,6 @@ func (h *UserEntityHandler) EnsureKey(c *gin.Context) {
c.JSON(http.StatusOK, resp)
}
-// GetKey...
func (h *UserEntityHandler) GetKey(c *gin.Context) {
var request model.GetEntityKeyRequest
if err := c.ShouldBindQuery(&request); err != nil {
@@ -71,7 +68,6 @@ func (h *UserEntityHandler) GetKey(c *gin.Context) {
c.JSON(http.StatusOK, resp)
}
-// CreateEntity...
func (h *UserEntityHandler) CreateEntity(c *gin.Context) {
var request model.EntityDataRequest
if err := handler.BindJSON(c, &request); err != nil {
@@ -86,7 +82,6 @@ func (h *UserEntityHandler) CreateEntity(c *gin.Context) {
c.JSON(http.StatusOK, resp)
}
-// UpdateEntity...
func (h *UserEntityHandler) UpdateEntity(c *gin.Context) {
var request model.UpdateEntityDataRequest
if err := handler.BindJSON(c, &request); err != nil {
@@ -101,7 +96,6 @@ func (h *UserEntityHandler) UpdateEntity(c *gin.Context) {
c.JSON(http.StatusOK, resp)
}
-// DeleteEntity...
func (h *UserEntityHandler) DeleteEntity(c *gin.Context) {
id := c.Query("id")
_, err := h.Controller.Delete(c, id)
@@ -112,7 +106,6 @@ func (h *UserEntityHandler) DeleteEntity(c *gin.Context) {
c.Status(http.StatusOK)
}
-// GetDiff...
func (h *UserEntityHandler) GetDiff(c *gin.Context) {
var request model.GetEntityDiffRequest
if err := c.ShouldBindQuery(&request); err != nil {
diff --git a/server/pkg/controller/access/access.go b/server/pkg/controller/access/access.go
index 019d970e3e..9a032d27ff 100644
--- a/server/pkg/controller/access/access.go
+++ b/server/pkg/controller/access/access.go
@@ -5,22 +5,18 @@ import (
"github.com/gin-gonic/gin"
)
-// Controller exposes helper methods to perform access checks while fetching or editing
-// any entity.
type Controller interface {
GetCollection(ctx *gin.Context, req *GetCollectionParams) (*GetCollectionResponse, error)
VerifyFileOwnership(ctx *gin.Context, req *VerifyFileOwnershipParams) error
CanAccessFile(ctx *gin.Context, req *CanAccessFileParams) error
}
-// controllerImpl implements Controller
type controllerImpl struct {
FileRepo *repo.FileRepository
CollectionRepo *repo.CollectionRepository
}
-// https://stackoverflow.com/a/33089540/546896
-var _ Controller = (*controllerImpl)(nil) // Verify that *T implements I.
+var _ Controller = (*controllerImpl)(nil)
var _ Controller = controllerImpl{}
func NewAccessController(
diff --git a/server/pkg/controller/access/collection.go b/server/pkg/controller/access/collection.go
index df6936261a..07f5d92d4b 100644
--- a/server/pkg/controller/access/collection.go
+++ b/server/pkg/controller/access/collection.go
@@ -8,8 +8,7 @@ import (
type GetCollectionParams struct {
CollectionID int64
- // userID of the user trying to fetch the controller
- ActorUserID int64
+ ActorUserID int64
// IncludeDeleted defaults to false. If false and user is trying to fetch deletion collection
// then the request fails
IncludeDeleted bool
@@ -31,7 +30,6 @@ func (c controllerImpl) GetCollection(ctx *gin.Context, req *GetCollectionParams
return nil, stacktrace.Propagate(err, "")
}
- // Perform permission related access check if user is not the owner of the collection
if req.VerifyOwner && req.ActorUserID != collection.Owner.ID {
return nil, stacktrace.Propagate(ente.ErrPermissionDenied, "actor doesn't owns the collection")
}
diff --git a/server/pkg/controller/access/file.go b/server/pkg/controller/access/file.go
index c0ca85456f..9d6e80371c 100644
--- a/server/pkg/controller/access/file.go
+++ b/server/pkg/controller/access/file.go
@@ -10,7 +10,6 @@ import (
)
type VerifyFileOwnershipParams struct {
- // userID of the user trying to fetch the controller
ActorUserId int64
FileIDs []int64
}
@@ -20,7 +19,6 @@ type CanAccessFileParams struct {
FileIDs []int64
}
-// VerifyFileOwnership will return error if given fileIDs are not valid or don't belong to the ownerID
func (c controllerImpl) VerifyFileOwnership(ctx *gin.Context, req *VerifyFileOwnershipParams) error {
if enteArray.ContainsDuplicateInInt64Array(req.FileIDs) {
return stacktrace.Propagate(ente.ErrBadRequest, "duplicate fileIDs")
diff --git a/server/pkg/controller/authenticator/controller.go b/server/pkg/controller/authenticator/controller.go
index a9fef70ad8..5dbed8a831 100644
--- a/server/pkg/controller/authenticator/controller.go
+++ b/server/pkg/controller/authenticator/controller.go
@@ -14,13 +14,11 @@ import (
"github.com/gin-gonic/gin"
)
-// Controller is interface for exposing business logic related to authenticator app
type Controller struct {
Repo *authenticator.Repository
UserRepo *repo.UserRepository
}
-// CreateKey...
func (c *Controller) CreateKey(ctx *gin.Context, req model.CreateKeyRequest) error {
userID := auth.GetUserID(ctx.Request.Header)
if _, keyErr := c.UserRepo.GetKeyAttributes(userID); keyErr != nil {
@@ -29,7 +27,6 @@ func (c *Controller) CreateKey(ctx *gin.Context, req model.CreateKeyRequest) err
return c.Repo.CreateKey(ctx, userID, req)
}
-// GetKey...
func (c *Controller) GetKey(ctx *gin.Context) (*model.Key, error) {
userID := auth.GetUserID(ctx.Request.Header)
res, err := c.Repo.GetKey(ctx, userID)
@@ -39,7 +36,6 @@ func (c *Controller) GetKey(ctx *gin.Context) (*model.Key, error) {
return &res, nil
}
-// CreateEntity...
func (c *Controller) CreateEntity(ctx *gin.Context, req model.CreateEntityRequest) (*model.Entity, error) {
if err := c.validateKey(ctx); err != nil {
return nil, stacktrace.Propagate(err, "failed to validateKey")
@@ -56,7 +52,6 @@ func (c *Controller) CreateEntity(ctx *gin.Context, req model.CreateEntityReques
return &entity, nil
}
-// UpdateEntity...
func (c *Controller) UpdateEntity(ctx *gin.Context, req model.UpdateEntityRequest) error {
if err := c.validateKey(ctx); err != nil {
return stacktrace.Propagate(err, "failed to validateKey")
@@ -79,13 +74,11 @@ func (c *Controller) validateKey(ctx *gin.Context) error {
return err
}
-// Delete...
func (c *Controller) Delete(ctx *gin.Context, entityID uuid.UUID) (bool, error) {
userID := auth.GetUserID(ctx.Request.Header)
return c.Repo.Delete(ctx, userID, entityID)
}
-// GetDiff...
func (c *Controller) GetDiff(ctx *gin.Context, req model.GetEntityDiffRequest) ([]model.Entity, error) {
if req.Limit <= 0 || req.Limit > 5000 {
return nil, ente.NewBadRequestWithMessage("limit must be between 1 and 5000")
diff --git a/server/pkg/controller/collections/cast.go b/server/pkg/controller/collections/cast.go
index bc104c6cda..35f3b2a984 100644
--- a/server/pkg/controller/collections/cast.go
+++ b/server/pkg/controller/collections/cast.go
@@ -21,7 +21,6 @@ func (c *CollectionController) GetCastCollection(ctx *gin.Context) (*ente.Collec
return &collection, nil
}
-// GetCastDiff returns the changes in the collections since a timestamp, along with hasMore bool flag.
func (c *CollectionController) GetCastDiff(ctx *gin.Context, sinceTime int64) ([]ente.File, bool, error) {
castCtx := auth.GetCastCtx(ctx)
collectionID := castCtx.CollectionID
diff --git a/server/pkg/controller/collections/collection.go b/server/pkg/controller/collections/collection.go
index 74eaac5f36..7c182feaaa 100644
--- a/server/pkg/controller/collections/collection.go
+++ b/server/pkg/controller/collections/collection.go
@@ -25,7 +25,6 @@ const (
CollectionDiffLimit = 2500
)
-// CollectionController encapsulates logic that deals with collections
type CollectionController struct {
CollectionLinkCtrl *public.CollectionLinkController
EmailCtrl *email.EmailNotificationController
@@ -44,7 +43,6 @@ type CollectionController struct {
ReactionsRepo *socialrepo.ReactionsRepository
}
-// Create creates a collection
func (c *CollectionController) Create(collection ente.Collection, ownerID int64) (ente.Collection, error) {
if err := validateOwnedCollectionKey(collection.EncryptedKey, collection.KeyDecryptionNonce); err != nil {
return ente.Collection{}, err
@@ -82,7 +80,6 @@ func (c *CollectionController) Create(collection ente.Collection, ownerID int64)
return collection, nil
}
-// GetCollection returns the collection for given collectionID
func (c *CollectionController) GetCollection(ctx *gin.Context, userID int64, cID int64) (ente.Collection, error) {
resp, err := c.AccessCtrl.GetCollection(ctx, &access.GetCollectionParams{
CollectionID: cID,
@@ -128,8 +125,6 @@ func (c *CollectionController) GetFile(ctx *gin.Context, collectionID int64, fil
return &file, nil
}
-// TrashV3 deletes a given collection and based on user input (TrashCollectionV3Request.KeepFiles as FALSE) , it will move all files present in the underlying collection
-// to trash.
func (c *CollectionController) TrashV3(ctx *gin.Context, req ente.TrashCollectionV3Request) error {
if req.KeepFiles == nil {
return ente.ErrBadRequest
@@ -183,7 +178,6 @@ func (c *CollectionController) TrashV3(ctx *gin.Context, req ente.TrashCollectio
return nil
}
-// Rename updates the collection's name
func (c *CollectionController) Rename(userID int64, cID int64, encryptedName string, nameDecryptionNonce string) error {
if err := c.verifyOwnership(cID, userID); err != nil {
return stacktrace.Propagate(err, "")
@@ -195,7 +189,6 @@ func (c *CollectionController) Rename(userID int64, cID int64, encryptedName str
return nil
}
-// UpdateMagicMetadata updates the magic metadata for given collection
func (c *CollectionController) UpdateMagicMetadata(ctx *gin.Context, request ente.UpdateCollectionMagicMetadata, isPublicMetadata bool) error {
userID := auth.GetUserID(ctx.Request.Header)
if err := c.verifyOwnership(request.ID, userID); err != nil {
@@ -239,7 +232,6 @@ func (c *CollectionController) HandleAccountDeletion(ctx context.Context, userID
return c.ResetUserSharingAccess(ctx, userID, logger)
}
-// Verify that user owns the collection
func (c *CollectionController) verifyOwnership(cID int64, userID int64) error {
collection, err := c.CollectionRepo.Get(cID)
if err != nil {
diff --git a/server/pkg/controller/collections/diff.go b/server/pkg/controller/collections/diff.go
index 725c4c6399..7513ea057c 100644
--- a/server/pkg/controller/collections/diff.go
+++ b/server/pkg/controller/collections/diff.go
@@ -5,7 +5,6 @@ import (
"github.com/ente/stacktrace"
)
-// GetOwnedV2 returns the list of collections owned by a user using optimized query
func (c *CollectionController) GetOwnedV2(userID int64, sinceTime int64, app ente.App, limit *int64) ([]ente.Collection, error) {
collections, err := c.CollectionRepo.GetCollectionsOwnedByUserV2(userID, sinceTime, app, limit)
if err != nil {
@@ -14,7 +13,6 @@ func (c *CollectionController) GetOwnedV2(userID int64, sinceTime int64, app ent
return collections, nil
}
-// GetSharedWith returns the list of collections that are shared with a user
func (c *CollectionController) GetSharedWith(userID int64, sinceTime int64, app ente.App, limit *int64) ([]ente.Collection, error) {
collections, err := c.CollectionRepo.GetCollectionsSharedWithUser(userID, sinceTime, app, limit)
if err != nil {
diff --git a/server/pkg/controller/collections/file_action.go b/server/pkg/controller/collections/file_action.go
index 38aa67ef94..84609aa223 100644
--- a/server/pkg/controller/collections/file_action.go
+++ b/server/pkg/controller/collections/file_action.go
@@ -9,7 +9,6 @@ import (
log "github.com/sirupsen/logrus"
)
-// AddFiles adds files to a collection
func (c *CollectionController) AddFiles(ctx *gin.Context, userID int64, files []ente.CollectionFileItem, cID int64) error {
resp, err := c.AccessCtrl.GetCollection(ctx, &access.GetCollectionParams{
CollectionID: cID,
@@ -30,7 +29,6 @@ func (c *CollectionController) AddFiles(ctx *gin.Context, userID int64, files []
collectionOwnerID := resp.Collection.Owner.ID
filesOwnerID := userID
- // Verify that the user owns each file
fileIDs := make([]int64, 0)
for _, file := range files {
fileIDs = append(fileIDs, file.ID)
@@ -44,7 +42,6 @@ func (c *CollectionController) AddFiles(ctx *gin.Context, userID int64, files []
return stacktrace.Propagate(err, "Failed to verify fileOwnership")
}
- // Verify that none of the files are in trash or permanently deleted
trashedOrDeletedFileIDs, err := c.TrashRepo.GetFilesInTrashOrDeleted(ctx, userID, fileIDs)
if err != nil {
return stacktrace.Propagate(err, "failed to check trash state")
@@ -65,7 +62,6 @@ func (c *CollectionController) AddFiles(ctx *gin.Context, userID int64, files []
return nil
}
-// RestoreFiles restore files from trash and add to the collection
func (c *CollectionController) RestoreFiles(ctx *gin.Context, userID int64, cID int64, files []ente.CollectionFileItem) error {
_, err := c.AccessCtrl.GetCollection(ctx, &access.GetCollectionParams{
CollectionID: cID,
@@ -76,7 +72,6 @@ func (c *CollectionController) RestoreFiles(ctx *gin.Context, userID int64, cID
if err != nil {
return stacktrace.Propagate(err, "failed to verify collection access")
}
- // Verify that the user owns each file
for _, file := range files {
// todo #perf find owners of all files
ownerID, err := c.FileRepo.GetOwnerID(file.ID)
@@ -99,8 +94,6 @@ func (c *CollectionController) RestoreFiles(ctx *gin.Context, userID int64, cID
return nil
}
-// MoveFiles from one collection to another collection. Both the collections and files should belong to
-// single user
func (c *CollectionController) MoveFiles(ctx *gin.Context, req ente.MoveFilesRequest) error {
userID := auth.GetUserID(ctx.Request.Header)
r1, err := c.AccessCtrl.GetCollection(ctx, &access.GetCollectionParams{
@@ -127,7 +120,6 @@ func (c *CollectionController) MoveFiles(ctx *gin.Context, req ente.MoveFilesReq
return stacktrace.Propagate(ente.ErrInvalidApp, "move across app not supported %s to %s", r1.Collection.App, r2.Collection.App)
}
- // Verify that the user owns each file
fileIDs := make([]int64, 0)
for _, file := range req.Files {
fileIDs = append(fileIDs, file.ID)
@@ -140,7 +132,6 @@ func (c *CollectionController) MoveFiles(ctx *gin.Context, req ente.MoveFilesReq
return stacktrace.Propagate(err, "Failed to verify fileOwnership")
}
- // Verify that none of the files are in trash or permanently deleted
trashedOrDeletedFileIDs, err := c.TrashRepo.GetFilesInTrashOrDeleted(ctx, userID, fileIDs)
if err != nil {
return stacktrace.Propagate(err, "failed to check trash state")
@@ -156,7 +147,7 @@ func (c *CollectionController) MoveFiles(ctx *gin.Context, req ente.MoveFilesReq
}
err = c.CollectionRepo.MoveFiles(ctx, req.ToCollectionID, req.FromCollectionID, req.Files, userID, userID)
- return stacktrace.Propagate(err, "") // return nil if err is nil
+ return stacktrace.Propagate(err, "")
}
// RemoveFilesV3 enforces all removal rules for shared collections:
@@ -180,7 +171,6 @@ func (c *CollectionController) RemoveFilesV3(ctx *gin.Context, actorUserID int64
collectionOwnerID := accessResp.Collection.Owner.ID
role := accessResp.Role
- // Validate requested files exist in the target collection and filter already-removed ones.
fileIDsToRemove, err := c.CollectionRepo.FilterActiveFileIDsInCollection(ctx, req.CollectionID, req.FileIDs)
if err != nil {
return stacktrace.Propagate(err, "file not found in collection")
@@ -190,7 +180,6 @@ func (c *CollectionController) RemoveFilesV3(ctx *gin.Context, actorUserID int64
}
req.FileIDs = fileIDsToRemove
- // Partition fileIDs by owner
ownerToFilesMap, err := c.FileRepo.GetOwnerToFileIDsMap(ctx, req.FileIDs)
if err != nil {
return stacktrace.Propagate(err, "failed to get owner to fileIDs map")
@@ -200,7 +189,6 @@ func (c *CollectionController) RemoveFilesV3(ctx *gin.Context, actorUserID int64
}
filesOwnedByCollectionOwner := ownerToFilesMap[collectionOwnerID]
- // Files owned by others (excluding owner)
ownerFilesSet := make(map[int64]struct{}, len(filesOwnedByCollectionOwner))
for _, fid := range filesOwnedByCollectionOwner {
ownerFilesSet[fid] = struct{}{}
@@ -212,10 +200,8 @@ func (c *CollectionController) RemoveFilesV3(ctx *gin.Context, actorUserID int64
}
}
- // If admin is trying to remove owner's files
if len(filesOwnedByCollectionOwner) > 0 {
if role != nil && *role == ente.ADMIN && actorUserID != collectionOwnerID {
- // Populate collection_files with action for owner's files
if err := c.CollectionRepo.SuggestAction(ctx, req.CollectionID, actorUserID, filesOwnedByCollectionOwner, ente.ActionRemove); err != nil {
return stacktrace.Propagate(err, "failed to set remove action for owner's files")
}
@@ -223,11 +209,9 @@ func (c *CollectionController) RemoveFilesV3(ctx *gin.Context, actorUserID int64
return stacktrace.Propagate(err, "failed to create collection action REMOVE")
}
} else {
- // unless client is buggy, we should never reach here.
return stacktrace.NewError("actor %d with role %s is not allowed to remove files owned by collectionOwner %d", actorUserID, *role, collectionOwnerID)
}
}
- // Remove files owned by others if allowed
if len(others) > 0 {
if err := c.CollectionRepo.RemoveFilesV3(ctx, req.CollectionID, collectionOwnerID, others); err != nil {
return stacktrace.Propagate(err, "failed to remove files")
@@ -255,11 +239,9 @@ func (c *CollectionController) SuggestDeleteInSharedCollection(ctx *gin.Context,
if err != nil {
return stacktrace.Propagate(err, "failed to verify collection access")
}
- // Only owner or admin can suggest
if accessResp.Role == nil || (*accessResp.Role != ente.OWNER && *accessResp.Role != ente.ADMIN) {
return stacktrace.Propagate(ente.ErrPermissionDenied, "role not allowed to suggest delete")
}
- // Validate fileIDs exist in the collection and filter already-removed ones.
fileIDsToRemove, err := c.CollectionRepo.FilterActiveFileIDsInCollection(ctx, req.CollectionID, req.FileIDs)
if err != nil {
return stacktrace.Propagate(err, "file not found in collection")
@@ -267,7 +249,6 @@ func (c *CollectionController) SuggestDeleteInSharedCollection(ctx *gin.Context,
if len(fileIDsToRemove) == 0 {
return nil
}
- // Ensure none of the files belong to actor
ownerMap, err := c.FileRepo.GetOwnerToFileIDsMap(ctx, fileIDsToRemove)
if err != nil {
return stacktrace.Propagate(err, "failed to get owner map")
@@ -290,14 +271,12 @@ func (c *CollectionController) SuggestDeleteInSharedCollection(ctx *gin.Context,
return nil
}
-// isRemoveAllowed verifies that given set of files can be removed from the collection or not
func (c *CollectionController) isRemoveAllowed(ctx *gin.Context,
actorUserID int64,
collectionOwnerID int64,
role *ente.CollectionParticipantRole,
ownerToFilesMap map[int64][]int64) error {
- // verify that none of the file belongs to the collection owner
if _, ok := ownerToFilesMap[collectionOwnerID]; ok {
if collectionOwnerID == actorUserID {
return stacktrace.Propagate(ente.NewBadRequestWithMessage("can not remove files owned collection owner, admins can perform remove suggestion"), "")
@@ -305,20 +284,15 @@ func (c *CollectionController) isRemoveAllowed(ctx *gin.Context,
return stacktrace.Propagate(ente.NewBadRequestWithMessage("can not remove files owned by album owner"), "role %s", *role)
}
}
- // allow collection owner to remove files added by others
if collectionOwnerID == actorUserID {
return nil
}
- // allow admins to remove files added by anyone else.
if role != nil && *role == ente.ADMIN {
return nil
}
- // for collaborators and viewers, they should be only removing files added by themselfs.
- // verify that user is only trying to remove files owned by them
if len(ownerToFilesMap) > 1 {
return stacktrace.Propagate(ente.ErrPermissionDenied, "can not remove files owned by others")
}
- // verify that user is only trying to remove files owned by them
if _, ok := ownerToFilesMap[actorUserID]; !ok {
return stacktrace.Propagate(ente.ErrPermissionDenied, "can not remove files owned by others")
}
@@ -326,7 +300,6 @@ func (c *CollectionController) isRemoveAllowed(ctx *gin.Context,
}
func (c *CollectionController) IsCopyAllowed(ctx *gin.Context, actorUserID int64, req ente.CopyFileSyncRequest) error {
- // verify that srcCollectionID is accessible by actorUserID
srcCollection, err := c.AccessCtrl.GetCollection(ctx, &access.GetCollectionParams{
CollectionID: req.SrcCollectionID,
ActorUserID: actorUserID,
@@ -334,7 +307,6 @@ func (c *CollectionController) IsCopyAllowed(ctx *gin.Context, actorUserID int64
if err != nil {
return stacktrace.Propagate(err, "failed to verify srcCollection access")
}
- // verify that dstCollectionID is owned by actorUserID
dstCollection, err := c.AccessCtrl.GetCollection(ctx, &access.GetCollectionParams{
CollectionID: req.DstCollection,
ActorUserID: actorUserID,
@@ -346,7 +318,6 @@ func (c *CollectionController) IsCopyAllowed(ctx *gin.Context, actorUserID int64
if srcCollection.Collection.App != dstCollection.Collection.App {
return stacktrace.Propagate(ente.ErrInvalidApp, "copy across app not supported %s to %s", srcCollection.Collection.App, dstCollection.Collection.App)
}
- // verify that all FileIDs exists in the srcCollection
fileIDs := make([]int64, len(req.CollectionFileItems))
for idx, file := range req.CollectionFileItems {
fileIDs[idx] = file.ID
@@ -358,7 +329,6 @@ func (c *CollectionController) IsCopyAllowed(ctx *gin.Context, actorUserID int64
if err != nil {
return err
}
- // verify that none of the file belongs to actorUserID
if _, ok := dsMap[actorUserID]; ok {
return ente.NewBadRequestWithMessage("can not copy files owned by actor")
}
diff --git a/server/pkg/controller/collections/files_diff.go b/server/pkg/controller/collections/files_diff.go
index 95fab7c444..069bca5c2c 100644
--- a/server/pkg/controller/collections/files_diff.go
+++ b/server/pkg/controller/collections/files_diff.go
@@ -11,7 +11,6 @@ import (
log "github.com/sirupsen/logrus"
)
-// GetDiffV2 returns the changes in user's collections since a timestamp, along with hasMore bool flag.
func (c *CollectionController) GetDiffV2(ctx *gin.Context, cID int64, userID int64, sinceTime int64) ([]ente.File, bool, error) {
reqContextLogger := log.WithFields(log.Fields{
"user_id": userID,
diff --git a/server/pkg/controller/collections/share.go b/server/pkg/controller/collections/share.go
index 4b18f31b8f..92e3eafe9e 100644
--- a/server/pkg/controller/collections/share.go
+++ b/server/pkg/controller/collections/share.go
@@ -284,7 +284,6 @@ func (c *CollectionController) JoinViaLink(ctx *gin.Context, req ente.JoinCollec
return nil
}
-// UnShare unshares a collection with a user
func (c *CollectionController) UnShare(ctx *gin.Context, cID int64, fromUserID int64, toUserEmail string) ([]ente.CollectionUser, error) {
collection, err := c.collectionForShareMutation(cID, fromUserID)
if err != nil {
@@ -425,7 +424,6 @@ func shareeIndexForEmail(sharees []ente.CollectionUser, targetEmail string) int
})
}
-// Leave leaves the collection owned by someone else,
func (c *CollectionController) Leave(ctx *gin.Context, cID int64) error {
userID := auth.GetUserID(ctx.Request.Header)
collection, err := c.CollectionRepo.Get(cID)
@@ -475,7 +473,6 @@ func (c *CollectionController) UpdateShareeMagicMetadata(ctx *gin.Context, req e
return nil
}
-// ShareURL generates a public auth-token for the given collectionID
func (c *CollectionController) ShareURL(ctx *gin.Context, userID int64, req ente.CreatePublicAccessTokenRequest) (
ente.PublicURL, error) {
collection, err := c.CollectionRepo.Get(req.CollectionID)
@@ -497,7 +494,6 @@ func (c *CollectionController) ShareURL(ctx *gin.Context, userID int64, req ente
if !errors.Is(err, ente.ErrSharingDisabledForFreeAccounts) {
return ente.PublicURL{}, stacktrace.Propagate(err, "")
}
- // Override device limit for free users
req.DeviceLimit = public.FreeUserDeviceLimit
}
response, err := c.CollectionLinkCtrl.CreateLink(ctx, req)
@@ -507,7 +503,6 @@ func (c *CollectionController) ShareURL(ctx *gin.Context, userID int64, req ente
return response, nil
}
-// UpdateShareURL updates the shared url configuration
func (c *CollectionController) UpdateShareURL(
ctx *gin.Context,
userID int64,
@@ -522,11 +517,9 @@ func (c *CollectionController) UpdateShareURL(
err := c.BillingCtrl.HasActiveSelfOrFamilySubscription(userID, true)
if err != nil {
if errors.Is(err, ente.ErrSharingDisabledForFreeAccounts) {
- // Only throw error if free user tries to change device limit to non-default value
if req.DeviceLimit != nil && *req.DeviceLimit != public.FreeUserDeviceLimit {
return nil, stacktrace.Propagate(&ente.ErrLinkEditNotAllowed, "")
}
- // Allow other settings changes for free users
} else {
return nil, stacktrace.Propagate(err, "")
}
@@ -538,7 +531,6 @@ func (c *CollectionController) UpdateShareURL(
return &response, nil
}
-// DisableSharedURL disable a public auth-token for the given collectionID
func (c *CollectionController) DisableSharedURL(ctx context.Context, userID int64, cID int64) error {
if err := c.verifyOwnership(cID, userID); err != nil {
return stacktrace.Propagate(err, "")
@@ -547,7 +539,6 @@ func (c *CollectionController) DisableSharedURL(ctx context.Context, userID int6
return stacktrace.Propagate(err, "")
}
-// GetSharees returns the list of users a collection has been shared with
func (c *CollectionController) GetSharees(ctx *gin.Context, cID int64, userID int64) ([]ente.CollectionUser, error) {
_, err := c.AccessCtrl.GetCollection(ctx, &access.GetCollectionParams{
CollectionID: cID,
@@ -563,7 +554,6 @@ func (c *CollectionController) GetSharees(ctx *gin.Context, cID int64, userID in
return sharees, nil
}
-// GetPublicDiff returns the changes in the collections since a timestamp, along with hasMore bool flag.
func (c *CollectionController) GetPublicDiff(ctx *gin.Context, sinceTime int64) ([]ente.File, bool, error) {
accessContext := auth.MustGetPublicAccessContext(ctx)
reqContextLogger := log.WithFields(log.Fields{
diff --git a/server/pkg/controller/discountcoupon/controller.go b/server/pkg/controller/discountcoupon/controller.go
index 2576e58d68..231bd6eb7d 100644
--- a/server/pkg/controller/discountcoupon/controller.go
+++ b/server/pkg/controller/discountcoupon/controller.go
@@ -179,7 +179,6 @@ func (c *Controller) AddCoupons(ctx *gin.Context, req AddCouponsRequest) error {
return ente.NewBadRequestWithMessage("No coupon codes provided")
}
- // Filter out empty codes and validate
validCodes := make([]string, 0, len(req.Codes))
for _, code := range req.Codes {
trimmed := strings.TrimSpace(code)
diff --git a/server/pkg/controller/emergency/account_owner.go b/server/pkg/controller/emergency/account_owner.go
index c5c889fcc2..640e232898 100644
--- a/server/pkg/controller/emergency/account_owner.go
+++ b/server/pkg/controller/emergency/account_owner.go
@@ -129,12 +129,10 @@ func (c *Controller) GetInfo(ctx *gin.Context, userID int64) (*ente.EmergencyDat
}
func (c *Controller) UpdateRecoveryNotice(ctx *gin.Context, userID int64, request ente.UpdateRecoveryNotice) error {
- // Validate recovery notice is between 1 and 60 days
if request.RecoveryNoticeInDays < 1 || request.RecoveryNoticeInDays > 60 {
return stacktrace.Propagate(ente.NewBadRequestWithMessage("recovery notice must be between 1 and 60 days"), "")
}
- // Check if there's an active recovery session
activeSessions, err := c.Repo.GetActiveSessions(ctx, userID, request.EmergencyContactID)
if err != nil {
return stacktrace.Propagate(err, "failed to check active recovery sessions")
@@ -143,7 +141,6 @@ func (c *Controller) UpdateRecoveryNotice(ctx *gin.Context, userID int64, reques
return stacktrace.Propagate(ente.NewBadRequestWithMessage("cannot update recovery notice while there is an active recovery session"), "")
}
- // Update the recovery notice period
noticePeriodInHrs := request.RecoveryNoticeInDays * 24
err = c.Repo.UpdateRecoveryNotice(ctx, userID, request.EmergencyContactID, noticePeriodInHrs)
if err != nil {
diff --git a/server/pkg/controller/emergency/recovery.go b/server/pkg/controller/emergency/recovery.go
index 72e1383b19..0af90ffcc1 100644
--- a/server/pkg/controller/emergency/recovery.go
+++ b/server/pkg/controller/emergency/recovery.go
@@ -55,7 +55,6 @@ func (c *Controller) ChangePassword(ctx *gin.Context, userID int64, request ente
if err != nil {
return nil, err
}
- // disable 2fa
if disableErr := c.UserCtrl.DisableTwoFactor(contact.UserID); disableErr != nil {
return nil, stacktrace.Propagate(disableErr, "failed to disable 2fa")
}
@@ -156,15 +155,12 @@ func (c *Controller) SendRecoveryReminder() {
shouldUpdate bool
)
if daysLeft > 9 {
- // schedule another reminder after 7 days
nextReminder = row.NextReminderAt + int64(microsecondsInDay*7)
shouldUpdate = true
} else if daysLeft > 2 {
- // schedule the final reminder two days before waitTill
nextReminder = row.WaitTill - int64(microsecondsInDay*2)
shouldUpdate = true
} else {
- // final reminder already sent; wait until recovery becomes ready
nextReminder = row.WaitTill
shouldUpdate = true
}
diff --git a/server/pkg/controller/family/admin.go b/server/pkg/controller/family/admin.go
index bc52d5676b..a64bc1b3df 100644
--- a/server/pkg/controller/family/admin.go
+++ b/server/pkg/controller/family/admin.go
@@ -32,7 +32,6 @@ const (
SadHeaderImage = "iVBORw0KGgoAAAANSUhEUgAAAN4AAADeCAYAAABSZ763AAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAABjjSURBVHgB7Z1bbBzXecc/7lLkcilblOXKVqGYK6OODSSxqKdcAFcrC2hefH0pnMKCKMB20db1BYH7UAmQBFh9SBBYbpIWUFyYgoLEaB58UV4SQNZaRmv7SbQco3ZdxENbjWxFEimLXF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ILIqx97JXtHI1vTgv2LYsHQcmxIOztWeLrqID2goP4IVz9kZJl4vQFdh4jTUT1cgGVWjravpBxpMTL3uzOiZeCIczXv1p3ZIorUiN8IDEfUILLNI4nmuG1q6mH7ywbPm2yBwXwcVxLbWO55qRKovnha3fOC11upRIMI60uZZ+Uis8ANeTX/wXZZCSWSBridkoabNyXlLlavpxs5745JNul+yD9xgbV/Gep1l0INUWz4uTeNnHl50kZI4sWDkvmRGei8R+2QJWDjNRkhjPECWZEx5wjoZ+ij8lnyQhtTgn9ezTvRgehEwKz0Xcz3SSNbeyGZkWnou4n+nAERw2q1Yo4xghPBcRoLZYtLQ7fIIMwSjhuYgAtcEiwwTnYqTwXESAyeC4lIdNFJyL0cJzYQGWeTHslQ6YaDEphuuECM+DJwu6lcQKKgF1uFwud5gvEwMDA9qNYEgKEV4L4IbyJ/ROsYLBgHWr1+uvwp3MYh0uLCK8DjiN2Bg7eD+JFeyExZfDfJnIcg1OBSK8HsD0s/7+/nERYQMWLYmtIrFb94jwAgIRctxS5sv9prmjrhvJ16+IZQuGCE8BLLyRarVazufzZb67le+PUYZggSEp8katVqsUi8WKxGzhEeFFAIS4sLAA8aFMsZWtw1hahjQ5WcgK35zi268UCoVJEZp6RHgx4ZQqsGsCLirKFSNJCtIRmAVrxpbsXb5v8f1JcR3jQYSXMLCOc3NzJXZTRyBKCJEFMIrH+cv2xbkNSm1+zoxrmZxr3LdwnwU+xeKCyLCD2xoeHrbEiiXLnwDnkx8SBNVTNQAAAABJRU5ErkJggg=="
)
-// CreateFamily creates a family with current user as admin member
func (c *Controller) CreateFamily(ctx context.Context, adminUserID int64) error {
err := c.BillingCtrl.HasActiveSelfOrFamilySubscription(adminUserID, true)
if err != nil {
@@ -57,7 +56,6 @@ func (c *Controller) CreateFamily(ctx context.Context, adminUserID int64) error
return nil
}
-// InviteMember invites a user to join the family plan of admin User
func (c *Controller) InviteMember(ctx *gin.Context, adminUserID int64, email string, storageLimit *int64) error {
err := c.BillingCtrl.HasActiveSelfOrFamilySubscription(adminUserID, true)
if err != nil {
@@ -129,7 +127,6 @@ func (c *Controller) InviteMember(ctx *gin.Context, adminUserID int64, email str
return nil
}
-// RemoveMember verify admin -> memberID mapping & revokes the member's access from admin plan
func (c *Controller) RemoveMember(ctx context.Context, adminID int64, id uuid.UUID) error {
familyMember, err := c.FamilyRepo.GetMemberById(ctx, id)
if err != nil {
@@ -160,7 +157,6 @@ func (c *Controller) RemoveMember(ctx context.Context, adminID int64, id uuid.UU
return nil
}
-// RevokeInvite revokes a family invite which is not accepted yet
func (c *Controller) RevokeInvite(ctx context.Context, adminID int64, id uuid.UUID) error {
familyMember, err := c.FamilyRepo.GetMemberById(ctx, id)
if err != nil {
@@ -195,7 +191,6 @@ func (c *Controller) CloseFamily(ctx context.Context, adminID int64) error {
return nil
}
-// ModifyMemberStorage allows admin user to update the storageLimit for a member in the family
func (c *Controller) ModifyMemberStorage(ctx context.Context, actorUserID int64, id uuid.UUID, storageLimit *int64) error {
member, err := c.FamilyRepo.GetMemberById(ctx, id)
if err != nil {
@@ -214,7 +209,6 @@ func (c *Controller) ModifyMemberStorage(ctx context.Context, actorUserID int64,
return stacktrace.Propagate(ente.ErrBadRequest, "user is not a part of family")
}
- // gets admin subscription in order to get the size of total storage quota (including bonus)
if storageLimit != nil {
familyMembersData, err := c.FetchMembersForAdminID(ctx, member.AdminUserID)
if err != nil {
@@ -225,8 +219,6 @@ func (c *Controller) ModifyMemberStorage(ctx context.Context, actorUserID int64,
return stacktrace.Propagate(ente.ErrStorageLimitExceeded, "potential storage limit is more than subscription storage")
}
- // Handle if the admin user tries reducing the storage Limit
- // and the members Usage is more than the potential storage Limit
memberUsage, memUsageErr := c.UsageRepo.GetUsage(member.MemberUserID)
if memUsageErr != nil {
return stacktrace.Propagate(memUsageErr, "Couldn't find members storage usage")
diff --git a/server/pkg/controller/family/family.go b/server/pkg/controller/family/family.go
index 918f584678..53047fc706 100644
--- a/server/pkg/controller/family/family.go
+++ b/server/pkg/controller/family/family.go
@@ -18,11 +18,9 @@ import (
)
const (
- // maxFamilyMemberLimit number of folks who can be part of a family
maxFamilyMemberLimit = 6
)
-// Controller exposes functions to interact with family module
type Controller struct {
BillingCtrl *controller.BillingController
UserLookup controller.UserLookup
@@ -33,7 +31,6 @@ type Controller struct {
RemoteStoreRepo *remoteStoreRepo.Repository
}
-// FetchMembers return list of members who are part of a family plan
func (c *Controller) FetchMembers(ctx context.Context, userID int64) (ente.FamilyMemberResponse, error) {
user, err := c.UserRepo.Get(userID)
if err != nil {
@@ -71,7 +68,6 @@ func (c *Controller) FetchMembersForAdminID(ctx context.Context, familyAdminID i
for _, userUsageData := range usersUsageWithSubData {
if member.MemberUserID == userUsageData.UserID {
member.Email = *userUsageData.Email
- // return usage only if the member is part of family group
if member.Status == ente.ACCEPTED || member.Status == ente.SELF {
member.Usage = userUsageData.StorageConsumed
}
@@ -95,7 +91,7 @@ func (c *Controller) FetchMembersForAdminID(ctx context.Context, familyAdminID i
return ente.FamilyMemberResponse{
Members: familyMembers,
- Storage: adminSubStorage, // family plan storage
+ Storage: adminSubStorage,
ExpiryTime: adminSubExpiryTime,
AdminBonus: adminUsableBonus,
}, nil
diff --git a/server/pkg/controller/family/member.go b/server/pkg/controller/family/member.go
index 80b048e6fe..2d16327407 100644
--- a/server/pkg/controller/family/member.go
+++ b/server/pkg/controller/family/member.go
@@ -10,7 +10,6 @@ import (
"github.com/sirupsen/logrus"
)
-// LeaveFamily removes the actor user from the family in which the user belongs to.
func (c *Controller) LeaveFamily(ctx context.Context, userID int64) error {
user, err := c.UserRepo.Get(userID)
if err != nil {
@@ -18,7 +17,6 @@ func (c *Controller) LeaveFamily(ctx context.Context, userID int64) error {
}
if user.FamilyAdminID == nil {
logrus.WithField("user_id", userID).Info("not part of any family group")
- // user has either not joined any group or already left it.
return nil
}
if *user.FamilyAdminID == userID {
@@ -40,7 +38,6 @@ func (c *Controller) LeaveFamily(ctx context.Context, userID int64) error {
return nil
}
-// InviteInfo return basic information about the invite
func (c *Controller) InviteInfo(ctx context.Context, token string) (ente.InviteInfoResponse, error) {
familyMember, err := c.FamilyRepo.GetInvite(token)
if err != nil && errors.Is(err, sql.ErrNoRows) {
@@ -57,7 +54,6 @@ func (c *Controller) InviteInfo(ctx context.Context, token string) (ente.InviteI
return ente.InviteInfoResponse{}, stacktrace.Propagate(err, "failed to fetch user")
}
- // verify that the invitor is still an admin
if adminUser.FamilyAdminID == nil || *adminUser.FamilyAdminID != adminUser.ID {
return ente.InviteInfoResponse{}, stacktrace.Propagate(fmt.Errorf("inviter is no longer a admin of family plam "), "")
}
@@ -67,7 +63,6 @@ func (c *Controller) InviteInfo(ctx context.Context, token string) (ente.InviteI
}, nil
}
-// AcceptInvite accepts a family invite as long as it's in invited state.
func (c *Controller) AcceptInvite(ctx context.Context, token string) (ente.AcceptInviteResponse, error) {
familyMember, err := c.FamilyRepo.GetInvite(token)
if err != nil {
@@ -77,14 +72,11 @@ func (c *Controller) AcceptInvite(ctx context.Context, token string) (ente.Accep
if err != nil {
return ente.AcceptInviteResponse{}, stacktrace.Propagate(err, "failed to fetch user")
}
- // verify that the invitor is still an admin
if adminUser.FamilyAdminID == nil || *adminUser.FamilyAdminID != adminUser.ID {
return ente.AcceptInviteResponse{}, stacktrace.Propagate(fmt.Errorf("inviter is no longer a admin of family plam "), "")
}
- // Accept invitation and notify admin if it's not accepted already
if familyMember.Status != ente.ACCEPTED {
- // if the state is invited, accept the invitation and send email notification to the admin.
if familyMember.Status == ente.INVITED {
err = c.FamilyRepo.AcceptInvite(ctx, familyMember.AdminUserID, familyMember.MemberUserID, token)
if err != nil {
diff --git a/server/pkg/controller/file_copy/file_copy.go b/server/pkg/controller/file_copy/file_copy.go
index 49fd7b3219..8be4e5a594 100644
--- a/server/pkg/controller/file_copy/file_copy.go
+++ b/server/pkg/controller/file_copy/file_copy.go
@@ -157,10 +157,8 @@ func (fc *FileCopyController) CopyFiles(c *gin.Context, req ente.CopyFileSyncReq
})
}
- // Wait for all goroutines to finish
wg.Wait()
- // Close the error channel and check if there were any errors
close(errChan)
if err, ok := <-errChan; ok {
return nil, err
@@ -169,7 +167,6 @@ func (fc *FileCopyController) CopyFiles(c *gin.Context, req ente.CopyFileSyncReq
}
func (fc *FileCopyController) createCopy(c *gin.Context, fcInternal fileCopyInternal, userID int64, app ente.App) (*ente.File, error) {
- // using HotS3Client copy the File and Thumbnail
s3Client := fc.S3Config.GetHotS3Client()
hotBucket := fc.S3Config.GetHotBucket()
g := new(errgroup.Group)
@@ -190,7 +187,6 @@ func (fc *FileCopyController) createCopy(c *gin.Context, fcInternal fileCopyInte
return &newFile, nil
}
-// Helper function for S3 object copying.
func copyS3Object(s3Client *s3.S3, bucket *string, req *copyS3ObjectReq) error {
copySource := fmt.Sprintf("%s/%s", *bucket, req.SourceS3Object.ObjectKey)
copyInput := &s3.CopyObjectInput{
diff --git a/server/pkg/controller/memory_share/controller.go b/server/pkg/controller/memory_share/controller.go
index 7d09b68706..28787cf17d 100644
--- a/server/pkg/controller/memory_share/controller.go
+++ b/server/pkg/controller/memory_share/controller.go
@@ -18,14 +18,12 @@ const (
AccessTokenLength = 10
)
-// Controller handles memory share operations
type Controller struct {
Repo *repo.MemoryShareRepository
FileRepo *repo.FileRepository
AccessCtrl access.Controller
}
-// NewController creates a new memory share controller
func NewController(
repo *repo.MemoryShareRepository,
fileRepo *repo.FileRepository,
@@ -38,7 +36,6 @@ func NewController(
}
}
-// Create creates a new memory share
func (c *Controller) Create(ctx *gin.Context, userID int64, req ente.CreateMemoryShareRequest) (*ente.CreateMemoryShareResponse, error) {
shareType := req.Type
if shareType == "" {
diff --git a/server/pkg/controller/offer/offer.go b/server/pkg/controller/offer/offer.go
index ca3f5bb8e8..40f0d34015 100644
--- a/server/pkg/controller/offer/offer.go
+++ b/server/pkg/controller/offer/offer.go
@@ -24,7 +24,6 @@ import (
log "github.com/sirupsen/logrus"
)
-// OfferController controls all offer related operations
type OfferController struct {
BlackFridayOffers ente.BlackFridayOfferPerCountry
UserRepo repo.UserRepository
@@ -69,7 +68,6 @@ func (c *OfferController) GetBlackFridayOffers(countryCode string) []ente.BlackF
if offers, found := c.BlackFridayOffers[countryCode]; found {
return offers
}
- // unable to find plans for given country code, return plans for default country
defaultCountry := billing.GetDefaultPlanCountry()
return c.BlackFridayOffers[defaultCountry]
}
diff --git a/server/pkg/controller/public/anon_identity.go b/server/pkg/controller/public/anon_identity.go
index 93e1fd8e55..f6142b958d 100644
--- a/server/pkg/controller/public/anon_identity.go
+++ b/server/pkg/controller/public/anon_identity.go
@@ -12,20 +12,17 @@ import (
gonanoid "github.com/matoous/go-nanoid/v2"
)
-// AnonIdentityController issues anonymous identities for public commenters.
type AnonIdentityController struct {
JwtSecret []byte
AnonUsersRepo *socialrepo.AnonUsersRepository
}
-// AnonIdentityResponse is returned when minting anon identities.
type AnonIdentityResponse struct {
AnonUserID string `json:"anonUserID"`
Token string `json:"token"`
ExpiresAt int64 `json:"expiresAt"`
}
-// CreateAnonIdentityRequest captures the profile payload for a new anonymous user.
type CreateAnonIdentityRequest struct {
CollectionID int64
Cipher string
diff --git a/server/pkg/controller/public/collection_link.go b/server/pkg/controller/public/collection_link.go
index 774c5463d3..6d07fc4968 100644
--- a/server/pkg/controller/public/collection_link.go
+++ b/server/pkg/controller/public/collection_link.go
@@ -30,11 +30,9 @@ const (
DeviceLimitWarningThreshold = 2000
- // FreeUserDeviceLimit is the hardcoded device limit for free users
FreeUserDeviceLimit = 5
)
-// CollectionLinkController controls share collection operations
type CollectionLinkController struct {
FileController *controller.FileController
EmailNotificationCtrl *emailCtrl.EmailNotificationController
@@ -65,7 +63,6 @@ func (c *CollectionLinkController) CreateLink(ctx *gin.Context, req ente.CreateP
return publicUrls[0], nil
}
}
- // ideally we should never reach here
return ente.PublicURL{}, stacktrace.NewError("Unexpected state")
}
return ente.PublicURL{}, stacktrace.Propagate(err, "")
@@ -118,7 +115,6 @@ func (c *CollectionLinkController) CreateFile(ctx *gin.Context, file ente.File,
return createdFile, nil
}
-// Disable all public accessTokens generated for the given cID till date.
func (c *CollectionLinkController) Disable(ctx context.Context, cID int64) error {
err := c.CollectionLinkRepo.DisableSharing(ctx, cID)
return stacktrace.Propagate(err, "")
@@ -217,8 +213,6 @@ func (c *CollectionLinkController) HandleAccountDeletion(ctx context.Context, us
return c.FileLinkRepo.DisableLinksForUser(ctx, userID)
}
-// GetPublicCollection will return collection info for a public url.
-// is mustAllowCollect is set to true but the underlying collection doesn't allow uploading
func (c *CollectionLinkController) GetPublicCollection(ctx *gin.Context, mustAllowCollect bool) (ente.Collection, error) {
accessContext := auth.MustGetPublicAccessContext(ctx)
collection, err := c.CollectionRepo.Get(accessContext.CollectionID)
diff --git a/server/pkg/controller/public/comments.go b/server/pkg/controller/public/comments.go
index 1c59a002fd..3f3bcabe4f 100644
--- a/server/pkg/controller/public/comments.go
+++ b/server/pkg/controller/public/comments.go
@@ -19,7 +19,6 @@ import (
const maxCommentPayloadSize = 20 * 1024
-// CommentsController handles comments exposed via public collection links.
type CommentsController struct {
CommentCtrl *socialcontroller.CommentsController
CommentsRepo *socialrepo.CommentsRepository
@@ -30,7 +29,6 @@ type CommentsController struct {
JwtSecret []byte
}
-// CommentRequest models incoming payload for creating a comment.
type CommentRequest struct {
ID string `json:"id"`
FileID *int64 `json:"fileID"`
diff --git a/server/pkg/controller/public/file_link.go b/server/pkg/controller/public/file_link.go
index c9bbb9bef0..7a422dcc08 100644
--- a/server/pkg/controller/public/file_link.go
+++ b/server/pkg/controller/public/file_link.go
@@ -14,7 +14,6 @@ import (
"github.com/lithammer/shortuuid/v3"
)
-// FileLinkController controls share collection operations
type FileLinkController struct {
FileController *controller.FileController
FileLinkRepo *public.FileLinkRepository
@@ -66,7 +65,6 @@ func (c *FileLinkController) CreateLink(ctx *gin.Context, req ente.CreateFileUrl
return nil, stacktrace.Propagate(ente.ErrAccessTokenInUse, "failed to generate unique access token for file link")
}
-// Disable all public accessTokens generated for the given fileID till date.
func (c *FileLinkController) Disable(ctx *gin.Context, fileID int64) error {
userID := auth.GetUserID(ctx.Request.Header)
file, err := c.FileRepo.GetFileAttributes(fileID)
diff --git a/server/pkg/controller/public/link_common.go b/server/pkg/controller/public/link_common.go
index 0e32936005..7391950c46 100644
--- a/server/pkg/controller/public/link_common.go
+++ b/server/pkg/controller/public/link_common.go
@@ -42,7 +42,6 @@ func verifyPassword(secret []byte, expectedPassHash *string, req ente.VerifyPass
PassHash: req.PassHash,
ExpiryTime: time.NDaysFromNow(30),
})
- // Sign and get the complete encoded token as a string using the secret
tokenString, err := token.SignedString(secret)
if err != nil {
diff --git a/server/pkg/controller/public/link_device_token.go b/server/pkg/controller/public/link_device_token.go
index 3a2cc5ca82..d28c799fa4 100644
--- a/server/pkg/controller/public/link_device_token.go
+++ b/server/pkg/controller/public/link_device_token.go
@@ -23,7 +23,6 @@ const (
LinkDeviceTokenRefreshBefore = 30 * 24 * time.MicroSecondsInOneHour
)
-// LinkDeviceClaim represents a signed browser admission token for public links.
type LinkDeviceClaim struct {
Typ string `json:"typ"`
Scope string `json:"scope"`
diff --git a/server/pkg/controller/public/memory_share.go b/server/pkg/controller/public/memory_share.go
index cf1a035273..ae8cbc62b8 100644
--- a/server/pkg/controller/public/memory_share.go
+++ b/server/pkg/controller/public/memory_share.go
@@ -13,7 +13,6 @@ import (
"github.com/sirupsen/logrus"
)
-// MemoryShareController handles public memory share operations
type MemoryShareController struct {
Repo *repo.MemoryShareRepository
FileRepo *repo.FileRepository
@@ -21,7 +20,6 @@ type MemoryShareController struct {
FileController *controller.FileController
}
-// NewMemoryShareController creates a new public memory share controller
func NewMemoryShareController(
repo *repo.MemoryShareRepository,
fileRepo *repo.FileRepository,
@@ -36,7 +34,6 @@ func NewMemoryShareController(
}
}
-// GetPublicMemoryShare retrieves a public memory share by access token
func (c *MemoryShareController) GetPublicMemoryShare(ctx context.Context, accessToken string) (*ente.MemoryShare, error) {
share, err := c.Repo.GetByAccessToken(ctx, accessToken)
if err != nil {
@@ -51,7 +48,6 @@ func (c *MemoryShareController) GetPublicMemoryShare(ctx context.Context, access
return share, nil
}
-// GetPublicFiles retrieves all files in a public memory share
func (c *MemoryShareController) GetPublicFiles(ctx context.Context, shareID int64) (*ente.PublicMemoryShareFilesResponse, error) {
shareFiles, err := c.Repo.GetFiles(ctx, shareID)
if err != nil {
@@ -122,7 +118,6 @@ func (c *MemoryShareController) GetAccessibleFileOwnerID(ctx context.Context, sh
return ownerID, nil
}
-// GetPublicFileURL returns a signed URL for accessing a file in a public memory share
func (c *MemoryShareController) GetPublicFileURL(ctx *gin.Context, shareID int64, fileID int64, objType ente.ObjectType) (string, error) {
_, err := c.GetAccessibleFileOwnerID(ctx, shareID, fileID)
if err != nil {
diff --git a/server/pkg/controller/public/reactions.go b/server/pkg/controller/public/reactions.go
index 5ec8225078..a1fdd60178 100644
--- a/server/pkg/controller/public/reactions.go
+++ b/server/pkg/controller/public/reactions.go
@@ -11,7 +11,6 @@ import (
const reactionCipherLength = 156
-// ReactionsController exposes reactions for public collections.
type ReactionsController struct {
ReactionCtrl *socialcontroller.ReactionsController
ReactionsRepo *socialrepo.ReactionsRepository
diff --git a/server/pkg/controller/remotestore/controller.go b/server/pkg/controller/remotestore/controller.go
index 6792a0709b..6c72356ca3 100644
--- a/server/pkg/controller/remotestore/controller.go
+++ b/server/pkg/controller/remotestore/controller.go
@@ -26,7 +26,6 @@ const (
videoStreamingRolloutNonce = "video-streaming-v1"
)
-// Controller is interface for exposing business logic related to for remote store
type Controller struct {
Repo *remotestore.Repository
BillingCtrl *controller.BillingController
@@ -34,7 +33,6 @@ type Controller struct {
FamilyRepo *repo.FamilyRepository
}
-// InsertOrUpdate the key's value
func (c *Controller) InsertOrUpdate(ctx *gin.Context, request ente.UpdateKeyValueRequest) error {
userID := auth.GetUserID(ctx.Request.Header)
if err := c._validateRequest(userID, request.Key, request.Value, false); err != nil {
@@ -49,7 +47,6 @@ func (c *Controller) InsertOrUpdate(ctx *gin.Context, request ente.UpdateKeyValu
return c.Repo.InsertOrUpdate(ctx, userID, request.Key, *request.Value)
}
-// RemoveKey removes the key from remote store
func (c *Controller) RemoveKey(ctx *gin.Context, key string) error {
userID := auth.GetUserID(ctx.Request.Header)
if valid := ente.IsValidFlagKey(key); !valid {
@@ -104,7 +101,7 @@ func (c *Controller) GetFeatureFlags(ctx *gin.Context) (*ente.FeatureFlagRespons
return nil, stacktrace.Propagate(err, "")
}
response := &ente.FeatureFlagResponse{
- EnableStripe: true, // enable stripe for all
+ EnableStripe: true,
DisableCFWorker: false,
// When true, users will see an option to enable multiple part upload in the app
// Changing it to false will hide the option and disable multi part upload for everyone
diff --git a/server/pkg/controller/social/actor.go b/server/pkg/controller/social/actor.go
index 7937ddc6be..cbf0ef6221 100644
--- a/server/pkg/controller/social/actor.go
+++ b/server/pkg/controller/social/actor.go
@@ -2,18 +2,15 @@ package social
import "github.com/ente/museum/ente"
-// Actor represents a user identity (authenticated or anonymous) performing an action.
type Actor struct {
UserID *int64
AnonUserID *string
}
-// IsAnonymous reports whether the actor is using an anonymous persona.
func (a Actor) IsAnonymous() bool {
return a.UserID == nil
}
-// ValidateAnon ensures anonymous actors always supply an anonUserID.
func (a Actor) ValidateAnon() error {
if !a.IsAnonymous() {
return nil
@@ -24,7 +21,6 @@ func (a Actor) ValidateAnon() error {
return nil
}
-// UserIDValue returns the concrete userID if present.
func (a Actor) UserIDValue() (int64, bool) {
if a.UserID == nil {
return 0, false
diff --git a/server/pkg/controller/social/comments_controller.go b/server/pkg/controller/social/comments_controller.go
index 6c7bf237c0..7947191e74 100644
--- a/server/pkg/controller/social/comments_controller.go
+++ b/server/pkg/controller/social/comments_controller.go
@@ -10,14 +10,12 @@ import (
"github.com/gin-gonic/gin"
)
-// CommentsController wires comment-specific business logic.
type CommentsController struct {
Repo *socialrepo.CommentsRepository
CollectionRepo *repo.CollectionRepository
AccessCtrl access.Controller
}
-// CreateCommentRequest encapsulates parameters for adding a comment.
type CreateCommentRequest struct {
Actor Actor
CollectionID int64
@@ -29,7 +27,6 @@ type CreateCommentRequest struct {
RequireAccess bool
}
-// CommentDiffRequest describes the paging request for a collection's comments.
type CommentDiffRequest struct {
Actor Actor
CollectionID int64
@@ -39,7 +36,6 @@ type CommentDiffRequest struct {
RequireAccess bool
}
-// UpdateCommentRequest holds the information needed to edit a comment.
type UpdateCommentRequest struct {
Actor Actor
CommentID string
@@ -48,14 +44,12 @@ type UpdateCommentRequest struct {
RequireAccess bool
}
-// DeleteCommentRequest defines the delete operation parameters.
type DeleteCommentRequest struct {
Actor Actor
CommentID string
RequireAccess bool
}
-// Create inserts a new comment; returns the supplied ID on success.
func (c *CommentsController) Create(ctx *gin.Context, req CreateCommentRequest) (string, error) {
var err error
req.ID, err = NormalizeCommentID(req.ID)
@@ -132,7 +126,6 @@ func (c *CommentsController) Create(ctx *gin.Context, req CreateCommentRequest)
return comment.ID, nil
}
-// Diff returns a window of comments for the requested collection.
func (c *CommentsController) Diff(ctx *gin.Context, req CommentDiffRequest) ([]socialentity.Comment, bool, error) {
userID, hasUserID := req.Actor.UserIDValue()
if req.RequireAccess {
@@ -149,7 +142,6 @@ func (c *CommentsController) Diff(ctx *gin.Context, req CommentDiffRequest) ([]s
return c.Repo.GetDiff(ctx, req.CollectionID, req.Since, req.Limit, req.FileID)
}
-// UpdatePayload edits the encrypted payload of a comment.
func (c *CommentsController) UpdatePayload(ctx *gin.Context, req UpdateCommentRequest) error {
if len(req.Cipher) == 0 || len(req.Nonce) == 0 {
return ente.ErrBadRequest
@@ -172,7 +164,6 @@ func (c *CommentsController) UpdatePayload(ctx *gin.Context, req UpdateCommentRe
return c.Repo.UpdateCipher(ctx, req.CommentID, req.Cipher, req.Nonce)
}
-// Delete removes a comment if the actor is allowed to do so.
func (c *CommentsController) Delete(ctx *gin.Context, req DeleteCommentRequest) error {
userID, hasUserID := req.Actor.UserIDValue()
comment, err := c.Repo.GetByID(ctx, req.CommentID)
diff --git a/server/pkg/controller/social/controller.go b/server/pkg/controller/social/controller.go
index b8f638bb9e..a098b4606e 100644
--- a/server/pkg/controller/social/controller.go
+++ b/server/pkg/controller/social/controller.go
@@ -13,7 +13,6 @@ import (
"github.com/gin-gonic/gin"
)
-// Controller combines comments and reactions for unified endpoints.
type Controller struct {
CommentsRepo *socialrepo.CommentsRepository
ReactionsRepo *socialrepo.ReactionsRepository
@@ -22,7 +21,6 @@ type Controller struct {
AnonUsersRepo *socialrepo.AnonUsersRepository
}
-// UnifiedDiffRequest describes paging parameters for the social diff.
type UnifiedDiffRequest struct {
Actor Actor
CollectionID int64
@@ -33,14 +31,12 @@ type UnifiedDiffRequest struct {
RequireAccess bool
}
-// CollectionCount summarizes activity for a collection.
type CollectionCount struct {
CollectionID int64 `json:"collectionID"`
Comments int64 `json:"comments"`
Reactions int64 `json:"reactions"`
}
-// CollectionLatestUpdate captures the latest activity timestamps per collection.
type CollectionLatestUpdate struct {
CollectionID int64 `json:"collectionID"`
CommentsUpdatedAt *int64 `json:"commentsUpdatedAt,omitempty"`
@@ -48,14 +44,12 @@ type CollectionLatestUpdate struct {
AnonProfilesUpdatedAt *int64 `json:"anonProfilesUpdatedAt,omitempty"`
}
-// AnonProfilesRequest describes the parameters for listing anonymous profiles.
type AnonProfilesRequest struct {
Actor Actor
CollectionID int64
RequireAccess bool
}
-// UnifiedDiff returns comments and reactions snapshots side by side.
func (c *Controller) UnifiedDiff(ctx *gin.Context, req UnifiedDiffRequest) ([]socialentity.Comment, []socialentity.Reaction, bool, bool, error) {
if req.RequireAccess {
userID, hasUserID := req.Actor.UserIDValue()
@@ -80,7 +74,6 @@ func (c *Controller) UnifiedDiff(ctx *gin.Context, req UnifiedDiffRequest) ([]so
return comments, reactions, moreComments, moreReactions, nil
}
-// CountActiveCollections returns the active counts per collection accessible to the actor.
func (c *Controller) CountActiveCollections(ctx context.Context, userID int64) ([]CollectionCount, error) {
ownedMap, err := c.CollectionRepo.GetCollectionIDsOwnedByUser(userID)
if err != nil {
@@ -130,7 +123,6 @@ func (c *Controller) CountActiveCollections(ctx context.Context, userID int64) (
return results, nil
}
-// LatestUpdates returns the most recent comment/reaction timestamps for collections accessible to the user.
func (c *Controller) LatestUpdates(ctx context.Context, userID int64, app ente.App) ([]CollectionLatestUpdate, error) {
ownedMap, err := c.CollectionRepo.GetCollectionIDsOwnedByUser(userID)
if err != nil {
@@ -229,7 +221,6 @@ func (c *Controller) LatestUpdates(ctx context.Context, userID int64, app ente.A
return results, nil
}
-// ListAnonProfiles returns encrypted anonymous profiles for a collection when allowed.
func (c *Controller) ListAnonProfiles(ctx *gin.Context, req AnonProfilesRequest) ([]socialentity.AnonUser, error) {
if req.RequireAccess {
userID, hasUserID := req.Actor.UserIDValue()
diff --git a/server/pkg/controller/social/id_helper.go b/server/pkg/controller/social/id_helper.go
index 05eaf4b871..55bcd52727 100644
--- a/server/pkg/controller/social/id_helper.go
+++ b/server/pkg/controller/social/id_helper.go
@@ -14,12 +14,10 @@ const (
nanoidSuffixLength = 21
)
-// NormalizeCommentID optionally generates or validates a comment ID.
func NormalizeCommentID(id string) (string, error) {
return normalizeOrGenerateID(commentIDPrefix, id)
}
-// NormalizeReactionID optionally generates or validates a reaction ID.
func NormalizeReactionID(id string) (string, error) {
return normalizeOrGenerateID(reactionIDPrefix, id)
}
diff --git a/server/pkg/controller/social/reactions_controller.go b/server/pkg/controller/social/reactions_controller.go
index 23b93c4ad1..2a09f65d63 100644
--- a/server/pkg/controller/social/reactions_controller.go
+++ b/server/pkg/controller/social/reactions_controller.go
@@ -10,7 +10,6 @@ import (
"github.com/gin-gonic/gin"
)
-// ReactionsController orchestrates reactions operations.
type ReactionsController struct {
Repo *socialrepo.ReactionsRepository
CommentsRepo *socialrepo.CommentsRepository
@@ -18,7 +17,6 @@ type ReactionsController struct {
AccessCtrl access.Controller
}
-// UpsertReactionRequest holds the payload for creating or updating a reaction.
type UpsertReactionRequest struct {
Actor Actor
ID string
@@ -30,7 +28,6 @@ type UpsertReactionRequest struct {
RequireAccess bool
}
-// ReactionDiffRequest describes paging for reactions.
type ReactionDiffRequest struct {
Actor Actor
CollectionID int64
@@ -41,14 +38,12 @@ type ReactionDiffRequest struct {
RequireAccess bool
}
-// ReactionDeleteRequest contains parameters to remove a reaction.
type ReactionDeleteRequest struct {
Actor Actor
ReactionID string
RequireAccess bool
}
-// Upsert creates or updates a reaction entry.
func (c *ReactionsController) Upsert(ctx *gin.Context, req UpsertReactionRequest) (string, error) {
var err error
req.ID, err = NormalizeReactionID(req.ID)
@@ -126,7 +121,6 @@ func (c *ReactionsController) Upsert(ctx *gin.Context, req UpsertReactionRequest
return id, nil
}
-// Diff returns reaction windows for the provided scope.
func (c *ReactionsController) Diff(ctx *gin.Context, req ReactionDiffRequest) ([]socialentity.Reaction, bool, error) {
userID, hasUserID := req.Actor.UserIDValue()
if req.RequireAccess {
@@ -143,7 +137,6 @@ func (c *ReactionsController) Diff(ctx *gin.Context, req ReactionDiffRequest) ([
return c.Repo.GetDiff(ctx, req.CollectionID, req.Since, req.Limit, req.FileID, req.CommentID)
}
-// Delete removes a reaction if the actor owns it.
func (c *ReactionsController) Delete(ctx *gin.Context, req ReactionDeleteRequest) error {
userID, hasUserID := req.Actor.UserIDValue()
reaction, err := c.Repo.GetByID(ctx, req.ReactionID)
diff --git a/server/pkg/controller/storagebonus/bonus.go b/server/pkg/controller/storagebonus/bonus.go
index 19e23261e8..c1959c2fa7 100644
--- a/server/pkg/controller/storagebonus/bonus.go
+++ b/server/pkg/controller/storagebonus/bonus.go
@@ -9,12 +9,10 @@ import (
"github.com/sirupsen/logrus"
)
-// GetActiveReferralBonusValue returns the storage bonus value for the user
func (c *Controller) GetActiveReferralBonusValue(ctx context.Context, userID int64) (*int64, error) {
return c.StorageBonus.ActiveStorageSurplusOfType(ctx, userID, []entity.BonusType{entity.Referral, entity.SignUp})
}
-// GetStorageBonusDetailResponse returns the storage bonus detail for the user
func (c *Controller) GetStorageBonusDetailResponse(ctx *gin.Context, userID int64) (*entity.GetStorageBonusDetailResponse, error) {
user, err := c.UserRepo.Get(userID)
@@ -35,7 +33,6 @@ func (c *Controller) GetStorageBonusDetailResponse(ctx *gin.Context, userID int6
return nil, stacktrace.Propagate(err, "")
}
hasAppliedCode := false
- // check if storage bonus has type SIGNUP and if it is, set hasAppliedCode to true
for _, bonus := range storageBonuses {
if bonus.Type == entity.SignUp {
hasAppliedCode = true
diff --git a/server/pkg/controller/storagebonus/referral.go b/server/pkg/controller/storagebonus/referral.go
index 8d5f94c1f0..67067e07d2 100644
--- a/server/pkg/controller/storagebonus/referral.go
+++ b/server/pkg/controller/storagebonus/referral.go
@@ -26,7 +26,6 @@ const (
defaultPlanType = entity.TenGbOnUpgrade
)
-// Controller exposes functions to interact with family module
type Controller struct {
UserRepo *repo.UserRepository
StorageBonus *storagebonus.Repository
@@ -36,10 +35,8 @@ type Controller struct {
}
func (c *Controller) GetUserReferralView(ctx *gin.Context) (*entity.GetUserReferralView, error) {
- // Get the user id from the context
userID := auth.GetUserID(ctx.Request.Header)
- // Use goroutines to fetch UserRepo.Get, HasAppliedReferral
user, err := c.UserRepo.Get(userID)
if err != nil {
return nil, stacktrace.Propagate(err, "failed to get user")
@@ -50,7 +47,6 @@ func (c *Controller) GetUserReferralView(ctx *gin.Context) (*entity.GetUserRefer
}
isFamilyMember := user.FamilyAdminID != nil && *user.FamilyAdminID != userID
enableApplyCode := !appliedReferral && !isFamilyMember
- // Get the referral code for the user or family admin
codeUser := userID
if isFamilyMember {
codeUser = *user.FamilyAdminID
@@ -92,7 +88,6 @@ func (c *Controller) GetUserReferralView(ctx *gin.Context) (*entity.GetUserRefer
}
func (c *Controller) ApplyReferralCode(ctx *gin.Context, code string) error {
- // Get user id from the context
userID := auth.GetUserID(ctx.Request.Header)
user, err := c.UserRepo.Get(userID)
if err != nil {
@@ -103,7 +98,6 @@ func (c *Controller) ApplyReferralCode(ctx *gin.Context, code string) error {
if err != nil {
return stacktrace.Propagate(err, "failed to get user id by code")
}
- // Verify that the codeOwnerID is not deleted yet
_, err = c.UserRepo.Get(*codeOwnerID)
if err != nil {
if errors.Is(err, ente.ErrUserDeleted) {
@@ -151,7 +145,6 @@ func (c *Controller) UpdateReferralCode(ctx *gin.Context, userID int64, code str
return stacktrace.Propagate(ente.NewBadRequestWithMessage("code length should be between 4 and 8"), "")
}
- // Check if the code contains any offensive language using the go-away library
if goaway.IsProfane(code) {
return stacktrace.Propagate(ente.NewBadRequestWithMessage("Referral code contains offensive language and cannot be used"), "")
}
diff --git a/server/pkg/controller/storagebonus/referral_cron.go b/server/pkg/controller/storagebonus/referral_cron.go
index b6385c8613..b0a33ec7c3 100644
--- a/server/pkg/controller/storagebonus/referral_cron.go
+++ b/server/pkg/controller/storagebonus/referral_cron.go
@@ -7,9 +7,6 @@ import (
"github.com/sirupsen/logrus"
)
-// PaymentUpgradeOrDowngradeCron cron which returns if CronRunning is true and if false,
-// it acquires a lock using the lock controller and sets CronRunning to true.
-// It then runs the cron and sets CronRunning to false.
func (c *Controller) PaymentUpgradeOrDowngradeCron() {
cronName := "payment_upgrade_or_downgrade"
logger := logrus.WithField("cron", cronName)
diff --git a/server/pkg/controller/usercache/controller.go b/server/pkg/controller/usercache/controller.go
index 05d7474b72..9c0ca3d230 100644
--- a/server/pkg/controller/usercache/controller.go
+++ b/server/pkg/controller/usercache/controller.go
@@ -9,8 +9,6 @@ import (
"github.com/ente/stacktrace"
)
-// Controller is the controller for the data cache.
-// It contains all the repositories that are used by the controller.
// Avoid adding any direct dependencies to the other controller.
type Controller struct {
FileRepo *repo.FileRepository
@@ -21,7 +19,6 @@ type Controller struct {
}
func (c *Controller) GetActiveStorageBonus(ctx context.Context, userID int64) (*bonus.ActiveStorageBonus, error) {
- // Check if the value is present in the cache
if bonus, ok := c.UserCache.GetBonus(userID); ok {
// Cache hit, update the cache asynchronously
go func() {
diff --git a/server/pkg/controller/usercache/count.go b/server/pkg/controller/usercache/count.go
index 1052715e16..942258dc5f 100644
--- a/server/pkg/controller/usercache/count.go
+++ b/server/pkg/controller/usercache/count.go
@@ -8,7 +8,6 @@ import (
)
func (c *Controller) GetUserFileCountWithCache(userID int64, app ente.App) (int64, error) {
- // Check if the value is present in the cache
if count, ok := c.UserCache.GetFileCount(userID, app); ok {
// Cache hit, update the cache asynchronously
go func() {
diff --git a/server/pkg/controller/userentity/controller.go b/server/pkg/controller/userentity/controller.go
index 7d4020a96f..43d4ae682d 100644
--- a/server/pkg/controller/userentity/controller.go
+++ b/server/pkg/controller/userentity/controller.go
@@ -9,12 +9,10 @@ import (
"github.com/gin-gonic/gin"
)
-// Controller is interface for exposing business logic related to authenticator app
type Controller struct {
Repo *userentity.Repository
}
-// CreateKey stores an entity key for the given type
func (c *Controller) CreateKey(ctx *gin.Context, req model.EntityKeyRequest) error {
userID := auth.GetUserID(ctx.Request.Header)
return c.Repo.CreateKey(ctx, userID, req)
@@ -29,7 +27,6 @@ func (c *Controller) EnsureKey(ctx *gin.Context, req model.EntityKeyRequest) (*m
return &res, nil
}
-// GetKey
func (c *Controller) GetKey(ctx *gin.Context, req model.GetEntityKeyRequest) (*model.EntityKey, error) {
userID := auth.GetUserID(ctx.Request.Header)
res, err := c.Repo.GetKey(ctx, userID, req.Type)
@@ -39,7 +36,6 @@ func (c *Controller) GetKey(ctx *gin.Context, req model.GetEntityKeyRequest) (*m
return &res, nil
}
-// CreateEntity stores entity data for the given type
func (c *Controller) CreateEntity(ctx *gin.Context, req model.EntityDataRequest) (*model.EntityData, error) {
userID := auth.GetUserID(ctx.Request.Header)
if err := req.IsValid(userID); err != nil {
@@ -52,7 +48,6 @@ func (c *Controller) CreateEntity(ctx *gin.Context, req model.EntityDataRequest)
return c.Repo.Get(ctx, userID, id)
}
-// UpdateEntity...
func (c *Controller) UpdateEntity(ctx *gin.Context, req model.UpdateEntityDataRequest) (*model.EntityData, error) {
userID := auth.GetUserID(ctx.Request.Header)
err := c.Repo.Update(ctx, userID, req)
@@ -62,13 +57,11 @@ func (c *Controller) UpdateEntity(ctx *gin.Context, req model.UpdateEntityDataRe
return c.Repo.Get(ctx, userID, req.ID)
}
-// Delete...
func (c *Controller) Delete(ctx *gin.Context, entityID string) (bool, error) {
userID := auth.GetUserID(ctx.Request.Header)
return c.Repo.Delete(ctx, userID, entityID)
}
-// GetDiff returns diff of EntityData for the given type
func (c *Controller) GetDiff(ctx *gin.Context, req model.GetEntityDiffRequest) ([]model.EntityData, error) {
if req.Limit <= 0 || req.Limit > 5000 {
return nil, ente.NewBadRequestWithMessage("limit must be between 1 and 5000")