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

Contribution: Bug Fixed when a plugin file is not found.
This commit is contained in:
Luis Fernando Molina authored and GitHub committed 2021-08-26 05:23:58 -04:00
commit c158a6756a
6 files changed
+107 -38

No files matched your search

+8 -1
View File
@@ -1388,7 +1388,14 @@ exports.newHttpInterface = function newHttpInterface() {
project,
folder,
fileName
)
).catch(err => {
let error = {
result: 'Fail Because',
message: err
}
respondWithContent(JSON.stringify(error), httpResponse)
return
})
respondWithContent(response, httpResponse)
+53 -7
View File
@@ -24,13 +24,20 @@ exports.newEvent = function newEvent() {
QUOTE_REPOST_TRADE: 23,
FOLLOW_USER_PROFILE_TRADE_POSTS: 24,
UNFOLLOW_USER_PROFILE_TRADE_POSTS: 25,
REACTION_LIKE: 100,
REACTION_LOVE: 101,
REACTION_HAHA: 102,
REACTION_WOW: 103,
REACTION_SAD: 104,
REACTION_ANGRY: 105,
REACTION_HUG: 106
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_HUG: 106,
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_HUG: 206
}
return thisObject
@@ -152,5 +159,44 @@ exports.newEvent = function newEvent() {
}
return
}
/*
Is is a Reaction?
*/
if (
event.eventType === EVENT_TYPES.ADD_REACTION_LIKE ||
event.eventType === EVENT_TYPES.ADD_REACTION_LOVE ||
event.eventType === EVENT_TYPES.ADD_REACTION_HAHA ||
event.eventType === EVENT_TYPES.ADD_REACTION_WOW ||
event.eventType === EVENT_TYPES.ADD_REACTION_SAD ||
event.eventType === EVENT_TYPES.ADD_REACTION_ANGRY ||
event.eventType === EVENT_TYPES.ADD_REACTION_HUG
) {
let targetPost = NT.memory.POSTS.get(event.targetPostHash)
if (targetPost === undefined) {
throw ('Target Post Not Found')
}
targetPost.addReaction(event.eventType - 100)
return
}
if (
event.eventType === EVENT_TYPES.REMOVE_REACTION_LIKE ||
event.eventType === EVENT_TYPES.REMOVE_REACTION_LOVE ||
event.eventType === EVENT_TYPES.REMOVE_REACTION_HAHA ||
event.eventType === EVENT_TYPES.REMOVE_REACTION_WOW ||
event.eventType === EVENT_TYPES.REMOVE_REACTION_SAD ||
event.eventType === EVENT_TYPES.REMOVE_REACTION_ANGRY ||
event.eventType === EVENT_TYPES.REMOVE_REACTION_HUG
) {
let targetPost = NT.memory.POSTS.get(event.targetPostHash)
if (targetPost === undefined) {
throw ('Target Post Not Found')
}
targetPost.removeReaction(event.eventType - 200)
return
}
}
}
+42
View File
@@ -8,6 +8,9 @@ exports.newPost = function newPost() {
timestamp: undefined,
replies: undefined,
targetPost: undefined,
reactionsCount: undefined,
addReaction: addReaction,
removeReactions: removeReaction,
initialize: initialize,
finalize: finalize
}
@@ -23,6 +26,25 @@ exports.newPost = function newPost() {
QUOTE_REPOST_TRADE: 23
}
const REACTION_TYPES = {
REACTION_LIKE: 0,
REACTION_LOVE: 1,
REACTION_HAHA: 2,
REACTION_WOW: 3,
REACTION_SAD: 4,
REACTION_ANGRY: 5,
REACTION_HUG: 6
}
thisObject.reactionsCount = new Map()
thisObject.reactionsCount.set(REACTION_TYPES.REACTION_LIKE, 0)
thisObject.reactionsCount.set(REACTION_TYPES.REACTION_LOVE, 0)
thisObject.reactionsCount.set(REACTION_TYPES.REACTION_HAHA, 0)
thisObject.reactionsCount.set(REACTION_TYPES.REACTION_WOW, 0)
thisObject.reactionsCount.set(REACTION_TYPES.REACTION_SAD, 0)
thisObject.reactionsCount.set(REACTION_TYPES.REACTION_ANGRY, 0)
thisObject.reactionsCount.set(REACTION_TYPES.REACTION_HUG, 0)
return thisObject
function finalize() {
@@ -77,4 +99,24 @@ exports.newPost = function newPost() {
thisObject.targetPost.replies.push(thisObject)
}
}
function addReaction(reactionType) {
let reactionCount = thisObject.reactionsCount.get(reactionType)
if (reactionCount === undefined) {
throw ('Reaction Type Not Supported.')
}
thisObject.reactionsCount.set(reactionType, reactionsCount + 1)
}
function removeReaction(reactionType) {
let reactionCount = thisObject.reactionsCount.get(reactionType)
if (reactionCount === undefined) {
throw ('Reaction Type Not Supported.')
}
thisObject.reactionsCount.set(reactionType, reactionsCount - 1)
}
}
+1 -1
View File
@@ -38,7 +38,7 @@ exports.newFoundationsUtilitiesPlugins = function () {
function onFileRead(err, file) {
if (err) {
console.log('[WARN] getPluginFileContent -> File not Found -> Path = ' + path)
reject()
reject('File not Found')
return
}
resolve(file.toString())
@@ -1214,34 +1214,6 @@
"isRunning": false
}
}
},
{
"type": "Plugin File",
"name": "test",
"config": "{\"project\":\"Governance\",\"fileName\":\"test\",\"folderName\":\"User-Profiles\",\"nodeType\":\"User Profile\",\"saveWithWorkspace\":true}",
"project": "Foundations",
"id": "752c1c55-e983-4ead-a52c-4193015469fc",
"savedPayload": {
"position": {
"x": 35572.314597728066,
"y": 10724.773136533244
},
"targetPosition": {
"x": 35605.314597728066,
"y": 10678.773136533244
},
"floatingObject": {
"isPinned": false,
"isFrozen": false,
"isCollapsed": false,
"angleToParent": 2,
"distanceToParent": 3,
"arrangementStyle": 0
},
"uiObject": {
"isRunning": false
}
}
}
],
"id": "2c899fe9-1335-4e9f-b2d0-45a83e478fd0",
@@ -360,7 +360,9 @@ function newGovernanceUserProfileSpace() {
}).catch(function (err) {
const message = err.message + ' - ' + 'Can not access BSC SCAN servers.'
console.log(message)
userProfile.payload.uiObject.setErrorMessage(message, 1000)
if (userProfile.payload !== undefined) {
userProfile.payload.uiObject.setErrorMessage(message, 1000)
}
waitingForResponses--
});
}