1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-09-22 02:31:36 +02:00

save private data in user.user_data

This commit is contained in:
Flam3rboy 2021-04-06 03:56:08 +02:00
parent 75b690600d
commit 35be87b867

View File

@ -8,7 +8,6 @@ export interface User {
username: string; // username max length 32, min 2 username: string; // username max length 32, min 2
discriminator: string; // #0001 4 digit long string from #0001 - #9999 discriminator: string; // #0001 4 digit long string from #0001 - #9999
avatar: string | null; // hash of the user avatar avatar: string | null; // hash of the user avatar
fingerprints: string[]; // array of fingerprints -> used to prevent multiple accounts
phone?: string; // phone number of the user phone?: string; // phone number of the user
desktop: boolean; // if the user has desktop app installed desktop: boolean; // if the user has desktop app installed
mobile: boolean; // if the user has mobile app installed mobile: boolean; // if the user has mobile app installed
@ -16,7 +15,6 @@ export interface User {
premium_type: number; // nitro level premium_type: number; // nitro level
bot: boolean; // if user is bot bot: boolean; // if user is bot
system: boolean; // shouldn't be used, the api sents this field type true, if the genetaed message comes from a system generated author system: boolean; // shouldn't be used, the api sents this field type true, if the genetaed message comes from a system generated author
level: string; // organization permission level (owner, moderator, user)
nsfw_allowed: boolean; // if the user is older than 18 (resp. Config) nsfw_allowed: boolean; // if the user is older than 18 (resp. Config)
mfa_enabled: boolean; // if multi factor authentication is enabled mfa_enabled: boolean; // if multi factor authentication is enabled
created_at: Date; // registration date created_at: Date; // registration date
@ -24,12 +22,8 @@ export interface User {
email?: string; // email of the user email?: string; // email of the user
flags: bigint; // UserFlags flags: bigint; // UserFlags
public_flags: bigint; public_flags: bigint;
hash: string; // hash of the password, salt is saved in password (bcrypt)
guilds: bigint[]; // array of guild ids the user is part of
valid_tokens_since: Date; // all tokens with a previous issue date are invalid
user_settings: UserSettings; user_settings: UserSettings;
relationships: Relationship[]; user_data: UserData;
connected_accounts: ConnectedAccount[];
presence: { presence: {
status: Status; status: Status;
activities: Activity[]; activities: Activity[];
@ -37,6 +31,16 @@ export interface User {
}; };
} }
// Privat user data:
export interface UserData {
valid_tokens_since: Date; // all tokens with a previous issue date are invalid
relationships: Relationship[];
connected_accounts: ConnectedAccount[];
guilds: bigint[]; // array of guild ids the user is part of
hash: string; // hash of the password, salt is saved in password (bcrypt)
fingerprints: string[]; // array of fingerprints -> used to prevent multiple accounts
}
export interface UserDocument extends User, Document { export interface UserDocument extends User, Document {
id: bigint; id: bigint;
} }
@ -118,7 +122,6 @@ export const UserSchema = new Schema({
username: String, username: String,
discriminator: String, discriminator: String,
avatar: String, avatar: String,
fingerprints: [String],
phone: String, phone: String,
desktop: Boolean, desktop: Boolean,
mobile: Boolean, mobile: Boolean,
@ -133,9 +136,33 @@ export const UserSchema = new Schema({
email: String, email: String,
flags: Types.Long, // TODO: automatically convert Types.Long to BitField of UserFlags flags: Types.Long, // TODO: automatically convert Types.Long to BitField of UserFlags
public_flags: Types.Long, public_flags: Types.Long,
hash: String, // hash of the password, salt is saved in password (bcrypt) user_data: {
guilds: [Types.Long], // array of guild ids the user is part of fingerprints: [String],
valid_tokens_since: Date, // all tokens with a previous issue date are invalid hash: String, // hash of the password, salt is saved in password (bcrypt)
guilds: [Types.Long], // array of guild ids the user is part of
valid_tokens_since: Date, // all tokens with a previous issue date are invalid
relationships: [
{
id: Types.Long,
nickname: String,
type: Number,
user_id: Types.Long,
},
],
connected_accounts: [
{
access_token: String,
friend_sync: Boolean,
id: String,
name: String,
revoked: Boolean,
show_activity: Boolean,
type: String,
verifie: Boolean,
visibility: Number,
},
],
},
user_settings: { user_settings: {
afk_timeout: Number, afk_timeout: Number,
allow_accessibility_detection: Boolean, allow_accessibility_detection: Boolean,
@ -182,27 +209,7 @@ export const UserSchema = new Schema({
theme: String, // dark theme: String, // dark
timezone_offset: Number, // e.g -60, timezone_offset: Number, // e.g -60,
}, },
relationships: [
{
id: Types.Long,
nickname: String,
type: Number,
user_id: Types.Long,
},
],
connected_accounts: [
{
access_token: String,
friend_sync: Boolean,
id: String,
name: String,
revoked: Boolean,
show_activity: Boolean,
type: String,
verifie: Boolean,
visibility: Number,
},
],
presence: { presence: {
status: String, status: String,
activities: [Activity], activities: [Activity],