Merge branch 'master' into feat/feed

This commit is contained in:
Daniel Lugo 2020-06-27 20:47:00 -04:00
commit f8ce6589f2

View file

@ -12,6 +12,8 @@ require('gun/lib/load')
const debounce = require('lodash/debounce') const debounce = require('lodash/debounce')
const Encryption = require('../../../utils/encryptionStore') const Encryption = require('../../../utils/encryptionStore')
const Key = require('../contact-api/key')
/** @type {import('../contact-api/SimpleGUN').ISEA} */ /** @type {import('../contact-api/SimpleGUN').ISEA} */
// @ts-ignore // @ts-ignore
const SEAx = require('gun/sea') const SEAx = require('gun/sea')
@ -267,6 +269,21 @@ const authenticate = async (alias, pass, __user) => {
if (typeof ack.err === 'string') { if (typeof ack.err === 'string') {
throw new Error(ack.err) throw new Error(ack.err)
} else if (typeof ack.sea === 'object') { } else if (typeof ack.sea === 'object') {
await new Promise((res, rej) => {
_user.get(Key.FOLLOWS).put(
{
unused: null
},
ack => {
if (ack.err) {
rej(new Error(`Error initializing follows: ${ack.err}`))
} else {
res()
}
}
)
})
return ack.sea.pub return ack.sea.pub
} else { } else {
throw new Error('Unknown error.') throw new Error('Unknown error.')
@ -279,6 +296,22 @@ const authenticate = async (alias, pass, __user) => {
`Tried to re-authenticate with an alias different to that of stored one, tried: ${alias} - stored: ${_currentAlias}, logoff first if need to change aliases.` `Tried to re-authenticate with an alias different to that of stored one, tried: ${alias} - stored: ${_currentAlias}, logoff first if need to change aliases.`
) )
} }
await new Promise((res, rej) => {
_user.get(Key.FOLLOWS).put(
{
unused: null
},
ack => {
if (ack.err) {
rej(new Error(`Error initializing follows: ${ack.err}`))
} else {
res()
}
}
)
})
// move this to a subscription; implement off() ? todo // move this to a subscription; implement off() ? todo
API.Jobs.onAcceptedRequests(_user, mySEA) API.Jobs.onAcceptedRequests(_user, mySEA)
API.Jobs.onOrders(_user, gun, mySEA) API.Jobs.onOrders(_user, gun, mySEA)
@ -312,6 +345,21 @@ const authenticate = async (alias, pass, __user) => {
await new Promise(res => setTimeout(res, 5000)) await new Promise(res => setTimeout(res, 5000))
await new Promise((res, rej) => {
_user.get(Key.FOLLOWS).put(
{
unused: null
},
ack => {
if (ack.err) {
rej(new Error(`Error initializing follows: ${ack.err}`))
} else {
res()
}
}
)
})
API.Jobs.onAcceptedRequests(_user, mySEA) API.Jobs.onAcceptedRequests(_user, mySEA)
API.Jobs.onOrders(_user, gun, mySEA) API.Jobs.onOrders(_user, gun, mySEA)
API.Jobs.lastSeenNode(_user) API.Jobs.lastSeenNode(_user)