copy chatReporter - fix unknown apiMessages - add api for flagging pm
This commit is contained in:
@@ -234,7 +234,7 @@ api.likeChat = {
|
||||
let groupId = req.params.groupId;
|
||||
|
||||
req.checkParams('groupId', apiError('groupIdRequired')).notEmpty();
|
||||
req.checkParams('chatId', res.t('chatIdRequired')).notEmpty();
|
||||
req.checkParams('chatId', apiError('chatIdRequired')).notEmpty();
|
||||
|
||||
let validationErrors = req.validationErrors();
|
||||
if (validationErrors) throw validationErrors;
|
||||
@@ -325,7 +325,7 @@ api.clearChatFlags = {
|
||||
let chatId = req.params.chatId;
|
||||
|
||||
req.checkParams('groupId', apiError('groupIdRequired')).notEmpty();
|
||||
req.checkParams('chatId', res.t('chatIdRequired')).notEmpty();
|
||||
req.checkParams('chatId', apiError('chatIdRequired')).notEmpty();
|
||||
|
||||
let validationErrors = req.validationErrors();
|
||||
if (validationErrors) throw validationErrors;
|
||||
@@ -465,7 +465,7 @@ api.deleteChat = {
|
||||
let chatId = req.params.chatId;
|
||||
|
||||
req.checkParams('groupId', apiError('groupIdRequired')).notEmpty();
|
||||
req.checkParams('chatId', res.t('chatIdRequired')).notEmpty();
|
||||
req.checkParams('chatId', apiError('chatIdRequired')).notEmpty();
|
||||
|
||||
let validationErrors = req.validationErrors();
|
||||
if (validationErrors) throw validationErrors;
|
||||
|
||||
@@ -20,6 +20,7 @@ import {
|
||||
} from '../../libs/email';
|
||||
import { sendNotification as sendPushNotification } from '../../libs/pushNotifications';
|
||||
import { achievements } from '../../../../website/common/';
|
||||
import {chatReporterFactory} from '../../libs/chatReporting/chatReporterFactory';
|
||||
|
||||
let api = {};
|
||||
|
||||
@@ -514,6 +515,40 @@ api.sendPrivateMessage = {
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @api {post} /api/v3//members/flag-private-message/:messageId Flag a private message
|
||||
* @apiDescription A message will be hidden immediately if a moderator flags the message. An email is sent to the moderators about every flagged message.
|
||||
* @apiName FlagPrivateMessage
|
||||
* @apiGroup Member
|
||||
*
|
||||
* @apiParam (Path) {UUID} messageId The private message id
|
||||
*
|
||||
* @apiSuccess {Object} data The flagged chat message
|
||||
* @apiSuccess {UUID} data.id The id of the message
|
||||
* @apiSuccess {String} data.text The text of the message
|
||||
* @apiSuccess {Number} data.timestamp The timestamp of the message in milliseconds
|
||||
* @apiSuccess {Object} data.likes The likes of the message
|
||||
* @apiSuccess {Object} data.flags The flags of the message
|
||||
* @apiSuccess {Number} data.flagCount The number of flags the message has
|
||||
* @apiSuccess {UUID} data.uuid The user id of the author of the message
|
||||
* @apiSuccess {String} data.user The username of the author of the message
|
||||
*
|
||||
* @apiUse MessageNotFound
|
||||
* @apiUse MessageIdRequired
|
||||
* @apiError (404) {NotFound} messageGroupChatFlagAlreadyReported The message has already been flagged
|
||||
*/
|
||||
api.flagPrivateMessage = {
|
||||
method: 'POST',
|
||||
url: '/members/flag-private-message/:messageId',
|
||||
middlewares: [authWithHeaders()],
|
||||
async handler (req, res) {
|
||||
const chatReporter = chatReporterFactory('Inbox', req, res);
|
||||
const message = await chatReporter.flag();
|
||||
res.respond(200, message);
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* @api {post} /api/v3/members/transfer-gems Send a gem gift to a member
|
||||
* @apiName TransferGems
|
||||
|
||||
Reference in New Issue
Block a user