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