Post the new message to the server using replyTo

Signed-off-by: Marco Ambrosini <marcoambrosini@pm.me>
This commit is contained in:
Marco Ambrosini 2019-10-21 17:29:03 +02:00
Родитель b6acc6e512
Коммит 46b6e9b470
2 изменённых файлов: 12 добавлений и 4 удалений

Просмотреть файл

@ -96,6 +96,13 @@ export default {
token: this.token,
timestamp: 0
})
/**
* If the current message is a quote-reply messag, add the parent key to the
* temporary message object.
*/
if (this.messageToBeReplied) {
message.parent = this.messageToBeReplied
}
return message
},
/**
@ -106,7 +113,7 @@ export default {
*/
createTemporaryMessageId() {
const date = new Date()
return `temp_${(date.getTime()).toString()}`
return date.getTime()
},
/**
* Sends the new message

Просмотреть файл

@ -59,11 +59,12 @@ const lookForNewMessges = async function(token, lastKnownMessageId) {
*
* @param {object} param0 The message object that is destructured;
* @param {string} token The conversation token;
* @param {object} message The message object.
* @param {string} message The message object;
* @param {Object} parent The id of the message to be replied to.
*/
const postNewMessage = async function({ token, message, replyTo }) {
const postNewMessage = async function({ token, message, parent }) {
try {
const response = await axios.post(generateOcsUrl('apps/spreed/api/v1/chat', 2) + token, { message, actorDisplayName: '' })
const response = await axios.post(generateOcsUrl('apps/spreed/api/v1/chat', 2) + token, { message, actorDisplayName: '', replyTo: parent.id })
return response
} catch (error) {
console.debug(error)