80 lines
1.9 KiB
JavaScript
80 lines
1.9 KiB
JavaScript
![]() |
const mongoose = require('mongoose');
|
|||
|
|
|||
|
const reportSchema = new mongoose.Schema({
|
|||
|
// Кто подает жалобу
|
|||
|
reporter: {
|
|||
|
type: mongoose.Schema.Types.ObjectId,
|
|||
|
ref: 'User',
|
|||
|
required: true
|
|||
|
},
|
|||
|
|
|||
|
// На кого подается жалоба
|
|||
|
reportedUser: {
|
|||
|
type: mongoose.Schema.Types.ObjectId,
|
|||
|
ref: 'User',
|
|||
|
required: true
|
|||
|
},
|
|||
|
|
|||
|
// Причина жалобы
|
|||
|
reason: {
|
|||
|
type: String,
|
|||
|
required: true,
|
|||
|
enum: [
|
|||
|
'inappropriate_content',
|
|||
|
'fake_profile',
|
|||
|
'harassment',
|
|||
|
'spam',
|
|||
|
'offensive_behavior',
|
|||
|
'underage',
|
|||
|
'other'
|
|||
|
]
|
|||
|
},
|
|||
|
|
|||
|
// Дополнительное описание
|
|||
|
description: {
|
|||
|
type: String,
|
|||
|
maxlength: 500
|
|||
|
},
|
|||
|
|
|||
|
// Статус жалобы
|
|||
|
status: {
|
|||
|
type: String,
|
|||
|
enum: ['pending', 'reviewed', 'resolved', 'dismissed'],
|
|||
|
default: 'pending'
|
|||
|
},
|
|||
|
|
|||
|
// Администратор, который рассмотрел жалобу
|
|||
|
reviewedBy: {
|
|||
|
type: mongoose.Schema.Types.ObjectId,
|
|||
|
ref: 'User'
|
|||
|
},
|
|||
|
|
|||
|
// Дата рассмотрения
|
|||
|
reviewedAt: {
|
|||
|
type: Date
|
|||
|
},
|
|||
|
|
|||
|
// Комментарий администратора
|
|||
|
adminComment: {
|
|||
|
type: String,
|
|||
|
maxlength: 500
|
|||
|
},
|
|||
|
|
|||
|
// Действие, предпринятое администратором
|
|||
|
actionTaken: {
|
|||
|
type: String,
|
|||
|
enum: ['none', 'warning', 'temporary_ban', 'permanent_ban', 'profile_removal']
|
|||
|
}
|
|||
|
}, {
|
|||
|
timestamps: true
|
|||
|
});
|
|||
|
|
|||
|
// Индексы для оптимизации запросов
|
|||
|
reportSchema.index({ reporter: 1, reportedUser: 1 });
|
|||
|
reportSchema.index({ reportedUser: 1, status: 1 });
|
|||
|
reportSchema.index({ status: 1, createdAt: -1 });
|
|||
|
|
|||
|
// Предотвращаем дублирование жалоб от одного пользователя на другого
|
|||
|
reportSchema.index({ reporter: 1, reportedUser: 1 }, { unique: true });
|
|||
|
|
|||
|
module.exports = mongoose.model('Report', reportSchema);
|