[IMPROVEMENT] Send tmid on slash commands and media (#1698)

This commit is contained in:
Djorkaeff Alexandre 2020-02-11 12:56:06 -03:00 committed by GitHub
parent e588c1fc08
commit 836683591c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 12 deletions

View File

@ -343,7 +343,9 @@ class MessageBox extends Component {
onPressCommandPreview = (item) => {
const { command } = this.state;
const { rid } = this.props;
const {
rid, tmid, message: { id: messageTmid }, replyCancel
} = this.props;
const { text } = this;
const name = text.substr(0, text.indexOf(' ')).slice(1);
const params = text.substr(text.indexOf(' ') + 1) || 'params';
@ -354,7 +356,8 @@ class MessageBox extends Component {
try {
const { appId } = command;
const triggerId = generateTriggerId(appId);
RocketChat.executeCommandPreview(name, params, rid, item, triggerId);
RocketChat.executeCommandPreview(name, params, rid, item, triggerId, tmid || messageTmid);
replyCancel();
} catch (e) {
log(e);
}
@ -500,7 +503,7 @@ class MessageBox extends Component {
sendMediaMessage = async(file) => {
const {
rid, tmid, baseUrl: server, user
rid, tmid, baseUrl: server, user, message: { id: messageTmid }, replyCancel
} = this.props;
this.setState({ file: { isVisible: false } });
const fileInfo = {
@ -512,7 +515,8 @@ class MessageBox extends Component {
path: file.path
};
try {
await RocketChat.sendFileMessage(rid, fileInfo, tmid, server, user);
replyCancel();
await RocketChat.sendFileMessage(rid, fileInfo, tmid || messageTmid, server, user);
Review.pushPositiveEvent();
} catch (e) {
log(e);
@ -647,7 +651,7 @@ class MessageBox extends Component {
submit = async() => {
const {
onSubmit, rid: roomId
onSubmit, rid: roomId, tmid
} = this.props;
const message = this.text;
@ -661,7 +665,7 @@ class MessageBox extends Component {
}
const {
editing, replying
editing, replying, message: { id: messageTmid }, replyCancel
} = this.props;
// Slash command
@ -677,7 +681,8 @@ class MessageBox extends Component {
const messageWithoutCommand = message.replace(/([^\s]+)/, '').trim();
const [{ appId }] = slashCommand;
const triggerId = generateTriggerId(appId);
RocketChat.runSlashCommand(command, roomId, messageWithoutCommand, triggerId);
RocketChat.runSlashCommand(command, roomId, messageWithoutCommand, triggerId, tmid || messageTmid);
replyCancel();
} catch (e) {
log(e);
}
@ -694,7 +699,7 @@ class MessageBox extends Component {
// Reply
} else if (replying) {
const {
message: replyingMessage, replyCancel, threadsEnabled, replyWithMention
message: replyingMessage, threadsEnabled, replyWithMention
} = this.props;
// Thread

View File

@ -1009,10 +1009,10 @@ const RocketChat = {
rid, updatedSince
});
},
runSlashCommand(command, roomId, params, triggerId) {
runSlashCommand(command, roomId, params, triggerId, tmid) {
// RC 0.60.2
return this.sdk.post('commands.run', {
command, roomId, params, triggerId
command, roomId, params, triggerId, tmid
});
},
getCommandPreview(command, roomId, params) {
@ -1021,10 +1021,10 @@ const RocketChat = {
command, roomId, params
});
},
executeCommandPreview(command, params, roomId, previewItem, triggerId) {
executeCommandPreview(command, params, roomId, previewItem, triggerId, tmid) {
// RC 0.65.0
return this.sdk.post('commands.preview', {
command, params, roomId, previewItem, triggerId
command, params, roomId, previewItem, triggerId, tmid
});
},
_setUser(ddpMessage) {