Skip to content

armgit / ente

Public Imported from GitHub
0

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

Reduce frequency of device limit warning alerts

Neeraj Gupta2a5110c9d182
diff --git a/server/pkg/middleware/collection_link.go b/server/pkg/middleware/collection_link.go
index 600a7cd7c6..1c8ed7e42c 100644
--- a/server/pkg/middleware/collection_link.go
+++ b/server/pkg/middleware/collection_link.go
@@ -162,10 +162,15 @@ func (m *CollectionLinkMiddleware) isDeviceLimitReached(ctx context.Context,
}
if count >= public2.DeviceLimitWarningThreshold {
- if !array.Int64InList(sharedID, whitelistedCollectionShareIDs) {
+ alertStepSize := int64(200)
+ shouldAlert := count == public2.DeviceLimitWarningThreshold ||
+ (count > public2.DeviceLimitWarningThreshold &&
+ (count-public2.DeviceLimitWarningThreshold)%alertStepSize == 0)
+
+ if shouldAlert && !array.Int64InList(sharedID, whitelistedCollectionShareIDs) {
m.DiscordController.NotifyPotentialAbuse(
- fmt.Sprintf("Album exceeds warning threshold: {CollectionID: %d, ShareID: %d}",
- collectionSummary.CollectionID, collectionSummary.ID))
+ fmt.Sprintf("Album exceeds warning threshold: {CollectionID: %d, ShareID: %d, DeviceCount: %d}",
+ collectionSummary.CollectionID, collectionSummary.ID, count))
}
}
diff --git a/server/pkg/middleware/file_link.go b/server/pkg/middleware/file_link.go
index b9c20e42aa..80f6d59fec 100644
--- a/server/pkg/middleware/file_link.go
+++ b/server/pkg/middleware/file_link.go
@@ -140,9 +140,16 @@ func (m *FileLinkMiddleware) isDeviceLimitReached(ctx context.Context,
}
if count >= publicCtrl.DeviceLimitWarningThreshold {
- m.DiscordController.NotifyPotentialAbuse(
- fmt.Sprintf("FileLink exceeds warning threshold: {FileID: %d, ShareID: %s}",
- collectionSummary.FileID, collectionSummary.LinkID))
+ alertStepSize := int64(200)
+ shouldAlert := count == publicCtrl.DeviceLimitWarningThreshold ||
+ (count > publicCtrl.DeviceLimitWarningThreshold &&
+ (count-publicCtrl.DeviceLimitWarningThreshold)%alertStepSize == 0)
+
+ if shouldAlert {
+ m.DiscordController.NotifyPotentialAbuse(
+ fmt.Sprintf("FileLink exceeds warning threshold: {FileID: %d, ShareID: %s, DeviceCount: %d}",
+ collectionSummary.FileID, collectionSummary.LinkID, count))
+ }
}
if deviceLimit > 0 && count >= deviceLimit {