store

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HistoryCoverageStatusReady     = "ready"
	HistoryCoverageStatusBlocked   = "blocked"
	HistoryCoverageBlockedNoAnchor = "no_local_anchor"
)
View Source
const DeletedForMeMessageDisplayText = "This message was deleted for me"
View Source
const DeletedMessageDisplayText = "This message was deleted"

Variables

This section is empty.

Functions

func IsPollNotFound added in v0.9.0

func IsPollNotFound(err error) bool

IsPollNotFound is a small convenience predicate.

Types

type Button added in v0.9.0

type Button struct {
	Type         string `json:"type"`
	DisplayText  string `json:"display_text"`
	ID           string `json:"id,omitempty"`
	URL          string `json:"url,omitempty"`
	PhoneNumber  string `json:"phone_number,omitempty"`
	Description  string `json:"description,omitempty"`
	ResponseType string `json:"response_type,omitempty"`
	Index        int    `json:"index,omitempty"`
}

type CallEvent added in v0.9.2

type CallEvent struct {
	ChatJID      string            `json:"chat_jid"`
	ChatName     string            `json:"chat_name,omitempty"`
	SenderJID    string            `json:"sender_jid,omitempty"`
	SenderName   string            `json:"sender_name,omitempty"`
	CallID       string            `json:"call_id"`
	MsgID        string            `json:"msg_id,omitempty"`
	EventType    string            `json:"event_type"`
	Direction    string            `json:"direction,omitempty"`
	Media        string            `json:"media,omitempty"`
	Outcome      string            `json:"outcome,omitempty"`
	Reason       string            `json:"reason,omitempty"`
	CallType     string            `json:"call_type,omitempty"`
	DurationSecs int64             `json:"duration_secs,omitempty"`
	Timestamp    time.Time         `json:"timestamp"`
	Participants []CallParticipant `json:"participants,omitempty"`
	// contains filtered or unexported fields
}

type CallParticipant added in v0.9.2

type CallParticipant struct {
	JID     string `json:"jid"`
	Outcome string `json:"outcome,omitempty"`
}

type Chat

type Chat struct {
	JID           string    `json:"jid"`
	Kind          string    `json:"kind"`
	Name          string    `json:"name"`
	LastMessageTS time.Time `json:"last_message_ts"`
	Archived      bool      `json:"archived"`
	Pinned        bool      `json:"pinned"`
	MutedUntil    int64     `json:"muted_until"`
	Unread        bool      `json:"unread"`
	UnreadCount   int       `json:"unread_count"`
}

func (Chat) Muted

func (c Chat) Muted() bool

type ChatListFilter

type ChatListFilter struct {
	Query    string
	Limit    int
	Archived *bool
	Pinned   *bool
	Muted    *bool
	Unread   *bool
}

type Contact

type Contact struct {
	JID        string    `json:"jid"`
	Phone      string    `json:"phone"`
	Name       string    `json:"name"`
	Alias      string    `json:"alias"`
	SystemName string    `json:"system_name"`
	Tags       []string  `json:"tags,omitempty"`
	UpdatedAt  time.Time `json:"updated_at"`
}

type DB

type DB struct {
	// contains filtered or unexported fields
}

func Open

func Open(path string) (*DB, error)

func OpenReadOnly added in v0.9.2

func OpenReadOnly(path string) (*DB, error)

func (*DB) AddTag

func (d *DB) AddTag(jid, tag string) error

func (*DB) ClearAllSystemNames

func (d *DB) ClearAllSystemNames() (int64, error)

func (*DB) Close

func (d *DB) Close() error

func (*DB) CountChatMessages

func (d *DB) CountChatMessages(jid string) (int64, error)

func (*DB) CountChats added in v0.9.2

func (d *DB) CountChats() (int64, error)

func (*DB) CountGroups added in v0.9.2

func (d *DB) CountGroups() (int64, error)

func (*DB) CountLeftGroups added in v0.9.2

func (d *DB) CountLeftGroups() (int64, error)

func (*DB) CountMessages

func (d *DB) CountMessages() (int64, error)

func (*DB) CountSystemNames

