From 354b01ca1aa43d51bf4150577d279d3f4d957087 Mon Sep 17 00:00:00 2001 From: vhcsilva Date: Wed, 21 Aug 2024 09:06:01 -0300 Subject: [PATCH 1/6] adjust notifications content --- .../notifications/templates/notif-deliverable-created.hbs | 4 ++-- .../notifications/templates/notif-deliverable-ready.hbs | 4 ++-- .../notifications/templates/notif-proposal-disputed.hbs | 4 ++-- .../notifications/templates/notif-proposal-open.hbs | 4 ++-- .../notifications/templates/notif-task-closed.hbs | 4 ++-- .../notifications/templates/notif-task-created.hbs | 4 ++-- .../notifications/templates/notif-task-funding-created.hbs | 4 ++-- src/integrations/notifications/templates/notif-template.hbs | 6 +++--- 8 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/integrations/notifications/templates/notif-deliverable-created.hbs b/src/integrations/notifications/templates/notif-deliverable-created.hbs index 3ad4e5cd..750b5f8a 100644 --- a/src/integrations/notifications/templates/notif-deliverable-created.hbs +++ b/src/integrations/notifications/templates/notif-deliverable-created.hbs @@ -5,12 +5,12 @@ Deliverable #{{deliverable.id}} created for task #{{task.id}} {{#if task.title}} - + {{task.title}} {{/if}}
- {{task.network}} + {{task.network}} %DATE%
diff --git a/src/integrations/notifications/templates/notif-deliverable-ready.hbs b/src/integrations/notifications/templates/notif-deliverable-ready.hbs index 516c1937..b8c2fa94 100644 --- a/src/integrations/notifications/templates/notif-deliverable-ready.hbs +++ b/src/integrations/notifications/templates/notif-deliverable-ready.hbs @@ -5,12 +5,12 @@ Deliverable #{{deliverable.id}} marked as ready for review
{{#if deliverable.title}} - + {{deliverable.title}} {{/if}}
- {{task.network}} + {{task.network}} %DATE%
diff --git a/src/integrations/notifications/templates/notif-proposal-disputed.hbs b/src/integrations/notifications/templates/notif-proposal-disputed.hbs index e768914b..20439624 100644 --- a/src/integrations/notifications/templates/notif-proposal-disputed.hbs +++ b/src/integrations/notifications/templates/notif-proposal-disputed.hbs @@ -5,12 +5,12 @@ Proposal #{{proposal.id}} was disputed with {{proposal.disputes}} votes
{{#if deliverable.title}} - + {{deliverable.title}} {{/if}}
- {{task.network}} + {{task.network}} %DATE%
diff --git a/src/integrations/notifications/templates/notif-proposal-open.hbs b/src/integrations/notifications/templates/notif-proposal-open.hbs index 8fba3e73..b0e7825a 100644 --- a/src/integrations/notifications/templates/notif-proposal-open.hbs +++ b/src/integrations/notifications/templates/notif-proposal-open.hbs @@ -5,12 +5,12 @@ Proposal #{{proposal.id}} created for deliverable #{{deliverable.id}}
{{#if deliverable.title}} - + {{deliverable.title}} {{/if}}
- {{task.network}} + {{task.network}} %DATE%
diff --git a/src/integrations/notifications/templates/notif-task-closed.hbs b/src/integrations/notifications/templates/notif-task-closed.hbs index af55076f..d5a856b2 100644 --- a/src/integrations/notifications/templates/notif-task-closed.hbs +++ b/src/integrations/notifications/templates/notif-task-closed.hbs @@ -5,12 +5,12 @@ Task #{{task.id}} closed
{{#if task.title}} - + {{task.title}} {{/if}}
- {{task.network}} + {{task.network}} %DATE%
diff --git a/src/integrations/notifications/templates/notif-task-created.hbs b/src/integrations/notifications/templates/notif-task-created.hbs index fa854fb9..7be6907b 100644 --- a/src/integrations/notifications/templates/notif-task-created.hbs +++ b/src/integrations/notifications/templates/notif-task-created.hbs @@ -5,12 +5,12 @@ Task #{{task.id}} created
{{#if task.title}} - + {{task.title}} {{/if}}
- {{task.network}} + {{task.network}} %DATE%
diff --git a/src/integrations/notifications/templates/notif-task-funding-created.hbs b/src/integrations/notifications/templates/notif-task-funding-created.hbs index 0033ab06..2df64813 100644 --- a/src/integrations/notifications/templates/notif-task-funding-created.hbs +++ b/src/integrations/notifications/templates/notif-task-funding-created.hbs @@ -5,12 +5,12 @@ Funding #{{task.id}} created
{{#if task.title}} - + {{task.title}} {{/if}}
- {{task.network}} + {{task.network}} %DATE%
diff --git a/src/integrations/notifications/templates/notif-template.hbs b/src/integrations/notifications/templates/notif-template.hbs index 9adb59f0..0727b22b 100644 --- a/src/integrations/notifications/templates/notif-template.hbs +++ b/src/integrations/notifications/templates/notif-template.hbs @@ -1,16 +1,16 @@ {{> avatar}}
- + {{notification.title}} {{#if notification.subTitle}} - + {{notification.subTitle}} {{/if}}
- {{notification.network}} + {{notification.network}} %DATE%
From 21111f05da52b536c5a16d4408e60854153d377d Mon Sep 17 00:00:00 2001 From: Vitor Hugo Date: Fri, 23 Aug 2024 12:17:06 -0300 Subject: [PATCH 2/6] Bepro 2251 add title of task and add deliverable proposal type to email (#237) * add task title to emails * refactor email subject and body get --- src/actions/get-proposal-created-event.ts | 3 +- .../get-pullrequest-ready-for-review.ts | 1 + .../notifications/email-notification.ts | 5 +- .../send-grid/notifications/templater.ts | 7 ++- .../notifications/templates/email-info.ts | 51 ++++++++++++++++--- src/services/templating/email-template.ts | 10 ++-- 6 files changed, 55 insertions(+), 22 deletions(-) diff --git a/src/actions/get-proposal-created-event.ts b/src/actions/get-proposal-created-event.ts index 398c5e25..32f8bd0d 100644 --- a/src/actions/get-proposal-created-event.ts +++ b/src/actions/get-proposal-created-event.ts @@ -105,7 +105,8 @@ export async function action(block: DecodedLog e).entries()) { const uuid = uuidv4(); await EmailService.sendEmail( - format(EmailNotificationSubjects[this.type]!, (this.payload as any)?.network?.name ?? "BEPRO"), + getEmailNotificationSubject(this.type, this.payload), [to], new EmailTemplate().compile({...this.payload, type: this.type, template: templateName, uuid}) ); diff --git a/src/integrations/send-grid/notifications/templater.ts b/src/integrations/send-grid/notifications/templater.ts index a0fbb57c..41d51e8d 100644 --- a/src/integrations/send-grid/notifications/templater.ts +++ b/src/integrations/send-grid/notifications/templater.ts @@ -1,8 +1,7 @@ import {readFileSync} from "node:fs"; import {join, resolve} from "node:path"; import process from "process"; -import {EmailNotificationSubjects} from "./templates/email-info"; -import {format} from "node:util"; +import {getEmailNotificationBodyTitle, getEmailNotificationSubject} from "./templates/email-info"; export class Templater { @@ -22,8 +21,8 @@ export class Templater { compile(payload: any) { const templateData = { - pageTitle: format(EmailNotificationSubjects[payload.template], payload.network.name), - notificationTitleHeading: format(EmailNotificationSubjects[payload.template], payload.network.name), + pageTitle: getEmailNotificationSubject(payload.type, payload), + notificationTitleHeading: getEmailNotificationBodyTitle(payload.type, payload), taskTitleParagraph: payload.title, actionHref: `https://app.bepro.network/${payload.network.name}/task/${payload.bountyId}/?fromEmail=${payload.uuid}` }; diff --git a/src/integrations/send-grid/notifications/templates/email-info.ts b/src/integrations/send-grid/notifications/templates/email-info.ts index 3949f0a1..26427fcf 100644 --- a/src/integrations/send-grid/notifications/templates/email-info.ts +++ b/src/integrations/send-grid/notifications/templates/email-info.ts @@ -1,11 +1,48 @@ -import {Templates} from "./index"; +import { format } from "node:util"; +import { CollectEventPayloadParams } from "src/services/analytics/types/analytics"; +import { AnalyticEventName } from "src/services/analytics/types/events"; +import { Templates } from "./index"; export const EmailNotificationSubjects: { [k in keyof typeof Templates]: string } = { + BOUNTY_CREATED: "%s @ BEPRO | A task has been created!", + BOUNTY_CLOSED: "%s @ BEPRO | A task has been closed!", + FUNDING_REQUEST_CREATED: "%s @ BEPRO | A funding request has been created!", + PULL_REQUEST_OPEN: `%s @ BEPRO | A new deliverable has been created on "%s"!`, + PULL_REQUEST_READY: `%s @ BEPRO | A deliverable has been marked as ready for review on "%s"!`, + MERGE_PROPOSAL_OPEN: `%s @ BEPRO | A new proposal was created on "%s"!`, + MERGE_PROPOSAL_READY: `%s @ BEPRO | A deliverable is ready to be accepted on "%s"!`, +} + +export const EmailNotificationBodyTitles: { [k in keyof typeof Templates]: string } = { BOUNTY_CREATED: "A task has been created on %s!", - BOUNTY_CLOSED: "A task has bee closed!", - FUNDING_REQUEST_CREATED: "New funding request has been created on %s!", - PULL_REQUEST_OPEN: "A new deliverable has been created!", - PULL_REQUEST_READY: "A deliverable has been marked as \"ready for review\"!", - MERGE_PROPOSAL_OPEN: "A new proposal was created!", - MERGE_PROPOSAL_READY: "A deliverable is ready to be accepted!", + BOUNTY_CLOSED: "A task has been closed on %s!", + FUNDING_REQUEST_CREATED: "A funding request has been created on %s!", + PULL_REQUEST_OPEN: `A new deliverable has been created on "%s"!`, + PULL_REQUEST_READY: `A deliverable has been marked as ready for review on "%s"!`, + MERGE_PROPOSAL_OPEN: `A new proposal was created on "%s"!`, + MERGE_PROPOSAL_READY: `A deliverable is ready to be accepted on "%s"!`, +} + +export function getEmailNotificationSubject(type: AnalyticEventName, payload: CollectEventPayloadParams) { + const marketplace = payload.network.name?.toUpperCase(); + switch(type) { + case "BOUNTY_CREATED": + case "BOUNTY_CLOSED": + case "FUNDING_REQUEST_CREATED": + return format(EmailNotificationSubjects[type], marketplace); + default: + return format(EmailNotificationSubjects[type], marketplace, payload.title); + } +} + +export function getEmailNotificationBodyTitle(type: AnalyticEventName, payload: CollectEventPayloadParams) { + const marketplace = payload.network.name?.toUpperCase(); + switch(type) { + case "BOUNTY_CREATED": + case "BOUNTY_CLOSED": + case "FUNDING_REQUEST_CREATED": + return format(EmailNotificationBodyTitles[type], marketplace); + default: + return format(EmailNotificationBodyTitles[type], payload.title); + } } \ No newline at end of file diff --git a/src/services/templating/email-template.ts b/src/services/templating/email-template.ts index 12243d67..91e6abb4 100644 --- a/src/services/templating/email-template.ts +++ b/src/services/templating/email-template.ts @@ -1,5 +1,4 @@ -import {EmailNotificationSubjects} from "../../integrations/send-grid/notifications/templates/email-info"; -import {format} from "node:util"; +import {getEmailNotificationBodyTitle, getEmailNotificationSubject} from "../../integrations/send-grid/notifications/templates/email-info"; import Handlebars from "handlebars"; import {Template} from "./template"; @@ -10,12 +9,9 @@ export class EmailTemplate extends Template { } compile(payload: any) { - - const title = format(EmailNotificationSubjects[payload.type], payload?.network?.name ?? "BEPRO"); - const templateData = { - pageTitle: title, - notificationTitleHeading: title, + pageTitle: getEmailNotificationSubject(payload.type, payload), + notificationTitleHeading: getEmailNotificationBodyTitle(payload.type, payload), taskTitleParagraph: payload.title, actionHref: `https://app.bepro.network/${payload?.network?.name ?? "BEPRO"}/task/${payload.bountyId}/?fromEmail=${payload.uuid}` }; From c663673cea2be4c10dbb4eea2eef8afe9ebede55 Mon Sep 17 00:00:00 2001 From: vhcsilva Date: Fri, 16 Aug 2024 11:01:05 -0300 Subject: [PATCH 3/6] adjust email template for mobile --- .../templates/handlebars/base-template.hbs | 56 ++++++++++--------- .../templates/handlebars/partials/styles.hbs | 33 +++++++++-- 2 files changed, 58 insertions(+), 31 deletions(-) diff --git a/src/integrations/send-grid/notifications/templates/handlebars/base-template.hbs b/src/integrations/send-grid/notifications/templates/handlebars/base-template.hbs index c70f741e..9d9ee648 100644 --- a/src/integrations/send-grid/notifications/templates/handlebars/base-template.hbs +++ b/src/integrations/send-grid/notifications/templates/handlebars/base-template.hbs @@ -9,32 +9,34 @@ {{> styles}} - - - - -
- {{> logo}} -

{{notificationTitleHeading}}

- - - - -
-

{{taskTitleParagraph}}

- View task -
-
Manage your BEPRO notifications
- - - - - -
+
+ + + + +
+ {{> logo}} +

{{notificationTitleHeading}}

+ + + + +
+

{{taskTitleParagraph}}

+ View task +
+
Manage your BEPRO notifications
+ + + + + +
+
diff --git a/src/integrations/send-grid/notifications/templates/handlebars/partials/styles.hbs b/src/integrations/send-grid/notifications/templates/handlebars/partials/styles.hbs index ec05aa58..175f52e2 100644 --- a/src/integrations/send-grid/notifications/templates/handlebars/partials/styles.hbs +++ b/src/integrations/send-grid/notifications/templates/handlebars/partials/styles.hbs @@ -1,13 +1,29 @@ \ No newline at end of file From 67b393e300f1a049f08f2137ac48cabb6ddf900c Mon Sep 17 00:00:00 2001 From: vhcsilva Date: Fri, 23 Aug 2024 10:48:42 -0300 Subject: [PATCH 6/6] more adjusts --- .../notifications/templates/handlebars/partials/styles.hbs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/integrations/send-grid/notifications/templates/handlebars/partials/styles.hbs b/src/integrations/send-grid/notifications/templates/handlebars/partials/styles.hbs index f3167ffd..4fb4af83 100644 --- a/src/integrations/send-grid/notifications/templates/handlebars/partials/styles.hbs +++ b/src/integrations/send-grid/notifications/templates/handlebars/partials/styles.hbs @@ -11,7 +11,7 @@ @media only screen and (max-width: 600px) { #container { - padding: 2rem; + padding: 2.5rem; } html { @@ -23,6 +23,7 @@ width: 100%; background: #09090B; font-family: 'Inter', sans-serif; + min-height: 700px; } #container {