From dd28d6b146ed7e4677058ed5858b4029a0c7292d Mon Sep 17 00:00:00 2001 From: Ben Gotow Date: Wed, 23 Nov 2016 16:25:45 -0800 Subject: [PATCH] [n1] fix(api): Add support for messages?thread_id=1 --- packages/local-sync/src/local-api/routes/messages.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/local-sync/src/local-api/routes/messages.js b/packages/local-sync/src/local-api/routes/messages.js index 5524c4320..b4ce55a26 100644 --- a/packages/local-sync/src/local-api/routes/messages.js +++ b/packages/local-sync/src/local-api/routes/messages.js @@ -13,6 +13,7 @@ module.exports = (server) => { tags: ['messages'], validate: { query: { + thread_id: Joi.string(), limit: Joi.number().integer().min(1).max(2000).default(100), offset: Joi.number().integer().min(0).default(0), }, @@ -26,9 +27,14 @@ module.exports = (server) => { handler: (request, reply) => { request.getAccountDatabase().then((db) => { const {Message, Folder, Label} = db; + const wheres = {}; + if (request.query.thread_id) { + wheres.threadId = request.query.thread_id; + } Message.findAll({ limit: request.query.limit, offset: request.query.offset, + where: wheres, include: [{model: Folder}, {model: Label}], }).then((messages) => { reply(Serialization.jsonStringify(messages));