Merge pull request #2227 from Tentacule23/develop
Contribution: app.contributeuserprofile
This commit is contained in:
3 files changed
+249
-236
No files matched your search
+177
-166
@@ -862,172 +862,6 @@ exports.newHttpInterface = function newHttpInterface() {
|
||||
break
|
||||
}
|
||||
|
||||
case 'UserUpdate': {
|
||||
try {
|
||||
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 error
|
||||
|
||||
/* Unsaving # */
|
||||
for (let i = 0; i < 10; i++) {
|
||||
commitMessage = commitMessage.replace('_SLASH_', '/')
|
||||
commitMessage = commitMessage.replace('_HASHTAG_', '#')
|
||||
}
|
||||
|
||||
updateUser()
|
||||
|
||||
async function updateUser() {
|
||||
|
||||
await doGithub()
|
||||
if (error !== undefined) {
|
||||
|
||||
let docs = {
|
||||
project: 'Foundations',
|
||||
category: 'Topic',
|
||||
type: 'App Error - Contribution Not Sent',
|
||||
anchor: undefined,
|
||||
placeholder: {}
|
||||
}
|
||||
console.log('respond with docs ')
|
||||
|
||||
respondWithDocsObject(docs, error)
|
||||
return
|
||||
}
|
||||
SA.projects.foundations.utilities.httpResponses.respondWithContent(JSON.stringify(global.DEFAULT_OK_RESPONSE), httpResponse)
|
||||
|
||||
}
|
||||
|
||||
async function doGithub() {
|
||||
|
||||
const { Octokit } = SA.nodeModules.octokit
|
||||
|
||||
const octokit = new Octokit({
|
||||
auth: token,
|
||||
userAgent: 'Superalgos Beta 12'
|
||||
})
|
||||
|
||||
const repo = 'Superalgos'
|
||||
const owner = 'Superalgos'
|
||||
const head = username + ':' + contributionsBranch
|
||||
const base = currentBranch
|
||||
const title = 'Contribution: ' + commitMessage
|
||||
const path = 'Projects/Governance/Plugins/User-Profiles/' + username + '.json' ;
|
||||
|
||||
const sha = await getSHA(path, octokit);
|
||||
let file = await SA.projects.communityPlugins.utilities.plugins.getPluginFileContent(
|
||||
'Governance',
|
||||
'User-Profiles',
|
||||
username + '.json'
|
||||
)
|
||||
|
||||
let buff = new Buffer.from(file, 'utf-8');
|
||||
let encodedFile = buff.toString('base64');
|
||||
|
||||
try {
|
||||
await octokit.repos.createOrUpdateFileContents({
|
||||
owner: username,
|
||||
repo: "Superalgos",
|
||||
path,
|
||||
message: title,
|
||||
content: encodedFile,
|
||||
sha,
|
||||
branch: base
|
||||
});
|
||||
} catch (err) {
|
||||
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)
|
||||
error = err
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
await octokit.pulls.create({
|
||||
owner,
|
||||
repo,
|
||||
title,
|
||||
head,
|
||||
base,
|
||||
});
|
||||
} catch (err) {
|
||||
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)
|
||||
error = err
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
async function getSHA(path, octokit) {
|
||||
let sha = ''
|
||||
try{
|
||||
const result = await octokit.repos.getContent({
|
||||
owner: username,
|
||||
repo: "Superalgos",
|
||||
path,
|
||||
ref: currentBranch
|
||||
});
|
||||
sha = result.data.sha
|
||||
return sha
|
||||
|
||||
} catch (err) {
|
||||
if (err.message === 'Not Found') {
|
||||
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)
|
||||
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)
|
||||
|
||||
let error = {
|
||||
result: 'Fail Because',
|
||||
message: err.message,
|
||||
stack: err.stack
|
||||
}
|
||||
SA.projects.foundations.utilities.httpResponses.respondWithContent(JSON.stringify(error), httpResponse)
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
case 'Checkout': {
|
||||
try {
|
||||
const currentBranch = unescape(requestPath[3])
|
||||
@@ -1439,6 +1273,183 @@ exports.newHttpInterface = function newHttpInterface() {
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
case 'contributeUserProfile': {
|
||||
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 error
|
||||
|
||||
/* Unsaving # */
|
||||
for (let i = 0; i < 10; i++) {
|
||||
commitMessage = commitMessage.replace('_SLASH_', '/')
|
||||
commitMessage = commitMessage.replace('_HASHTAG_', '#')
|
||||
}
|
||||
|
||||
await updateUser()
|
||||
|
||||
async function updateUser() {
|
||||
|
||||
await doGithub()
|
||||
if (error !== undefined) {
|
||||
|
||||
let docs = {
|
||||
project: 'Governance',
|
||||
category: 'Topic',
|
||||
type: 'Gov Error - Contribution Not Sent',
|
||||
anchor: undefined,
|
||||
placeholder: {}
|
||||
}
|
||||
console.log('respond with docs ')
|
||||
|
||||
respondWithDocsObject(docs, error)
|
||||
return
|
||||
}
|
||||
SA.projects.foundations.utilities.httpResponses.respondWithContent(JSON.stringify(global.DEFAULT_OK_RESPONSE), httpResponse)
|
||||
|
||||
}
|
||||
|
||||
async function doGithub() {
|
||||
|
||||
const { Octokit } = SA.nodeModules.octokit
|
||||
|
||||
const octokit = new Octokit({
|
||||
auth: token,
|
||||
userAgent: 'Superalgos Beta 12'
|
||||
})
|
||||
|
||||
const repo = 'Superalgos'
|
||||
const owner = 'Superalgos'
|
||||
const head = username + ':' + contributionsBranch
|
||||
const base = currentBranch
|
||||
const title = 'Contribution: ' + commitMessage
|
||||
const path = 'Projects/Governance/Plugins/User-Profiles/' + username + '.json' ;
|
||||
|
||||
const sha = await getSHA(path, octokit);
|
||||
let file = await SA.projects.communityPlugins.utilities.plugins.getPluginFileContent(
|
||||
'Governance',
|
||||
'User-Profiles',
|
||||
username + '.json'
|
||||
)
|
||||
|
||||
let buff = new Buffer.from(file, 'utf-8');
|
||||
let encodedFile = buff.toString('base64');
|
||||
|
||||
try {
|
||||
await octokit.repos.createOrUpdateFileContents({
|
||||
owner: username,
|
||||
repo: "Superalgos",
|
||||
path,
|
||||
message: title,
|
||||
content: encodedFile,
|
||||
sha,
|
||||
branch: base
|
||||
});
|
||||
} catch (err) {
|
||||
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)
|
||||
error = err
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
await octokit.pulls.create({
|
||||
owner,
|
||||
repo,
|
||||
title,
|
||||
head,
|
||||
base,
|
||||
});
|
||||
} catch (err) {
|
||||
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)
|
||||
error = err
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
async function getSHA(path, octokit) {
|
||||
let sha = ''
|
||||
try{
|
||||
const result = await octokit.repos.getContent({
|
||||
owner: username,
|
||||
repo: "Superalgos",
|
||||
path,
|
||||
ref: currentBranch
|
||||
});
|
||||
sha = result.data.sha
|
||||
return sha
|
||||
|
||||
} catch (err) {
|
||||
if (err.message === 'Not Found') {
|
||||
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)
|
||||
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)
|
||||
|
||||
let error = {
|
||||
result: 'Fail Because',
|
||||
message: err.message,
|
||||
stack: err.stack
|
||||
}
|
||||
SA.projects.foundations.utilities.httpResponses.respondWithContent(JSON.stringify(error), httpResponse)
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
case 'payContributors': {
|
||||
console.log('----------------------------------------------------------------------------------------------')
|
||||
console.log('DISTRIBUTION PROCESS STARTED')
|
||||
|
||||
@@ -26,7 +26,6 @@ function newFoundationsDocsCommmandInterface() {
|
||||
|
||||
function detectAppCommands() {
|
||||
if (checkContributeCommand() === undefined) { return true }
|
||||
if (checkUserUpdateCommand() === undefined) { return true }
|
||||
if (checkUpdateCommand() === undefined) { return true }
|
||||
if (fixAppSchema() === undefined) { return true }
|
||||
|
||||
@@ -99,75 +98,6 @@ function newFoundationsDocsCommmandInterface() {
|
||||
}
|
||||
}
|
||||
|
||||
function checkUserUpdateCommand() {
|
||||
if (UI.projects.education.spaces.docsSpace.commandInterface.command.toLowerCase() === 'app.help app.userupdate') {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'App Userupdate Command')
|
||||
return
|
||||
}
|
||||
if (UI.projects.education.spaces.docsSpace.commandInterface.command.indexOf('App.UserUpdate') !== 0 && UI.projects.education.spaces.docsSpace.commandInterface.command.indexOf('app.userupdate') !== 0) { return 'Not 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() === 'app.userupdate') {
|
||||
message = 'This is my UserUpdate to Superalgos'
|
||||
}
|
||||
|
||||
/* Find the Username and Password */
|
||||
let apisNode = UI.projects.foundations.spaces.designSpace.workspace.getHierarchyHeadByNodeType('APIs')
|
||||
if (apisNode === undefined) {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'App Error - Github Credentials Missing', 'Anchor Github Credentials Missing')
|
||||
return
|
||||
}
|
||||
if (apisNode.githubAPI === undefined) {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'App Error - Github Credentials Missing', 'Anchor Github Credentials Missing')
|
||||
return
|
||||
}
|
||||
|
||||
let config = JSON.parse(apisNode.githubAPI.config)
|
||||
if (config.username === undefined || config.username === "") {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'App Error - Github Credentials Missing', 'Anchor Github Credentials Missing')
|
||||
return
|
||||
}
|
||||
if (config.token === undefined || config.token === "") {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'App Error - Github Credentials Missing', 'Anchor Github Credentials Missing')
|
||||
return
|
||||
}
|
||||
|
||||
message = message.replaceAll('#', '_HASHTAG_')
|
||||
message = message.replaceAll('/', '_SLASH_')
|
||||
|
||||
httpRequest(
|
||||
undefined,
|
||||
'App/UserUpdate/' +
|
||||
message + '/' +
|
||||
config.username + '/' +
|
||||
config.token + '/' +
|
||||
UI.projects.education.spaces.docsSpace.currentBranch + '/' +
|
||||
UI.projects.education.spaces.docsSpace.contributionsBranch
|
||||
, onResponse)
|
||||
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'App Message - UserUpdate Request')
|
||||
|
||||
return
|
||||
|
||||
function onResponse(err, data) {
|
||||
/* Lets check the result of the call through the http interface */
|
||||
data = JSON.parse(data)
|
||||
if (err.result === GLOBAL.DEFAULT_OK_RESPONSE.result && data.result === GLOBAL.DEFAULT_OK_RESPONSE.result) {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'App Message - UserUpdate Done')
|
||||
} else {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo(
|
||||
data.docs.project,
|
||||
data.docs.category,
|
||||
data.docs.type,
|
||||
data.docs.anchor,
|
||||
undefined,
|
||||
data.docs.placeholder
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function checkUpdateCommand() {
|
||||
if (UI.projects.education.spaces.docsSpace.commandInterface.command.toLowerCase() === 'app.help app.update') {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'App Update Command')
|
||||
|
||||
@@ -24,6 +24,7 @@ function newGovernanceReportsCommmandInterface() {
|
||||
|
||||
function detectGovCommands() {
|
||||
if (checkPRsCommand() === undefined) { return true }
|
||||
if (checkUserUpdateCommand() === undefined) { return true }
|
||||
if (checkPayCommand() === undefined) { return true }
|
||||
|
||||
function checkPRsCommand() {
|
||||
@@ -118,6 +119,77 @@ function newGovernanceReportsCommmandInterface() {
|
||||
}
|
||||
}
|
||||
|
||||
function checkUserUpdateCommand() {
|
||||
if (UI.projects.education.spaces.docsSpace.commandInterface.command.toLowerCase() === 'gov.help gov.contributeUserProfile') {
|
||||
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' }
|
||||
|
||||
/* 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'
|
||||
}
|
||||
|
||||
UI.projects.governance.spaces.reportsSpace.sidePanelTab.close()
|
||||
UI.projects.education.spaces.docsSpace.sidePanelTab.open()
|
||||
|
||||
/* Find the Username and Password */
|
||||
let apisNode = UI.projects.foundations.spaces.designSpace.workspace.getHierarchyHeadByNodeType('APIs')
|
||||
if (apisNode === undefined) {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Governance', 'Topic', 'Gov Error - Github Credentials Missing', 'Anchor Github Credentials Missing')
|
||||
return
|
||||
}
|
||||
if (apisNode.githubAPI === undefined) {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Governance', 'Topic', 'Gov Error - Github Credentials Missing', 'Anchor Github Credentials Missing')
|
||||
return
|
||||
}
|
||||
|
||||
let config = JSON.parse(apisNode.githubAPI.config)
|
||||
if (config.username === undefined || config.username === "") {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Governance', 'Topic', 'Gov Error - Github Credentials Missing', 'Anchor Github Credentials Missing')
|
||||
return
|
||||
}
|
||||
if (config.token === undefined || config.token === "") {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Governance', 'Topic', 'Gov Error - Github Credentials Missing', 'Anchor Github Credentials Missing')
|
||||
return
|
||||
}
|
||||
|
||||
message = message.replaceAll('#', '_HASHTAG_')
|
||||
message = message.replaceAll('/', '_SLASH_')
|
||||
|
||||
let params = {
|
||||
method: 'contributeUserProfile',
|
||||
commitMessage: message,
|
||||
username: config.username,
|
||||
token: config.token,
|
||||
currentBranch: UI.projects.education.spaces.docsSpace.currentBranch,
|
||||
contributionsBranch: UI.projects.education.spaces.docsSpace.contributionsBranch
|
||||
}
|
||||
|
||||
let url = 'GOV' // We will access the default Client GOV endpoint.
|
||||
|
||||
httpRequest(JSON.stringify(params), url, onResponse)
|
||||
|
||||
function onResponse(err, data) {
|
||||
/* Lets check the result of the call through the http interface */
|
||||
data = JSON.parse(data)
|
||||
if (err.result === GLOBAL.DEFAULT_OK_RESPONSE.result && data.result === GLOBAL.DEFAULT_OK_RESPONSE.result) {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Governance', 'Topic', 'Gov Message - Contribute User Profile Done')
|
||||
} else {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo(
|
||||
data.docs.project,
|
||||
data.docs.category,
|
||||
data.docs.type,
|
||||
data.docs.anchor,
|
||||
undefined,
|
||||
data.docs.placeholder
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function checkPayCommand() {
|
||||
|
||||
let command = UI.projects.governance.spaces.reportsSpace.commandInterface.command.toLowerCase()
|
||||
|
||||
Reference in new issue
Block a user