func (d *DB) CountSystemNames() (int64, error)

func (*DB) DeleteCallEvents added in v0.9.2

func (d *DB) DeleteCallEvents(p DeleteCallEventsParams) (int64, error)

func (*DB) DeleteChat

func (d *DB) DeleteChat(jid string) error

func (*DB) DeleteChatsOlderThan

func (d *DB) DeleteChatsOlderThan(days int) (int64, error)

func (*DB) DeleteGroup

func (d *DB) DeleteGroup(jid string) error

func (*DB) DeleteGroupLocalData

func (d *DB) DeleteGroupLocalData(jid string) (err error)

func (*DB) DeleteLeftGroups

func (d *DB) DeleteLeftGroups() (int64, error)

func (*DB) DeleteLeftGroupsOlderThan

func (d *DB) DeleteLeftGroupsOlderThan(days int) (int64, error)

func (*DB) DeletePoll added in v0.9.0

func (d *DB) DeletePoll(chatJID, msgID string) error

DeletePoll removes a poll and all its votes (votes are cascaded by foreign key, but we issue an explicit delete since the FK isn't declared at the table level).

func (*DB) DeletePollVote added in v0.9.0

func (d *DB) DeletePollVote(chatJID, pollMsgID, voterJID string, votedAt time.Time) error

DeletePollVote removes one voter's current vote if the deletion is not older than the stored vote row.

func (*DB) FindPollByMsgID added in v0.9.0

func (d *DB) FindPollByMsgID(msgID string) (Poll, error)

FindPollByMsgID returns the most recent poll matching the given msg_id across any chat. Useful when the chat JID embedded in a vote event (often a LID) does not match the chat under which the poll was stored (often a phone-number JID for self-conversations). Returns sql.ErrNoRows if not found.

func (*DB) GetChat

func (d *DB) GetChat(jid string) (Chat, error)

func (*DB) GetContact

func (d *DB) GetContact(jid string) (Contact, error)

func (*DB) GetLatestMessageInfo

func (d *DB) GetLatestMessageInfo(chatJID string) (MessageInfo, error)

func (*DB) GetMediaDownloadInfo

func (d *DB) GetMediaDownloadInfo(chatJID, msgID string) (MediaDownloadInfo, error)

func (*DB) GetMessage

func (d *DB) GetMessage(chatJID, msgID string) (Message, error)

func (*DB) GetOldestMessageInfo

func (d *DB) GetOldestMessageInfo(chatJID string) (MessageInfo, error)

func (*DB) GetPoll added in v0.9.0

func (d *DB) GetPoll(chatJID, msgID string) (Poll, error)

GetPoll fetches a single poll by (chat_jid, msg_id). Returns sql.ErrNoRows if not found.

func (*DB) GetStatusMessage added in v0.9.2

func (d *DB) GetStatusMessage(msgID string) (StatusMessage, error)

func (*DB) HasFTS

func (d *DB) HasFTS() bool

func (*DB) HistoricalLIDJIDs

func (d *DB) HistoricalLIDJIDs() ([]string, error)

HistoricalLIDJIDs returns distinct hidden-user JIDs stored in chat and message/poll identity columns. The app layer resolves these through whatsmeow.

func (*DB) IncrementChatUnread added in v0.11.0

func (d *DB) IncrementChatUnread(jid string) error

func (*DB) ListCallEvents added in v0.9.2

func (d *DB) ListCallEvents(p ListCallEventsParams) ([]CallEvent, error)

func (*DB) ListChats

func (d *DB) ListChats(query string, limit int) ([]Chat, error)

func (*DB) ListChatsFiltered

func (d *DB) ListChatsFiltered(f ChatListFilter) ([]Chat, error)

func (*DB) ListChatsOlderThan

func (d *DB) ListChatsOlderThan(days int) ([]Chat, error)

func (*DB) ListContacts

func (d *DB) ListContacts(limit int) ([]Contact, error)

func (*DB) ListGroups

func (d *DB) ListGroups(query string, limit int) ([]Group, error)

func (*DB) ListHistoryCoverage

func (d *DB) ListHistoryCoverage(p ListHistoryCoverageParams) ([]HistoryCoverage, error)

func (*DB) ListLeftGroups

func (d *DB) ListLeftGroups() ([]Group, error)

func (*DB) ListMessages

func (d *DB) ListMessages(p ListMessagesParams) ([]Message, error)

func (*DB) ListPollVotes added in v0.9.0

func (d *DB) ListPollVotes(chatJID, pollMsgID string) ([]PollVote, error)

ListPollVotes returns the per-voter votes for a poll, ordered by ts ASC.

func (*DB) ListPolls added in v0.9.0

func (d *DB) ListPolls(filter PollListFilter) ([]Poll, error)

ListPolls returns polls ordered most-recent-first.

func (*DB) ListPrunableGroups

func (d *DB) ListPrunableGroups(days int, includeActive bool) ([]Group, error)

func (*DB) ListStarredMessages

func (d *DB) ListStarredMessages(p ListStarredMessagesParams) ([]Message, error)

func (*DB) ListTags

func (d *DB) ListTags(jid string) ([]string, error)

func (*DB) MarkGroupLeft

func (d *DB) MarkGroupLeft(jid string, leftAt time.Time) error

func (*DB) MarkGroupsMissingFrom

func (d *DB) MarkGroupsMissingFrom(joined map[string]bool, leftAt time.Time) error

func (*DB) MarkMediaDownloaded

func (d *DB) MarkMediaDownloaded(chatJID, msgID, localPath string, downloadedAt time.Time) error

func (*DB) MarkMessageDeletedForMe

func (d *DB) MarkMessageDeletedForMe(chatJID, msgID, senderJID string, fromMe bool, deletedAt time.Time) error

func (*DB) MarkMessageDeletedForMePreserveMedia added in v0.9.2

func (d *DB) MarkMessageDeletedForMePreserveMedia(chatJID, msgID string) error

func (*DB) MarkMessageRevoked

func (d *DB) MarkMessageRevoked(chatJID, msgID string) error

func (*DB) MessageContext

func (d *DB) MessageContext(chatJID, msgID string, before, after int) ([]Message, error)

func (*DB) MigrateLIDToPN

func (d *DB) MigrateLIDToPN(lidJID, pnJID string) error

MigrateLIDToPN rewrites one historical hidden-user JID to its phone-number JID. It is idempotent and merges duplicate chat/message rows created by the old split storage behavior.

func (*DB) RemoveAlias

func (d *DB) RemoveAlias(jid string) error

func (*DB) RemoveTag

func (d *DB) RemoveTag(jid, tag string) error

func (*DB) ReplaceGroupParticipants

func (d *DB) ReplaceGroupParticipants(groupJID string, participants []GroupParticipant) (err error)

func (*DB) SearchContacts

func (d *DB) SearchContacts(query string, limit int) ([]Contact, error)

func (*DB) SearchMessages

func (d *DB) SearchMessages(p SearchMessagesParams) ([]Message, error)

func (*DB) SetAlias

func (d *DB) SetAlias(jid, alias string) error

func (*DB) SetChatArchived

func (d *DB) SetChatArchived(jid string, archived bool) error

func (*DB) SetChatMutedUntil

func (d *DB) SetChatMutedUntil(jid string, mutedUntil int64) error

func (*DB) SetChatPinned

func (d *DB) SetChatPinned(jid string, pinned bool) error

func (*DB) SetChatUnread

func (d *DB) SetChatUnread(jid string, unread bool) error

func (*DB) SetChatUnreadCount added in v0.11.0

func (d *DB) SetChatUnreadCount(jid string, count int) error

func (*DB) SetStarred

func (d *DB) SetStarred(p SetStarredParams) error

func (*DB) SetSystemName

func (d *DB) SetSystemName(jid, systemName string) error

func (*DB) Stats

func (d *DB) Stats() (StoreStats, error)

func (*DB) UpdateMessageText

func (d *DB) UpdateMessageText(chatJID, msgID, text string) error

func (*DB) UpsertCallEvent added in v0.9.2

func (d *DB) UpsertCallEvent(p UpsertCallEventParams) error

func (*DB) UpsertChat

func (d *DB) UpsertChat(jid, kind, name string, lastTS time.Time) error

func (*DB) UpsertContact

func (d *DB) UpsertContact(jid, phone, pushName, fullName, firstName, businessName string) error

func (*DB) UpsertGroup

func (d *DB) UpsertGroup(jid, name, ownerJID string, created time.Time) error

func (*DB) UpsertGroupWithHierarchy

func (d *DB) UpsertGroupWithHierarchy(jid, name, ownerJID string, created time.Time, isParent bool, linkedParentJID string) error

func (*DB) UpsertMessage

func (d *DB) UpsertMessage(p UpsertMessageParams) error

func (*DB) UpsertPoll added in v0.9.0

func (d *DB) UpsertPoll(p Poll) error

UpsertPoll inserts or replaces a poll row keyed on (chat_jid, msg_id).

func (*DB) UpsertPollVote added in v0.9.0

func (d *DB) UpsertPollVote(v PollVote) error

UpsertPollVote replaces the vote row for (chat, poll, voter).

func (*DB) UpsertStatusMessage added in v0.9.2

func (d *DB) UpsertStatusMessage(p UpsertStatusMessageParams) error

type DeleteCallEventsParams added in v0.9.2

type DeleteCallEventsParams struct {
	ChatJID   string
	Direction string
}

type Group

type Group struct {
	JID             string
	Name            string
	OwnerJID        string
	IsParent        bool
	LinkedParentJID string
	CreatedAt       time.Time
	LeftAt          time.Time
	UpdatedAt       time.Time
}

type GroupParticipant

type GroupParticipant struct {
	GroupJID  string
	UserJID   string
	Role      string
	UpdatedAt time.Time
}

type HistoryCoverage

type HistoryCoverage struct {
	ChatJID       string    `json:"chat_jid"`
	Kind          string    `json:"kind"`
	Name          string    `json:"name,omitempty"`
	LastMessageTS time.Time `json:"last_message_ts,omitempty"`
	MessageCount  int64     `json:"message_count"`
	OldestTS      time.Time `json:"oldest_ts,omitempty"`
	NewestTS      time.Time `json:"newest_ts,omitempty"`
	Status        string    `json:"status"`
	BlockedReason string    `json:"blocked_reason,omitempty"`
}

type ListCallEventsParams added in v0.9.2

type ListCallEventsParams struct {
	ChatJID  string
	ChatJIDs []string
	Limit    int
	Before   *time.Time
	After    *time.Time
	Asc      bool
}

type ListHistoryCoverageParams

type ListHistoryCoverageParams struct {
	Query          string
	Kind           string
	ChatJIDs       []string
	Limit          int
	IncludeBlocked bool
	OnlyActionable bool
}

type ListMessagesParams

type ListMessagesParams struct {
	ChatJID   string
	ChatJIDs  []string
	SenderJID string
	Limit     int
	Before    *time.Time
	After     *time.Time
	FromMe    *bool
	Asc       bool
	Forwarded bool
	Starred   bool
}

type ListStarredMessagesParams

type ListStarredMessagesParams struct {
	ChatJID  string
	ChatJIDs []string
	Limit    int
	Before   *time.Time
	After    *time.Time
	Asc      bool
}

type MediaDownloadInfo

type MediaDownloadInfo struct {
	ChatJID       string
	ChatName      string
	MsgID         string
	MediaType     string
	Filename      string
	MimeType      string
	DirectPath    string
	MediaKey      []byte
	FileSHA256    []byte
	FileEncSHA256 []byte
	FileLength    uint64
	LocalPath     string
	DownloadedAt  time.Time
}

type Message

type Message struct {
	ChatJID         string
	ChatName        string
	MsgID           string
	SenderJID       string
	SenderName      string
	Timestamp       time.Time
	FromMe          bool
	Text            string
	DisplayText     string
	QuotedMsgID     string   `json:"quoted_msg_id,omitempty"`
	QuotedSenderJID string   `json:"quoted_sender_jid,omitempty"`
	Buttons         []Button `json:",omitempty"`
	IsForwarded     bool
	ForwardingScore uint32
	ReactionToID    string
	ReactionEmoji   string
	MediaType       string
	MediaCaption    string
	Filename        string
	MimeType        string
	DirectPath      string
	LocalPath       string
	DownloadedAt    time.Time
	Starred         bool
	StarredAt       time.Time
	Revoked         bool
	DeletedForMe    bool
	Snippet         string
	// contains filtered or unexported fields
}

type MessageInfo

type MessageInfo struct {
	ChatJID    string
	MsgID      string
	Timestamp  time.Time
	FromMe     bool
	SenderJID  string
	SenderName string
}

type Poll added in v0.9.0

type Poll struct {
	ChatJID         string
	MsgID           string
	SenderJID       string
	Question        string
	Options         []string
	SelectableCount uint32
	CreatedAt       time.Time
}

Poll represents a stored PollCreationMessage.

type PollListFilter added in v0.9.0

type PollListFilter struct {
	ChatJID  string
	ChatJIDs []string
	Limit    int
	Offset   int
}

PollListFilter narrows down polls returned by ListPolls.

type PollVote added in v0.9.0

type PollVote struct {
	ChatJID       string
	PollMsgID     string
	VoterJID      string
	VoteMsgID     string
	Selected      []string
	UnknownHashes []string
	VotedAt       time.Time
}

PollVote represents one voter's latest vote on a poll.

type SearchMessagesParams

type SearchMessagesParams struct {
	Query     string
	ChatJID   string
	ChatJIDs  []string
	From      string
	Limit     int
	Before    *time.Time
	After     *time.Time
	HasMedia  bool
	Type      string
	Forwarded bool
	Starred   bool
}

type SetStarredParams

type SetStarredParams struct {
	ChatJID   string
	MsgID     string
	SenderJID string
	FromMe    bool
	Starred   bool
	StarredAt time.Time
}

type StatusMessage added in v0.9.2

type StatusMessage struct {
	RowID           int64
	MsgID           string
	Timestamp       time.Time
	FromMe          bool
	SenderJID       string
	SenderName      string
	Text            string
	MediaType       string
	MediaCaption    string
	Filename        string
	MimeType        string
	DirectPath      string
	MediaKey        []byte
	FileSHA256      []byte
	FileEncSHA256   []byte
	FileLength      uint64
	BackgroundColor string
	Font            int32
}

type StoreStats

type StoreStats struct {
	Messages      int64
	Chats         int64
	Contacts      int64
	Groups        int64
	LastMessageTS int64
}

type UpsertCallEventParams added in v0.9.2

type UpsertCallEventParams struct {
	ChatJID      string
	ChatName     string
	SenderJID    string
	SenderName   string
	CallID       string
	MsgID        string
	EventType    string
	Direction    string
	Media        string
	Outcome      string
	Reason       string
	CallType     string
	DurationSecs int64
	Timestamp    time.Time
	Participants []CallParticipant
}

type UpsertMessageParams

type UpsertMessageParams struct {
	ChatJID         string
	ChatName        string
	MsgID           string
	SenderJID       string
	SenderName      string
	Timestamp       time.Time
	FromMe          bool
	Text            string
	DisplayText     string
	QuotedMsgID     string
	QuotedSenderJID string
	Buttons         []Button
	IsForwarded     bool
	ForwardingScore uint32
	ReactionToID    string
	ReactionEmoji   string
	MediaType       string
	MediaCaption    string
	Filename        string
	MimeType        string
	DirectPath      string
	MediaKey        []byte
	FileSHA256      []byte
	FileEncSHA256   []byte
	FileLength      uint64
	Edited          bool
	Revoked         bool
	DeletedForMe    bool
}

type UpsertStatusMessageParams added in v0.9.2

type UpsertStatusMessageParams struct {
	MsgID           string
	Timestamp       time.Time
	FromMe          bool
	SenderJID       string
	SenderName      string
	Text            string
	MediaType       string
	MediaCaption    string
	Filename        string
	MimeType        string
	DirectPath      string
	MediaKey        []byte
	FileSHA256      []byte
	FileEncSHA256   []byte
	FileLength      uint64
	BackgroundColor string
	Font            int32
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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