nakama/backend/models/User.js

124 lines
2.8 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

const mongoose = require('mongoose');
const UserSchema = new mongoose.Schema({
telegramId: {
type: String,
sparse: true, // Разрешаем null для web-пользователей
unique: true
},
username: {
type: String,
required: true
},
firstName: String,
lastName: String,
photoUrl: String,
bio: {
type: String,
default: '',
maxlength: 300
},
role: {
type: String,
enum: ['user', 'moderator', 'admin'],
default: 'user'
},
followers: [{
type: mongoose.Schema.Types.ObjectId,
ref: 'User'
}],
following: [{
type: mongoose.Schema.Types.ObjectId,
ref: 'User'
}],
settings: {
whitelist: {
noFurry: { type: Boolean, default: false },
onlyAnime: { type: Boolean, default: false },
// Скрыть контент 18+
noNSFW: { type: Boolean, default: false },
// Скрыть гомосексуальный контент
noHomo: { type: Boolean, default: true }
},
searchPreference: {
type: String,
enum: ['furry', 'anime'],
default: 'furry'
}
},
// Предпочитаемые теги для ленты по интересам
preferredTags: [{
type: String,
lowercase: true,
trim: true
}],
// Предложенные пользователем теги (ожидают модерации)
suggestedTags: [{
tagName: {
type: String,
required: true,
lowercase: true,
trim: true
},
category: {
type: String,
enum: ['theme', 'style', 'mood', 'technical']
},
description: String,
status: {
type: String,
enum: ['pending', 'approved', 'rejected'],
default: 'pending'
},
createdAt: {
type: Date,
default: Date.now
}
}],
lastActiveAt: {
type: Date,
default: Date.now
},
banned: {
type: Boolean,
default: false
},
bannedUntil: Date,
// Билеты для Monthly Ladder
tickets: {
type: Number,
default: 0
},
// Email и пароль для авторизации через логин/пароль
email: {
type: String,
lowercase: true,
trim: true,
sparse: true, // Разрешить null, но если есть - должен быть уникальным
index: true
},
passwordHash: {
type: String,
select: false // Не возвращать по умолчанию
},
emailVerified: {
type: Boolean,
default: false
},
// Magic-link токены для авторизации
magicLinkToken: String,
magicLinkExpires: Date,
// Onboarding - отслеживание показа приветствия
onboardingCompleted: {
type: Boolean,
default: false
},
createdAt: {
type: Date,
default: Date.now
}
});
module.exports = mongoose.model('User', UserSchema);