[IMPROVEMENT] Send tmid on slash commands and media (#1698)
This commit is contained in:
parent
e588c1fc08
commit
836683591c
|
@ -343,7 +343,9 @@ class MessageBox extends Component {
|
||||||
|
|
||||||
onPressCommandPreview = (item) => {
|
onPressCommandPreview = (item) => {
|
||||||
const { command } = this.state;
|
const { command } = this.state;
|
||||||
const { rid } = this.props;
|
const {
|
||||||
|
rid, tmid, message: { id: messageTmid }, replyCancel
|
||||||
|
} = this.props;
|
||||||
const { text } = this;
|
const { text } = this;
|
||||||
const name = text.substr(0, text.indexOf(' ')).slice(1);
|
const name = text.substr(0, text.indexOf(' ')).slice(1);
|
||||||
const params = text.substr(text.indexOf(' ') + 1) || 'params';
|
const params = text.substr(text.indexOf(' ') + 1) || 'params';
|
||||||
|
@ -354,7 +356,8 @@ class MessageBox extends Component {
|
||||||
try {
|
try {
|
||||||
const { appId } = command;
|
const { appId } = command;
|
||||||
const triggerId = generateTriggerId(appId);
|
const triggerId = generateTriggerId(appId);
|
||||||
RocketChat.executeCommandPreview(name, params, rid, item, triggerId);
|
RocketChat.executeCommandPreview(name, params, rid, item, triggerId, tmid || messageTmid);
|
||||||
|
replyCancel();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log(e);
|
log(e);
|
||||||
}
|
}
|
||||||
|
@ -500,7 +503,7 @@ class MessageBox extends Component {
|
||||||
|
|
||||||
sendMediaMessage = async(file) => {
|
sendMediaMessage = async(file) => {
|
||||||
const {
|
const {
|
||||||
rid, tmid, baseUrl: server, user
|
rid, tmid, baseUrl: server, user, message: { id: messageTmid }, replyCancel
|
||||||
} = this.props;
|
} = this.props;
|
||||||
this.setState({ file: { isVisible: false } });
|
this.setState({ file: { isVisible: false } });
|
||||||
const fileInfo = {
|
const fileInfo = {
|
||||||
|
@ -512,7 +515,8 @@ class MessageBox extends Component {
|
||||||
path: file.path
|
path: file.path
|
||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
await RocketChat.sendFileMessage(rid, fileInfo, tmid, server, user);
|
replyCancel();
|
||||||
|
await RocketChat.sendFileMessage(rid, fileInfo, tmid || messageTmid, server, user);
|
||||||
Review.pushPositiveEvent();
|
Review.pushPositiveEvent();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log(e);
|
log(e);
|
||||||
|
@ -647,7 +651,7 @@ class MessageBox extends Component {
|
||||||
|
|
||||||
submit = async() => {
|
submit = async() => {
|
||||||
const {
|
const {
|
||||||
onSubmit, rid: roomId
|
onSubmit, rid: roomId, tmid
|
||||||
} = this.props;
|
} = this.props;
|
||||||
const message = this.text;
|
const message = this.text;
|
||||||
|
|
||||||
|
@ -661,7 +665,7 @@ class MessageBox extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
const {
|
const {
|
||||||
editing, replying
|
editing, replying, message: { id: messageTmid }, replyCancel
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
// Slash command
|
// Slash command
|
||||||
|
@ -677,7 +681,8 @@ class MessageBox extends Component {
|
||||||
const messageWithoutCommand = message.replace(/([^\s]+)/, '').trim();
|
const messageWithoutCommand = message.replace(/([^\s]+)/, '').trim();
|
||||||
const [{ appId }] = slashCommand;
|
const [{ appId }] = slashCommand;
|
||||||
const triggerId = generateTriggerId(appId);
|
const triggerId = generateTriggerId(appId);
|
||||||
RocketChat.runSlashCommand(command, roomId, messageWithoutCommand, triggerId);
|
RocketChat.runSlashCommand(command, roomId, messageWithoutCommand, triggerId, tmid || messageTmid);
|
||||||
|
replyCancel();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log(e);
|
log(e);
|
||||||
}
|
}
|
||||||
|
@ -694,7 +699,7 @@ class MessageBox extends Component {
|
||||||
// Reply
|
// Reply
|
||||||
} else if (replying) {
|
} else if (replying) {
|
||||||
const {
|
const {
|
||||||
message: replyingMessage, replyCancel, threadsEnabled, replyWithMention
|
message: replyingMessage, threadsEnabled, replyWithMention
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
// Thread
|
// Thread
|
||||||
|
|
|
@ -1009,10 +1009,10 @@ const RocketChat = {
|
||||||
rid, updatedSince
|
rid, updatedSince
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
runSlashCommand(command, roomId, params, triggerId) {
|
runSlashCommand(command, roomId, params, triggerId, tmid) {
|
||||||
// RC 0.60.2
|
// RC 0.60.2
|
||||||
return this.sdk.post('commands.run', {
|
return this.sdk.post('commands.run', {
|
||||||
command, roomId, params, triggerId
|
command, roomId, params, triggerId, tmid
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
getCommandPreview(command, roomId, params) {
|
getCommandPreview(command, roomId, params) {
|
||||||
|
@ -1021,10 +1021,10 @@ const RocketChat = {
|
||||||
command, roomId, params
|
command, roomId, params
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
executeCommandPreview(command, params, roomId, previewItem, triggerId) {
|
executeCommandPreview(command, params, roomId, previewItem, triggerId, tmid) {
|
||||||
// RC 0.65.0
|
// RC 0.65.0
|
||||||
return this.sdk.post('commands.preview', {
|
return this.sdk.post('commands.preview', {
|
||||||
command, params, roomId, previewItem, triggerId
|
command, params, roomId, previewItem, triggerId, tmid
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
_setUser(ddpMessage) {
|
_setUser(ddpMessage) {
|
||||||
|
|
Loading…
Reference in New Issue