forked from bepronetwork/web-network
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #494 from layerx-labs/fix-comment-notifications
Fix comment notifications
- Loading branch information
Showing
12 changed files
with
210 additions
and
7 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
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
35 changes: 35 additions & 0 deletions
35
server/templates/compilers/email-comment-subscriber-template-compiler.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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import {Template} from "./template"; | ||
import {EmailNotificationSubjects} from "../index"; | ||
import Handlebars from "handlebars"; | ||
import {CommentPushProps} from "../../services/push/types"; | ||
import getConfig from "next/config"; | ||
|
||
const { publicRuntimeConfig } = getConfig(); | ||
|
||
export class EmailCommentSubscriberTemplateCompiler extends Template { | ||
constructor() { | ||
super("server/templates/"); | ||
} | ||
|
||
compile(payload: CommentPushProps) { | ||
const title = `${payload.data.marketplace} @ BEPRO | ${EmailNotificationSubjects[payload.type]}`; | ||
|
||
const actionUrlEntryPart = payload.data.entryId ? `${payload.data.type}/${payload.data.entryId}/` : ""; | ||
const actionUrlPart = | ||
`${payload.data.marketplace}/task/${payload.data.taskId}/${actionUrlEntryPart}`; | ||
|
||
const templateData = { | ||
pageTitle: title, | ||
comment: payload.data.comment, | ||
type: payload.data.type, | ||
isTaskType: payload.data.type === "task", | ||
actionHref: `${publicRuntimeConfig.urls.home}/${actionUrlPart}/?fromEmail=${payload.uuid}`, | ||
commentCreator: payload.data.creator, | ||
}; | ||
|
||
super.registerPartials(); | ||
|
||
return Handlebars.compile(this.getHtmlOf("emails/comment-subscriber.hbs"))(templateData, {allowProtoPropertiesByDefault: true}); | ||
} | ||
|
||
} |
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
29 changes: 29 additions & 0 deletions
29
server/templates/compilers/notif-comment-subscriber-template-compiler.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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import {Template} from "./template"; | ||
import Handlebars from "handlebars"; | ||
import {CommentPushProps} from "../../services/push/types"; | ||
|
||
export class NotifCommentSubscriberTemplateCompiler extends Template { | ||
constructor() { | ||
super("server/templates/"); | ||
} | ||
|
||
compile(payload: CommentPushProps) { | ||
const actionUrlEntryPart = payload.data.entryId ? `${payload.data.type}/${payload.data.entryId}/` : ""; | ||
const actionUrlPart = | ||
`${payload.data.marketplace}/task/${payload.data.taskId}/${actionUrlEntryPart}`; | ||
|
||
const templateData = { | ||
comment: payload.data.comment, | ||
type: payload.data.type, | ||
isTaskType: payload.data.type === "task", | ||
actionHref: `${actionUrlPart}/`, | ||
creator: payload.data.creator, | ||
marketplace: payload.data.marketplace, | ||
}; | ||
|
||
super.registerPartials(); | ||
|
||
return Handlebars.compile(this.getHtmlOf("notifs/comment-subscriber.hbs"))(templateData, {allowProtoPropertiesByDefault: true}); | ||
} | ||
|
||
} |
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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>{{pageTitle}}</title> | ||
{{> headLinks}} | ||
{{> styles}} | ||
</head> | ||
<body id="body"> | ||
<table id="container" cellspacing="0" cellpadding="0" border="0"> | ||
<tr> | ||
<td> | ||
{{> logo}} | ||
{{#if isTaskType}} | ||
<h1>You have a new comment on a subscribed task</h1> | ||
{{else}} | ||
<h1>You have a new comment on a {{type}} of a subscribed task</h1> | ||
{{/if}} | ||
|
||
<table id="action-card" cellspacing="0" cellpadding="0" border="0"> | ||
<tr> | ||
<td> | ||
<p>{{commentCreator}} commented:</p> | ||
<p>{{comment}}</p> | ||
<a id="action-button" href="{{actionHref}}">View comment</a> | ||
</td> | ||
</tr> | ||
</table> | ||
{{> appLinks}} | ||
</td> | ||
</tr> | ||
</table> | ||
</body> | ||
</html> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{{> avatar}} | ||
<div id="link">{{actionHref}}</div> | ||
<div class="d-flex flex-column ms-3"> | ||
{{#if isTaskType}} | ||
<span class="xs-medium title text-white mb-3"> | ||
Comment on a subscribed task | ||
</span> | ||
{{else}} | ||
<span class="xs-medium title text-white mb-3"> | ||
Comment on a {{type}} of a subscribed task | ||
</span> | ||
{{/if}} | ||
|
||
{{#if comment}} | ||
<span class="sm-regular mb-3 text-white-50"> | ||
{{comment}} | ||
</span> | ||
{{/if}} | ||
|
||
<div class="d-flex gap-2 text-white-50"> | ||
<span class="sm-regular">{{marketplace}}</span> | ||
<span>•</span> | ||
<span class="sm-regular">%DATE%</span> | ||
</div> | ||
</div> |