mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-09-09 22:24:27 +08:00
Merge branch 'master' of ssh://github.com/nylas/k2
This commit is contained in:
commit
1996666516
8 changed files with 63 additions and 57 deletions
|
@ -4,7 +4,6 @@
|
|||
"description": "k2",
|
||||
"main": "",
|
||||
"dependencies": {
|
||||
"bluebird": "3.x.x",
|
||||
"bunyan": "1.8.0",
|
||||
"bunyan-cloudwatch": "2.0.0",
|
||||
"bunyan-loggly": "^1.0.0",
|
||||
|
|
|
@ -10,21 +10,6 @@ module.exports = (server) => {
|
|||
server.route({
|
||||
method: 'POST',
|
||||
path: '/send',
|
||||
config: {
|
||||
validate: {
|
||||
payload: {
|
||||
subject: Joi.string(),
|
||||
reply_to_message_id: Joi.number().integer(),
|
||||
from: Joi.array(),
|
||||
reply_to: Joi.array(),
|
||||
to: Joi.array(),
|
||||
cc: Joi.array(),
|
||||
bcc: Joi.array(),
|
||||
body: Joi.string(),
|
||||
file_ids: Joi.array(),
|
||||
},
|
||||
},
|
||||
},
|
||||
handler: (request, reply) => { DatabaseConnector.forShared().then((db) => {
|
||||
const accountId = request.auth.credentials.id;
|
||||
db.Account.findById(accountId).then((account) => {
|
||||
|
|
|
@ -184,16 +184,15 @@ module.exports = (server) => {
|
|||
},
|
||||
handler: (request, reply) => {
|
||||
const payload = request.payload
|
||||
if (payload.folder_id) {
|
||||
if (payload.folder_id || payload.folder) {
|
||||
createSyncbackRequest(request, reply, {
|
||||
type: "MoveToFolder",
|
||||
props: {
|
||||
folderId: request.payload.folder_id,
|
||||
folderId: request.payload.folder_id || request.payload.folder,
|
||||
threadId: request.params.id,
|
||||
},
|
||||
})
|
||||
}
|
||||
if (payload.unread === false) {
|
||||
} else if (payload.unread === false) {
|
||||
createSyncbackRequest(request, reply, {
|
||||
type: "MarkThreadAsRead",
|
||||
props: {
|
||||
|
@ -207,8 +206,7 @@ module.exports = (server) => {
|
|||
threadId: request.params.id,
|
||||
},
|
||||
})
|
||||
}
|
||||
if (payload.starred === false) {
|
||||
} else if (payload.starred === false) {
|
||||
createSyncbackRequest(request, reply, {
|
||||
type: "UnstarThread",
|
||||
props: {
|
||||
|
@ -222,6 +220,8 @@ module.exports = (server) => {
|
|||
threadId: request.params.id,
|
||||
},
|
||||
})
|
||||
} else {
|
||||
reply("Invalid thread update").code(400)
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
|
@ -10,5 +10,17 @@ module.exports = (sequelize, Sequelize) => {
|
|||
},
|
||||
error: JSONType('error'),
|
||||
props: JSONType('props'),
|
||||
}, {
|
||||
instanceMethods: {
|
||||
toJSON: function toJSON() {
|
||||
return {
|
||||
id: this.id,
|
||||
type: this.type,
|
||||
status: this.status,
|
||||
error: this.error,
|
||||
props: this.props,
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
|
@ -239,6 +239,12 @@ pre {
|
|||
font-size: 12px;
|
||||
}
|
||||
|
||||
.sum-accounts {
|
||||
border-top: solid black 1px;
|
||||
margin-top: 5px;
|
||||
padding-top: 5px;
|
||||
}
|
||||
|
||||
.account-filter {
|
||||
padding-left: 5px;
|
||||
}
|
||||
|
|
|
@ -1,30 +1,33 @@
|
|||
const React = window.React;
|
||||
|
||||
class ProcessLoads extends React.Component {
|
||||
|
||||
render() {
|
||||
let entries;
|
||||
if (this.props.counts == null || Object.keys(this.props.counts).length === 0) {
|
||||
entries = "No Data"
|
||||
function ProcessLoads(props) {
|
||||
let entries;
|
||||
let sumElem;
|
||||
if (props.counts == null || Object.keys(props.counts).length === 0) {
|
||||
entries = "No Data";
|
||||
sumElem = "";
|
||||
} else {
|
||||
entries = [];
|
||||
let sum = 0;
|
||||
for (const processName of Object.keys(props.counts)) {
|
||||
const count = props.counts[processName];
|
||||
sum += count;
|
||||
entries.push(
|
||||
<div className="load-count">
|
||||
<b>{processName}</b>: {count} accounts
|
||||
</div>
|
||||
);
|
||||
}
|
||||
else {
|
||||
entries = [];
|
||||
for (const processName of Object.keys(this.props.counts).sort()) {
|
||||
entries.push(
|
||||
<div className="load-count">
|
||||
<b>{processName}</b>: {this.props.counts[processName]} accounts
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="process-loads">
|
||||
<div className="section">Process Loads </div>
|
||||
{entries}
|
||||
</div>
|
||||
)
|
||||
sumElem = <div className="sum-accounts">Total Accounts: {sum} </div>
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="process-loads">
|
||||
<div className="section">Process Loads </div>
|
||||
{entries}
|
||||
{sumElem}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
ProcessLoads.propTypes = {
|
||||
|
|
|
@ -5,6 +5,7 @@ const {
|
|||
DatabaseConnector,
|
||||
MessageTypes,
|
||||
Errors,
|
||||
PromiseUtils,
|
||||
} = require('nylas-core');
|
||||
const {
|
||||
jsonError,
|
||||
|
@ -137,9 +138,9 @@ class SyncWorker {
|
|||
|
||||
syncbackMessageActions() {
|
||||
const where = {where: {status: "NEW"}, limit: 100};
|
||||
return this._db.SyncbackRequest.findAll(where)
|
||||
.map((req) => SyncbackTaskFactory.create(this._account, req))
|
||||
.each(this.runSyncbackTask.bind(this))
|
||||
return PromiseUtils.each((this._db.SyncbackRequest.findAll(where)
|
||||
.map((req) => SyncbackTaskFactory.create(this._account, req))),
|
||||
this.runSyncbackTask.bind(this))
|
||||
}
|
||||
|
||||
runSyncbackTask(task) {
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
const _ = require('underscore')
|
||||
const {PromiseUtils} = require('nylas-core')
|
||||
|
||||
const TaskHelpers = {
|
||||
messagesForThreadByFolder: function messagesForThreadByFolder(db, threadId) {
|
||||
return db.Thread.findById(threadId).then((thread) => {
|
||||
return Promise.resolve(db.Thread.findById(threadId).then((thread) => {
|
||||
return thread.getMessages()
|
||||
}).then((messages) => {
|
||||
})).then((messages) => {
|
||||
return _.groupBy(messages, "folderId")
|
||||
})
|
||||
},
|
||||
|
@ -13,25 +14,24 @@ const TaskHelpers = {
|
|||
return TaskHelpers.messagesForThreadByFolder(db, threadId)
|
||||
.then((msgsInCategories) => {
|
||||
const cids = Object.keys(msgsInCategories);
|
||||
return db.Folder.findAll({where: {id: cids}})
|
||||
.each((category) =>
|
||||
imap.openBox(category.name, {readOnly: false}).then((box) => {
|
||||
return Promise.all(msgsInCategories[category.id].map((message) =>
|
||||
return PromiseUtils.each(db.Folder.findAll({where: {id: cids}}), (category) =>
|
||||
imap.openBox(category.name, {readOnly: false}).then((box) =>
|
||||
Promise.all(msgsInCategories[category.id].map((message) =>
|
||||
callback({message, category, box})
|
||||
)).then(() => box.closeBox())
|
||||
})
|
||||
)
|
||||
)
|
||||
})
|
||||
},
|
||||
|
||||
openMessageBox: function openMessageBox({messageId, db, imap}) {
|
||||
return db.Message.findById(messageId).then((message) => {
|
||||
return Promise.resolve(db.Message.findById(messageId).then((message) => {
|
||||
return db.Folder.findById(message.folderId).then((category) => {
|
||||
return imap.openBox(category.name).then((box) => {
|
||||
return Promise.resolve({box, message})
|
||||
})
|
||||
})
|
||||
})
|
||||
}))
|
||||
},
|
||||
}
|
||||
module.exports = TaskHelpers
|
||||
|
|
Loading…
Add table
Reference in a new issue