history

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2026 License: MIT Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const DefaultProfileID = "default"

DefaultProfileID mirrors config.DefaultProfileID (importing config would cycle). Pre-multi-profile rows are migrated to it.

View Source
const ResendCooldown = 25 * 24 * time.Hour

ResendCooldown: long enough that resuming a backlog across the daily cap skips yesterday's brokers, short enough for the monthly re-run.

Variables

This section is empty.

Functions

func DBPathFor

func DBPathFor(configPath string) string

DBPathFor returns history.db next to configPath, so an alternate --config gets isolated data. DefaultDBPath() when configPath is empty.

func DefaultDBPath

func DefaultDBPath() string

func SortBySendPriority added in v0.8.5

func SortBySendPriority[T any](items []T, lastSent func(T) time.Time)

SortBySendPriority orders items never-sent first, then by oldest last send, keeping the original order among ties. Senders truncate to the daily cap after this, so runs spaced a cooldown or more apart still reach the tail of the list instead of re-sending its head every time.

Types

type BrokerResponse

type BrokerResponse struct {
	ID           int64
	ProfileID    string
	BrokerID     string
	BrokerName   string
	ResponseType string // form_required, confirmation_required, success, rejected, pending, unknown
	EmailFrom    string
	EmailSubject string
	EmailBody    string // Stored for reclassification
	FormURL      string // Extracted form URL (if any)
	ConfirmURL   string // Extracted confirmation URL (if any)
	Confidence   float64
	NeedsReview  bool
	ReceivedAt   time.Time
	ProcessedAt  time.Time
	CreatedAt    time.Time
}

BrokerResponse stores a classified response from a broker

type BrokerStatus

type BrokerStatus struct {
	BrokerID  string
	LastSent  time.Time
	Status    Status
	TotalSent int
}

type FormWithStatus

type FormWithStatus struct {
	BrokerID       string
	BrokerName     string
	FormURL        string
	EmailSubject   string
	DetectedAt     time.Time
	Status         string // pending, filled, captcha, failed, skipped
	TaskID         int64  // If there's a pending task
	PipelineStatus PipelineStatus
}

FormWithStatus represents a form detected from email with its current fill status

type PendingTask

type PendingTask struct {
	ID             int64
	ProfileID      string
	BrokerID       string
	BrokerName     string
	TaskType       TaskType
	FormURL        string
	ScreenshotPath string
	BrowserState   string // JSON serialized browser state (profile data for helper page)
	Notes          string
	Status         string // pending, completed, skipped
	CreatedAt      time.Time
	OpenedAt       sql.NullTime // When user first opened the helper page
	CompletedAt    sql.NullTime
}

PendingTask represents a task that needs human intervention

type PipelineStatus

type PipelineStatus string

PipelineStatus represents the current stage in the removal pipeline

const (
	PipelineEmailSent            PipelineStatus = "email_sent"
	PipelineAwaitingResponse     PipelineStatus = "awaiting_response"
	PipelineFormRequired         PipelineStatus = "form_required"
	PipelineFormFilled           PipelineStatus = "form_filled"
	PipelineAwaitingCaptcha      PipelineStatus = "awaiting_captcha"
	PipelineCaptchaSolved        PipelineStatus = "captcha_solved"
	PipelineAwaitingConfirmation PipelineStatus = "awaiting_confirmation"
	PipelineConfirmed            PipelineStatus = "confirmed"
	PipelineFailed               PipelineStatus = "failed"
	PipelineRejected             PipelineStatus = "rejected"
)

type Record

type Record struct {
	ID             int64
	ProfileID      string
	BrokerID       string
	BrokerName     string
	Email          string
	Template       string
	Status         Status
	MessageID      string
	Error          string
	SentAt         time.Time
	CreatedAt      time.Time
	PipelineStatus PipelineStatus // Current stage in pipeline
	SentMethod     string         // "smtp" (Eraser sent it) or "manual" (user did)
}

type Status

type Status string
const (
	StatusSent    Status = "sent"
	StatusFailed  Status = "failed"
	StatusPending Status = "pending"
)

type Store

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

func NewStore

