2016-06-29 09:14:39 +08:00
|
|
|
const Serialization = require('./serialization');
|
2016-06-29 06:35:35 +08:00
|
|
|
const {PubsubConnector, MessageTypes} = require('nylas-core')
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
createSyncbackRequest: function createSyncbackRequest(request, reply, syncRequestArgs) {
|
|
|
|
request.getAccountDatabase().then((db) => {
|
|
|
|
db.SyncbackRequest.create(syncRequestArgs).then((syncbackRequest) => {
|
|
|
|
PubsubConnector.notify({
|
|
|
|
accountId: db.accountId,
|
|
|
|
type: MessageTypes.SYNCBACK_REQUESTED,
|
|
|
|
data: syncbackRequest.id,
|
|
|
|
});
|
|
|
|
reply(Serialization.jsonStringify(syncbackRequest))
|
|
|
|
})
|
|
|
|
})
|
2016-06-29 09:43:53 +08:00
|
|
|
},
|
2016-06-29 06:35:35 +08:00
|
|
|
}
|