feat(flag-message): add server methods

This commit is contained in:
Matteo Pagliazzi
2014-12-07 14:35:09 +01:00
parent e49e8f5765
commit ae6e0255c6
7 changed files with 67 additions and 24 deletions
+13 -1
View File
@@ -99,7 +99,7 @@ var chatDefaults = module.exports.chatDefaults = function(msg,user){
text: msg,
timestamp: +new Date,
likes: {},
flags: {} // for @paglias, @crookedneighbor added this.
flags: {}
};
if (user) {
_.defaults(message, {
@@ -317,6 +317,18 @@ GroupSchema.statics.bossQuest = function(user, progress, cb) {
})
}
GroupSchema.methods.toJSON = function() {
var doc = this.toObject();
if(doc.chat){
doc.chat.forEach(function(msg){
msg.flags = {};
});
}
return doc;
};
module.exports.schema = GroupSchema;
var Group = module.exports.model = mongoose.model("Group", GroupSchema);