From 2ecec3b59aabe2fd6156338cd4cbab7672d4f9b1 Mon Sep 17 00:00:00 2001 From: Wu Cheng-Han Date: Tue, 12 Jan 2016 08:01:42 -0600 Subject: Support show last change user with profile and support YAML config inside the note with robots, lang, dir, breaks options --- lib/note.js | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'lib/note.js') diff --git a/lib/note.js b/lib/note.js index dc384b7f..671e5383 100644 --- a/lib/note.js +++ b/lib/note.js @@ -26,6 +26,10 @@ var model = mongoose.model('note', { type: String, enum: permissionTypes }, + lastchangeuser: { + type: Schema.Types.ObjectId, + ref: 'user' + }, viewcount: { type: Number, default: 0 @@ -45,7 +49,8 @@ var note = { getNoteTitle: getNoteTitle, generateWebTitle: generateWebTitle, increaseViewCount: increaseViewCount, - updatePermission: updatePermission + updatePermission: updatePermission, + updateLastChangeUser: updateLastChangeUser }; function checkNoteIdValid(noteId) { @@ -198,4 +203,18 @@ function updatePermission(note, permission, callback) { }); } +function updateLastChangeUser(note, lastchangeuser, callback) { + note.lastchangeuser = lastchangeuser; + note.updated = Date.now(); + note.save(function (err) { + if (err) { + logger.error('update note lastchangeuser failed: ' + err); + callback(err, null); + } else { + logger.info("update note lastchangeuser success: " + note.id); + callback(null, note); + }; + }); +} + module.exports = note; \ No newline at end of file -- cgit v1.2.3