Restructure notification code for batching
1 open thread
1 open thread
Compare changes
+ 87
− 88
@@ -33,17 +33,12 @@ import (
@@ -33,17 +33,12 @@ import (
@@ -68,7 +63,6 @@ type Impl struct {
@@ -68,7 +63,6 @@ type Impl struct {
@@ -114,7 +108,6 @@ func StartNotifications(params Params, noTLS, noFirebase bool) (*Impl, error) {
@@ -114,7 +108,6 @@ func StartNotifications(params Params, noTLS, noFirebase bool) (*Impl, error) {
@@ -186,93 +179,92 @@ func NewImplementation(instance *Impl) *notificationBot.Implementation {
@@ -186,93 +179,92 @@ func NewImplementation(instance *Impl) *notificationBot.Implementation {
fc *firebase.FirebaseComm, db *storage.Storage, maxBatchSize, maxBytes int) ([]*notifications.Data, error) {
// This path is not an error. if no results are returned, the user hasn't registered for notifications
db.GetNotificationBuffer().Add(id.Round(nd.RoundID), []*notifications.Data{nd}) // TODO build lists by rid for more efficient re-insertion? Accumulator would let us do this with the other size check in swap
"Some notifications are not for you to ensure privacy; we hope to remove this notification soon").MutableContent().Custom(
// return errors.WithMessagef(err, "Failed to remove user registration tRSA hash: %+v", u.TransmissionRSAHash)
jww.ERROR.Printf("User with Transmission RSA hash %+v has invalid token, unregistering...", u.TransmissionRSAHash)
jww.ERROR.Printf("Failed to remove user registration tRSA hash %+v: %+v", u.TransmissionRSAHash, err)
jww.ERROR.Printf("Failed to send notification to user with tRSA hash %+v: %+v", u.TransmissionRSAHash, err)
@@ -425,20 +417,27 @@ func (nb *Impl) Sender(sendFreq int) {
@@ -425,20 +417,27 @@ func (nb *Impl) Sender(sendFreq int) {
rest, err := nb.notifyFunc(localEphID, notifList, nb.apnsClient, nb.fcm, nb.Storage, nb.maxNotifications, nb.maxPayloadBytes)