downstream: add hard limit on Web Push subscriptions

Each subscription comes with the cost of a HTTP request when
broadcasting a message.
This commit is contained in:
Simon Ser 2022-08-17 17:08:23 +02:00
parent cffdbc16b4
commit 6fa8a1f30a

View File

@ -3336,6 +3336,13 @@ func (dc *downstreamConn) handleMessageRegistered(ctx context.Context, msg *irc.
}}
}
if len(subs) > 25 {
return ircError{&irc.Message{
Command: "FAIL",
Params: []string{"WEBPUSH", "INTERNAL_ERROR", subcommand, "Too many subscriptions"},
}}
}
oldSub := findWebPushSubscription(subs, endpoint)
if oldSub != nil {
// Update the old subscription instead of creating a new one