Skip to content

Commit d600506

Browse files
committed
rename pomeloEnabled to uniqueUsernames
1 parent 9f4022a commit d600506

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
@@ -7262,7 +7262,7 @@
72627262
"type": "boolean",
72637263
"default": false
72647264
},
7265-
"pomeloEnabled": {
7265+
"uniqueUsernames": {
72667266
"type": "boolean",
72677267
"default": false
72687268
}
@@ -7276,8 +7276,8 @@
72767276
"instanceDescription",
72777277
"instanceId",
72787278
"instanceName",
7279-
"pomeloEnabled",
7280-
"tosPage"
7279+
"tosPage",
7280+
"uniqueUsernames"
72817281
]
72827282
},
72837283
"APIChannelArray": {

assets/schemas.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -427156,7 +427156,7 @@
427156427156
"type": "boolean",
427157427157
"default": false
427158427158
},
427159-
"pomeloEnabled": {
427159+
"uniqueUsernames": {
427160427160
"type": "boolean",
427161427161
"default": false
427162427162
}
@@ -427171,8 +427171,8 @@
427171427171
"instanceDescription",
427172427172
"instanceId",
427173427173
"instanceName",
427174-
"pomeloEnabled",
427175-
"tosPage"
427174+
"tosPage",
427175+
"uniqueUsernames"
427176427176
],
427177427177
"definitions": {
427178427178
"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)