EventBuzz_Backend/src/models/ChatSubscriber.js

33 lines
892 B
JavaScript

const mongoose = require('mongoose');
const chatSubscriberSchema = new mongoose.Schema(
{
eventId: {
type: mongoose.Schema.Types.ObjectId,
ref: 'Event',
required: true,
index: true,
},
attendeeId: {
type: mongoose.Schema.Types.ObjectId,
ref: 'Participant',
default: null,
},
phoneNumber: { type: String, required: true, index: true },
sessionState: {
type: String,
enum: ['WELCOME_FORK', 'AWAITING_TICKET', 'MAIN_MENU', 'LOCAL_GUIDE_MODE'],
default: 'WELCOME_FORK',
},
metaContext: {
guestModeEnabled: { type: Boolean, default: false },
lastMenuInteraction: { type: Date, default: Date.now },
},
},
{ timestamps: true },
);
chatSubscriberSchema.index({ eventId: 1, phoneNumber: 1 }, { unique: true });
module.exports = mongoose.model('ChatSubscriber', chatSubscriberSchema);