diff --git a/UpNext.md b/UpNext.md index 2809959..d1565f6 100644 --- a/UpNext.md +++ b/UpNext.md @@ -4,7 +4,6 @@ * Alerts box should not be clickable, bar should be. * Issue page: Captcha. -* Issue page: Check for success and then redirect to /. * Enable text search for `locationName` on find-code page. * Responsive text sizes for boards. @@ -19,7 +18,10 @@ * Implement error pages. * Issue page: Submit using API. * Issue page: Collect diagnostics such as browser features etc. +* Add sanitizing to Gitea Issue API, currently considered to be unsafe. * Add Gitea Issue API +* Issue page: Check for success and then redirect to /. +* Add success test for Gitea Issue API and send the result onto the client. ## Backend: @@ -27,7 +29,5 @@ * DB Indexes: - "stations": 3ALPHA, STANOX, TIPLOC - "corpus": 3ALPHA, NLC, NLCDESC(TEXT) -* Add sanitizing to Gitea Issue API, currently considered to be unsafe. -* Add success test for Gitea Issue API and send the result onto the client. * Rewrite sanitizing functions to remove external dependancy. * Undo changed to make everything an array - frontend code to handle this. \ No newline at end of file diff --git a/src/services/issue.services.js b/src/services/issue.services.js index 52310b9..a3c16de 100644 --- a/src/services/issue.services.js +++ b/src/services/issue.services.js @@ -1,15 +1,10 @@ const axios = require('axios') -const clean = require('../utils/sanitizer.utils') async function processor(data) { let out = {} - out.title = await cleanData(data.subject) - out.body = await cleanData(data.msg) + out.title = data.subject.replace(/<[^>]+>|[\*\$]/g, ''); + out.body = data.msg.replace(/<[^>]+>|[\*\$]/g, '') sendToGitea(out); -} - -async function cleanData(data) { - return data //clean.cleanApiEndpointTxt(data) } async function sendToGitea(body) { @@ -20,8 +15,13 @@ async function sendToGitea(body) { Authorization: key } } - await axios.post(url, body, opts) + var res = await axios.post(url, body, opts) // Need to read the output from the POST and pass the result upwards to the client. + if (res.status == 201) { + return {status: res.status,message:"issue created"} + } else { + return {status: res.status,message:"issue not created"} + } } module.exports = { diff --git a/static/js/issue.js b/static/js/issue.js index a8f65a5..162a100 100644 --- a/static/js/issue.js +++ b/static/js/issue.js @@ -33,12 +33,11 @@ async function getBrowserData() { async function preflight(data) { document.getElementById("pre_subject").textContent = data.formData.subject pre_msg = `UserAgent: ${data.browserData.userAgent} - \nUserAgentData: ${data.browserData.userAgentData} - \nlocalStorage Avail: ${data.browserData.localStorage} - \nsessionStorage Avail: ${data.browserData.sessionStorage} - \nViewport size: ${data.browserData.viewport} - \nUser message:\n - ${data.formData.message}` + \nUserAgentData: ${data.browserData.userAgentData} + \nlocalStorage Avail: ${data.browserData.localStorage} + \nsessionStorage Avail: ${data.browserData.sessionStorage} + \nViewport size: ${data.browserData.viewport} + \nUser message:\n\n${data.formData.message}` document.getElementById("pre_message").innerText = pre_msg hideLoading() document.getElementById("preflight").style = "display: block" @@ -73,6 +72,16 @@ async function send() { redirect: 'follow', body: payload } - await fetch("/api/v1/issue", opt) - hideLoading(); + var res = await fetch("/api/v1/issue", opt) + if (res.status == 200) { + setLoadingDesc("Success") + await delay(2500) + window.location.replace("/") + } else { + setLoadingDesc("Error") + navigator.vibrate(1500) + await delay(2500) + hideLoading() + document.getElementById("preflight").style = "display: none;" + } } \ No newline at end of file