fix and test email parsing, add mock matrix
This commit is contained in:
@@ -2,11 +2,13 @@ package message
|
||||
|
||||
import (
|
||||
"local/truckstop/config"
|
||||
"log"
|
||||
|
||||
"github.com/matrix-org/gomatrix"
|
||||
)
|
||||
|
||||
type Matrix struct {
|
||||
mock bool
|
||||
homeserver string
|
||||
username string
|
||||
token string
|
||||
@@ -20,6 +22,7 @@ func NewMatrix() Matrix {
|
||||
username: conf.Username,
|
||||
token: conf.Token,
|
||||
room: conf.Room,
|
||||
mock: conf.Mock,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +31,10 @@ func (m Matrix) client() (*gomatrix.Client, error) {
|
||||
}
|
||||
|
||||
func (m Matrix) Send(text string) error {
|
||||
if m.mock {
|
||||
log.Printf("matrix.Send(%s)", text)
|
||||
return nil
|
||||
}
|
||||
c, err := m.client()
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user