change notice to signal

This commit is contained in:
Sharon Kennedy 2020-09-11 16:12:01 -04:00
parent 4fdddc8c92
commit e2c291c040

View File

@ -12,6 +12,7 @@ import logger from "./logger";
import encrypt from "./encrypt-attachment"; import encrypt from "./encrypt-attachment";
const BOT_SIGNAL_END_CHAT = 'END_CHAT' const BOT_SIGNAL_END_CHAT = 'END_CHAT'
const BOT_SIGNAL_CHAT_OFFLINE = 'CHAT_OFFLINE'
class OcrccBot { class OcrccBot {
@ -130,7 +131,7 @@ class OcrccBot {
this.localStorage.setItem(`${roomId}-invitations`, invitations) this.localStorage.setItem(`${roomId}-invitations`, invitations)
} else { } else {
logger.log('info', "NO FACILITATORS ONLINE") logger.log('info', "NO FACILITATORS ONLINE")
this.sendNotice(roomId, "CHAT_OFFLINE") this.sendBotSignal(roomId, BOT_SIGNAL_CHAT_OFFLINE)
} }
} catch(err) { } catch(err) {
@ -596,9 +597,14 @@ class OcrccBot {
} }
setTimeoutforFacilitator(roomId) { setTimeoutforFacilitator(roomId) {
setTimeout(() => { setTimeout(async() => {
const stillWaiting = this.localStorage.getItem(`${roomId}-waiting`) const stillWaiting = this.localStorage.getItem(`${roomId}-waiting`)
if (stillWaiting) { if (stillWaiting) {
logger.log("info", `FACILITATOR DID NOT JOIN CHAT WITHIN TIME LIMIT, SENDING SIGNAL TO END CHAT`);
await this.sendTextMessage(
roomId,
this.config.CHAT_NOT_AVAILABLE_MESSAGE
);
this.sendBotSignal(roomId, BOT_SIGNAL_END_CHAT) this.sendBotSignal(roomId, BOT_SIGNAL_END_CHAT)
} }
}, this.config.MAX_WAIT_TIME) }, this.config.MAX_WAIT_TIME)
@ -611,8 +617,9 @@ class OcrccBot {
clearTimeout(oldTimeout); clearTimeout(oldTimeout);
} }
const newTimeout = setTimeout(() => { const newTimeout = setTimeout(async() => {
this.sendTextMessage( logger.log("info", `CHAT IS INACTIVE, SENDING SIGNAL TO END CHAT`);
await this.sendTextMessage(
roomId, roomId,
`This chat has been closed due to inactivity.` `This chat has been closed due to inactivity.`
); );