diff --git a/app/containers/MessageActions.js b/app/containers/MessageActions.js index 2f5d7923..8b8c323c 100644 --- a/app/containers/MessageActions.js +++ b/app/containers/MessageActions.js @@ -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; diff --git a/app/i18n/locales/en.js b/app/i18n/locales/en.js index 334e2c3d..091d5c5e 100644 --- a/app/i18n/locales/en.js +++ b/app/i18n/locales/en.js @@ -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', diff --git a/app/lib/rocketchat.js b/app/lib/rocketchat.js index 99893500..96ce1891 100644 --- a/app/lib/rocketchat.js +++ b/app/lib/rocketchat.js @@ -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) {