mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-01-11 10:38:11 +08:00
[n1] fix(api): Add support for messages?thread_id=1
This commit is contained in:
parent
42e20f106c
commit
dd28d6b146
1 changed files with 6 additions and 0 deletions
|
@ -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));
|
||||
|
|
Loading…
Reference in a new issue