diff --git a/test/api/v3/integration/chat/POST-groups_id_chat_id_clear_flags.test.js b/test/api/v3/integration/chat/POST-groups_id_chat_id_clear_flags.test.js index b3d410675a..35a2878847 100644 --- a/test/api/v3/integration/chat/POST-groups_id_chat_id_clear_flags.test.js +++ b/test/api/v3/integration/chat/POST-groups_id_chat_id_clear_flags.test.js @@ -3,6 +3,7 @@ import { generateUser, translate as t, } from '../../../../helpers/api-v3-integration.helper'; +import config from '../../../../../config.json'; import { v4 as generateUUID } from 'uuid'; describe('POST /groups/:id/chat/:id/clearflags', () => { @@ -74,7 +75,7 @@ describe('POST /groups/:id/chat/:id/clearflags', () => { expect(messages[0].flagCount).to.eql(0); }); - it('can unflag a system message', async () => { + it('can\'t flag a system message', async () => { let { group, members } = await createAndPopulateGroup({ groupDetails: { type: 'party', @@ -95,13 +96,15 @@ describe('POST /groups/:id/chat/:id/clearflags', () => { await member.post('/user/class/cast/mpheal'); let [skillMsg] = await member.get(`/groups/${group.id}/chat`); - - await member.post(`/groups/${group._id}/chat/${skillMsg.id}/flag`); - await admin.post(`/groups/${group._id}/chat/${skillMsg.id}/clearflags`); - - let messages = await members[0].get(`/groups/${group._id}/chat`); - expect(messages[0].id).to.eql(skillMsg.id); - expect(messages[0].flagCount).to.eql(0); + await expect(member.post(`/groups/${group._id}/chat/${skillMsg.id}/flag`)) + .to.eventually.be.rejected.and.eql({ + code: 400, + error: 'BadRequest', + message: t('messageCannotFlagSystemMessages', {communityManagerEmail: config.EMAILS.COMMUNITY_MANAGER_EMAIL}), + }); + // let messages = await members[0].get(`/groups/${group._id}/chat`); + // expect(messages[0].id).to.eql(skillMsg.id); + // expect(messages[0].flagCount).to.eql(0); }); }); diff --git a/website/client/components/chat/chatMessages.vue b/website/client/components/chat/chatMessages.vue index 176106f32a..ad5524cbad 100644 --- a/website/client/components/chat/chatMessages.vue +++ b/website/client/components/chat/chatMessages.vue @@ -41,7 +41,7 @@ .svg-icon(v-html="icons.copy") | {{$t('copyAsTodo')}} // @TODO make copyAsTodo work in the inbox - span.action(v-if='!inbox && user.flags.communityGuidelinesAccepted', @click='report(msg)') + span.action(v-if='!inbox && user.flags.communityGuidelinesAccepted && msg.uuid !== "system"', @click='report(msg)') .svg-icon(v-html="icons.report") | {{$t('report')}} // @TODO make flagging/reporting work in the inbox. NOTE: it must work even if the communityGuidelines are not accepted and it MUST work for messages that you have SENT as well as received. -- Alys diff --git a/website/common/locales/en/messages.json b/website/common/locales/en/messages.json index 2bef686376..64eb2cd9a4 100644 --- a/website/common/locales/en/messages.json +++ b/website/common/locales/en/messages.json @@ -1,5 +1,4 @@ { - "messageLostItem": "Your <%= itemText %> broke.", "messageTaskNotFound": "Task not found.", "messageDuplicateTaskID": "A task with that ID already exists.", @@ -58,6 +57,7 @@ "messageGroupChatFlagAlreadyReported": "You have already reported this message", "messageGroupChatNotFound": "Message not found!", "messageGroupChatAdminClearFlagCount": "Only an admin can clear the flag count!", + "messageCannotFlagSystemMessages": "You cannot flag a system message. If you need to report a violation of the Community Guidelines related to this message, please email a screenshot and explanation to Lemoness at <%= communityManagerEmail %>.", "messageGroupChatSpam": "Whoops, looks like you're posting too many messages! Please wait a minute and try again. The Tavern chat only holds 200 messages at a time, so Habitica encourages posting longer, more thoughtful messages and consolidating replies. Can't wait to hear what you have to say. :)", "messageUserOperationProtected": "path `<%= operation %>` was not saved, as it's a protected path.", diff --git a/website/server/controllers/api-v3/chat.js b/website/server/controllers/api-v3/chat.js index e5de5e5608..88687c43c1 100644 --- a/website/server/controllers/api-v3/chat.js +++ b/website/server/controllers/api-v3/chat.js @@ -22,6 +22,7 @@ const FLAG_REPORT_EMAILS = nconf.get('FLAG_REPORT_EMAIL').split(',').map((email) return { email, canSend: true }; }); +const COMMUNITY_MANAGER_EMAIL = nconf.get('EMAILS:COMMUNITY_MANAGER_EMAIL'); /** * @apiDefine MessageNotFound * @apiError (404) {NotFound} MessageNotFound The specified message could not be found. @@ -320,7 +321,7 @@ api.flagChat = { let message = _.find(group.chat, {id: req.params.chatId}); if (!message) throw new NotFound(res.t('messageGroupChatNotFound')); - + if (message.uuid === 'system') throw new BadRequest(res.t('messageCannotFlagSystemMessages', {communityManagerEmail: COMMUNITY_MANAGER_EMAIL})); let update = {$set: {}}; // Log user ids that have flagged the message