From eaf51dbd72a7dbc21f66240e4b41d0f837ba16e6 Mon Sep 17 00:00:00 2001 From: Tentacule23 Date: Tue, 26 Oct 2021 17:26:10 -0400 Subject: [PATCH] userprofile app to gov Tentacule23 --- Platform/Client/httpInterface.js | 96 ++++++++----------- .../Spaces/Reports-Space/CommandInterface.js | 15 +-- 2 files changed, 50 insertions(+), 61 deletions(-) diff --git a/Platform/Client/httpInterface.js b/Platform/Client/httpInterface.js index 91a672e98..d90b5ad8a 100644 --- a/Platform/Client/httpInterface.js +++ b/Platform/Client/httpInterface.js @@ -1274,36 +1274,22 @@ exports.newHttpInterface = function newHttpInterface() { return } - case 'contributeUserProfile': { + case 'UserProfile': { try { - let commitMessage = params.message - const username = params.username - const token = params.token - const currentBranch = params.currentBranch - const contributionsBranch = params.contributionsBranch - - /* - let commitMessage = unescape(requestPath[3]) - const username = unescape(requestPath[4]) - const token = unescape(requestPath[5]) - const currentBranch = unescape(requestPath[6]) - const contributionsBranch = unescape(requestPath[7]) - */ + let mess = unescape(params.commitMessage) + const username = unescape(params.username) + const token = unescape(params.token) + const currentBranch = unescape(params.currentBranch) + const contributionsBranch = unescape(params.contributionsBranch) let error - /* Unsaving # */ - for (let i = 0; i < 10; i++) { - commitMessage = commitMessage.replace('_SLASH_', '/') - commitMessage = commitMessage.replace('_HASHTAG_', '#') - } - await updateUser() async function updateUser() { - await doGithub() + await doGithubUser() if (error !== undefined) { let docs = { @@ -1322,7 +1308,7 @@ exports.newHttpInterface = function newHttpInterface() { } - async function doGithub() { + async function doGithubUser() { const { Octokit } = SA.nodeModules.octokit @@ -1335,7 +1321,7 @@ exports.newHttpInterface = function newHttpInterface() { const owner = 'Superalgos' const head = username + ':' + contributionsBranch const base = currentBranch - const title = 'Contribution: ' + commitMessage + const title = 'Contribution: ' + mess const path = 'Projects/Governance/Plugins/User-Profiles/' + username + '.json' ; const sha = await getSHA(path, octokit); @@ -1362,14 +1348,14 @@ exports.newHttpInterface = function newHttpInterface() { if (err.stack.indexOf('Error User Commit') >= 0) { return } else { - console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> Method call produced an error.') - console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> err.stack = ' + err.stack) - console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> commitMessage = ' + commitMessage) - console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> username = ' + username) - console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> token starts with = ' + token.substring(0, 10) + '...') - console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> token ends with = ' + '...' + token.substring(token.length - 10)) - console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> currentBranch = ' + currentBranch) - console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> contributionsBranch = ' + contributionsBranch) + console.log('[ERROR] httpInterface -> Gov -> contributeUserProfile -> doGithub -> Method call produced an error.') + console.log('[ERROR] httpInterface -> Gov -> contributeUserProfile -> doGithub -> err.stack = ' + err.stack) + console.log('[ERROR] httpInterface -> Gov -> contributeUserProfile -> doGithub -> commitMessage = ' + mess) + console.log('[ERROR] httpInterface -> Gov -> contributeUserProfile -> doGithub -> username = ' + username) + console.log('[ERROR] httpInterface -> Gov -> contributeUserProfile -> doGithub -> token starts with = ' + token.substring(0, 10) + '...') + console.log('[ERROR] httpInterface -> Gov -> contributeUserProfile -> doGithub -> token ends with = ' + '...' + token.substring(token.length - 10)) + console.log('[ERROR] httpInterface -> Gov -> contributeUserProfile -> doGithub -> currentBranch = ' + currentBranch) + console.log('[ERROR] httpInterface -> Gov -> contributeUserProfile -> doGithub -> contributionsBranch = ' + contributionsBranch) error = err } } @@ -1386,14 +1372,14 @@ exports.newHttpInterface = function newHttpInterface() { if (err.stack.indexOf('A pull request already exists') >= 0) { return } else { - console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> Method call produced an error.') - console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> err.stack = ' + err.stack) - console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> commitMessage = ' + commitMessage) - console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> username = ' + username) - console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> token starts with = ' + token.substring(0, 10) + '...') - console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> token ends with = ' + '...' + token.substring(token.length - 10)) - console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> currentBranch = ' + currentBranch) - console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> contributionsBranch = ' + contributionsBranch) + console.log('[ERROR] httpInterface -> Gov -> contributeUserProfile -> doGithub -> Method call produced an error.') + console.log('[ERROR] httpInterface -> Gov -> contributeUserProfile -> doGithub -> err.stack = ' + err.stack) + console.log('[ERROR] httpInterface -> Gov -> contributeUserProfile -> doGithub -> commitMessage = ' + mess) + console.log('[ERROR] httpInterface -> Gov -> contributeUserProfile -> doGithub -> username = ' + username) + console.log('[ERROR] httpInterface -> Gov -> contributeUserProfile -> doGithub -> token starts with = ' + token.substring(0, 10) + '...') + console.log('[ERROR] httpInterface -> Gov -> contributeUserProfile -> doGithub -> token ends with = ' + '...' + token.substring(token.length - 10)) + console.log('[ERROR] httpInterface -> Gov -> contributeUserProfile -> doGithub -> currentBranch = ' + currentBranch) + console.log('[ERROR] httpInterface -> Gov -> contributeUserProfile -> doGithub -> contributionsBranch = ' + contributionsBranch) error = err } @@ -1417,28 +1403,28 @@ exports.newHttpInterface = function newHttpInterface() { console.log("[User Not Found] -> Creating new user") return sha } else { - console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> Method call produced an error.') - console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> err.stack = ' + err.stack) - console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> commitMessage = ' + commitMessage) - console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> username = ' + username) - console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> token starts with = ' + token.substring(0, 10) + '...') - console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> token ends with = ' + '...' + token.substring(token.length - 10)) - console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> currentBranch = ' + currentBranch) - console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> contributionsBranch = ' + contributionsBranch) + console.log('[ERROR] httpInterface -> Gov -> contributeUserProfile -> doGithub -> Method call produced an error.') + console.log('[ERROR] httpInterface -> Gov -> contributeUserProfile -> doGithub -> err.stack = ' + err.stack) + console.log('[ERROR] httpInterface -> Gov -> contributeUserProfile -> doGithub -> commitMessage = ' + mess) + console.log('[ERROR] httpInterface -> Gov -> contributeUserProfile -> doGithub -> username = ' + username) + console.log('[ERROR] httpInterface -> Gov -> contributeUserProfile -> doGithub -> token starts with = ' + token.substring(0, 10) + '...') + console.log('[ERROR] httpInterface -> Gov -> contributeUserProfile -> doGithub -> token ends with = ' + '...' + token.substring(token.length - 10)) + console.log('[ERROR] httpInterface -> Gov -> contributeUserProfile -> doGithub -> currentBranch = ' + currentBranch) + console.log('[ERROR] httpInterface -> Gov -> contributeUserProfile -> doGithub -> contributionsBranch = ' + contributionsBranch) return sha } } } } catch (err) { - console.log('[ERROR] httpInterface -> App -> Contribute -> Method call produced an error.') - console.log('[ERROR] httpInterface -> App -> Contribute -> err.stack = ' + err.stack) - console.log('[ERROR] httpInterface -> App -> Contribute -> commitMessage = ' + commitMessage) - console.log('[ERROR] httpInterface -> App -> Contribute -> username = ' + username) - console.log('[ERROR] httpInterface -> App -> Contribute -> token starts with = ' + token.substring(0, 10) + '...') - console.log('[ERROR] httpInterface -> App -> Contribute -> token ends with = ' + '...' + token.substring(token.length - 10)) - console.log('[ERROR] httpInterface -> App -> Contribute -> currentBranch = ' + currentBranch) - console.log('[ERROR] httpInterface -> App -> Contribute -> contributionsBranch = ' + contributionsBranch) + console.log('[ERROR] httpInterface -> Gov -> contributeUserProfile -> Method call produced an error.') + console.log('[ERROR] httpInterface -> Gov -> contributeUserProfile -> err.stack = ' + err.stack) + console.log('[ERROR] httpInterface -> Gov -> contributeUserProfile -> commitMessage = ' + mess) + console.log('[ERROR] httpInterface -> Gov -> contributeUserProfile -> username = ' + username) + console.log('[ERROR] httpInterface -> Gov -> contributeUserProfile -> token starts with = ' + token.substring(0, 10) + '...') + console.log('[ERROR] httpInterface -> Gov -> contributeUserProfile -> token ends with = ' + '...' + token.substring(token.length - 10)) + console.log('[ERROR] httpInterface -> Gov -> contributeUserProfile -> currentBranch = ' + currentBranch) + console.log('[ERROR] httpInterface -> Gov -> contributeUserProfile -> contributionsBranch = ' + contributionsBranch) let error = { result: 'Fail Because', diff --git a/Projects/Governance/UI/Spaces/Reports-Space/CommandInterface.js b/Projects/Governance/UI/Spaces/Reports-Space/CommandInterface.js index 4fb090822..c38ba481d 100644 --- a/Projects/Governance/UI/Spaces/Reports-Space/CommandInterface.js +++ b/Projects/Governance/UI/Spaces/Reports-Space/CommandInterface.js @@ -120,16 +120,19 @@ function newGovernanceReportsCommmandInterface() { } function checkUserUpdateCommand() { - if (UI.projects.education.spaces.docsSpace.commandInterface.command.toLowerCase() === 'gov.help gov.contributeUserProfile') { + + let command = UI.projects.governance.spaces.reportsSpace.commandInterface.command.toLowerCase() + + if (command === 'gov.help gov.userprofile') { UI.projects.education.spaces.docsSpace.navigateTo('Governance', 'Topic', 'Gov Contribute User Profile Command') return } - if (UI.projects.education.spaces.docsSpace.commandInterface.command.indexOf('gov.contributeUserProfile') !== 0 && UI.projects.education.spaces.docsSpace.commandInterface.command.indexOf('gov.contributeuserprofile') !== 0) { return 'Not Contribute Commands' } + if (command.indexOf('gov.userprofile') !== 0 ) { return 'Not User Contribute Commands' } /* Set up the commit message */ - let message = UI.projects.education.spaces.docsSpace.commandInterface.command.trim().substring(UI.projects.education.spaces.docsSpace.commandInterface.command.indexOf(' ') + 1, UI.projects.education.spaces.docsSpace.commandInterface.command.length) - if (message.toLowerCase() === 'gov.contributeuserprofile') { - message = 'This is my Contribute User Profile to Superalgos' + let message = command.trim().substring(command.indexOf(' ') + 1, command.length) + if (message.toLowerCase() === 'gov.userprofile') { + message = 'Automated Userprofile contribute process.' } UI.projects.governance.spaces.reportsSpace.sidePanelTab.close() @@ -160,7 +163,7 @@ function newGovernanceReportsCommmandInterface() { message = message.replaceAll('/', '_SLASH_') let params = { - method: 'contributeUserProfile', + method: 'UserProfile', commitMessage: message, username: config.username, token: config.token,