Set User-Agent when sending Web Push notifications
This allows push servers to figure out where the notifications are coming from.
This commit is contained in:
parent
2ce370d627
commit
02ed7aa308
10
server.go
10
server.go
@ -326,6 +326,9 @@ func (s *Server) sendWebPush(ctx context.Context, sub *webpush.Subscription, vap
|
|||||||
}
|
}
|
||||||
|
|
||||||
options := webpush.Options{
|
options := webpush.Options{
|
||||||
|
HTTPClient: &http.Client{
|
||||||
|
Transport: userAgentHTTPTransport("soju"),
|
||||||
|
},
|
||||||
VAPIDPublicKey: s.webPush.VAPIDKeys.Public,
|
VAPIDPublicKey: s.webPush.VAPIDKeys.Public,
|
||||||
VAPIDPrivateKey: s.webPush.VAPIDKeys.Private,
|
VAPIDPrivateKey: s.webPush.VAPIDKeys.Private,
|
||||||
Subscriber: "https://soju.im",
|
Subscriber: "https://soju.im",
|
||||||
@ -733,3 +736,10 @@ func (s *Server) disableInactiveUsers(ctx context.Context) error {
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type userAgentHTTPTransport string
|
||||||
|
|
||||||
|
func (ua userAgentHTTPTransport) RoundTrip(req *http.Request) (*http.Response, error) {
|
||||||
|
req.Header.Set("User-Agent", string(ua))
|
||||||
|
return http.DefaultTransport.RoundTrip(req)
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user