package db

func (d *DB) CountSendersForDomain(domainID int64) (int, error) {
	var n int
	err := d.QueryRow(`SELECT COUNT(*) FROM esrv_senders WHERE domain_id = ?`, domainID).Scan(&n)
	return n, err
}

func (d *DB) HasActiveDKIMForDomain(domainID int64) (bool, error) {
	var n int
	err := d.QueryRow(`SELECT COUNT(*) FROM esrv_dkim_keys WHERE domain_id = ? AND is_active = 1`, domainID).Scan(&n)
	return n > 0, err
}

func (d *DB) HasAnyDKIMForDomain(domainID int64) (bool, error) {
	var n int
	err := d.QueryRow(`SELECT COUNT(*) FROM esrv_dkim_keys WHERE domain_id = ?`, domainID).Scan(&n)
	return n > 0, err
}
