|
@ -18,6 +18,7 @@ const tribes = require("../utils/tribes"); |
|
|
const confirmations_1 = require("../controllers/confirmations"); |
|
|
const confirmations_1 = require("../controllers/confirmations"); |
|
|
const receive_1 = require("./receive"); |
|
|
const receive_1 = require("./receive"); |
|
|
const constants = require(path.join(__dirname, '../../config/constants.json')); |
|
|
const constants = require(path.join(__dirname, '../../config/constants.json')); |
|
|
|
|
|
const MIN_SATS = 3; |
|
|
function sendMessage(params) { |
|
|
function sendMessage(params) { |
|
|
return __awaiter(this, void 0, void 0, function* () { |
|
|
return __awaiter(this, void 0, void 0, function* () { |
|
|
const { type, chat, message, sender, amount, success, failure, skipPubKey } = params; |
|
|
const { type, chat, message, sender, amount, success, failure, skipPubKey } = params; |
|
@ -75,14 +76,18 @@ function sendMessage(params) { |
|
|
return; // skip (for tribe owner broadcasting, not back to the sender)
|
|
|
return; // skip (for tribe owner broadcasting, not back to the sender)
|
|
|
} |
|
|
} |
|
|
console.log('-> sending to ', contact.id, destkey); |
|
|
console.log('-> sending to ', contact.id, destkey); |
|
|
|
|
|
let mqttTopic = networkType === 'mqtt' ? `${destkey}/${chatUUID}` : ''; |
|
|
|
|
|
// sending a payment to one subscriber (like buying a pic)
|
|
|
|
|
|
if (isTribeOwner && contactIds.length === 1 && amount && amount > MIN_SATS) { |
|
|
|
|
|
mqttTopic = ''; // FORCE KEYSEND!!!
|
|
|
|
|
|
} |
|
|
const m = yield msg_1.personalizeMessage(msg, contact, isTribeOwner); |
|
|
const m = yield msg_1.personalizeMessage(msg, contact, isTribeOwner); |
|
|
const opts = { |
|
|
const opts = { |
|
|
dest: destkey, |
|
|
dest: destkey, |
|
|
data: m, |
|
|
data: m, |
|
|
amt: Math.max((amount || 0), 3) |
|
|
amt: Math.max((amount || 0), MIN_SATS) |
|
|
}; |
|
|
}; |
|
|
try { |
|
|
try { |
|
|
const mqttTopic = networkType === 'mqtt' ? `${destkey}/${chatUUID}` : ''; |
|
|
|
|
|
const r = yield signAndSend(opts, mqttTopic); |
|
|
const r = yield signAndSend(opts, mqttTopic); |
|
|
yes = r; |
|
|
yes = r; |
|
|
} |
|
|
} |
|
@ -116,6 +121,7 @@ function signAndSend(opts, mqttTopic, replayingHistory) { |
|
|
let data = JSON.stringify(opts.data || {}); |
|
|
let data = JSON.stringify(opts.data || {}); |
|
|
opts.amt = opts.amt || 0; |
|
|
opts.amt = opts.amt || 0; |
|
|
console.log("==> AMOuNTS TO SEND!", opts.amt); |
|
|
console.log("==> AMOuNTS TO SEND!", opts.amt); |
|
|
|
|
|
console.log("==> NETWOrK TYPE:", mqttTopic ? 'mqtt' : 'lightning'); |
|
|
const sig = yield signer.signAscii(data); |
|
|
const sig = yield signer.signAscii(data); |
|
|
data = data + sig; |
|
|
data = data + sig; |
|
|
// console.log("ACTUALLY SEND", mqttTopic)
|
|
|
// console.log("ACTUALLY SEND", mqttTopic)
|
|
|