logs
This commit is contained in:
parent
2fee9974b5
commit
8b7ad32d77
1 changed files with 7 additions and 3 deletions
|
|
@ -6,11 +6,13 @@ const { listPeers, connectPeer,getInfo } = require('./v2')
|
||||||
const handlerBaseUrl = "https://channels.shock.network:4444"
|
const handlerBaseUrl = "https://channels.shock.network:4444"
|
||||||
|
|
||||||
module.exports = async () => {
|
module.exports = async () => {
|
||||||
|
console.log("DOING CHANNEL INVITE THING: START")
|
||||||
/**
|
/**
|
||||||
* @type string | undefined
|
* @type string | undefined
|
||||||
*/
|
*/
|
||||||
const invite = process.env.HOSTING_INVITE
|
const invite = process.env.HOSTING_INVITE
|
||||||
if(!invite) {
|
if(!invite) {
|
||||||
|
console.log("DOING CHANNEL INVITE THING: NVM NO INVITE")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
|
@ -19,17 +21,17 @@ module.exports = async () => {
|
||||||
*/
|
*/
|
||||||
const invites = await Storage.getItem('processedInvites') || []
|
const invites = await Storage.getItem('processedInvites') || []
|
||||||
if(invites.includes(invite)){
|
if(invites.includes(invite)){
|
||||||
|
console.log("DOING CHANNEL INVITE THING: INVITE PROCESSED ALREADY")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const me = await getInfo()
|
const me = await getInfo()
|
||||||
const {identity_pubkey} = me
|
const {identity_pubkey} = me
|
||||||
//@ts-expect-error
|
//@ts-expect-error
|
||||||
const connectReq = await fetch(`${handlerBaseUrl}/connect`)
|
const connectReq = await fetch(`${handlerBaseUrl}/connect`)
|
||||||
if(connectReq.status !== 200 ){
|
if(connectReq.status !== 200 ){
|
||||||
|
console.log("DOING CHANNEL INVITE THING: CONNECT FAILED")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const connJson = await connectReq.json()
|
const connJson = await connectReq.json()
|
||||||
const [uri] = connJson.uris
|
const [uri] = connJson.uris
|
||||||
const [pub,host] = uri.split("@")
|
const [pub,host] = uri.split("@")
|
||||||
|
|
@ -51,13 +53,15 @@ module.exports = async () => {
|
||||||
body:JSON.stringify(channelReq)
|
body:JSON.stringify(channelReq)
|
||||||
})
|
})
|
||||||
if(res.status !== 200 ){
|
if(res.status !== 200 ){
|
||||||
|
console.log("DOING CHANNEL INVITE THING: FAILED ")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
invites.push(invite)
|
invites.push(invite)
|
||||||
await Storage.setItem('processedInvites',invites)
|
await Storage.setItem('processedInvites',invites)
|
||||||
|
console.log("DOING CHANNEL INVITE THING: DONE!")
|
||||||
} catch(e){
|
} catch(e){
|
||||||
logger.error("error sending invite to channels handler")
|
logger.error("error sending invite to channels handler")
|
||||||
|
console.log("DOING CHANNEL INVITE THING: :(")
|
||||||
console.error(e)
|
console.error(e)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue