Gate bot logic on full account authentication

This commit is contained in:
jjbrunton committed 2026-08-08 16:01:06 +01:00
1 parent 4db6de8bf5
commit 2fd92bf82c
22 files changed
+635 -65

No files matched your search

+11 -1
View File
@@ -1,5 +1,6 @@
import type { Logger } from '../utils/logger.js';
import type { ChatService } from './chat.js';
import { denyAccountAuth, type AccountAuthGate } from './account-auth-context.js';
export interface MediaSyncStatus {
isSyncing: boolean;
@@ -22,7 +23,8 @@ export class MediaSyncService {
constructor(
private chatService: ChatService,
private logger: Logger,
intervalMs: number = 30 * 60 * 1000 // default 30 minutes
intervalMs: number = 30 * 60 * 1000, // default 30 minutes
private accountAuth: AccountAuthGate = denyAccountAuth,
) {
this.intervalMs = intervalMs;
}
@@ -64,6 +66,10 @@ export class MediaSyncService {
* Returns immediately if a sync is already in progress.
*/
async triggerSync(full = false): Promise<boolean> {
if (!this.accountAuth.isFullyAuthenticated()) {
this.logger.warn('Media sync: blocked until the account is fully authenticated');
return false;
}
if (this.syncing) {
this.logger.info('Media sync: sync already in progress, skipping trigger');
return false;
@@ -86,6 +92,10 @@ export class MediaSyncService {
}
private async runSync(full = false): Promise<void> {
if (!this.accountAuth.isFullyAuthenticated()) {
this.logger.debug('Media sync: skipped because the account is not fully authenticated');
return;
}
if (this.syncing) return;
this.syncing = true;
this.lastError = null;