From 84a69a8a6884ebd4975167f993d8d2614d038ee5 Mon Sep 17 00:00:00 2001 From: Puyodead1 Date: Fri, 19 May 2023 15:14:40 -0400 Subject: [PATCH] rename pomeloEnabled to uniqueUsernames --- assets/openapi.json | Bin 574762 -> 574766 bytes assets/schemas.json | Bin 18377081 -> 18377085 bytes .../channels/#channel_id/messages/index.ts | 4 ++-- src/api/routes/users/@me/index.ts | 4 ++-- src/api/routes/users/@me/relationships.ts | 6 +++--- src/connections/Discord/index.ts | 4 ++-- src/util/config/types/GeneralConfiguration.ts | 2 +- src/util/entities/User.ts | 14 +++++++------- src/util/schemas/RelationshipPostSchema.ts | 2 +- 9 files changed, 18 insertions(+), 18 deletions(-) diff --git a/assets/openapi.json b/assets/openapi.json index 7132ad932a235fc506d061c03f779a02f24cebb3..131e370b2f21bbc30a45a36b6640fb79ebe53edd 100644 GIT binary patch delta 104 zcmZ40rM#|7xuJ!zg=q_O??s-{yv)MV)X?J8qP)b(3zeAmf^drPJtkY#e8{_O&@@N`#YCh_SLx|y}6 z_jfb%PuD%q%szehCFWx=<0;)XzORQ_aJs`vX2teLmzjZ>1&CRJm~H!` I%j`ZM0p&F=`Tzg` diff --git a/assets/schemas.json b/assets/schemas.json index 24c016c244726ac9cecc8c1794ae6f439a6002fe..7f74d353a62dfb13f45d78237069ddf1b31af756 100644 GIT binary patch delta 783 zcmY+)S6B^j7=ZETwD%rFWK+uCBiXV?DzoGul%_qxs}PcP?0GV>iHykJGs^6t?42!y z?|eGORG@>z0Xi77h(}I@x(h5IX(}uRR zqdgtyNGJU1Oc%P+jqdcIC%x!R9|Gu0AVCDvkNyl`AcGi82%!uijG<^5#&AXu&PYZv zng}8pLln`(5KA2KjAb0-nZQIQF_|e$Wf}=gX9hEYStOFgZ00bRWacrS1*EW$R2H$A zB`jqbI+nA7m8@blYgo%V*0X_)Y(h^Oo7uuvwvo}C&p*~fk|IKV+NImBU( zaFi^Lahz;UaFSD;<_u>!$9XPrkxN|W3Rk(tb#8Ez9By%&T=KZXUG8z82RzKkPY<+? zj|`8F*9OFDVv<<2OYe8I{*Lx delta 775 zcmX}iS6B^j7=ZETwD&kIWM`ATM@EtrnPtxqrR>TIuM3Jyu z=HX$XK_Ov2`ZO;ScYVB9uw#Nlp;n)i8D*W|pQz2S3(WJ?{GYPDja>Ap;mO(47)&^;25MZPEyPsCI4OgtAa#7pr?ycTc7Tk%f37azn&@kx9ZU&L4OO?($W zM4>1WKgBQcTNH~w;%}@$r->6PMk>ZCCMu>XW-8_?7Alr1Rw~viHY&C%b}IHN4l0f+ VS`{Z1XB8I}S51~d=cdUm_y;_9c#i-8 diff --git a/src/api/routes/channels/#channel_id/messages/index.ts b/src/api/routes/channels/#channel_id/messages/index.ts index 1fe6d0ee1..6741790c8 100644 --- a/src/api/routes/channels/#channel_id/messages/index.ts +++ b/src/api/routes/channels/#channel_id/messages/index.ts @@ -171,11 +171,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 1d2095427..fc44e17e9 100644 --- a/src/api/routes/users/@me/index.ts +++ b/src/api/routes/users/@me/index.ts @@ -140,7 +140,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, ""); if (!check_username) { @@ -163,7 +163,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 083426020..5fc55e585 100644 --- a/src/api/routes/users/@me/relationships.ts +++ b/src/api/routes/users/@me/relationships.ts @@ -114,10 +114,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 a88a38ce2..35bae5149 100644 --- a/src/connections/Discord/index.ts +++ b/src/connections/Discord/index.ts @@ -130,12 +130,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/util/config/types/GeneralConfiguration.ts b/src/util/config/types/GeneralConfiguration.ts index df3dfbcdc..b5c8b2729 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 c1a05e516..fea8ad498 100644 --- a/src/util/entities/User.ts +++ b/src/util/entities/User.ts @@ -92,10 +92,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 @@ -328,10 +328,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}`; } @@ -350,13 +350,13 @@ export class User extends BaseClass { id?: string; req?: Request; }) { - 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) { diff --git a/src/util/schemas/RelationshipPostSchema.ts b/src/util/schemas/RelationshipPostSchema.ts index f0a5fc32a..8b9f8611d 100644 --- a/src/util/schemas/RelationshipPostSchema.ts +++ b/src/util/schemas/RelationshipPostSchema.ts @@ -16,7 +16,7 @@ along with this program. If not, see . */ -// TODO: pomelo? +// TODO: uniqueUsernames? export interface RelationshipPostSchema { discriminator: string; username: string;