Skip to content

Commit

Permalink
await fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sgao88 committed Apr 13, 2021
1 parent ec927d0 commit 77313db
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions ReceiveMessage/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ const manageKeywordSent = async function (
const newUser = new UserState({ userId: body.From, dataConsent: true, currMessage: messageId, lowData: false })

await newUser.save()
return await fixedMessages.get('datapermission')
return fixedMessages.get('datapermission')
} else if (!curUserState) {
//new user that hasn't consented
return await fixedMessages.get('messagepermission')
return fixedMessages.get('messagepermission')
} else if (specialMessageIds.has(String(sentMessage.Body).toLowerCase())) {
// special message handling
const responseHandler = specialMessageIds.get(String(sentMessage.Body).toLowerCase())
Expand Down
18 changes: 9 additions & 9 deletions ReceiveMessage/specialMessageIds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ const restartHandler: templateSpecialMessageHandler = async function (curUserSta
curUserState.currMessage = (await fixedMessages.get('welcome'))._id
await curUserState.save()

return await fixedMessages.get('welcome')
return fixedMessages.get('welcome')
}

const commandsHandler: templateSpecialMessageHandler = async function (curUserState: IUserState): Promise<IMessage> {
return await fixedMessages.get('commands')
return fixedMessages.get('commands')
}

const helpHandler: templateSpecialMessageHandler = async function (curUserState: IUserState): Promise<IMessage> {
return await fixedMessages.get('helpme')
return fixedMessages.get('helpme')
}

const completedHandler: templateSpecialMessageHandler = async function (curUserState: IUserState): Promise<IMessage> {
Expand All @@ -36,40 +36,40 @@ const completedHandler: templateSpecialMessageHandler = async function (curUserS

// mostly for testing purposes
const currentHandler: templateSpecialMessageHandler = async function (curUserState: IUserState): Promise<IMessage> {
return await ChatbotMessage.findById(curUserState.currMessage)
return ChatbotMessage.findById(curUserState.currMessage)
}

const yesDataHandler: templateSpecialMessageHandler = async function (curUserState: IUserState): Promise<IMessage> {
curUserState.dataConsent = true
await curUserState.save()

return await fixedMessages.get('yesDataCollection')
return fixedMessages.get('yesDataCollection')
}

const noDataHandler: templateSpecialMessageHandler = async function (curUserState: IUserState): Promise<IMessage> {
curUserState.dataConsent = false
await curUserState.save()

return await fixedMessages.get('noDataCollection')
return fixedMessages.get('noDataCollection')
}

const yesLowDataHandler: templateSpecialMessageHandler = async function (curUserState: IUserState): Promise<IMessage> {
curUserState.lowData = true
await curUserState.save()

return await fixedMessages.get('TurnOnLowData')
return fixedMessages.get('TurnOnLowData')
}

const noLowDataHandler: templateSpecialMessageHandler = async function (curUserState: IUserState): Promise<IMessage> {
curUserState.lowData = false
await curUserState.save()

return await fixedMessages.get('TurnOffLowData')
return fixedMessages.get('TurnOffLowData')
}

const deleteHandler: templateSpecialMessageHandler = async function (curUserState: IUserState): Promise<IMessage> {
UserState.deleteOne({ userId: curUserState.userId })
return await fixedMessages.get('complete exit message')
return fixedMessages.get('complete exit message')
}

const specialMessageIds: Map<string | qs.ParsedQs | string[] | qs.ParsedQs[], templateSpecialMessageHandler> = new Map<
Expand Down

0 comments on commit 77313db

Please sign in to comment.