Skip to content

armgit / ente

Public Imported from GitHub
0

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

Prune server entity comments

Manav Rathi4c1e9a3324dc
diff --git a/server/ente/access.go b/server/ente/access.go
index b52c073d3c..bf76a74fc1 100644
--- a/server/ente/access.go
+++ b/server/ente/access.go
@@ -17,7 +17,6 @@ func (c *CollectionParticipantRole) CanAdd() bool {
return *c == OWNER || *c == COLLABORATOR || *c == ADMIN
}
-// CanRemoveAny indicates if the role allows user to remove files added by others too
func (c *CollectionParticipantRole) CanRemoveAny() bool {
if c == nil {
return false
diff --git a/server/ente/admin.go b/server/ente/admin.go
index 0bb34f6f49..e50cc3fe4c 100644
--- a/server/ente/admin.go
+++ b/server/ente/admin.go
@@ -6,7 +6,6 @@ import (
"time"
)
-// GetEmailsFromHashesRequest represents a request to convert hashes
type GetEmailsFromHashesRequest struct {
Hashes []string `json:"hashes"`
}
@@ -62,13 +61,11 @@ type AdminOpsForUserRequest struct {
EmailMFA *bool `json:"emailMFA"`
}
-// ReQueueItemRequest puts an item back into the queue for processing.
type ReQueueItemRequest struct {
ID int64 `json:"id" binding:"required"`
QueueName string `json:"queueName" binding:"required"`
}
-// RecoverAccount is used to recover accounts which are in soft-delete state.
type RecoverAccountRequest struct {
UserID int64 `json:"userID" binding:"required"`
EmailID string `json:"emailID" binding:"required"`
@@ -83,7 +80,6 @@ type ScheduledDeletion struct {
AuthenticatorEntryCount int64 `json:"authenticatorEntryCount"`
}
-// UpdateSubscriptionRequest is used to update a user's subscription
type UpdateSubscriptionRequest struct {
AdminID int64 `json:"-"`
UserID int64 `json:"userID" binding:"required"`
diff --git a/server/ente/anonymous_identity.go b/server/ente/anonymous_identity.go
index d664cac5ab..a1212bc7f4 100644
--- a/server/ente/anonymous_identity.go
+++ b/server/ente/anonymous_identity.go
@@ -9,13 +9,11 @@ import (
const anonIdentityTokenType = "anon-identity"
-// AnonymousIdentityClaim represents the JWT issued for anonymous commenters.
type AnonymousIdentityClaim struct {
Typ string `json:"typ"`
jwt.RegisteredClaims
}
-// NewAnonymousIdentityToken signs a token for the provided anonUserID.
func NewAnonymousIdentityToken(secret []byte, anonUserID string) (string, int64, error) {
issuedAt := time.Now()
expiry := issuedAt.AddDate(1, 0, 0) // 1 year validity
@@ -36,7 +34,6 @@ func NewAnonymousIdentityToken(secret []byte, anonUserID string) (string, int64,
return tokenString, MicrosecondsFromTime(expiry), nil
}
-// ParseAnonymousIdentityToken validates the token and returns the parsed claim.
func ParseAnonymousIdentityToken(secret []byte, tokenString string) (*AnonymousIdentityClaim, error) {
token, err := jwt.ParseWithClaims(tokenString, &AnonymousIdentityClaim{}, func(t *jwt.Token) (interface{}, error) {
if _, ok := t.Method.(*jwt.SigningMethodHMAC); !ok {
diff --git a/server/ente/app.go b/server/ente/app.go
index bd02ed08f6..ad3150fbda 100644
--- a/server/ente/app.go
+++ b/server/ente/app.go
@@ -1,6 +1,5 @@
package ente
-// PaymentProvider represents the payment provider via which a purchase was made
type App string
const (
@@ -9,7 +8,6 @@ const (
Locker App = "locker"
)
-// Check if the app string is valid
func (a App) IsValid() bool {
switch a {
case Photos, Auth, Locker:
@@ -18,7 +16,6 @@ func (a App) IsValid() bool {
return false
}
-// IsValidForCollection returns True if the given app type can create collections
func (a App) IsValidForCollection() bool {
switch a {
case Photos, Locker:
diff --git a/server/ente/authenticator/authenticator.go b/server/ente/authenticator/authenticator.go
index 4989333a57..82c36b06e8 100644
--- a/server/ente/authenticator/authenticator.go
+++ b/server/ente/authenticator/authenticator.go
@@ -9,7 +9,6 @@ type Key struct {
CreatedAt int64 `json:"createdAt" binding:"required"`
}
-// Entity represents a single TOTP Entity
type Entity struct {
ID uuid.UUID `json:"id" binding:"required"`
UserID int64 `json:"userID" binding:"required"`
@@ -20,26 +19,22 @@ type Entity struct {
UpdatedAt int64 `json:"updatedAt" binding:"required"`
}
-// CreateKeyRequest represents a request to create totp encryption key for user
type CreateKeyRequest struct {
EncryptedKey string `json:"encryptedKey" binding:"required"`
Header string `json:"header" binding:"required"`
}
-// CreateEntityRequest...
type CreateEntityRequest struct {
EncryptedData string `json:"encryptedData" binding:"required"`
Header string `json:"header" binding:"required"`
}
-// UpdateEntityRequest...
type UpdateEntityRequest struct {
ID uuid.UUID `json:"id" binding:"required"`
EncryptedData string `json:"encryptedData" binding:"required"`
Header string `json:"header" binding:"required"`
}
-// GetEntityDiffRequest...
type GetEntityDiffRequest struct {
// SinceTime *int64. Pointer allows us to pass 0 value otherwise binding fails for zero Value.
SinceTime *int64 `form:"sinceTime" binding:"required"`
diff --git a/server/ente/base/id.go b/server/ente/base/id.go
index 8d7e3aac52..b6706f01a6 100644
--- a/server/ente/base/id.go
+++ b/server/ente/base/id.go
@@ -7,21 +7,17 @@ import (
"github.com/matoous/go-nanoid/v2"
)
-// Ref https://github.com/ente/ente/blob/main/web/packages/base/id.ts#L4
const alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
-// NewID generates a new random identifier with the given prefix.
func NewID(prefix string) (*string, error) {
if len(prefix) < 2 {
return nil, errors.New("prefix must be at least 2 characters long")
}
- // check that prefix only contains alphabet characters
for _, c := range prefix {
if !(c >= 'a' && c <= 'z') {
return nil, errors.New("prefix must only contain lower case alphabet characters")
}
}
- // Generate a nanoid with a custom alphabet and length of 22
id, err := gonanoid.Generate(alphabet, 22)
if err != nil {
return nil, err
@@ -39,7 +35,6 @@ func MustNewID(prefix string) string {
}
func ServerReqID() string {
- // Generate a nanoid with a custom alphabet and length of 22
id, err := NewID("ser")
if err != nil {
return "ser_" + uuid.New().String()
diff --git a/server/ente/cache/user_data_cache.go b/server/ente/cache/user_data_cache.go
index a5972e1d06..d12952a793 100644
--- a/server/ente/cache/user_data_cache.go
+++ b/server/ente/cache/user_data_cache.go
@@ -7,7 +7,6 @@ import (
"sync"
)
-// UserCache struct holds can be used to fileCount various entities for user.
type UserCache struct {
mu sync.Mutex
fileCache map[string]*FileCountCache
@@ -20,7 +19,6 @@ type FileCountCache struct {
Usage int64
}
-// NewUserCache creates a new instance of the UserCache struct.
func NewUserCache() *UserCache {
return &UserCache{
fileCache: make(map[string]*FileCountCache),
@@ -28,7 +26,6 @@ func NewUserCache() *UserCache {
}
}
-// SetFileCount updates the fileCount with the given userID and fileCount.
func (c *UserCache) SetFileCount(userID int64, fileCount *FileCountCache, app ente.App) {
c.mu.Lock()
defer c.mu.Unlock()
@@ -48,8 +45,6 @@ func (c *UserCache) GetBonus(userID int64) (*storagebonus.ActiveStorageBonus, bo
return bonus, ok
}
-// GetFileCount retrieves the file count from the fileCount for the given userID.
-// It returns the file count and a boolean indicating if the value was found.
func (c *UserCache) GetFileCount(userID int64, app ente.App) (*FileCountCache, bool) {
c.mu.Lock()
defer c.mu.Unlock()
diff --git a/server/ente/cast/entity.go b/server/ente/cast/entity.go
index 232614caa4..b60d310c58 100644
--- a/server/ente/cast/entity.go
+++ b/server/ente/cast/entity.go
@@ -2,7 +2,6 @@ package cast
import "github.com/google/uuid"
-// CastRequest ..
type CastRequest struct {
CollectionID int64 `json:"collectionID" binding:"required"`
CastToken string `json:"castToken" binding:"required"`
diff --git a/server/ente/data_cleanup/entity.go b/server/ente/data_cleanup/entity.go
index 0d98eec9ac..35fc0b9472 100644
--- a/server/ente/data_cleanup/entity.go
+++ b/server/ente/data_cleanup/entity.go
@@ -1,27 +1,19 @@
package data_cleanup
-// Stage represents the action to be taken on the next scheduled run for a particular stage
type Stage string
const (
- // Scheduled means user data is scheduled for deletion
- Scheduled Stage = "scheduled"
- // Collection means trash all collections for the user
+ Scheduled Stage = "scheduled"
Collection Stage = "collection"
- // Trash means trigger empty trash for the user
- Trash Stage = "trash"
- // Storage means check for consumed storage
- Storage Stage = "storage"
- // Completed means data clean up is done
- Completed Stage = "completed"
+ Trash Stage = "trash"
+ Storage Stage = "storage"
+ Completed Stage = "completed"
)
type DataCleanup struct {
- UserID int64
- Stage Stage
- // StageScheduleTime indicates when should we process current stage
+ UserID int64
+ Stage Stage
StageScheduleTime int64
- // StageAttemptCount refers to number of attempts made to execute current stage
StageAttemptCount int
CreatedAt int64
UpdatedAt int64
diff --git a/server/ente/details/userdetails.go b/server/ente/details/userdetails.go
index 3baae9acf6..bcd477f0f8 100644
--- a/server/ente/details/userdetails.go
+++ b/server/ente/details/userdetails.go
@@ -19,7 +19,6 @@ type UserDetailsResponse struct {
BonusData *storagebonus.ActiveStorageBonus `json:"bonusData"`
}
-// LockerFamilyUsage contains locker-specific usage data for family members
type LockerFamilyUsage struct {
FamilyFileCount int64 `json:"familyFileCount"`
}
diff --git a/server/ente/family.go b/server/ente/family.go
index 9e6da1a805..cb8a3e5dd5 100644
--- a/server/ente/family.go
+++ b/server/ente/family.go
@@ -58,8 +58,7 @@ type ModifyMemberStorage struct {
type FamilyMemberResponse struct {
Members []FamilyMember `json:"members" binding:"required"`
// Family admin subscription storage capacity. This excludes add-on and any other bonus storage
- Storage int64 `json:"storage" binding:"required"`
- // Family admin subscription expiry time
+ Storage int64 `json:"storage" binding:"required"`
ExpiryTime int64 `json:"expiryTime" binding:"required"`
AdminBonus int64 `json:"adminBonus" binding:"required"`
@@ -70,10 +69,7 @@ type UserUsageWithSubData struct {
// StorageConsumed by the current member.
// This information should not be sent back in the response if the membership status is `INVITED`
StorageConsumed int64
- // ExpiryTime of member's current subscription plan
- ExpiryTime int64
- // Storage indicates storage capacity based on member's current subscription plan
- Storage int64
- // Email of the member. It will be populated on need basis
- Email *string
+ ExpiryTime int64
+ Storage int64
+ Email *string
}
diff --git a/server/ente/offer.go b/server/ente/offer.go
index 0b230b24ce..caf354bd4c 100644
--- a/server/ente/offer.go
+++ b/server/ente/offer.go
@@ -1,6 +1,5 @@
package ente
-// BlackFridayOffer represents the latest Black Friday Offer
type BlackFridayOffer struct {
ID string `json:"id"`
Storage int64 `json:"storage"`
diff --git a/server/ente/passkey.go b/server/ente/passkey.go
index edeb99fd54..7a4e69908a 100644
--- a/server/ente/passkey.go
+++ b/server/ente/passkey.go
@@ -2,7 +2,6 @@ package ente
import "github.com/google/uuid"
-// Passkey is our way of keeping track of user credentials and storing useful info for users.
type Passkey struct {
ID uuid.UUID `json:"id"`
UserID int64 `json:"userID"`
diff --git a/server/ente/passkeyCredential.go b/server/ente/passkeyCredential.go
index 67e5772ea6..1973a13556 100644
--- a/server/ente/passkeyCredential.go
+++ b/server/ente/passkeyCredential.go
@@ -28,7 +28,6 @@ type PasskeyCredential struct {
CreatedAt int64 `json:"createdAt"`
}
-// de-serialization function into a webauthn.Credential
func (c *PasskeyCredential) WebAuthnCredential() (cred *webauthn.Credential, err error) {
decodedID, err := base64.StdEncoding.DecodeString(c.CredentialID)
@@ -48,7 +47,6 @@ func (c *PasskeyCredential) WebAuthnCredential() (cred *webauthn.Credential, err
cred.Transport = transports
- // decode b64 back to []byte
publicKeyByte, err := base64.StdEncoding.DecodeString(c.PublicKey)
if err != nil {
return
@@ -74,7 +72,6 @@ func (c *PasskeyCredential) WebAuthnCredential() (cred *webauthn.Credential, err
return
}
- // decode the AAGUID base64 back to []byte
aaguidByte, err := base64.StdEncoding.DecodeString(
authenticatorMap["AAGUID"].(string),
)
diff --git a/server/ente/push.go b/server/ente/push.go
index 8949901bfc..31f77fd0f8 100644
--- a/server/ente/push.go
+++ b/server/ente/push.go
@@ -5,7 +5,6 @@ import (
"time"
)
-// PushTokenRequest represents a push token
type PushTokenRequest struct {
FCMToken string `json:"fcmToken" binding:"required"`
APNSToken string `json:"apnsToken"`
diff --git a/server/ente/remotestore_test.go b/server/ente/remotestore_test.go
index f73da846a5..5adafe787b 100644
--- a/server/ente/remotestore_test.go
+++ b/server/ente/remotestore_test.go
@@ -8,7 +8,6 @@ func TestIsValidDomainWithoutScheme(t *testing.T) {
input string
wantErr bool
}{
- // βœ… Valid cases
{"simple domain", "google.com", false},
{"multi-level domain", "sub.example.co.in", false},
{"multi-level domain", "photos.Γ€.com", false},
@@ -16,26 +15,21 @@ func TestIsValidDomainWithoutScheme(t *testing.T) {
{"idn", "γƒ†γ‚Ήγƒˆ.jp", false},
{"long but valid label", "my-very-long-subdomain-name.example.com", false},
- // ❌ Leading/trailing spaces
{"leading space", " google.com", true},
{"trailing space", "google.com ", true},
{"both spaces", " google.com ", true},
- // ❌ Empty or whitespace
{"empty string", "", true},
{"only spaces", " ", true},
- // ❌ Scheme included
{"http scheme", "http://google.com", true},
{"https scheme", "https://example.com", true},
{"ftp scheme", "ftp://example.com", true},
- // ❌ Invalid characters
{"underscore in label", "my_domain.com", true},
{"invalid symbol", "exa$mple.com", true},
{"space inside", "exa mple.com", true},
- // ❌ Wrong format
{"missing dot", "localhost", true},
{"ipv4 address", "172.17.0.2", true},
{"ipv6 address", "2001:db8::1", true},
@@ -44,7 +38,6 @@ func TestIsValidDomainWithoutScheme(t *testing.T) {
{"ends with dash", "example-.com", true},
{"starts with dash", "-example.com", true},
- // ❌ Consecutive dots
{"double dots", "example..com", true},
}
@@ -86,21 +79,17 @@ func TestFlagKey_IsValidValue(t *testing.T) {
value string
wantErr bool
}{
- // βœ… Valid boolean flag values
{"valid true for bool key", MapEnabled, "true", false},
{"valid false for bool key", FaceSearchEnabled, "false", false},
- // ❌ Invalid boolean flag values
{"invalid value for bool key", PassKeyEnabled, "yes", true},
{"empty value for bool key", IsInternalUser, "", true},
- // βœ… Valid custom domain values
{"valid custom domain", CustomDomain, "example.com", false},
{"valid subdomain", CustomDomain, "sub.example.com", false},
{"valid family custom domain pointer", CustomDomain, "_123:example.com", false},
- // ❌ Invalid custom domain values
- {"empty custom domain", CustomDomain, "", false}, // Allowed as empty
+ {"empty custom domain", CustomDomain, "", false},
{"custom domain with scheme", CustomDomain, "http://example.com", true},
{"custom domain with invalid format", CustomDomain, "exa$mple.com", true},
{"custom domain with leading space", CustomDomain, " example.com", true},
diff --git a/server/ente/social/anon_user.go b/server/ente/social/anon_user.go
index f34892e4c8..3f1a842f12 100644
--- a/server/ente/social/anon_user.go
+++ b/server/ente/social/anon_user.go
@@ -1,6 +1,5 @@
package social
-// AnonUser captures encrypted profile metadata for anonymous public commenters.
type AnonUser struct {
ID string `json:"anonUserID"`
CollectionID int64 `json:"collectionID"`
diff --git a/server/ente/social/comment.go b/server/ente/social/comment.go
index 8f08fabab9..40c366fd0e 100644
--- a/server/ente/social/comment.go
+++ b/server/ente/social/comment.go
@@ -1,6 +1,5 @@
package social
-// Comment represents an encrypted comment or reply stored in the database.
type Comment struct {
ID string `json:"id"`
CollectionID int64 `json:"collectionID"`
diff --git a/server/ente/social/reaction.go b/server/ente/social/reaction.go
index cad8a74056..3b4c07d448 100644
--- a/server/ente/social/reaction.go
+++ b/server/ente/social/reaction.go
@@ -1,6 +1,5 @@
package social
-// Reaction represents an encrypted reaction scoped to a collection, file, or comment.
type Reaction struct {
ID string `json:"id"`
CollectionID int64 `json:"collectionID"`
diff --git a/server/ente/srp.go b/server/ente/srp.go
index e3d0153287..0be5a04e31 100644
--- a/server/ente/srp.go
+++ b/server/ente/srp.go
@@ -36,8 +36,6 @@ type RecoveryUpdateSRPAndKeysRequest struct {
UpdateSrp UpdateSRPAndKeysRequest `json:"updateSrpAndKeysRequest" binding:"required"`
}
-// UpdateSRPAndKeysRequest is used to update the SRP attributes (e.g. when user updates his password) and also
-// update the keys attributes
type UpdateSRPAndKeysRequest struct {
SetupID uuid.UUID `json:"setupID" binding:"required"`
SRPM1 string `json:"srpM1" binding:"required"`
@@ -82,7 +80,6 @@ type VerifySRPSessionRequest struct {
SRPM1 string `json:"srpM1"`
}
-// SRPSessionEntity represents a row in the srp_sessions table
type SRPSessionEntity struct {
ID uuid.UUID
SRPUserID uuid.UUID
diff --git a/server/ente/storagebonus/referral.go b/server/ente/storagebonus/referral.go
index 52a6e7a510..9743d73330 100644
--- a/server/ente/storagebonus/referral.go
+++ b/server/ente/storagebonus/referral.go
@@ -1,12 +1,8 @@
package storagebonus
-// Tracking represents entity used to track various referral history
type Tracking struct {
- // UserID of the user who invited the other person
- Invitor int64
- // UserID of the user who's invited by invitor
- Invitee int64
- // CreatedAt time when the user applied the code
+ Invitor int64
+ Invitee int64
CreatedAt int64
PlanType PlanType
@@ -22,16 +18,11 @@ type UpdateReferralCodeRequest struct {
Code string `json:"code" binding:"required"`
}
-// PlanInfo represents the referral plan metadata
type PlanInfo struct {
- // IsEnabled indicates if the referral plan is enabled for given user
- IsEnabled bool `json:"isEnabled"`
- // Referral plan type
- PlanType PlanType `json:"planType"`
- // Storage which can be gained on successfully referral
- StorageInGB int64 `json:"storageInGB"`
- // Max storage which can be claimed by the user
- MaxClaimableStorageInGB int64 `json:"maxClaimableStorageInGB"`
+ IsEnabled bool `json:"isEnabled"`
+ PlanType PlanType `json:"planType"`
+ StorageInGB int64 `json:"storageInGB"`
+ MaxClaimableStorageInGB int64 `json:"maxClaimableStorageInGB"`
}
type GetStorageBonusDetailResponse struct {
@@ -39,24 +30,16 @@ type GetStorageBonusDetailResponse struct {
Bonuses []StorageBonus `json:"bonuses"`
RefCount int `json:"refCount"`
RefUpgradeCount int `json:"refUpgradeCount"`
- // Indicates if the user applied code during signup
- HasAppliedCode bool `json:"hasAppliedCode"`
+ HasAppliedCode bool `json:"hasAppliedCode"`
}
-// GetUserReferralView represents the basic view of the user's referral plan
-// This is used to show the user's referral details in the UI
type GetUserReferralView struct {
- PlanInfo PlanInfo `json:"planInfo"`
- Code *string `json:"code"`
- // Indicates if the user can apply the referral code.
- EnableApplyCode bool `json:"enableApplyCode"`
- HasAppliedCode bool `json:"hasAppliedCode"`
- // Indicates claimed referral storage
- ClaimedStorage int64 `json:"claimedStorage"`
- // Indicates if the user is part of a family and is the admin
- IsFamilyMember bool `json:"isFamilyMember"`
- // Number of times the user has changed their referral code
- CodeChangeAttempts int `json:"codeChangeAttempts"`
- // Remaining number of times the user can change their referral code
- RemainingCodeChangeAttempts int `json:"remainingCodeChangeAttempts"`
+ PlanInfo PlanInfo `json:"planInfo"`
+ Code *string `json:"code"`
+ EnableApplyCode bool `json:"enableApplyCode"`
+ HasAppliedCode bool `json:"hasAppliedCode"`
+ ClaimedStorage int64 `json:"claimedStorage"`
+ IsFamilyMember bool `json:"isFamilyMember"`
+ CodeChangeAttempts int `json:"codeChangeAttempts"`
+ RemainingCodeChangeAttempts int `json:"remainingCodeChangeAttempts"`
}
diff --git a/server/ente/storagebonus/referral_type.go b/server/ente/storagebonus/referral_type.go
index 15afc3a9e1..beb0d216ce 100644
--- a/server/ente/storagebonus/referral_type.go
+++ b/server/ente/storagebonus/referral_type.go
@@ -7,13 +7,9 @@ import (
type PlanType string
const (
- // TenGbOnUpgrade plan when both the parties get 10 GB surplus storage.
- // The invitee gets 10 GB storage on successful signup
- // The invitor gets 10 GB storage only after the invitee upgrades to a paid plan
TenGbOnUpgrade PlanType = "10_GB_ON_UPGRADE"
)
-// SignUpInviteeBonus returns the storage which can be gained by the invitee on successful signup with a referral code
func (c PlanType) SignUpInviteeBonus() int64 {
switch c {
case TenGbOnUpgrade:
@@ -23,24 +19,20 @@ func (c PlanType) SignUpInviteeBonus() int64 {
}
}
-// SignUpInvitorBonus returns the storage which can be gained by the invitor when some sign ups using their code
func (c PlanType) SignUpInvitorBonus() int64 {
switch c {
case TenGbOnUpgrade:
return 0
default:
- // panic if the plan type is not supported
panic("unsupported plan type")
}
}
-// InvitorBonusOnInviteeUpgrade returns the storage which can be gained by the invitor when the invitee upgrades to a paid plan
func (c PlanType) InvitorBonusOnInviteeUpgrade() int64 {
switch c {
case TenGbOnUpgrade:
return 10 * 1024 * 1024 * 1024
default:
- // panic if the plan type is not supported
panic("unsupported plan type")
}
}
diff --git a/server/ente/storagebonus/storge_bonus.go b/server/ente/storagebonus/storge_bonus.go
index e129f2f523..8e866d9d5c 100644
--- a/server/ente/storagebonus/storge_bonus.go
+++ b/server/ente/storagebonus/storge_bonus.go
@@ -3,29 +3,17 @@ package storagebonus
type BonusType string
const (
- // Referral bonus is gained by inviting others
Referral BonusType = "REFERRAL"
- // SignUp for applying code shared by others during sign up
- // Note: In the future, for surplus types which should be only applied once, we can add unique constraints
- SignUp BonusType = "SIGN_UP"
+ SignUp BonusType = "SIGN_UP"
- // AddOnSupport is the bonus for users added by the support team
- AddOnSupport BonusType = "ADD_ON_SUPPORT"
- // AddOnNonProfit is the bonus for users on the non-profit program
+ AddOnSupport BonusType = "ADD_ON_SUPPORT"
AddOnNonProfit BonusType = "ADD_ON_NON_PROFIT"
- // AddOnBf is the bonus for users who have opted for the Black Friday offers
- AddOnBf2023 BonusType = "ADD_ON_BF_2023"
- AddOnBf2024 BonusType = "ADD_ON_BF_2024"
- // In the future, we can add various types of bonuses based on different events like Anniversary,
- // or finishing tasks like ML indexing, enabling sharing etc etc
+ AddOnBf2023 BonusType = "ADD_ON_BF_2023"
+ AddOnBf2024 BonusType = "ADD_ON_BF_2024"
)
-// PaidAddOnTypes : These add-ons can be purchased by the users and help in the expiry of an account
-// as long as the add-on is active.
var PaidAddOnTypes = []BonusType{AddOnSupport, AddOnNonProfit, AddOnBf2023, AddOnBf2024}
-// ExtendsExpiry returns true if the bonus type extends the expiry of the account.
-// By default, all bonuses don't extend expiry.
func (t BonusType) ExtendsExpiry() bool {
switch t {
case AddOnSupport, AddOnNonProfit, AddOnBf2023, AddOnBf2024:
@@ -73,17 +61,13 @@ func (t BonusType) RestrictToDoublingStorage() bool {
type RevokeReason string
const (
- Fraud RevokeReason = "FRAUD"
- // Expired is usually used to take away one time bonus.
- Expired RevokeReason = "EXPIRED"
- // Discontinued Used when storagebonus is taken away before other user deleted their account
- // or stopped subscription or user decides to pause subscription after anniversary gift
+ Fraud RevokeReason = "FRAUD"
+ Expired RevokeReason = "EXPIRED"
Discontinued RevokeReason = "DISCONTINUED"
)
type StorageBonus struct {
- UserID int64 `json:"-"`
- // Amount of storage bonus added to the account
+ UserID int64 `json:"-"`
Storage int64 `json:"storage"`
Type BonusType `json:"type"`
CreatedAt int64 `json:"createdAt"`
@@ -137,8 +121,6 @@ func (a *ActiveStorageBonus) GetAddonStorage() int64 {
return addonStorage
}
-// GetUsableBonus Returns the add_on_bonus + referral_bonus for a given user. The referral bonus is restricted
-// to max of addonStorage + subStorage
func (a *ActiveStorageBonus) GetUsableBonus(subStorage int64) int64 {
refBonus := a.GetReferralBonus()
totalSubAndAddOnStorage := a.GetAddonStorage() + subStorage
diff --git a/server/ente/webauthnSession.go b/server/ente/webauthnSession.go
index 62bf1dbcba..e2c5a72b12 100644
--- a/server/ente/webauthnSession.go
+++ b/server/ente/webauthnSession.go
@@ -12,7 +12,6 @@ import (
"github.com/google/uuid"
)
-// WebAuthnSession is a protocol level session that stores challenges and other metadata during registration and login ceremonies
type WebAuthnSession struct {
ID uuid.UUID