Documentation
¶
Index ¶
- Constants
- func DBPathFor(configPath string) string
- func DefaultDBPath() string
- type BrokerResponse
- type BrokerStatus
- type FormWithStatus
- type PendingTask
- type PipelineStatus
- type Record
- type Status
- type Store
- func (s *Store) Add(record *Record) error
- func (s *Store) AddBrokerResponse(resp *BrokerResponse) error
- func (s *Store) AddPendingTask(task *PendingTask) error
- func (s *Store) ClearBrokerResponses() error
- func (s *Store) Close() error
- func (s *Store) CompletePendingTask(id int64, profileID string, status string) error
- func (s *Store) CountSentSince(profileID string, since time.Time) (int, error)
- func (s *Store) DeleteAllHistory(profileID string) (int64, error)
- func (s *Store) DeleteByStatus(profileID string, status Status) (int64, error)
- func (s *Store) FindBrokerResponseBySubject(profileID, brokerID, subject string) (*BrokerResponse, error)
- func (s *Store) GetAllBrokerResponses() ([]BrokerResponse, error)
- func (s *Store) GetAllBrokerStatuses(profileID string) (map[string]BrokerStatus, error)
- func (s *Store) GetAllRequests(profileID string) ([]Record, error)
- func (s *Store) GetBrokerResponses(profileID, responseType string, needsReview bool, limit int) ([]BrokerResponse, error)
- func (s *Store) GetBrokerResponsesForExport(profileID string) ([]BrokerResponse, error)
- func (s *Store) GetBrokerStatus(profileID, brokerID string) (BrokerStatus, error)
- func (s *Store) GetFormStats(profileID string) (pending, filled, captcha, failed, skipped int, err error)
- func (s *Store) GetFormsWithStatus(profileID string) ([]FormWithStatus, error)
- func (s *Store) GetMonthlyStats(profileID string) (sent, failed int, err error)
- func (s *Store) GetPendingTaskByID(id int64, profileID string) (*PendingTask, error)
- func (s *Store) GetPendingTaskStats(profileID string) (pending, completed, skipped int, err error)
- func (s *Store) GetPendingTasks(profileID string, taskType TaskType, status string) ([]PendingTask, error)
- func (s *Store) GetPipelineStats(profileID string) (map[PipelineStatus]int, error)
- func (s *Store) GetRecentRequests(profileID string, limit int) ([]Record, error)
- func (s *Store) GetResponseStats(profileID string) (map[string]int, error)
- func (s *Store) GetStats(profileID string) (total, sent, failed int, err error)
- func (s *Store) LastSuccessfulSendTimes(profileID string) (map[string]time.Time, error)
- func (s *Store) MarkFailed(profileID, brokerID, note string) (int64, error)
- func (s *Store) MarkTaskOpened(id int64, profileID string) error
- func (s *Store) ResolveProfileForBroker(brokerID string) (string, error)
- func (s *Store) UpdateBrokerResponseBody(id int64, profileID string, body string) error
- func (s *Store) UpdateBrokerResponseClassification(id int64, profileID string, responseType string, formURL, confirmURL string, ...) error
- func (s *Store) UpdatePipelineStatus(profileID, brokerID string, status PipelineStatus) error
- type TaskType
Constants ¶
const DefaultProfileID = "default"
DefaultProfileID mirrors config.DefaultProfileID (history can't import config - that would create an import cycle, since config has no dependency on history and should stay that way). Every row written before multi-profile support existed is attributed to this ID by the migration below, and it's what a single-profile config's requests are stamped with.
Variables ¶
This section is empty.
Functions ¶
func DBPathFor ¶
DBPathFor returns the history database path to use alongside a given config file: history.db in the same directory as configPath, rather than always the default ~/.eraser/history.db. Every command already accepts --config to point at an alternate config file, but used to still read/ write the one shared default history.db regardless - this makes an alternate --config imply an isolated data directory too, the way a user pointing --config at a scratch file would expect. Falls back to DefaultDBPath() when configPath is empty (matches DefaultConfigPath's own fallback path, so behavior for the normal default-config case is unchanged).
func DefaultDBPath ¶
func DefaultDBPath() string
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 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 Store ¶
type Store struct {
// contains filtered or unexported fields
}
func (*Store) AddBrokerResponse ¶
func (s *Store) AddBrokerResponse(resp *BrokerResponse) error
AddBrokerResponse stores a classified response from a broker
func (*Store) AddPendingTask ¶
func (s *Store) AddPendingTask(task *PendingTask) error
AddPendingTask creates a new pending task for human intervention
func (*Store) ClearBrokerResponses ¶
ClearBrokerResponses removes all broker responses (for full re-scan)
func (*Store) CompletePendingTask ¶
CompletePendingTask marks a task as completed, scoped to the given profile - a task belonging to a different profile is left untouched.
func (*Store) CountSentSince ¶
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 ¶
DeleteAllHistory removes every send-history record for one profile, regardless of status. Used by the web UI's Settings > Danger Zone > "Clear All History" action. This only touches removal_requests (what brokers you've emailed and when) - broker_responses (inbox-classified replies) is a separate table and is untouched; see ClearBrokerResponses for that.
func (*Store) DeleteByStatus ¶
DeleteByStatus deletes all records with the given status for one profile
func (*Store) FindBrokerResponseBySubject ¶
func (s *Store) FindBrokerResponseBySubject(profileID, brokerID, subject string) (*BrokerResponse, error)
FindBrokerResponseBySubject finds an existing response by profile, broker_id and email_subject
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 ¶
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) 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 every classified response for one profile, oldest first, with the raw email_body included (GetBrokerResponses omits it; GetAllBrokerResponses includes it but is not profile-scoped). Used by `eraser export`.
func (*Store) GetBrokerStatus ¶
func (s *Store) GetBrokerStatus(profileID, brokerID string) (BrokerStatus, error)
GetBrokerStatus returns one broker's status - the single-broker-scoped equivalent of GetAllBrokerStatuses, used by the web UI to refresh just one row (see handleAPIBrokerStatus) instead of re-running the GROUP-BY-plus-correlated-subquery query over every broker on every poll tick during an active send.
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 (*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 ¶
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 (*Store) GetResponseStats ¶
GetResponseStats returns counts of response types for one profile
func (*Store) LastSuccessfulSendTimes ¶
LastSuccessfulSendTimes returns, for every broker with at least one successful send, the timestamp of its most recent one - in a single query, so callers filtering a large broker list against a resend cooldown don't need one query per broker.
func (*Store) MarkFailed ¶
MarkFailed flips a broker's most recent "sent" record over to "failed", recording the given note in its error field. This exists because a normal SMTP send only tells you the message was handed off, not that it actually arrived - Add() records StatusSent as soon as the provider accepts it, and a bounce shows up later as a separate, asynchronous email. Without inbox monitoring enabled, nothing corrects that record automatically. Once a bounce has been confirmed by hand (or a broker's contact info has been fixed and it should be retried), this is what removes the false "sent" so LastSuccessfulSendTimes() - and therefore the resend cooldown in `send` - stops treating the broker as already contacted. Returns the number of rows updated: 0 means there was no "sent" record for that broker to fix (e.g. it was never sent, or was already marked failed).
func (*Store) MarkTaskOpened ¶
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 ¶
ResolveProfileForBroker returns the profile_id of the most recent removal_request sent to brokerID, regardless of which profile sent it. Used when processing inbox replies: the shared IMAP inbox (config.Inbox is one mailbox for the whole install, not per-profile) carries replies for every profile's requests together, so a reply has to be attributed to whichever profile actually emailed that broker rather than to whatever profile happens to be "active" in the CLI/web session doing the monitoring. Falls back to DefaultProfileID if the broker was never emailed by any profile (e.g. a reply arrived before send()'s history write, or the history was cleared).
func (*Store) UpdateBrokerResponseBody ¶
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 updates the pipeline status for a broker within one profile. Callers processing inbox replies (which can be for any profile) should resolve profileID via ResolveProfileForBroker first rather than assuming whatever profile happens to be active in their own session.