diff --git a/assets/openapi.json b/assets/openapi.json index 2157340a4..8e2b9383b 100644 --- a/assets/openapi.json +++ b/assets/openapi.json @@ -7262,7 +7262,7 @@ "type": "boolean", "default": false }, - "pomeloEnabled": { + "uniqueUsernames": { "type": "boolean", "default": false } @@ -7276,8 +7276,8 @@ "instanceDescription", "instanceId", "instanceName", - "pomeloEnabled", - "tosPage" + "tosPage", + "uniqueUsernames" ] }, "APIChannelArray": { diff --git a/assets/schemas.json b/assets/schemas.json index b7c48e3a2..46c70cdb6 100644 --- a/assets/schemas.json +++ b/assets/schemas.json @@ -427156,7 +427156,7 @@ "type": "boolean", "default": false }, - "pomeloEnabled": { + "uniqueUsernames": { "type": "boolean", "default": false } @@ -427171,8 +427171,8 @@ "instanceDescription", "instanceId", "instanceName", - "pomeloEnabled", - "tosPage" + "tosPage", + "uniqueUsernames" ], "definitions": { "ChannelPermissionOverwriteType": { diff --git a/src/api/routes/channels/#channel_id/messages/index.ts b/src/api/routes/channels/#channel_id/messages/index.ts index eb8414bec..3c04b68e3 100644 --- a/src/api/routes/channels/#channel_id/messages/index.ts +++ b/src/api/routes/channels/#channel_id/messages/index.ts @@ -149,11 +149,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 333c5bd91..ea8fbaf58 100644 --- a/src/api/routes/users/@me/index.ts +++ b/src/api/routes/users/@me/index.ts @@ -142,7 +142,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) { @@ -165,7 +165,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 8400c3836..d2bf1e7f9 100644 --- a/src/connections/Discord/index.ts +++ b/src/connections/Discord/index.ts @@ -124,12 +124,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 e2cbadd2e..718a7041c 100644 --- a/src/util/entities/User.ts +++ b/src/util/entities/User.ts @@ -99,10 +99,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 @@ -338,10 +338,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}`; } @@ -360,13 +360,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;