edit messages
This commit is contained in:
@@ -234,6 +234,8 @@ var Chat = {
|
||||
|
||||
if (text == '') {
|
||||
Chat.disableSending();
|
||||
} else if (Chat.getOmemoState() == 'yes') {
|
||||
Chat.sendEncryptedCorrection(jid, textarea.dataset.mid, text, isMuc);
|
||||
} else {
|
||||
let correct = Chat_ajaxHttpDaemonCorrect(jid, textarea.dataset.mid, text);
|
||||
correct.then(e => {
|
||||
@@ -301,6 +303,35 @@ var Chat = {
|
||||
}
|
||||
}
|
||||
},
|
||||
sendEncryptedCorrection: function (jid, mid, text, isMuc) {
|
||||
let omemo = ChatOmemo.encrypt(jid, text, isMuc);
|
||||
|
||||
if (!omemo) {
|
||||
Chat.failedMessage(text);
|
||||
return;
|
||||
}
|
||||
|
||||
omemo.then(omemoheader => {
|
||||
let id = omemoheader.id = crypto.randomUUID();
|
||||
Chat.tempMessages[id] = text;
|
||||
|
||||
Chat_ajaxHttpDaemonCorrect(jid, mid, null, omemoheader)
|
||||
.then(e => Chat.sentMessage())
|
||||
.catch(e => Chat.failedMessage(text));
|
||||
});
|
||||
},
|
||||
// The server cannot read encrypted messages, the text comes from this browser
|
||||
editEncrypted: function (id, mid) {
|
||||
if (typeof ChatOmemoDB == 'undefined') return;
|
||||
|
||||
ChatOmemoDB.getMessage(id).then(text => {
|
||||
if (typeof text == 'string' && text != '' && !AESGCM_REGEX.test(text.trim())) {
|
||||
Chat.setTextarea(text, mid);
|
||||
} else {
|
||||
Toast.send(Chat.action_impossible_encrypted_error);
|
||||
}
|
||||
});
|
||||
},
|
||||
sentId: function (id) {
|
||||
if (Chat.tempMessages[id]) {
|
||||
ChatOmemoDB.putMessage(id, Chat.tempMessages[id]);
|
||||
@@ -405,11 +436,7 @@ var Chat = {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Chat.isEncrypted()) {
|
||||
Chat_ajaxLast(textarea.dataset.jid, Boolean(textarea.dataset.muc));
|
||||
} else {
|
||||
Toast.send(Chat.action_impossible_encrypted_error);
|
||||
}
|
||||
Chat_ajaxLast(textarea.dataset.jid, Boolean(textarea.dataset.muc));
|
||||
},
|
||||
resolveMessage: function (mid) {
|
||||
ChatActions_ajaxResolveMessage(mid);
|
||||
@@ -443,7 +470,7 @@ var Chat = {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.key == 'ArrowUp' && !Chat.isEncrypted()) {
|
||||
if (event.key == 'ArrowUp') {
|
||||
Chat.editPrevious();
|
||||
} else if (event.key == 'Escape'
|
||||
&& (this.value == '' || Chat.edit == true)) {
|
||||
|
||||
Reference in New Issue
Block a user