store

package
v1.0.13 Latest Latest
Warning

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

Go to latest
Published: May 9, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SchemaVersion = 12
)

Variables

View Source
var (
	ErrUnsupportedLegacySchema = errors.New("unsupported legacy sqlite schema version")
	ErrLegacyDatabaseNotFound  = errors.New("legacy sqlite database not found")
	ErrUnsafeSQL               = errors.New("unsafe sql statement")
)

Functions

func AppendRelationshipEvent

func AppendRelationshipEvent(ctx context.Context, db *sql.DB, record RelationshipEventRecord) (string, error)

func ClearOwnerE2EEData

func ClearOwnerE2EEData(ctx context.Context, db *sql.DB, ownerDID string) (map[string]int64, error)

func CurrentSchemaVersion

func CurrentSchemaVersion(db *sql.DB) (int, error)

func DeleteGroupMembers

func DeleteGroupMembers(ctx context.Context, db *sql.DB, ownerDID string, groupID string, targetDID string, targetUserID string) (int64, error)

func EnsureSchema

func EnsureSchema(ctx context.Context, db *sql.DB) error

func ExecuteSQL

func ExecuteSQL(ctx context.Context, db *sql.DB, statement string, params ...any) ([]map[string]any, error)

func GetContactByDID

func GetContactByDID(ctx context.Context, db *sql.DB, ownerDID string, did string) (map[string]any, error)

func GetCurrentContactByHandle

func GetCurrentContactByHandle(ctx context.Context, db *sql.DB, ownerDID string, handle string) (map[string]any, error)

func GetE2EEOutbox

func GetE2EEOutbox(ctx context.Context, db *sql.DB, outboxID string, ownerDID string, credentialName string) (map[string]any, error)

func GetGroupSnapshot

func GetGroupSnapshot(ctx context.Context, db *sql.DB, ownerDID string, groupID string) (map[string]any, error)

func GetMessageByID

func GetMessageByID(ctx context.Context, db *sql.DB, msgID string, ownerDID string, credentialName string) (map[string]any, error)

func ListCachedGroupMembers

func ListCachedGroupMembers(ctx context.Context, db *sql.DB, ownerDID string, groupID string, limit int) ([]map[string]any, error)

func ListDIDsByHandle

func ListDIDsByHandle(ctx context.Context, db *sql.DB, ownerDID string, handle string) ([]string, error)

func ListDirectMessagesByPeerDIDs

func ListDirectMessagesByPeerDIDs(ctx context.Context, db *sql.DB, ownerDID string, peerDIDs []string, limit int, unreadOnly bool, inboxOnly bool) ([]map[string]any, error)

func ListE2EEOutbox

func ListE2EEOutbox(ctx context.Context, db *sql.DB, ownerDID string, credentialName string, localStatus string) ([]map[string]any, error)

func ListGroupInboxMessages

func ListGroupInboxMessages(ctx context.Context, db *sql.DB, ownerDID string, limit int, groupID string, unreadOnly bool) ([]map[string]any, error)

func ListGroupMessages

func ListGroupMessages(ctx context.Context, db *sql.DB, ownerDID string, groupID string, limit int, sinceSeq *int64) ([]map[string]any, error)

func ListInboxMessages

func ListInboxMessages(ctx context.Context, db *sql.DB, ownerDID string, limit int, peerDID string, unreadOnly bool, includeLocalNotifications bool) ([]map[string]any, error)

func ListMessagesByIDs

func ListMessagesByIDs(ctx context.Context, db *sql.DB, ownerDID string, messageIDs []string) ([]map[string]any, error)

func ListNotificationInboxMessages

func ListNotificationInboxMessages(ctx context.Context, db *sql.DB, ownerDID string, limit int, unreadOnly bool) ([]map[string]any, error)

func ListNotifications

func ListNotifications(ctx context.Context, db *sql.DB, ownerDID string, limit int) ([]map[string]any, error)

ListNotifications returns the most recent locally cached mail-notification rows for a given owner. It matches both legacy content_type-based records and current metadata.source_kind=mail records written by the runtime listener.

