sendNotificationData sends data about unread notifications to the Sync API server.
(userID string, data *eventutil.NotificationData)
| 79 | |
| 80 | // sendNotificationData sends data about unread notifications to the Sync API server. |
| 81 | func (p *SyncAPI) sendNotificationData(userID string, data *eventutil.NotificationData) error { |
| 82 | m := &nats.Msg{ |
| 83 | Subject: p.notificationDataTopic, |
| 84 | Header: nats.Header{}, |
| 85 | } |
| 86 | m.Header.Set(jetstream.UserID, userID) |
| 87 | |
| 88 | var err error |
| 89 | m.Data, err = json.Marshal(data) |
| 90 | if err != nil { |
| 91 | return err |
| 92 | } |
| 93 | |
| 94 | log.WithFields(log.Fields{ |
| 95 | "user_id": userID, |
| 96 | "room_id": data.RoomID, |
| 97 | }).Tracef("Producing to topic '%s'", p.clientDataTopic) |
| 98 | |
| 99 | _, err = p.producer.PublishMsg(m) |
| 100 | return err |
| 101 | } |
no test coverage detected