Documentation
¶
Overview ¶
Package tracker turns changes in chat.db into events.
New messages are found by ROWID high-water mark, so none are missed even if a file notification is. Changes to existing messages (sent, delivered, read, edited, unsent, failed, played) are found by diffing a cheap state snapshot of recent messages against the previous one. Chat read markers are diffed the same way.
Index ¶
Constants ¶
const ( ChangeSent = "sent" ChangeDelivered = "delivered" ChangeRead = "read" ChangePlayed = "played" ChangeEdited = "edited" ChangeUnsent = "unsent" ChangeFailed = "failed" )
Change names reported in message.updated events.
Variables ¶
This section is empty.
Functions ¶
func Diff ¶
func Diff(prev, cur db.MessageState) []string
Diff lists what changed between two states of the same message.
Types ¶
type ChatReadEvent ¶
ChatReadEvent is the data of chat.read events.
type MessageEvent ¶
MessageEvent is the data of message.received/sent events.
type Options ¶
type Options struct {
DB *db.DB
Bus *events.Bus
Presenter *present.Presenter
// Window is how far back changes to existing messages are tracked.
// Default 7 days.
Window time.Duration
// BackfillAge suppresses events for new rows dated more than this far in
// the past (e.g. history downloaded from iCloud). Default 1 hour.
BackfillAge time.Duration
// OnNewMessage, if set, is called for every new row (including
// suppressed backfill) before events are published.
OnNewMessage func(*db.Message)
// OnMessageUpdated, if set, is called with each changed message.
OnMessageUpdated func(m *db.Message, changes []string)
Now func() time.Time
}
type Tracker ¶
type Tracker struct {
// contains filtered or unexported fields
}
type UpdateEvent ¶
type UpdateEvent struct {
Message present.Message `json:"message"`
Changes []string `json:"changes"`
}
UpdateEvent is the data of message.updated events.