This commit is contained in:
bel
2022-02-20 17:11:16 -07:00
parent 4066d4aeb5
commit 65178b8bdf
3 changed files with 58 additions and 0 deletions

36
pttodo/action.go Normal file
View File

@@ -0,0 +1,36 @@
package pttodo
import (
"errors"
"local/sandbox/contact/contact"
"net/url"
"regexp"
)
type Action string
var (
actionEmailPattern = regexp.MustCompile(`[^@]+@.*[^\.]+\.[a-z]+`)
)
func (action Action) String() string {
return string(action)
}
func (action Action) CB() (func() error, error) {
u, _ := url.Parse(action.String())
switch u.Scheme {
case "email":
return action.email
}
if actionEmailPattern.MatchString(action.String()) {
return action.email, nil
}
return nil, errors.New("unrecognized action")
}
func (action Action) email() error {
em := contact.NewEmailer()
_ = em
return errors.New("not impl")
}