mirror of
https://github.com/spacebarchat/server.git
synced 2026-05-28 05:24:14 +00:00
initial pomelo implementation
This commit is contained in:
@@ -111,7 +111,7 @@ router.post(
|
||||
})
|
||||
.catch((e) => {
|
||||
console.error(
|
||||
`Failed to send password reset email to ${user.username}#${user.discriminator}: ${e}`,
|
||||
`Failed to send password reset email to ${user.handle}: ${e}`,
|
||||
);
|
||||
throw new HTTPError("Failed to send password reset email", 500);
|
||||
});
|
||||
|
||||
@@ -43,6 +43,7 @@ router.post(
|
||||
username: "",
|
||||
avatar: "",
|
||||
discriminator: "",
|
||||
global_name: "",
|
||||
public_flags: 64,
|
||||
},
|
||||
attachments: [],
|
||||
|
||||
@@ -171,11 +171,14 @@ router.get(
|
||||
if ((y.user_ids || []).includes(req.user_id)) y.me = true;
|
||||
delete y.user_ids;
|
||||
});
|
||||
const { pomeloEnabled } = Config.get().general;
|
||||
if (!x.author)
|
||||
x.author = User.create({
|
||||
id: "4",
|
||||
discriminator: "0000",
|
||||
discriminator: pomeloEnabled ? "0" : "0000",
|
||||
username: "Spacebar Ghost",
|
||||
global_name: "spacebarghost",
|
||||
display_name: "Spacebar Ghost",
|
||||
public_flags: 0,
|
||||
});
|
||||
x.attachments?.forEach((y: Attachment) => {
|
||||
|
||||
@@ -70,6 +70,8 @@ router.get(
|
||||
user: {
|
||||
username: user.username,
|
||||
discriminator: user.discriminator,
|
||||
global_name: user.global_name,
|
||||
display_name: user.display_name,
|
||||
id: user.id,
|
||||
avatar: user.avatar,
|
||||
public_flags: user.public_flags,
|
||||
|
||||
@@ -149,6 +149,8 @@ router.get(
|
||||
avatar: x.author?.avatar,
|
||||
avatar_decoration: null,
|
||||
discriminator: x.author?.discriminator,
|
||||
global_name: x.author?.global_name,
|
||||
display_name: x.author?.display_name,
|
||||
public_flags: x.author?.public_flags,
|
||||
},
|
||||
attachments: x.attachments,
|
||||
|
||||
@@ -89,6 +89,8 @@ router.get(
|
||||
"username",
|
||||
"avatar",
|
||||
"discriminator",
|
||||
"global_name",
|
||||
"display_name",
|
||||
"public_flags",
|
||||
],
|
||||
});
|
||||
@@ -137,6 +139,8 @@ router.get(
|
||||
avatar: user.avatar,
|
||||
avatar_decoration: null, // TODO
|
||||
discriminator: user.discriminator,
|
||||
global_name: user.global_name,
|
||||
display_name: user.display_name,
|
||||
public_flags: user.public_flags,
|
||||
},
|
||||
application: {
|
||||
@@ -159,6 +163,8 @@ router.get(
|
||||
avatar: bot.avatar,
|
||||
avatar_decoration: null, // TODO
|
||||
discriminator: bot.discriminator,
|
||||
global_name: bot.global_name,
|
||||
display_name: bot.display_name,
|
||||
public_flags: bot.public_flags,
|
||||
bot: true,
|
||||
approximated_guild_count: 0, // TODO
|
||||
|
||||
@@ -58,6 +58,8 @@ router.get(
|
||||
username: relation_user.username,
|
||||
avatar: relation_user.avatar,
|
||||
discriminator: relation_user.discriminator,
|
||||
global_name: relation_user.global_name,
|
||||
display_name: relation_user.display_name,
|
||||
public_flags: relation_user.public_flags,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -140,6 +140,7 @@ router.patch(
|
||||
newToken = (await generateToken(user.id)) as string;
|
||||
}
|
||||
|
||||
// TODO: pomelo: disallow if pomelo is enabled
|
||||
if (body.username) {
|
||||
const check_username = body?.username?.replace(/\s/g, "");
|
||||
if (!check_username) {
|
||||
@@ -162,6 +163,7 @@ router.patch(
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: pomelo: disallow if pomelo is enabled
|
||||
if (body.discriminator) {
|
||||
if (
|
||||
await User.findOne({
|
||||
|
||||
@@ -114,19 +114,26 @@ router.post(
|
||||
},
|
||||
}),
|
||||
async (req: Request, res: Response) => {
|
||||
const { pomeloEnabled } = Config.get().general;
|
||||
const where = pomeloEnabled
|
||||
? {
|
||||
// TODO: pomelo: should we use username or add global_name property to the request?
|
||||
global_name: req.body.username,
|
||||
}
|
||||
: {
|
||||
discriminator: String(req.body.discriminator).padStart(
|
||||
4,
|
||||
"0",
|
||||
), //Discord send the discriminator as integer, we need to add leading zeroes
|
||||
username: req.body.username,
|
||||
};
|
||||
return await updateRelationship(
|
||||
req,
|
||||
res,
|
||||
await User.findOneOrFail({
|
||||
relations: ["relationships", "relationships.to"],
|
||||
select: userProjection,
|
||||
where: {
|
||||
discriminator: String(req.body.discriminator).padStart(
|
||||
4,
|
||||
"0",
|
||||
), //Discord send the discriminator as integer, we need to add leading zeroes
|
||||
username: req.body.username,
|
||||
},
|
||||
where,
|
||||
}),
|
||||
req.body.type,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user