@nu-art/bug-report
Version:
45 lines (44 loc) • 2.15 kB
JavaScript
;
/*
* Permissions management system, define access level for each of
* your server apis, and restrict users by giving them access levels
*
* Copyright (C) 2020 Adam van der Kruk aka TacB0sS
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.SlackBugReportIntegrator = exports.SlackBugReportIntegrator_Class = void 0;
const ts_common_1 = require("@nu-art/ts-common");
const __1 = require("../..");
const backend_1 = require("@nu-art/slack/backend");
class SlackBugReportIntegrator_Class extends ts_common_1.Module {
constructor() {
super(...arguments);
this.openTicket = async (bugReport, logs, reporter) => {
if (bugReport.platforms && !bugReport.platforms.includes(__1.Platform_Slack))
return;
if (!this.config.channel)
throw new ts_common_1.ImplementationMissingException('Missing Slack Channel in bug report configurations');
let description = logs.reduce((carry, log, i) => {
return carry + '\n' + `<${log.path}|Click to view logs (${i})>`;
}, bugReport.subject + '\n' + bugReport.description);
if (reporter)
description += '\nReported by: ' + reporter;
await backend_1.ModuleBE_Slack.postMessage(description, this.config.channel);
return { platform: __1.Platform_Slack, issueId: (0, ts_common_1.generateHex)(32) };
};
}
}
exports.SlackBugReportIntegrator_Class = SlackBugReportIntegrator_Class;
exports.SlackBugReportIntegrator = new SlackBugReportIntegrator_Class();