newStaffLDB-API #48

Merged
fred.boniface merged 85 commits from newStaffLDB-API into main 2023-10-03 21:35:03 +01:00
Showing only changes of commit d395b65512 - Show all commits

View File

@ -1,6 +1,6 @@
/* eslint-disable no-useless-escape */ /* eslint-disable no-useless-escape */
const axios = require("axios"); const axios = require("axios");
const log = require("../utils/logs.utils"); import { logger } from "../utils/logger.utils";
const issueLabels = { const issueLabels = {
bug: 120, bug: 120,
@ -11,7 +11,7 @@ const issueLabels = {
}; };
async function processor(data) { async function processor(data) {
log.out("issueService.processor: Issue received", "info"); logger.debug("issueService.processor: Issue received");
let out = {}; let out = {};
out.labels = [issueLabels[data?.label] || 0, issueLabels["web-user"]]; out.labels = [issueLabels[data?.label] || 0, issueLabels["web-user"]];
out.title = data?.subject.replace(/<[^>]+>|[\*\$]/g, ""); out.title = data?.subject.replace(/<[^>]+>|[\*\$]/g, "");
@ -31,10 +31,10 @@ async function sendToGitea(body) {
/* Need to read the output from the POST and pass the result upwards to the /* Need to read the output from the POST and pass the result upwards to the
client.*/ client.*/
if (res.status == 201) { if (res.status == 201) {
log.out("issueService.sendToGitea: Issue sent to Gitea", "info"); logger.info("issueService.sendToGitea: Issue sent to Gitea");
return { status: res.status, message: "issue created" }; return { status: res.status, message: "issue created" };
} else { } else {
log.out(`issueService.sendToGitea: Fail to send issue: ${res.body}`, "err"); logger.error(res.body, "issueService.sendToGitea: Fail to send issue");
return { status: res.status, message: "issue not created" }; return { status: res.status, message: "issue not created" };
} }
} }