π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Revert "Require legacy app URL configuration"
Neeraj Gupta9276d5c7c56a
diff --git a/server/configurations/local.yaml b/server/configurations/local.yamlindex 86cffcffb4..e741e5b934 100644--- a/server/configurations/local.yaml+++ b/server/configurations/local.yaml@@ -113,9 +113,10 @@ apps:# If you're running a self-hosted instance and wish to serve public memory shares,# set this to the URL where your memories web app is running.public-memories:+ # Default is https://legacy.ente.com+ ## If you're running a self-hosted instance and wish to serve legacy kit recovery,- # set this to the URL where your legacy recovery web app is running. This must- # be set before legacy kit records can be returned to clients.+ # set this to the URL where your legacy recovery web app is running.legacy:custom-domain:# Default is my.ente.iodiff --git a/server/pkg/controller/legacy_kit/controller.go b/server/pkg/controller/legacy_kit/controller.goindex 58c6354dff..12fe90e664 100644--- a/server/pkg/controller/legacy_kit/controller.go+++ b/server/pkg/controller/legacy_kit/controller.go@@ -30,7 +30,10 @@ var validNoticePeriods = map[int]struct{}{720: {},}-const maxActiveLegacyKits = 5+const (+ maxActiveLegacyKits = 5+ defaultLegacyURL = "https://legacy.ente.com"+)type Controller struct {Repo *legacykitrepo.Repository@@ -59,7 +62,7 @@ func (c *Controller) CreateKit(ctx *gin.Context, userID int64, req ente.CreateLeif err != nil {return nil, err}- return toLegacyKit(row, nil)+ return toLegacyKit(row, nil), nil}func (c *Controller) ListKits(ctx *gin.Context, userID int64) (*ente.ListLegacyKitsResponse, error) {@@ -80,11 +83,7 @@ func (c *Controller) ListKits(ctx *gin.Context, userID int64) (*ente.ListLegacyKresp := &ente.ListLegacyKitsResponse{Kits: make([]*ente.LegacyKit, 0, len(kits))}for i := range kits {row := kits[i]- kit, err := toLegacyKit(&row, sessionByKit[row.ID])- if err != nil {- return nil, err- }- resp.Kits = append(resp.Kits, kit)+ resp.Kits = append(resp.Kits, toLegacyKit(&row, sessionByKit[row.ID]))}return resp, nil}@@ -312,16 +311,12 @@ func (c *Controller) ChangePassword(ctx *gin.Context, req ente.LegacyKitRecoveryreturn resp, nil}-func toLegacyKit(row *legacykitrepo.KitRow, session *legacykitrepo.RecoverySessionRow) (*ente.LegacyKit, error) {- legacyURL, err := legacyURL()- if err != nil {- return nil, err- }+func toLegacyKit(row *legacykitrepo.KitRow, session *legacykitrepo.RecoverySessionRow) *ente.LegacyKit {kit := &ente.LegacyKit{ID: row.ID,Variant: row.Variant,NoticePeriodInHours: row.NoticePeriodInHrs,- LegacyURL: legacyURL,+ LegacyURL: legacyURL(),EncryptedOwnerBlob: row.EncryptedOwnerBlob,CreatedAt: row.CreatedAt,UpdatedAt: row.UpdatedAt,@@ -330,15 +325,15 @@ func toLegacyKit(row *legacykitrepo.KitRow, session *legacykitrepo.RecoverySessirecoverySession := toRecoverySession(session)kit.ActiveRecoverySession = &recoverySession}- return kit, nil+ return kit}-func legacyURL() (string, error) {+func legacyURL() string {url := strings.TrimRight(strings.TrimSpace(viper.GetString("apps.legacy")), "/")if url == "" {- return "", stacktrace.Propagate(ente.NewInternalError("legacy recovery app URL is not configured"), "")+ return defaultLegacyURL}- return url, nil+ return url}func toRecoverySession(row *legacykitrepo.RecoverySessionRow) ente.LegacyKitRecoverySession {diff --git a/server/pkg/controller/legacy_kit/controller_test.go b/server/pkg/controller/legacy_kit/controller_test.goindex f12dedd688..193d2f5e3f 100644--- a/server/pkg/controller/legacy_kit/controller_test.go+++ b/server/pkg/controller/legacy_kit/controller_test.go@@ -12,16 +12,14 @@ import ("github.com/stretchr/testify/require")-func TestLegacyURLRequiresConfiguration(t *testing.T) {+func TestLegacyURLUsesDefaultWhenUnset(t *testing.T) {previousURL := viper.GetString("apps.legacy")viper.Set("apps.legacy", "")t.Cleanup(func() {viper.Set("apps.legacy", previousURL)})- url, err := legacyURL()- require.Error(t, err)- require.Empty(t, url)+ require.Equal(t, defaultLegacyURL, legacyURL())}func TestLegacyURLUsesConfiguredURLWithoutTrailingSlash(t *testing.T) {@@ -31,9 +29,7 @@ func TestLegacyURLUsesConfiguredURLWithoutTrailingSlash(t *testing.T) {viper.Set("apps.legacy", previousURL)})- url, err := legacyURL()- require.NoError(t, err)- require.Equal(t, "http://localhost:3013", url)+ require.Equal(t, "http://localhost:3013", legacyURL())}func TestToRecoverySessionReturnsRemainingWaitTime(t *testing.T) {