diff options
author | Emma [it/its]@Rory& <root@rory.gay> | 2023-12-11 01:12:54 +0100 |
---|---|---|
committer | Emma [it/its]@Rory& <root@rory.gay> | 2023-12-11 01:12:54 +0100 |
commit | 0a8ceb9e6349284e75545a01ffad608b020f78e2 (patch) | |
tree | 17a9163f963eddabf9168b0b630096b2f7535b64 /src/util/connections | |
parent | Prettier: use editorconfig (diff) | |
download | server-0a8ceb9e6349284e75545a01ffad608b020f78e2.tar.xz |
Actually run prettier dev/emma-refactors
Diffstat (limited to '')
-rw-r--r-- | src/util/connections/Connection.ts | 11 | ||||
-rw-r--r-- | src/util/connections/ConnectionConfig.ts | 9 | ||||
-rw-r--r-- | src/util/connections/ConnectionLoader.ts | 13 | ||||
-rw-r--r-- | src/util/connections/ConnectionStore.ts | 3 | ||||
-rw-r--r-- | src/util/connections/RefreshableConnection.ts | 8 |
5 files changed, 11 insertions, 33 deletions
diff --git a/src/util/connections/Connection.ts b/src/util/connections/Connection.ts index 5bdebd47..181234b7 100644 --- a/src/util/connections/Connection.ts +++ b/src/util/connections/Connection.ts @@ -42,8 +42,7 @@ export abstract class Connection { * @returns redirect_uri for this connection */ getRedirectUri() { - const endpointPublic = - Config.get().api.endpointPublic ?? "http://localhost:3001"; + const endpointPublic = Config.get().api.endpointPublic ?? "http://localhost:3001"; return `${endpointPublic}/connections/${this.id}/callback`; } @@ -51,9 +50,7 @@ export abstract class Connection { * Processes the callback * @param args Callback arguments */ - abstract handleCallback( - params: ConnectionCallbackSchema, - ): Promise<ConnectedAccount | null>; + abstract handleCallback(params: ConnectionCallbackSchema): Promise<ConnectedAccount | null>; /** * Gets a user id from state @@ -91,9 +88,7 @@ export abstract class Connection { * @param data connected account data * @returns the new connected account */ - async createConnection( - data: ConnectedAccountSchema, - ): Promise<ConnectedAccount> { + async createConnection(data: ConnectedAccountSchema): Promise<ConnectedAccount> { const ca = ConnectedAccount.create({ ...data }); await ca.save(); return ca; diff --git a/src/util/connections/ConnectionConfig.ts b/src/util/connections/ConnectionConfig.ts index 5a2239a0..0610b43e 100644 --- a/src/util/connections/ConnectionConfig.ts +++ b/src/util/connections/ConnectionConfig.ts @@ -49,11 +49,7 @@ export const ConnectionConfig = { function applyConfig(val: any) { async function apply(obj: any, key = ""): Promise<any> { if (typeof obj === "object" && obj !== null && !(obj instanceof Date)) - return Promise.all( - Object.keys(obj).map((k) => - apply(obj[k], key ? `${key}_${k}` : k), - ), - ); + return Promise.all(Object.keys(obj).map((k) => apply(obj[k], key ? `${key}_${k}` : k))); let pair = pairs.find((x) => x.key === key); if (!pair) pair = new ConnectionConfigEntity(); @@ -83,8 +79,7 @@ function pairsToConfig(pairs: ConnectionConfigEntity[]) { let i = 0; for (const key of keys) { - if (!isNaN(Number(key)) && !prevObj[prev]?.length) - prevObj[prev] = obj = []; + if (!isNaN(Number(key)) && !prevObj[prev]?.length) prevObj[prev] = obj = []; if (i++ === keys.length - 1) obj[key] = p.value; else if (!obj[key]) obj[key] = {}; diff --git a/src/util/connections/ConnectionLoader.ts b/src/util/connections/ConnectionLoader.ts index e9dc6973..9507d5f6 100644 --- a/src/util/connections/ConnectionLoader.ts +++ b/src/util/connections/ConnectionLoader.ts @@ -67,18 +67,11 @@ export class ConnectionLoader { return cfg; } - public static async setConnectionConfig( - id: string, - config: Partial<unknown>, - ): Promise<void> { - if (!config) - console.warn(`[Connections/WARN] ${id} tried to set config=null!`); + public static async setConnectionConfig(id: string, config: Partial<unknown>): Promise<void> { + if (!config) console.warn(`[Connections/WARN] ${id} tried to set config=null!`); await ConnectionConfig.set({ - [id]: Object.assign( - config, - ConnectionLoader.getConnectionConfig(id) || {}, - ), + [id]: Object.assign(config, ConnectionLoader.getConnectionConfig(id) || {}), }); } } diff --git a/src/util/connections/ConnectionStore.ts b/src/util/connections/ConnectionStore.ts index 95e54fd9..0cc4dc31 100644 --- a/src/util/connections/ConnectionStore.ts +++ b/src/util/connections/ConnectionStore.ts @@ -20,6 +20,5 @@ import { Connection } from "./Connection"; import { RefreshableConnection } from "./RefreshableConnection"; export class ConnectionStore { - public static connections: Map<string, Connection | RefreshableConnection> = - new Map(); + public static connections: Map<string, Connection | RefreshableConnection> = new Map(); } diff --git a/src/util/connections/RefreshableConnection.ts b/src/util/connections/RefreshableConnection.ts index 88ad8dab..08b01c68 100644 --- a/src/util/connections/RefreshableConnection.ts +++ b/src/util/connections/RefreshableConnection.ts @@ -30,17 +30,13 @@ export abstract class RefreshableConnection extends Connection { * Refreshes the token for a connected account. * @param connectedAccount The connected account to refresh */ - abstract refreshToken( - connectedAccount: ConnectedAccount, - ): Promise<ConnectedAccountCommonOAuthTokenResponse>; + abstract refreshToken(connectedAccount: ConnectedAccount): Promise<ConnectedAccountCommonOAuthTokenResponse>; /** * Refreshes the token for a connected account and saves it to the database. * @param connectedAccount The connected account to refresh */ - async refresh( - connectedAccount: ConnectedAccount, - ): Promise<ConnectedAccountCommonOAuthTokenResponse> { + async refresh(connectedAccount: ConnectedAccount): Promise<ConnectedAccountCommonOAuthTokenResponse> { const tokenData = await this.refreshToken(connectedAccount); connectedAccount.token_data = { ...tokenData, fetched_at: Date.now() }; await connectedAccount.save(); |