feat(security.gblib): Phone field and conversation refeerence.
This commit is contained in:
parent
223801da17
commit
46261d7b1f
2 changed files with 30 additions and 0 deletions
|
@ -77,6 +77,13 @@ export class GuaribasUser extends Model<GuaribasUser> {
|
||||||
|
|
||||||
@BelongsTo(() => GuaribasInstance)
|
@BelongsTo(() => GuaribasInstance)
|
||||||
public instance: GuaribasInstance;
|
public instance: GuaribasInstance;
|
||||||
|
|
||||||
|
@Column
|
||||||
|
phone: string
|
||||||
|
|
||||||
|
@Column(DataType.TEXT)
|
||||||
|
@Column
|
||||||
|
conversationReference: string
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -3,6 +3,7 @@ import urlJoin = require('url-join');
|
||||||
|
|
||||||
import { GBService, IGBInstance } from 'botlib';
|
import { GBService, IGBInstance } from 'botlib';
|
||||||
import { GuaribasGroup, GuaribasUser, GuaribasUserGroup } from '../models';
|
import { GuaribasGroup, GuaribasUser, GuaribasUserGroup } from '../models';
|
||||||
|
import { ConversationReference } from 'botbuilder';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Security service layer.
|
* Security service layer.
|
||||||
|
@ -65,4 +66,26 @@ export class SecService extends GBService {
|
||||||
.error(reject);
|
.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();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue