Skip to content

Commit

Permalink
rename pomeloEnabled to uniqueUsernames
Browse files Browse the repository at this point in the history
  • Loading branch information
Puyodead1 committed May 19, 2023
1 parent c8176d6 commit 24588d7
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 24 deletions.
6 changes: 3 additions & 3 deletions assets/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -7223,7 +7223,7 @@
"instanceId": {
"type": "string"
},
"pomeloEnabled": {
"uniqueUsernames": {
"type": "boolean",
"default": false
}
Expand All @@ -7236,8 +7236,8 @@
"instanceDescription",
"instanceId",
"instanceName",
"pomeloEnabled",
"tosPage"
"tosPage",
"uniqueUsernames"
]
},
"APIChannelArray": {
Expand Down
6 changes: 3 additions & 3 deletions assets/schemas.json
Original file line number Diff line number Diff line change
Expand Up @@ -424416,7 +424416,7 @@
"instanceId": {
"type": "string"
},
"pomeloEnabled": {
"uniqueUsernames": {
"type": "boolean",
"default": false
}
Expand All @@ -424430,8 +424430,8 @@
"instanceDescription",
"instanceId",
"instanceName",
"pomeloEnabled",
"tosPage"
"tosPage",
"uniqueUsernames"
],
"definitions": {
"ChannelPermissionOverwriteType": {
Expand Down
4 changes: 2 additions & 2 deletions src/api/routes/channels/#channel_id/messages/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/api/routes/users/@me/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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({
Expand Down
6 changes: 3 additions & 3 deletions src/api/routes/users/@me/relationships.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
: {
Expand Down
4 changes: 2 additions & 2 deletions src/connections/Discord/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/util/config/types/GeneralConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ export class GeneralConfiguration {
correspondenceUserID: string | null = null;
image: string | null = null;
instanceId: string = Snowflake.generate();
pomeloEnabled: boolean = false;
uniqueUsernames: boolean = false;
}
14 changes: 7 additions & 7 deletions src/util/entities/User.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}`;
}
Expand All @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/util/schemas/RelationshipPostSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

// TODO: pomelo?
// TODO: uniqueUsernames?
export interface RelationshipPostSchema {
discriminator: string;
username: string;
Expand Down

0 comments on commit 24588d7

Please sign in to comment.