prevent not_auth errors

This commit is contained in:
Daniel Lugo 2020-02-27 17:34:26 -04:00
parent 7a51780a6e
commit 9f0b4f4272
3 changed files with 11 additions and 1 deletions

View file

@ -239,6 +239,10 @@ const getGun = () => {
} }
const getUser = () => { const getUser = () => {
if (!user.is) {
logger.warn('called getUser() without being authed')
throw new Error('NOT_AUTH')
}
return user return user
} }

View file

@ -527,11 +527,11 @@ const onChats = cb => {
if (!onChatsSubbed) { if (!onChatsSubbed) {
const Streams = require('../streams') const Streams = require('../streams')
onChatsSubbed = true
onOutgoing(processChats) onOutgoing(processChats)
Streams.onAvatar(processChats) Streams.onAvatar(processChats)
Streams.onDisplayName(processChats) Streams.onDisplayName(processChats)
Streams.onPubToFeed(processChats) Streams.onPubToFeed(processChats)
onChatsSubbed = true
} }
return () => { return () => {

View file

@ -105,6 +105,9 @@ const tryAndWait = async (promGen, shouldRetry = () => false) => {
} }
} catch (e) { } catch (e) {
logger.error(e) logger.error(e)
if (e.message === 'NOT_AUTH') {
throw e
}
} }
logger.info( logger.info(
@ -132,6 +135,9 @@ const tryAndWait = async (promGen, shouldRetry = () => false) => {
} }
} catch (e) { } catch (e) {
logger.error(e) logger.error(e)
if (e.message === 'NOT_AUTH') {
throw e
}
} }
logger.info( logger.info(