From 97e146589969d02b54636a992f1e1a9cc8e0dcfc Mon Sep 17 00:00:00 2001 From: negue Date: Wed, 13 Jun 2018 22:55:28 +0200 Subject: [PATCH] fix ci - revert reporter to user var --- test/api/v3/unit/libs/slack.js | 2 +- website/server/controllers/api-v3/chat.js | 5 +++++ .../server/libs/chatReporting/inboxChatReporter.js | 12 ++++++------ 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/test/api/v3/unit/libs/slack.js b/test/api/v3/unit/libs/slack.js index e660a340d2..0e259e9ace 100644 --- a/test/api/v3/unit/libs/slack.js +++ b/test/api/v3/unit/libs/slack.js @@ -47,7 +47,7 @@ describe('slack', () => { expect(IncomingWebhook.prototype.send).to.be.calledOnce; expect(IncomingWebhook.prototype.send).to.be.calledWith({ - text: 'flagger (flagger-id; language: flagger-lang) flagged a message', + text: 'flagger (flagger-id; language: flagger-lang) flagged a group message', attachments: [{ fallback: 'Flag Message', color: 'danger', diff --git a/website/server/controllers/api-v3/chat.js b/website/server/controllers/api-v3/chat.js index a8f5241971..99265960d1 100644 --- a/website/server/controllers/api-v3/chat.js +++ b/website/server/controllers/api-v3/chat.js @@ -39,6 +39,11 @@ const FLAG_REPORT_EMAILS = nconf.get('FLAG_REPORT_EMAIL').split(',').map((email) * @apiError (404) {badRequest} chatIdRequired A chat ID is required */ +/** + * @apiDefine MessageIdRequired + * @apiError (404) {badRequest} messageIdRequired A message ID is required + */ + let api = {}; function textContainsBannedSlur (message) { diff --git a/website/server/libs/chatReporting/inboxChatReporter.js b/website/server/libs/chatReporting/inboxChatReporter.js index 7f94237afc..de111fdd2b 100644 --- a/website/server/libs/chatReporting/inboxChatReporter.js +++ b/website/server/libs/chatReporting/inboxChatReporter.js @@ -19,7 +19,7 @@ export default class InboxChatReporter extends ChatReporter { constructor (req, res) { super(req, res); - this.reporter = res.locals.user; + this.user = res.locals.user; this.inboxUser = res.locals.user; } @@ -29,7 +29,7 @@ export default class InboxChatReporter extends ChatReporter { let validationErrors = this.req.validationErrors(); if (validationErrors) throw validationErrors; - if (this.reporter.contributor.admin && this.req.query.userId) { + if (this.user.contributor.admin && this.req.query.userId) { this.inboxUser = await User.findOne({_id: this.req.query.userId}); } @@ -61,7 +61,7 @@ export default class InboxChatReporter extends ChatReporter { slack.sendInboxFlagNotification({ authorEmail: this.authorEmail, - flagger: this.reporter, + flagger: this.user, message, userComment, }); @@ -80,16 +80,16 @@ export default class InboxChatReporter extends ChatReporter { // Log user ids that have flagged the message if (!message.flags) message.flags = {}; // TODO fix error type - if (message.flags[this.reporter._id] && !this.reporter.contributor.admin) { + if (message.flags[this.user._id] && !this.user.contributor.admin) { throw new NotFound(this.res.t('messageGroupChatFlagAlreadyReported')); } return this.updateMessageAndSave(message, (m) => { - m.flags[this.reporter._id] = true; + m.flags[this.user._id] = true; // Log total number of flags (publicly viewable) if (!m.flagCount) m.flagCount = 0; - if (this.reporter.contributor.admin) { + if (this.user.contributor.admin) { // Arbitrary amount, higher than 2 m.flagCount = 5; } else {