Commit 6b11b54a authored by ale's avatar ale

only send out update email if there are recipients

parent de330d65
......@@ -47,8 +47,12 @@ func NewSsbm(rootDir string) *Ssbm {
func (s *Ssbm) Init(email string, keyId string, selfKey io.Reader) error {
os.Mkdir(s.rootDir, 0700)
os.Mkdir(s.updatesDir, 0700)
s.config.Set("self_email", email)
s.config.Set("self_key_id", keyId)
if err := s.config.Set("self_email", email); err != nil {
log.Printf("error setting config: %s", err)
}
if err := s.config.Set("self_key_id", keyId); err != nil {
log.Printf("error setting config: %s", err)
}
return s.gpg.Init(keyId, selfKey)
}
......@@ -126,14 +130,17 @@ func (s *Ssbm) Save() error {
}
}
msg, err := s.gpg.EncryptAndSign(data, recipientKeys)
if err != nil {
return err
}
// Encrypt and sign the outgoing update emails (but only if the
// recipient list is not empty).
if len(recipientKeys) > 0 {
msg, err := s.gpg.EncryptAndSign(data, recipientKeys)
if err != nil {
return err
}
// Send out the update emails.
if err := s.mailer.SendMail(selfEmail, recipientEmails, msg); err != nil {
return err
if err := s.mailer.SendMail(selfEmail, recipientEmails, msg); err != nil {
return err
}
}
return nil
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment