ChatModel - IEEE-Team-3/map GitHub Wiki
Chats are divided into two types: team
and dm
(direct messages).
-
id
: Unique chat ID -
type
: "team" | "dm" -
name
: Channel name (for team chats) -
participants
: List of user IDs -
messages
: Reference to messages -
locked
: Boolean (whether chat is locked) -
lockedBy
: User ID who locked the chat -
teamId
: (if team chat)
const ChatSchema = new Schema({
type: { type: String, enum: ['team', 'dm'], required: true },
name: String,
participants: [{ type: Schema.Types.ObjectId, ref: 'User' }],
messages: [{ type: Schema.Types.ObjectId, ref: 'Message' }],
locked: { type: Boolean, default: false },
lockedBy: { type: Schema.Types.ObjectId, ref: 'User' },
teamId: { type: Schema.Types.ObjectId, ref: 'Team' }
});
- When
locked = true
, messages cannot be sent, but can still be viewed. - Only users with specific roles (e.g., Team Owner, Admin) can lock/unlock a chat.