From 83c7abd9b45fcc37acc5e66fd6e1fefa38fafef5 Mon Sep 17 00:00:00 2001 From: PK Date: Thu, 15 Dec 2022 18:09:00 -0600 Subject: [PATCH] Make indentation not completely suck --- packages/backend/src/boot/index.ts | 52 ++++++++-------- .../remote/activitypub/kernel/delete/index.ts | 60 +++++++++---------- .../remote/activitypub/kernel/flag/index.ts | 4 +- .../src/remote/activitypub/models/image.ts | 4 +- .../src/remote/activitypub/models/person.ts | 8 +-- 5 files changed, 64 insertions(+), 64 deletions(-) diff --git a/packages/backend/src/boot/index.ts b/packages/backend/src/boot/index.ts index 056dc9a51d..185dab673f 100644 --- a/packages/backend/src/boot/index.ts +++ b/packages/backend/src/boot/index.ts @@ -18,62 +18,62 @@ const ev = new Xev(); * Init process */ export default async function() { - process.title = `Calckey (${cluster.isPrimary ? 'master' : 'worker'})`; + process.title = `Calckey (${cluster.isPrimary ? 'master' : 'worker'})`; - if (cluster.isPrimary || envOption.disableClustering) { - await masterMain(); + if (cluster.isPrimary || envOption.disableClustering) { + await masterMain(); - if (cluster.isPrimary) { - ev.mount(); - } - } + if (cluster.isPrimary) { + ev.mount(); + } + } - if (cluster.isWorker || envOption.disableClustering) { - await workerMain(); - } + if (cluster.isWorker || envOption.disableClustering) { + await workerMain(); + } - // For when Calckey is started in a child process during unit testing. - // Otherwise, process.send cannot be used, so start it. - if (process.send) { - process.send('ok'); - } + // For when Calckey is started in a child process during unit testing. + // Otherwise, process.send cannot be used, so start it. + if (process.send) { + process.send('ok'); + } } //#region Events // Listen new workers cluster.on('fork', worker => { - clusterLogger.debug(`Process forked: [${worker.id}]`); + clusterLogger.debug(`Process forked: [${worker.id}]`); }); // Listen online workers cluster.on('online', worker => { - clusterLogger.debug(`Process is now online: [${worker.id}]`); + clusterLogger.debug(`Process is now online: [${worker.id}]`); }); // Listen for dying workers cluster.on('exit', worker => { - // Replace the dead worker, - // we're not sentimental - clusterLogger.error(chalk.red(`[${worker.id}] died :(`)); - cluster.fork(); + // Replace the dead worker, + // we're not sentimental + clusterLogger.error(chalk.red(`[${worker.id}] died :(`)); + cluster.fork(); }); // Display detail of unhandled promise rejection if (!envOption.quiet) { - process.on('unhandledRejection', console.dir); + process.on('unhandledRejection', console.dir); } // Display detail of uncaught exception process.on('uncaughtException', err => { - try { - logger.error(err); - } catch { } + try { + logger.error(err); + } catch { } }); // Dying away... process.on('exit', code => { - logger.info(`The process is going to exit with code ${code}`); + logger.info(`The process is going to exit with code ${code}`); }); //#endregion diff --git a/packages/backend/src/remote/activitypub/kernel/delete/index.ts b/packages/backend/src/remote/activitypub/kernel/delete/index.ts index fc0ff8ad51..01ff8f5dbf 100644 --- a/packages/backend/src/remote/activitypub/kernel/delete/index.ts +++ b/packages/backend/src/remote/activitypub/kernel/delete/index.ts @@ -8,44 +8,44 @@ import { deleteActor } from './actor.js'; * Handle delete activity */ export default async (actor: CacheableRemoteUser, activity: IDelete): Promise => { - if ('actor' in activity && actor.uri !== activity.actor) { - throw new Error('invalid actor'); - } + if ('actor' in activity && actor.uri !== activity.actor) { + throw new Error('invalid actor'); + } - // Type of object to be deleted - let formerType: string | undefined; + // Type of object to be deleted + let formerType: string | undefined; if (typeof activity.object === 'string') { - // The type is unknown, but it has disappeared - // anyway, so it does not remote resolve - formerType = undefined; + // The type is unknown, but it has disappeared + // anyway, so it does not remote resolve + formerType = undefined; } else { - const object = activity.object as IObject; - if (isTombstone(object)) { - formerType = toSingle(object.formerType); - } else { - formerType = toSingle(object.type); - } + const object = activity.object as IObject; + if (isTombstone(object)) { + formerType = toSingle(object.formerType); + } else { + formerType = toSingle(object.type); + } } - const uri = getApId(activity.object); + const uri = getApId(activity.object); - // Even if type is unknown, if actor and object are the same, - // it must be `Person`. - if (!formerType && actor.uri === uri) { - formerType = 'Person'; - } + // Even if type is unknown, if actor and object are the same, + // it must be `Person`. + if (!formerType && actor.uri === uri) { + formerType = 'Person'; + } // If not, fallback to `Note`. - if (!formerType) { - formerType = 'Note'; - } + if (!formerType) { + formerType = 'Note'; + } - if (validPost.includes(formerType)) { - return await deleteNote(actor, uri); - } else if (validActor.includes(formerType)) { - return await deleteActor(actor, uri); - } else { - return `Unknown type ${formerType}`; - } + if (validPost.includes(formerType)) { + return await deleteNote(actor, uri); + } else if (validActor.includes(formerType)) { + return await deleteActor(actor, uri); + } else { + return `Unknown type ${formerType}`; + } }; diff --git a/packages/backend/src/remote/activitypub/kernel/flag/index.ts b/packages/backend/src/remote/activitypub/kernel/flag/index.ts index 804cd1d35d..53e5daa515 100644 --- a/packages/backend/src/remote/activitypub/kernel/flag/index.ts +++ b/packages/backend/src/remote/activitypub/kernel/flag/index.ts @@ -7,8 +7,8 @@ import { genId } from '@/misc/gen-id.js'; export default async (actor: CacheableRemoteUser, activity: IFlag): Promise => { // The object is `(User | Note) | (User | Note) []`, but it cannot be - // matched with all patterns of the DB schema, so the target user is the first - // user and it is stored as a comment. + // matched with all patterns of the DB schema, so the target user is the first + // user and it is stored as a comment. const uris = getApIds(activity.object); const userIds = uris.filter(uri => uri.startsWith(config.url + '/users/')).map(uri => uri.split('/').pop()!); diff --git a/packages/backend/src/remote/activitypub/models/image.ts b/packages/backend/src/remote/activitypub/models/image.ts index 111cd25647..1fa90ff503 100644 --- a/packages/backend/src/remote/activitypub/models/image.ts +++ b/packages/backend/src/remote/activitypub/models/image.ts @@ -39,8 +39,8 @@ export async function createImage(actor: CacheableRemoteUser, value: any): Promi }); if (file.isLink) { - // If the URL is different, it means that the same image was previously - // registered with a different URL, so update the URL + // If the URL is different, it means that the same image was previously + // registered with a different URL, so update the URL if (file.url !== image.url) { await DriveFiles.update({ id: file.id }, { url: image.url, diff --git a/packages/backend/src/remote/activitypub/models/person.ts b/packages/backend/src/remote/activitypub/models/person.ts index 83f81f9797..b23479be0e 100644 --- a/packages/backend/src/remote/activitypub/models/person.ts +++ b/packages/backend/src/remote/activitypub/models/person.ts @@ -101,10 +101,10 @@ function validateActor(x: IObject, uri: string): IActor { } /** - * Fetch a Person. - * - * If the target Person is registered in Calckey, it will be returned. - */ + * Fetch a Person. + * + * If the target Person is registered in Calckey, it will be returned. + */ export async function fetchPerson(uri: string, resolver?: Resolver): Promise { if (typeof uri !== 'string') throw new Error('uri is not string');