chatdb

package
v2.4.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 22, 2024 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

Package chatdb provides an interface ChatDB for interacting with the Mac OS Messages database typically located at $HOME/Library/Messages/chat.db. See [this Medium post](https://towardsdatascience.com/heres-how-you-can-access-your-entire-imessage-history-on-your-mac-f8878276c6e9) for a decent primer on navigating the database. Specifically, this package is tailored to supporting the exporting of all messages in the database to readable, searchable text files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Attachment

type Attachment struct {
	ID           int
	Filename     string
	MIMEType     string
	TransferName string
}

Attachment represents a row from the attachment table.

type Chat

type Chat struct {
	ID   int
	GUID string
}

Chat represents a row from the chat table.

type ChatDB

type ChatDB interface {
	// Init determines the version of the database, preparing it to make the
	// appropriate queries.
	Init(macOSVersion *semver.Version) error
	// GetHandleMap returns a mapping from handle ID to phone number or email
	// address. If a contact map is supplied, it will attempt to resolve these
	// handles to formatted names.
	GetHandleMap(contactMap map[string]*vcard.Card) (map[int]string, error)
	// GetChats returns a slice of EntityChats, effectively a table scan of
	// the chat table.
	GetChats(contactMap map[string]*vcard.Card) ([]EntityChats, error)
	// GetMessageIDs returns a slice of DatedMessageIDs corresponding to a
	// given chat ID.
	GetMessageIDs(chatID int) ([]DatedMessageID, error)
	// GetMessage returns a message retrieved from the database formatted for
	// writing to a chat file, as well as flag indicating the validity of the
	// text in the message.
	GetMessage(messageID int, handleMap map[int]string) (string, bool, error)
	// GetAttachmentPaths returns a list of attachment filepaths associated with
	// each message ID.
	GetAttachmentPaths(ptools pathtools.PathTools) (map[int][]Attachment, error)
}

ChatDB extracts data from a Mac OS Messages database on disk.

func NewChatDB

func NewChatDB(db *sql.DB, selfHandle string) ChatDB

NewChatDB returns a ChatDB interface using the given DB. Init must be called on it before use.

type DatedMessageID

type DatedMessageID struct {
	ID   int
	Date int
}

DatedMessageID pairs a message ID and its date, in the legacy date format.

type EntityChats

type EntityChats struct {
	Name  string
	Chats []Chat
}

EntityChats represents all of the chats with a given entity (associated with the same vCard, phone number, or email address). In the case of group chats, this struct will only contain a single Chat.

Directories

Path Synopsis
Package mock_chatdb is a generated GoMock package.
Package mock_chatdb is a generated GoMock package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL