This commit is contained in:
Daniel Lugo 2020-02-27 17:12:13 -04:00
parent ff1589e644
commit 7a51780a6e
7 changed files with 38 additions and 16 deletions

View file

@ -112,6 +112,10 @@ const onReceivedReqs = cb => {
cb(getReceivedReqs()) cb(getReceivedReqs())
if (!subbed) { if (!subbed) {
const user = require('../../Mediator').getUser()
if (!user.is) {
logger.warn('Tried subscribing to onReceivedReqs without authing')
}
require('./index').onCurrentHandshakeAddress(addr => { require('./index').onCurrentHandshakeAddress(addr => {
if (currentAddress === addr) { if (currentAddress === addr) {
return return
@ -128,7 +132,7 @@ const onReceivedReqs = cb => {
.get(addr) .get(addr)
.open(listenerForAddr(addr)) .open(listenerForAddr(addr))
} }
}, require('../../Mediator').getUser()) }, user)
Streams.onAvatar(react) Streams.onAvatar(react)
Streams.onDisplayName(react) Streams.onDisplayName(react)

View file

@ -24,6 +24,7 @@ let procid = 0
*/ */
const onAcceptedRequests = (user, SEA) => { const onAcceptedRequests = (user, SEA) => {
if (!user.is) { if (!user.is) {
logger.warn('onAcceptedRequests() -> tried to sub without authing')
throw new Error(ErrorCode.NOT_AUTH) throw new Error(ErrorCode.NOT_AUTH)
} }

View file

@ -26,6 +26,9 @@ let currentOrderAddr = ''
* @returns {(order: ListenerData, orderID: string) => void} * @returns {(order: ListenerData, orderID: string) => void}
*/ */
const listenerForAddr = (addr, user, SEA) => async (order, orderID) => { const listenerForAddr = (addr, user, SEA) => async (order, orderID) => {
if (!user.is) {
logger.warn('onOrders -> listenerForAddr() -> tried to sub without authing')
}
try { try {
if (addr !== currentOrderAddr) { if (addr !== currentOrderAddr) {
return return
@ -97,6 +100,7 @@ const listenerForAddr = (addr, user, SEA) => async (order, orderID) => {
*/ */
const onOrders = (user, gun, SEA) => { const onOrders = (user, gun, SEA) => {
if (!user.is) { if (!user.is) {
logger.warn('onOrders() -> tried to sub without authing')
throw new Error(ErrorCode.NOT_AUTH) throw new Error(ErrorCode.NOT_AUTH)
} }

View file

@ -1,4 +1,6 @@
/** @format */ /** @format */
const logger = require('winston')
const Key = require('../key') const Key = require('../key')
/** @type {Record<string, string|null|undefined>} */ /** @type {Record<string, string|null|undefined>} */
@ -18,10 +20,13 @@ const onLastSentReqIDs = cb => {
cb() cb()
if (!subbed) { if (!subbed) {
require('../../Mediator') const user = require('../../Mediator').getUser()
.getUser() if (!user.is) {
.get(Key.USER_TO_LAST_REQUEST_SENT) logger.warn('lastSentReqID() -> tried to sub without authing')
.open(data => { throw new Error('NOT_AUTH')
}
user.get(Key.USER_TO_LAST_REQUEST_SENT).open(data => {
if (typeof data === 'object' && data !== null) { if (typeof data === 'object' && data !== null) {
for (const [pub, id] of Object.entries(data)) { for (const [pub, id] of Object.entries(data)) {
if (typeof id === 'string' || id === null) { if (typeof id === 'string' || id === null) {

View file

@ -137,6 +137,9 @@ const onOpenForPubFeedPair = ([pub, feed]) =>
pubToLastUpdate[pub] = thisUpdate pubToLastUpdate[pub] = thisUpdate
const user = require('../../Mediator').getUser() const user = require('../../Mediator').getUser()
if (!user.is) {
logger.warn('pubToFeed -> onOpenForPubFeedPair() -> user is not auth')
}
const SEA = require('../../Mediator').mySEA const SEA = require('../../Mediator').mySEA
const ourSecret = await SEA.secret(await Utils.pubToEpub(pub), user._.sea) const ourSecret = await SEA.secret(await Utils.pubToEpub(pub), user._.sea)

View file

@ -82,6 +82,9 @@ const onPubToIncoming = cb => {
if (!subbed) { if (!subbed) {
const user = require('../../Mediator').getUser() const user = require('../../Mediator').getUser()
if (!user.is) {
logger.warn(`subscribing to pubToIncoming on a unauth user`)
}
user.get(USER_TO_INCOMING).open(onOpen) user.get(USER_TO_INCOMING).open(onOpen)
subbed = true subbed = true
} }

View file

@ -1594,6 +1594,7 @@ module.exports = async (
// spinup // spinup
Events.onSimplerSentRequests(() => {})() Events.onSimplerSentRequests(() => {})()
const data = Events.getCurrentSentReqs() const data = Events.getCurrentSentReqs()
logger.info(`Sent requests poll: ${JSON.stringify(data, null, 4)}`)
res.json({ res.json({
data, data,
}) })
@ -1611,6 +1612,7 @@ module.exports = async (
// spinup // spinup
Events.onChats(() => {})() Events.onChats(() => {})()
const data = Events.getChats() const data = Events.getChats()
logger.info(`Chats polled: ${JSON.stringify(data, null, 4)}`)
res.json({ res.json({
data data
}) })