From 7277c932fea3e031aa4c1dafb2602ee537a5d5b4 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 27 Aug 2021 19:42:05 +0200 Subject: [PATCH 1/3] User Profile Cleaned from Multi Media Posts concept --- Network/NetwokNode.js | 2 +- Network/Queries/Events.js | 12 ++-- Network/Queries/ProfileStats.js | 6 +- Network/{bot.js => botProfile.js} | 1 + Network/event.js | 8 +-- Network/userProfile.js | 111 ++++++++---------------------- 6 files changed, 44 insertions(+), 96 deletions(-) rename Network/{bot.js => botProfile.js} (93%) diff --git a/Network/NetwokNode.js b/Network/NetwokNode.js index c2b1b55a5..fa5c8f701 100644 --- a/Network/NetwokNode.js +++ b/Network/NetwokNode.js @@ -16,9 +16,9 @@ global.NT = { }, modules: { USER_PROFILE: require('./UserProfile.js'), + BOT: require('./BotProfile.js'), EVENT: require('./Event.js'), POST: require('./Post.js'), - BOT: require('./Bot.js'), QUERY: require('./Query.js'), QUERY_PROFILE_STATS: require('./Queries/ProfileStats.js'), QUERY_PROFILE_POSTS: require('./Queries/ProfilePosts.js'), diff --git a/Network/Queries/Events.js b/Network/Queries/Events.js index fb401ea2f..bb84a4de8 100644 --- a/Network/Queries/Events.js +++ b/Network/Queries/Events.js @@ -145,13 +145,13 @@ exports.newEvents = function newEvents() { Test #2 : The Emitter or Traget profile must be at the Following map of the Query Profile. */ if (emitterUserProfile !== undefined) { - if (thisObject.profile.multiMediaPostsFollowing.get(emitterUserProfile.userProfieId) !== undefined) { + if (thisObject.profile.following.get(emitterUserProfile.userProfieId) !== undefined) { addToResponse(event) return } } if (targetUserProfile !== undefined) { - if (thisObject.profile.multiMediaPostsFollowing.get(targetUserProfile.userProfieId) !== undefined) { + if (thisObject.profile.following.get(targetUserProfile.userProfieId) !== undefined) { addToResponse(event) return } @@ -160,25 +160,25 @@ exports.newEvents = function newEvents() { Test #3 : The Emmiter or Target post must be belong to any profile at the Following of the Query Profile. */ if (emitterPost !== undefined) { - if (thisObject.profile.multiMediaPostsFollowing.get(emitterPost.emitterUserProfileId) !== undefined) { + if (thisObject.profile.following.get(emitterPost.emitterUserProfileId) !== undefined) { addToResponse(event) return } } if (emitterPost !== undefined) { - if (thisObject.profile.multiMediaPostsFollowing.get(emitterPost.targetUserProfileId) !== undefined) { + if (thisObject.profile.following.get(emitterPost.targetUserProfileId) !== undefined) { addToResponse(event) return } } if (targetPost !== undefined) { - if (thisObject.profile.multiMediaPostsFollowing.get(targetPost.emitterUserProfileId) !== undefined) { + if (thisObject.profile.following.get(targetPost.emitterUserProfileId) !== undefined) { addToResponse(event) return } } if (targetPost !== undefined) { - if (thisObject.profile.multiMediaPostsFollowing.get(targetPost.targetUserProfileId) !== undefined) { + if (thisObject.profile.following.get(targetPost.targetUserProfileId) !== undefined) { addToResponse(event) return } diff --git a/Network/Queries/ProfileStats.js b/Network/Queries/ProfileStats.js index 350ed48f4..56de88255 100644 --- a/Network/Queries/ProfileStats.js +++ b/Network/Queries/ProfileStats.js @@ -36,10 +36,8 @@ exports.newProfileStats = function newProfileStats() { "userProfileHandle": thisObject.profile.userProfileHandle, "blockchainAccount": thisObject.profile.blockchainAccount, "ranking": thisObject.profile.ranking, - "multiMediaPostFollowingCount": thisObject.profile.multiMediaPostFollowingCount, - "multiMediaPostFollowersCount": thisObject.profile.multiMediaPostFollowersCount, - "tradePostsFollowingCount": thisObject.profile.tradePostsFollowingCount, - "tradePostsFollowersCount": thisObject.profile.tradePostsFollowersCount, + "followingCount": thisObject.profile.followingCount, + "followersCount": thisObject.profile.followersCount, "emitterEventsCount": thisObject.profile.emitterEventsCount, "targetEventsCount": thisObject.profile.targetEventsCount, "postsCount": thisObject.profile.postsCount, diff --git a/Network/bot.js b/Network/botProfile.js similarity index 93% rename from Network/bot.js rename to Network/botProfile.js index b6ad63f2b..a1c1b80c7 100644 --- a/Network/bot.js +++ b/Network/botProfile.js @@ -2,6 +2,7 @@ exports.newBot = function newBot() { let thisObject = { botId: undefined, + botProfileHandle: undefined, botAsset: undefined, botExchange: undefined, enabled: undefined, diff --git a/Network/event.js b/Network/event.js index e69fd9ead..ea61143ba 100644 --- a/Network/event.js +++ b/Network/event.js @@ -137,19 +137,19 @@ exports.newEvent = function newEvent() { ) { switch (thisObject.eventType) { case EVENT_TYPES.FOLLOW_USER_PROFILE_MULTI_MEDIA_POSTS: { - emitterUserProfile.addMultiMediaPostsFollowing( + emitterUserProfile.addFollowing( targetUserProfile ) - targetUserProfile.addMultiMediaPostsFollower( + targetUserProfile.addFollower( emitterUserProfile ) break } case EVENT_TYPES.UNFOLLOW_USER_PROFILE_MULTI_MEDIA_POSTS: { - emitterUserProfile.removeMultiMediaPostsFollowing( + emitterUserProfile.removeFollowing( targetUserProfile ) - targetUserProfile.removeMultiMediaPostsFollower( + targetUserProfile.removeFollower( emitterUserProfile ) break diff --git a/Network/userProfile.js b/Network/userProfile.js index 500b713bb..cc0f8a315 100644 --- a/Network/userProfile.js +++ b/Network/userProfile.js @@ -4,15 +4,11 @@ exports.newUserProfile = function newUserProfile() { userProfieId: undefined, userProfileHandle: undefined, blockchainAccount: undefined, - multiMediaPostsFollowing: undefined, - multiMediaPostsFollowers: undefined, - tradePostsFollowing: undefined, - tradePostsFollowers: undefined, ranking: undefined, - multiMediaPostFollowingCount: undefined, - multiMediaPostFollowersCount: undefined, - tradePostsFollowingCount: undefined, - tradePostsFollowersCount: undefined, + following: undefined, + followers: undefined, + followingCount: undefined, + followersCount: undefined, emitterEventsCount: undefined, targetEventsCount: undefined, postsCount: undefined, @@ -21,14 +17,10 @@ exports.newUserProfile = function newUserProfile() { posts: undefined, addPost: addPost, removePost: removePost, - addMultiMediaPostsFollowing: addMultiMediaPostsFollowing, - removeMultiMediaPostsFollowing: removeMultiMediaPostsFollowing, - addTradePostsFollowing: addTradePostsFollowing, - removeTradePostsFollowing: removeTradePostsFollowing, - addMultiMediaPostsFollower: addMultiMediaPostsFollower, - removeMultiMediaPostsFollower: removeMultiMediaPostsFollower, - addTradePostsFollower: addTradePostsFollower, - removeTradePostsFollower: removeTradePostsFollower, + addFollowing: addFollowing, + removeFollowing: removeFollowing, + addFollower: addFollower, + removeFollower: removeFollower, addBot: addBot, removeBot: removeBot, enableBot: enableBot, @@ -40,11 +32,8 @@ exports.newUserProfile = function newUserProfile() { return thisObject function finalize() { - thisObject.multiMediaPostsFollowing = undefined - thisObject.multiMediaPostsFollowers = undefined - - thisObject.tradePostsFollowing = undefined - thisObject.tradePostsFollowers = undefined + thisObject.following = undefined + thisObject.followers = undefined thisObject.posts = undefined thisObject.bots = undefined @@ -52,16 +41,12 @@ exports.newUserProfile = function newUserProfile() { function initialize() { - thisObject.multiMediaPostsFollowing = new Map() - thisObject.multiMediaPostsFollowers = new Map() + thisObject.following = new Map() + thisObject.followers = new Map() - thisObject.tradePostsFollowing = new Map() - thisObject.tradePostsFollowers = new Map() + thisObject.followingCount = 0 + thisObject.followersCount = 0 - thisObject.multiMediaPostFollowingCount = 0 - thisObject.multiMediaPostFollowersCount = 0 - thisObject.tradePostsFollowingCount = 0 - thisObject.tradePostsFollowersCount = 0 thisObject.emitterEventsCount = 0 thisObject.targetEventsCount = 0 thisObject.postsCount = 0 @@ -116,75 +101,39 @@ exports.newUserProfile = function newUserProfile() { thisObject.postsCount-- } - function addMultiMediaPostsFollowing( + function addFollowing( userProfile ) { - if (thisObject.multiMediaPostsFollowing.get(userProfile.id) === undefined) { - thisObject.multiMediaPostsFollowing.set(userProfile.id, userProfile) - thisObject.multiMediaPostFollowingCount++ + if (thisObject.following.get(userProfile.id) === undefined) { + thisObject.following.set(userProfile.id, userProfile) + thisObject.followingCount++ } } - function removeMultiMediaPostsFollowing( + function removeFollowing( userProfile ) { - if (thisObject.multiMediaPostsFollowing.get(userProfile.id) !== undefined) { - thisObject.multiMediaPostsFollowing.delete(userProfile.id) - thisObject.multiMediaPostFollowingCount-- + if (thisObject.following.get(userProfile.id) !== undefined) { + thisObject.following.delete(userProfile.id) + thisObject.followingCount-- } } - function addTradePostsFollowing( + function addFollower( userProfile ) { - if (thisObject.tradePostsFollowingCount.get(userProfile.id) === undefined) { - thisObject.tradePostsFollowingCount.set(userProfile.id, userProfile) - thisObject.tradePostsFollowingCount++ + if (thisObject.followers.get(userProfile.id) === undefined) { + thisObject.followers.set(userProfile.id, userProfile) + thisObject.followersCount++ } } - function removeTradePostsFollowing( + function removeFollower( userProfile ) { - if (thisObject.tradePostsFollowingCount.get(userProfile.id) !== undefined) { - thisObject.tradePostsFollowingCount.delete(userProfile.id) - thisObject.tradePostsFollowingCount-- - } - } - - function addMultiMediaPostsFollower( - userProfile - ) { - if (thisObject.multiMediaPostsFollowers.get(userProfile.id) === undefined) { - thisObject.multiMediaPostsFollowers.set(userProfile.id, userProfile) - thisObject.multiMediaPostFollowersCount++ - } - } - - function removeMultiMediaPostsFollower( - userProfile - ) { - if (thisObject.multiMediaPostsFollowers.get(userProfile.id) !== undefined) { - thisObject.multiMediaPostsFollowers.delete(userProfile.id) - thisObject.multiMediaPostFollowersCount-- - } - } - - function addTradePostsFollower( - userProfile - ) { - if (thisObject.tradePostsFollowers.get(userProfile.id) === undefined) { - thisObject.tradePostsFollowers.set(userProfile.id, userProfile) - thisObject.tradePostsFollowersCount++ - } - } - - function removeTradePostsFollower( - userProfile - ) { - if (thisObject.tradePostsFollowers.get(userProfile.id) !== undefined) { - thisObject.tradePostsFollowers.delete(userProfile.id) - thisObject.tradePostsFollowersCount-- + if (thisObject.followers.get(userProfile.id) !== undefined) { + thisObject.followers.delete(userProfile.id) + thisObject.followersCount-- } } From f36f1d2e298af5413cf5908b75dd43721f6799e2 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 27 Aug 2021 20:03:03 +0200 Subject: [PATCH 2/3] Update botProfile.js --- Network/botProfile.js | 129 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 118 insertions(+), 11 deletions(-) diff --git a/Network/botProfile.js b/Network/botProfile.js index a1c1b80c7..31871927c 100644 --- a/Network/botProfile.js +++ b/Network/botProfile.js @@ -1,11 +1,27 @@ -exports.newBot = function newBot() { +exports.newUserProfile = function newUserProfile() { let thisObject = { - botId: undefined, + botProfileId: undefined, botProfileHandle: undefined, botAsset: undefined, botExchange: undefined, enabled: undefined, + following: undefined, + followers: undefined, + followingCount: undefined, + followersCount: undefined, + emitterEventsCount: undefined, + targetEventsCount: undefined, + postsCount: undefined, + botsCount: undefined, + bots: undefined, + posts: undefined, + addPost: addPost, + removePost: removePost, + addFollowing: addFollowing, + removeFollowing: removeFollowing, + addFollower: addFollower, + removeFollower: removeFollower, initialize: initialize, finalize: finalize } @@ -13,17 +29,108 @@ exports.newBot = function newBot() { return thisObject function finalize() { + thisObject.following = undefined + thisObject.followers = undefined + thisObject.posts = undefined + thisObject.bots = undefined } - function initialize( - botId, - botAsset, - botExchange + function initialize() { + + thisObject.following = new Map() + thisObject.followers = new Map() + + thisObject.followingCount = 0 + thisObject.followersCount = 0 + + thisObject.emitterEventsCount = 0 + thisObject.targetEventsCount = 0 + thisObject.postsCount = 0 + thisObject.botsCount = 0 + + thisObject.posts = [] + thisObject.bots = undefined + } + + function addPost( + emitterPostHash, + targetPostHash, + postType, + botProfile, + timestamp ) { - thisObject.botId = botId - thisObject.botAsset = botAsset - thisObject.botExchange = botExchange - thisObject.enabled = true + if (NT.memory.maps.POSTS.get(emitterPostHash) !== undefined) { + throw ('Post Already Exists.') + } + + let post = NT.modules.POST.newPost() + post.initialize( + emitterPostHash, + targetPostHash, + postType, + botProfile, + timestamp + ) + + thisObject.maps.POSTS.push(post) + NT.memory.maps.POSTS.set(emitterPostHash, post) + thisObject.postsCount++ } -} \ No newline at end of file + + function removePost( + emitterPostHash + ) { + if (NT.memory.maps.POSTS.get(emitterPostHash) === undefined) { + throw ('Post Does Not Exist.') + } + + let post = thisObject.posts.get(emitterPostHash) + post.finalize() + + for (let i = thisObject.posts.length - 1; i >= 0; i--) { + if (thisObject.posts[i].emitterPostHash === emitterPostHash) { + thisObject.posts.splice(i, 1) + break + } + } + NT.memory.maps.POSTS.delete(emitterPostHash) + thisObject.postsCount-- + } + + function addFollowing( + botProfile + ) { + if (thisObject.following.get(botProfile.id) === undefined) { + thisObject.following.set(botProfile.id, botProfile) + thisObject.followingCount++ + } + } + + function removeFollowing( + botProfile + ) { + if (thisObject.following.get(botProfile.id) !== undefined) { + thisObject.following.delete(botProfile.id) + thisObject.followingCount-- + } + } + + function addFollower( + botProfile + ) { + if (thisObject.followers.get(botProfile.id) === undefined) { + thisObject.followers.set(botProfile.id, botProfile) + thisObject.followersCount++ + } + } + + function removeFollower( + botProfile + ) { + if (thisObject.followers.get(botProfile.id) !== undefined) { + thisObject.followers.delete(botProfile.id) + thisObject.followersCount-- + } + } +} From 78ea072b9ff836b1ff833523150cea5929e83f6c Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 27 Aug 2021 20:50:53 +0200 Subject: [PATCH 3/3] Post.js supports Users and Bots --- Network/botProfile.js | 5 --- Network/event.js | 76 +++++++++++++++++++++++------------------- Network/post.js | 32 +++++++++--------- Network/userProfile.js | 8 ++++- 4 files changed, 64 insertions(+), 57 deletions(-) diff --git a/Network/botProfile.js b/Network/botProfile.js index 31871927c..643571170 100644 --- a/Network/botProfile.js +++ b/Network/botProfile.js @@ -13,8 +13,6 @@ exports.newUserProfile = function newUserProfile() { emitterEventsCount: undefined, targetEventsCount: undefined, postsCount: undefined, - botsCount: undefined, - bots: undefined, posts: undefined, addPost: addPost, removePost: removePost, @@ -33,7 +31,6 @@ exports.newUserProfile = function newUserProfile() { thisObject.followers = undefined thisObject.posts = undefined - thisObject.bots = undefined } function initialize() { @@ -47,10 +44,8 @@ exports.newUserProfile = function newUserProfile() { thisObject.emitterEventsCount = 0 thisObject.targetEventsCount = 0 thisObject.postsCount = 0 - thisObject.botsCount = 0 thisObject.posts = [] - thisObject.bots = undefined } function addPost( diff --git a/Network/event.js b/Network/event.js index ea61143ba..7cddc9c22 100644 --- a/Network/event.js +++ b/Network/event.js @@ -4,6 +4,8 @@ exports.newEvent = function newEvent() { eventId: undefined, emitterUserProfileId: undefined, targetUserProfileId: undefined, + emitterBotProfileId: undefined, + targetBotProfileId: undefined, emitterPostHash: undefined, targetPostHash: undefined, timestamp: undefined, @@ -16,19 +18,19 @@ exports.newEvent = function newEvent() { const EVENT_TYPES = { - NEW_MULTI_MEDIA_POST: 10, - REPLY_TO_MULTI_MEDIA_POST: 11, - REPOST_MULTI_MEDIA: 12, - QUOTE_REPOST_MULTI_MEDIA: 13, - FOLLOW_USER_PROFILE_MULTI_MEDIA_POSTS: 14, - UNFOLLOW_USER_PROFILE_MULTI_MEDIA_POSTS: 15, + NEW_USER_POST: 10, + REPLY_TO_USER_POST: 11, + REPOST_USER_POST: 12, + QUOTE_REPOST_USER_POST: 13, + FOLLOW_USER_PROFILE: 14, + UNFOLLOW_USER_PROFILE: 15, - NEW_TRADE_POST: 20, - REPLY_TO_TRADE_POST: 21, - RE_POST_TRADE: 22, - QUOTE_REPOST_TRADE: 23, - FOLLOW_USER_PROFILE_TRADE_POSTS: 24, - UNFOLLOW_USER_PROFILE_TRADE_POSTS: 25, + 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, ADD_BOT: 50, REMOVE_BOT: 51, @@ -66,6 +68,8 @@ exports.newEvent = function newEvent() { thisObject.eventId = eventReceived.eventId thisObject.emitterUserProfileId = eventReceived.emitterUserProfileId thisObject.targetUserProfileId = eventReceived.targetUserProfileId + thisObject.emitterBotProfileId = eventReceived.emitterBotProfileId + thisObject.targetBotProfileId = eventReceived.targetBotProfileId thisObject.emitterPostHash = eventReceived.emitterPostHash thisObject.targetPostHash = eventReceived.targetPostHash thisObject.timestamp = eventReceived.timestamp @@ -87,8 +91,8 @@ exports.newEvent = function newEvent() { if (targetUserProfile === undefined) { /* We thow an exception when it does not have a target user profile and is required*/ if ( - thisObject.eventType !== EVENT_TYPES.NEW_MULTI_MEDIA_POST && - thisObject.eventType !== EVENT_TYPES.NEW_TRADE_POST + thisObject.eventType !== EVENT_TYPES.NEW_USER_POST && + thisObject.eventType !== EVENT_TYPES.NEW_BOT_POST ) { throw ('Target User Profile Not Found.') } @@ -99,27 +103,29 @@ exports.newEvent = function newEvent() { Is is a new post? */ if ( - thisObject.eventType === EVENT_TYPES.NEW_MULTI_MEDIA_POST || - thisObject.eventType === EVENT_TYPES.REPLY_TO_MULTI_MEDIA_POST || - thisObject.eventType === EVENT_TYPES.REPOST_MULTI_MEDIA || - thisObject.eventType === EVENT_TYPES.QUOTE_REPOST_MULTI_MEDIA || - thisObject.eventType === EVENT_TYPES.NEW_TRADE_POST || - thisObject.eventType === EVENT_TYPES.REPLY_TO_TRADE_POST || - thisObject.eventType === EVENT_TYPES.RE_POST_TRADE || - thisObject.eventType === EVENT_TYPES.QUOTE_REPOST_TRADE + thisObject.eventType === EVENT_TYPES.NEW_USER_POST || + thisObject.eventType === EVENT_TYPES.REPLY_TO_USER_POST || + thisObject.eventType === EVENT_TYPES.REPOST_USER_POST || + thisObject.eventType === EVENT_TYPES.QUOTE_REPOST_USER_POST || + 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 ) { if ( - thisObject.eventType === EVENT_TYPES.NEW_MULTI_MEDIA_POST || - thisObject.eventType === EVENT_TYPES.REPLY_TO_MULTI_MEDIA_POST || - thisObject.eventType === EVENT_TYPES.REPOST_MULTI_MEDIA || - thisObject.eventType === EVENT_TYPES.QUOTE_REPOST_MULTI_MEDIA + thisObject.eventType === EVENT_TYPES.NEW_USER_POST || + thisObject.eventType === EVENT_TYPES.REPLY_TO_USER_POST || + thisObject.eventType === EVENT_TYPES.REPOST_USER_POST || + thisObject.eventType === EVENT_TYPES.QUOTE_REPOST_USER_POST ) { emitterUserProfile.addPost( thisObject.emitterUserProfileId, thisObject.targetUserProfileId, + thisObject.emitterBotProfileId, + thisObject.targetBotProfileId, thisObject.emitterPostHash, thisObject.targetPostHash, - thisObject.eventType, + thisObject.eventType - 10, thisObject.timestamp ) } @@ -130,13 +136,13 @@ exports.newEvent = function newEvent() { Is is a following? */ if ( - thisObject.eventType === EVENT_TYPES.FOLLOW_USER_PROFILE_MULTI_MEDIA_POSTS || - thisObject.eventType === EVENT_TYPES.UNFOLLOW_USER_PROFILE_MULTI_MEDIA_POSTS || - thisObject.eventType === EVENT_TYPES.FOLLOW_USER_PROFILE_TRADE_POSTS || - thisObject.eventType === EVENT_TYPES.UNFOLLOW_USER_PROFILE_TRADE_POSTS + thisObject.eventType === EVENT_TYPES.FOLLOW_USER_PROFILE || + thisObject.eventType === EVENT_TYPES.UNFOLLOW_USER_PROFILE || + thisObject.eventType === EVENT_TYPES.FOLLOW_BOT_PROFILE || + thisObject.eventType === EVENT_TYPES.UNFOLLOW_BOT_PROFILE ) { switch (thisObject.eventType) { - case EVENT_TYPES.FOLLOW_USER_PROFILE_MULTI_MEDIA_POSTS: { + case EVENT_TYPES.FOLLOW_USER_PROFILE: { emitterUserProfile.addFollowing( targetUserProfile ) @@ -145,7 +151,7 @@ exports.newEvent = function newEvent() { ) break } - case EVENT_TYPES.UNFOLLOW_USER_PROFILE_MULTI_MEDIA_POSTS: { + case EVENT_TYPES.UNFOLLOW_USER_PROFILE: { emitterUserProfile.removeFollowing( targetUserProfile ) @@ -154,7 +160,7 @@ exports.newEvent = function newEvent() { ) break } - case EVENT_TYPES.FOLLOW_USER_PROFILE_TRADE_POSTS: { + case EVENT_TYPES.FOLLOW_BOT_PROFILE: { emitterUserProfile.addTradePostsFollowing( targetUserProfile ) @@ -163,7 +169,7 @@ exports.newEvent = function newEvent() { ) break } - case EVENT_TYPES.UNFOLLOW_USER_PROFILE_TRADE_POSTS: { + case EVENT_TYPES.UNFOLLOW_BOT_PROFILE: { emitterUserProfile.removeTradePostsFollowing( targetUserProfile ) diff --git a/Network/post.js b/Network/post.js index f3e3bd873..9b35c95cb 100644 --- a/Network/post.js +++ b/Network/post.js @@ -3,6 +3,8 @@ exports.newPost = function newPost() { let thisObject = { emitterUserProfileId: undefined, targetUserProfileId: undefined, + emitterBotProfileId: undefined, + targetBotProfileId: undefined, emitterPostHash: undefined, targetPostHash: undefined, postType: undefined, @@ -17,14 +19,10 @@ exports.newPost = function newPost() { } const POST_TYPES = { - NEW_MULTI_MEDIA_POST: 10, - REPLY_TO_MULTI_MEDIA_POST: 11, - REPOST_MULTI_MEDIA: 12, - QUOTE_REPOST_MULTI_MEDIA: 13, - NEW_TRADE_POST: 20, - REPLY_TO_TRADE_POST: 21, - RE_POST_TRADE: 22, - QUOTE_REPOST_TRADE: 23 + NEW_POST: 0, + REPLY_TO_POST: 1, + REPOST_: 2, + QUOTE_REPOST_: 3 } const REACTION_TYPES = { @@ -53,6 +51,8 @@ exports.newPost = function newPost() { function finalize() { thisObject.emitterUserProfileId = undefined thisObject.targetUserProfileId = undefined + thisObject.emitterBotProfileId = undefined + thisObject.targetBotProfileId = undefined thisObject.emitterPostHash = undefined thisObject.targetPostHash = undefined thisObject.postType = undefined @@ -63,6 +63,8 @@ exports.newPost = function newPost() { function initialize( emitterUserProfileId, targetUserProfileId, + emitterBotProfileId, + targetBotProfileId, emitterPostHash, targetPostHash, postType, @@ -71,6 +73,8 @@ exports.newPost = function newPost() { thisObject.emitterUserProfileId = emitterUserProfileId thisObject.targetUserProfileId = targetUserProfileId + thisObject.emitterBotProfileId = emitterBotProfileId + thisObject.targetBotProfileId = targetBotProfileId thisObject.emitterPostHash = emitterPostHash thisObject.targetPostHash = targetPostHash thisObject.postType = postType @@ -83,12 +87,9 @@ exports.newPost = function newPost() { let targetPost if ( - event.eventType === POST_TYPES.REPLY_TO_MULTI_MEDIA_POST || - event.eventType === POST_TYPES.REPOST_MULTI_MEDIA || - event.eventType === POST_TYPES.QUOTE_REPOST_MULTI_MEDIA || - event.eventType === POST_TYPES.REPLY_TO_TRADE_POST || - event.eventType === POST_TYPES.RE_POST_TRADE || - event.eventType === POST_TYPES.QUOTE_REPOST_TRADE + thisObject.postType === POST_TYPES.REPLY_TO_POST || + thisObject.postType === POST_TYPES.REPOST_ || + thisObject.postType === POST_TYPES.QUOTE_REPOST_ ) { targetPost = NT.memory.maps.POSTS.get(thisObject.targetPostHash) @@ -100,8 +101,7 @@ exports.newPost = function newPost() { Let's add this post to the replies of the Target Post */ if ( - event.eventType === POST_TYPES.REPLY_TO_MULTI_MEDIA_POST || - event.eventType === POST_TYPES.REPLY_TO_TRADE_POST + thisObject.postType === POST_TYPES.REPLY_TO_POST ) { targetPost.replies.push(thisObject) } diff --git a/Network/userProfile.js b/Network/userProfile.js index cc0f8a315..a7d308cf6 100644 --- a/Network/userProfile.js +++ b/Network/userProfile.js @@ -53,10 +53,12 @@ exports.newUserProfile = function newUserProfile() { thisObject.botsCount = 0 thisObject.posts = [] - thisObject.bots = undefined + thisObject.bots = [] } function addPost( + emitterUserProfileId, + targetUserProfileId, emitterPostHash, targetPostHash, postType, @@ -69,6 +71,10 @@ exports.newUserProfile = function newUserProfile() { let post = NT.modules.POST.newPost() post.initialize( + emitterUserProfileId, + targetUserProfileId, + undefined, + undefined, emitterPostHash, targetPostHash, postType,