From 0be94e7e0020ccc53c93ec2afc2b8e92943d9b92 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 28 Aug 2021 09:50:28 +0200 Subject: [PATCH 1/3] addPost at botProfile fixed --- Network/botProfile.js | 10 ++++++++-- Network/event.js | 26 +++++++++++++++++++++++++- Network/userProfile.js | 2 -- 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/Network/botProfile.js b/Network/botProfile.js index 643571170..d53f060b8 100644 --- a/Network/botProfile.js +++ b/Network/botProfile.js @@ -49,10 +49,13 @@ exports.newUserProfile = function newUserProfile() { } function addPost( + emitterUserProfileId, + targetUserProfileId, + emitterBotProfileId, + targetBotProfileId, emitterPostHash, targetPostHash, postType, - botProfile, timestamp ) { if (NT.memory.maps.POSTS.get(emitterPostHash) !== undefined) { @@ -61,10 +64,13 @@ exports.newUserProfile = function newUserProfile() { let post = NT.modules.POST.newPost() post.initialize( + emitterUserProfileId, + targetUserProfileId, + emitterBotProfileId, + targetBotProfileId, emitterPostHash, targetPostHash, postType, - botProfile, timestamp ) diff --git a/Network/event.js b/Network/event.js index 7cddc9c22..2793244a9 100644 --- a/Network/event.js +++ b/Network/event.js @@ -128,9 +128,33 @@ exports.newEvent = function newEvent() { thisObject.eventType - 10, thisObject.timestamp ) + return } + if ( + thisObject.eventType === EVENT_TYPES.NEW_BOT_POST || + thisObject.eventType === EVENT_TYPES.REPLY_TO_BOT_POST || + thisObject.eventType === EVENT_TYPES.REPOST_BOT_POST || + thisObject.eventType === EVENT_TYPES.QUOTE_REPOST_BOT_POST + ) { + let botProfile = emitterUserProfile.bots.get(emitterBotProfileId) + if ( + botProfile === undefined + ) { + throw ('Emitter BOt Profile Not Found.') + } - return + botProfile.addPost( + thisObject.emitterUserProfileId, + thisObject.targetUserProfileId, + thisObject.emitterBotProfileId, + thisObject.targetBotProfileId, + thisObject.emitterPostHash, + thisObject.targetPostHash, + thisObject.eventType - 20, + thisObject.timestamp + ) + return + } } /* Is is a following? diff --git a/Network/userProfile.js b/Network/userProfile.js index a7d308cf6..161aaa801 100644 --- a/Network/userProfile.js +++ b/Network/userProfile.js @@ -62,7 +62,6 @@ exports.newUserProfile = function newUserProfile() { emitterPostHash, targetPostHash, postType, - userProfile, timestamp ) { if (NT.memory.maps.POSTS.get(emitterPostHash) !== undefined) { @@ -78,7 +77,6 @@ exports.newUserProfile = function newUserProfile() { emitterPostHash, targetPostHash, postType, - userProfile, timestamp ) From b7eeb0e549d4fba394ba3f73b13d90449534156f Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 28 Aug 2021 10:01:36 +0200 Subject: [PATCH 2/3] Supporting Post Removal --- Network/event.js | 60 +++++++++++++++++++++++++++++++++++++----------- 1 file changed, 47 insertions(+), 13 deletions(-) diff --git a/Network/event.js b/Network/event.js index 2793244a9..ba63b45bc 100644 --- a/Network/event.js +++ b/Network/event.js @@ -22,15 +22,17 @@ exports.newEvent = function newEvent() { REPLY_TO_USER_POST: 11, REPOST_USER_POST: 12, QUOTE_REPOST_USER_POST: 13, - FOLLOW_USER_PROFILE: 14, - UNFOLLOW_USER_PROFILE: 15, + REMOVE_USER_POST: 14, + FOLLOW_USER_PROFILE: 15, + UNFOLLOW_USER_PROFILE: 16, NEW_BOT_POST: 20, REPLY_TO_BOT_POST: 21, REPOST_BOT_POST: 22, QUOTE_REPOST_BOT_POST: 23, - FOLLOW_BOT_PROFILE: 24, - UNFOLLOW_BOT_PROFILE: 25, + REMOVE_BOT_POST: 24, + FOLLOW_BOT_PROFILE: 25, + UNFOLLOW_BOT_PROFILE: 26, ADD_BOT: 50, REMOVE_BOT: 51, @@ -100,7 +102,18 @@ exports.newEvent = function newEvent() { targetUserProfile.targetEventsCount++ } /* - Is is a new post? + Validate Emitter Bot Profile. + */ + if (emitterBotProfileId !== undefined) { + let botProfile = emitterUserProfile.bots.get(emitterBotProfileId) + if ( + emitterBotProfile === undefined + ) { + throw ('Emitter BOt Profile Not Found.') + } + } + /* + Is is related to Posting? */ if ( thisObject.eventType === EVENT_TYPES.NEW_USER_POST || @@ -112,6 +125,9 @@ exports.newEvent = function newEvent() { thisObject.eventType === EVENT_TYPES.REPOST_BOT_POST || thisObject.eventType === EVENT_TYPES.QUOTE_REPOST_BOT_POST ) { + /* + New User Post + */ if ( thisObject.eventType === EVENT_TYPES.NEW_USER_POST || thisObject.eventType === EVENT_TYPES.REPLY_TO_USER_POST || @@ -130,20 +146,16 @@ exports.newEvent = function newEvent() { ) return } + /* + New Bot Post + */ if ( thisObject.eventType === EVENT_TYPES.NEW_BOT_POST || thisObject.eventType === EVENT_TYPES.REPLY_TO_BOT_POST || thisObject.eventType === EVENT_TYPES.REPOST_BOT_POST || thisObject.eventType === EVENT_TYPES.QUOTE_REPOST_BOT_POST ) { - let botProfile = emitterUserProfile.bots.get(emitterBotProfileId) - if ( - botProfile === undefined - ) { - throw ('Emitter BOt Profile Not Found.') - } - - botProfile.addPost( + emitterBotProfile.addPost( thisObject.emitterUserProfileId, thisObject.targetUserProfileId, thisObject.emitterBotProfileId, @@ -155,6 +167,28 @@ exports.newEvent = function newEvent() { ) return } + /* + Remove User Post + */ + if ( + thisObject.eventType === EVENT_TYPES.REMOVE_USER_POST + ) { + emitterUserProfile.removePost( + thisObject.emitterPostHash + ) + return + } + /* + Remove Bot Post + */ + if ( + thisObject.eventType === EVENT_TYPES.REMOVE_USER_POST + ) { + emitterBotProfile.removePost( + thisObject.emitterPostHash + ) + return + } } /* Is is a following? From a1e790c7bbfe40c544fd8146e473730f00fc021d Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 28 Aug 2021 10:11:01 +0200 Subject: [PATCH 3/3] Bug Fixes --- Network/botProfile.js | 2 +- Network/userProfile.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Network/botProfile.js b/Network/botProfile.js index d53f060b8..baa427101 100644 --- a/Network/botProfile.js +++ b/Network/botProfile.js @@ -74,7 +74,7 @@ exports.newUserProfile = function newUserProfile() { timestamp ) - thisObject.maps.POSTS.push(post) + thisObject.posts.push(post) NT.memory.maps.POSTS.set(emitterPostHash, post) thisObject.postsCount++ } diff --git a/Network/userProfile.js b/Network/userProfile.js index 161aaa801..50766821f 100644 --- a/Network/userProfile.js +++ b/Network/userProfile.js @@ -80,7 +80,7 @@ exports.newUserProfile = function newUserProfile() { timestamp ) - thisObject.maps.POSTS.push(post) + thisObject.posts.push(post) NT.memory.maps.POSTS.set(emitterPostHash, post) thisObject.postsCount++ }