mirror of
https://github.com/wekan/wekan.git
synced 2026-02-20 23:14:07 +01:00
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
70 lines
1.5 KiB
JavaScript
70 lines
1.5 KiB
JavaScript
import { ReactiveCache } from '/imports/reactiveCache';
|
|
|
|
const commentReactionSchema = new SimpleSchema({
|
|
reactionCodepoint: {
|
|
type: String,
|
|
optional: false,
|
|
max: 9, // max length of reaction code
|
|
custom() {
|
|
if (!this.value.match(/^&#\d{4,6};$/)) { // regex for only valid reactions
|
|
return "incorrectReactionCode";
|
|
}
|
|
},
|
|
},
|
|
userIds: { type: [String], defaultValue: [] }
|
|
});
|
|
|
|
CardCommentReactions = new Mongo.Collection('card_comment_reactions');
|
|
|
|
/**
|
|
* All reactions of a card comment
|
|
*/
|
|
CardCommentReactions.attachSchema(
|
|
new SimpleSchema({
|
|
boardId: {
|
|
/**
|
|
* the board ID
|
|
*/
|
|
type: String,
|
|
optional: false
|
|
},
|
|
cardId: {
|
|
/**
|
|
* the card ID
|
|
*/
|
|
type: String,
|
|
optional: false
|
|
},
|
|
cardCommentId: {
|
|
/**
|
|
* the card comment ID
|
|
*/
|
|
type: String,
|
|
optional: false
|
|
},
|
|
reactions: {
|
|
type: [commentReactionSchema],
|
|
defaultValue: []
|
|
}
|
|
}),
|
|
);
|
|
|
|
CardCommentReactions.allow({
|
|
async insert(userId, doc) {
|
|
return allowIsBoardMember(userId, await ReactiveCache.getBoard(doc.boardId));
|
|
},
|
|
async update(userId, doc) {
|
|
return allowIsBoardMember(userId, await ReactiveCache.getBoard(doc.boardId));
|
|
},
|
|
async remove(userId, doc) {
|
|
return allowIsBoardMember(userId, await ReactiveCache.getBoard(doc.boardId));
|
|
},
|
|
fetch: ['boardId'],
|
|
});
|
|
|
|
|
|
if (Meteor.isServer) {
|
|
Meteor.startup(async () => {
|
|
await CardCommentReactions._collection.createIndexAsync({ cardCommentId: 1 }, { unique: true });
|
|
});
|
|
}
|