fix(basic.gblib): update ChatServices.ts #420

Closed
eltociear wants to merge 2540 commits from patch-1 into main
2 changed files with 30 additions and 0 deletions
Showing only changes of commit 46261d7b1f - Show all commits

View file

@ -77,6 +77,13 @@ export class GuaribasUser extends Model<GuaribasUser> {
@BelongsTo(() => GuaribasInstance)
public instance: GuaribasInstance;
@Column
phone: string
@Column(DataType.TEXT)
@Column
conversationReference: string
}
/**

View file

@ -3,6 +3,7 @@ import urlJoin = require('url-join');
import { GBService, IGBInstance } from 'botlib';
import { GuaribasGroup, GuaribasUser, GuaribasUserGroup } from '../models';
import { ConversationReference } from 'botbuilder';
/**
* Security service layer.
@ -65,4 +66,26 @@ export class SecService extends GBService {
.error(reject);
});
}
/**
* Retrives a conversation reference from contact phone.
*/
public async getConversationReference(phone: string): Promise<ConversationReference> {
const options = { where: { phone: phone } };
const user = await GuaribasUser.findOne(options);
return JSON.parse(user.conversationReference);
}
/**
* Updates a conversation reference from contact phone.
*/
public async updateConversationReference(phone: string, conversationReference: string) {
const options = { where: { phone: phone } };
const user = await GuaribasUser.findOne(options);
user.conversationReference = conversationReference;
await user.save();
}
}