Browse Source

no publickey condition

q-apps
Phillip Lang Martinez 2 years ago
parent
commit
0d1646b2b5
  1. 43
      qortal-ui-plugins/plugins/core/components/ChatPage.js
  2. 15
      qortal-ui-plugins/plugins/core/messaging/q-chat/q-chat.src.js

43
qortal-ui-plugins/plugins/core/components/ChatPage.js

@ -1673,6 +1673,39 @@ class ChatPage extends LitElement {
} }
async _sendMessage(outSideMsg) { async _sendMessage(outSideMsg) {
if(this.isReceipient){
let hasPublicKey = true
if(!this._publicKey.hasPubKey){
hasPublicKey = false
try {
const res = await parentEpml.request('apiCall', {
type: 'api',
url: `/addresses/publickey/${this.selectedAddress.address}`
})
if (res.error === 102) {
this._publicKey.key = ''
this._publicKey.hasPubKey = false
} else if (res !== false) {
this._publicKey.key = res
this._publicKey.hasPubKey = true
hasPublicKey = true
} else {
this._publicKey.key = ''
this._publicKey.hasPubKey = false
}
} catch (error) {
console.error(error);
}
if(!hasPublicKey || !this._publicKey.hasPubKey){
let err4string = get("chatpage.cchange39");
parentEpml.request('showSnackBar', `${err4string}`)
return
}
}
}
console.log(outSideMsg); console.log(outSideMsg);
// have params to determine if it's a reply or not // have params to determine if it's a reply or not
// have variable to determine if it's a response, holds signature in constructor // have variable to determine if it's a response, holds signature in constructor
@ -1997,7 +2030,7 @@ class ChatPage extends LitElement {
message: messageText, message: messageText,
lastReference: reference, lastReference: reference,
proofOfWorkNonce: 0, proofOfWorkNonce: 0,
isEncrypted: this._publicKey.hasPubKey === false ? 0 : 1, isEncrypted: 1,
isText: 1 isText: 1
} }
}); });
@ -2081,6 +2114,12 @@ class ChatPage extends LitElement {
this.openForwardOpen = false; this.openForwardOpen = false;
this.chatEditor.enable(); this.chatEditor.enable();
if (isRecipient === true) { if (isRecipient === true) {
if(!publicKey.hasPubKey){
let err4string = get("chatpage.cchange39");
parentEpml.request('showSnackBar', `${err4string}`)
getSendChatResponse(false)
return
}
let chatResponse = await parentEpml.request('chat', { let chatResponse = await parentEpml.request('chat', {
type: 18, type: 18,
nonce: this.selectedAddress.nonce, nonce: this.selectedAddress.nonce,
@ -2093,7 +2132,7 @@ class ChatPage extends LitElement {
message: messageText, message: messageText,
lastReference: reference, lastReference: reference,
proofOfWorkNonce: 0, proofOfWorkNonce: 0,
isEncrypted: publicKey.hasPubKey === false ? 0 : 1, isEncrypted: 1,
isText: 1 isText: 1
} }
}); });

15
qortal-ui-plugins/plugins/core/messaging/q-chat/q-chat.src.js

@ -199,7 +199,11 @@ class Chat extends LitElement {
</button> </button>
<button <button
class="modal-button" class="modal-button"
@click=${this._sendMessage} @click=${()=> {
this.chatEditor.updateMirror()
this._sendMessage()
}}
?disabled="${this.isLoading}"> ?disabled="${this.isLoading}">
${this.isLoading === false ${this.isLoading === false
? this.renderSendText() ? this.renderSendText()
@ -501,9 +505,10 @@ class Chat extends LitElement {
_publicKey = addressPublicKey; _publicKey = addressPublicKey;
sendMessageRequest(isEncrypted, _publicKey); sendMessageRequest(isEncrypted, _publicKey);
} else { } else {
isEncrypted = 0; let err4string = get("chatpage.cchange39");
_publicKey = this.selectedAddress.address; parentEpml.request('showSnackBar', `${err4string}`);
sendMessageRequest(isEncrypted, _publicKey); this.chatEditor.enable();
this.isLoading = false;
} }
}; };
let _reference = new Uint8Array(64); let _reference = new Uint8Array(64);
@ -521,7 +526,7 @@ class Chat extends LitElement {
message: messageText, message: messageText,
lastReference: reference, lastReference: reference,
proofOfWorkNonce: 0, proofOfWorkNonce: 0,
isEncrypted: isEncrypted, isEncrypted: 1,
isText: 1 isText: 1
} }
}); });

Loading…
Cancel
Save