Compare commits

..

4 Commits

Author SHA1 Message Date
Keith Holliday 0044778497 4.39.2 2018-04-24 08:16:35 -05:00
Matteo Pagliazzi 46d6590fec chat: use _id instead of id when finding doc (#10278) 2018-04-24 15:10:20 +02:00
Keith Holliday b10f056a73 4.39.1 2018-04-23 21:04:03 -05:00
Keith Holliday eeb890466a Converted date to timestamp (#10276)
* Converted date to timestamp

* Added existence check

* Updated test to include timestamp
2018-04-23 21:03:24 -05:00
6 changed files with 13 additions and 7 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "habitica",
"version": "4.39.0",
"version": "4.39.2",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "habitica",
"description": "A habit tracker app which treats your goals like a Role Playing Game.",
"version": "4.39.0",
"version": "4.39.2",
"main": "./website/server/index.js",
"dependencies": {
"@slack/client": "^3.8.1",
@@ -32,7 +32,8 @@ describe('GET /groups/:groupId/chat', () => {
it('returns Guild chat', async () => {
const chat = await user.get(`/groups/${group._id}/chat`);
expect(chat).to.eql(group.chat);
expect(chat[0].id).to.eql(group.chat[0].id);
expect(chat[1].id).to.eql(group.chat[1].id);
});
});
+3 -3
View File
@@ -235,7 +235,7 @@ api.likeChat = {
let group = await Group.getGroup({user, groupId});
if (!group) throw new NotFound(res.t('groupNotFound'));
let message = await Chat.findOne({id: req.params.chatId}).exec();
let message = await Chat.findOne({_id: req.params.chatId}).exec();
if (!message) throw new NotFound(res.t('messageGroupChatNotFound'));
// @TODO correct this error type
if (message.uuid === user._id) throw new NotFound(res.t('messageGroupChatLikeOwnMessage'));
@@ -330,7 +330,7 @@ api.clearChatFlags = {
});
if (!group) throw new NotFound(res.t('groupNotFound'));
let message = await Chat.findOne({id: chatId}).exec();
let message = await Chat.findOne({_id: chatId}).exec();
if (!message) throw new NotFound(res.t('messageGroupChatNotFound'));
message.flagCount = 0;
@@ -458,7 +458,7 @@ api.deleteChat = {
let group = await Group.getGroup({user, groupId, fields: 'chat'});
if (!group) throw new NotFound(res.t('groupNotFound'));
let message = await Chat.findOne({id: chatId}).exec();
let message = await Chat.findOne({_id: chatId}).exec();
if (!message) throw new NotFound(res.t('messageGroupChatNotFound'));
if (user._id !== message.uuid && !user.contributor.admin) {
@@ -37,7 +37,7 @@ export default class GroupChatReporter extends ChatReporter {
});
if (!group) throw new NotFound(this.res.t('groupNotFound'));
const message = await Chat.findOne({id: this.req.params.chatId}).exec();
const message = await Chat.findOne({_id: this.req.params.chatId}).exec();
if (!message) throw new NotFound(this.res.t('messageGroupChatNotFound'));
if (message.uuid === 'system') throw new BadRequest(this.res.t('messageCannotFlagSystemMessages', {communityManagerEmail: COMMUNITY_MANAGER_EMAIL}));
+5
View File
@@ -341,6 +341,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();
});
return toJSON;
};