diff --git a/server/src/yemot-handler.service.ts b/server/src/yemot-handler.service.ts index b4ec3b5a..6be2b40e 100644 --- a/server/src/yemot-handler.service.ts +++ b/server/src/yemot-handler.service.ts @@ -16,6 +16,10 @@ export class YemotHandlerService extends BaseYemotHandlerService { override async processCall(): Promise { await this.getUserByDidPhone(); this.logger.log(`Processing call with ID: ${this.call.callId} from phone: ${this.call.phone}`); + if (await this.isPastReportingDeadline()) { + await this.hangupWithMessage("המערכת סגורה. לא ניתן לדווח אחרי השעה תשע וחצי בבוקר. המשך יום טוב."); + return; + } const student = await this.getStudentByInput() if (!student) return; const alreadyReported = await this.hasReportedToday(student.id); @@ -34,7 +38,15 @@ export class YemotHandlerService extends BaseYemotHandlerService { await this.hangupWithMessage("יצאת מאוחר מידי המשך יום טוב"); } } + private isPastReportingDeadline(): boolean { + const now = new Date(); + const israelTime = new Date(now.toLocaleString('en-US', { timeZone: 'Asia/Jerusalem' })); + const hour = israelTime.getHours(); + const minute = israelTime.getMinutes(); + + return hour > 9 || (hour === 9 && minute >= 30); + } private async getStudentByInput(): Promise { let student = null; while (!student) {