fix duplicate notifications on support chat request; fix transcript attachment filename

This commit is contained in:
Sharon Kennedy
2020-06-19 12:57:23 -04:00
parent 5ac3b9d367
commit 391bd22121
7 changed files with 210 additions and 99 deletions

View File

@@ -64,9 +64,9 @@ class OcrccBot {
}
async sendMessage(roomId, content) {
logger.log("info", `SENDING MESSAGE: ${content.body}`)
try {
await this.client.sendMessage(roomId, content)
logger.log("info", `SENT MESSAGE: ${content.body}`)
} catch(err) {
switch (err["name"]) {
case "UnknownDeviceError":
@@ -293,7 +293,7 @@ class OcrccBot {
const file = fs.readFileSync(transcriptFile);
const stats = fs.statSync(transcriptFile);
const url = await this.client.uploadContent(file, { rawResponse: false, type: 'text/plain' })
const url = await this.client.uploadContent(file, { rawResponse: false, name: filename })
logger.log('info', url)
const content = {
@@ -304,7 +304,8 @@ class OcrccBot {
mimetype: 'text/plain'
},
url: url.content_uri,
showToUser: senderId
showToUser: senderId,
mimetype: 'text/plain'
};
this.sendMessage(roomId, content);
@@ -388,15 +389,19 @@ class OcrccBot {
!this.joinedRooms.includes(member.roomId)
) {
try {
const room = await this.client.joinRoom(member.roomId)
logger.log("info", "AUTO JOINED ROOM => " + room.roomId)
const currentDate = new Date()
const chatDate = currentDate.toLocaleDateString()
const chatTime = currentDate.toLocaleTimeString()
const roomId = room.roomId.split(':')[0]
const notification = `Incoming support chat at ${chatTime} (room ID: ${roomId})`
this.sendTextMessage(this.config.FACILITATOR_ROOM_ID, notification);
this.inviteFacilitators(room.roomId)
const roomData = await this.client.getJoinedRooms()
const joinedRooms = roomData["joined_rooms"]
if (!joinedRooms.includes(member.roomId)) {
const room = await this.client.joinRoom(member.roomId)
logger.log("info", "AUTO JOINED ROOM => " + room.roomId)
const currentDate = new Date()
const chatDate = currentDate.toLocaleDateString()
const chatTime = currentDate.toLocaleTimeString()
const roomId = room.roomId.split(':')[0]
const notification = `Incoming support chat at ${chatTime} (room ID: ${roomId})`
this.sendTextMessage(this.config.FACILITATOR_ROOM_ID, notification);
this.inviteFacilitators(room.roomId)
}
} catch(err) {
logger.log("error", "ERROR JOINING ROOM => " + err)
}

View File

@@ -48,7 +48,6 @@ const {
BOT_USERID,
BOT_PASSWORD,
BOT_DISPLAY_NAME,
FACILITATOR_GROUP_ID,
FACILITATOR_ROOM_ID,
CHAT_OFFLINE_MESSAGE,
CAPTURE_TRANSCRIPTS
@@ -64,7 +63,6 @@ const botConfig = {
BOT_USERID,
BOT_PASSWORD,
BOT_DISPLAY_NAME,
FACILITATOR_GROUP_ID,
FACILITATOR_ROOM_ID,
CHAT_OFFLINE_MESSAGE,
CAPTURE_TRANSCRIPTS

View File

@@ -11,7 +11,6 @@ const {
BOT_USERID,
BOT_PASSWORD,
BOT_DISPLAY_NAME,
FACILITATOR_GROUP_ID,
FACILITATOR_ROOM_ID,
CAPTURE_TRANSCRIPTS,
} = process.env;
@@ -26,7 +25,6 @@ const botConfig = {
BOT_USERID,
BOT_PASSWORD,
BOT_DISPLAY_NAME,
FACILITATOR_GROUP_ID,
FACILITATOR_ROOM_ID,
CAPTURE_TRANSCRIPTS,
}