From f5f8f8c24661b9815ac22d8a8063ee1973166a0a Mon Sep 17 00:00:00 2001 From: cincospenguinos Date: Tue, 13 Sep 2016 11:23:11 -0600 Subject: [PATCH] Players able to flag their own messages - Fixes #8005 (#8006) * Players able to flag their own messages * Modify test case to match the new behavior * Remove a comment and a locales message --- common/locales/en/messages.json | 1 - test/api/v3/integration/chat/POST-chat.flag.test.js | 9 ++------- website/server/controllers/api-v3/chat.js | 2 -- website/views/options/social/chat-message.jade | 2 +- 4 files changed, 3 insertions(+), 11 deletions(-) diff --git a/common/locales/en/messages.json b/common/locales/en/messages.json index d812cf28c5..e2375b0d8b 100644 --- a/common/locales/en/messages.json +++ b/common/locales/en/messages.json @@ -53,7 +53,6 @@ "messageGroupCannotRemoveSelf": "You cannot remove yourself!", "messageGroupChatBlankMessage": "You cannot send a blank message", "messageGroupChatLikeOwnMessage": "Can't like your own message. Don't be that person.", - "messageGroupChatFlagOwnMessage": "Can't report your own message.", "messageGroupChatFlagAlreadyReported": "You have already reported this message", "messageGroupChatNotFound": "Message not found!", "messageGroupChatAdminClearFlagCount": "Only an admin can clear the flag count!", diff --git a/test/api/v3/integration/chat/POST-chat.flag.test.js b/test/api/v3/integration/chat/POST-chat.flag.test.js index 9c2d5849a9..a726a49942 100644 --- a/test/api/v3/integration/chat/POST-chat.flag.test.js +++ b/test/api/v3/integration/chat/POST-chat.flag.test.js @@ -29,14 +29,9 @@ describe('POST /chat/:chatId/flag', () => { }); }); - it('Returns an error when user tries to flag their own message', async () => { + it('Allows players to flag their own message', async () => { let message = await user.post(`/groups/${group._id}/chat`, {message: TEST_MESSAGE}); - await expect(user.post(`/groups/${group._id}/chat/${message.message.id}/flag`)) - .to.eventually.be.rejected.and.eql({ - code: 404, - error: 'NotFound', - message: t('messageGroupChatFlagOwnMessage'), - }); + await expect(user.post(`/groups/${group._id}/chat/${message.message.id}/flag`)).to.eventually.be.ok; }); it('Flags a chat', async () => { diff --git a/website/server/controllers/api-v3/chat.js b/website/server/controllers/api-v3/chat.js index aaeb05a0b7..988b3a893a 100644 --- a/website/server/controllers/api-v3/chat.js +++ b/website/server/controllers/api-v3/chat.js @@ -222,8 +222,6 @@ api.flagChat = { if (!message) throw new NotFound(res.t('messageGroupChatNotFound')); - if (message.uuid === user._id) throw new NotFound(res.t('messageGroupChatFlagOwnMessage')); - let update = {$set: {}}; // Log user ids that have flagged the message diff --git a/website/views/options/social/chat-message.jade b/website/views/options/social/chat-message.jade index a8ad847d79..8dcdd0ec7e 100644 --- a/website/views/options/social/chat-message.jade +++ b/website/views/options/social/chat-message.jade @@ -31,7 +31,7 @@ mixin chatMessages(inbox) span(ng-if='#{inbox ? "true" : ":: user.contributor.admin || message.uuid == user.id"}')     a(ng-click='#{inbox? "User.deletePM({params:{id:message.$key}})" : "deleteChatMessage(group, message)"}') span.glyphicon.glyphicon-trash(tooltip=env.t('delete')) - span(ng-if=':: user.contributor.admin || (!message.sent && user.flags.communityGuidelinesAccepted && message.uuid != user.id)')     + span(ng-if=':: user.contributor.admin || (!message.sent && user.flags.communityGuidelinesAccepted)')     a(ng-click="flagChatMessage(group._id, message)") span.glyphicon.glyphicon-flag(tooltip="{{message.flags[user._id] ? env.t('abuseAlreadyReported') : env.t('abuseFlag')}}" ng-class='message.flags[user._id] ? "text-danger" : ""') span