Documentation
¶
Index ¶
- Constants
- func UserBrokersPath() string
- type Broker
- type BrokerDatabase
- func Load(overridePath string) (*BrokerDatabase, error)
- func LoadFromFile(path string) (*BrokerDatabase, error)
- func LoadList(overridePath, configPath, listName string) (*BrokerDatabase, error)
- func Parse(raw []byte) (*BrokerDatabase, error)
- func Validate(raw []byte, minCount int) (*BrokerDatabase, error)
- func (db *BrokerDatabase) Add(broker Broker) error
- func (db *BrokerDatabase) Filter(regions []string, excluded []string, excludedCategories []string) []Broker
- func (db *BrokerDatabase) FindByEmail(email string) *Broker
- func (db *BrokerDatabase) FindByID(id string) *Broker
- func (db *BrokerDatabase) MarkEmailUnreachable(email, reason string) *Broker
- func (db *BrokerDatabase) RemoveByEmail(email string) *Broker
- func (db *BrokerDatabase) RemoveByID(id string) *Broker
- func (db *BrokerDatabase) Save(path string) error
- func (db *BrokerDatabase) SaveWithBackup(path string) error
- func (db *BrokerDatabase) Select(ids, regions, categories, excluded, excludedCategories []string) []Broker
- func (db *BrokerDatabase) UnknownIDs(ids []string) []string
Constants ¶
const MinSaneBrokerCount = 200
MinSaneBrokerCount is the floor below which the main broker database is assumed to be truncated or corrupt rather than legitimately small. Used both by `update-brokers` (before replacing the local copy) and by Validate.
const MinVerifiedBrokerCount = 20
MinVerifiedBrokerCount is the equivalent floor for the hand-built, registry-sourced verified list (data/brokers-verified.yaml), which is deliberately a fraction of the size of the main list.
Variables ¶
This section is empty.
Functions ¶
func UserBrokersPath ¶
func UserBrokersPath() string
UserBrokersPath is where `eraser update-brokers` writes a refreshed copy of the list; Load() prefers it over the embedded default when it exists.
Types ¶
type Broker ¶
type Broker struct {
ID string `yaml:"id"`
Name string `yaml:"name"`
Email string `yaml:"email"`
Website string `yaml:"website,omitempty"`
OptOutURL string `yaml:"opt_out_url,omitempty"`
Region string `yaml:"region"` // "us", "eu", "global"
Category string `yaml:"category,omitempty"` // "people-search", "marketing", "background-check", etc.
Notes string `yaml:"notes,omitempty"`
}
type BrokerDatabase ¶
type BrokerDatabase struct {
Brokers []Broker `yaml:"brokers"`
}
func Load ¶
func Load(overridePath string) (*BrokerDatabase, error)
Load resolves the broker database from, in order: overridePath (the --brokers flag) when set, then ~/.eraser/brokers.yaml when it exists, then the copy embedded in the binary. There is no implicit ./data or <exe-dir>/data scanning any more.
func LoadFromFile ¶
func LoadFromFile(path string) (*BrokerDatabase, error)
LoadFromFile parses a broker YAML file from an explicit path.
func LoadList ¶ added in v0.7.0
func LoadList(overridePath, configPath, listName string) (*BrokerDatabase, error)
LoadList resolves the broker database for the send-family commands, which can point at a custom file or switch to the smaller verified list. Order:
- overridePath (--brokers flag), when set
- configPath (options.broker_file), when set
- the embedded verified list, when listName == "verified"
- otherwise the normal Load() resolution (~/.eraser/brokers.yaml, then the embedded main list)
Commands that should always act on the full list (audit, guides, update-brokers, reply processing) keep calling Load directly.
func Parse ¶
func Parse(raw []byte) (*BrokerDatabase, error)
Parse unmarshals and sanitizes a broker YAML document. Used to validate a freshly downloaded list before it replaces the local copy.
func Validate ¶
func Validate(raw []byte, minCount int) (*BrokerDatabase, error)
Validate parses raw broker YAML and checks structural invariants: sane entry count (at least minCount), required id/name, unique ids, known regions, plausible emails, well-formed http(s) URLs. Unlike Parse it doesn't sanitize, so a malformed URL is reported rather than silently blanked. One error lists every problem (CI runs this against data/brokers.yaml); the parsed db is returned so callers skip a second unmarshal.
func (*BrokerDatabase) Add ¶
func (db *BrokerDatabase) Add(broker Broker) error
func (*BrokerDatabase) Filter ¶
func (db *BrokerDatabase) Filter(regions []string, excluded []string, excludedCategories []string) []Broker
Filter returns brokers matching the given regions (empty means "all"), excluding any broker whose ID/name is in excluded or whose category (case-insensitive) is in excludedCategories - e.g. "requires-id" to skip brokers that demand a government ID document before acting on a request.
func (*BrokerDatabase) FindByEmail ¶
func (db *BrokerDatabase) FindByEmail(email string) *Broker
FindByEmail finds a broker by their email address
func (*BrokerDatabase) FindByID ¶
func (db *BrokerDatabase) FindByID(id string) *Broker
func (*BrokerDatabase) MarkEmailUnreachable ¶
func (db *BrokerDatabase) MarkEmailUnreachable(email, reason string) *Broker
MarkEmailUnreachable finds a broker by their current email address and clears it, recording the old address and the reason in Notes, instead of removing the broker entirely. A bounced email usually means the company changed its privacy-request address, not that it stopped existing - deleting the whole record (name, category, website, opt-out URL) on a bounce throws away everything needed to give it a working address later. Returns the mutated broker, or nil if no broker has that email.
func (*BrokerDatabase) RemoveByEmail ¶
func (db *BrokerDatabase) RemoveByEmail(email string) *Broker
RemoveByEmail removes a broker by their email address Returns the removed broker, or nil if not found
func (*BrokerDatabase) RemoveByID ¶
func (db *BrokerDatabase) RemoveByID(id string) *Broker
RemoveByID removes a broker by their ID Returns the removed broker, or nil if not found
func (*BrokerDatabase) Save ¶
func (db *BrokerDatabase) Save(path string) error
func (*BrokerDatabase) SaveWithBackup ¶
func (db *BrokerDatabase) SaveWithBackup(path string) error
SaveWithBackup saves the database to file, creating a backup first
func (*BrokerDatabase) Select ¶ added in v0.7.0
func (db *BrokerDatabase) Select(ids, regions, categories, excluded, excludedCategories []string) []Broker
func (*BrokerDatabase) UnknownIDs ¶ added in v0.7.0
func (db *BrokerDatabase) UnknownIDs(ids []string) []string