This repository has been archived on 2023-08-24. You can view files and clone it, but cannot push or open issues or pull requests.
OwlBoard/src/services/issue.services.js
Fred Boniface bbdaf4308a FullStack: Add response to issue API
Signed-off-by: Fred Boniface <fred@fjla.uk>
2023-01-31 11:32:35 +00:00

29 lines
776 B
JavaScript

const axios = require('axios')
async function processor(data) {
let out = {}
out.title = data.subject.replace(/<[^>]+>|[\*\$]/g, '');
out.body = data.msg.replace(/<[^>]+>|[\*\$]/g, '')
sendToGitea(out);
}
async function sendToGitea(body) {
let key = process.env.OWL_GIT_ISSUEBOT
let url = process.env.OWL_GIT_APIENDPOINT
let opts = {
headers: {
Authorization: key
}
}
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 = {
processor
}