func ListThreadMessages

func ListThreadMessages(ctx context.Context, db *sql.DB, ownerDID string, threadID string, limit int) ([]map[string]any, error)

func MakeThreadID

func MakeThreadID(myDID string, peerDID string, groupID string) string

func MarkE2EEOutboxFailed

func MarkE2EEOutboxFailed(ctx context.Context, db *sql.DB, outboxID string, ownerDID string, errorCode string, retryHint string, failedMsgID string, failedServerSeq *int64, metadata string) error

func MarkE2EEOutboxSent

func MarkE2EEOutboxSent(ctx context.Context, db *sql.DB, outboxID string, ownerDID string, sessionID string, sentMsgID string, sentServerSeq *int64, metadata string) error

func MarkMessagesRead

func MarkMessagesRead(ctx context.Context, db *sql.DB, ownerDID string, messageIDs []string) (int64, error)

func MergeRecoveredHandleLocalState

func MergeRecoveredHandleLocalState(ctx context.Context, paths appconfig.Paths, oldOwnerDIDs []string, newOwnerDID string, finalCredentialName string) (map[string]int64, map[string]int64, error)

func Open

func Open(paths appconfig.Paths) (*sql.DB, error)

func OpenReadOnly

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

func QueueE2EEOutbox

func QueueE2EEOutbox(ctx context.Context, db *sql.DB, record E2EEOutboxRecord) (string, error)

func RebindLocalIdentityState

func RebindLocalIdentityState(ctx context.Context, paths appconfig.Paths, oldOwnerDID string, newOwnerDID string) (map[string]int64, map[string]int64, error)

func RebindOwnerDID

func RebindOwnerDID(ctx context.Context, db *sql.DB, oldOwnerDID string, newOwnerDID string) (map[string]int64, error)

func ReplaceGroupMembers

func ReplaceGroupMembers(ctx context.Context, db *sql.DB, ownerDID string, groupID string, members []GroupMemberRecord, credentialName string) error

func ResolveContactHandleByDID

func ResolveContactHandleByDID(ctx context.Context, db *sql.DB, ownerDID string, did string) (string, error)

func SetE2EEOutboxFailureByID

func SetE2EEOutboxFailureByID(ctx context.Context, db *sql.DB, outboxID string, ownerDID string, credentialName string, errorCode string, retryHint string, metadata string) error

func StoreMessage

func StoreMessage(ctx context.Context, db *sql.DB, record MessageRecord) error

func StoreMessagesBatch

func StoreMessagesBatch(ctx context.Context, db *sql.DB, batch []MessageRecord) error

func SyncGroupMemberFromSystemEvent

func SyncGroupMemberFromSystemEvent(ctx context.Context, db *sql.DB, ownerDID string, groupID string, systemEvent map[string]any, credentialName string) (bool, error)

func UpdateE2EEOutboxStatus

func UpdateE2EEOutboxStatus(ctx context.Context, db *sql.DB, outboxID string, ownerDID string, credentialName string, status string) error

func UpsertContact

func UpsertContact(ctx context.Context, db *sql.DB, record ContactRecord) error

func UpsertGroup

func UpsertGroup(ctx context.Context, db *sql.DB, record GroupRecord) error

func UpsertGroupMember

func UpsertGroupMember(ctx context.Context, db *sql.DB, record GroupMemberRecord) error

Types

type ContactHandleBindingRecord

type ContactHandleBindingRecord struct {
	OwnerDID       string
	Handle         string
	DID            string
	IsCurrent      bool
	FirstSeenAt    string
	LastSeenAt     string
	SourceType     string
	SourceGroupID  string
	Metadata       string
	CredentialName string
}

type ContactRecord

type ContactRecord struct {
	OwnerDID          string
	DID               string
	Name              string
	Handle            string
	NickName          string
	Bio               string
	ProfileMD         string
	Tags              string
	Relationship      string
	SourceType        string
	SourceName        string
	SourceGroupID     string
	ConnectedAt       string
	RecommendedReason string
	Followed          *bool
	Messaged          *bool
	Note              string
	FirstSeenAt       string
	LastSeenAt        string
	Metadata          string
	CredentialName    string
}

