GetAndSendNotificationData reads the database and sends data about unread notifications to the Sync API server.
(ctx context.Context, userID, roomID string)
| 60 | // GetAndSendNotificationData reads the database and sends data about unread |
| 61 | // notifications to the Sync API server. |
| 62 | func (p *SyncAPI) GetAndSendNotificationData(ctx context.Context, userID, roomID string) error { |
| 63 | localpart, _, err := gomatrixserverlib.SplitID('@', userID) |
| 64 | if err != nil { |
| 65 | return err |
| 66 | } |
| 67 | |
| 68 | ntotal, nhighlight, err := p.db.GetRoomNotificationCounts(ctx, localpart, roomID) |
| 69 | if err != nil { |
| 70 | return err |
| 71 | } |
| 72 | |
| 73 | return p.sendNotificationData(userID, &eventutil.NotificationData{ |
| 74 | RoomID: roomID, |
| 75 | UnreadHighlightCount: int(nhighlight), |
| 76 | UnreadNotificationCount: int(ntotal), |
| 77 | }) |
| 78 | } |
| 79 | |
| 80 | // sendNotificationData sends data about unread notifications to the Sync API server. |
| 81 | func (p *SyncAPI) sendNotificationData(userID string, data *eventutil.NotificationData) error { |
no test coverage detected