func NewStore(dbPath string) (*Store, error)

func (*Store) Add

func (s *Store) Add(record *Record) error

func (*Store) AddBrokerResponse

func (s *Store) AddBrokerResponse(resp *BrokerResponse) error

AddBrokerResponse stores a classified response from a broker

func (*Store) AddBrokerResponseIfNew added in v0.9.0

func (s *Store) AddBrokerResponseIfNew(resp *BrokerResponse) (inserted bool, err error)

FindBrokerResponseBySubject finds an existing response by profile, broker_id and email_subject AddBrokerResponseIfNew stores resp unless the same reply (profile, broker, subject and received time) is already recorded, so repeated or scheduled inbox scans over an overlapping window don't pile up duplicates. inserted is false for a reply seen before.

func (*Store) AddPendingTask

func (s *Store) AddPendingTask(task *PendingTask) error

AddPendingTask creates a new pending task for human intervention

func (*Store) ClearBrokerResponses

func (s *Store) ClearBrokerResponses() error

ClearBrokerResponses removes all broker responses (for full re-scan)

func (*Store) Close

func (s *Store) Close() error

func (*Store) CompletePendingTask

func (s *Store) CompletePendingTask(id int64, profileID string, status string) error

CompletePendingTask marks a task as completed, scoped to the given profile - a task belonging to a different profile is left untouched.

func (*Store) CountSentSince

func (s *Store) CountSentSince(profileID string, since time.Time) (int, error)