type E2EEOutboxRecord

type E2EEOutboxRecord struct {
	OutboxID        string
	OwnerDID        string
	PeerDID         string
	SessionID       string
	OriginalType    string
	Plaintext       string
	LocalStatus     string
	AttemptCount    int
	SentMsgID       string
	SentServerSeq   *int64
	LastErrorCode   string
	RetryHint       string
	FailedMsgID     string
	FailedServerSeq *int64
	Metadata        string
	LastAttemptAt   string
	CreatedAt       string
	UpdatedAt       string
	CredentialName  string
}

type E2EESessionRecord

type E2EESessionRecord struct {
	OwnerDID       string
	PeerDID        string
	SessionID      string
	IsInitiator    bool
	SendChainKey   string
	RecvChainKey   string
	SendSeq        int
	RecvSeq        int
	ExpiresAt      *float64
	CreatedAt      string
	ActiveAt       string
	PeerConfirmed  bool
	UpdatedAt      string
	CredentialName string
}

type GroupMemberRecord

type GroupMemberRecord struct {
	OwnerDID         string
	GroupID          string
	UserID           string
	MemberDID        string
	MemberHandle     string
	ProfileURL       string
	Role             string
	Status           string
	JoinedAt         string
	SentMessageCount *int64
	LastSyncedAt     string
	Metadata         string
	CredentialName   string
}

type GroupRecord

type GroupRecord struct {
	OwnerDID          string
	GroupID           string
	GroupDID          string
	Name              string
	GroupMode         string
	Slug              string
	Description       string
	Goal              string
	Rules             string
	MessagePrompt     string
	DocURL            string
	GroupOwnerDID     string
	GroupOwnerHandle  string
	MyRole            string
	MembershipStatus  string
	JoinEnabled       *bool
	JoinCode          string
	JoinCodeExpiresAt string
	MemberCount       *int64
	LastSyncedSeq     *int64
	LastReadSeq       *int64
	LastMessageAt     string
	RemoteCreatedAt   string
	RemoteUpdatedAt   string
	StoredAt          string
	Metadata          string
	CredentialName    string
}

type ImportReport

type ImportReport struct {
	SourcePath          string         `json:"source_path"`
	SourceSchemaVersion int            `json:"source_schema_version"`
	ImportedRows        map[string]int `json:"imported_rows"`
	SkippedTables       []string       `json:"skipped_tables,omitempty"`
	Warnings            []string       `json:"warnings,omitempty"`
}

func ImportLegacyDatabase

func ImportLegacyDatabase(ctx context.Context, targetDB *sql.DB, paths appconfig.Paths, manager *identity.Manager) (*ImportReport, error)

type LegacyScan

type LegacyScan struct {
	Path          string   `json:"path"`
	Exists        bool     `json:"exists"`
	SchemaVersion int      `json:"schema_version"`
	Tables        []string `json:"tables,omitempty"`
}

func ScanLegacyDatabase

func ScanLegacyDatabase(ctx context.Context, paths appconfig.Paths) (*LegacyScan, error)

type MessageRecord

type MessageRecord struct {
	MsgID          string
	OwnerDID       string
	ThreadID       string
	Direction      int
	SenderDID      string
	ReceiverDID    string
	GroupID        string
	GroupDID       string
	ContentType    string
	Content        string
	Title          string
	ServerSeq      *int64
	SentAt         string
	StoredAt       string
	IsE2EE         bool
	IsRead         bool
	SenderName     string
	Metadata       string
	CredentialName string
}

type OpenOptions

type OpenOptions struct {
	ReadOnly bool
}

type RelationshipEventRecord

type RelationshipEventRecord struct {
	EventID        string
	OwnerDID       string
	TargetDID      string
	TargetHandle   string
	EventType      string
	SourceType     string
	SourceName     string
	SourceGroupID  string
	Reason         string
	Score          *float64
	Status         string
	CreatedAt      string
	UpdatedAt      string
	Metadata       string
	CredentialName string
}

Jump to

Keyboard shortcuts

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