Skip to content

armgit / ente

Public Imported from GitHub
0

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

Raise free public-link device limit to 10

Neeraj Gupta2cd7ddd7eaa6
diff --git a/docs/docs/photos/faq/sharing-and-collaboration.md b/docs/docs/photos/faq/sharing-and-collaboration.md
index 3dcb9998f2..f8f38e2a48 100644
--- a/docs/docs/photos/faq/sharing-and-collaboration.md
+++ b/docs/docs/photos/faq/sharing-and-collaboration.md
@@ -571,13 +571,13 @@ Deduplication and the similar-images tool only work within albums you own, not a
### Who can create collaborative albums or public links? {#who-can-share}
-Album sharing and public links are now available on every plan, including the free tier. Free plan users can create public links with a [device limit](https://ente.com/help/photos/features/sharing-and-collaboration/public-links#device-limits) of 5. This limitation helps safeguard against potential platform abuse.
+Album sharing and public links are now available on every plan, including the free tier. Free plan users can create public links with a [device limit](https://ente.com/help/photos/features/sharing-and-collaboration/public-links#device-limits) of 10. This limitation helps safeguard against potential platform abuse.
Free users can:
- Create and receive shared albums
- Share albums directly with other Ente users
-- Create public links ([device limit](https://ente.com/help/photos/features/sharing-and-collaboration/public-links#device-limits) of 5)
+- Create public links ([device limit](https://ente.com/help/photos/features/sharing-and-collaboration/public-links#device-limits) of 10)
- View public links shared with them
- Add photos to collect links that allow uploads
diff --git a/docs/docs/photos/faq/storage-and-plans.md b/docs/docs/photos/faq/storage-and-plans.md
index 803f10fcf5..21b3075a5a 100644
--- a/docs/docs/photos/faq/storage-and-plans.md
+++ b/docs/docs/photos/faq/storage-and-plans.md
@@ -141,7 +141,7 @@ All other features work on the free plan, including:
- Map view
- Machine learning (face recognition, magic search)
- Creating /receiving shared albums
-- Public links (device limit of 5)
+- Public links (device limit of 10)
- Background sync
### Is there an x GB plan? {#specific-plan-size}
diff --git a/docs/docs/photos/features/account/index.md b/docs/docs/photos/features/account/index.md
index a19670d1fa..60104645b2 100644
--- a/docs/docs/photos/features/account/index.md
+++ b/docs/docs/photos/features/account/index.md
@@ -106,7 +106,7 @@ Ente offers **10 GB of storage for free, forever**. The free plan includes:
- βœ… Map view and location tags
- βœ… Background sync
- βœ… Creating /receiving shared albums
-- βœ… Public links ([device limit](https://ente.com/help/photos/features/sharing-and-collaboration/public-links#device-limits) of 5)
+- βœ… Public links ([device limit](https://ente.com/help/photos/features/sharing-and-collaboration/public-links#device-limits) of 10)
**Free plan limitations:**
diff --git a/docs/docs/photos/features/sharing-and-collaboration/public-links.md b/docs/docs/photos/features/sharing-and-collaboration/public-links.md
index 5cb78f7b6d..1fa9d917c5 100644
--- a/docs/docs/photos/features/sharing-and-collaboration/public-links.md
+++ b/docs/docs/photos/features/sharing-and-collaboration/public-links.md
@@ -270,11 +270,11 @@ Public links are end-to-end encrypted, but with an important caveat:
## Availability
-Public links (including collect links and quick links) are available on all plans, including the free tier. Free plan users can create public links with a [device limit](https://ente.com/help/photos/features/sharing-and-collaboration/public-links#device-limits) of 5.
+Public links (including collect links and quick links) are available on all plans, including the free tier. Free plan users can create public links with a [device limit](https://ente.com/help/photos/features/sharing-and-collaboration/public-links#device-limits) of 10.
**Free users can:**
-- Create public links ([device limit](https://ente.com/help/photos/features/sharing-and-collaboration/public-links#device-limits) of 5)
+- Create public links ([device limit](https://ente.com/help/photos/features/sharing-and-collaboration/public-links#device-limits) of 10)
- View public links shared with them
- Add photos to collect links shared with them
- Create and receive shared albums
diff --git a/docs/docs/photos/features/sharing-and-collaboration/share.md b/docs/docs/photos/features/sharing-and-collaboration/share.md
index b825c42bce..4fc66e1c95 100644
--- a/docs/docs/photos/features/sharing-and-collaboration/share.md
+++ b/docs/docs/photos/features/sharing-and-collaboration/share.md
@@ -69,7 +69,7 @@ More details, including technical aspect about how the sharing features were imp
## Limitations
-Peer-to-peer sharing between Ente users and creating public links are available on every plan, including the free tier. Free plan users can create public links with a device limit of 5, while paid users can create public links with no device limit.
+Peer-to-peer sharing between Ente users and creating public links are available on every plan, including the free tier. Free plan users can create public links with a device limit of 10, while paid users can create public links with no device limit.
## Related topics
diff --git a/server/pkg/controller/collections/share.go b/server/pkg/controller/collections/share.go
index 1ce571cd83..d230fe5d6f 100644
--- a/server/pkg/controller/collections/share.go
+++ b/server/pkg/controller/collections/share.go
@@ -517,7 +517,7 @@ func (c *CollectionController) UpdateShareURL(
err := c.BillingCtrl.HasActiveSelfOrFamilySubscription(userID, true)
if err != nil {
if errors.Is(err, ente.ErrSharingDisabledForFreeAccounts) {
- if req.DeviceLimit != nil && *req.DeviceLimit != public.FreeUserDeviceLimit {
+ if req.DeviceLimit != nil && !public.IsAllowedFreeUserDeviceLimit(*req.DeviceLimit) {
return nil, stacktrace.Propagate(&ente.ErrLinkEditNotAllowed, "")
}
} else {
diff --git a/server/pkg/controller/public/collection_link.go b/server/pkg/controller/public/collection_link.go
index 528de1ba01..9c030e5591 100644
--- a/server/pkg/controller/public/collection_link.go
+++ b/server/pkg/controller/public/collection_link.go
@@ -29,9 +29,15 @@ const (
DeviceLimitWarningThreshold = 2000
- FreeUserDeviceLimit = 5
+ FreeUserDeviceLimit = 10
+
+ legacyFreeUserDeviceLimit = 5
)
+func IsAllowedFreeUserDeviceLimit(deviceLimit int) bool {
+ return deviceLimit == FreeUserDeviceLimit || deviceLimit == legacyFreeUserDeviceLimit
+}
+
type CollectionLinkController struct {
FileController *controller.FileController
EmailNotificationCtrl *emailCtrl.EmailNotificationController
diff --git a/server/pkg/controller/public/free_user_device_limit_test.go b/server/pkg/controller/public/free_user_device_limit_test.go
new file mode 100644
index 0000000000..7e88ee339c
--- /dev/null
+++ b/server/pkg/controller/public/free_user_device_limit_test.go
@@ -0,0 +1,21 @@
+package public
+
+import "testing"
+
+func TestIsAllowedFreeUserDeviceLimit(t *testing.T) {
+ if FreeUserDeviceLimit != 10 {
+ t.Fatalf("free user device limit = %d, want 10", FreeUserDeviceLimit)
+ }
+
+ for _, deviceLimit := range []int{FreeUserDeviceLimit, 5} {
+ if !IsAllowedFreeUserDeviceLimit(deviceLimit) {
+ t.Fatalf("device limit %d should be allowed for free users", deviceLimit)
+ }
+ }
+
+ for _, deviceLimit := range []int{0, 1, 2, 25, 50} {
+ if IsAllowedFreeUserDeviceLimit(deviceLimit) {
+ t.Fatalf("device limit %d should not be allowed for free users", deviceLimit)
+ }
+ }
+}
diff --git a/server/pkg/middleware/collection_link.go b/server/pkg/middleware/collection_link.go
index fbaf7804f1..5edea3995b 100644
--- a/server/pkg/middleware/collection_link.go
+++ b/server/pkg/middleware/collection_link.go
@@ -88,7 +88,7 @@ func (m *CollectionLinkMiddleware) Authenticate(urlSanitizer func(_ *gin.Context
return
}
if isFreeUser {
- publicCollectionSummary.DeviceLimit = public2.FreeUserDeviceLimit
+ publicCollectionSummary.DeviceLimit = capFreeUserDeviceLimit(publicCollectionSummary.DeviceLimit)
}
if publicCollectionSummary.ValidTill > 0 && // expiry time is defined, 0 indicates no expiry
@@ -172,6 +172,13 @@ func (m *CollectionLinkMiddleware) Authenticate(urlSanitizer func(_ *gin.Context
}
}
+func capFreeUserDeviceLimit(deviceLimit int) int {
+ if deviceLimit == 0 || deviceLimit > public2.FreeUserDeviceLimit {
+ return public2.FreeUserDeviceLimit
+ }
+ return deviceLimit
+}
+
func (m *CollectionLinkMiddleware) checkDeviceLimit(c *gin.Context, accessToken string,
collectionSummary ente.PublicCollectionSummary, ip string, ua string) (string, bool, error) {
linkID := strconv.FormatInt(collectionSummary.ID, 10)
diff --git a/server/pkg/middleware/collection_link_test.go b/server/pkg/middleware/collection_link_test.go
index 62b7aa56e5..4980e61967 100644
--- a/server/pkg/middleware/collection_link_test.go
+++ b/server/pkg/middleware/collection_link_test.go
@@ -22,6 +22,23 @@ func TestShouldCheckCollectionLinkDeviceLimit(t *testing.T) {
require.False(t, shouldCheckCollectionLinkDeviceLimit("/public-collection/verify-password"))
}
+func TestCapFreeUserDeviceLimit(t *testing.T) {
+ for _, test := range []struct {
+ name string
+ deviceLimit int
+ want int
+ }{
+ {name: "unlimited", deviceLimit: 0, want: 10},
+ {name: "legacy free limit", deviceLimit: 5, want: 5},
+ {name: "current free limit", deviceLimit: 10, want: 10},
+ {name: "paid limit", deviceLimit: 25, want: 10},
+ } {
+ t.Run(test.name, func(t *testing.T) {
+ require.Equal(t, test.want, capFreeUserDeviceLimit(test.deviceLimit))
+ })
+ }
+}
+
func TestCollectionLinkCacheIsScopedToOrigin(t *testing.T) {
const (
accessToken = "access-token"