diff --git a/lib/api/addresses.js b/lib/api/addresses.js index d2bc569e..14c58262 100644 --- a/lib/api/addresses.js +++ b/lib/api/addresses.js @@ -203,7 +203,7 @@ module.exports = (db, server) => { if (pageNext) { opts.next = pageNext; - } else if (page > 1 && pagePrevious) { + } else if ((!page || page > 1) && pagePrevious) { opts.previous = pagePrevious; } diff --git a/lib/api/auth.js b/lib/api/auth.js index 17898706..90d01606 100644 --- a/lib/api/auth.js +++ b/lib/api/auth.js @@ -365,7 +365,7 @@ module.exports = (db, server, userHandler) => { if (pageNext) { opts.next = pageNext; - } else if (page > 1 && pagePrevious) { + } else if ((!page || page > 1) && pagePrevious) { opts.previous = pagePrevious; } diff --git a/lib/api/dkim.js b/lib/api/dkim.js index 1c109618..3b38771c 100644 --- a/lib/api/dkim.js +++ b/lib/api/dkim.js @@ -155,7 +155,7 @@ module.exports = (db, server) => { if (pageNext) { opts.next = pageNext; - } else if (page > 1 && pagePrevious) { + } else if ((!page || page > 1) && pagePrevious) { opts.previous = pagePrevious; } diff --git a/lib/api/domainaliases.js b/lib/api/domainaliases.js index 3e88a19c..cabb03bc 100644 --- a/lib/api/domainaliases.js +++ b/lib/api/domainaliases.js @@ -151,7 +151,7 @@ module.exports = (db, server) => { if (pageNext) { opts.next = pageNext; - } else if (page > 1 && pagePrevious) { + } else if ((!page || page > 1) && pagePrevious) { opts.previous = pagePrevious; } diff --git a/lib/api/messages.js b/lib/api/messages.js index 2ae58a75..735c8004 100644 --- a/lib/api/messages.js +++ b/lib/api/messages.js @@ -467,7 +467,7 @@ module.exports = (db, server, messageHandler) => { if (pageNext) { opts.next = pageNext; - } else if (page > 1 && pagePrevious) { + } else if ((!page || page > 1) && pagePrevious) { opts.previous = pagePrevious; } @@ -920,7 +920,7 @@ module.exports = (db, server, messageHandler) => { if (pageNext) { opts.next = pageNext; - } else if (page > 1 && pagePrevious) { + } else if ((!page || page > 1) && pagePrevious) { opts.previous = pagePrevious; } @@ -2692,7 +2692,7 @@ module.exports = (db, server, messageHandler) => { if (pageNext) { opts.next = pageNext; - } else if (page > 1 && pagePrevious) { + } else if ((!page || page > 1) && pagePrevious) { opts.previous = pagePrevious; } diff --git a/lib/message-handler.js b/lib/message-handler.js index f20a5b1a..27bcc456 100644 --- a/lib/message-handler.js +++ b/lib/message-handler.js @@ -432,7 +432,7 @@ class MessageHandler { let queryOpts = {}; if (options.skipExisting) { // no need to load extra data when we only need to know the basics - queryOpts.fields = { + queryOpts.projection = { _id: true, uid: true, outbound: true,