Merge pull request #477 from shocknet/feature/split-create

init as a separate route
This commit is contained in:
CapDog 2021-09-19 13:46:13 -04:00 committed by GitHub
commit 48d116e8fc
4 changed files with 47 additions and 11 deletions

View file

@ -0,0 +1,17 @@
version: "3.8"
networks:
default:
external: true
name: 2_default
services:
web:
image: shockwallet/api:latest
command: -c -h 0.0.0.0 -l polar-n2-alice:10009 -m /root/.lnd/data/chain/bitcoin/regtest/admin.macaroon -d /root/.lnd/tls.cert
restart: on-failure
stop_grace_period: 1m
ports:
- 9835:9835
volumes:
- C:\Users\boufn\.polar\networks\2\volumes\lnd\alice:/root/.lnd
environment:
TRUSTED_KEYS: 'false'

View file

@ -518,17 +518,7 @@ const register = async (alias, pass) => {
// don't work
instantiateGun()
return authenticate(alias, pass).then(async pub => {
await API.Actions.setDisplayName('anon' + pub.slice(0, 8), user)
await API.Actions.generateHandshakeAddress()
await API.Actions.generateOrderAddress(user)
await API.Actions.initWall()
await API.Actions.setBio('A little bit about myself.', user)
await API.Actions.setDefaultSeedProvider('', user)
await API.Actions.setSeedServiceData('', user)
await API.Actions.setCurrentStreamInfo('', user)
return pub
})
return authenticate(alias, pass)
}
module.exports = {

12
services/initializer.js Normal file
View file

@ -0,0 +1,12 @@
const API = require('./gunDB/contact-api')
module.exports.InitUserData = async (user) => {
await API.Actions.setDisplayName('anon' + user._.sea.pub.slice(0, 8), user)
await API.Actions.generateHandshakeAddress()
await API.Actions.generateOrderAddress(user)
await API.Actions.initWall()
await API.Actions.setBio('A little bit about myself.', user)
await API.Actions.setDefaultSeedProvider('', user)
await API.Actions.setSeedServiceData('', user)
await API.Actions.setCurrentStreamInfo('', user)
}

View file

@ -38,6 +38,7 @@ const Key = require('../services/gunDB/contact-api/key')
const { startedStream, endStream } = require('../services/streams')
const channelRequest = require('../utils/lightningServices/channelRequests')
const TipsForwarder = require('../services/tipsCallback')
const UserInitializer = require('../services/initializer')
const DEFAULT_MAX_NUM_ROUTES_TO_QUERY = 10
const SESSION_ID = uuid()
@ -2826,6 +2827,22 @@ module.exports = async (
})
}
})
ap.post('/api/initUserInformation', async (req, res) => {
try {
const user = require('../services/gunDB/Mediator').getUser()
await UserInitializer.InitUserData(user)
} catch (err) {
logger.error(err)
res
.status(
err.message === Common.Constants.ErrorCode.NOT_AUTH ? 401 : 500
)
.json({
errorMessage: err.message
})
}
})
} catch (err) {
logger.warn('Unhandled rejection:', err)
}