diff --git a/app/graphql/schema/utils.ts b/app/graphql/schema/utils.ts index 7de4d07dc..9ae8cc84e 100644 --- a/app/graphql/schema/utils.ts +++ b/app/graphql/schema/utils.ts @@ -3,10 +3,11 @@ * Written by: Alexis Tyler */ -import { pubsub, utils, errors, states, apiManager, graphqlLogger } from '../../core'; +import { pubsub, utils, errors, states, apiManager, graphqlLogger, paths } from '../../core'; import { hasSubscribedToChannel } from '../../ws'; import { userCache, CachedServer, CachedServers } from '../../cache'; import { getServers as getUserServers } from '../../utils'; +import { loadState } from '../../core/utils/misc/load-state'; const { varState, networkState } = states; @@ -92,6 +93,18 @@ export const getServers = async (): Promise => { // No cached servers found if (!cachedServers) { + // Get my server's config file path + const configPath = paths.get('myservers-config')!; + const myserversConfigFile = loadState<{ + remote: { anonMode?: string }; + }>(configPath); + + // If they're in anon mode bail + if (myserversConfigFile.remote.anonMode !== undefined) { + graphqlLogger.debug('Falling back to local state for /servers endpoint'); + return getLocalServer(apiKey); + } + // Fetch servers from mothership const servers = await getUserServers(apiKey); diff --git a/app/mothership/index.ts b/app/mothership/index.ts index f53d7b5fb..6efaebd85 100644 --- a/app/mothership/index.ts +++ b/app/mothership/index.ts @@ -33,12 +33,12 @@ export const startInternal = (apiKey: string) => { } })); - const myserversConfigFile = loadState<{ - remote: { anonMode?: string }; - }>(configPath); - // Internal is ready at this point if (!sockets.relay) { + const myserversConfigFile = loadState<{ + remote: { anonMode?: string }; + }>(configPath); + // If they're in anon mode bail if (myserversConfigFile.remote.anonMode !== undefined) { return;