mirror of
https://github.com/wekan/wekan.git
synced 2025-12-19 17:00:13 +01:00
Merge pull request #2665 from whowillcare/master
Add Feature: complete the original author's webhook functions and add two-way webhook type
This commit is contained in:
commit
bfbe32e1ec
10 changed files with 221 additions and 73 deletions
|
|
@ -18,6 +18,8 @@ template(name="setting")
|
||||||
a.js-setting-menu(data-id="announcement-setting") {{_ 'admin-announcement'}}
|
a.js-setting-menu(data-id="announcement-setting") {{_ 'admin-announcement'}}
|
||||||
li
|
li
|
||||||
a.js-setting-menu(data-id="layout-setting") {{_ 'layout'}}
|
a.js-setting-menu(data-id="layout-setting") {{_ 'layout'}}
|
||||||
|
li
|
||||||
|
a.js-setting-menu(data-id="webhook-setting") {{_ 'global-webhook'}}
|
||||||
.main-body
|
.main-body
|
||||||
if loading.get
|
if loading.get
|
||||||
+spinner
|
+spinner
|
||||||
|
|
@ -31,6 +33,12 @@ template(name="setting")
|
||||||
+announcementSettings
|
+announcementSettings
|
||||||
else if layoutSetting.get
|
else if layoutSetting.get
|
||||||
+layoutSettings
|
+layoutSettings
|
||||||
|
else if webhookSetting.get
|
||||||
|
+webhookSettings
|
||||||
|
|
||||||
|
template(name="webhookSettings")
|
||||||
|
span
|
||||||
|
+outgoingWebhooksPopup
|
||||||
|
|
||||||
template(name="general")
|
template(name="general")
|
||||||
ul#registration-setting.setting-detail
|
ul#registration-setting.setting-detail
|
||||||
|
|
|
||||||
|
|
@ -7,11 +7,13 @@ BlazeComponent.extendComponent({
|
||||||
this.accountSetting = new ReactiveVar(false);
|
this.accountSetting = new ReactiveVar(false);
|
||||||
this.announcementSetting = new ReactiveVar(false);
|
this.announcementSetting = new ReactiveVar(false);
|
||||||
this.layoutSetting = new ReactiveVar(false);
|
this.layoutSetting = new ReactiveVar(false);
|
||||||
|
this.webhookSetting = new ReactiveVar(false);
|
||||||
|
|
||||||
Meteor.subscribe('setting');
|
Meteor.subscribe('setting');
|
||||||
Meteor.subscribe('mailServer');
|
Meteor.subscribe('mailServer');
|
||||||
Meteor.subscribe('accountSettings');
|
Meteor.subscribe('accountSettings');
|
||||||
Meteor.subscribe('announcements');
|
Meteor.subscribe('announcements');
|
||||||
|
Meteor.subscribe('globalwebhooks');
|
||||||
},
|
},
|
||||||
|
|
||||||
setError(error) {
|
setError(error) {
|
||||||
|
|
@ -83,6 +85,7 @@ BlazeComponent.extendComponent({
|
||||||
this.accountSetting.set('account-setting' === targetID);
|
this.accountSetting.set('account-setting' === targetID);
|
||||||
this.announcementSetting.set('announcement-setting' === targetID);
|
this.announcementSetting.set('announcement-setting' === targetID);
|
||||||
this.layoutSetting.set('layout-setting' === targetID);
|
this.layoutSetting.set('layout-setting' === targetID);
|
||||||
|
this.webhookSetting.set('webhook-setting' === targetID);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -135,22 +135,30 @@ template(name="archiveBoardPopup")
|
||||||
template(name="outgoingWebhooksPopup")
|
template(name="outgoingWebhooksPopup")
|
||||||
each integrations
|
each integrations
|
||||||
form.integration-form
|
form.integration-form
|
||||||
if title
|
a.flex
|
||||||
h4 {{title}}
|
span {{_ 'disable-webhook'}}
|
||||||
|
b
|
||||||
|
.materialCheckBox(class="{{#unless enabled}}is-checked{{/unless}}")
|
||||||
|
input.js-outgoing-webhooks-title(placeholder="{{_ 'webhook-title'}}" type="text" name="title" value=title)
|
||||||
|
input.js-outgoing-webhooks-url(type="text" name="url" value=url autofocus)
|
||||||
|
input.js-outgoing-webhooks-token(placeholder="{{_ 'webhook-token' }}" type="text" value=token name="token")
|
||||||
|
select.js-outgoing-webhooks-type(name="type")
|
||||||
|
each _type in types
|
||||||
|
if($eq _type this.type)
|
||||||
|
option(value=_type selected="selected") {{_ _type}}
|
||||||
else
|
else
|
||||||
h4 {{_ 'no-name'}}
|
option(value=_type) {{_ _type}}
|
||||||
label
|
input(type="hidden" value=this.type name="_type")
|
||||||
| URL
|
|
||||||
input.js-outgoing-webhooks-url(type="text" name="url" value=url)
|
|
||||||
input(type="hidden" value=_id name="id")
|
input(type="hidden" value=_id name="id")
|
||||||
input.primary.wide(type="submit" value="{{_ 'save'}}")
|
input.primary.wide(type="submit" value="{{_ 'save'}}")
|
||||||
form.integration-form
|
form.integration-form
|
||||||
h4
|
input.js-outgoing-webhooks-title(placeholder="{{_ 'webhook-title'}}" type="text" name="title" autofocus)
|
||||||
| {{_ 'new-outgoing-webhook'}}
|
input.js-outgoing-webhooks-url(placeholder="{{_ 'URL' }}" type="text" name="url")
|
||||||
label
|
input.js-outgoing-webhooks-token(placeholder="{{_ 'webhook-token' }}" type="text" name="token")
|
||||||
| URL
|
select.js-outgoing-webhooks-type(name="type")
|
||||||
input.js-outgoing-webhooks-url(type="text" name="url" autofocus)
|
each _type in types
|
||||||
input.primary.wide(type="submit" value="{{_ 'save'}}")
|
option(value=_type) {{_ _type}}
|
||||||
|
input.primary.wide(type="submit" value="{{_ 'create'}}")
|
||||||
|
|
||||||
template(name="boardMenuPopup")
|
template(name="boardMenuPopup")
|
||||||
ul.pop-over-list
|
ul.pop-over-list
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
Sidebar = null;
|
Sidebar = null;
|
||||||
|
|
||||||
const defaultView = 'home';
|
const defaultView = 'home';
|
||||||
|
const MCB = '.materialCheckBox';
|
||||||
|
const CKCLS = 'is-checked';
|
||||||
|
|
||||||
const viewTitles = {
|
const viewTitles = {
|
||||||
filter: 'filter-cards',
|
filter: 'filter-cards',
|
||||||
|
|
@ -280,44 +282,71 @@ Template.membersWidget.events({
|
||||||
});
|
});
|
||||||
|
|
||||||
BlazeComponent.extendComponent({
|
BlazeComponent.extendComponent({
|
||||||
|
boardId() {
|
||||||
|
return Session.get('currentBoard') || Integrations.Const.GLOBAL_WEBHOOK_ID;
|
||||||
|
},
|
||||||
integrations() {
|
integrations() {
|
||||||
const boardId = Session.get('currentBoard');
|
const boardId = this.boardId();
|
||||||
return Integrations.find({ boardId: `${boardId}` }).fetch();
|
return Integrations.find({ boardId: `${boardId}` }).fetch();
|
||||||
},
|
},
|
||||||
|
types() {
|
||||||
integration(id) {
|
return Integrations.Const.WEBHOOK_TYPES;
|
||||||
const boardId = Session.get('currentBoard');
|
},
|
||||||
return Integrations.findOne({ _id: id, boardId: `${boardId}` });
|
integration(cond) {
|
||||||
|
const boardId = this.boardId();
|
||||||
|
const condition = { boardId, ...cond };
|
||||||
|
for (const k in condition) {
|
||||||
|
if (!condition[k]) delete condition[k];
|
||||||
|
}
|
||||||
|
return Integrations.findOne(condition);
|
||||||
|
},
|
||||||
|
onCreated() {
|
||||||
|
this.disabled = new ReactiveVar(false);
|
||||||
},
|
},
|
||||||
|
|
||||||
events() {
|
events() {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
|
'click a.flex'(evt) {
|
||||||
|
this.disabled.set(!this.disabled.get());
|
||||||
|
$(evt.target).toggleClass(CKCLS, this.disabled.get());
|
||||||
|
},
|
||||||
submit(evt) {
|
submit(evt) {
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
const url = evt.target.url.value;
|
const url = evt.target.url.value;
|
||||||
const boardId = Session.get('currentBoard');
|
const boardId = this.boardId();
|
||||||
let id = null;
|
let id = null;
|
||||||
let integration = null;
|
let integration = null;
|
||||||
|
const title = evt.target.title.value;
|
||||||
|
const token = evt.target.token.value;
|
||||||
|
const type = evt.target.type.value;
|
||||||
|
const enabled = !this.disabled.get();
|
||||||
|
let remove = false;
|
||||||
|
const values = {
|
||||||
|
url,
|
||||||
|
type,
|
||||||
|
token,
|
||||||
|
title,
|
||||||
|
enabled,
|
||||||
|
};
|
||||||
if (evt.target.id) {
|
if (evt.target.id) {
|
||||||
id = evt.target.id.value;
|
id = evt.target.id.value;
|
||||||
integration = this.integration(id);
|
integration = this.integration({ _id: id });
|
||||||
if (url) {
|
remove = !url;
|
||||||
Integrations.update(integration._id, {
|
} else if (url) {
|
||||||
$set: {
|
integration = this.integration({ url, token });
|
||||||
url: `${url}`,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
Integrations.remove(integration._id);
|
|
||||||
}
|
}
|
||||||
|
if (remove) {
|
||||||
|
Integrations.remove(integration._id);
|
||||||
|
} else if (integration && integration._id) {
|
||||||
|
Integrations.update(integration._id, {
|
||||||
|
$set: values,
|
||||||
|
});
|
||||||
} else if (url) {
|
} else if (url) {
|
||||||
Integrations.insert({
|
Integrations.insert({
|
||||||
|
...values,
|
||||||
userId: Meteor.userId(),
|
userId: Meteor.userId(),
|
||||||
enabled: true,
|
enabled: true,
|
||||||
type: 'outgoing-webhooks',
|
boardId,
|
||||||
url: `${url}`,
|
|
||||||
boardId: `${boardId}`,
|
|
||||||
activities: ['all'],
|
activities: ['all'],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -474,12 +503,12 @@ BlazeComponent.extendComponent({
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
this.currentBoard.allowsSubtasks = !this.currentBoard.allowsSubtasks;
|
this.currentBoard.allowsSubtasks = !this.currentBoard.allowsSubtasks;
|
||||||
this.currentBoard.setAllowsSubtasks(this.currentBoard.allowsSubtasks);
|
this.currentBoard.setAllowsSubtasks(this.currentBoard.allowsSubtasks);
|
||||||
$('.js-field-has-subtasks .materialCheckBox').toggleClass(
|
$(`.js-field-has-subtasks ${MCB}`).toggleClass(
|
||||||
'is-checked',
|
CKCLS,
|
||||||
this.currentBoard.allowsSubtasks,
|
this.currentBoard.allowsSubtasks,
|
||||||
);
|
);
|
||||||
$('.js-field-has-subtasks').toggleClass(
|
$('.js-field-has-subtasks').toggleClass(
|
||||||
'is-checked',
|
CKCLS,
|
||||||
this.currentBoard.allowsSubtasks,
|
this.currentBoard.allowsSubtasks,
|
||||||
);
|
);
|
||||||
$('.js-field-deposit-board').prop(
|
$('.js-field-deposit-board').prop(
|
||||||
|
|
@ -515,15 +544,12 @@ BlazeComponent.extendComponent({
|
||||||
];
|
];
|
||||||
options.forEach(function(element) {
|
options.forEach(function(element) {
|
||||||
if (element !== value) {
|
if (element !== value) {
|
||||||
$(`#${element} .materialCheckBox`).toggleClass(
|
$(`#${element} ${MCB}`).toggleClass(CKCLS, false);
|
||||||
'is-checked',
|
$(`#${element}`).toggleClass(CKCLS, false);
|
||||||
false,
|
|
||||||
);
|
|
||||||
$(`#${element}`).toggleClass('is-checked', false);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$(`#${value} .materialCheckBox`).toggleClass('is-checked', true);
|
$(`#${value} ${MCB}`).toggleClass(CKCLS, true);
|
||||||
$(`#${value}`).toggleClass('is-checked', true);
|
$(`#${value}`).toggleClass(CKCLS, true);
|
||||||
this.currentBoard.setPresentParentTask(value);
|
this.currentBoard.setPresentParentTask(value);
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,6 @@ Utils = {
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
MAX_IMAGE_PIXEL: Meteor.settings.public.MAX_IMAGE_PIXEL,
|
MAX_IMAGE_PIXEL: Meteor.settings.public.MAX_IMAGE_PIXEL,
|
||||||
COMPRESS_RATIO: Meteor.settings.public.IMAGE_COMPRESS_RATIO,
|
COMPRESS_RATIO: Meteor.settings.public.IMAGE_COMPRESS_RATIO,
|
||||||
processUploadedAttachment(card, fileObj, callback) {
|
processUploadedAttachment(card, fileObj, callback) {
|
||||||
|
|
|
||||||
|
|
@ -510,9 +510,14 @@
|
||||||
"email-smtp-test-text": "You have successfully sent an email",
|
"email-smtp-test-text": "You have successfully sent an email",
|
||||||
"error-invitation-code-not-exist": "Invitation code doesn't exist",
|
"error-invitation-code-not-exist": "Invitation code doesn't exist",
|
||||||
"error-notAuthorized": "You are not authorized to view this page.",
|
"error-notAuthorized": "You are not authorized to view this page.",
|
||||||
|
"webhook-title": "Webhook Name",
|
||||||
|
"webhook-token": "Token (Optional for Authentication)",
|
||||||
"outgoing-webhooks": "Outgoing Webhooks",
|
"outgoing-webhooks": "Outgoing Webhooks",
|
||||||
|
"bidirectional-webhooks": "Two-Way Webhooks",
|
||||||
"outgoingWebhooksPopup-title": "Outgoing Webhooks",
|
"outgoingWebhooksPopup-title": "Outgoing Webhooks",
|
||||||
"boardCardTitlePopup-title": "Card Title Filter",
|
"boardCardTitlePopup-title": "Card Title Filter",
|
||||||
|
"disable-webhook": "Disable This Webhook",
|
||||||
|
"global-webhook": "Global Webhooks",
|
||||||
"new-outgoing-webhook": "New Outgoing Webhook",
|
"new-outgoing-webhook": "New Outgoing Webhook",
|
||||||
"no-name": "(Unknown)",
|
"no-name": "(Unknown)",
|
||||||
"Node_version": "Node version",
|
"Node_version": "Node version",
|
||||||
|
|
|
||||||
|
|
@ -184,10 +184,11 @@ if (Meteor.isServer) {
|
||||||
// it's person at himself, ignore it?
|
// it's person at himself, ignore it?
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const user = Users.findOne(username) || Users.findOne({ username });
|
const atUser =
|
||||||
const uid = user && user._id;
|
Users.findOne(username) || Users.findOne({ username });
|
||||||
|
const uid = atUser && atUser._id;
|
||||||
params.atUsername = username;
|
params.atUsername = username;
|
||||||
params.atEmails = user.emails;
|
params.atEmails = atUser.emails;
|
||||||
if (board.hasMember(uid)) {
|
if (board.hasMember(uid)) {
|
||||||
title = 'act-atUserComment';
|
title = 'act-atUserComment';
|
||||||
watchers = _.union(watchers, [uid]);
|
watchers = _.union(watchers, [uid]);
|
||||||
|
|
@ -268,13 +269,23 @@ if (Meteor.isServer) {
|
||||||
});
|
});
|
||||||
|
|
||||||
const integrations = Integrations.find({
|
const integrations = Integrations.find({
|
||||||
boardId: board._id,
|
boardId: { $in: [board._id, Integrations.Const.GLOBAL_WEBHOOK_ID] },
|
||||||
type: 'outgoing-webhooks',
|
// type: 'outgoing-webhooks', // all types
|
||||||
enabled: true,
|
enabled: true,
|
||||||
activities: { $in: [description, 'all'] },
|
activities: { $in: [description, 'all'] },
|
||||||
}).fetch();
|
}).fetch();
|
||||||
if (integrations.length > 0) {
|
if (integrations.length > 0) {
|
||||||
Meteor.call('outgoingWebhooks', integrations, description, params);
|
integrations.forEach(integration => {
|
||||||
|
Meteor.call(
|
||||||
|
'outgoingWebhooks',
|
||||||
|
integration,
|
||||||
|
description,
|
||||||
|
params,
|
||||||
|
() => {
|
||||||
|
return;
|
||||||
|
},
|
||||||
|
);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -88,16 +88,30 @@ Integrations.attachSchema(
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
Integrations.Const = {
|
||||||
|
GLOBAL_WEBHOOK_ID: '_global',
|
||||||
|
ONEWAY: 'outgoing-webhooks',
|
||||||
|
TWOWAY: 'bidirectional-webhooks',
|
||||||
|
get WEBHOOK_TYPES() {
|
||||||
|
return [this.ONEWAY, this.TWOWAY];
|
||||||
|
},
|
||||||
|
};
|
||||||
|
const permissionHelper = {
|
||||||
|
allow(userId, doc) {
|
||||||
|
const user = Users.findOne(userId);
|
||||||
|
const isAdmin = user && Meteor.user().isAdmin;
|
||||||
|
return isAdmin || allowIsBoardAdmin(userId, Boards.findOne(doc.boardId));
|
||||||
|
},
|
||||||
|
};
|
||||||
Integrations.allow({
|
Integrations.allow({
|
||||||
insert(userId, doc) {
|
insert(userId, doc) {
|
||||||
return allowIsBoardAdmin(userId, Boards.findOne(doc.boardId));
|
return permissionHelper.allow(userId, doc);
|
||||||
},
|
},
|
||||||
update(userId, doc) {
|
update(userId, doc) {
|
||||||
return allowIsBoardAdmin(userId, Boards.findOne(doc.boardId));
|
return permissionHelper.allow(userId, doc);
|
||||||
},
|
},
|
||||||
remove(userId, doc) {
|
remove(userId, doc) {
|
||||||
return allowIsBoardAdmin(userId, Boards.findOne(doc.boardId));
|
return permissionHelper.allow(userId, doc);
|
||||||
},
|
},
|
||||||
fetch: ['boardId'],
|
fetch: ['boardId'],
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,19 @@ const postCatchError = Meteor.wrapAsync((url, options, resolve) => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const Lock = {
|
||||||
|
_lock: {},
|
||||||
|
has(id) {
|
||||||
|
return !!this._lock[id];
|
||||||
|
},
|
||||||
|
set(id) {
|
||||||
|
this._lock[id] = 1;
|
||||||
|
},
|
||||||
|
unset(id) {
|
||||||
|
delete this._lock[id];
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
const webhooksAtbts = (process.env.WEBHOOKS_ATTRIBUTES &&
|
const webhooksAtbts = (process.env.WEBHOOKS_ATTRIBUTES &&
|
||||||
process.env.WEBHOOKS_ATTRIBUTES.split(',')) || [
|
process.env.WEBHOOKS_ATTRIBUTES.split(',')) || [
|
||||||
'cardId',
|
'cardId',
|
||||||
|
|
@ -20,15 +33,49 @@ const webhooksAtbts = (process.env.WEBHOOKS_ATTRIBUTES &&
|
||||||
'commentId',
|
'commentId',
|
||||||
'swimlaneId',
|
'swimlaneId',
|
||||||
];
|
];
|
||||||
|
const responseFunc = 'reactOnHookResponse';
|
||||||
Meteor.methods({
|
Meteor.methods({
|
||||||
outgoingWebhooks(integrations, description, params) {
|
[responseFunc](data) {
|
||||||
check(integrations, Array);
|
check(data, Object);
|
||||||
|
const paramCommentId = data.commentId;
|
||||||
|
const paramCardId = data.cardId;
|
||||||
|
const paramBoardId = data.boardId;
|
||||||
|
const newComment = data.comment;
|
||||||
|
if (paramCardId && paramBoardId && newComment) {
|
||||||
|
// only process data with the cardid, boardid and comment text, TODO can expand other functions here to react on returned data
|
||||||
|
const comment = CardComments.findOne({
|
||||||
|
_id: paramCommentId,
|
||||||
|
cardId: paramCardId,
|
||||||
|
boardId: paramBoardId,
|
||||||
|
});
|
||||||
|
if (comment) {
|
||||||
|
CardComments.update(comment._id, {
|
||||||
|
$set: {
|
||||||
|
text: newComment,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
const userId = data.userId;
|
||||||
|
if (userId) {
|
||||||
|
CardComments.insert({
|
||||||
|
text: newComment,
|
||||||
|
userId,
|
||||||
|
cardId,
|
||||||
|
boardId,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
outgoingWebhooks(integration, description, params) {
|
||||||
|
check(integration, Object);
|
||||||
check(description, String);
|
check(description, String);
|
||||||
check(params, Object);
|
check(params, Object);
|
||||||
|
this.unblock();
|
||||||
|
|
||||||
// label activity did not work yet, see wekan/models/activities.js
|
// label activity did not work yet, see wekan/models/activities.js
|
||||||
const quoteParams = _.clone(params);
|
const quoteParams = _.clone(params);
|
||||||
|
const clonedParams = _.clone(params);
|
||||||
[
|
[
|
||||||
'card',
|
'card',
|
||||||
'list',
|
'list',
|
||||||
|
|
@ -63,23 +110,44 @@ Meteor.methods({
|
||||||
if (params[key]) value[key] = params[key];
|
if (params[key]) value[key] = params[key];
|
||||||
});
|
});
|
||||||
value.description = description;
|
value.description = description;
|
||||||
|
//integrations.forEach(integration => {
|
||||||
const options = {
|
const is2way = integration.type === Integrations.Const.TWOWAY;
|
||||||
headers: {
|
const token = integration.token || '';
|
||||||
// 'Content-Type': 'application/json',
|
const headers = {
|
||||||
// 'X-Wekan-Activities-Token': 'Random.Id()',
|
'Content-Type': 'application/json',
|
||||||
},
|
|
||||||
data: value,
|
|
||||||
};
|
};
|
||||||
|
if (token) headers['X-Wekan-Token'] = token;
|
||||||
integrations.forEach(integration => {
|
const options = {
|
||||||
const response = postCatchError(integration.url, options);
|
headers,
|
||||||
|
data: is2way ? clonedParams : value,
|
||||||
|
};
|
||||||
|
const url = integration.url;
|
||||||
|
const response = postCatchError(url, options);
|
||||||
|
|
||||||
if (response && response.statusCode && response.statusCode === 200) {
|
if (response && response.statusCode && response.statusCode === 200) {
|
||||||
return true; // eslint-disable-line consistent-return
|
if (is2way) {
|
||||||
|
const cid = params.commentId;
|
||||||
|
const tooSoon = Lock.has(cid); // if an activity happens to fast, notification shouldn't fire with the same id
|
||||||
|
if (!tooSoon) {
|
||||||
|
let clearNotification = () => {};
|
||||||
|
if (cid) {
|
||||||
|
Lock.set(cid);
|
||||||
|
const clearNotificationFlagTimeout = 1000;
|
||||||
|
clearNotification = () => Lock.unset(cid);
|
||||||
|
Meteor.setTimeout(clearNotification, clearNotificationFlagTimeout);
|
||||||
|
}
|
||||||
|
const data = response.data; // only an JSON encoded response will be actioned
|
||||||
|
if (data) {
|
||||||
|
Meteor.call(responseFunc, data, () => {
|
||||||
|
clearNotification();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return response; // eslint-disable-line consistent-return
|
||||||
} else {
|
} else {
|
||||||
throw new Meteor.Error('error-invalid-webhook-response');
|
throw new Meteor.Error('error-invalid-webhook-response');
|
||||||
}
|
}
|
||||||
});
|
//});
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,9 @@
|
||||||
|
Meteor.publish('globalwebhooks', () => {
|
||||||
|
const boardId = Integrations.Const.GLOBAL_WEBHOOK_ID;
|
||||||
|
return Integrations.find({
|
||||||
|
boardId,
|
||||||
|
});
|
||||||
|
});
|
||||||
Meteor.publish('setting', () => {
|
Meteor.publish('setting', () => {
|
||||||
return Settings.find(
|
return Settings.find(
|
||||||
{},
|
{},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue