diff --git a/go.mod b/go.mod index 6e253ae6..2e0d2922 100644 --- a/go.mod +++ b/go.mod @@ -51,5 +51,5 @@ require ( gopkg.in/alecthomas/kingpin.v2 v2.2.6 // indirect gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect gopkg.in/yaml.v2 v2.3.0 - maunium.net/go/mautrix v0.7.0 + maunium.net/go/mautrix v0.9.2 ) diff --git a/services/rssbot/rssbot.go b/services/rssbot/rssbot.go index c339975d..1e46cce2 100644 --- a/services/rssbot/rssbot.go +++ b/services/rssbot/rssbot.go @@ -215,7 +215,10 @@ func (s *Service) OnPoll(cli types.MatrixClient) time.Time { "feed_url": u, log.ErrorKey: err, "item": item, - }).Error("Failed to send item to room") + }).Error("Failed to send item to room due to 429; aborting further sends") + // no point continuing if we errored due to a 429 - we'll just hit the rate limit + // again and again + break } } } @@ -415,7 +418,11 @@ func (s *Service) sendToRooms(cli types.MatrixClient, feedURL string, feed *gofe logger.Info("Sending new feed item") for _, roomID := range s.Feeds[feedURL].Rooms { if _, err := cli.SendMessageEvent(roomID, mevt.EventMessage, itemToHTML(feed, item)); err != nil { - logger.WithError(err).WithField("room_id", roomID).Error("Failed to send to room") + if httpErr, ok := err.(mautrix.HTTPError); ok && httpErr.IsStatus(429) { + return err + } else { + logger.WithError(err).WithField("room_id", roomID).Error("Failed to send to room") + } } } return nil