Browse Source

amtToForward

dependabot/npm_and_yarn/ini-1.3.7
Evan Feenstra 4 years ago
parent
commit
3852e3900d
  1. 13
      dist/src/network/receive.js
  2. 2
      dist/src/network/receive.js.map
  3. 5
      dist/src/network/send.js
  4. 2
      dist/src/network/send.js.map
  5. 13
      src/network/receive.ts
  6. 5
      src/network/send.ts

13
dist/src/network/receive.js

@ -137,20 +137,22 @@ function onReceive(payload) {
}
// forward boost sats to recipient
let realSatsContactId = null;
let amtToForward = 0;
if (payload.type === msgtypes.boost && payload.message.replyUuid) {
const ogMsg = yield models_1.models.Message.findOne({ where: {
uuid: payload.message.replyUuid,
} });
if (ogMsg && ogMsg.sender && ogMsg.sender !== 1) {
const amtToForward = payload.message.amount - (chat.pricePerMessage || 0) - (chat.escrowAmount || 0);
if (amtToForward > 0) {
const theAmtToForward = payload.message.amount - (chat.pricePerMessage || 0) - (chat.escrowAmount || 0);
if (theAmtToForward > 0) {
realSatsContactId = ogMsg.sender;
amtToForward = theAmtToForward;
console.log('=======> ADMIN WILL FORWARD BOOST TO', ogMsg.sender);
}
}
}
if (doAction)
forwardMessageToTribe(payload, senderContact, realSatsContactId);
forwardMessageToTribe(payload, senderContact, realSatsContactId, amtToForward);
else
console.log('=> insufficient payment for this action');
}
@ -205,7 +207,7 @@ function doTheAction(data) {
}
});
}
function forwardMessageToTribe(ogpayload, sender, realSatsContactId) {
function forwardMessageToTribe(ogpayload, sender, realSatsContactId, amtToForward) {
return __awaiter(this, void 0, void 0, function* () {
// console.log('forwardMessageToTribe')
const chat = yield models_1.models.Chat.findOne({ where: { uuid: ogpayload.chat.uuid } });
@ -226,9 +228,10 @@ function forwardMessageToTribe(ogpayload, sender, realSatsContactId) {
send_1.sendMessage({
type, message,
sender: Object.assign(Object.assign(Object.assign({}, owner.dataValues), payload.sender && payload.sender.alias && { alias: payload.sender.alias }), { role: constants_1.default.chat_roles.reader }),
amount: amtToForward || 0,
chat: chat,
skipPubKey: payload.sender.pub_key,
realSatsContactId: realSatsContactId,
realSatsContactId,
success: () => { },
receive: () => { },
isForwarded: true,

2
dist/src/network/receive.js.map

File diff suppressed because one or more lines are too long

5
dist/src/network/send.js

@ -89,6 +89,11 @@ function sendMessage(params) {
let mqttTopic = networkType === 'mqtt' ? `${destkey}/${chatUUID}` : '';
// sending a payment to one subscriber, buying a pic from OG poster
// or boost to og poster
if (realSatsContactId) {
console.log("REAL SATS CONTACT ID", realSatsContactId);
console.log("is tribe owenr", isTribeOwner);
console.log('amount', amount);
}
if (isTribeOwner && amount && realSatsContactId === contactId) {
mqttTopic = ''; // FORCE KEYSEND!!!
}

2
dist/src/network/send.js.map

File diff suppressed because one or more lines are too long

13
src/network/receive.ts

@ -123,19 +123,21 @@ async function onReceive(payload){
}
// forward boost sats to recipient
let realSatsContactId = null
let amtToForward = 0
if(payload.type===msgtypes.boost && payload.message.replyUuid) {
const ogMsg = await models.Message.findOne({where:{
uuid: payload.message.replyUuid,
}})
if(ogMsg && ogMsg.sender && ogMsg.sender!==1) {
const amtToForward = payload.message.amount - (chat.pricePerMessage||0) - (chat.escrowAmount||0)
if(amtToForward>0) {
const theAmtToForward = payload.message.amount - (chat.pricePerMessage||0) - (chat.escrowAmount||0)
if(theAmtToForward>0) {
realSatsContactId = ogMsg.sender
amtToForward = theAmtToForward
console.log('=======> ADMIN WILL FORWARD BOOST TO',ogMsg.sender)
}
}
}
if(doAction) forwardMessageToTribe(payload, senderContact, realSatsContactId)
if(doAction) forwardMessageToTribe(payload, senderContact, realSatsContactId, amtToForward)
else console.log('=> insufficient payment for this action')
}
if(isTribeOwner && payload.type===msgtypes.purchase) {
@ -185,7 +187,7 @@ async function doTheAction(data){
}
}
async function forwardMessageToTribe(ogpayload, sender, realSatsContactId){
async function forwardMessageToTribe(ogpayload, sender, realSatsContactId, amtToForward){
// console.log('forwardMessageToTribe')
const chat = await models.Chat.findOne({where:{uuid:ogpayload.chat.uuid}})
@ -210,9 +212,10 @@ async function forwardMessageToTribe(ogpayload, sender, realSatsContactId){
...payload.sender&&payload.sender.alias && {alias:payload.sender.alias},
role: constants.chat_roles.reader,
},
amount: amtToForward||0,
chat: chat,
skipPubKey: payload.sender.pub_key,
realSatsContactId: realSatsContactId,
realSatsContactId,
success: ()=>{},
receive: ()=>{},
isForwarded: true,

5
src/network/send.ts

@ -86,6 +86,11 @@ export async function sendMessage(params) {
// sending a payment to one subscriber, buying a pic from OG poster
// or boost to og poster
if(realSatsContactId) {
console.log("REAL SATS CONTACT ID",realSatsContactId)
console.log("is tribe owenr",isTribeOwner)
console.log('amount', amount)
}
if(isTribeOwner && amount && realSatsContactId===contactId) {
mqttTopic = '' // FORCE KEYSEND!!!
}

Loading…
Cancel
Save