new(basic.gblib): SEND FILE pdf as temporary images.
This commit is contained in:
		
							parent
							
								
									8590607aa9
								
							
						
					
					
						commit
						2cffae858c
					
				
					 3 changed files with 12 additions and 4 deletions
				
			
		| 
						 | 
					@ -1462,7 +1462,7 @@ export class DialogKeywords {
 | 
				
			||||||
      const pngs = await GBUtil.pdfPageAsImage(min, pdf, undefined);
 | 
					      const pngs = await GBUtil.pdfPageAsImage(min, pdf, undefined);
 | 
				
			||||||
      
 | 
					      
 | 
				
			||||||
      await CollectionUtil.asyncForEach(pngs, async png => {
 | 
					      await CollectionUtil.asyncForEach(pngs, async png => {
 | 
				
			||||||
        await GBUtil.sleep(500);
 | 
					        await GBUtil.sleep(2000);
 | 
				
			||||||
        // Prepare a cache to be referenced by Bot Framework.
 | 
					        // Prepare a cache to be referenced by Bot Framework.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        url = urlJoin(GBServer.globals.publicAddress, min.botId, 'cache', path.basename(png.localName));
 | 
					        url = urlJoin(GBServer.globals.publicAddress, min.botId, 'cache', path.basename(png.localName));
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1114,7 +1114,11 @@ export class GBMinService {
 | 
				
			||||||
        step.context.activity['pid'] = pid;
 | 
					        step.context.activity['pid'] = pid;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        const notes = min.core.getParam(min.instance, 'Notes', null);
 | 
					        const notes = min.core.getParam(min.instance, 'Notes', null);
 | 
				
			||||||
        await this.handleUploads(min, step, user, params, notes != null);
 | 
					        if (await this.handleUploads(min, step, user, params, notes != null))
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					          return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
        // Required for MSTEAMS handling of persisted conversations.
 | 
					        // Required for MSTEAMS handling of persisted conversations.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1358,7 +1362,7 @@ export class GBMinService {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  private async handleUploads(min, step, user, params, autoSave) {
 | 
					  private async handleUploads(min, step, user, params, autoSave) {
 | 
				
			||||||
    // Prepare Promises to download each attachment and then execute each Promise.
 | 
					    // Prepare Promises to download each attachment and then execute each Promise.
 | 
				
			||||||
 | 
					    let ret = false;
 | 
				
			||||||
    if (
 | 
					    if (
 | 
				
			||||||
      step.context.activity.attachments &&
 | 
					      step.context.activity.attachments &&
 | 
				
			||||||
      step.context.activity.attachments[0] &&
 | 
					      step.context.activity.attachments[0] &&
 | 
				
			||||||
| 
						 | 
					@ -1370,6 +1374,7 @@ export class GBMinService {
 | 
				
			||||||
      const successfulSaves = await Promise.all(promises);
 | 
					      const successfulSaves = await Promise.all(promises);
 | 
				
			||||||
      async function replyForReceivedAttachments(attachmentData) {
 | 
					      async function replyForReceivedAttachments(attachmentData) {
 | 
				
			||||||
        if (attachmentData) {
 | 
					        if (attachmentData) {
 | 
				
			||||||
 | 
					          
 | 
				
			||||||
          // In case of not having HEAR activated before, it is
 | 
					          // In case of not having HEAR activated before, it is
 | 
				
			||||||
          // a upload with no Dialog, so run Auto Save to .gbdrive.
 | 
					          // a upload with no Dialog, so run Auto Save to .gbdrive.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1406,6 +1411,7 @@ export class GBMinService {
 | 
				
			||||||
      const replyPromises = successfulSaves.map(replyForReceivedAttachments.bind(step.context));
 | 
					      const replyPromises = successfulSaves.map(replyForReceivedAttachments.bind(step.context));
 | 
				
			||||||
      await Promise.all(replyPromises);
 | 
					      await Promise.all(replyPromises);
 | 
				
			||||||
      if (successfulSaves.length > 0) {
 | 
					      if (successfulSaves.length > 0) {
 | 
				
			||||||
 | 
					        ret = true;
 | 
				
			||||||
        class GBFile {
 | 
					        class GBFile {
 | 
				
			||||||
          data: Buffer;
 | 
					          data: Buffer;
 | 
				
			||||||
          filename: string;
 | 
					          filename: string;
 | 
				
			||||||
| 
						 | 
					@ -1429,11 +1435,13 @@ export class GBMinService {
 | 
				
			||||||
            throw new Error('It is only possible to upload one file per message, right now.');
 | 
					            throw new Error('It is only possible to upload one file per message, right now.');
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
          min.cbMap[user.userId].promise = results[0];
 | 
					          min.cbMap[user.userId].promise = results[0];
 | 
				
			||||||
 | 
					          return;
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
          return;
 | 
					          return;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					    return ret;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /**
 | 
					  /**
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -802,8 +802,8 @@ export class WhatsappDirectLine extends GBService {
 | 
				
			||||||
      image: {
 | 
					      image: {
 | 
				
			||||||
        link: imageUrl,
 | 
					        link: imageUrl,
 | 
				
			||||||
        caption: caption,
 | 
					        caption: caption,
 | 
				
			||||||
        view_once: true
 | 
					 | 
				
			||||||
      },
 | 
					      },
 | 
				
			||||||
 | 
					      view_once: true
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const response = await fetch(sendMessageEndpoint, {
 | 
					    const response = await fetch(sendMessageEndpoint, {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue