fix(whatsapp.gblib): Fix PRIVACY_STORE_MESSAGES param.
This commit is contained in:
		
							parent
							
								
									b301b238ff
								
							
						
					
					
						commit
						99b5b8ba8b
					
				
					 4 changed files with 43 additions and 38 deletions
				
			
		| 
						 | 
				
			
			@ -1272,6 +1272,7 @@ export class GBConversationalService {
 | 
			
		|||
      });
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (process.env.PRIVACY_STORE_MESSAGES === 'true') {
 | 
			
		||||
      const analytics = new AnalyticsService();
 | 
			
		||||
      const conversation = null;
 | 
			
		||||
      if (!user.conversationId) {
 | 
			
		||||
| 
						 | 
				
			
			@ -1279,7 +1280,7 @@ export class GBConversationalService {
 | 
			
		|||
        user.conversationId = conversation.conversationId;
 | 
			
		||||
      }
 | 
			
		||||
      analytics.createMessage(min.instance.instanceId, conversation, null, text);
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
    if (!step && member && !isNaN(member.id) && !member.id.startsWith('1000')) {
 | 
			
		||||
      const to = step.context.activity.group ? step.context.activity.group : member.id;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1034,12 +1034,12 @@ export class GBMinService {
 | 
			
		|||
 | 
			
		||||
          if (context.activity.from.id !== min.botId) {
 | 
			
		||||
            // Creates a new row in user table if it does not exists.
 | 
			
		||||
 | 
			
		||||
            if (process.env.PRIVACY_STORE_MESSAGES === 'true') {
 | 
			
		||||
              // Stores conversation associated to the user to group each message.
 | 
			
		||||
 | 
			
		||||
              const analytics = new AnalyticsService();
 | 
			
		||||
              await analytics.createConversation(user);
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
          }
 | 
			
		||||
 | 
			
		||||
          await sec.updateConversationReferenceById(userId, conversationReference);
 | 
			
		||||
| 
						 | 
				
			
			@ -1409,8 +1409,10 @@ export class GBMinService {
 | 
			
		|||
    const userId = user.userId;
 | 
			
		||||
    const params = user.params ? JSON.parse(user.params) : {};
 | 
			
		||||
 | 
			
		||||
    
 | 
			
		||||
    let message: GuaribasConversationMessage;
 | 
			
		||||
    if (process.env.PRIVACY_STORE_MESSAGES === 'true') {
 | 
			
		||||
      
 | 
			
		||||
      // Adds message to the analytics layer.
 | 
			
		||||
 | 
			
		||||
      const analytics = new AnalyticsService();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -53,7 +53,7 @@ export class FeedbackDialog extends IGBDialog {
 | 
			
		|||
   * @param bot The bot adapter.
 | 
			
		||||
   * @param min The minimal bot instance data.
 | 
			
		||||
   */
 | 
			
		||||
  public static setup (bot: BotAdapter, min: GBMinInstance) {
 | 
			
		||||
  public static setup(bot: BotAdapter, min: GBMinInstance) {
 | 
			
		||||
    const service = new CSService();
 | 
			
		||||
 | 
			
		||||
    min.dialogs.add(
 | 
			
		||||
| 
						 | 
				
			
			@ -264,16 +264,19 @@ export class FeedbackDialog extends IGBDialog {
 | 
			
		|||
        async step => {
 | 
			
		||||
          const fixedLocale = 'en-US';
 | 
			
		||||
          const user = await min.userProfile.get(step.context, {});
 | 
			
		||||
          let rate = 1;
 | 
			
		||||
 | 
			
		||||
          if (process.env.PRIVACY_STORE_MESSAGES === 'true') {
 | 
			
		||||
            // Updates values to perform Bot Analytics.
 | 
			
		||||
 | 
			
		||||
            const analytics = new AnalyticsService();
 | 
			
		||||
          const rate = await analytics.updateConversationSuggestion(
 | 
			
		||||
            let rate = await analytics.updateConversationSuggestion(
 | 
			
		||||
              min.instance.instanceId,
 | 
			
		||||
              user.conversation.conversationId,
 | 
			
		||||
              step.result,
 | 
			
		||||
              user.locale
 | 
			
		||||
            );
 | 
			
		||||
          }
 | 
			
		||||
 | 
			
		||||
          if (rate > 0.5) {
 | 
			
		||||
            await min.conversationalService.sendText(min, step, Messages[fixedLocale].glad_you_liked);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -39,7 +39,6 @@ import { GBMinInstance, IGBDialog } from 'botlib';
 | 
			
		|||
import { BotAdapter } from 'botbuilder';
 | 
			
		||||
import { WaterfallDialog } from 'botbuilder-dialogs';
 | 
			
		||||
import { AnalyticsService } from '../../analytics.gblib/services/AnalyticsService.js';
 | 
			
		||||
import { GBConversationalService } from '../../core.gbapp/services/GBConversationalService.js';
 | 
			
		||||
import { CSService } from '../services/CSService.js';
 | 
			
		||||
import { Messages } from '../strings.js';
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -53,7 +52,7 @@ export class QualityDialog extends IGBDialog {
 | 
			
		|||
   * @param bot The bot adapter.
 | 
			
		||||
   * @param min The minimal bot instance data.
 | 
			
		||||
   */
 | 
			
		||||
  public static setup (bot: BotAdapter, min: GBMinInstance) {
 | 
			
		||||
  public static setup(bot: BotAdapter, min: GBMinInstance) {
 | 
			
		||||
    const service = new CSService();
 | 
			
		||||
 | 
			
		||||
    min.dialogs.add(
 | 
			
		||||
| 
						 | 
				
			
			@ -89,7 +88,7 @@ export class QualityDialog extends IGBDialog {
 | 
			
		|||
            await service.insertQuestionAlternate(min.instance.instanceId, user.lastQuestion, user.lastQuestionId);
 | 
			
		||||
 | 
			
		||||
            // Updates values to perform Bot Analytics.
 | 
			
		||||
 | 
			
		||||
            if (process.env.PRIVACY_STORE_MESSAGES === 'true') {
 | 
			
		||||
              const analytics = new AnalyticsService();
 | 
			
		||||
              analytics.updateConversationSuggestion(
 | 
			
		||||
                min.instance.instanceId,
 | 
			
		||||
| 
						 | 
				
			
			@ -97,7 +96,7 @@ export class QualityDialog extends IGBDialog {
 | 
			
		|||
                step.result,
 | 
			
		||||
                user.locale
 | 
			
		||||
              );
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
            // Goes to the ask loop.
 | 
			
		||||
 | 
			
		||||
            return await step.replaceDialog('/ask', { emptyPrompt: true });
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue