MCPcopy Create free account
hub / github.com/daodst/chat / GetAndSendNotificationData

Method GetAndSendNotificationData

userapi/producers/syncapi.go:62–78  ·  view source on GitHub ↗

GetAndSendNotificationData reads the database and sends data about unread notifications to the Sync API server.

(ctx context.Context, userID, roomID string)

Source from the content-addressed store, hash-verified

60// GetAndSendNotificationData reads the database and sends data about unread
61// notifications to the Sync API server.
62func (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.
81func (p *SyncAPI) sendNotificationData(userID string, data *eventutil.NotificationData) error {

Callers 2

onMessageMethod · 0.80
notifyLocalMethod · 0.80

Calls 1

sendNotificationDataMethod · 0.95

Tested by

no test coverage detected