Downgrade Web Push urgency for unimportant messages

For instance TAGMSG and MARKREAD aren't really high urgency.
This commit is contained in:
Simon Ser 2022-08-17 16:04:11 +02:00
parent 1ee5dc062d
commit 05a382ef16
1 changed files with 9 additions and 1 deletions

View File

@ -303,12 +303,20 @@ func (s *Server) sendWebPush(ctx context.Context, sub *webpush.Subscription, vap
ctx, cancel := context.WithTimeout(ctx, 15*time.Second)
defer cancel()
var urgency webpush.Urgency
switch msg.Command {
case "PRIVMSG", "NOTICE", "INVITE":
urgency = webpush.UrgencyHigh
default:
urgency = webpush.UrgencyNormal
}
options := webpush.Options{
VAPIDPublicKey: s.webPush.VAPIDKeys.Public,
VAPIDPrivateKey: s.webPush.VAPIDKeys.Private,
Subscriber: "https://soju.im",
TTL: 7 * 24 * 60 * 60, // seconds
Urgency: webpush.UrgencyHigh,
Urgency: urgency,
RecordSize: 2048,
}