integrations.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. Integrations = new Mongo.Collection('integrations');
  2. Integrations.attachSchema(new SimpleSchema({
  3. enabled: {
  4. type: Boolean,
  5. defaultValue: true,
  6. },
  7. title: {
  8. type: String,
  9. optional: true,
  10. },
  11. type: {
  12. type: String,
  13. },
  14. url: { // URL validation regex (https://mathiasbynens.be/demo/url-regex)
  15. type: String,
  16. },
  17. token: {
  18. type: String,
  19. optional: true,
  20. },
  21. boardId: {
  22. type: String,
  23. },
  24. createdAt: {
  25. type: Date,
  26. denyUpdate: false,
  27. autoValue() { // eslint-disable-line consistent-return
  28. if (this.isInsert) {
  29. return new Date();
  30. } else {
  31. this.unset();
  32. }
  33. },
  34. },
  35. userId: {
  36. type: String,
  37. autoValue() { // eslint-disable-line consistent-return
  38. if (this.isInsert || this.isUpdate) {
  39. return this.userId;
  40. }
  41. },
  42. },
  43. }));
  44. Integrations.allow({
  45. insert(userId, doc) {
  46. return allowIsBoardAdmin(userId, Boards.findOne(doc.boardId));
  47. },
  48. update(userId, doc) {
  49. return allowIsBoardAdmin(userId, Boards.findOne(doc.boardId));
  50. },
  51. fetch: ['boardId'],
  52. });