From 32d7af3621d0c5380963b563bc34d74d302422d1 Mon Sep 17 00:00:00 2001 From: Daniel Lugo Date: Wed, 14 Oct 2020 14:39:13 -0400 Subject: [PATCH] avatar now inside of profileBinary subnode, remove poll endpoint --- services/gunDB/contact-api/actions.js | 2 +- services/gunDB/contact-api/events/index.js | 2 +- services/gunDB/contact-api/key.js | 2 ++ services/gunDB/contact-api/streams/index.js | 2 +- src/routes.js | 23 --------------------- 5 files changed, 5 insertions(+), 26 deletions(-) diff --git a/services/gunDB/contact-api/actions.js b/services/gunDB/contact-api/actions.js index 18b59f21..9308303e 100644 --- a/services/gunDB/contact-api/actions.js +++ b/services/gunDB/contact-api/actions.js @@ -815,7 +815,7 @@ const setAvatar = (avatar, user) => } user - .get(Key.PROFILE) + .get(Key.PROFILE_BINARY) .get(Key.AVATAR) .put(avatar, ack => { if (ack.err && typeof ack.err !== 'number') { diff --git a/services/gunDB/contact-api/events/index.js b/services/gunDB/contact-api/events/index.js index 24f66a0b..5f7de532 100644 --- a/services/gunDB/contact-api/events/index.js +++ b/services/gunDB/contact-api/events/index.js @@ -114,7 +114,7 @@ const onAvatar = (cb, user) => { if (!avatarSubbed) { avatarSubbed = true user - .get(Key.PROFILE) + .get(Key.PROFILE_BINARY) .get(Key.AVATAR) .on(avatar => { if (typeof avatar === 'string' || avatar === null) { diff --git a/services/gunDB/contact-api/key.js b/services/gunDB/contact-api/key.js index 5bc5ad04..58d43fba 100644 --- a/services/gunDB/contact-api/key.js +++ b/services/gunDB/contact-api/key.js @@ -60,3 +60,5 @@ exports.POSTS = 'posts' exports.TOTAL_TIPS = 'totalTips' exports.TIPS_PAYMENT_STATUS = 'tipsPaymentStatus' + +exports.PROFILE_BINARY = 'profileBinary' diff --git a/services/gunDB/contact-api/streams/index.js b/services/gunDB/contact-api/streams/index.js index d4fab683..0b211bcd 100644 --- a/services/gunDB/contact-api/streams/index.js +++ b/services/gunDB/contact-api/streams/index.js @@ -34,7 +34,7 @@ const onAvatar = (cb, pub) => { require('../../Mediator') .getGun() .user(pub) - .get(Key.PROFILE) + .get(Key.PROFILE_BINARY) .get(Key.AVATAR) .on(av => { if (typeof av === 'string' || av === null) { diff --git a/src/routes.js b/src/routes.js index 57211dc1..1d56f0eb 100644 --- a/src/routes.js +++ b/src/routes.js @@ -2107,29 +2107,6 @@ module.exports = async ( } }) - app.get(`/api/gun/${GunEvent.ON_AVATAR}`, async (_, res) => { - try { - const user = require('../services/gunDB/Mediator').getUser() - const data = await timeout5( - user - .get(Key.PROFILE) - .get(Key.AVATAR) - .then() - ) - res.json({ - data - }) - } catch (err) { - logger.info('Error in Avatar poll:') - logger.error(err) - res - .status(err.message === Common.Constants.ErrorCode.NOT_AUTH ? 401 : 500) - .json({ - errorMessage: typeof err === 'string' ? err : err.message - }) - } - }) - app.get(`/api/gun/${GunEvent.ON_DISPLAY_NAME}`, async (_, res) => { try { const user = require('../services/gunDB/Mediator').getUser()