mirror of
https://github.com/wekan/wekan.git
synced 2026-01-02 15:48:49 +01:00
adds card comment reactions feature
This commit is contained in:
parent
d8e8512d66
commit
2977120129
8 changed files with 239 additions and 10 deletions
59
models/cardCommentReactions.js
Normal file
59
models/cardCommentReactions.js
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
const commentReactionSchema = new SimpleSchema({
|
||||
reactionCodepoint: { type: String, optional: false },
|
||||
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({
|
||||
insert(userId, doc) {
|
||||
return allowIsBoardMember(userId, Boards.findOne(doc.boardId));
|
||||
},
|
||||
update(userId, doc) {
|
||||
return allowIsBoardMember(userId, Boards.findOne(doc.boardId));
|
||||
},
|
||||
remove(userId, doc) {
|
||||
return allowIsBoardMember(userId, Boards.findOne(doc.boardId));
|
||||
},
|
||||
fetch: ['boardId'],
|
||||
});
|
||||
|
||||
|
||||
if (Meteor.isServer) {
|
||||
Meteor.startup(() => {
|
||||
CardCommentReactions._collection._ensureIndex({ cardCommentId: 1 }, { unique: true });
|
||||
});
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue