Loading CHANGELOG.md +1 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ The format is based on [keep a changelog](http://keepachangelog.com) and this pr - Improve JS runtime authoritative match filtered broadcasts to large sets of users. - Correctly align optional parameters in JS runtime bindings. - Fix JS registered match handlers not being available within the InitModule function. - Correct notification identifier handling for persistent notifications sent to all users. ## [3.11.0] - 2022-03-21 ### Added Loading server/core_notification.go +26 −10 Original line number Diff line number Diff line Loading @@ -85,6 +85,8 @@ func NotificationSend(ctx context.Context, logger *zap.Logger, db *sql.DB, messa } func NotificationSendAll(ctx context.Context, logger *zap.Logger, db *sql.DB, tracker Tracker, messageRouter MessageRouter, notification *api.Notification) error { // Non-persistent notifications don't need to work through all database users, just use currently connected notification streams. if !notification.Persistent { env := &rtapi.Envelope{ Message: &rtapi.Envelope_Notifications{ Notifications: &rtapi.Notifications{ Loading @@ -93,8 +95,6 @@ func NotificationSendAll(ctx context.Context, logger *zap.Logger, db *sql.DB, tr }, } // Non-persistent notifications don't need to work through all database users, just use currently connected notification streams. if !notification.Persistent { notificationStreamMode := StreamModeNotifications streams := tracker.CountByStreamModeFilter(map[uint8]*uint8{StreamModeNotifications: ¬ificationStreamMode}) for streamPtr, count := range streams { Loading Loading @@ -144,7 +144,15 @@ func NotificationSendAll(ctx context.Context, logger *zap.Logger, db *sql.DB, tr notificationLogger.Error("Failed to parse scanned user id data to send notification", zap.String("id", userIDStr), zap.Error(err)) return } sends[userID] = []*api.Notification{notification} sends[userID] = []*api.Notification{{ Id: uuid.Must(uuid.NewV4()).String(), Subject: notification.Subject, Content: notification.Content, Code: notification.Code, SenderId: notification.SenderId, CreateTime: notification.CreateTime, Persistent: notification.Persistent, }} } _ = rows.Close() Loading @@ -159,7 +167,15 @@ func NotificationSendAll(ctx context.Context, logger *zap.Logger, db *sql.DB, tr } // Deliver live notifications to connected users. for userID, _ := range sends { for userID, notifications := range sends { env := &rtapi.Envelope{ Message: &rtapi.Envelope_Notifications{ Notifications: &rtapi.Notifications{ Notifications: []*api.Notification{notifications[0]}, }, }, } messageRouter.SendToStream(logger, PresenceStream{Mode: StreamModeNotifications, Subject: userID}, env, true) } Loading Loading
CHANGELOG.md +1 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ The format is based on [keep a changelog](http://keepachangelog.com) and this pr - Improve JS runtime authoritative match filtered broadcasts to large sets of users. - Correctly align optional parameters in JS runtime bindings. - Fix JS registered match handlers not being available within the InitModule function. - Correct notification identifier handling for persistent notifications sent to all users. ## [3.11.0] - 2022-03-21 ### Added Loading
server/core_notification.go +26 −10 Original line number Diff line number Diff line Loading @@ -85,6 +85,8 @@ func NotificationSend(ctx context.Context, logger *zap.Logger, db *sql.DB, messa } func NotificationSendAll(ctx context.Context, logger *zap.Logger, db *sql.DB, tracker Tracker, messageRouter MessageRouter, notification *api.Notification) error { // Non-persistent notifications don't need to work through all database users, just use currently connected notification streams. if !notification.Persistent { env := &rtapi.Envelope{ Message: &rtapi.Envelope_Notifications{ Notifications: &rtapi.Notifications{ Loading @@ -93,8 +95,6 @@ func NotificationSendAll(ctx context.Context, logger *zap.Logger, db *sql.DB, tr }, } // Non-persistent notifications don't need to work through all database users, just use currently connected notification streams. if !notification.Persistent { notificationStreamMode := StreamModeNotifications streams := tracker.CountByStreamModeFilter(map[uint8]*uint8{StreamModeNotifications: ¬ificationStreamMode}) for streamPtr, count := range streams { Loading Loading @@ -144,7 +144,15 @@ func NotificationSendAll(ctx context.Context, logger *zap.Logger, db *sql.DB, tr notificationLogger.Error("Failed to parse scanned user id data to send notification", zap.String("id", userIDStr), zap.Error(err)) return } sends[userID] = []*api.Notification{notification} sends[userID] = []*api.Notification{{ Id: uuid.Must(uuid.NewV4()).String(), Subject: notification.Subject, Content: notification.Content, Code: notification.Code, SenderId: notification.SenderId, CreateTime: notification.CreateTime, Persistent: notification.Persistent, }} } _ = rows.Close() Loading @@ -159,7 +167,15 @@ func NotificationSendAll(ctx context.Context, logger *zap.Logger, db *sql.DB, tr } // Deliver live notifications to connected users. for userID, _ := range sends { for userID, notifications := range sends { env := &rtapi.Envelope{ Message: &rtapi.Envelope_Notifications{ Notifications: &rtapi.Notifications{ Notifications: []*api.Notification{notifications[0]}, }, }, } messageRouter.SendToStream(logger, PresenceStream{Mode: StreamModeNotifications, Subject: userID}, env, true) } Loading