summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorLauri Ojansivu <x@xet7.org>2017-07-12 02:30:53 +0300
committerLauri Ojansivu <x@xet7.org>2017-07-12 02:30:53 +0300
commitafa5ec360f61d8c891bc4058c3fc96525af4f4fa (patch)
treefb691f47d8b455c1b9e12d8d169d29e1a02d095f /models
parent19a71c0d9295b3d1e595ceb711eadca7bac3a868 (diff)
parentc649c87d16c7269452aa9fff17293db8be550bd5 (diff)
downloadwekan-afa5ec360f61d8c891bc4058c3fc96525af4f4fa.tar.gz
wekan-afa5ec360f61d8c891bc4058c3fc96525af4f4fa.tar.bz2
wekan-afa5ec360f61d8c891bc4058c3fc96525af4f4fa.zip
Merge branch 'nztqa-improve-notify' into devel
Add Feature: Outgoing Webhooks. Thanks to nztqa !
Diffstat (limited to 'models')
-rw-r--r--models/activities.js5
-rw-r--r--models/integrations.js54
2 files changed, 59 insertions, 0 deletions
diff --git a/models/activities.js b/models/activities.js
index 9a41d4aa..f1e52493 100644
--- a/models/activities.js
+++ b/models/activities.js
@@ -131,5 +131,10 @@ if (Meteor.isServer) {
Notifications.getUsers(participants, watchers).forEach((user) => {
Notifications.notify(user, title, description, params);
});
+
+ const integration = Integrations.findOne({ boardId: board._id, type: 'outgoing-webhooks', enabled: true });
+ if (integration) {
+ Meteor.call('outgoingWebhooks', integration, description, params);
+ }
});
}
diff --git a/models/integrations.js b/models/integrations.js
new file mode 100644
index 00000000..b9bf248f
--- /dev/null
+++ b/models/integrations.js
@@ -0,0 +1,54 @@
+Integrations = new Mongo.Collection('integrations');
+
+Integrations.attachSchema(new SimpleSchema({
+ enabled: {
+ type: Boolean,
+ defaultValue: true,
+ },
+ title: {
+ type: String,
+ optional: true,
+ },
+ type: {
+ type: String,
+ },
+ url: { // URL validation regex (https://mathiasbynens.be/demo/url-regex)
+ type: String,
+ },
+ token: {
+ type: String,
+ optional: true,
+ },
+ boardId: {
+ type: String,
+ },
+ createdAt: {
+ type: Date,
+ denyUpdate: false,
+ autoValue() { // eslint-disable-line consistent-return
+ if (this.isInsert) {
+ return new Date();
+ } else {
+ this.unset();
+ }
+ },
+ },
+ userId: {
+ type: String,
+ autoValue() { // eslint-disable-line consistent-return
+ if (this.isInsert || this.isUpdate) {
+ return this.userId;
+ }
+ },
+ },
+}));
+
+Integrations.allow({
+ insert(userId, doc) {
+ return allowIsBoardAdmin(userId, Boards.findOne(doc.boardId));
+ },
+ update(userId, doc) {
+ return allowIsBoardAdmin(userId, Boards.findOne(doc.boardId));
+ },
+ fetch: ['boardId'],
+});