+
+ fdsigfudfsbigbfduigbdfb
+JUST TIPPED YOU!
+100sats
+diff --git a/services/gunDB/contact-api/actions.js b/services/gunDB/contact-api/actions.js index 39831095..ec8c66fe 100644 --- a/services/gunDB/contact-api/actions.js +++ b/services/gunDB/contact-api/actions.js @@ -1090,12 +1090,16 @@ const sendSpontaneousPayment = async ( const { num_satoshis: decodedAmt } = await decodePayReq(encodedInvoice) if (decodedAmt !== amount.toString()) { - throw new Error('Invoice amount mismatch') + throw new Error( + `Invoice amount mismatch got: ${decodedAmt} expected: ${amount.toString()}` + ) } // double check if (Number(decodedAmt) !== amount) { - throw new Error('Invoice amount mismatch') + throw new Error( + `Invoice amount mismatch got:${decodedAmt} expected:${amount.toString()}` + ) } logger.info('Will now send payment through lightning') diff --git a/services/gunDB/contact-api/jobs/onOrders.js b/services/gunDB/contact-api/jobs/onOrders.js index 23bfbf0a..34e80a25 100644 --- a/services/gunDB/contact-api/jobs/onOrders.js +++ b/services/gunDB/contact-api/jobs/onOrders.js @@ -18,6 +18,8 @@ const Utils = require('../utils') const Gun = require('gun') const { selfContentToken, enrollContentTokens } = require('../../../seed') +const TipForwarder = require('../../../tipsCallback') + const getUser = () => require('../../Mediator').getUser() /** @@ -278,6 +280,13 @@ const listenerForAddr = (addr, SEA) => async (order, orderID) => { .get('postToTipCount') .get(postID) .set(null) // each item in the set is a tip + + TipForwarder.notifySocketIfAny( + postID, + order.from, + 'TIPPED YOU', + amt + ' sats' + ) break } case 'spontaneousPayment': { diff --git a/services/tipsCallback.js b/services/tipsCallback.js new file mode 100644 index 00000000..fca084a7 --- /dev/null +++ b/services/tipsCallback.js @@ -0,0 +1,30 @@ +//@ts-nocheck TODO- fix types +class TipsCB { + listeners = {} + + addSocket(postID,socket){ + console.log("subbing new socket for post: "+postID) + + if(!this.listeners[postID]){ + this.listeners[postID] = [] + } + this.listeners[postID].push(socket) + } + + notifySocketIfAny(postID,name,message,amount){ + if(!this.listeners[postID]){ + return + } + this.listeners[postID].forEach(socket => { + if(!socket.connected){ + return + } + socket.emit("update",{ + name,message,amount + }) + }); + } +} + +const TipsForwarder = new TipsCB() +module.exports = TipsForwarder \ No newline at end of file diff --git a/src/index.html b/src/index.html new file mode 100644 index 00000000..d376198f --- /dev/null +++ b/src/index.html @@ -0,0 +1,85 @@ + + +
+ + + +