handshake address regen through HTTP

This commit is contained in:
Daniel Lugo 2020-07-24 12:43:16 -04:00
parent b7ad45f1d5
commit 89b1263e80

View file

@ -1920,8 +1920,13 @@ module.exports = async (
* @type {RequestHandler<{}>}
*/
const apiGunMePut = async (req, res) => {
/**
* @typedef {Omit<Common.Schema.User, 'publicKey'>} UserWithoutPK
* @typedef {{ handshakeAddress: boolean }} HasHandshakeAddress
* @typedef {UserWithoutPK & HasHandshakeAddress} MePutBody
*/
try {
const { avatar, bio , displayName} = /** @type {Partial<Omit<Common.Schema.User, 'publicKey'>>} */ (req.body)
const { avatar, bio , displayName, handshakeAddress } = /** @type {Partial<MePutBody>} */ (req.body)
if (avatar) {
await GunActions.setAvatar(avatar, require('../services/gunDB/Mediator').getUser())
@ -1935,6 +1940,10 @@ module.exports = async (
await GunActions.setDisplayName(displayName, require('../services/gunDB/Mediator').getUser())
}
if (handshakeAddress) {
await GunActions.generateHandshakeAddress();
}
return res.status(200).json({
ok: true
})