2019-04-24 21:52:08 +00:00
|
|
|
package notification
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"io/ioutil"
|
|
|
|
"time"
|
|
|
|
|
2019-12-24 02:14:52 +00:00
|
|
|
"github.com/authelia/authelia/internal/configuration/schema"
|
2019-04-24 21:52:08 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// FileNotifier a notifier to send emails to SMTP servers.
|
|
|
|
type FileNotifier struct {
|
|
|
|
path string
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewFileNotifier create an FileNotifier writing the notification into a file.
|
|
|
|
func NewFileNotifier(configuration schema.FileSystemNotifierConfiguration) *FileNotifier {
|
|
|
|
return &FileNotifier{
|
|
|
|
path: configuration.Filename,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Send send a identity verification link to a user.
|
2019-12-30 02:03:51 +00:00
|
|
|
func (n *FileNotifier) Send(recipient, subject, body string) error {
|
2019-04-24 21:52:08 +00:00
|
|
|
content := fmt.Sprintf("Date: %s\nRecipient: %s\nSubject: %s\nBody: %s", time.Now(), recipient, subject, body)
|
|
|
|
|
|
|
|
err := ioutil.WriteFile(n.path, []byte(content), 0755)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|