-
fdsigfudfsbigbfduigbdfb
+
+
some random name i dont know
JUST TIPPED YOU!
100sats
@@ -61,9 +61,9 @@
console.log(location.origin)
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
- const postID = urlParams.get("postID")
+ const accessId = urlParams.get("accessId")
var socket = io(`${location.origin}/streams`);
- socket.emit("postID",postID)
+ socket.emit("accessId",accessId)
let latestTimeout = null
socket.on("update",(update)=>{
const name = document.querySelector("#content-name")
diff --git a/src/routes.js b/src/routes.js
index 492087bd..77696517 100644
--- a/src/routes.js
+++ b/src/routes.js
@@ -37,6 +37,7 @@ const GunWriteRPC = require('../services/gunDB/rpc')
const Key = require('../services/gunDB/contact-api/key')
const { startedStream, endStream } = require('../services/streams')
const channelRequest = require('../utils/lightningServices/channelRequests')
+const TipsForwarder = require('../services/tipsCallback')
const DEFAULT_MAX_NUM_ROUTES_TO_QUERY = 10
const SESSION_ID = uuid()
@@ -2291,11 +2292,20 @@ module.exports = async (
app.post(`/api/gun/wall/`, async (req, res) => {
try {
- const { tags, title, contentItems } = req.body
+ const { tags, title, contentItems, enableTipsOverlay } = req.body
const SEA = require('../services/gunDB/Mediator').mySEA
- return res
- .status(200)
- .json(await GunActions.createPostNew(tags, title, contentItems, SEA))
+ const postRes = await GunActions.createPostNew(
+ tags,
+ title,
+ contentItems,
+ SEA
+ )
+ if (enableTipsOverlay) {
+ const [postID] = postRes
+ const accessId = TipsForwarder.enablePostNotifications(postID)
+ return res.status(200).json([...postRes, accessId])
+ }
+ return res.status(200).json(postRes)
} catch (e) {
console.log(e)
return res.status(500).json({
@@ -3348,6 +3358,18 @@ module.exports = async (
ap.get('/api/subscribeStream', (req, res) => {
res.sendFile(path.join(__dirname, '/index.html'))
})
+ ap.post('/api/enableNotificationsOverlay', (req, res) => {
+ const { postID } = req.body
+ if (!postID) {
+ return res.status(400).json({
+ errorMessage: 'no post id provided'
+ })
+ }
+ const accessId = TipsForwarder.enablePostNotifications(postID)
+ res.json({
+ accessId
+ })
+ })
//this is for wasLive/isLive status
ap.post('/api/listenStream', (req, res) => {
try {
diff --git a/src/sockets.js b/src/sockets.js
index 16838705..9273d1a5 100644
--- a/src/sockets.js
+++ b/src/sockets.js
@@ -186,10 +186,13 @@ module.exports = (
io.of('streams').on('connect', socket => {
console.log('a user connected')
- socket.on('postID', postID => {
- TipsForwarder.addSocket(postID, socket)
+ socket.on('accessId', accessId => {
+ const err = TipsForwarder.addSocket(accessId, socket)
+ if (err) {
+ console.log('err invalid socket for tips notifications ' + err)
+ socket.disconnect(true)
+ }
})
})
-
return io
}
diff --git a/utils/index.js b/utils/index.js
index 516d762a..09549b5d 100644
--- a/utils/index.js
+++ b/utils/index.js
@@ -10,7 +10,7 @@ const { asyncFilter } = require('./helpers')
*/
const gunUUID = () => {
// @ts-expect-error Not typed
- const uuid = Gun.Text.random()
+ const uuid = Gun.text.random()
return uuid
}