Add the sender address in message
This commit is contained in:
parent
870fdc831f
commit
bcabeb9a0f
@ -105,7 +105,9 @@ class Services {
|
||||
const recipientSpAddress = spAddressElement.value;
|
||||
const message = messageElement.value;
|
||||
|
||||
let notificationInfo = await services.notify_address_for_message(recipientSpAddress, message);
|
||||
const msg_payload = JSON.stringify({sender: this.sp_address, payload: message});
|
||||
|
||||
let notificationInfo = await services.notify_address_for_message(recipientSpAddress, msg_payload);
|
||||
if (notificationInfo) {
|
||||
let ciphers: string[] = [];
|
||||
console.info('Successfully sent notification transaction');
|
||||
@ -113,7 +115,7 @@ class Services {
|
||||
// encrypt the message(s)
|
||||
for (const [address, ankSharedSecret] of Object.entries(notificationInfo.address2secret)) {
|
||||
try {
|
||||
let cipher = await services.encryptData(message, ankSharedSecret.secret);
|
||||
let cipher = await services.encryptData(msg_payload, ankSharedSecret.secret);
|
||||
ciphers.push(cipher);
|
||||
} catch (error) {
|
||||
throw error;
|
||||
@ -821,7 +823,8 @@ class Services {
|
||||
|
||||
try {
|
||||
const feeRate = 1;
|
||||
let notificationInfo: createNotificationTransactionReturn = services.sdkClient.create_notification_transaction(sp_address, message, feeRate);
|
||||
const commitment = services.sdkClient.create_commitment(message);
|
||||
let notificationInfo: createNotificationTransactionReturn = services.sdkClient.create_notification_transaction(sp_address, commitment, feeRate);
|
||||
const flag: AnkFlag = "NewTx";
|
||||
const newTxMsg: NewTxMessage = {
|
||||
'transaction': notificationInfo.transaction,
|
||||
|
@ -33,7 +33,16 @@ class WebSocketClient {
|
||||
window.alert(`New tx\n${res.message}`);
|
||||
await services.updateOwnedOutputsForUser();
|
||||
} else if (res.topic === 'unknown') {
|
||||
window.alert(`new message: ${res.message}`);
|
||||
// Do we have a json with a sender?
|
||||
try {
|
||||
let parsed = JSON.parse(res.message);
|
||||
if (parsed.sender !== undefined) {
|
||||
console.info(`Message sent by ${parsed.sender}`);
|
||||
}
|
||||
window.alert(`new message: ${parsed.payload}`);
|
||||
} catch (_) {
|
||||
window.alert(`new message: ${res.message}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user