logs
This commit is contained in:
parent
ff1589e644
commit
7a51780a6e
7 changed files with 38 additions and 16 deletions
|
|
@ -112,6 +112,10 @@ const onReceivedReqs = cb => {
|
|||
cb(getReceivedReqs())
|
||||
|
||||
if (!subbed) {
|
||||
const user = require('../../Mediator').getUser()
|
||||
if (!user.is) {
|
||||
logger.warn('Tried subscribing to onReceivedReqs without authing')
|
||||
}
|
||||
require('./index').onCurrentHandshakeAddress(addr => {
|
||||
if (currentAddress === addr) {
|
||||
return
|
||||
|
|
@ -128,7 +132,7 @@ const onReceivedReqs = cb => {
|
|||
.get(addr)
|
||||
.open(listenerForAddr(addr))
|
||||
}
|
||||
}, require('../../Mediator').getUser())
|
||||
}, user)
|
||||
|
||||
Streams.onAvatar(react)
|
||||
Streams.onDisplayName(react)
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ let procid = 0
|
|||
*/
|
||||
const onAcceptedRequests = (user, SEA) => {
|
||||
if (!user.is) {
|
||||
logger.warn('onAcceptedRequests() -> tried to sub without authing')
|
||||
throw new Error(ErrorCode.NOT_AUTH)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,6 +26,9 @@ let currentOrderAddr = ''
|
|||
* @returns {(order: ListenerData, orderID: string) => void}
|
||||
*/
|
||||
const listenerForAddr = (addr, user, SEA) => async (order, orderID) => {
|
||||
if (!user.is) {
|
||||
logger.warn('onOrders -> listenerForAddr() -> tried to sub without authing')
|
||||
}
|
||||
try {
|
||||
if (addr !== currentOrderAddr) {
|
||||
return
|
||||
|
|
@ -97,6 +100,7 @@ const listenerForAddr = (addr, user, SEA) => async (order, orderID) => {
|
|||
*/
|
||||
const onOrders = (user, gun, SEA) => {
|
||||
if (!user.is) {
|
||||
logger.warn('onOrders() -> tried to sub without authing')
|
||||
throw new Error(ErrorCode.NOT_AUTH)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
/** @format */
|
||||
const logger = require('winston')
|
||||
|
||||
const Key = require('../key')
|
||||
|
||||
/** @type {Record<string, string|null|undefined>} */
|
||||
|
|
@ -18,10 +20,13 @@ const onLastSentReqIDs = cb => {
|
|||
cb()
|
||||
|
||||
if (!subbed) {
|
||||
require('../../Mediator')
|
||||
.getUser()
|
||||
.get(Key.USER_TO_LAST_REQUEST_SENT)
|
||||
.open(data => {
|
||||
const user = require('../../Mediator').getUser()
|
||||
if (!user.is) {
|
||||
logger.warn('lastSentReqID() -> tried to sub without authing')
|
||||
throw new Error('NOT_AUTH')
|
||||
}
|
||||
|
||||
user.get(Key.USER_TO_LAST_REQUEST_SENT).open(data => {
|
||||
if (typeof data === 'object' && data !== null) {
|
||||
for (const [pub, id] of Object.entries(data)) {
|
||||
if (typeof id === 'string' || id === null) {
|
||||
|
|
|
|||
|
|
@ -137,6 +137,9 @@ const onOpenForPubFeedPair = ([pub, feed]) =>
|
|||
pubToLastUpdate[pub] = thisUpdate
|
||||
|
||||
const user = require('../../Mediator').getUser()
|
||||
if (!user.is) {
|
||||
logger.warn('pubToFeed -> onOpenForPubFeedPair() -> user is not auth')
|
||||
}
|
||||
const SEA = require('../../Mediator').mySEA
|
||||
|
||||
const ourSecret = await SEA.secret(await Utils.pubToEpub(pub), user._.sea)
|
||||
|
|
|
|||
|
|
@ -82,6 +82,9 @@ const onPubToIncoming = cb => {
|
|||
|
||||
if (!subbed) {
|
||||
const user = require('../../Mediator').getUser()
|
||||
if (!user.is) {
|
||||
logger.warn(`subscribing to pubToIncoming on a unauth user`)
|
||||
}
|
||||
user.get(USER_TO_INCOMING).open(onOpen)
|
||||
subbed = true
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1594,6 +1594,7 @@ module.exports = async (
|
|||
// spinup
|
||||
Events.onSimplerSentRequests(() => {})()
|
||||
const data = Events.getCurrentSentReqs()
|
||||
logger.info(`Sent requests poll: ${JSON.stringify(data, null, 4)}`)
|
||||
res.json({
|
||||
data,
|
||||
})
|
||||
|
|
@ -1611,6 +1612,7 @@ module.exports = async (
|
|||
// spinup
|
||||
Events.onChats(() => {})()
|
||||
const data = Events.getChats()
|
||||
logger.info(`Chats polled: ${JSON.stringify(data, null, 4)}`)
|
||||
res.json({
|
||||
data
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue