wip
This commit is contained in:
36
pttodo/action.go
Normal file
36
pttodo/action.go
Normal 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")
|
||||
}
|
||||
Reference in New Issue
Block a user