Documentation
¶
Overview ¶
Package database provides contact resolution functionality.
Package database provides functionality for reading iMessage data from chat.db.
Index ¶
- func AppleTimeToTime(appleTime int64) *time.Time
- func CloseDB()
- func DB() (*sql.DB, error)
- func ExtractTextFromAttributedBody(data []byte) string
- func GetAttachmentsForMessages(messageIDs []int64) (map[int64][]Attachment, error)
- func GetConnection() (*sql.DB, error)
- func GetContactName(identifier string) string
- func GetDBPath() string
- func GetPhoneVariants(phone string) []string
- func GetUnreadCount() (int, error)
- func NormalizePhoneNumber(phone string) string
- func PreloadContacts()
- func ResolveSender(isFromMe bool, senderID string) string
- type Attachment
- type ContactResolver
- type Conversation
- type Message
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppleTimeToTime ¶
AppleTimeToTime converts Apple's timestamp format to Go time.Time. Apple uses nanoseconds since 2001-01-01, while Unix uses seconds since 1970-01-01. The difference is 978307200 seconds.
func CloseDB ¶
func CloseDB()
CloseDB closes the shared database connection pool. Call this during application shutdown for a clean exit.
func DB ¶
DB returns the shared database connection pool. The pool is lazily initialized on first call and reused for all subsequent queries.
func ExtractTextFromAttributedBody ¶
ExtractTextFromAttributedBody extracts plain text from an attributedBody blob. The attributedBody column contains a serialized NSAttributedString.
func GetAttachmentsForMessages ¶
func GetAttachmentsForMessages(messageIDs []int64) (map[int64][]Attachment, error)
GetAttachmentsForMessages retrieves attachments for multiple message IDs in a single query and returns them keyed by message ID.
func GetConnection ¶
GetConnection creates a new standalone connection to the iMessage database. Deprecated: Use DB() for the shared connection pool instead.
func GetContactName ¶
GetContactName returns the contact name for a phone number or email.
func GetPhoneVariants ¶
GetPhoneVariants generates common variants of a phone number for matching.
func GetUnreadCount ¶
GetUnreadCount returns the count of unread messages.
func NormalizePhoneNumber ¶
NormalizePhoneNumber normalizes a phone number to just digits for comparison.
func ResolveSender ¶
ResolveSender resolves a sender identifier to a display name.
Types ¶
type Attachment ¶
type Attachment struct {
AttachmentID int64
Filename string // original filename
FilePath string // full path on disk (~ expanded)
MIMEType string
UTI string // e.g. public.jpeg, public.heic
TotalBytes int64
IsImage bool
}
Attachment represents a file attachment on an iMessage.
func GetAttachmentsForMessage ¶
func GetAttachmentsForMessage(messageID int64) ([]Attachment, error)
GetAttachmentsForMessage retrieves attachments for a single message ID.
type ContactResolver ¶
type ContactResolver struct {
// contains filtered or unexported fields
}
ContactResolver resolves phone numbers and email addresses to contact names.
func NewContactResolver ¶
func NewContactResolver() *ContactResolver
NewContactResolver creates a new ContactResolver.
func (*ContactResolver) GetContactCount ¶
func (cr *ContactResolver) GetContactCount() int
GetContactCount returns the number of loaded contacts.
func (*ContactResolver) Resolve ¶
func (cr *ContactResolver) Resolve(identifier string) string
Resolve resolves an identifier (phone/email) to a contact name.
type Conversation ¶
type Conversation struct {
ChatID int64
ChatIdentifier string
DisplayName string
Service string
LastMessageDate *time.Time
LastMessageText string
UnreadCount int
Participants []string
}
Conversation represents a chat/conversation.
func GetContactByIdentifier ¶
func GetContactByIdentifier(identifier string) (*Conversation, error)
GetContactByIdentifier looks up a contact by phone number or email.
func GetConversations ¶
func GetConversations(limit int) ([]Conversation, error)
GetConversations retrieves a list of recent conversations.
type Message ¶
type Message struct {
MessageID int64
Text string
Date *time.Time
IsFromMe bool
IsRead bool
Service string
Sender string
ChatID int64
ChatIdent string
ChatName string
Attachments []Attachment
}
Message represents an iMessage.
func GetMessages ¶
GetMessages retrieves messages from a specific conversation.