summary refs log tree commit diff
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2025-12-17 07:52:20 +0100
committerRory& <root@rory.gay>2025-12-17 07:52:20 +0100
commit73397e49a75911b20e72b8bad419f0fa167112fb (patch)
treecc7aa58b7fe88649d6c346a447617c889a20d462
parentPrettier 5 (diff)
downloadserver-ts-73397e49a75911b20e72b8bad419f0fa167112fb.tar.xz
Prettier 6
-rw-r--r--src/api/routes/applications/#application_id/bot/index.ts6
-rw-r--r--src/api/routes/guilds/#guild_id/members/index.ts6
-rw-r--r--src/util/config/types/EmailConfiguration.ts6
-rw-r--r--src/util/entities/UserSettings.ts6
-rw-r--r--src/util/util/JSON.ts6
-rw-r--r--src/util/util/email/clients/IEmailClient.ts6
-rw-r--r--src/util/util/email/index.ts63
7 files changed, 20 insertions, 79 deletions
diff --git a/src/api/routes/applications/#application_id/bot/index.ts b/src/api/routes/applications/#application_id/bot/index.ts

index e6f1522c..ad491840 100644 --- a/src/api/routes/applications/#application_id/bot/index.ts +++ b/src/api/routes/applications/#application_id/bot/index.ts
@@ -71,11 +71,7 @@ router.post( if (owner.id != req.user_id) throw DiscordApiErrors.ACTION_NOT_AUTHORIZED_ON_APPLICATION; - if ( - owner.totp_secret && - (!req.body.code || verifyToken(owner.totp_secret, req.body.code)) - ) - throw new HTTPError(req.t("auth:login.INVALID_TOTP_CODE"), 60008); + if (owner.totp_secret && (!req.body.code || verifyToken(owner.totp_secret, req.body.code))) throw new HTTPError(req.t("auth:login.INVALID_TOTP_CODE"), 60008); bot.data = { hash: undefined, valid_tokens_since: new Date() }; diff --git a/src/api/routes/guilds/#guild_id/members/index.ts b/src/api/routes/guilds/#guild_id/members/index.ts
index 490d5b5e..a047472c 100644 --- a/src/api/routes/guilds/#guild_id/members/index.ts +++ b/src/api/routes/guilds/#guild_id/members/index.ts
@@ -34,8 +34,7 @@ router.get( query: { limit: { type: "number", - description: - "max number of members to return (1-1000). default 1", + description: "max number of members to return (1-1000). default 1", }, after: { type: "string", @@ -53,8 +52,7 @@ router.get( async (req: Request, res: Response) => { const { guild_id } = req.params; const limit = Number(req.query.limit) || 1; - if (limit > 1000 || limit < 1) - throw new HTTPError("Limit must be between 1 and 1000"); + if (limit > 1000 || limit < 1) throw new HTTPError("Limit must be between 1 and 1000"); const after = `${req.query.after}`; const query = after ? { id: MoreThan(after) } : {}; diff --git a/src/util/config/types/EmailConfiguration.ts b/src/util/config/types/EmailConfiguration.ts
index 62305d10..a430cb17 100644 --- a/src/util/config/types/EmailConfiguration.ts +++ b/src/util/config/types/EmailConfiguration.ts
@@ -16,11 +16,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>. */ -import { - MailGunConfiguration, - MailJetConfiguration, - SMTPConfiguration, -} from "./subconfigurations/email"; +import { MailGunConfiguration, MailJetConfiguration, SMTPConfiguration } from "./subconfigurations/email"; import { SendGridConfiguration } from "./subconfigurations/email/SendGrid"; export class EmailConfiguration { diff --git a/src/util/entities/UserSettings.ts b/src/util/entities/UserSettings.ts
index f1fc78b4..eac09a95 100644 --- a/src/util/entities/UserSettings.ts +++ b/src/util/entities/UserSettings.ts
@@ -18,7 +18,7 @@ import { Column, Entity, PrimaryGeneratedColumn } from "typeorm"; import { BaseClassWithoutId } from "./BaseClass"; -import { CustomStatus, FriendSourceFlags, GuildFolder } from "@spacebar/schemas" +import { CustomStatus, FriendSourceFlags, GuildFolder } from "@spacebar/schemas"; @Entity({ name: "user_settings", @@ -128,9 +128,7 @@ export class UserSettings extends BaseClassWithoutId { public static async getOrDefault(userId: string) { // raw sql query - const userSettingsIndex = ( - await this.getRepository().query("SELECT \"settingsIndex\" FROM users WHERE id = $1", [userId]) - )[0]?.settingsIndex as string | null; + const userSettingsIndex = (await this.getRepository().query('SELECT "settingsIndex" FROM users WHERE id = $1', [userId]))[0]?.settingsIndex as string | null; console.log(`[INFO/UserSettings] Fetched settings index for user ${userId}:`, userSettingsIndex); diff --git a/src/util/util/JSON.ts b/src/util/util/JSON.ts
index c7dcf47e..767fc618 100644 --- a/src/util/util/JSON.ts +++ b/src/util/util/JSON.ts
@@ -18,11 +18,7 @@ // Discord.com sends ISO strings with +00:00 extension, not Z // This causes issues with Python bot libs -const JSONReplacer = function ( - this: { [key: string]: unknown }, - key: string, - value: unknown, -) { +const JSONReplacer = function (this: { [key: string]: unknown }, key: string, value: unknown) { if (this[key] instanceof Date) { return (this[key] as Date).toISOString().replace("Z", "+00:00"); } diff --git a/src/util/util/email/clients/IEmailClient.ts b/src/util/util/email/clients/IEmailClient.ts
index 01329e84..261bffae 100644 --- a/src/util/util/email/clients/IEmailClient.ts +++ b/src/util/util/email/clients/IEmailClient.ts
@@ -25,9 +25,7 @@ export interface IEmail { } export interface IEmailClient { init: () => Promise<void>; - sendMail: ( - email: IEmail, - ) => Promise<void>; + sendMail: (email: IEmail) => Promise<void>; } export class BaseEmailClient implements IEmailClient { @@ -37,4 +35,4 @@ export class BaseEmailClient implements IEmailClient { sendMail(email: IEmail): Promise<void> { throw new Error("Method not implemented."); } -} \ No newline at end of file +} diff --git a/src/util/util/email/index.ts b/src/util/util/email/index.ts
index d66bbc38..4773b0db 100644 --- a/src/util/util/email/index.ts +++ b/src/util/util/email/index.ts
@@ -27,14 +27,7 @@ import { SMTPEmailClient } from "./clients/SMTPEmailClient"; import { MailGunEmailClient } from "./clients/MailGunEmailClient"; import { MailJetEmailClient } from "./clients/MailJetEmailClient"; -const ASSET_FOLDER_PATH = path.join( - __dirname, - "..", - "..", - "..", - "..", - "assets", -); +const ASSET_FOLDER_PATH = path.join(__dirname, "..", "..", "..", "..", "assets"); export enum MailTypes { verifyEmail = "verifyEmail", @@ -45,21 +38,11 @@ export enum MailTypes { export const Email: { transporter: IEmailClient | null; init: () => Promise<void>; - generateLink: ( - type: Omit<MailTypes, "changePassword">, - id: string, - ) => Promise<string>; - sendMail: ( - type: MailTypes, - user: User, - email: string, - ) => Promise<void>; + generateLink: (type: Omit<MailTypes, "changePassword">, id: string) => Promise<string>; + sendMail: (type: MailTypes, user: User, email: string) => Promise<void>; sendVerifyEmail: (user: User, email: string) => Promise<void>; sendResetPassword: (user: User, email: string) => Promise<void>; - sendPasswordChanged: ( - user: User, - email: string, - ) => Promise<void>; + sendPasswordChanged: (user: User, email: string) => Promise<void>; doReplacements: ( template: string, user: User, @@ -95,8 +78,7 @@ export const Email: { return; } - if (!this.transporter) - return console.error(`[Email] Invalid provider: ${provider}`); + if (!this.transporter) return console.error(`[Email] Invalid provider: ${provider}`); console.log(`[Email] Initializing ${provider} transport...`); await this.transporter.init(); console.log(`[Email] ${provider} transport initialized.`); @@ -148,9 +130,7 @@ export const Email: { generateLink: async function (type, id) { const token = (await generateToken(id)) as string; // puyodead1: this is set to api endpoint because the verification page is on the server since no clients have one, and not all 3rd party clients will have one - const instanceUrl = - Config.get().api.endpointPublic?.replace("/api", "") || - "http://localhost:3001"; + const instanceUrl = Config.get().api.endpointPublic?.replace("/api", "") || "http://localhost:3001"; const dashedType = type.replace(/([A-Z])/g, "-$1").toLowerCase(); const link = `${instanceUrl}/${dashedType}#token=${token}`; return link; @@ -178,51 +158,30 @@ export const Email: { changePassword: "password_changed.txt", }; - const htmlTemplate = await fs.readFile( - path.join( - ASSET_FOLDER_PATH, - "email_templates", - htmlTemplateNames[type], - ), - { encoding: "utf-8" }, - ); + const htmlTemplate = await fs.readFile(path.join(ASSET_FOLDER_PATH, "email_templates", htmlTemplateNames[type]), { encoding: "utf-8" }); - const textTemplate = await fs.readFile( - path.join( - ASSET_FOLDER_PATH, - "email_templates", - textTemplateNames[type], - ), - { encoding: "utf-8" }, - ); + const textTemplate = await fs.readFile(path.join(ASSET_FOLDER_PATH, "email_templates", textTemplateNames[type]), { encoding: "utf-8" }); // replace email template placeholders const html = this.doReplacements( htmlTemplate, user, // password change emails don't have links - type != MailTypes.changePassword - ? await this.generateLink(type, user.id) - : undefined, + type != MailTypes.changePassword ? await this.generateLink(type, user.id) : undefined, ); const text = this.doReplacements( textTemplate, user, // password change emails don't have links - type != MailTypes.changePassword - ? await this.generateLink(type, user.id) - : undefined, + type != MailTypes.changePassword ? await this.generateLink(type, user.id) : undefined, ); // extract the title from the email template to use as the email subject const subject = html.match(/<title>(.*)<\/title>/)?.[1] || ""; const message: IEmail = { - from: - Config.get().email.senderAddress || - Config.get().general.correspondenceEmail || - "noreply@localhost", + from: Config.get().email.senderAddress || Config.get().general.correspondenceEmail || "noreply@localhost", to: email, subject, text,