Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

πŸ”€ πŸ€– ✨ Enable the bot to switch between stories - #4 #172

Prev Previous commit
Next Next commit
πŸ‡ πŸ”§ add update method and pass story to end user document
  • Loading branch information
ReaganCn committed Dec 2, 2022
commit b60639e677bc1551502d384b12b6c9ec8de32495
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { ChatStatus, EndUser } from '@app/model/convs-mgr/conversations/chats';
/**
* Contains all the required database flow methods for the chat-status collection
*/
export class EndUserDataService extends BotDataService<EndUser>{
export class EndUserDataService extends BotDataService<EndUser>{
private _docPath: string;
tools: HandlerTools;

Expand All @@ -24,11 +24,13 @@ export class EndUserDataService extends BotDataService<EndUser>{
this._docPath = `orgs/${orgId}/end-users`;
}

async createEndUser(endUserId: string, phoneNumber: string, chatStatus?: ChatStatus)
async createEndUser(endUserId: string, phoneNumber: string, storyId: string)
{
const newEndUser: EndUser = {
currentStory: storyId,
phoneNumber,
status: chatStatus || ChatStatus.Running
status: ChatStatus.Running,

};

const endUser = await this.createDocument(newEndUser, this._docPath, endUserId);
Expand All @@ -44,6 +46,11 @@ export class EndUserDataService extends BotDataService<EndUser>{
return endUser;
}

async updateEndUser(endUser: EndUser)
{
return this.updateDocument(endUser, this._docPath, endUser.id)
}

async updateEndUserChatStatus(endUser: EndUser, status: ChatStatus)
{
const newStatus: EndUser = {
Expand Down