SendAccountData sends account data to the Sync API server.
(userID string, data eventutil.AccountData)
| 35 | |
| 36 | // SendAccountData sends account data to the Sync API server. |
| 37 | func (p *SyncAPI) SendAccountData(userID string, data eventutil.AccountData) error { |
| 38 | m := &nats.Msg{ |
| 39 | Subject: p.clientDataTopic, |
| 40 | Header: nats.Header{}, |
| 41 | } |
| 42 | m.Header.Set(jetstream.UserID, userID) |
| 43 | |
| 44 | var err error |
| 45 | m.Data, err = json.Marshal(data) |
| 46 | if err != nil { |
| 47 | return err |
| 48 | } |
| 49 | |
| 50 | log.WithFields(log.Fields{ |
| 51 | "user_id": userID, |
| 52 | "room_id": data.RoomID, |
| 53 | "data_type": data.Type, |
| 54 | }).Tracef("Producing to topic '%s'", p.clientDataTopic) |
| 55 | |
| 56 | _, err = p.producer.PublishMsg(m) |
| 57 | return err |
| 58 | } |
| 59 | |
| 60 | // GetAndSendNotificationData reads the database and sends data about unread |
| 61 | // notifications to the Sync API server. |
no test coverage detected