extract chat (#10362)

* extract chatTextarea from group/tavern - extract staffList array

* fix lint / rewrite condition

* clean up - part 1

* rename chatTextarea to chat

* refactor timestamp check
This commit is contained in:
negue
2018-05-18 17:01:05 +02:00
committed by Matteo Pagliazzi
parent 3d39718048
commit de9883c3ac
5 changed files with 349 additions and 373 deletions
+6 -2
View File
@@ -346,7 +346,11 @@ schema.statics.toJSONCleanChat = async function groupToJSONCleanChat (group, use
// Convert to timestamps because Android expects it
toJSON.chat.forEach(chat => {
chat.timestamp = chat.timestamp ? chat.timestamp.getTime() : new Date().getTime();
// old chats are saved with a numeric timestamp
// new chats use `Date` which then has to be converted to the numeric timestamp
if (chat.timestamp.getTime) {
chat.timestamp = chat.timestamp.getTime();
}
});
return toJSON;
@@ -1537,4 +1541,4 @@ if (!nconf.get('IS_TEST')) {
privacy: 'public',
}).save();
});
}
}