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#{{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%
diff --git a/src/integrations/send-grid/notifications/email-notification.ts b/src/integrations/send-grid/notifications/email-notification.ts index cd50b4d2..d6aacdc6 100644 --- a/src/integrations/send-grid/notifications/email-notification.ts +++ b/src/integrations/send-grid/notifications/email-notification.ts @@ -1,10 +1,9 @@ import {EmailService} from "../email-service/email-service"; import {Templates} from "./templates"; -import {EmailNotificationSubjects} from "./templates/email-info"; +import {getEmailNotificationSubject} from "./templates/email-info"; import {EmailTemplate} from "../../../services/templating/email-template"; import {users} from "../../../db/models/users"; import {v4 as uuidv4} from "uuid"; -import {format} from "node:util" import {getEventTargets} from "../../../utils/get-event-targets"; import { CollectEventPayloadParams } from "src/services/analytics/types/analytics"; import { AnalyticEventName } from "src/services/analytics/types/events"; @@ -26,7 +25,7 @@ export class EmailNotification { for (const [index, to] of recipients.filter(e => 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/integrations/send-grid/notifications/templates/handlebars/base-template.hbs b/src/integrations/send-grid/notifications/templates/handlebars/base-template.hbs index c70f741e..2da2ef4e 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,40 @@ {{> styles}} - - - - -
- {{> logo}} -

{{notificationTitleHeading}}

- - - - -
-

{{taskTitleParagraph}}

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

{{notificationTitleHeading}}

+ + + + +
+

{{taskTitleParagraph}}

+ View task +
+ + + + + + + + + + +
+
diff --git a/src/integrations/send-grid/notifications/templates/handlebars/partials/logo.hbs b/src/integrations/send-grid/notifications/templates/handlebars/partials/logo.hbs index 6676052e..c4717921 100644 --- a/src/integrations/send-grid/notifications/templates/handlebars/partials/logo.hbs +++ b/src/integrations/send-grid/notifications/templates/handlebars/partials/logo.hbs @@ -1 +1 @@ -Bepro Logo +Bepro Logo 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..4fb4af83 100644 --- a/src/integrations/send-grid/notifications/templates/handlebars/partials/styles.hbs +++ b/src/integrations/send-grid/notifications/templates/handlebars/partials/styles.hbs @@ -1,36 +1,61 @@ \ 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}` };