Merge branch 'codex/native-login-handoff' into main
# Conflicts: # public/index.html # src/bootstrap.ts # src/services/chat/service.ts # tests/chat-service-username-persist.test.ts
This commit is contained in:
commit
50985b52f1
28 files changed
+987
-124
No files matched your search
+16
-1
@@ -20,6 +20,7 @@ export async function runMainLoop(app: AppContainer): Promise<void> {
|
||||
config,
|
||||
logger,
|
||||
browserClient,
|
||||
accountAuth,
|
||||
postsRepo,
|
||||
messagesRepo,
|
||||
redditApi,
|
||||
@@ -66,7 +67,7 @@ export async function runMainLoop(app: AppContainer): Promise<void> {
|
||||
const RESPONSE_CHECK_INTERVAL_MS = Math.max(config.reddit.pollIntervalMs * 5, 60_000);
|
||||
|
||||
const checkResponses = async (): Promise<void> => {
|
||||
if (isShuttingDown) return;
|
||||
if (isShuttingDown || !accountAuth.isFullyAuthenticated()) return;
|
||||
try {
|
||||
logger.debug('Checking for responses to sent messages (Background Thread)...');
|
||||
const responses = await responseChecker.checkForResponses();
|
||||
@@ -93,12 +94,26 @@ export async function runMainLoop(app: AppContainer): Promise<void> {
|
||||
responseCheckInterval = setInterval(checkResponses, RESPONSE_CHECK_INTERVAL_MS);
|
||||
|
||||
let lastPausedLog = 0;
|
||||
let lastAuthPausedLog = 0;
|
||||
let lastCooldownLog = 0;
|
||||
let reportedCooldownUntil: number | null = null;
|
||||
const COOLDOWN_LOG_INTERVAL_MS = 5 * 60_000;
|
||||
|
||||
while (!isShuttingDown) {
|
||||
try {
|
||||
if (!accountAuth.isFullyAuthenticated()) {
|
||||
await accountAuth.ensureFullyAuthenticated();
|
||||
}
|
||||
if (!accountAuth.isFullyAuthenticated()) {
|
||||
if (Date.now() - lastAuthPausedLog > PAUSED_LOG_INTERVAL_MS) {
|
||||
logger.info('Bot logic is locked until full Reddit and Matrix authentication is verified.');
|
||||
lastAuthPausedLog = Date.now();
|
||||
}
|
||||
await sleep(PAUSE_POLL_MS);
|
||||
continue;
|
||||
}
|
||||
lastAuthPausedLog = 0;
|
||||
|
||||
if (webServer && !webServer.isRunning()) {
|
||||
if (Date.now() - lastPausedLog > PAUSED_LOG_INTERVAL_MS) {
|
||||
logger.info('Bot is paused. Use the web dashboard to start.');
|
||||
|
||||
Reference in new issue
Block a user