diff --git a/classes/search/search-manager.ts b/classes/search/search-manager.ts index 01884b32..23dd85a1 100644 --- a/classes/search/search-manager.ts +++ b/classes/search/search-manager.ts @@ -49,19 +49,20 @@ export class SonicSearchManager { /** * Connect to Sonic */ - async connect(): Promise { + async connect(silent = false): Promise { if (!this.config.sonic.enabled) { - this.logger.info`Sonic search is disabled`; + !silent && this.logger.info`Sonic search is disabled`; return; } - this.logger.info`Connecting to Sonic...`; + !silent && this.logger.info`Connecting to Sonic...`; // Connect to Sonic await new Promise((resolve, reject) => { this.searchChannel.connect({ connected: () => { - this.logger.info`Connected to Sonic Search Channel`; + !silent && + this.logger.info`Connected to Sonic Search Channel`; resolve(true); }, disconnected: () => @@ -84,7 +85,8 @@ export class SonicSearchManager { await new Promise((resolve, reject) => { this.ingestChannel.connect({ connected: () => { - this.logger.info`Connected to Sonic Ingest Channel`; + !silent && + this.logger.info`Connected to Sonic Ingest Channel`; resolve(true); }, disconnected: () => @@ -108,7 +110,7 @@ export class SonicSearchManager { this.searchChannel.ping(), this.ingestChannel.ping(), ]); - this.logger.info`Connected to Sonic`; + !silent && this.logger.info`Connected to Sonic`; } catch (error) { this.logger.fatal`Error while connecting to Sonic: ${error}`; throw error; diff --git a/cli/base.ts b/cli/base.ts index 063aa075..288fefd1 100644 --- a/cli/base.ts +++ b/cli/base.ts @@ -1,4 +1,5 @@ import { Command } from "@oclif/core"; +import { searchManager } from "~/classes/search/search-manager"; import { setupDatabase } from "~/drizzle/db"; export abstract class BaseCommand<_T extends typeof Command> extends Command { @@ -6,5 +7,6 @@ export abstract class BaseCommand<_T extends typeof Command> extends Command { await super.init(); await setupDatabase(false); + await searchManager.connect(true); } } diff --git a/cli/commands/index/rebuild.ts b/cli/commands/index/rebuild.ts index 00feed3d..dff65fea 100644 --- a/cli/commands/index/rebuild.ts +++ b/cli/commands/index/rebuild.ts @@ -33,8 +33,6 @@ export default class IndexRebuild extends BaseCommand { this.exit(1); } - await searchManager.connect(); - const spinner = ora("Rebuilding search indexes").start(); switch (args.type) { diff --git a/cli/commands/user/refetch.ts b/cli/commands/user/refetch.ts index 8ece0f30..8e44f79f 100644 --- a/cli/commands/user/refetch.ts +++ b/cli/commands/user/refetch.ts @@ -1,6 +1,7 @@ import confirm from "@inquirer/confirm"; import { Flags } from "@oclif/core"; import chalk from "chalk"; +import ora from "ora"; import { UserFinderCommand } from "~/cli/classes"; import { formatArray } from "~/cli/utils/format"; @@ -78,8 +79,11 @@ export default class UserRefetch extends UserFinderCommand { } } + const spinner = ora("Refetching users").start(); + for (const user of users) { try { + spinner.text = `Refetching user ${user.data.username}`; await user.updateFromRemote(); } catch (error) { this.log( @@ -93,6 +97,8 @@ export default class UserRefetch extends UserFinderCommand { } } + spinner.succeed("Refetched users"); + this.exit(0); } } diff --git a/packages/database-interface/user.ts b/packages/database-interface/user.ts index d4af2767..aa10b036 100644 --- a/packages/database-interface/user.ts +++ b/packages/database-interface/user.ts @@ -576,18 +576,19 @@ export class User extends BaseInterface { // If something important is updated, federate it if ( - newUser.username || - newUser.displayName || - newUser.note || - newUser.avatar || - newUser.header || - newUser.fields || - newUser.publicKey || - newUser.isAdmin || - newUser.isBot || - newUser.isLocked || - newUser.endpoints || - newUser.isDiscoverable + this.isLocal() && + (newUser.username || + newUser.displayName || + newUser.note || + newUser.avatar || + newUser.header || + newUser.fields || + newUser.publicKey || + newUser.isAdmin || + newUser.isBot || + newUser.isLocked || + newUser.endpoints || + newUser.isDiscoverable) ) { await this.federateToFollowers(this.toLysand()); }