2023-01-15 01:11:16 +01:00
|
|
|
import { ReactiveCache } from '/imports/reactiveCache';
|
|
|
|
|
|
2017-02-24 22:10:38 +08:00
|
|
|
InvitationCodes = new Mongo.Collection('invitation_codes');
|
|
|
|
|
|
2019-06-26 17:47:27 -05:00
|
|
|
InvitationCodes.attachSchema(
|
|
|
|
|
new SimpleSchema({
|
|
|
|
|
code: {
|
|
|
|
|
type: String,
|
|
|
|
|
},
|
|
|
|
|
email: {
|
|
|
|
|
type: String,
|
|
|
|
|
unique: true,
|
|
|
|
|
regEx: SimpleSchema.RegEx.Email,
|
|
|
|
|
},
|
|
|
|
|
createdAt: {
|
|
|
|
|
type: Date,
|
|
|
|
|
denyUpdate: false,
|
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
// always be the admin if only one admin
|
|
|
|
|
authorId: {
|
|
|
|
|
type: String,
|
|
|
|
|
},
|
|
|
|
|
boardsToBeInvited: {
|
|
|
|
|
type: [String],
|
|
|
|
|
optional: true,
|
|
|
|
|
},
|
|
|
|
|
valid: {
|
|
|
|
|
type: Boolean,
|
|
|
|
|
defaultValue: true,
|
|
|
|
|
},
|
2019-06-28 12:52:09 -05:00
|
|
|
}),
|
2019-06-26 17:47:27 -05:00
|
|
|
);
|
2017-02-24 22:10:38 +08:00
|
|
|
|
|
|
|
|
InvitationCodes.helpers({
|
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 author() {
|
|
|
|
|
return await ReactiveCache.getUser(this.authorId);
|
2017-02-24 22:10:38 +08:00
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// InvitationCodes.before.insert((userId, doc) => {
|
2017-12-03 04:00:55 +02:00
|
|
|
// doc.createdAt = new Date();
|
|
|
|
|
// doc.authorId = userId;
|
2017-02-24 22:10:38 +08:00
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
if (Meteor.isServer) {
|
2026-01-24 01:55:29 +02:00
|
|
|
Meteor.startup(async () => {
|
|
|
|
|
await InvitationCodes._collection.createIndexAsync({ modifiedAt: -1 });
|
2019-06-26 17:47:27 -05:00
|
|
|
});
|
2017-02-24 22:10:38 +08:00
|
|
|
Boards.deny({
|
|
|
|
|
fetch: ['members'],
|
|
|
|
|
});
|
|
|
|
|
}
|
2019-06-26 17:47:27 -05:00
|
|
|
|
|
|
|
|
export default InvitationCodes;
|