diff --git a/src/api/routes/channels/#channel_id/messages/index.ts b/src/api/routes/channels/#channel_id/messages/index.ts index d8760d969..2bd62628e 100644 --- a/src/api/routes/channels/#channel_id/messages/index.ts +++ b/src/api/routes/channels/#channel_id/messages/index.ts @@ -192,11 +192,11 @@ router.get( if ((y.user_ids || []).includes(req.user_id)) y.me = true; delete y.user_ids; }); - const { pomeloEnabled } = Config.get().general; + const { uniqueUsernames } = Config.get().general; if (!x.author) x.author = User.create({ id: "4", - discriminator: pomeloEnabled ? "0" : "0000", + discriminator: uniqueUsernames ? "0" : "0000", username: "spacebarghost", global_name: "Spacebar Ghost", public_flags: 0, diff --git a/src/api/routes/users/@me/index.ts b/src/api/routes/users/@me/index.ts index 628dddd4c..796d56297 100644 --- a/src/api/routes/users/@me/index.ts +++ b/src/api/routes/users/@me/index.ts @@ -120,7 +120,7 @@ router.patch( newToken = (await generateToken(user.id)) as string; } - // TODO: pomelo: disallow if pomelo is enabled + // TODO: uniqueUsernames: disallow if uniqueUsernames is enabled if (body.username) { const check_username = body?.username?.replace(/\s/g, "").trim(); if (!check_username) { @@ -152,7 +152,7 @@ router.patch( } } - // TODO: pomelo: disallow if pomelo is enabled + // TODO: uniqueUsernames: disallow if uniqueUsernames is enabled if (body.discriminator) { if ( await User.findOne({ diff --git a/src/api/routes/users/@me/relationships.ts b/src/api/routes/users/@me/relationships.ts index 9cd138af8..c6294e491 100644 --- a/src/api/routes/users/@me/relationships.ts +++ b/src/api/routes/users/@me/relationships.ts @@ -131,10 +131,10 @@ router.post( }, }), async (req: Request, res: Response) => { - const { pomeloEnabled } = Config.get().general; - const where = pomeloEnabled + const { uniqueUsernames } = Config.get().general; + const where = uniqueUsernames ? { - // TODO: pomelo: should we use username or add global_name property to the request? + // TODO: uniqueUsernames: should we use username or add global_name property to the request? global_name: req.body.username, } : { diff --git a/src/connections/Discord/index.ts b/src/connections/Discord/index.ts index 95c4ad348..3f5585580 100644 --- a/src/connections/Discord/index.ts +++ b/src/connections/Discord/index.ts @@ -122,12 +122,12 @@ export default class DiscordConnection extends Connection { if (exists) return null; - const { pomeloEnabled } = Config.get().general; + const { uniqueUsernames } = Config.get().general; return await this.createConnection({ user_id: userId, external_id: userInfo.id, friend_sync: params.friend_sync, - name: pomeloEnabled + name: uniqueUsernames ? userInfo.username : `${userInfo.username}#${userInfo.discriminator}`, type: this.id, diff --git a/src/schemas/uncategorised/RelationshipPostSchema.ts b/src/schemas/uncategorised/RelationshipPostSchema.ts index f0a5fc32a..8b9f8611d 100644 --- a/src/schemas/uncategorised/RelationshipPostSchema.ts +++ b/src/schemas/uncategorised/RelationshipPostSchema.ts @@ -16,7 +16,7 @@ along with this program. If not, see . */ -// TODO: pomelo? +// TODO: uniqueUsernames? export interface RelationshipPostSchema { discriminator: string; username: string; diff --git a/src/util/config/types/GeneralConfiguration.ts b/src/util/config/types/GeneralConfiguration.ts index 1db15dfa3..17e8ee3a6 100644 --- a/src/util/config/types/GeneralConfiguration.ts +++ b/src/util/config/types/GeneralConfiguration.ts @@ -29,5 +29,5 @@ export class GeneralConfiguration { image: string | null = null; instanceId: string = Snowflake.generate(); autoCreateBotUsers: boolean = false; - pomeloEnabled: boolean = false; + uniqueUsernames: boolean = false; } diff --git a/src/util/entities/User.ts b/src/util/entities/User.ts index 6b9964a5c..e03054afb 100644 --- a/src/util/entities/User.ts +++ b/src/util/entities/User.ts @@ -55,10 +55,10 @@ export class User extends BaseClass { username: string; // username max length 32, min 2 (should be configurable) @Column({ nullable: true }) - global_name?: string; // puyo: pomelo + global_name?: string; // puyo: uniqueUsernames @Column() - discriminator: string; // opaque string: 4 digits on discord.com, 0 for pomelo + discriminator: string; // opaque string: 4 digits on discord.com, 0 for uniqueUsernames @Column({ nullable: true }) avatar?: string; // hash of the user avatar @@ -267,10 +267,10 @@ export class User extends BaseClass { } public get tag(): string { - const { pomeloEnabled } = Config.get().general; + const { uniqueUsernames } = Config.get().general; - // if pomelo is enabled, global_name should be set - return pomeloEnabled + // if uniqueUsernames is enabled, global_name should be set + return uniqueUsernames ? (this.global_name as string) : `${this.username}#${this.discriminator}`; } @@ -291,13 +291,13 @@ export class User extends BaseClass { req?: Request; bot?: boolean; }) { - const { pomeloEnabled } = Config.get().general; + const { uniqueUsernames } = Config.get().general; // trim special uf8 control characters -> Backspace, Newline, ... username = trimSpecial(username); let discriminator: string | undefined; - if (pomeloEnabled) discriminator = "0"; + if (uniqueUsernames) discriminator = "0"; else { discriminator = await User.generateDiscriminator(username); if (!discriminator) {