fix and test email parsing, add mock matrix

This commit is contained in:
Bel LaPointe
2022-01-11 00:02:00 -05:00
parent ec2b514a9f
commit 392578bb54
6 changed files with 72 additions and 13 deletions

View File

@@ -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