-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bepro 2251 add title of task and add deliverable proposal type to ema…
…il (#237) * add task title to emails * refactor email subject and body get
- Loading branch information
Showing
6 changed files
with
55 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 44 additions & 7 deletions
51
src/integrations/send-grid/notifications/templates/email-info.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters