beeper

package
v0.0.0-...-188bdbd Latest Latest
Warning

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

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

Documentation

Overview

Package beeper provides read-only access to Beeper's local SQLite data.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ResolveMessageText

func ResolveMessageText(rawMessage string, msgType string, textContent string, format MessageFormat) string

ResolveMessageText produces a display string based on the chosen format.

Types

type BridgeLookup

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

BridgeLookup resolves DM names via platform bridge databases.

func NewBridgeLookup

func NewBridgeLookup(indexDBPath string, overrideRoot string) (*BridgeLookup, error)

NewBridgeLookup discovers megabridge.db files under the Beeper support directory.

func (*BridgeLookup) LookupDMName

func (b *BridgeLookup) LookupDMName(ctx context.Context, roomID string, accountID string) (string, bool, error)

LookupDMName attempts to resolve a DM name for the given room ID.

func (*BridgeLookup) Paths

func (b *BridgeLookup) Paths() []string

Paths returns bridge database paths discovered for the current user.

type Message

type Message struct {
	ID         int64     `json:"id"`
	EventID    string    `json:"eventId"`
	ThreadID   string    `json:"threadId"`
	ThreadName string    `json:"threadName,omitempty"`
	AccountID  string    `json:"accountId,omitempty"`
	SenderID   string    `json:"senderId"`
	SenderName string    `json:"senderName,omitempty"`
	Timestamp  time.Time `json:"timestamp"`
	IsSentByMe bool      `json:"isSentByMe"`
	Type       string    `json:"type"`
	Text       string    `json:"text"`
	Score      float64   `json:"score,omitempty"`
}

Message represents a message row from Beeper's store.

type MessageFormat

type MessageFormat string

MessageFormat controls how message text is rendered.

const (
	// FormatPlain returns the raw/plain text only.
	FormatPlain MessageFormat = "plain"
	// FormatRich renders attachments and non-text messages with placeholders.
	FormatRich MessageFormat = "rich"
)

type MessageListOptions

type MessageListOptions struct {
	ThreadID string
	Limit    int
	After    *time.Time
	Before   *time.Time
	Format   MessageFormat
}

MessageListOptions controls message list filtering.

type Participant

type Participant struct {
	ID     string `json:"id"`
	Name   string `json:"name"`
	IsSelf bool   `json:"isSelf"`
}

Participant represents a user in a thread.

type SearchOptions

type SearchOptions struct {
	Query     string
	ThreadID  string
	Days      int
	Limit     int
	AccountID string
	Context   int
	Window    time.Duration
	Format    MessageFormat
}

SearchOptions controls full-text search behavior.

type SearchResult

type SearchResult struct {
	Match   Message   `json:"match"`
	Context []Message `json:"context,omitempty"`
}

SearchResult is a match plus optional surrounding context.

type Store

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

Store provides read-only access to Beeper's SQLite database.

func Open

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

Open opens a read-only store with bridge lookups enabled.

func OpenWithOptions

func OpenWithOptions(path string, opts StoreOptions) (*Store, error)

OpenWithOptions opens a read-only store with the provided options.

func (*Store) BridgeDBs

func (s *Store) BridgeDBs() []string

BridgeDBs returns discovered platform bridge database paths.

func (*Store) Close

func (s *Store) Close() error

Close closes the underlying database connection.

func (*Store) GetThread

func (s *Store) GetThread(ctx context.Context, threadID string, withStats bool) (Thread, error)

GetThread returns a single thread by ID.

func (*Store) HasFTS

func (s *Store) HasFTS(ctx context.Context) (bool, error)

HasFTS reports whether the FTS table exists.

func (*Store) ListMessages

func (s *Store) ListMessages(ctx context.Context, opts MessageListOptions) ([]Message, error)

ListMessages returns messages for a thread.

func (*Store) ListThreads

func (s *Store) ListThreads(ctx context.Context, opts ThreadListOptions) ([]Thread, error)

ListThreads returns threads filtered by the provided options.

func (*Store) SearchMessages

func (s *Store) SearchMessages(ctx context.Context, opts SearchOptions) ([]SearchResult, error)

SearchMessages searches messages using FTS (or LIKE fallback).

type StoreOptions

type StoreOptions struct {
	BridgeLookup bool
	BridgeRoot   string
}

StoreOptions configures Store behavior.

type Thread

type Thread struct {
	ID             string        `json:"id"`
	AccountID      string        `json:"accountId"`
	Title          string        `json:"title,omitempty"`
	Name           string        `json:"name,omitempty"`
	Type           string        `json:"type,omitempty"`
	DisplayName    string        `json:"displayName"`
	LastActivity   time.Time     `json:"lastActivity"`
	LastMessage    time.Time     `json:"lastMessageTime,omitempty"`
	LastOpen       time.Time     `json:"lastOpenTime,omitempty"`
	IsUnread       bool          `json:"isUnread"`
	IsMarkedUnread bool          `json:"isMarkedUnread"`
	IsLowPriority  bool          `json:"isLowPriority"`
	IsArchived     bool          `json:"isArchived"`
	UnreadCount    int           `json:"unreadCount,omitempty"`
	UnreadMentions int           `json:"unreadMentions,omitempty"`
	TotalMessages  int           `json:"totalMessages,omitempty"`
	Tags           []string      `json:"tags,omitempty"`
	Participants   []Participant `json:"participants,omitempty"`
}

Thread describes a conversation.

type ThreadLabel

type ThreadLabel string

ThreadLabel filters conversation lists.

const (
	// LabelAll returns all threads.
	LabelAll ThreadLabel = "all"
	// LabelInbox returns inbox threads.
	LabelInbox ThreadLabel = "inbox"
	// LabelArchive returns archived threads.
	LabelArchive ThreadLabel = "archive"
	// LabelFavourite returns favourite threads.
	LabelFavourite ThreadLabel = "favourite"
	// LabelUnread returns threads with unread messages.
	LabelUnread ThreadLabel = "unread"
)

type ThreadListOptions

type ThreadListOptions struct {
	Days               int
	Limit              int
	AccountID          string
	Label              ThreadLabel
	IncludeLowPriority bool
	WithParticipants   bool
	WithStats          bool
}

ThreadListOptions controls thread list filtering.

Jump to

Keyboard shortcuts

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