2023-01-14 13:29:57 +01:00
|
|
|
import { ReactiveCache } from '/imports/reactiveCache';
|
2021-03-03 15:23:43 +02:00
|
|
|
import { Meteor } from 'meteor/meteor';
|
|
|
|
|
|
2018-08-03 19:47:20 +02:00
|
|
|
Rules = new Mongo.Collection('rules');
|
|
|
|
|
|
2019-06-26 17:47:27 -05:00
|
|
|
Rules.attachSchema(
|
|
|
|
|
new SimpleSchema({
|
|
|
|
|
title: {
|
|
|
|
|
type: String,
|
|
|
|
|
optional: false,
|
|
|
|
|
},
|
|
|
|
|
triggerId: {
|
|
|
|
|
type: String,
|
|
|
|
|
optional: false,
|
|
|
|
|
},
|
|
|
|
|
actionId: {
|
|
|
|
|
type: String,
|
|
|
|
|
optional: false,
|
|
|
|
|
},
|
|
|
|
|
boardId: {
|
|
|
|
|
type: String,
|
|
|
|
|
optional: false,
|
|
|
|
|
},
|
|
|
|
|
createdAt: {
|
|
|
|
|
type: Date,
|
|
|
|
|
optional: true,
|
|
|
|
|
// eslint-disable-next-line consistent-return
|
|
|
|
|
autoValue() {
|
|
|
|
|
if (this.isInsert) {
|
|
|
|
|
return new Date();
|
2019-09-05 12:29:45 -05:00
|
|
|
} else if (this.isUpsert) {
|
|
|
|
|
return { $setOnInsert: new Date() };
|
2019-06-26 17:47:27 -05:00
|
|
|
} else {
|
|
|
|
|
this.unset();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
modifiedAt: {
|
|
|
|
|
type: Date,
|
|
|
|
|
denyUpdate: false,
|
|
|
|
|
// eslint-disable-next-line consistent-return
|
|
|
|
|
autoValue() {
|
|
|
|
|
if (this.isInsert || this.isUpsert || this.isUpdate) {
|
|
|
|
|
return new Date();
|
|
|
|
|
} else {
|
|
|
|
|
this.unset();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
},
|
2019-06-28 12:52:09 -05:00
|
|
|
}),
|
2019-06-26 17:47:27 -05:00
|
|
|
);
|
2018-08-03 19:47:20 +02:00
|
|
|
|
2018-08-16 00:32:31 +02:00
|
|
|
Rules.helpers({
|
2026-01-21 19:22:54 +02:00
|
|
|
async rename(description) {
|
|
|
|
|
return await Rules.updateAsync(this._id, { $set: { description } });
|
|
|
|
|
},
|
Update ReactiveCache call sites to use async/await for Meteor 3.0
Part 3 of ReactiveCache async migration:
- Add await before all ReactiveCache.getX() calls
- Make functions containing ReactiveCache calls async
- Convert forEach/map/filter loops with async callbacks to for...of
- Update model helpers, Meteor methods, JsonRoutes handlers
- Update collection hooks (.before/.after insert/update/remove)
- Update .allow() callbacks to async
Files updated across models/ and server/ directories:
- Model files: cards, boards, lists, swimlanes, activities, users,
checklists, checklistItems, customFields, attachments, integrations,
cardComments, settings files, creators, exporters, and more
- Server files: publications, methods, notifications, routes, migrations
2026-02-01 00:54:38 +02:00
|
|
|
async getAction() {
|
|
|
|
|
return await ReactiveCache.getAction(this.actionId);
|
2018-08-16 00:32:31 +02:00
|
|
|
},
|
Update ReactiveCache call sites to use async/await for Meteor 3.0
Part 3 of ReactiveCache async migration:
- Add await before all ReactiveCache.getX() calls
- Make functions containing ReactiveCache calls async
- Convert forEach/map/filter loops with async callbacks to for...of
- Update model helpers, Meteor methods, JsonRoutes handlers
- Update collection hooks (.before/.after insert/update/remove)
- Update .allow() callbacks to async
Files updated across models/ and server/ directories:
- Model files: cards, boards, lists, swimlanes, activities, users,
checklists, checklistItems, customFields, attachments, integrations,
cardComments, settings files, creators, exporters, and more
- Server files: publications, methods, notifications, routes, migrations
2026-02-01 00:54:38 +02:00
|
|
|
async getTrigger() {
|
|
|
|
|
return await ReactiveCache.getTrigger(this.triggerId);
|
2018-09-16 01:50:36 +03:00
|
|
|
},
|
Update ReactiveCache call sites to use async/await for Meteor 3.0
Part 3 of ReactiveCache async migration:
- Add await before all ReactiveCache.getX() calls
- Make functions containing ReactiveCache calls async
- Convert forEach/map/filter loops with async callbacks to for...of
- Update model helpers, Meteor methods, JsonRoutes handlers
- Update collection hooks (.before/.after insert/update/remove)
- Update .allow() callbacks to async
Files updated across models/ and server/ directories:
- Model files: cards, boards, lists, swimlanes, activities, users,
checklists, checklistItems, customFields, attachments, integrations,
cardComments, settings files, creators, exporters, and more
- Server files: publications, methods, notifications, routes, migrations
2026-02-01 00:54:38 +02:00
|
|
|
async board() {
|
|
|
|
|
return await ReactiveCache.getBoard(this.boardId);
|
2021-04-12 11:44:28 +02:00
|
|
|
},
|
Update ReactiveCache call sites to use async/await for Meteor 3.0
Part 3 of ReactiveCache async migration:
- Add await before all ReactiveCache.getX() calls
- Make functions containing ReactiveCache calls async
- Convert forEach/map/filter loops with async callbacks to for...of
- Update model helpers, Meteor methods, JsonRoutes handlers
- Update collection hooks (.before/.after insert/update/remove)
- Update .allow() callbacks to async
Files updated across models/ and server/ directories:
- Model files: cards, boards, lists, swimlanes, activities, users,
checklists, checklistItems, customFields, attachments, integrations,
cardComments, settings files, creators, exporters, and more
- Server files: publications, methods, notifications, routes, migrations
2026-02-01 00:54:38 +02:00
|
|
|
async trigger() {
|
|
|
|
|
return await ReactiveCache.getTrigger(this.triggerId);
|
2021-04-12 11:44:28 +02:00
|
|
|
},
|
Update ReactiveCache call sites to use async/await for Meteor 3.0
Part 3 of ReactiveCache async migration:
- Add await before all ReactiveCache.getX() calls
- Make functions containing ReactiveCache calls async
- Convert forEach/map/filter loops with async callbacks to for...of
- Update model helpers, Meteor methods, JsonRoutes handlers
- Update collection hooks (.before/.after insert/update/remove)
- Update .allow() callbacks to async
Files updated across models/ and server/ directories:
- Model files: cards, boards, lists, swimlanes, activities, users,
checklists, checklistItems, customFields, attachments, integrations,
cardComments, settings files, creators, exporters, and more
- Server files: publications, methods, notifications, routes, migrations
2026-02-01 00:54:38 +02:00
|
|
|
async action() {
|
|
|
|
|
return await ReactiveCache.getAction(this.actionId);
|
2021-04-12 11:44:28 +02:00
|
|
|
},
|
2018-08-16 00:32:31 +02:00
|
|
|
});
|
2018-08-03 20:43:37 +02:00
|
|
|
|
2018-08-03 19:47:20 +02:00
|
|
|
Rules.allow({
|
Update ReactiveCache call sites to use async/await for Meteor 3.0
Part 3 of ReactiveCache async migration:
- Add await before all ReactiveCache.getX() calls
- Make functions containing ReactiveCache calls async
- Convert forEach/map/filter loops with async callbacks to for...of
- Update model helpers, Meteor methods, JsonRoutes handlers
- Update collection hooks (.before/.after insert/update/remove)
- Update .allow() callbacks to async
Files updated across models/ and server/ directories:
- Model files: cards, boards, lists, swimlanes, activities, users,
checklists, checklistItems, customFields, attachments, integrations,
cardComments, settings files, creators, exporters, and more
- Server files: publications, methods, notifications, routes, migrations
2026-02-01 00:54:38 +02:00
|
|
|
async insert(userId, doc) {
|
|
|
|
|
return allowIsBoardAdmin(userId, await ReactiveCache.getBoard(doc.boardId));
|
2018-08-03 19:47:20 +02:00
|
|
|
},
|
Update ReactiveCache call sites to use async/await for Meteor 3.0
Part 3 of ReactiveCache async migration:
- Add await before all ReactiveCache.getX() calls
- Make functions containing ReactiveCache calls async
- Convert forEach/map/filter loops with async callbacks to for...of
- Update model helpers, Meteor methods, JsonRoutes handlers
- Update collection hooks (.before/.after insert/update/remove)
- Update .allow() callbacks to async
Files updated across models/ and server/ directories:
- Model files: cards, boards, lists, swimlanes, activities, users,
checklists, checklistItems, customFields, attachments, integrations,
cardComments, settings files, creators, exporters, and more
- Server files: publications, methods, notifications, routes, migrations
2026-02-01 00:54:38 +02:00
|
|
|
async update(userId, doc) {
|
|
|
|
|
return allowIsBoardAdmin(userId, await ReactiveCache.getBoard(doc.boardId));
|
2018-08-03 20:43:37 +02:00
|
|
|
},
|
Update ReactiveCache call sites to use async/await for Meteor 3.0
Part 3 of ReactiveCache async migration:
- Add await before all ReactiveCache.getX() calls
- Make functions containing ReactiveCache calls async
- Convert forEach/map/filter loops with async callbacks to for...of
- Update model helpers, Meteor methods, JsonRoutes handlers
- Update collection hooks (.before/.after insert/update/remove)
- Update .allow() callbacks to async
Files updated across models/ and server/ directories:
- Model files: cards, boards, lists, swimlanes, activities, users,
checklists, checklistItems, customFields, attachments, integrations,
cardComments, settings files, creators, exporters, and more
- Server files: publications, methods, notifications, routes, migrations
2026-02-01 00:54:38 +02:00
|
|
|
async remove(userId, doc) {
|
|
|
|
|
return allowIsBoardAdmin(userId, await ReactiveCache.getBoard(doc.boardId));
|
2018-09-16 01:50:36 +03:00
|
|
|
},
|
2018-08-03 19:47:20 +02:00
|
|
|
});
|
2019-06-26 17:47:27 -05:00
|
|
|
|
|
|
|
|
if (Meteor.isServer) {
|
2026-01-24 01:55:29 +02:00
|
|
|
Meteor.startup(async () => {
|
|
|
|
|
await Rules._collection.createIndexAsync({ modifiedAt: -1 });
|
2019-06-26 17:47:27 -05:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default Rules;
|