mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-11-08 07:21:18 +08:00
A few changes to support linking to K2 via the new GUI
This commit is contained in:
parent
f9f78968b1
commit
e10e51ab5d
10 changed files with 39 additions and 8 deletions
|
|
@ -2,6 +2,36 @@ const Serialization = require('../serialization');
|
|||
const {DatabaseConnector} = require('nylas-core');
|
||||
|
||||
module.exports = (server) => {
|
||||
if (process.env.ALLOW_LIST_ACCOUNTS) {
|
||||
server.route({
|
||||
method: 'GET',
|
||||
path: '/accounts',
|
||||
config: {
|
||||
auth: false,
|
||||
description: 'Returns all accounts, only in dev mode. Only intended to easily link N1.',
|
||||
tags: ['accounts'],
|
||||
},
|
||||
handler: (request, reply) => {
|
||||
DatabaseConnector.forShared().then((db) => {
|
||||
const {Account, AccountToken} = db;
|
||||
|
||||
// N1 assumes that the local sync engine uses the account IDs as the
|
||||
// auth tokens. K2 supports real auth tokens out of the box, but we
|
||||
// create ones that have value = accountId.
|
||||
Account.all().then((accounts) => {
|
||||
Promise.all(
|
||||
accounts.map(({id}) => AccountToken.create({accountId: id, value: id})
|
||||
)).finally(() =>
|
||||
reply(accounts.map((account) =>
|
||||
Object.assign(account.toJSON(), {id: `${account.id}`, auth_token: `${account.id}`})
|
||||
))
|
||||
)
|
||||
});
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
server.route({
|
||||
method: 'GET',
|
||||
path: '/account',
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ module.exports = (sequelize, Sequelize) => {
|
|||
instanceMethods: {
|
||||
toJSON: function toJSON() {
|
||||
return {
|
||||
id: this.id,
|
||||
id: `${this.id}`,
|
||||
account_id: this.accountId,
|
||||
object: 'contact',
|
||||
email: this.email,
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ module.exports = (sequelize, Sequelize) => {
|
|||
},
|
||||
toJSON: function toJSON() {
|
||||
return {
|
||||
id: this.id,
|
||||
id: `${this.id}`,
|
||||
object: 'file',
|
||||
account_id: this.accountId,
|
||||
message_id: this.messageId,
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ module.exports = (sequelize, Sequelize) => {
|
|||
instanceMethods: {
|
||||
toJSON: function toJSON() {
|
||||
return {
|
||||
id: this.id,
|
||||
id: `${this.id}`,
|
||||
account_id: this.accountId,
|
||||
object: 'folder',
|
||||
name: this.role,
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ module.exports = (sequelize, Sequelize) => {
|
|||
instanceMethods: {
|
||||
toJSON: function toJSON() {
|
||||
return {
|
||||
id: this.id,
|
||||
id: `${this.id}`,
|
||||
account_id: this.accountId,
|
||||
object: 'label',
|
||||
name: this.role,
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ module.exports = (sequelize, Sequelize) => {
|
|||
// Message though and need to protect `this.date` from null
|
||||
// errors.
|
||||
return {
|
||||
id: this.id,
|
||||
id: `${this.id}`,
|
||||
account_id: this.accountId,
|
||||
object: 'message',
|
||||
body: this.body,
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ module.exports = (sequelize, Sequelize) => {
|
|||
instanceMethods: {
|
||||
toJSON: function toJSON() {
|
||||
return {
|
||||
id: this.id,
|
||||
id: `${this.id}`,
|
||||
type: this.type,
|
||||
status: this.status,
|
||||
error: this.error,
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ module.exports = (sequelize, Sequelize) => {
|
|||
}
|
||||
|
||||
const response = {
|
||||
id: this.id,
|
||||
id: `${this.id}`,
|
||||
object: 'thread',
|
||||
folders: this.folders,
|
||||
labels: this.labels,
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ module.exports = (sequelize, Sequelize) => {
|
|||
instanceMethods: {
|
||||
toJSON: function toJSON() {
|
||||
return {
|
||||
id: this.id,
|
||||
id: `${this.id}`,
|
||||
event: this.event,
|
||||
object: this.object,
|
||||
objectId: this.objectId,
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ apps:
|
|||
name : api
|
||||
env :
|
||||
PORT: 5100
|
||||
ALLOW_LIST_ACCOUNTS : true
|
||||
DB_ENCRYPTION_ALGORITHM : "aes-256-ctr"
|
||||
DB_ENCRYPTION_PASSWORD : "d6F3Efeq"
|
||||
GMAIL_CLIENT_ID : "271342407743-nibas08fua1itr1utq9qjladbkv3esdm.apps.googleusercontent.com"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue