Follow / Unfollow event types
This commit is contained in:
1 parent
1aad11a320
commit
979670a7aa
3 files changed
+180
-50
No files matched your search
+75
-25
@@ -16,14 +16,14 @@ exports.newEvent = function newEvent() {
|
||||
REPLY_TO_MULTI_MEDIA_POST: 11,
|
||||
REPOST_MULTI_MEDIA: 12,
|
||||
QUOTE_REPOST_MULTI_MEDIA: 13,
|
||||
FOLLOW_MULTI_MEDIA_POSTS: 14,
|
||||
UNFOLLOW_MULTIMEDIA_POSTS: 15,
|
||||
FOLLOW_USER_PROFILE_MULTI_MEDIA_POSTS: 14,
|
||||
UNFOLLOW_USER_PROFILE_MULTI_MEDIA_POSTS: 15,
|
||||
NEW_TRADE_POST: 20,
|
||||
REPLY_TO_TRADE_POST: 21,
|
||||
RE_POST_TRADE: 22,
|
||||
QUOTE_REPOST_TRADE: 23,
|
||||
FOLLOW_TRADE_POSTS: 24,
|
||||
UNFOLLOW_TRADE_POSTS: 25,
|
||||
FOLLOW_USER_PROFILE_TRADE_POSTS: 24,
|
||||
UNFOLLOW_USER_PROFILE_TRADE_POSTS: 25,
|
||||
REACTION_LIKE: 100,
|
||||
REACTION_LOVE: 101,
|
||||
REACTION_HAHA: 102,
|
||||
@@ -66,12 +66,12 @@ exports.newEvent = function newEvent() {
|
||||
|
||||
thisObject.targetUserProfile = NT.memory.USER_PROFILES.get(event.targetUserProfileId)
|
||||
if (thisObject.targetUserProfile === undefined) {
|
||||
/* The message is ignored when it does not have a target user profile and is required*/
|
||||
/* We thow an exception when it does not have a target user profile and is required*/
|
||||
if (
|
||||
event.eventType !== EVENT_TYPES.NEW_MULTI_MEDIA_POST &&
|
||||
event.eventType !== EVENT_TYPES.NEW_TRADE_POST
|
||||
)
|
||||
return
|
||||
throw ('Target User Profile Not Found.')
|
||||
}
|
||||
|
||||
thisObject.eventId = event.eventId
|
||||
@@ -79,28 +79,78 @@ exports.newEvent = function newEvent() {
|
||||
thisObject.asset = event.asset
|
||||
thisObject.timestamp = event.timestamp
|
||||
|
||||
switch (true) {
|
||||
case (
|
||||
event.eventType === EVENT_TYPES.NEW_MULTI_MEDIA_POST ||
|
||||
event.eventType === EVENT_TYPES.REPLY_TO_MULTI_MEDIA_POST ||
|
||||
event.eventType === EVENT_TYPES.REPOST_MULTI_MEDIA ||
|
||||
event.eventType === EVENT_TYPES.QUOTE_REPOST_MULTI_MEDIA ||
|
||||
event.eventType === EVENT_TYPES.NEW_TRADE_POST ||
|
||||
event.eventType === EVENT_TYPES.REPLY_TO_TRADE_POST ||
|
||||
event.eventType === EVENT_TYPES.RE_POST_TRADE ||
|
||||
event.eventType === EVENT_TYPES.QUOTE_REPOST_TRADE
|
||||
): {
|
||||
let post = NT.modules.POST.newPost()
|
||||
post.initialize(
|
||||
event.emitterPostHash,
|
||||
event.targetPostHash,
|
||||
thisObject.eventType,
|
||||
thisObject.emitterUserProfile,
|
||||
thisObject.asset,
|
||||
thisObject.timestamp
|
||||
/*
|
||||
Is is a new post?
|
||||
*/
|
||||
if (
|
||||
event.eventType === EVENT_TYPES.NEW_MULTI_MEDIA_POST ||
|
||||
event.eventType === EVENT_TYPES.REPLY_TO_MULTI_MEDIA_POST ||
|
||||
event.eventType === EVENT_TYPES.REPOST_MULTI_MEDIA ||
|
||||
event.eventType === EVENT_TYPES.QUOTE_REPOST_MULTI_MEDIA ||
|
||||
event.eventType === EVENT_TYPES.NEW_TRADE_POST ||
|
||||
event.eventType === EVENT_TYPES.REPLY_TO_TRADE_POST ||
|
||||
event.eventType === EVENT_TYPES.RE_POST_TRADE ||
|
||||
event.eventType === EVENT_TYPES.QUOTE_REPOST_TRADE
|
||||
) {
|
||||
let post = NT.modules.POST.newPost()
|
||||
post.initialize(
|
||||
event.emitterPostHash,
|
||||
event.targetPostHash,
|
||||
thisObject.eventType,
|
||||
thisObject.emitterUserProfile,
|
||||
thisObject.asset,
|
||||
thisObject.timestamp
|
||||
)
|
||||
return
|
||||
}
|
||||
/*
|
||||
Is is a following?
|
||||
*/
|
||||
if (
|
||||
event.eventType === EVENT_TYPES.FOLLOW_USER_PROFILE_MULTI_MEDIA_POSTS ||
|
||||
event.eventType === EVENT_TYPES.UNFOLLOW_USER_PROFILE_MULTI_MEDIA_POSTS ||
|
||||
event.eventType === EVENT_TYPES.FOLLOW_USER_PROFILE_TRADE_POSTS ||
|
||||
event.eventType === EVENT_TYPES.UNFOLLOW_USER_PROFILE_TRADE_POSTS
|
||||
) {
|
||||
switch (event.eventType) {
|
||||
case EVENT_TYPES.FOLLOW_USER_PROFILE_MULTI_MEDIA_POSTS: {
|
||||
thisObject.emitterUserProfile.addMultiMediaPostsFollowing(
|
||||
thisObject.targetUserProfile
|
||||
)
|
||||
thisObject.targetUserProfile.addMultiMediaPostsFollower(
|
||||
thisObject.emitterUserProfile
|
||||
)
|
||||
break
|
||||
}
|
||||
case EVENT_TYPES.UNFOLLOW_USER_PROFILE_MULTI_MEDIA_POSTS: {
|
||||
thisObject.emitterUserProfile.removeMultiMediaPostsFollowing(
|
||||
thisObject.targetUserProfile
|
||||
)
|
||||
thisObject.targetUserProfile.removeMultiMediaPostsFollower(
|
||||
thisObject.emitterUserProfile
|
||||
)
|
||||
break
|
||||
}
|
||||
case EVENT_TYPES.FOLLOW_USER_PROFILE_TRADE_POSTS: {
|
||||
thisObject.emitterUserProfile.addTradePostsFollowing(
|
||||
thisObject.targetUserProfile
|
||||
)
|
||||
thisObject.targetUserProfile.addTradePostsFollower(
|
||||
thisObject.emitterUserProfile
|
||||
)
|
||||
break
|
||||
}
|
||||
case EVENT_TYPES.UNFOLLOW_USER_PROFILE_TRADE_POSTS: {
|
||||
thisObject.emitterUserProfile.removeTradePostsFollowing(
|
||||
thisObject.targetUserProfile
|
||||
)
|
||||
thisObject.targetUserProfile.removeTradePostsFollower(
|
||||
thisObject.emitterUserProfile
|
||||
)
|
||||
break
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
+8
-8
@@ -54,12 +54,12 @@ exports.newPost = function newPost() {
|
||||
Let's find the Target Post
|
||||
*/
|
||||
if (
|
||||
event.eventType === EVENT_TYPES.REPLY_TO_MULTI_MEDIA_POST ||
|
||||
event.eventType === EVENT_TYPES.REPOST_MULTI_MEDIA ||
|
||||
event.eventType === EVENT_TYPES.QUOTE_REPOST_MULTI_MEDIA ||
|
||||
event.eventType === EVENT_TYPES.REPLY_TO_TRADE_POST ||
|
||||
event.eventType === EVENT_TYPES.RE_POST_TRADE ||
|
||||
event.eventType === EVENT_TYPES.QUOTE_REPOST_TRADE
|
||||
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.targetPost = NT.memory.POSTS.get(thisObject.targetPostHash)
|
||||
|
||||
@@ -71,8 +71,8 @@ exports.newPost = function newPost() {
|
||||
Let's add this post to the replies of the Target Post
|
||||
*/
|
||||
if (
|
||||
event.eventType === EVENT_TYPES.REPLY_TO_MULTI_MEDIA_POST ||
|
||||
event.eventType === EVENT_TYPES.REPLY_TO_TRADE_POST
|
||||
event.eventType === POST_TYPES.REPLY_TO_MULTI_MEDIA_POST ||
|
||||
event.eventType === POST_TYPES.REPLY_TO_TRADE_POST
|
||||
) {
|
||||
thisObject.targetPost.replies.push(thisObject)
|
||||
}
|
||||
|
||||
+97
-17
@@ -4,18 +4,26 @@ exports.newUserProfile = function newUserProfile() {
|
||||
userProfieId: undefined,
|
||||
githubUsername: undefined,
|
||||
blockchainAccount: undefined,
|
||||
postFollowing: undefined,
|
||||
postFollowers: undefined,
|
||||
tradeFollowing: undefined,
|
||||
tradeFollowers: undefined,
|
||||
multiMediaPostsFollowing: undefined,
|
||||
multiMediaPostsFollowers: undefined,
|
||||
tradePostsFollowing: undefined,
|
||||
tradePostsFollowers: undefined,
|
||||
ranking: undefined,
|
||||
events: undefined,
|
||||
postFollowingCount: undefined,
|
||||
postFollowersCount: undefined,
|
||||
tradeFollowingCount: undefined,
|
||||
tradeFollowersCount: undefined,
|
||||
multiMediaPostFollowingCount: undefined,
|
||||
multiMediaPostFollowersCount: undefined,
|
||||
tradePostsFollowingCount: undefined,
|
||||
tradePostsFollowersCount: undefined,
|
||||
eventsCount: undefined,
|
||||
postsCount: undefined,
|
||||
addMultiMediaPostsFollowing: addMultiMediaPostsFollowing,
|
||||
removeMultiMediaPostsFollowing: removeMultiMediaPostsFollowing,
|
||||
addTradePostsFollowing: addTradePostsFollowing,
|
||||
removeTradePostsFollowing: removeTradePostsFollowing,
|
||||
addMultiMediaPostsFollower: addMultiMediaPostsFollower,
|
||||
removeMultiMediaPostsFollower: removeMultiMediaPostsFollower,
|
||||
addTradePostsFollower: addTradePostsFollower,
|
||||
removeTradePostsFollower: removeTradePostsFollower,
|
||||
initialize: initialize,
|
||||
finalize: finalize
|
||||
}
|
||||
@@ -28,20 +36,92 @@ exports.newUserProfile = function newUserProfile() {
|
||||
|
||||
function initialize() {
|
||||
|
||||
thisObject.postFollowing = new Map()
|
||||
thisObject.postFollowers = new Map()
|
||||
thisObject.multiMediaPostsFollowing = new Map()
|
||||
thisObject.multiMediaPostsFollowers = new Map()
|
||||
|
||||
thisObject.tradeFollowing = new Map()
|
||||
thisObject.tradeFollowers = new Map()
|
||||
thisObject.tradePostsFollowing = new Map()
|
||||
thisObject.tradePostsFollowers = new Map()
|
||||
|
||||
thisObject.events = []
|
||||
thisObject.events = [] // Dont know what this is
|
||||
|
||||
thisObject.postFollowingCount = 0
|
||||
thisObject.postFollowersCount = 0
|
||||
thisObject.tradeFollowingCount = 0
|
||||
thisObject.tradeFollowersCount = 0
|
||||
thisObject.multiMediaPostFollowingCount = 0
|
||||
thisObject.multiMediaPostFollowersCount = 0
|
||||
thisObject.tradePostsFollowingCount = 0
|
||||
thisObject.tradePostsFollowersCount = 0
|
||||
thisObject.eventsCount = 0
|
||||
thisObject.postsCount = 0
|
||||
|
||||
}
|
||||
|
||||
function addMultiMediaPostsFollowing(
|
||||
userProfile
|
||||
) {
|
||||
if (thisObject.multiMediaPostsFollowing.get(userProfile.id) === undefined) {
|
||||
thisObject.multiMediaPostsFollowing.set(userProfile.id, userProfile)
|
||||
thisObject.multiMediaPostFollowingCount++
|
||||
}
|
||||
}
|
||||
|
||||
function removeMultiMediaPostsFollowing(
|
||||
userProfile
|
||||
) {
|
||||
if (thisObject.multiMediaPostsFollowing.get(userProfile.id) !== undefined) {
|
||||
thisObject.multiMediaPostsFollowing.delete(userProfile.id)
|
||||
thisObject.multiMediaPostFollowingCount--
|
||||
}
|
||||
}
|
||||
|
||||
function addTradePostsFollowing(
|
||||
userProfile
|
||||
) {
|
||||
if (thisObject.tradePostsFollowingCount.get(userProfile.id) === undefined) {
|
||||
thisObject.tradePostsFollowingCount.set(userProfile.id, userProfile)
|
||||
thisObject.tradePostsFollowingCount++
|
||||
}
|
||||
}
|
||||
|
||||
function removeTradePostsFollowing(
|
||||
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--
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user