41 lines
1.2 KiB
JavaScript
41 lines
1.2 KiB
JavaScript
const mongoose = require('mongoose')
|
|
|
|
const chatRoomSchema = new mongoose.Schema(
|
|
{
|
|
title: { type: String, required: true, trim: true },
|
|
slug: { type: String, required: true, unique: true, trim: true },
|
|
description: { type: String, trim: true },
|
|
image: { type: String },
|
|
members: [{ type: mongoose.Schema.Types.ObjectId, ref: 'User' }],
|
|
createdBy: { type: mongoose.Schema.Types.ObjectId, ref: 'User' },
|
|
province: {
|
|
id: { type: Number },
|
|
name: { type: String }
|
|
},
|
|
city: {
|
|
id: { type: Number },
|
|
name: { type: String }
|
|
},
|
|
expertise: { type: String, trim: true },
|
|
visibility: {
|
|
type: String,
|
|
enum: ['public', 'private'],
|
|
default: 'public',
|
|
index: true,
|
|
},
|
|
lastActivityAt: { type: Date, default: Date.now, index: true },
|
|
idleTimeoutMs: { type: Number, default: 30 * 24 * 60 * 60 * 1000 },
|
|
isSystem: { type: Boolean, default: false },
|
|
e2ee_enabled: { type: Boolean, default: false },
|
|
e2ee_wrapped_keys: [
|
|
{
|
|
userId: { type: mongoose.Schema.Types.ObjectId, ref: 'User', required: true },
|
|
wrappedKey: { type: String, required: true }
|
|
}
|
|
]
|
|
},
|
|
{ timestamps: true }
|
|
)
|
|
|
|
module.exports = mongoose.model('ChatRoom', chatRoomSchema)
|