diff --git a/Network/botProfile.js b/Network/botProfile.js index 643571170..baa427101 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,14 +64,17 @@ exports.newUserProfile = function newUserProfile() { let post = NT.modules.POST.newPost() post.initialize( + emitterUserProfileId, + targetUserProfileId, + emitterBotProfileId, + targetBotProfileId, emitterPostHash, targetPostHash, postType, - botProfile, timestamp ) - thisObject.maps.POSTS.push(post) + thisObject.posts.push(post) NT.memory.maps.POSTS.set(emitterPostHash, post) thisObject.postsCount++ } diff --git a/Network/event.js b/Network/event.js index 7cddc9c22..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 || @@ -128,9 +144,51 @@ exports.newEvent = function newEvent() { thisObject.eventType - 10, thisObject.timestamp ) + 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 + ) { + emitterBotProfile.addPost( + thisObject.emitterUserProfileId, + thisObject.targetUserProfileId, + thisObject.emitterBotProfileId, + thisObject.targetBotProfileId, + thisObject.emitterPostHash, + thisObject.targetPostHash, + thisObject.eventType - 20, + thisObject.timestamp + ) + 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 } - - return } /* Is is a following? diff --git a/Network/userProfile.js b/Network/userProfile.js index a7d308cf6..50766821f 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,11 +77,10 @@ exports.newUserProfile = function newUserProfile() { emitterPostHash, targetPostHash, postType, - userProfile, timestamp ) - thisObject.maps.POSTS.push(post) + thisObject.posts.push(post) NT.memory.maps.POSTS.set(emitterPostHash, post) thisObject.postsCount++ }