summaryrefslogtreecommitdiffstats
path: root/models/integrations.js
diff options
context:
space:
mode:
authornztqa <nztqa@users.noreply.github.com>2017-07-09 14:59:58 +0900
committernztqa <nztqa@users.noreply.github.com>2017-07-09 14:59:58 +0900
commitbcd42ad958159d1501b8f9a3df0f4a1ff1076f5b (patch)
treea59edb9f2170269e3a7502456d57dababff42856 /models/integrations.js
parent24290b66a3d8855eb743587b7720b8e8e3d99d91 (diff)
downloadwekan-bcd42ad958159d1501b8f9a3df0f4a1ff1076f5b.tar.gz
wekan-bcd42ad958159d1501b8f9a3df0f4a1ff1076f5b.tar.bz2
wekan-bcd42ad958159d1501b8f9a3df0f4a1ff1076f5b.zip
Add integrations model
Diffstat (limited to 'models/integrations.js')
-rw-r--r--models/integrations.js54
1 files changed, 54 insertions, 0 deletions
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'],
+});