[NEW] Report message (#818)

This commit is contained in:
pranavpandey1998official 2019-05-16 19:10:50 +05:30 committed by Diego Mello
parent 28628b4dba
commit d969b04d3a
3 changed files with 23 additions and 0 deletions

View File

@ -16,6 +16,7 @@ import {
import { vibrate } from '../utils/vibration';
import RocketChat from '../lib/rocketchat';
import I18n from '../i18n';
import log from '../utils/log';
@connect(
state => ({
@ -117,6 +118,10 @@ export default class MessageActions extends React.Component {
this.REACTION_INDEX = this.options.length - 1;
}
// Report
this.options.push(I18n.t('Report'));
this.REPORT_INDEX = this.options.length - 1;
// Delete
if (this.allowDelete(props)) {
this.options.push(I18n.t('Delete'));
@ -297,6 +302,16 @@ export default class MessageActions extends React.Component {
toggleReactionPicker(actionMessage);
}
handleReport = async() => {
const { actionMessage } = this.props;
try {
await RocketChat.reportMessage(actionMessage._id);
Alert.alert(I18n.t('Message_Reported'));
} catch (err) {
log('report message', err);
}
}
handleActionPress = (actionIndex) => {
if (actionIndex) {
switch (actionIndex) {
@ -327,6 +342,9 @@ export default class MessageActions extends React.Component {
case this.REACTION_INDEX:
this.handleReaction();
break;
case this.REPORT_INDEX:
this.handleReport();
break;
case this.DELETE_INDEX:
this.handleDelete();
break;

View File

@ -203,6 +203,7 @@ export default {
message: 'message',
messages: 'messages',
Messages: 'Messages',
Message_Reported: 'Message reported',
Microphone_Permission_Message: 'Rocket Chat needs access to your microphone so you can send audio message.',
Microphone_Permission: 'Microphone Permission',
Mute: 'Mute',
@ -266,6 +267,7 @@ export default {
replies: 'replies',
reply: 'reply',
Reply: 'Reply',
Report: 'Report',
Resend: 'Resend',
Reset_password: 'Reset password',
resetting_password: 'resetting password',

View File

@ -511,6 +511,9 @@ const RocketChat = {
// RC 0.59.0
return this.sdk.post('chat.pinMessage', { messageId: message._id });
},
reportMessage(messageId) {
return this.sdk.post('chat.reportMessage', { messageId, description: 'Message reported by user' });
},
getRoom(rid) {
const [result] = database.objects('subscriptions').filtered('rid = $0', rid);
if (!result) {