Merge pull request #1652 from Luis-Fernando-Molina/develop

Contribution: genereteUniqueId function moved to SA
This commit is contained in:
Luis Fernando Molina authored and GitHub committed 2021-09-04 05:30:18 -04:00
commit 966e9f7c6a
13 files changed
+225 -145

No files matched your search

+1
View File
@@ -12,3 +12,4 @@ Projects/Foundations/Icons/Thumbs.db
*.exe
node_modules
launch.json
.idea
+30 -1
View File
@@ -41,8 +41,37 @@ exports.newDesktopApp = function newDesktopApp() {
.then(showProfiles)
.catch(onError)
function showProfiles(profiles) {
async function showProfiles(profiles) {
console.log(profiles)
for (let i = 0; i < profiles.length; i++) {
let profile = profiles[i]
/*
Test Following Profiles.
*/
let eventMessage = {
eventId: SA.projects.foundations.utilities.miscellaneousFunctions.genereteUniqueId(),
eventType: SA.projects.socialTrading.globals.eventTypes.FOLLOW_USER_PROFILE,
emitterUserProfileId: DK.TEST_NETWORK_CLIENT_USER_PROFILE_ID,
targetUserProfileId: profile.userProfileId
}
let event = {
requestType: 'Event',
eventMessage: JSON.stringify(eventMessage)
}
await DK.webSocketsClient.sendMessage(
JSON.stringify(event)
)
.then(followAdded)
.catch(onError)
function followAdded() {
console.log("User Profile " + profile.userProfileHandle + " followed.")
}
}
}
/*
Test Query User Profile Stats.
@@ -0,0 +1,15 @@
exports.newFoundationsUtilitiesMiscellaneousFunctions = function () {
let thisObject = {
genereteUniqueId: genereteUniqueId
}
return thisObject
function genereteUniqueId() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8)
return v.toString(16)
})
}
}
@@ -58,7 +58,7 @@ exports.newFoundationsBotModulesLearningEpisode = function (processIndex) {
/* Recording the opening at the Learning Engine Data Structure */
learningEngine.learningCurrent.learningEpisode.status.value = 'Open'
learningEngine.learningCurrent.learningEpisode.serialNumber.value = 1
learningEngine.learningCurrent.learningEpisode.identifier.value = TS.projects.foundations.utilities.miscellaneousFunctions.genereteUniqueId()
learningEngine.learningCurrent.learningEpisode.identifier.value = SA.projects.foundations.utilities.miscellaneousFunctions.genereteUniqueId()
learningEngine.learningCurrent.learningEpisode.beginRate.value = learningEngine.learningCurrent.learningEpisode.candle.close.value
}
@@ -66,7 +66,7 @@ exports.newFoundationsBotModulesTradingEpisode = function (processIndex) {
/* Recording the opening at the Trading Engine Data Structure */
tradingEngine.tradingCurrent.tradingEpisode.status.value = 'Open'
tradingEngine.tradingCurrent.tradingEpisode.serialNumber.value = 1
tradingEngine.tradingCurrent.tradingEpisode.identifier.value = TS.projects.foundations.utilities.miscellaneousFunctions.genereteUniqueId()
tradingEngine.tradingCurrent.tradingEpisode.identifier.value = SA.projects.foundations.utilities.miscellaneousFunctions.genereteUniqueId()
tradingEngine.tradingCurrent.tradingEpisode.beginRate.value = tradingEngine.tradingCurrent.tradingEpisode.candle.close.value
}
@@ -361,7 +361,7 @@ exports.newFoundationsBotModulesTradingOrders = function (processIndex) {
/* Create Order Procedure */
tradingEngineOrder.status.value = 'Open'
tradingEngineOrder.identifier.value = TS.projects.foundations.utilities.miscellaneousFunctions.genereteUniqueId()
tradingEngineOrder.identifier.value = SA.projects.foundations.utilities.miscellaneousFunctions.genereteUniqueId()
tradingEngineOrder.begin.value = tradingEngine.tradingCurrent.tradingEpisode.cycle.begin.value
tradingEngineOrder.end.value = tradingEngine.tradingCurrent.tradingEpisode.cycle.end.value
tradingEngineOrder.serialNumber.value = tradingEngine.tradingCurrent.tradingEpisode.tradingEpisodeCounters.orders.value
@@ -58,7 +58,7 @@ exports.newFoundationsBotModulesTradingPosition = function (processIndex) {
/* Recording the opening at the Trading Engine Data Structure */
tradingEngine.tradingCurrent.position.status.value = 'Open'
tradingEngine.tradingCurrent.position.serialNumber.value = tradingEngine.tradingCurrent.tradingEpisode.tradingEpisodeCounters.positions.value + 1
tradingEngine.tradingCurrent.position.identifier.value = TS.projects.foundations.utilities.miscellaneousFunctions.genereteUniqueId()
tradingEngine.tradingCurrent.position.identifier.value = SA.projects.foundations.utilities.miscellaneousFunctions.genereteUniqueId()
tradingEngine.tradingCurrent.position.beginRate.value = tradingEngine.tradingCurrent.tradingEpisode.candle.close.value
tradingEngine.tradingCurrent.position.positionBaseAsset.beginBalance.value = tradingEngine.tradingCurrent.tradingEpisode.episodeBaseAsset.balance.value
tradingEngine.tradingCurrent.position.positionQuotedAsset.beginBalance.value = tradingEngine.tradingCurrent.tradingEpisode.episodeQuotedAsset.balance.value
@@ -44,7 +44,7 @@ exports.newFoundationsBotModulesTradingStrategy = function (processIndex) {
/* Recording the opening at the Trading Engine Data Structure */
tradingEngine.tradingCurrent.strategy.status.value = 'Open'
tradingEngine.tradingCurrent.strategy.serialNumber.value = tradingEngine.tradingCurrent.tradingEpisode.tradingEpisodeCounters.strategies.value
tradingEngine.tradingCurrent.strategy.identifier.value = TS.projects.foundations.utilities.miscellaneousFunctions.genereteUniqueId()
tradingEngine.tradingCurrent.strategy.identifier.value = SA.projects.foundations.utilities.miscellaneousFunctions.genereteUniqueId()
tradingEngine.tradingCurrent.strategy.beginRate.value = tradingEngine.tradingCurrent.tradingEpisode.candle.min.value
tradingEngine.tradingCurrent.strategy.index.value = index
@@ -1,7 +1,6 @@
exports.newFoundationsUtilitiesMiscellaneousFunctions = function () {
let thisObject = {
genereteUniqueId: genereteUniqueId,
truncateToThisPrecision: truncateToThisPrecision,
pad: pad,
asyncGetDatasetFile: asyncGetDatasetFile,
@@ -10,13 +9,6 @@ exports.newFoundationsUtilitiesMiscellaneousFunctions = function () {
return thisObject
function genereteUniqueId() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8)
return v.toString(16)
})
}
function truncateToThisPrecision(floatNumber, precision) {
return parseFloat(floatNumber.toFixed(precision))
}
+12
View File
@@ -894,6 +894,12 @@
"propertyName": "plugins",
"functionName": "newFoundationsUtilitiesPlugins",
"fileName": "Plugins.js"
},
{
"name": "Miscellaneous Functions",
"propertyName": "miscellaneousFunctions",
"functionName": "newFoundationsUtilitiesMiscellaneousFunctions",
"fileName": "MiscellaneousFunctions.js"
}
]
},
@@ -1439,6 +1445,12 @@
"propertyName": "queryTypes",
"functionName": "newSocialTradingGlobalsQueryTypes",
"fileName": "QueryTypes.js"
},
{
"name": "Event Types",
"propertyName": "eventTypes",
"functionName": "newSocialTradingGlobalsEventTypes",
"fileName": "EventTypes.js"
}
]
}
@@ -123,7 +123,7 @@ exports.newSocialTradingModulesClientInterface = function newSocialTradingModule
let response = {
result: 'Ok',
message: 'Client Interface Event Processed.'
message: 'Client Interface Event Processed.'
}
return response
@@ -132,9 +132,11 @@ exports.newSocialTradingModulesClientInterface = function newSocialTradingModule
Any exception that happens while trying to change the state of the Social Graph,
will be returned to the caller without doing anything else here.
*/
let errorMessage = err.message
if (errorMessage === undefined) { errorMessage = err }
let response = {
result: 'Error',
message: 'Client Interface ' + err.message
message: 'Client Interface ' + errorMessage
}
return response
}
@@ -191,21 +193,23 @@ exports.newSocialTradingModulesClientInterface = function newSocialTradingModule
try {
let query = NT.projects.socialTrading.modules.query.newSocialTradingModulesQuery()
query.initialize(queryReceived)
let response = {
result: 'Ok',
message: 'Client Interface Query Processed.',
data: query.execute()
}
return response
} catch (err) {
/*
Any exception that happens while trying to execute the query.
*/
let errorMessage = err.message
if (errorMessage === undefined) { errorMessage = err }
let response = {
result: 'Error',
message: err.message
message: 'Client Interface ' + errorMessage
}
return response
}
+109 -126
View File
@@ -29,46 +29,6 @@ exports.newSocialTradingModulesEvent = function newSocialTradingModulesEvent() {
finalize: finalize
}
const EVENT_TYPES = {
/* Users Posts and Following Events */
NEW_USER_POST: 10,
REPLY_TO_USER_POST: 11,
REPOST_USER_POST: 12,
QUOTE_REPOST_USER_POST: 13,
REMOVE_USER_POST: 14,
FOLLOW_USER_PROFILE: 15,
UNFOLLOW_USER_PROFILE: 16,
/* Bots Posts and Following Events */
NEW_BOT_POST: 20,
REPLY_TO_BOT_POST: 21,
REPOST_BOT_POST: 22,
QUOTE_REPOST_BOT_POST: 23,
REMOVE_BOT_POST: 24,
FOLLOW_BOT_PROFILE: 25,
UNFOLLOW_BOT_PROFILE: 26,
/* Bots Management Events */
ADD_BOT: 50,
REMOVE_BOT: 51,
ENABLE_BOT: 52,
DISABLE_BOT: 53,
/* Add Reaction to Posts Events */
ADD_REACTION_LIKE: 100,
ADD_REACTION_LOVE: 101,
ADD_REACTION_HAHA: 102,
ADD_REACTION_WOW: 103,
ADD_REACTION_SAD: 104,
ADD_REACTION_ANGRY: 105,
ADD_REACTION_CARE: 106,
/* Remove Reaction to Posts Events */
REMOVE_REACTION_LIKE: 200,
REMOVE_REACTION_LOVE: 201,
REMOVE_REACTION_HAHA: 202,
REMOVE_REACTION_WOW: 203,
REMOVE_REACTION_SAD: 204,
REMOVE_REACTION_ANGRY: 205,
REMOVE_REACTION_CARE: 206
}
return thisObject
function finalize() {
@@ -101,7 +61,7 @@ exports.newSocialTradingModulesEvent = function newSocialTradingModulesEvent() {
/*
Validate Emitter User Profile.
*/
if (emitterUserProfileId === undefined) {
if (thisObject.emitterUserProfileId === undefined) {
throw ('Emitter User Profile Id Not Provided.')
}
emitterUserProfile = NT.projects.socialTrading.globals.memory.maps.USER_PROFILES_BY_ID.get(thisObject.emitterUserProfileId)
@@ -120,8 +80,8 @@ exports.newSocialTradingModulesEvent = function newSocialTradingModulesEvent() {
/*
Validate Emitter Bot Profile.
*/
if (emitterBotProfileId !== undefined) {
emitterBotProfile = emitterUserProfile.bots.get(emitterBotProfileId)
if (thisObject.emitterBotProfileId !== undefined) {
emitterBotProfile = emitterUserProfile.bots.get(thisObject.emitterBotProfileId)
if (emitterBotProfile === undefined) {
throw ('Emitter Bot Profile Not Found.')
}
@@ -129,41 +89,52 @@ exports.newSocialTradingModulesEvent = function newSocialTradingModulesEvent() {
/*
Validate Target Bot Profile.
*/
if (targetBotProfileId !== undefined) {
targetBotProfile = emitterUserProfile.bots.get(targetBotProfileId)
if (thisObject.targetBotProfileId !== undefined) {
targetBotProfile = emitterUserProfile.bots.get(thisObject.targetBotProfileId)
if (targetBotProfile === undefined) {
throw ('Target Bot Profile Not Found.')
}
}
postingEvents()
followingEvents()
reactionEvents()
botEvents()
eventCounters()
if (postingEvents()) {
eventCounters()
return
}
if (followingEvents()) {
eventCounters()
return
}
if (reactionEvents()) {
eventCounters()
return
}
if (botEvents()) {
eventCounters()
return
}
function postingEvents() {
/*
Is is related to Posting?
*/
if (
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
thisObject.eventType === SA.projects.socialTrading.globals.eventTypes.NEW_USER_POST ||
thisObject.eventType === SA.projects.socialTrading.globals.eventTypes.REPLY_TO_USER_POST ||
thisObject.eventType === SA.projects.socialTrading.globals.eventTypes.REPOST_USER_POST ||
thisObject.eventType === SA.projects.socialTrading.globals.eventTypes.QUOTE_REPOST_USER_POST ||
thisObject.eventType === SA.projects.socialTrading.globals.eventTypes.NEW_BOT_POST ||
thisObject.eventType === SA.projects.socialTrading.globals.eventTypes.REPLY_TO_BOT_POST ||
thisObject.eventType === SA.projects.socialTrading.globals.eventTypes.REPOST_BOT_POST ||
thisObject.eventType === SA.projects.socialTrading.globals.eventTypes.QUOTE_REPOST_BOT_POST
) {
/*
New User Post
*/
if (
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 === SA.projects.socialTrading.globals.eventTypes.NEW_USER_POST ||
thisObject.eventType === SA.projects.socialTrading.globals.eventTypes.REPLY_TO_USER_POST ||
thisObject.eventType === SA.projects.socialTrading.globals.eventTypes.REPOST_USER_POST ||
thisObject.eventType === SA.projects.socialTrading.globals.eventTypes.QUOTE_REPOST_USER_POST
) {
emitterUserProfile.addPost(
thisObject.emitterUserProfileId,
@@ -175,16 +146,16 @@ exports.newSocialTradingModulesEvent = function newSocialTradingModulesEvent() {
thisObject.eventType - 10,
thisObject.timestamp
)
return
return true
}
/*
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
thisObject.eventType === SA.projects.socialTrading.globals.eventTypes.NEW_BOT_POST ||
thisObject.eventType === SA.projects.socialTrading.globals.eventTypes.REPLY_TO_BOT_POST ||
thisObject.eventType === SA.projects.socialTrading.globals.eventTypes.REPOST_BOT_POST ||
thisObject.eventType === SA.projects.socialTrading.globals.eventTypes.QUOTE_REPOST_BOT_POST
) {
if (emitterBotProfile === undefined) {
throw ('Emitter Bot Profile Id Not Provided.')
@@ -200,24 +171,24 @@ exports.newSocialTradingModulesEvent = function newSocialTradingModulesEvent() {
thisObject.eventType - 20,
thisObject.timestamp
)
return
return true
}
/*
Remove User Post
*/
if (
thisObject.eventType === EVENT_TYPES.REMOVE_USER_POST
thisObject.eventType === SA.projects.socialTrading.globals.eventTypes.REMOVE_USER_POST
) {
emitterUserProfile.removePost(
thisObject.emitterPostHash
)
return
return true
}
/*
Remove Bot Post
*/
if (
thisObject.eventType === EVENT_TYPES.REMOVE_BOT_POST
thisObject.eventType === SA.projects.socialTrading.globals.eventTypes.REMOVE_BOT_POST
) {
if (emitterBotProfile === undefined) {
throw ('Emitter Bot Profile Id Not Provided.')
@@ -226,7 +197,7 @@ exports.newSocialTradingModulesEvent = function newSocialTradingModulesEvent() {
emitterBotProfile.removePost(
thisObject.emitterPostHash
)
return
return true
}
}
}
@@ -236,13 +207,13 @@ exports.newSocialTradingModulesEvent = function newSocialTradingModulesEvent() {
Is is a following?
*/
if (
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
thisObject.eventType === SA.projects.socialTrading.globals.eventTypes.FOLLOW_USER_PROFILE ||
thisObject.eventType === SA.projects.socialTrading.globals.eventTypes.UNFOLLOW_USER_PROFILE ||
thisObject.eventType === SA.projects.socialTrading.globals.eventTypes.FOLLOW_BOT_PROFILE ||
thisObject.eventType === SA.projects.socialTrading.globals.eventTypes.UNFOLLOW_BOT_PROFILE
) {
switch (thisObject.eventType) {
case EVENT_TYPES.FOLLOW_USER_PROFILE: {
case SA.projects.socialTrading.globals.eventTypes.FOLLOW_USER_PROFILE: {
if (thisObject.emitterUserProfileId === undefined) {
throw ('Emitter User Profile Id Not Provided.')
@@ -253,14 +224,14 @@ exports.newSocialTradingModulesEvent = function newSocialTradingModulesEvent() {
}
emitterUserProfile.addFollowing(
targetUserProfileId
thisObject.targetUserProfileId
)
targetUserProfile.addFollower(
emitterUserProfileId
thisObject.emitterUserProfileId
)
break
}
case EVENT_TYPES.UNFOLLOW_USER_PROFILE: {
case SA.projects.socialTrading.globals.eventTypes.UNFOLLOW_USER_PROFILE: {
if (thisObject.emitterUserProfileId === undefined) {
throw ('Emitter User Profile Id Not Provided.')
@@ -271,14 +242,14 @@ exports.newSocialTradingModulesEvent = function newSocialTradingModulesEvent() {
}
emitterUserProfile.removeFollowing(
targetUserProfileId
thisObject.targetUserProfileId
)
targetUserProfile.removeFollower(
emitterUserProfileId
thisObject.emitterUserProfileId
)
break
}
case EVENT_TYPES.FOLLOW_BOT_PROFILE: {
case SA.projects.socialTrading.globals.eventTypes.FOLLOW_BOT_PROFILE: {
if (thisObject.emitterBotProfileId === undefined) {
throw ('Emitter Bot Profile Id Not Provided.')
@@ -289,16 +260,16 @@ exports.newSocialTradingModulesEvent = function newSocialTradingModulesEvent() {
}
emitterBotProfile.addFollowing(
targetUserProfileId,
targetBotProfileId
thisObject.targetUserProfileId,
thisObject.targetBotProfileId
)
targetBotProfile.addFollower(
emitterUserProfileId,
emitterBotProfileId
thisObject.emitterUserProfileId,
thisObject.emitterBotProfileId
)
break
}
case EVENT_TYPES.UNFOLLOW_BOT_PROFILE: {
case SA.projects.socialTrading.globals.eventTypes.UNFOLLOW_BOT_PROFILE: {
if (thisObject.emitterBotProfileId === undefined) {
throw ('Emitter Bot Profile Id Not Provided.')
@@ -309,15 +280,15 @@ exports.newSocialTradingModulesEvent = function newSocialTradingModulesEvent() {
}
emitterBotProfile.removeFollowing(
targetBotProfileId
thisObject.targetBotProfileId
)
targetBotProfile.removeFollower(
emitterBotProfileId
thisObject.emitterBotProfileId
)
break
}
}
return
return true
}
}
@@ -327,39 +298,51 @@ exports.newSocialTradingModulesEvent = function newSocialTradingModulesEvent() {
*/
let targetPost
if (targetBotProfile !== undefined) {
targetPost = targetBotProfile.posts.get(thisObject.targetPostHash)
} else {
targetPost = targetUserProfile.posts.get(thisObject.targetPostHash)
}
if (targetPost === undefined) {
throw ('Target Post Not Found')
}
if (
thisObject.eventType === EVENT_TYPES.ADD_REACTION_LIKE ||
thisObject.eventType === EVENT_TYPES.ADD_REACTION_LOVE ||
thisObject.eventType === EVENT_TYPES.ADD_REACTION_HAHA ||
thisObject.eventType === EVENT_TYPES.ADD_REACTION_WOW ||
thisObject.eventType === EVENT_TYPES.ADD_REACTION_SAD ||
thisObject.eventType === EVENT_TYPES.ADD_REACTION_ANGRY ||
thisObject.eventType === EVENT_TYPES.ADD_REACTION_CARE
thisObject.eventType === SA.projects.socialTrading.globals.eventTypes.ADD_REACTION_LIKE ||
thisObject.eventType === SA.projects.socialTrading.globals.eventTypes.ADD_REACTION_LOVE ||
thisObject.eventType === SA.projects.socialTrading.globals.eventTypes.ADD_REACTION_HAHA ||
thisObject.eventType === SA.projects.socialTrading.globals.eventTypes.ADD_REACTION_WOW ||
thisObject.eventType === SA.projects.socialTrading.globals.eventTypes.ADD_REACTION_SAD ||
thisObject.eventType === SA.projects.socialTrading.globals.eventTypes.ADD_REACTION_ANGRY ||
thisObject.eventType === SA.projects.socialTrading.globals.eventTypes.ADD_REACTION_CARE
) {
if (targetBotProfile !== undefined) {
targetPost = targetBotProfile.posts.get(thisObject.targetPostHash)
} else {
targetPost = targetUserProfile.posts.get(thisObject.targetPostHash)
}
if (targetPost === undefined) {
throw ('Target Post Not Found')
}
targetPost.addReaction(thisObject.eventType - 100)
return
return true
}
if (
thisObject.eventType === EVENT_TYPES.REMOVE_REACTION_LIKE ||
thisObject.eventType === EVENT_TYPES.REMOVE_REACTION_LOVE ||
thisObject.eventType === EVENT_TYPES.REMOVE_REACTION_HAHA ||
thisObject.eventType === EVENT_TYPES.REMOVE_REACTION_WOW ||
thisObject.eventType === EVENT_TYPES.REMOVE_REACTION_SAD ||
thisObject.eventType === EVENT_TYPES.REMOVE_REACTION_ANGRY ||
thisObject.eventType === EVENT_TYPES.REMOVE_REACTION_CARE
thisObject.eventType === SA.projects.socialTrading.globals.eventTypes.REMOVE_REACTION_LIKE ||
thisObject.eventType === SA.projects.socialTrading.globals.eventTypes.REMOVE_REACTION_LOVE ||
thisObject.eventType === SA.projects.socialTrading.globals.eventTypes.REMOVE_REACTION_HAHA ||
thisObject.eventType === SA.projects.socialTrading.globals.eventTypes.REMOVE_REACTION_WOW ||
thisObject.eventType === SA.projects.socialTrading.globals.eventTypes.REMOVE_REACTION_SAD ||
thisObject.eventType === SA.projects.socialTrading.globals.eventTypes.REMOVE_REACTION_ANGRY ||
thisObject.eventType === SA.projects.socialTrading.globals.eventTypes.REMOVE_REACTION_CARE
) {
if (targetBotProfile !== undefined) {
targetPost = targetBotProfile.posts.get(thisObject.targetPostHash)
} else {
targetPost = targetUserProfile.posts.get(thisObject.targetPostHash)
}
if (targetPost === undefined) {
throw ('Target Post Not Found')
}
targetPost.removeReaction(thisObject.eventType - 200)
return
return true
}
}
@@ -368,13 +351,13 @@ exports.newSocialTradingModulesEvent = function newSocialTradingModulesEvent() {
Is is a Bot?
*/
if (
thisObject.eventType === EVENT_TYPES.ADD_BOT ||
thisObject.eventType === EVENT_TYPES.REMOVE_BOT ||
thisObject.eventType === EVENT_TYPES.ENABLE_BOT ||
thisObject.eventType === EVENT_TYPES.DISABLE_BOT
thisObject.eventType === SA.projects.socialTrading.globals.eventTypes.ADD_BOT ||
thisObject.eventType === SA.projects.socialTrading.globals.eventTypes.REMOVE_BOT ||
thisObject.eventType === SA.projects.socialTrading.globals.eventTypes.ENABLE_BOT ||
thisObject.eventType === SA.projects.socialTrading.globals.eventTypes.DISABLE_BOT
) {
switch (thisObject.eventType) {
case EVENT_TYPES.ADD_BOT: {
case SA.projects.socialTrading.globals.eventTypes.ADD_BOT: {
emitterUserProfile.addBot(
thisObject.emitterUserProfileId,
thisObject.emitterBotProfileId,
@@ -384,26 +367,26 @@ exports.newSocialTradingModulesEvent = function newSocialTradingModulesEvent() {
)
break
}
case EVENT_TYPES.REMOVE_BOT: {
case SA.projects.socialTrading.globals.eventTypes.REMOVE_BOT: {
emitterUserProfile.removeBot(
thisObject.emitterBotProfileId
)
break
}
case EVENT_TYPES.ENABLE_BOT: {
case SA.projects.socialTrading.globals.eventTypes.ENABLE_BOT: {
emitterUserProfile.enableBot(
thisObject.emitterBotProfileId
)
break
}
case EVENT_TYPES.DISABLE_BOT: {
case SA.projects.socialTrading.globals.eventTypes.DISABLE_BOT: {
emitterUserProfile.disableBot(
thisObject.emitterBotProfileId
)
break
}
}
return
return true
}
}
@@ -0,0 +1,44 @@
exports.newSocialTradingGlobalsEventTypes = function () {
let thisObject = {
/* Users Posts and Following Events */
NEW_USER_POST: 10,
REPLY_TO_USER_POST: 11,
REPOST_USER_POST: 12,
QUOTE_REPOST_USER_POST: 13,
REMOVE_USER_POST: 14,
FOLLOW_USER_PROFILE: 15,
UNFOLLOW_USER_PROFILE: 16,
/* Bots Posts and Following Events */
NEW_BOT_POST: 20,
REPLY_TO_BOT_POST: 21,
REPOST_BOT_POST: 22,
QUOTE_REPOST_BOT_POST: 23,
REMOVE_BOT_POST: 24,
FOLLOW_BOT_PROFILE: 25,
UNFOLLOW_BOT_PROFILE: 26,
/* Bots Management Events */
ADD_BOT: 50,
REMOVE_BOT: 51,
ENABLE_BOT: 52,
DISABLE_BOT: 53,
/* Add Reaction to Posts Events */
ADD_REACTION_LIKE: 100,
ADD_REACTION_LOVE: 101,
ADD_REACTION_HAHA: 102,
ADD_REACTION_WOW: 103,
ADD_REACTION_SAD: 104,
ADD_REACTION_ANGRY: 105,
ADD_REACTION_CARE: 106,
/* Remove Reaction to Posts Events */
REMOVE_REACTION_LIKE: 200,
REMOVE_REACTION_LOVE: 201,
REMOVE_REACTION_HAHA: 202,
REMOVE_REACTION_WOW: 203,
REMOVE_REACTION_SAD: 204,
REMOVE_REACTION_ANGRY: 205,
REMOVE_REACTION_CARE: 206
}
return thisObject
}