From dba49aa67d9d0c7cd936a38081e115482ef4a1ee Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 26 Aug 2021 16:54:05 +0200 Subject: [PATCH] Profile Handle --- Network/NetwokNode.js | 13 +++++++------ Network/ProfileStatsQuery.js | 10 +++++++--- Network/clientsInterface.js | 2 ++ Network/event.js | 4 ++-- Network/userProfile.js | 2 +- 5 files changed, 19 insertions(+), 12 deletions(-) diff --git a/Network/NetwokNode.js b/Network/NetwokNode.js index f7ed65049..4bb49d8da 100644 --- a/Network/NetwokNode.js +++ b/Network/NetwokNode.js @@ -2,12 +2,13 @@ global.NT = { memory: { - USER_PROFILES: new Map(), // Here we will store the user profiles and their statistics. - POSTS: new Map(), // This are all the posts we are keeping track of. - EVENTS: new Map(), // This is the registry of all events received that prevents processing them more than once. - TIMELINE: [], // A time ordered list of Posts and Trades. - NETWORK_CLIENTS: [], // These are the Network Clients connected to this Network Node. - NETWORK_PEERS: [], // These are the Network Peers connected to this Network Node. + USER_PROFILES_BY_ID: new Map(), // Here we will store the user profiles by User Profile Id. + USER_PROFILES_BY_HANDLE: new Map(), // Here we will store the user profiles by User Profile Handle. + POSTS: new Map(), // This are all the posts we are keeping track of. + EVENTS: new Map(), // This is the registry of all events received that prevents processing them more than once. + TIMELINE: [], // A time ordered list of Posts and Trades. + NETWORK_CLIENTS: [], // These are the Network Clients connected to this Network Node. + NETWORK_PEERS: [], // These are the Network Peers connected to this Network Node. }, modules: { USER_PROFILE: require('./UserProfile.js'), diff --git a/Network/ProfileStatsQuery.js b/Network/ProfileStatsQuery.js index 459cb7179..2de22735e 100644 --- a/Network/ProfileStatsQuery.js +++ b/Network/ProfileStatsQuery.js @@ -15,8 +15,12 @@ exports.newProfileStatsQuery = function newProfileStatsQuery() { function initialize(queryReceived) { - thisObject.profile = NT.memory.PROFILES.get(queryReceived.targetUserProfileId) - + if (queryReceived.targetUserProfileId !== undefined) { + thisObject.profile = NT.memory.USER_PROFILES_BY_ID.get(queryReceived.targetUserProfileId) + } else { + thisObject.profile = NT.memory.USER_PROFILES_BY_ID.get(queryReceived.targetUserProfileHandle) + } + if (thisObject.profile === undefined) { throw ('Target User Profile Not Found.') } @@ -27,7 +31,7 @@ exports.newProfileStatsQuery = function newProfileStatsQuery() { return { "userProfieId": thisObject.profile.userProfieId, - "githubUsername": thisObject.profile.githubUsername, + "userHandle": thisObject.profile.userHandle, "blockchainAccount": thisObject.profile.blockchainAccount, "ranking": thisObject.profile.ranking, "multiMediaPostFollowingCount": thisObject.profile.multiMediaPostFollowingCount, diff --git a/Network/clientsInterface.js b/Network/clientsInterface.js index d5d222802..4f25230c6 100644 --- a/Network/clientsInterface.js +++ b/Network/clientsInterface.js @@ -54,6 +54,8 @@ exports.newClientInterface = function newClientInterface() { "queryType": 10, "emitterUserProfileId": "a8de78f0-c3e4-4a2a-b7e8-f659073969db", "targetUserProfileId": "a8de78f0-c3e4-4a2a-b7e8-f659073969db", + "emitterUserProfileHandle": "Luis-Fernando-Molina", + "targetUserProfileHandle": "Luis-Fernando-Molina", "emitterPostHash": "a8de78f0-c3e4-4a2a-b7e8-f659073969db", "targetPostHash": "a8de78f0-c3e4-4a2a-b7e8-f659073969db", "timestamp": 124234234234, diff --git a/Network/event.js b/Network/event.js index 4e4785d39..50988a5c7 100644 --- a/Network/event.js +++ b/Network/event.js @@ -58,13 +58,13 @@ exports.newEvent = function newEvent() { function initialize(eventReceived) { - thisObject.emitterUserProfile = NT.memory.USER_PROFILES.get(eventReceived.emitterUserProfileId) + thisObject.emitterUserProfile = NT.memory.USER_PROFILES_BY_ID.get(eventReceived.emitterUserProfileId) if (thisObject.emitterUserProfile === undefined) { throw ('Emitter User Profile Not Found.') } thisObject.emitterUserProfile.emitterEventsCount++ - thisObject.targetUserProfile = NT.memory.USER_PROFILES.get(eventReceived.targetUserProfileId) + thisObject.targetUserProfile = NT.memory.USER_PROFILES_BY_ID.get(eventReceived.targetUserProfileId) if (thisObject.targetUserProfile === undefined) { /* We thow an exception when it does not have a target user profile and is required*/ if ( diff --git a/Network/userProfile.js b/Network/userProfile.js index ec935aabf..ab4a3fe50 100644 --- a/Network/userProfile.js +++ b/Network/userProfile.js @@ -2,7 +2,7 @@ exports.newUserProfile = function newUserProfile() { let thisObject = { userProfieId: undefined, - githubUsername: undefined, + userHandle: undefined, blockchainAccount: undefined, multiMediaPostsFollowing: undefined, multiMediaPostsFollowers: undefined,