From 75bf1a0b0d35384cf5658e79fc855bf2c0954d62 Mon Sep 17 00:00:00 2001 From: Dries Augustyns Date: Tue, 20 Aug 2024 13:29:53 +0200 Subject: [PATCH 1/6] Update README.md --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ab791da..3a2b70f 100644 --- a/README.md +++ b/README.md @@ -8,8 +8,10 @@

- + + +

## Introduction @@ -39,4 +41,4 @@ You are welcome to contribute to Plunk. You can find a guide on how to contribut - \ No newline at end of file + From de51eb94d28baf8d9ba03ca2bf3a2edf1b9cdc86 Mon Sep 17 00:00:00 2001 From: Dries Augustyns Date: Sat, 7 Sep 2024 12:34:07 +0200 Subject: [PATCH 2/6] Added proper handling for pasted links in Plunk editor --- package.json | 74 +++++++++---------- .../Input/MarkdownEditor/Editor.tsx | 16 ++++ 2 files changed, 52 insertions(+), 38 deletions(-) diff --git a/package.json b/package.json index 1e60e5e..c539f87 100644 --- a/package.json +++ b/package.json @@ -1,40 +1,38 @@ { - "name": "plunk", - "version": "1.0.3", - "private": true, - "license": "agpl-3.0", - "workspaces": { - "packages": [ - "packages/*" - ] - }, - "engines": { - "npm": ">=6.14.x", - "yarn": "1.22.x", - "node": ">=18.x" - }, - "devDependencies": { - "@biomejs/biome": "^1.8.3", - "lerna": "^8.1.6", - "prisma": "^5.17.0", - "rimraf": "^5.0.9" - }, - "dependencies": { - "@prisma/client": "^5.17.0" - }, - "scripts": { - "dev:api": "yarn workspace @plunk/api dev", - "dev:dashboard": "yarn workspace @plunk/dashboard dev", - "dev:shared": "yarn workspace @plunk/shared dev", - "build:api": "yarn build:shared && yarn workspace @plunk/api build", - "build:dashboard": "yarn build:shared && yarn workspace @plunk/dashboard build", - "build:shared": "yarn generate && yarn workspace @plunk/shared build", - "clean": "rimraf node_modules yarn.lock && yarn add lerna -DW && lerna run clean", - "preinstall": "node tools/preinstall.js", - "migrate": "prisma migrate dev", - "migrate:deploy": "prisma migrate deploy", - "generate": "prisma generate", - "services:up": "docker compose -f docker-compose.dev.yml up -d", - "services:down": "docker compose -f docker-compose.dev.yml down" - } + "name": "plunk", + "version": "1.0.4", + "private": true, + "license": "agpl-3.0", + "workspaces": { + "packages": ["packages/*"] + }, + "engines": { + "npm": ">=6.14.x", + "yarn": "1.22.x", + "node": ">=18.x" + }, + "devDependencies": { + "@biomejs/biome": "^1.8.3", + "lerna": "^8.1.6", + "prisma": "^5.17.0", + "rimraf": "^5.0.9" + }, + "dependencies": { + "@prisma/client": "^5.17.0" + }, + "scripts": { + "dev:api": "yarn workspace @plunk/api dev", + "dev:dashboard": "yarn workspace @plunk/dashboard dev", + "dev:shared": "yarn workspace @plunk/shared dev", + "build:api": "yarn build:shared && yarn workspace @plunk/api build", + "build:dashboard": "yarn build:shared && yarn workspace @plunk/dashboard build", + "build:shared": "yarn generate && yarn workspace @plunk/shared build", + "clean": "rimraf node_modules yarn.lock && yarn add lerna -DW && lerna run clean", + "preinstall": "node tools/preinstall.js", + "migrate": "prisma migrate dev", + "migrate:deploy": "prisma migrate deploy", + "generate": "prisma generate", + "services:up": "docker compose -f docker-compose.dev.yml up -d", + "services:down": "docker compose -f docker-compose.dev.yml down" + } } diff --git a/packages/dashboard/src/components/Input/MarkdownEditor/Editor.tsx b/packages/dashboard/src/components/Input/MarkdownEditor/Editor.tsx index d9ecfd6..c7fdad0 100644 --- a/packages/dashboard/src/components/Input/MarkdownEditor/Editor.tsx +++ b/packages/dashboard/src/components/Input/MarkdownEditor/Editor.tsx @@ -108,6 +108,22 @@ export default function Editor({ value, onChange, mode, modeSwitcher }: Markdown keydown: (_view, event) => { return event.key === "Enter" && !event.shiftKey; }, + paste: (view, event) => { + const text = event.clipboardData?.getData("text"); + const urlPattern = /^(https?:\/\/)?([\w-]+\.)+[\w-]+(\/[\w- ./?%&=]*({{[\w-]+}})?)*$/; + + if (editor && text && urlPattern.test(text)) { + event.preventDefault(); + editor + .chain() + .focus() + .extendMarkRange("link") + .setLink({ href: text.startsWith("http") ? text : `https://${text}`, target: "_blank" }) + .run(); + editor.commands.insertContent(text); + } + return true; + }, }, }, onUpdate: ({ editor }) => { From 3f70be95dde80c04611089f66b1fcaa8eb30655e Mon Sep 17 00:00:00 2001 From: Nik Lampe Date: Mon, 9 Sep 2024 08:57:26 +0200 Subject: [PATCH 3/6] fix: refetch contact after awaiting triggers --- packages/api/src/services/ActionService.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/api/src/services/ActionService.ts b/packages/api/src/services/ActionService.ts index 26a88fa..fe485c6 100644 --- a/packages/api/src/services/ActionService.ts +++ b/packages/api/src/services/ActionService.ts @@ -71,6 +71,13 @@ export class ActionService { const triggers = await ContactService.triggers(contact.id); + // Refetch the contact, as it may have subscribed now + contact = await prisma.contact.findUniqueOrThrow({ + where: { + id: contact.id, + }, + }); + for (const action of actions) { const hasTriggeredAction = !!triggers.find((t) => t.actionId === action.id); From 7c8d3bb050fb0c35e0296eeb71d516f0c37329a2 Mon Sep 17 00:00:00 2001 From: Nik Lampe Date: Mon, 9 Sep 2024 16:44:58 +0200 Subject: [PATCH 4/6] fix: move updating the contact to contacts controller --- packages/api/src/controllers/v1/Contacts.ts | 8 ++++---- packages/api/src/services/ActionService.ts | 7 ------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/packages/api/src/controllers/v1/Contacts.ts b/packages/api/src/controllers/v1/Contacts.ts index 76a124a..7389975 100644 --- a/packages/api/src/controllers/v1/Contacts.ts +++ b/packages/api/src/controllers/v1/Contacts.ts @@ -103,13 +103,13 @@ export class Contacts { const { id, email } = ContactSchemas.manage.parse(req.body); - const contact = id ? await ContactService.id(id) : await ContactService.email(project.id, email as string); + let contact = id ? await ContactService.id(id) : await ContactService.email(project.id, email as string); if (!contact || contact.projectId !== project.id) { throw new NotFound("contact"); } - await prisma.contact.update({ + contact = await prisma.contact.update({ where: { id: contact.id }, data: { subscribed: false }, }); @@ -154,13 +154,13 @@ export class Contacts { const { id, email } = ContactSchemas.manage.parse(req.body); - const contact = id ? await ContactService.id(id) : await ContactService.email(project.id, email as string); + let contact = id ? await ContactService.id(id) : await ContactService.email(project.id, email as string); if (!contact || contact.projectId !== project.id) { throw new NotFound("contact"); } - await prisma.contact.update({ + contact = await prisma.contact.update({ where: { id: contact.id }, data: { subscribed: true }, }); diff --git a/packages/api/src/services/ActionService.ts b/packages/api/src/services/ActionService.ts index fe485c6..26a88fa 100644 --- a/packages/api/src/services/ActionService.ts +++ b/packages/api/src/services/ActionService.ts @@ -71,13 +71,6 @@ export class ActionService { const triggers = await ContactService.triggers(contact.id); - // Refetch the contact, as it may have subscribed now - contact = await prisma.contact.findUniqueOrThrow({ - where: { - id: contact.id, - }, - }); - for (const action of actions) { const hasTriggeredAction = !!triggers.find((t) => t.actionId === action.id); From 29590f359a99bf80c6a57b25a946ed5c0bde58e8 Mon Sep 17 00:00:00 2001 From: Nik Lampe Date: Tue, 10 Sep 2024 11:33:12 +0200 Subject: [PATCH 5/6] chore: bump dependency --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c539f87..d3bc611 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "plunk", - "version": "1.0.4", + "version": "1.0.5", "private": true, "license": "agpl-3.0", "workspaces": { From 0ef39ce3d2ad90be8e83ab97d5076f90642f3cc6 Mon Sep 17 00:00:00 2001 From: Dries Augustyns Date: Fri, 13 Sep 2024 15:17:24 +0200 Subject: [PATCH 6/6] Fix: clear Redis key on event deletion --- packages/api/src/controllers/v1/Events.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/api/src/controllers/v1/Events.ts b/packages/api/src/controllers/v1/Events.ts index d10c97d..9cf699f 100644 --- a/packages/api/src/controllers/v1/Events.ts +++ b/packages/api/src/controllers/v1/Events.ts @@ -33,6 +33,7 @@ export class Events { await prisma.event.delete({ where: { id } }); await redis.del(Keys.Event.id(id)); + await redis.del(Keys.Event.event(project.id, event.name)); return res.status(200).json(event); }