fix tests failures (#8422)

* fix tests failures

* make sure _meta is not public

* fix typo

* fix typo
This commit is contained in:
Matteo Pagliazzi
2017-01-18 20:17:56 +01:00
committed by GitHub
parent 4bf4c3a6c2
commit 68f4275c44
8 changed files with 36 additions and 5 deletions

View File

@@ -268,12 +268,14 @@ schema.statics.getGroups = async function getGroups (options = {}) {
// When converting to json remove chat messages with more than 1 flag and remove all flags info
// unless the user is an admin
// Not putting into toJSON because there we can't access user
// It also removes the _meta field that can be stored inside a chat message
schema.statics.toJSONCleanChat = function groupToJSONCleanChat (group, user) {
let toJSON = group.toJSON();
if (!user.contributor.admin) {
_.remove(toJSON.chat, chatMsg => {
chatMsg.flags = {};
if (chatMsg._meta) chatMsg._meta = undefined;
return chatMsg.flagCount >= 2;
});
}
@@ -391,6 +393,9 @@ export function chatDefaults (msg, user) {
schema.methods.sendChat = function sendChat (message, user, metaData) {
let newMessage = chatDefaults(message, user);
// Optional data stored in the chat message but not returned
// to the users that can be stored for debugging purposes
if (metaData) {
newMessage._meta = metaData;
}