fix up crypto services

This commit is contained in:
Josh Harvey 2016-12-09 00:10:18 +02:00
parent e24da06a1b
commit 1b89ed5c76
9 changed files with 82 additions and 46 deletions

View file

@ -5,6 +5,8 @@ const db = require('./db')
let settingsCache
function load (versionId) {
if (!versionId) throw new Error('versionId is required')
return Promise.all([loadConfig(versionId), loadAccounts()])
.then(([config, accounts]) => ({
config,
@ -23,7 +25,7 @@ function loadLatest (versionId) {
function loadConfig (versionId) {
const sql = `select data
from user_config
where versionId=$1 and type=$2`
where id=$1 and type=$2`
return db.oneOrNone(sql, [versionId, 'config'])
.then(row => row ? row.data.config : [])
@ -33,7 +35,7 @@ function loadLatestConfig () {
const sql = `select data
from user_config
where type=$1
order by versionId desc
order by id desc
limit 1`
return db.oneOrNone(sql, ['config'])