π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Throttle discord alerts
Neeraj Guptacf4084380cc6
diff --git a/server/pkg/controller/discord/discord.go b/server/pkg/controller/discord/discord.goindex 94876c8149..91a9b7ce7e 100644--- a/server/pkg/controller/discord/discord.go+++ b/server/pkg/controller/discord/discord.go@@ -2,6 +2,7 @@ package discordimport ("fmt"+ "sync""time""github.com/bwmarrin/discordgo"@@ -19,6 +20,8 @@ type DiscordController struct {HostName stringEnvironment stringUserRepo *repo.UserRepository+ lastSent map[string]time.Time+ mu sync.Mutex}func NewDiscordController(userRepo *repo.UserRepository, hostName string, environment string) *DiscordController {@@ -28,6 +31,7 @@ func NewDiscordController(userRepo *repo.UserRepository, hostName string, enviroHostName: hostName,Environment: environment,UserRepo: userRepo,+ lastSent: make(map[string]time.Time),}}@@ -106,6 +110,14 @@ func (c *DiscordController) NotifyAccountDelete(userID int64, paymentProvider st}func (c *DiscordController) NotifyPotentialAbuse(message string) {+ c.mu.Lock()+ defer c.mu.Unlock()+ now := time.Now()+ if lastTime, exists := c.lastSent[message]; exists && now.Sub(lastTime) < time.Minute {+ log.Infof("Skipping duplicate abuse notification: %s", message)+ return+ }+ c.lastSent[message] = nowc.Notify(fmt.Sprintf("%s: %s", c.HostName, message))}diff --git a/server/pkg/middleware/rate_limit.go b/server/pkg/middleware/rate_limit.goindex 747cb9a867..48a94bd847 100644--- a/server/pkg/middleware/rate_limit.go+++ b/server/pkg/middleware/rate_limit.go@@ -147,6 +147,8 @@ func (r *RateLimitMiddleware) APIRateLimitForUserMiddleware(urlSanitizer func(_func (r *RateLimitMiddleware) getLimiter(reqPath string, reqMethod string) *limiter.Limiter {if reqPath == "/users/ott" ||reqPath == "/users/verify-email" ||+ reqPath == "/user/change-email" ||+ reqPath == "/users/public-key" ||reqPath == "/public-collection/verify-password" ||reqPath == "/family/accept-invite" ||reqPath == "/users/srp/attributes" ||