From 070914e2fc405d2b41adcf5f633df5d9e7919d9e Mon Sep 17 00:00:00 2001 From: Arthur de Moulins Date: Wed, 11 Dec 2024 16:06:04 +0100 Subject: [PATCH] WIP --- novu/bridge/app/api/trigger/route.ts | 24 ------------------- novu/bridge/app/novu/emails/CTAEmail.tsx | 7 ++++-- novu/bridge/app/novu/emails/DefaultEmail.tsx | 10 ++++---- novu/bridge/app/novu/workflows/index.ts | 2 +- .../app/novu/workflows/uploader/index.ts | 1 + .../Handler/AssetConsumerNotifyHandler.php | 10 -------- 6 files changed, 12 insertions(+), 42 deletions(-) delete mode 100644 novu/bridge/app/api/trigger/route.ts create mode 100644 novu/bridge/app/novu/workflows/uploader/index.ts diff --git a/novu/bridge/app/api/trigger/route.ts b/novu/bridge/app/api/trigger/route.ts deleted file mode 100644 index 0459ac751..000000000 --- a/novu/bridge/app/api/trigger/route.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { NextResponse } from "next/server"; -import { welcomeOnboardingEmail } from "../../novu/workflows"; - -export async function POST() { - try { - await welcomeOnboardingEmail.trigger({ - to: process.env.NEXT_PUBLIC_NOVU_SUBSCRIBER_ID || "", - payload: {}, - }); - - return NextResponse.json({ - message: "Notification triggered successfully", - }); - } catch (error: unknown) { - const errorMessage = - error instanceof Error ? error.message : "Unknown error occurred"; - console.error("Error triggering notification:", errorMessage); - - return NextResponse.json( - { message: "Error triggering notification", error: errorMessage }, - { status: 500 }, - ); - } -} diff --git a/novu/bridge/app/novu/emails/CTAEmail.tsx b/novu/bridge/app/novu/emails/CTAEmail.tsx index 8616e34be..0f07e20c9 100644 --- a/novu/bridge/app/novu/emails/CTAEmail.tsx +++ b/novu/bridge/app/novu/emails/CTAEmail.tsx @@ -53,8 +53,11 @@ export function createCTAEmailControlSchema({ }: CreateCTAEEmailControlSchemaProps) { return createEmailControlSchema({ ...rest, - introText: createOptionalOrNotString(defaultIntroText), - outroText: createOptionalOrNotString(defaultOutroText), + shape: { + ...(rest.shape ?? {}), + introText: createOptionalOrNotString(defaultIntroText), + outroText: createOptionalOrNotString(defaultOutroText), + } }); } diff --git a/novu/bridge/app/novu/emails/DefaultEmail.tsx b/novu/bridge/app/novu/emails/DefaultEmail.tsx index 1b2727af0..39db6db86 100644 --- a/novu/bridge/app/novu/emails/DefaultEmail.tsx +++ b/novu/bridge/app/novu/emails/DefaultEmail.tsx @@ -1,7 +1,6 @@ import {Body, Container, Head, Html, Preview} from "@react-email/components"; import React, {CSSProperties, PropsWithChildren} from "react"; -import {z} from "zod"; -import {ZodRawShape} from "zod/lib/types"; +import {z, ZodRawShape} from "zod"; type Props = PropsWithChildren<{}>; @@ -67,14 +66,15 @@ export const styles: Record = { export type CreateEmailControlSchemaProps = { defaultEmailSubject: string; -} & ZodRawShape; + shape?: ZodRawShape; +}; export function createEmailControlSchema({ defaultEmailSubject, - ...rest + shape, }: CreateEmailControlSchemaProps) { return z.object({ emailSubject: z.string().default(defaultEmailSubject), - ...rest, + ...(shape ?? {}), }); } diff --git a/novu/bridge/app/novu/workflows/index.ts b/novu/bridge/app/novu/workflows/index.ts index f39dabcb0..babfe024d 100644 --- a/novu/bridge/app/novu/workflows/index.ts +++ b/novu/bridge/app/novu/workflows/index.ts @@ -1,2 +1,2 @@ -export * from "./uploader/commit-acknowledged"; +export * from "./uploader"; export * from "./expose"; diff --git a/novu/bridge/app/novu/workflows/uploader/index.ts b/novu/bridge/app/novu/workflows/uploader/index.ts new file mode 100644 index 000000000..978ae851d --- /dev/null +++ b/novu/bridge/app/novu/workflows/uploader/index.ts @@ -0,0 +1 @@ +export * from "./commit-acknowledged"; diff --git a/uploader/api/src/Consumer/Handler/AssetConsumerNotifyHandler.php b/uploader/api/src/Consumer/Handler/AssetConsumerNotifyHandler.php index cb98c5095..7ebc32611 100644 --- a/uploader/api/src/Consumer/Handler/AssetConsumerNotifyHandler.php +++ b/uploader/api/src/Consumer/Handler/AssetConsumerNotifyHandler.php @@ -5,7 +5,6 @@ namespace App\Consumer\Handler; use Alchemy\CoreBundle\Util\DoctrineUtil; -use Alchemy\NotifyBundle\Notification\NotifierInterface; use App\Entity\Asset; use App\Entity\Commit; use Doctrine\ORM\EntityManagerInterface; @@ -18,7 +17,6 @@ public function __construct( private HttpClientInterface $client, private EntityManagerInterface $em, - private NotifierInterface $notifier, private string $uploaderUrl, ) { } @@ -30,14 +28,6 @@ public function __invoke(AssetConsumerNotify $message): void $target = $commit->getTarget(); $accessToken = $target->getTargetAccessToken(); - $this->notifier->notifyUser( - $commit->getUserId(), - 'uploader-commit-acknowledged', - [ - 'assetCount' => $commit->getAssets()->count(), - ] - ); - if (empty($target->getTargetUrl()) || 'avoid' === $accessToken) { return; }