CountSentSince returns how many successful sends have happened since the given time - used to enforce a rolling daily send cap (e.g. staying under a provider's per-day sending limit).

func (*Store) DeleteAllHistory

func (s *Store) DeleteAllHistory(profileID string) (int64, error)

DeleteAllHistory removes one profile's removal_requests (Settings > Danger Zone). broker_responses is untouched; see ClearBrokerResponses.

func (*Store) DeleteByStatus

func (s *Store) DeleteByStatus(profileID string, status Status) (int64, error)

DeleteByStatus deletes all records with the given status for one profile

func (*Store) FindBrokerResponseBySubject

func (s *Store) FindBrokerResponseBySubject(profileID, brokerID, subject string) (*BrokerResponse, error)

func (*Store) GetAllBrokerResponses

func (s *Store) GetAllBrokerResponses() ([]BrokerResponse, error)

GetAllBrokerResponses retrieves all broker responses across every profile (for reclassification - a full re-scan processes the whole shared inbox regardless of which profile is active in the caller's session)

func (*Store) GetAllBrokerStatuses

func (s *Store) GetAllBrokerStatuses(profileID string) (map[string]BrokerStatus, error)

func (*Store) GetAllRequests

func (s *Store) GetAllRequests(profileID string) ([]Record, error)

GetAllRequests returns every removal request for one profile, oldest first, with pipeline_status included (unlike GetRecentRequests, which caps at a limit and omits it). Used by `eraser export` to build the evidence report.

func (*Store) GetBrokerResponseByID added in v0.6.1

func (s *Store) GetBrokerResponseByID(id int64, profileID string) (*BrokerResponse, error)

func (*Store) GetBrokerResponses

func (s *Store) GetBrokerResponses(profileID, responseType string, needsReview bool, limit int) ([]BrokerResponse, error)

GetBrokerResponses retrieves broker responses for one profile, with optional filtering

func (*Store) GetBrokerResponsesForExport

func (s *Store) GetBrokerResponsesForExport(profileID string) ([]BrokerResponse, error)

GetBrokerResponsesForExport returns one profile's responses, oldest first, including email_body. Used by `eraser export`.

func (*Store) GetBrokerStatus

func (s *Store) GetBrokerStatus(profileID, brokerID string) (BrokerStatus, error)

GetBrokerStatus is GetAllBrokerStatuses for one broker, so the web UI can refresh a single row while a send is polling.

func (*Store) GetFormStats

func (s *Store) GetFormStats(profileID string) (pending, filled, captcha, failed, skipped int, err error)

GetFormStats returns counts of forms by status for one profile

func (*Store) GetFormsWithStatus

func (s *Store) GetFormsWithStatus(profileID string) ([]FormWithStatus, error)

GetFormsWithStatus returns all detected forms with their current status for one profile.

func (*Store) GetMonthlyStats

func (s *Store) GetMonthlyStats(profileID string) (sent, failed int, err error)

func (*Store) GetPendingTaskByID

func (s *Store) GetPendingTaskByID(id int64, profileID string) (*PendingTask, error)

GetPendingTaskByID retrieves a specific pending task by its numeric ID, scoped to the given profile - a task belonging to a different profile returns nil, nil, the same as a task that doesn't exist at all.

func (*Store) GetPendingTaskStats

func (s *Store) GetPendingTaskStats(profileID string) (pending, completed, skipped int, err error)

GetPendingTaskStats returns counts of pending tasks by type and status for one profile

func (*Store) GetPendingTasks

func (s *Store) GetPendingTasks(profileID string, taskType TaskType, status string) ([]PendingTask, error)

GetPendingTasks retrieves pending tasks for one profile, with optional filtering

func (*Store) GetPipelineStats

func (s *Store) GetPipelineStats(profileID string) (map[PipelineStatus]int, error)

GetPipelineStats returns counts by pipeline status for one profile

func (*Store) GetRecentRequests

func (s *Store) GetRecentRequests(profileID string, limit int) ([]Record, error)

func (*Store) GetResponseStats

func (s *Store) GetResponseStats(profileID string) (map[string]int, error)

GetResponseStats returns counts of response types for one profile

func (*Store) GetStats

func (s *Store) GetStats(profileID string) (total, sent, failed int, err error)

func (*Store) LastSuccessfulSendTimes

func (s *Store) LastSuccessfulSendTimes(profileID string) (map[string]time.Time, error)

LastSuccessfulSendTimes returns each broker's latest successful send, in one query.

func (*Store) MarkBrokerResponseReviewed added in v0.6.1

func (s *Store) MarkBrokerResponseReviewed(id int64, profileID string) error

func (*Store) MarkFailed

func (s *Store) MarkFailed(profileID, brokerID, note string) (int64, error)

MarkFailed flips a broker's latest "sent" record to "failed" with a note. SMTP acceptance isn't delivery, and without inbox monitoring nothing fixes a later bounce; this lets the resend cooldown stop counting that broker as contacted. Returns rows updated (0 = nothing to fix).

func (*Store) MarkTaskOpened

func (s *Store) MarkTaskOpened(id int64, profileID string) error

MarkTaskOpened sets the opened_at timestamp (only if not already set), scoped to the given profile - a task belonging to a different profile is left untouched.

func (*Store) ResolveProfileForBroker

func (s *Store) ResolveProfileForBroker(brokerID string) (string, error)

ResolveProfileForBroker returns the profile that most recently emailed brokerID, so replies in a shared inbox go to the right profile rather than the active one. DefaultProfileID if none did.

func (*Store) UpdateBrokerResponseBody

func (s *Store) UpdateBrokerResponseBody(id int64, profileID string, body string) error

UpdateBrokerResponseBody updates the email body for an existing response, scoped to the given profile - a response belonging to a different profile is left untouched.

func (*Store) UpdateBrokerResponseClassification

func (s *Store) UpdateBrokerResponseClassification(id int64, profileID string, responseType string, formURL, confirmURL string, confidence float64, needsReview bool) error

UpdateBrokerResponseClassification updates the classification fields of a response, scoped to the given profile - a response belonging to a different profile is left untouched.

func (*Store) UpdatePipelineStatus

func (s *Store) UpdatePipelineStatus(profileID, brokerID string, status PipelineStatus) error

UpdatePipelineStatus sets a broker's pipeline status for one profile. For inbox replies, resolve the profile via ResolveProfileForBroker first.

type TaskType

type TaskType string

TaskType represents the type of pending task

const (
	TaskCaptcha    TaskType = "captcha"
	TaskManualForm TaskType = "manual_form"
	TaskReview     TaskType = "review"
	TaskConfirm    TaskType = "confirm"
)

Jump to

Keyboard shortcuts

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