mirror of
https://github.com/vale981/Vulcan
synced 2025-03-09 12:16:37 -04:00

* [eslint] update eslint rules & add .eslintignore to ignore non-ready nova packages * [clean-up] nova-voting * [clean-up] [bug] nova-users: missing user parameter * [clean-up] nova-users * [clean-up] nova-subscribe * [clean-up] nova-settings * [clean-up] nova-rss * [clean-up] [bug] nova-posts: correct UsersRemoveDeletePosts * [clean-up] nova-posts * [clean-up] nova-notifications * [clean-up] [bug] nova-newsletter: no error.message on throw error * [clean-up] nova-newsletter * [clean-up] nova-lib * [clean-up] nova-kadira * [clean-up] nova-inject-data * [clean-up] nova-getting-started * [clean-up] nova-forms * [clean-up] nova-events * [clean-up] [bug] nova-embedly: no FlowRouter * [clean-up] nova-embedly * [clean-up] nova-email-templates * [clean-up] nova-email * [clean-up] nova-debug * [clean-up] nova-core * [clean-up] [bug] nova-comments: correct UsersRemoveDeleteComments * [clean-up] nova-comments * [clean-up] [bug] nova-cloudinary: use Telescope.settings.collection instand * [clean-up] nova-cloudinary * [clean-up] nova-categories * [clean-up] nova-base-components * [clean-up] nova-api * [eslint] extends react recommended * [clean-up] for jsx files * [eslint] extends meteor recommended * i forgot this one little change
166 lines
3.1 KiB
JavaScript
166 lines
3.1 KiB
JavaScript
import Telescope from 'meteor/nova:lib';
|
|
import Users from 'meteor/nova:users';
|
|
import { SimpleSchema } from 'meteor/aldeed:simple-schema';
|
|
import Comments from './collection.js';
|
|
|
|
// check if user can create a new comment
|
|
const canInsert = user => Users.canDo(user, "comments.new");
|
|
|
|
// check if user can edit a comment
|
|
const canEdit = Users.canEdit;
|
|
|
|
// check if user can edit *all* comments
|
|
// const canEditAll = user => Users.canDo(user, "comments.edit.all");
|
|
|
|
/**
|
|
* @summary Comments schema
|
|
* @type {SimpleSchema}
|
|
*/
|
|
Comments.schema = new SimpleSchema({
|
|
/**
|
|
ID
|
|
*/
|
|
_id: {
|
|
type: String,
|
|
optional: true,
|
|
publish: true,
|
|
},
|
|
/**
|
|
The `_id` of the parent comment, if there is one
|
|
*/
|
|
parentCommentId: {
|
|
type: String,
|
|
// regEx: SimpleSchema.RegEx.Id,
|
|
max: 500,
|
|
insertableIf: canInsert,
|
|
optional: true,
|
|
publish: true,
|
|
control: "none" // never show this
|
|
},
|
|
/**
|
|
The `_id` of the top-level parent comment, if there is one
|
|
*/
|
|
topLevelCommentId: {
|
|
type: String,
|
|
// regEx: SimpleSchema.RegEx.Id,
|
|
max: 500,
|
|
insertableIf: canInsert,
|
|
optional: true,
|
|
publish: true,
|
|
control: "none" // never show this
|
|
},
|
|
/**
|
|
The timestamp of comment creation
|
|
*/
|
|
createdAt: {
|
|
type: Date,
|
|
optional: true,
|
|
publish: false
|
|
},
|
|
/**
|
|
The timestamp of the comment being posted. For now, comments are always created and posted at the same time
|
|
*/
|
|
postedAt: {
|
|
type: Date,
|
|
optional: true,
|
|
publish: true,
|
|
},
|
|
/**
|
|
The comment body (Markdown)
|
|
*/
|
|
body: {
|
|
type: String,
|
|
max: 3000,
|
|
insertableIf: canInsert,
|
|
editableIf: canEdit,
|
|
publish: true,
|
|
control: "textarea"
|
|
},
|
|
/**
|
|
The HTML version of the comment body
|
|
*/
|
|
htmlBody: {
|
|
type: String,
|
|
optional: true,
|
|
publish: true,
|
|
},
|
|
/**
|
|
The comment author's name
|
|
*/
|
|
author: {
|
|
type: String,
|
|
optional: true,
|
|
publish: true,
|
|
},
|
|
/**
|
|
Whether the comment is inactive. Inactive comments' scores gets recalculated less often
|
|
*/
|
|
inactive: {
|
|
type: Boolean,
|
|
optional: true,
|
|
publish: true,
|
|
},
|
|
/**
|
|
The post's `_id`
|
|
*/
|
|
postId: {
|
|
type: String,
|
|
optional: true,
|
|
publish: true,
|
|
// regEx: SimpleSchema.RegEx.Id,
|
|
max: 500,
|
|
form: {
|
|
omit: true // never show this
|
|
}
|
|
},
|
|
/**
|
|
The comment author's `_id`
|
|
*/
|
|
userId: {
|
|
type: String,
|
|
optional: true,
|
|
publish: true,
|
|
join: {
|
|
joinAs: "user",
|
|
collection: () => Users
|
|
}
|
|
},
|
|
/**
|
|
Whether the comment is deleted. Delete comments' content doesn't appear on the site.
|
|
*/
|
|
isDeleted: {
|
|
type: Boolean,
|
|
optional: true,
|
|
publish: true,
|
|
},
|
|
userIP: {
|
|
type: String,
|
|
optional: true,
|
|
publish: false
|
|
},
|
|
userAgent: {
|
|
type: String,
|
|
optional: true,
|
|
publish: false
|
|
},
|
|
referrer: {
|
|
type: String,
|
|
optional: true,
|
|
publish: false
|
|
}
|
|
});
|
|
|
|
Comments.attachSchema(Comments.schema);
|
|
|
|
if (typeof Telescope.notifications !== "undefined") {
|
|
Comments.addField({
|
|
fieldName: 'disableNotifications',
|
|
fieldSchema: {
|
|
type: Boolean,
|
|
optional: true,
|
|
form: {
|
|
omit: true
|
|
}
|
|
}
|
|
});
|
|
}
|