Skip to content

Commit f5eed6b

Browse files
committed
rename pomeloEnabled to uniqueUsernames
1 parent b950b4d commit f5eed6b

File tree

9 files changed

+24
-24
lines changed

9 files changed

+24
-24
lines changed

assets/openapi.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -7236,7 +7236,7 @@
72367236
"type": "boolean",
72377237
"default": false
72387238
},
7239-
"pomeloEnabled": {
7239+
"uniqueUsernames": {
72407240
"type": "boolean",
72417241
"default": false
72427242
}
@@ -7250,8 +7250,8 @@
72507250
"instanceDescription",
72517251
"instanceId",
72527252
"instanceName",
7253-
"pomeloEnabled",
7254-
"tosPage"
7253+
"tosPage",
7254+
"uniqueUsernames"
72557255
]
72567256
},
72577257
"APIChannelArray": {

assets/schemas.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -424429,7 +424429,7 @@
424429424429
"type": "boolean",
424430424430
"default": false
424431424431
},
424432-
"pomeloEnabled": {
424432+
"uniqueUsernames": {
424433424433
"type": "boolean",
424434424434
"default": false
424435424435
}
@@ -424444,8 +424444,8 @@
424444424444
"instanceDescription",
424445424445
"instanceId",
424446424446
"instanceName",
424447-
"pomeloEnabled",
424448-
"tosPage"
424447+
"tosPage",
424448+
"uniqueUsernames"
424449424449
],
424450424450
"definitions": {
424451424451
"ChannelPermissionOverwriteType": {

src/api/routes/channels/#channel_id/messages/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,11 @@ router.get(
149149
if ((y.user_ids || []).includes(req.user_id)) y.me = true;
150150
delete y.user_ids;
151151
});
152-
const { pomeloEnabled } = Config.get().general;
152+
const { uniqueUsernames } = Config.get().general;
153153
if (!x.author)
154154
x.author = User.create({
155155
id: "4",
156-
discriminator: pomeloEnabled ? "0" : "0000",
156+
discriminator: uniqueUsernames ? "0" : "0000",
157157
username: "spacebarghost",
158158
global_name: "Spacebar Ghost",
159159
public_flags: 0,

src/api/routes/users/@me/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ router.patch(
142142
newToken = (await generateToken(user.id)) as string;
143143
}
144144

145-
// TODO: pomelo: disallow if pomelo is enabled
145+
// TODO: uniqueUsernames: disallow if uniqueUsernames is enabled
146146
if (body.username) {
147147
const check_username = body?.username?.replace(/\s/g, "");
148148
if (!check_username) {
@@ -165,7 +165,7 @@ router.patch(
165165
}
166166
}
167167

168-
// TODO: pomelo: disallow if pomelo is enabled
168+
// TODO: uniqueUsernames: disallow if uniqueUsernames is enabled
169169
if (body.discriminator) {
170170
if (
171171
await User.findOne({

src/api/routes/users/@me/relationships.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,10 @@ router.post(
114114
},
115115
}),
116116
async (req: Request, res: Response) => {
117-
const { pomeloEnabled } = Config.get().general;
118-
const where = pomeloEnabled
117+
const { uniqueUsernames } = Config.get().general;
118+
const where = uniqueUsernames
119119
? {
120-
// TODO: pomelo: should we use username or add global_name property to the request?
120+
// TODO: uniqueUsernames: should we use username or add global_name property to the request?
121121
global_name: req.body.username,
122122
}
123123
: {

src/connections/Discord/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,12 @@ export default class DiscordConnection extends Connection {
124124

125125
if (exists) return null;
126126

127-
const { pomeloEnabled } = Config.get().general;
127+
const { uniqueUsernames } = Config.get().general;
128128
return await this.createConnection({
129129
user_id: userId,
130130
external_id: userInfo.id,
131131
friend_sync: params.friend_sync,
132-
name: pomeloEnabled
132+
name: uniqueUsernames
133133
? userInfo.username
134134
: `${userInfo.username}#${userInfo.discriminator}`,
135135
type: this.id,

src/util/config/types/GeneralConfiguration.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@ export class GeneralConfiguration {
2929
image: string | null = null;
3030
instanceId: string = Snowflake.generate();
3131
autoCreateBotUsers: boolean = false;
32-
pomeloEnabled: boolean = false;
32+
uniqueUsernames: boolean = false;
3333
}

src/util/entities/User.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,10 @@ export class User extends BaseClass {
9999
username: string; // username max length 32, min 2 (should be configurable)
100100

101101
@Column({ nullable: true })
102-
global_name?: string; // puyo: pomelo
102+
global_name?: string; // puyo: uniqueUsernames
103103

104104
@Column()
105-
discriminator: string; // opaque string: 4 digits on discord.com, 0 for pomelo
105+
discriminator: string; // opaque string: 4 digits on discord.com, 0 for uniqueUsernames
106106

107107
@Column({ nullable: true })
108108
avatar?: string; // hash of the user avatar
@@ -338,10 +338,10 @@ export class User extends BaseClass {
338338
}
339339

340340
public get tag(): string {
341-
const { pomeloEnabled } = Config.get().general;
341+
const { uniqueUsernames } = Config.get().general;
342342

343-
// if pomelo is enabled, global_name should be set
344-
return pomeloEnabled
343+
// if uniqueUsernames is enabled, global_name should be set
344+
return uniqueUsernames
345345
? (this.global_name as string)
346346
: `${this.username}#${this.discriminator}`;
347347
}
@@ -360,13 +360,13 @@ export class User extends BaseClass {
360360
id?: string;
361361
req?: Request;
362362
}) {
363-
const { pomeloEnabled } = Config.get().general;
363+
const { uniqueUsernames } = Config.get().general;
364364

365365
// trim special uf8 control characters -> Backspace, Newline, ...
366366
username = trimSpecial(username);
367367

368368
let discriminator: string | undefined;
369-
if (pomeloEnabled) discriminator = "0";
369+
if (uniqueUsernames) discriminator = "0";
370370
else {
371371
discriminator = await User.generateDiscriminator(username);
372372
if (!discriminator) {

src/util/schemas/RelationshipPostSchema.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
along with this program. If not, see <https://www.gnu.org/licenses/>.
1717
*/
1818

19-
// TODO: pomelo?
19+
// TODO: uniqueUsernames?
2020
export interface RelationshipPostSchema {
2121
discriminator: string;
2222
username: string;

0 commit comments

Comments
 (0)