diff options
| author | nanalelfe <nargiza.nosirova@mail.utoronto.ca> | 2016-08-26 23:21:52 +0000 |
|---|---|---|
| committer | nanalelfe <nargiza.nosirova@mail.utoronto.ca> | 2016-08-26 23:21:52 +0000 |
| commit | d94aad5042d2fd09242581f11415de4a978168be (patch) | |
| tree | 2e950a1b6c4a7e739b0f3df3ba2eaeb2464316c2 /node_simple.js | |
| parent | 81e415a89b17ddf9b57347de799022808507f41b (diff) | |
| parent | 17a4b5f57e0223b211ab8ff601e587920e6e1bef (diff) | |
Merge branch 'master' of https://github.com/HumairAK/solutions_repo
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'); + } + + }); + +}; |
