1234567891011121314151617181920212223242526272829303132333435 |
- {-# LANGUAGE OverloadedStrings #-}
- module Data.SMTP.Types.Address where
- import qualified Data.SMTP.Account as Ac
- import qualified Data.SMTP.URI as URI
- import qualified Data.SMTP.Seal as Seal
- import Text.StringConvert
- data Address = AccountAdd Ac.Account (Maybe Seal.Seal)
- | URIAdd URI.URI (Maybe Seal.Seal)
- deriving (Show, Eq, Ord)
- asToURI :: Address -> String
- asToURI (AccountAdd a _) = concat ["<", s . Ac.normalize $ a, ">"]
- asToURI (URIAdd u _) = URI.fullURI u
- hostFrom :: Address -> Ac.HostName
- hostFrom = Ac.domain . account
- fromAccount :: Ac.Account -> Address
- fromAccount a = AccountAdd a Nothing
- account :: Address -> Ac.Account
- account (AccountAdd a _) = a
- account (URIAdd u _) = URI.account u
- seal :: Address -> Maybe Seal.Seal
- seal (AccountAdd _ se) = se
- seal (URIAdd _ se) = se
- setSeal :: Address -> Maybe Seal.Seal -> Address
- setSeal (AccountAdd a _) se = AccountAdd a se
- setSeal (URIAdd u _) se = URIAdd u se
|