start upgrading eslint

This commit is contained in:
Matteo Pagliazzi
2019-10-08 16:57:10 +02:00
parent 90c917f69e
commit 621787915c
304 changed files with 5992 additions and 6394 deletions

View File

@@ -13,9 +13,7 @@ import { chatModel as Chat } from '../../models/message';
import apiError from '../apiError';
const COMMUNITY_MANAGER_EMAIL = nconf.get('EMAILS_COMMUNITY_MANAGER_EMAIL');
const FLAG_REPORT_EMAILS = nconf.get('FLAG_REPORT_EMAIL').split(',').map((email) => {
return { email, canSend: true };
});
const FLAG_REPORT_EMAILS = nconf.get('FLAG_REPORT_EMAIL').split(',').map(email => ({ email, canSend: true }));
const USER_AGE_FOR_FLAGGING = 3; // accounts less than this many days old don't increment flagCount
export default class GroupChatReporter extends ChatReporter {
@@ -30,29 +28,29 @@ export default class GroupChatReporter extends ChatReporter {
this.req.checkParams('groupId', apiError('groupIdRequired')).notEmpty();
this.req.checkParams('chatId', apiError('chatIdRequired')).notEmpty();
let validationErrors = this.req.validationErrors();
const validationErrors = this.req.validationErrors();
if (validationErrors) throw validationErrors;
let group = await Group.getGroup({
const group = await Group.getGroup({
user: this.user,
groupId: this.groupId,
optionalMembership: this.user.contributor.admin,
});
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}));
if (message.uuid === 'system') throw new BadRequest(this.res.t('messageCannotFlagSystemMessages', { communityManagerEmail: COMMUNITY_MANAGER_EMAIL }));
const userComment = this.req.body.comment;
return {message, group, userComment};
return { message, group, userComment };
}
async notify (group, message, userComment, automatedComment = '') {
let emailVariables = await this.getMessageVariables(group, message);
emailVariables = emailVariables.concat([
{name: 'REPORTER_COMMENT', content: userComment || ''},
{ name: 'REPORTER_COMMENT', content: userComment || '' },
]);
sendTxn(FLAG_REPORT_EMAILS, 'flag-report-to-mods-with-comments', emailVariables);
@@ -88,7 +86,7 @@ export default class GroupChatReporter extends ChatReporter {
}
async flag () {
let {message, group, userComment} = await this.validate();
const { message, group, userComment } = await this.validate();
let increaseFlagCount = true;
let automatedComment = '';