api key fix

This commit is contained in:
Jakub Klena 2024-05-24 01:24:08 +02:00
parent 2f659a164b
commit 9e2ab3ccea

View file

@ -8,7 +8,7 @@ exports.output = 1;
exports.click = false;
exports.author = 'Jakub Klena';
exports.icon = 'sign-out';
exports.options = { slack_channel: "C071KN2Q8SK", bot_name: "Flow DEMO", bot_icon: ":totaljs:" };
exports.options = { slack_channel: "C071KN2Q8SK", api_key: "", bot_name: "Flow DEMO", bot_icon: ":totaljs:" };
// Slack channel - where to post the messages, can be name like "backend-alerts"
// Bot Name - Name of the "user" that will post these messages, it should be based on which server it is running on.
// Bot Icon - We can use any slack icon (even custom ones uploaded by us) as the "user" profile picture
@ -19,6 +19,11 @@ exports.html = `<div class="padding">
<div data-jc="textbox" data-jc-path="slack_channel" data-jc-config="placeholder:name or id;required:true" class="m">Slack Channel</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div data-jc="textbox" data-jc-path="api_key" data-jc-config="placeholder:api key;required:true" class="m">API Key:</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div data-jc="textbox" data-jc-path="bot_name" data-jc-config="placeholder:Flow DEMO;required:false" class="m">Bot Name</div>
@ -69,17 +74,14 @@ exports.install = function(instance) {
}`;
let headers = {
'Content-type': `application/json`,
'Authorization': `Bearer xoxb-7060441089557-7144902656932-7IU6yMlvscrNtm5KrZxbm7Tf`
'Authorization': `Bearer ${instance.options.api_key}`
};
if (F.is4) {
let opt = {
'method': 'post',
'url': 'https://slack.com/api/chat.postMessage',
'headers': {
'Content-type': `application/json`,
'Authorization': `Bearer xoxb-7060441089557-7144902656932-7IU6yMlvscrNtm5KrZxbm7Tf`
},
'headers': headers,
'cookies': null,
'body': JSON.stringify(message),
'type': 'json',