mirror of
https://github.com/spacebarchat/server.git
synced 2026-03-30 20:25:40 +00:00
rename pomeloEnabled to uniqueUsernames
This commit is contained in:
@@ -192,11 +192,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,
|
||||
|
||||
@@ -120,7 +120,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, "").trim();
|
||||
if (!check_username) {
|
||||
@@ -152,7 +152,7 @@ router.patch(
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: pomelo: disallow if pomelo is enabled
|
||||
// TODO: uniqueUsernames: disallow if uniqueUsernames is enabled
|
||||
if (body.discriminator) {
|
||||
if (
|
||||
await User.findOne({
|
||||
|
||||
@@ -131,10 +131,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,
|
||||
}
|
||||
: {
|
||||
|
||||
@@ -122,12 +122,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,
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -29,5 +29,5 @@ export class GeneralConfiguration {
|
||||
image: string | null = null;
|
||||
instanceId: string = Snowflake.generate();
|
||||
autoCreateBotUsers: boolean = false;
|
||||
pomeloEnabled: boolean = false;
|
||||
uniqueUsernames: boolean = false;
|
||||
}
|
||||
|
||||
@@ -55,10 +55,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
|
||||
@@ -267,10 +267,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}`;
|
||||
}
|
||||
@@ -291,13 +291,13 @@ export class User extends BaseClass {
|
||||
req?: Request;
|
||||
bot?: boolean;
|
||||
}) {
|
||||
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) {
|
||||
|
||||
Reference in New Issue
Block a user