|
|
@@ -602,7 +602,7 @@ func (s *Server) handlePublishWithoutResponse(r *http.Request, v *visitor) (*mes
|
|
|
// Rate-Topics header). The 5xx response is because some app servers (in particular Mastodon) will remove
|
|
|
// the subscription as invalid if any 400-499 code (except 429/408) is returned.
|
|
|
// See https://github.com/mastodon/mastodon/blob/730bb3e211a84a2f30e3e2bbeae3f77149824a68/app/workers/web/push_notification_worker.rb#L35-L46
|
|
|
- return nil, errHTTPInsufficientStorage.With(t)
|
|
|
+ return nil, errHTTPInsufficientStorageUnifiedPush.With(t)
|
|
|
} else if !util.ContainsIP(s.config.VisitorRequestExemptIPAddrs, v.ip) && !vrate.MessageAllowed() {
|
|
|
return nil, errHTTPTooManyRequestsLimitMessages.With(t)
|
|
|
} else if email != "" && !vrate.EmailAllowed() {
|
|
|
@@ -680,6 +680,9 @@ func (s *Server) handlePublish(w http.ResponseWriter, r *http.Request, v *visito
|
|
|
func (s *Server) handlePublishMatrix(w http.ResponseWriter, r *http.Request, v *visitor) error {
|
|
|
_, err := s.handlePublishWithoutResponse(r, v)
|
|
|
if err != nil {
|
|
|
+ if e, ok := err.(*errHTTP); ok && e.HTTPCode == errHTTPInsufficientStorageUnifiedPush.HTTPCode {
|
|
|
+ return writeMatrixResponse(w, e.rejectedPushKey)
|
|
|
+ }
|
|
|
return err
|
|
|
}
|
|
|
return writeMatrixSuccess(w)
|
|
|
@@ -1036,6 +1039,9 @@ func (s *Server) handleSubscribeHTTP(w http.ResponseWriter, r *http.Request, v *
|
|
|
case <-time.After(s.config.KeepaliveInterval):
|
|
|
logvr(v, r).Tag(tagSubscribe).Trace("Sending keepalive message")
|
|
|
v.Keepalive()
|
|
|
+ for _, t := range topics {
|
|
|
+ t.Keepalive()
|
|
|
+ }
|
|
|
if err := sub(v, newKeepaliveMessage(topicsStr)); err != nil { // Send keepalive message
|
|
|
return err
|
|
|
}
|
|
|
@@ -1123,6 +1129,9 @@ func (s *Server) handleSubscribeWS(w http.ResponseWriter, r *http.Request, v *vi
|
|
|
return &websocket.CloseError{Code: websocket.CloseNormalClosure, Text: "subscription was canceled"}
|
|
|
case <-time.After(s.config.KeepaliveInterval):
|
|
|
v.Keepalive()
|
|
|
+ for _, t := range topics {
|
|
|
+ t.Keepalive()
|
|
|
+ }
|
|
|
if err := ping(); err != nil {
|
|
|
return err
|
|
|
}
|