mirror of
https://github.com/wassname/talk.git
synced 2026-07-29 11:28:24 +08:00
More edit changes
This commit is contained in:
@@ -2,6 +2,8 @@ const mongoose = require('../services/mongoose');
|
||||
const Schema = mongoose.Schema;
|
||||
const uuid = require('uuid');
|
||||
|
||||
const EDIT_WINDOW_MS = 30 * 1000; // 30 seconds
|
||||
|
||||
const STATUSES = [
|
||||
'ACCEPTED',
|
||||
'REJECTED',
|
||||
@@ -107,7 +109,16 @@ const CommentSchema = new Schema({
|
||||
}
|
||||
});
|
||||
|
||||
CommentSchema.virtual('edited').get(function() {
|
||||
return this.body_history.length > 1;
|
||||
});
|
||||
|
||||
CommentSchema.virtual('editableUntil').get(function() {
|
||||
return new Date(Number(this.created_at) + EDIT_WINDOW_MS);
|
||||
});
|
||||
|
||||
// Comment model.
|
||||
const Comment = mongoose.model('Comment', CommentSchema);
|
||||
|
||||
module.exports = Comment;
|
||||
module.exports.EDIT_WINDOW_MS = EDIT_WINDOW_MS;
|
||||
|
||||
Reference in New Issue
Block a user