瀏覽代碼

Added some doc

Brendan Abolivier 8 年之前
父節點
當前提交
25bd4cd295
簽署人: Brendan Abolivier <contact@brendanabolivier.com> GPG 金鑰 ID: 8EF1500759F70623
共有 1 個檔案被更改,包括 4 行新增1 行删除
  1. 4
    1
      server.js

+ 4
- 1
server.js 查看文件

@@ -74,10 +74,12 @@ app.listen(port, function() {
74 74
 // done(): Called once each mail has been sent
75 75
 function sendMails(params, update, done) {
76 76
     let mails = settings.recipients.map((recipient) => {
77
+        // Promise for each recipient to send each mail asynchronously
77 78
         return new Promise((sent) => {            
78 79
             params.to = recipient;
79
-            
80
+            // Send the email
80 81
             transporter.sendMail(params, (err, infos) => {
82
+                // Promise callback
81 83
                 sent();
82 84
                 if(err) {
83 85
                     return next(err, recipient);
@@ -86,6 +88,7 @@ function sendMails(params, update, done) {
86 88
             });
87 89
         });
88 90
     });
91
+    // Run all the promises (= send all the mails)
89 92
     Promise.all(mails).then(done);
90 93
 }
91 94