diff options
| author | HumairAK <humair88@hotmail.com> | 2016-08-26 07:30:05 +0000 |
|---|---|---|
| committer | HumairAK <humair88@hotmail.com> | 2016-08-26 07:30:05 +0000 |
| commit | 7deb83c56e680769ccc72527d719dbc411c20469 (patch) | |
| tree | 31946e8abebba07528432632ef6b853506e288fc /node_simple.js | |
| parent | b1b2a1b16961d75fe92cac2d829fab829e4cf060 (diff) | |
added mail receiver function, need to add script client side to fill inbox for user profile
Diffstat (limited to 'node_simple.js')
| -rw-r--r-- | node_simple.js | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/node_simple.js b/node_simple.js index 360125e..7ff70c6 100644 --- a/node_simple.js +++ b/node_simple.js @@ -1365,3 +1365,30 @@ exports.removeToken = function(token, callback) { }); }; + + +/** + * Check if the user with the given username has mail. + * If the user does, then send the mail that falls within the specified page range. + * + * @param {object} username object + * @param {function} callback of the form (<boolean1>, <boolean2>, <array of objects>, <string>) + * - callback(error, success, mail, message) + * */ +exports.getMail = function (username, callback) { + + var mail = db.collection('mail'); + + mail.find({receiver: username}).toArray(function (err, data) { + if (err) { + callback(false, true, null, 'Error: could not retrieve inbox messages.'); + } else if (!data) { + callback(false, false, null, 'No inbox.'); + } else { + // Mail retrieved + callback(true, false, data, 'Retrieved inbox'); + } + + }); + +}; |
