paid-types.go raw

   1  package database
   2  
   3  import "time"
   4  
   5  // PaidSubscription represents an active paid subscription.
   6  type PaidSubscription struct {
   7  	PubkeyHex   string    `json:"pubkey"`
   8  	Alias       string    `json:"alias,omitempty"`
   9  	ExpiresAt   time.Time `json:"expires_at"`
  10  	CreatedAt   time.Time `json:"created_at"`
  11  	InvoiceHash string    `json:"invoice_hash,omitempty"`
  12  }
  13  
  14  // IsActive returns true if the subscription has not expired.
  15  func (s *PaidSubscription) IsActive() bool {
  16  	return time.Now().Before(s.ExpiresAt)
  17  }
  18  
  19  // AliasClaim represents a claimed email alias.
  20  type AliasClaim struct {
  21  	Alias     string    `json:"alias"`
  22  	PubkeyHex string    `json:"pubkey"`
  23  	ClaimedAt time.Time `json:"claimed_at"`
  24  }
  25  
  26  // ErrAliasTaken is returned when attempting to claim an alias already taken by another pubkey.
  27  var ErrAliasTaken = &aliasTakenError{}
  28  
  29  type aliasTakenError struct{}
  30  
  31  func (e *aliasTakenError) Error() string { return "alias is already taken" }
  32