From 77423279c87e83852670cc6fed80131d74e1d1fb Mon Sep 17 00:00:00 2001 From: Reagan Charana Date: Thu, 25 Apr 2024 17:00:09 +0300 Subject: [PATCH 01/42] :bug: fix name of undefined --- .../services/data-services/variables.service.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/libs/functions/bot-engine/main/src/lib/services/data-services/variables.service.ts b/libs/functions/bot-engine/main/src/lib/services/data-services/variables.service.ts index 817e993759..6309de2a26 100644 --- a/libs/functions/bot-engine/main/src/lib/services/data-services/variables.service.ts +++ b/libs/functions/bot-engine/main/src/lib/services/data-services/variables.service.ts @@ -30,11 +30,15 @@ export class VariablesDataService extends BotDataService{ public getAllVariables(endUser: EndUser) { // Get channel details and include them in variables - const channelDetails = { - channelName: this._commChannel.name, - botPhoneNumber: this._commChannel['phoneNumber'] || null, - platform: this._commChannel.type - } + let channelDetails; + + if(this._commChannel) { + channelDetails = { + channelName: this._commChannel.name, + botPhoneNumber: this._commChannel['phoneNumber'] || null, + platform: this._commChannel.type + } + } return { ...endUser, @@ -50,6 +54,8 @@ export class VariablesDataService extends BotDataService{ const allVariables = this.getAllVariables(endUser); + if(!allVariables) return ''; + return allVariables[variable]; } } From 047960e96c4cd945cb8e650a800d0f7fd5522228 Mon Sep 17 00:00:00 2001 From: Reagan Charana Date: Mon, 29 Apr 2024 15:46:13 +0300 Subject: [PATCH 02/42] :lipstick: replace editor background image with css gradient --- .../lib/components/editor-frame/editor-frame.component.scss | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/features/convs-mgr/stories/editor/src/lib/components/editor-frame/editor-frame.component.scss b/libs/features/convs-mgr/stories/editor/src/lib/components/editor-frame/editor-frame.component.scss index 36b4d7b9ab..6af802f24e 100644 --- a/libs/features/convs-mgr/stories/editor/src/lib/components/editor-frame/editor-frame.component.scss +++ b/libs/features/convs-mgr/stories/editor/src/lib/components/editor-frame/editor-frame.component.scss @@ -18,8 +18,8 @@ min-width: 5000px; min-height: 3750px; - background-image: url(^/assets/bg/dot-bg.jpg); - background-repeat: repeat; + background-image: radial-gradient(circle at 1px 1px, #DADADA 1px, #F6F6F6 0); + background-size: 24px 24px; -webkit-box-shadow: 0px 0px 5px 0px #888; box-shadow: 0px 0px 5px 0px #888; From e9f09068fd47f5c17b4cd19f972ac5447730adb8 Mon Sep 17 00:00:00 2001 From: Reagan Charana Date: Mon, 29 Apr 2024 16:29:21 +0300 Subject: [PATCH 03/42] :lipstick: match intercom size with zoom btns --- apps/conv-learning-manager/src/styles.scss | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/apps/conv-learning-manager/src/styles.scss b/apps/conv-learning-manager/src/styles.scss index bf5b667f40..2575dcbfb2 100644 --- a/apps/conv-learning-manager/src/styles.scss +++ b/apps/conv-learning-manager/src/styles.scss @@ -15,6 +15,12 @@ body { height: 100%; } +// Intercom icon +.intercom-lightweight-app-launcher, .intercom-lightweight-app-launcher-icon { + width: 3.2rem !important; + height: 3.2rem !important; +} + //Block Connectors //endpoint .block_endpoint circle { From 51088a1cd680ecca7051ee78e63ec35fedfaf034 Mon Sep 17 00:00:00 2001 From: Reagan Charana Date: Mon, 29 Apr 2024 16:29:39 +0300 Subject: [PATCH 04/42] :lipstick: move zoom btns to bottom right --- .../pages/story-editor/story-editor.page.html | 12 ++-- .../pages/story-editor/story-editor.page.scss | 59 +++++++++++++++++-- 2 files changed, 58 insertions(+), 13 deletions(-) diff --git a/libs/features/convs-mgr/stories/editor/src/lib/pages/story-editor/story-editor.page.html b/libs/features/convs-mgr/stories/editor/src/lib/pages/story-editor/story-editor.page.html index 8d85dd58fd..ca71be4285 100644 --- a/libs/features/convs-mgr/stories/editor/src/lib/pages/story-editor/story-editor.page.html +++ b/libs/features/convs-mgr/stories/editor/src/lib/pages/story-editor/story-editor.page.html @@ -37,15 +37,13 @@ -
- - - -
diff --git a/libs/features/convs-mgr/stories/editor/src/lib/pages/story-editor/story-editor.page.scss b/libs/features/convs-mgr/stories/editor/src/lib/pages/story-editor/story-editor.page.scss index 2e2fdb423d..5b1b3af7a7 100644 --- a/libs/features/convs-mgr/stories/editor/src/lib/pages/story-editor/story-editor.page.scss +++ b/libs/features/convs-mgr/stories/editor/src/lib/pages/story-editor/story-editor.page.scss @@ -65,16 +65,18 @@ mat-sidenav { .sub-bar { width: auto; padding: 10px; - background-color: white; - border-bottom: solid #eee 1px; - // box-shadow: 0px 4px 8px slategrey; + background-color: #F6F6F6; } .subbar-btn { - background-color: #ffab2d !important; + background-color: #00112B !important; + border-radius: 2rem; + font-weight: 400; color: white !important; - font-weight: 600; min-width: 100px; + width: 7rem; + height: 3rem; + } @@ -96,8 +98,53 @@ mat-sidenav { .zoom-btn { background-color: white; color: black; + width: 3.2rem; + height: 3.2rem; +} + +.zoom-btn:disabled { + color: grey; +} + +.zoom-section { + display: flex; + flex-direction: column; + gap: 0.9rem; + + position: fixed; + z-index: 2147483003; + padding: 0 !important; + margin: 0 !important; + border: none; + bottom: 150px; + right: 20px; + max-width: 48px; + width: 48px; + max-height: 48px; + height: 48px; + cursor: pointer; } +// .zoom-btn.in { +// position: fixed; +// z-index: 2147483003; +// padding: 0 !important; +// margin: 0 !important; +// border: none; +// bottom: 80px; +// right: 20px; +// max-width: 48px; +// width: 48px; +// max-height: 48px; +// height: 48px; +// border-radius: 50%; +// background: #fff; +// cursor: pointer; +// box-shadow: 0 1px 6px 0 rgba(0, 0, 0, 0.06), 0 2px 32px 0 rgba(0, 0, 0, 0.16); +// transition: transform 167ms cubic-bezier(0.33, 0.00, 0.00, 1.00); +// box-sizing: content-box; +// } + .wrapper-edit { display: flex; flex-direction: column; @@ -134,7 +181,7 @@ convl-story-editor-frame { .error-count{ color: #707070; - background-color: white; + background-color: #F6F6F6; padding-right: 17em; /* Reg 14 */ font-family: Roboto; From d1f3b6e97f78a0b0b03a10cc348d0c1c6a0067d6 Mon Sep 17 00:00:00 2001 From: Lemmy Date: Mon, 29 Apr 2024 16:33:32 +0300 Subject: [PATCH 05/42] feat: add whatsapp upload media handler --- .../whatsapp-upload-media-cron.function.ts | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 libs/functions/bot-engine/whatsapp/src/lib/whatsapp-upload-media-cron.function.ts diff --git a/libs/functions/bot-engine/whatsapp/src/lib/whatsapp-upload-media-cron.function.ts b/libs/functions/bot-engine/whatsapp/src/lib/whatsapp-upload-media-cron.function.ts new file mode 100644 index 0000000000..e9ce594deb --- /dev/null +++ b/libs/functions/bot-engine/whatsapp/src/lib/whatsapp-upload-media-cron.function.ts @@ -0,0 +1,73 @@ +import { CloudSchedulerClient } from '@google-cloud/scheduler'; + +import { HandlerTools } from '@iote/cqrs'; +import { FunctionHandler, HttpsContext } from '@ngfi/functions'; + +import { Bot } from '@app/model/convs-mgr/bots'; +import { HttpMethodTypes } from '@app/model/convs-mgr/stories/blocks/main'; + +/** Handler responsible for managing and creating whatspp app media update cron job when a bot is published */ +export class WhatsappUploadMediaCronHandler extends FunctionHandler { + private cloudSchedulerClient: CloudSchedulerClient; + private projectId: string; + private locationId = 'europe-west1'; + + constructor(projectId:string = process.env.GCLOUD_PROJECT) { + super(); + this.projectId = projectId; + this.cloudSchedulerClient = new CloudSchedulerClient(); + } + + public async execute(data: any, context: HttpsContext, tools: HandlerTools) { + try { + tools.Logger.log(() => `[WhatsappMediaUpdateCronHandler] - Updating whatsapp Media`); + + const endpoint = this.getEndpoint(); + const jobName = this.getJobName(data.bot as Bot); + + const [job, ...jobs] = await this.cloudSchedulerClient.getJob({ + name: jobName, + }); + + console.log({job, jobs}); + + if (job) return; + + const body = JSON.stringify(data.channel); + + const newJob = { + name: jobName, + httpTarget: { + uri: endpoint, + body: Buffer.from(body,'utf-8').toString('base64'), + httpMethod: HttpMethodTypes.POST, + headers: { 'Content-Type': 'application/json' }, + }, + schedule: '0 18 * * *', + }; + + const request = { + parent: `projects/${this.projectId}/locations/${this.locationId}`, + newJob, + }; + + const res = this.cloudSchedulerClient.createJob(request); + console.log({res}); + + } catch (error) { + tools.Logger.error(() => `[WhatsappMediaUpdateCronHandler] - Error in WhatsappMediaUpdateCronHandler: ${error.message}`); + console.error(error.message); + } + } + + private getJobName(bot: Bot): string { + const jobPath = `projects/${this.projectId}/locations/${this.locationId}/jobs/`; + const jobId = `${bot.id}`; + + return jobPath + jobId; + } + + private getEndpoint(): string { + return `https://${this.locationId}-${this.projectId}.cloudfunctions.net/channelWhatsappUploadMedia`; + } +} From f794987e66f044b06e53a03888accdea29839fab Mon Sep 17 00:00:00 2001 From: Lemmy Date: Mon, 29 Apr 2024 16:34:25 +0300 Subject: [PATCH 06/42] feat: export whatapp upload media handler --- .../whatsapp-upload-media-cron.function.ts | 24 +++++++++++++++++++ apps/conv-lm-backend/src/main.ts | 1 + .../bot-engine/whatsapp/src/index.ts | 1 + 3 files changed, 26 insertions(+) create mode 100644 apps/conv-lm-backend/src/app/bot/whatsapp-channel/whatsapp-upload-media-cron.function.ts diff --git a/apps/conv-lm-backend/src/app/bot/whatsapp-channel/whatsapp-upload-media-cron.function.ts b/apps/conv-lm-backend/src/app/bot/whatsapp-channel/whatsapp-upload-media-cron.function.ts new file mode 100644 index 0000000000..2e5a86d8c5 --- /dev/null +++ b/apps/conv-lm-backend/src/app/bot/whatsapp-channel/whatsapp-upload-media-cron.function.ts @@ -0,0 +1,24 @@ +import { RestRegistrar } from "@ngfi/functions"; + +import { WhatsappUploadMediaCronHandler } from "@app/functions/bot-engine/whatsapp"; + +import { ConvLearnFunction } from "../../../conv-learn-func.class"; + + +const handler = new WhatsappUploadMediaCronHandler(); + +/** + * @Description : When an end user sends a message to the chatbot, this function is triggered, + * handles the message and potentially responds to it + * + * It is specifically for Whatsapp @see {PlatformType}, and subscribes to the 'messages' webhook on + * the Meta Developers platform + * + * @see https://developers.facebook.com/docs/whatsapp/cloud-api/guides/set-up-webhooks + * + */ +export const channelWhatsappUploadMediaCron = new ConvLearnFunction('channelWhatsappUploadMediaCron', + new RestRegistrar(), + [], + handler) + .build(); \ No newline at end of file diff --git a/apps/conv-lm-backend/src/main.ts b/apps/conv-lm-backend/src/main.ts index c12cd7caf2..f8e9fe64d3 100644 --- a/apps/conv-lm-backend/src/main.ts +++ b/apps/conv-lm-backend/src/main.ts @@ -10,6 +10,7 @@ export * from './app/bot/whatsapp-channel/whatsapp-upload-media.function'; export * from './app/bot/whatsapp-channel/whatsapp-templates-api.function'; export * from './app/bot/whatsapp-channel/whatsapp-get-templates.function'; export * from './app/bot/whatsapp-channel/whatsapp-upload-media.function'; +export * from './app/bot/whatsapp-channel/whatsapp-upload-media-cron.function'; export * from './app/bot/main/send-outgoing-message.function'; export * from './app/bot/main/talk-to-human.function'; diff --git a/libs/functions/bot-engine/whatsapp/src/index.ts b/libs/functions/bot-engine/whatsapp/src/index.ts index 24e904da9e..86a76ef133 100644 --- a/libs/functions/bot-engine/whatsapp/src/index.ts +++ b/libs/functions/bot-engine/whatsapp/src/index.ts @@ -5,3 +5,4 @@ export * from './lib/whats-app-upload-media.handler'; export * from './lib/models/manage-templates-request.interface'; export * from './lib/whatsapp-get-templates.handler'; export * from './lib/whatsapp-manage-templates.handler'; +export * from './lib/whatsapp-upload-media-cron.function'; \ No newline at end of file From dc7f94ef6ead7b7758ec78c8639466e114648568 Mon Sep 17 00:00:00 2001 From: Reagan Charana Date: Mon, 29 Apr 2024 16:47:05 +0300 Subject: [PATCH 07/42] :lipstick: remove custom intercom icon size --- apps/conv-learning-manager/src/styles.scss | 6 ------ 1 file changed, 6 deletions(-) diff --git a/apps/conv-learning-manager/src/styles.scss b/apps/conv-learning-manager/src/styles.scss index 2575dcbfb2..bf5b667f40 100644 --- a/apps/conv-learning-manager/src/styles.scss +++ b/apps/conv-learning-manager/src/styles.scss @@ -15,12 +15,6 @@ body { height: 100%; } -// Intercom icon -.intercom-lightweight-app-launcher, .intercom-lightweight-app-launcher-icon { - width: 3.2rem !important; - height: 3.2rem !important; -} - //Block Connectors //endpoint .block_endpoint circle { From afcacf3a1af8cfda4b4f80fbb1c736a4a416450a Mon Sep 17 00:00:00 2001 From: Lemmy Date: Mon, 29 Apr 2024 17:14:09 +0300 Subject: [PATCH 08/42] feat: get projectId from firebase admin --- .../src/lib/whatsapp-upload-media-cron.function.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libs/functions/bot-engine/whatsapp/src/lib/whatsapp-upload-media-cron.function.ts b/libs/functions/bot-engine/whatsapp/src/lib/whatsapp-upload-media-cron.function.ts index e9ce594deb..f279c46cec 100644 --- a/libs/functions/bot-engine/whatsapp/src/lib/whatsapp-upload-media-cron.function.ts +++ b/libs/functions/bot-engine/whatsapp/src/lib/whatsapp-upload-media-cron.function.ts @@ -1,3 +1,4 @@ +import * as admin from 'firebase-admin'; import { CloudSchedulerClient } from '@google-cloud/scheduler'; import { HandlerTools } from '@iote/cqrs'; @@ -12,15 +13,18 @@ export class WhatsappUploadMediaCronHandler extends FunctionHandler { private projectId: string; private locationId = 'europe-west1'; - constructor(projectId:string = process.env.GCLOUD_PROJECT) { + constructor() { super(); - this.projectId = projectId; this.cloudSchedulerClient = new CloudSchedulerClient(); } public async execute(data: any, context: HttpsContext, tools: HandlerTools) { try { tools.Logger.log(() => `[WhatsappMediaUpdateCronHandler] - Updating whatsapp Media`); + + admin.initializeApp(); + + this.projectId = admin.instanceId().app.options.projectId; const endpoint = this.getEndpoint(); const jobName = this.getJobName(data.bot as Bot); From 4c271b8dc6655bc2c3029a36d647ec7ac384fd2c Mon Sep 17 00:00:00 2001 From: Lemmy Date: Mon, 29 Apr 2024 17:15:04 +0300 Subject: [PATCH 09/42] refactor: clean subscriptions --- .../bots-list-all-courses.component.ts | 17 ++++++++--------- .../bots-list-latest-courses.component.ts | 4 ++-- .../course-module-item.component.ts | 17 +++++++++++------ .../courses-list/courses-list.component.ts | 4 ++-- .../modules-list-header.component.ts | 4 ++-- .../lib/whatsapp-upload-media-cron.function.ts | 3 ++- .../src/lib/providers/file-storage.service.ts | 10 +++++----- .../services/whatsapp-upload-file.service.ts | 10 ++++++++-- 8 files changed, 40 insertions(+), 29 deletions(-) diff --git a/libs/features/convs-mgr/stories/home/src/lib/components/bots/bots-list-all-courses/bots-list-all-courses.component.ts b/libs/features/convs-mgr/stories/home/src/lib/components/bots/bots-list-all-courses/bots-list-all-courses.component.ts index 69591446dc..12dcc10696 100644 --- a/libs/features/convs-mgr/stories/home/src/lib/components/bots/bots-list-all-courses/bots-list-all-courses.component.ts +++ b/libs/features/convs-mgr/stories/home/src/lib/components/bots/bots-list-all-courses/bots-list-all-courses.component.ts @@ -144,20 +144,21 @@ export class BotsListAllCoursesComponent implements OnInit, AfterViewInit, OnDes const published$ = dialogRef.afterClosed(); - published$.pipe(tap((published)=> { - if(published) { + this._sbS.sink = published$.pipe(tap((published)=> { + if (published) { this.isPublishing = false; } - }), + }), switchMap(() => { if(bot.linkedChannel) { this.isUploading = true; - return this._fileStorageService.uploadMediaToPlatform(bot.linkedChannel); + return this._fileStorageService.uploadMediaToPlatform(bot); } else { return of(null); } })).subscribe((result)=> { - this.isUploading = false; + this.isUploading = false; + if(result.success) { this.openSnackBar('Media upload successful', 'OK'); } else { @@ -167,14 +168,13 @@ export class BotsListAllCoursesComponent implements OnInit, AfterViewInit, OnDes }) } - archiveBot(bot: Bot) - { + archiveBot(bot: Bot) { this._dialog.open(ConfirmArchiveModalComponent, { data: { bot } }); } - deleteBot(bot:Bot){ + deleteBot(bot:Bot) { this._dialog.open(ConfirmDeleteModalComponent, { data: { mode: DeleteElementsEnum.BotModule, element: bot, @@ -186,7 +186,6 @@ export class BotsListAllCoursesComponent implements OnInit, AfterViewInit, OnDes this._snackBar.open(message, action); } - ngOnDestroy() { this._sbS.unsubscribe(); } diff --git a/libs/features/convs-mgr/stories/home/src/lib/components/bots/bots-list-latest-courses/bots-list-latest-courses.component.ts b/libs/features/convs-mgr/stories/home/src/lib/components/bots/bots-list-latest-courses/bots-list-latest-courses.component.ts index ddd4f100c1..20f5221872 100644 --- a/libs/features/convs-mgr/stories/home/src/lib/components/bots/bots-list-latest-courses/bots-list-latest-courses.component.ts +++ b/libs/features/convs-mgr/stories/home/src/lib/components/bots/bots-list-latest-courses/bots-list-latest-courses.component.ts @@ -77,7 +77,7 @@ export class BotsListLatestCoursesComponent implements OnInit, OnDestroy const published$ = dialogRef.afterClosed(); - published$.pipe(tap((published)=> { + this._sBs.sink = published$.pipe(tap((published)=> { if(published) { this.isPublishing = false; } @@ -85,7 +85,7 @@ export class BotsListLatestCoursesComponent implements OnInit, OnDestroy switchMap(() => { if(bot.linkedChannel) { this.isUploading = true; - return this._fileStorageService.uploadMediaToPlatform(bot.linkedChannel); + return this._fileStorageService.uploadMediaToPlatform(bot); } else { return of(null); } diff --git a/libs/features/convs-mgr/stories/home/src/lib/components/courses/course-module-item/course-module-item.component.ts b/libs/features/convs-mgr/stories/home/src/lib/components/courses/course-module-item/course-module-item.component.ts index 8ad2bcf0c5..8d252d95eb 100644 --- a/libs/features/convs-mgr/stories/home/src/lib/components/courses/course-module-item/course-module-item.component.ts +++ b/libs/features/convs-mgr/stories/home/src/lib/components/courses/course-module-item/course-module-item.component.ts @@ -1,4 +1,4 @@ -import { Component, Input, OnInit } from '@angular/core'; +import { Component, Input, OnDestroy } from '@angular/core'; import { Router } from '@angular/router'; import { MatDialog } from '@angular/material/dialog'; @@ -23,7 +23,7 @@ import { ConnectToChannelModalComponent } from '../../../modals/connect-to-chann templateUrl: './course-module-item.component.html', styleUrls: ['./course-module-item.component.scss'], }) -export class CourseModuleItemComponent { +export class CourseModuleItemComponent implements OnDestroy { @Input() botModule: BotModule; @Input() story: Story; @@ -87,13 +87,18 @@ export class CourseModuleItemComponent { publishBot(bot:Bot){ this.isPublishing = true; bot.isPublished = true; - this._botsService$.updateBot(bot) + + this._sBs.sink = this._botsService$.updateBot(bot) .subscribe(() => { this.isPublishing = false; }); - if(this.uploadMedia && bot.linkedChannel) { - this._fileStorageService.uploadMediaToPlatform(bot.linkedChannel).subscribe() + if (this.uploadMedia && bot.linkedChannel) { + this._sBs.sink = this._fileStorageService.uploadMediaToPlatform(bot).subscribe() } - } + } + + ngOnDestroy() { + this._sBs.unsubscribe() + } } diff --git a/libs/features/convs-mgr/stories/home/src/lib/components/courses/courses-list/courses-list.component.ts b/libs/features/convs-mgr/stories/home/src/lib/components/courses/courses-list/courses-list.component.ts index 0c4248d0fe..c0975ae4c6 100644 --- a/libs/features/convs-mgr/stories/home/src/lib/components/courses/courses-list/courses-list.component.ts +++ b/libs/features/convs-mgr/stories/home/src/lib/components/courses/courses-list/courses-list.component.ts @@ -65,7 +65,7 @@ export class CoursesListComponent implements OnDestroy { const published$ = dialogRef.afterClosed(); - published$.pipe(tap((published)=> { + this._sBs.sink = published$.pipe(tap((published)=> { if(published) { this.isPublishing = false; } @@ -73,7 +73,7 @@ export class CoursesListComponent implements OnDestroy { switchMap(() => { if(bot.linkedChannel) { this.isUploading = true; - return this._fileStorageService.uploadMediaToPlatform(bot.linkedChannel); + return this._fileStorageService.uploadMediaToPlatform(bot); } else { return of(null); } diff --git a/libs/features/convs-mgr/stories/home/src/lib/components/modules/modules-list-header/modules-list-header.component.ts b/libs/features/convs-mgr/stories/home/src/lib/components/modules/modules-list-header/modules-list-header.component.ts index cdfb9f1a9b..2ba351e2fc 100644 --- a/libs/features/convs-mgr/stories/home/src/lib/components/modules/modules-list-header/modules-list-header.component.ts +++ b/libs/features/convs-mgr/stories/home/src/lib/components/modules/modules-list-header/modules-list-header.component.ts @@ -131,7 +131,7 @@ export class BotModulesListHeaderComponent implements OnInit, OnDestroy { const published$ = dialogRef.afterClosed(); - published$.pipe(tap((published)=> { + this._sBs.sink = published$.pipe(tap((published)=> { if(published) { this.isPublishing = false; } @@ -139,7 +139,7 @@ export class BotModulesListHeaderComponent implements OnInit, OnDestroy { switchMap(() => { if(bot.linkedChannel) { this.isUploading = true; - return this._fileStorageService.uploadMediaToPlatform(bot.linkedChannel); + return this._fileStorageService.uploadMediaToPlatform(bot); } else { return of(null); } diff --git a/libs/functions/bot-engine/whatsapp/src/lib/whatsapp-upload-media-cron.function.ts b/libs/functions/bot-engine/whatsapp/src/lib/whatsapp-upload-media-cron.function.ts index f279c46cec..b31880eb45 100644 --- a/libs/functions/bot-engine/whatsapp/src/lib/whatsapp-upload-media-cron.function.ts +++ b/libs/functions/bot-engine/whatsapp/src/lib/whatsapp-upload-media-cron.function.ts @@ -6,6 +6,7 @@ import { FunctionHandler, HttpsContext } from '@ngfi/functions'; import { Bot } from '@app/model/convs-mgr/bots'; import { HttpMethodTypes } from '@app/model/convs-mgr/stories/blocks/main'; +import { CommunicationChannel } from '@app/model/convs-mgr/conversations/admin/system'; /** Handler responsible for managing and creating whatspp app media update cron job when a bot is published */ export class WhatsappUploadMediaCronHandler extends FunctionHandler { @@ -18,7 +19,7 @@ export class WhatsappUploadMediaCronHandler extends FunctionHandler { this.cloudSchedulerClient = new CloudSchedulerClient(); } - public async execute(data: any, context: HttpsContext, tools: HandlerTools) { + public async execute(data: { channel: CommunicationChannel, bot: Bot }, context: HttpsContext, tools: HandlerTools) { try { tools.Logger.log(() => `[WhatsappMediaUpdateCronHandler] - Updating whatsapp Media`); diff --git a/libs/state/file/store/src/lib/providers/file-storage.service.ts b/libs/state/file/store/src/lib/providers/file-storage.service.ts index 20197e7070..f7201b9794 100644 --- a/libs/state/file/store/src/lib/providers/file-storage.service.ts +++ b/libs/state/file/store/src/lib/providers/file-storage.service.ts @@ -9,6 +9,7 @@ import { WhatsappUploadFileService } from '@app/state/file/whatsapp'; import { CommunicationChannelService } from '@app/state/convs-mgr/channels'; import { FILE_LIMITS } from '../model/platform-file-size-limits'; +import { Bot } from '@app/model/convs-mgr/bots'; @Injectable({ providedIn: 'root' @@ -64,15 +65,14 @@ export class FileStorageService } } - uploadMediaToPlatform(channelId: string) + uploadMediaToPlatform(bot: Bot) { - return this.channelService.getSpecificChannel(channelId).pipe(switchMap((channel)=> { - if(channel) { - return this._whatsappUploadFileService.uploadMedia(channel); + return this.channelService.getSpecificChannel(bot.linkedChannel as string).pipe(switchMap((channel)=> { + if (channel) { + return this._whatsappUploadFileService.uploadMedia(bot, channel); } else { return of(null); } })) } - } diff --git a/libs/state/file/whatsapp/src/lib/services/whatsapp-upload-file.service.ts b/libs/state/file/whatsapp/src/lib/services/whatsapp-upload-file.service.ts index 4762e806b2..5a8ebafccb 100644 --- a/libs/state/file/whatsapp/src/lib/services/whatsapp-upload-file.service.ts +++ b/libs/state/file/whatsapp/src/lib/services/whatsapp-upload-file.service.ts @@ -1,6 +1,7 @@ import { Injectable } from "@angular/core"; import { AngularFireFunctions } from '@angular/fire/compat/functions'; +import { Bot } from "@app/model/convs-mgr/bots"; import { WhatsAppCommunicationChannel } from "@app/model/convs-mgr/conversations/admin/system"; @Injectable({ @@ -11,8 +12,13 @@ export class WhatsappUploadFileService { constructor(private _aFF: AngularFireFunctions) { } - uploadMedia(channel: WhatsAppCommunicationChannel) + uploadMedia(bot:Bot, channel: WhatsAppCommunicationChannel) { - return this._aFF.httpsCallable('channelWhatsappUploadMedia')(channel) + const payload = { + channel, + bot, + } + + return this._aFF.httpsCallable('channelWhatsappUploadMediaCron')(payload) } } \ No newline at end of file From 1ca61a87697bbbbb42473fe31308fb652155c94d Mon Sep 17 00:00:00 2001 From: Reagan Charana Date: Mon, 29 Apr 2024 17:18:47 +0300 Subject: [PATCH 10/42] :lipstick: add close icon to blocks library --- .../blocks-library/blocks-library.component.html | 5 +++++ .../blocks-library/blocks-library.component.scss | 16 ++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/libs/features/convs-mgr/stories/editor/src/lib/components/blocks-library/blocks-library.component.html b/libs/features/convs-mgr/stories/editor/src/lib/components/blocks-library/blocks-library.component.html index 4194b0fa69..fbc985149c 100644 --- a/libs/features/convs-mgr/stories/editor/src/lib/components/blocks-library/blocks-library.component.html +++ b/libs/features/convs-mgr/stories/editor/src/lib/components/blocks-library/blocks-library.component.html @@ -1,4 +1,9 @@