mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 06:37:23 +01:00
System messages flaggable (#9408)
* Remove flag from system messages, throw an error if system messages are flagged * Modify unflag system message test to check if flagging a system message throws an error * Move email from nconf to top
This commit is contained in:
@@ -3,6 +3,7 @@ import {
|
|||||||
generateUser,
|
generateUser,
|
||||||
translate as t,
|
translate as t,
|
||||||
} from '../../../../helpers/api-v3-integration.helper';
|
} from '../../../../helpers/api-v3-integration.helper';
|
||||||
|
import config from '../../../../../config.json';
|
||||||
import { v4 as generateUUID } from 'uuid';
|
import { v4 as generateUUID } from 'uuid';
|
||||||
|
|
||||||
describe('POST /groups/:id/chat/:id/clearflags', () => {
|
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);
|
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({
|
let { group, members } = await createAndPopulateGroup({
|
||||||
groupDetails: {
|
groupDetails: {
|
||||||
type: 'party',
|
type: 'party',
|
||||||
@@ -95,13 +96,15 @@ describe('POST /groups/:id/chat/:id/clearflags', () => {
|
|||||||
await member.post('/user/class/cast/mpheal');
|
await member.post('/user/class/cast/mpheal');
|
||||||
|
|
||||||
let [skillMsg] = await member.get(`/groups/${group.id}/chat`);
|
let [skillMsg] = await member.get(`/groups/${group.id}/chat`);
|
||||||
|
await expect(member.post(`/groups/${group._id}/chat/${skillMsg.id}/flag`))
|
||||||
await member.post(`/groups/${group._id}/chat/${skillMsg.id}/flag`);
|
.to.eventually.be.rejected.and.eql({
|
||||||
await admin.post(`/groups/${group._id}/chat/${skillMsg.id}/clearflags`);
|
code: 400,
|
||||||
|
error: 'BadRequest',
|
||||||
let messages = await members[0].get(`/groups/${group._id}/chat`);
|
message: t('messageCannotFlagSystemMessages', {communityManagerEmail: config.EMAILS.COMMUNITY_MANAGER_EMAIL}),
|
||||||
expect(messages[0].id).to.eql(skillMsg.id);
|
});
|
||||||
expect(messages[0].flagCount).to.eql(0);
|
// 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);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,7 @@
|
|||||||
.svg-icon(v-html="icons.copy")
|
.svg-icon(v-html="icons.copy")
|
||||||
| {{$t('copyAsTodo')}}
|
| {{$t('copyAsTodo')}}
|
||||||
// @TODO make copyAsTodo work in the inbox
|
// @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")
|
.svg-icon(v-html="icons.report")
|
||||||
| {{$t('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
|
// @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
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
{
|
{
|
||||||
|
|
||||||
"messageLostItem": "Your <%= itemText %> broke.",
|
"messageLostItem": "Your <%= itemText %> broke.",
|
||||||
"messageTaskNotFound": "Task not found.",
|
"messageTaskNotFound": "Task not found.",
|
||||||
"messageDuplicateTaskID": "A task with that ID already exists.",
|
"messageDuplicateTaskID": "A task with that ID already exists.",
|
||||||
@@ -58,6 +57,7 @@
|
|||||||
"messageGroupChatFlagAlreadyReported": "You have already reported this message",
|
"messageGroupChatFlagAlreadyReported": "You have already reported this message",
|
||||||
"messageGroupChatNotFound": "Message not found!",
|
"messageGroupChatNotFound": "Message not found!",
|
||||||
"messageGroupChatAdminClearFlagCount": "Only an admin can clear the flag count!",
|
"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. :)",
|
"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.",
|
"messageUserOperationProtected": "path `<%= operation %>` was not saved, as it's a protected path.",
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ const FLAG_REPORT_EMAILS = nconf.get('FLAG_REPORT_EMAIL').split(',').map((email)
|
|||||||
return { email, canSend: true };
|
return { email, canSend: true };
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const COMMUNITY_MANAGER_EMAIL = nconf.get('EMAILS:COMMUNITY_MANAGER_EMAIL');
|
||||||
/**
|
/**
|
||||||
* @apiDefine MessageNotFound
|
* @apiDefine MessageNotFound
|
||||||
* @apiError (404) {NotFound} MessageNotFound The specified message could not be found.
|
* @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});
|
let message = _.find(group.chat, {id: req.params.chatId});
|
||||||
|
|
||||||
if (!message) throw new NotFound(res.t('messageGroupChatNotFound'));
|
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: {}};
|
let update = {$set: {}};
|
||||||
|
|
||||||
// Log user ids that have flagged the message
|
// Log user ids that have flagged the message
|
||||||
|
|||||||
Reference in New Issue
Block a user