Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
X
xpub-faraday
Manage
Activity
Members
Labels
Plan
Issues
2
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Container Registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
xpub
xpub-faraday
Commits
650d0270
Commit
650d0270
authored
6 years ago
by
Sebastian Mihalache
Browse files
Options
Downloads
Patches
Plain Diff
refactor(email-templating): add props to constructors
parent
e0ae33d4
No related branches found
No related tags found
3 merge requests
!160
Update staging with master features
,
!156
Develop
,
!149
Hin 1089
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
packages/component-email-templating/src/EmailTemplate.js
+23
-5
23 additions, 5 deletions
packages/component-email-templating/src/EmailTemplate.js
with
23 additions
and
5 deletions
packages/component-email-templating/src/EmailTemplate.js
+
23
−
5
View file @
650d0270
const
config
=
require
(
'
config
'
)
const
config
=
require
(
'
config
'
)
const
helpers
=
require
(
'
./helpers
'
)
const
helpers
=
require
(
'
./helpers
'
)
const
SendEmail
=
require
(
'
@pubsweet/component-send-email
'
)
const
SendEmail
=
require
(
'
@pubsweet/component-send-email
'
)
const
logger
=
require
(
'
@pubsweet/logger
'
)
const
configData
=
{
const
configData
=
{
logo
:
config
.
get
(
'
journal.logo
'
),
logo
:
config
.
get
(
'
journal.logo
'
),
...
@@ -10,9 +11,10 @@ const configData = {
...
@@ -10,9 +11,10 @@ const configData = {
logoLink
:
config
.
get
(
'
journal.logoLink
'
),
logoLink
:
config
.
get
(
'
journal.logoLink
'
),
publisher
:
config
.
get
(
'
journal.publisher
'
),
publisher
:
config
.
get
(
'
journal.publisher
'
),
}
}
class
Email
{
class
Email
Template
{
constructor
({
constructor
({
type
=
'
system
'
,
type
=
'
system
'
,
templateType
=
'
notification
'
,
fromEmail
=
config
.
get
(
'
journal.staffEmail
'
),
fromEmail
=
config
.
get
(
'
journal.staffEmail
'
),
toUser
=
{
toUser
=
{
id
:
''
,
id
:
''
,
...
@@ -23,15 +25,19 @@ class Email {
...
@@ -23,15 +25,19 @@ class Email {
subject
:
''
,
subject
:
''
,
ctaLink
:
''
,
ctaLink
:
''
,
ctaText
:
''
,
ctaText
:
''
,
paragraph
:
''
,
signatureName
:
''
,
signatureName
:
''
,
unsubscribeLink
:
''
,
unsubscribeLink
:
''
,
signatureJournal
:
''
,
signatureJournal
:
''
,
},
},
bodyProps
=
{
hasLink
:
false
,
hasIntro
:
false
,
hasSignature
:
false
},
})
{
})
{
this
.
type
=
type
this
.
type
=
type
this
.
toUser
=
toUser
this
.
toUser
=
toUser
this
.
content
=
content
this
.
content
=
content
this
.
bodyProps
=
bodyProps
this
.
fromEmail
=
fromEmail
this
.
fromEmail
=
fromEmail
this
.
templateType
=
templateType
}
}
set
_toUser
(
newToUser
)
{
set
_toUser
(
newToUser
)
{
...
@@ -46,7 +52,7 @@ class Email {
...
@@ -46,7 +52,7 @@ class Email {
this
.
content
=
newContent
this
.
content
=
newContent
}
}
getInvitationBody
({
emailBodyProps
})
{
_
getInvitationBody
({
emailBodyProps
})
{
return
{
return
{
html
:
helpers
.
getCompiledInvitationBody
({
html
:
helpers
.
getCompiledInvitationBody
({
replacements
:
{
replacements
:
{
...
@@ -63,7 +69,7 @@ class Email {
...
@@ -63,7 +69,7 @@ class Email {
}
}
}
}
getNotificationBody
({
emailBodyProps
})
{
_
getNotificationBody
({
emailBodyProps
})
{
return
{
return
{
html
:
helpers
.
getCompiledNotificationBody
({
html
:
helpers
.
getCompiledNotificationBody
({
replacements
:
{
replacements
:
{
...
@@ -80,7 +86,12 @@ class Email {
...
@@ -80,7 +86,12 @@ class Email {
}
}
}
}
async
sendEmail
({
text
,
html
})
{
async
sendEmail
()
{
const
{
html
,
text
}
=
this
.
templateType
===
'
notification
'
?
this
.
_getNotificationBody
()
:
this
.
_getInvitationBody
()
const
{
fromEmail
:
from
}
=
this
const
{
fromEmail
:
from
}
=
this
const
{
email
:
to
}
=
this
.
toUser
const
{
email
:
to
}
=
this
.
toUser
const
{
subject
}
=
this
.
content
const
{
subject
}
=
this
.
content
...
@@ -95,10 +106,17 @@ class Email {
...
@@ -95,10 +106,17 @@ class Email {
try
{
try
{
await
SendEmail
.
send
(
mailData
)
await
SendEmail
.
send
(
mailData
)
logger
.
info
(
`Sent email from:
${
from
}
to:
${
to
}
with subject: "
${
subject
}
"`
,
)
logger
.
debug
(
`Sent email from:
${
from
}
to:
${
to
}
with subject: "
${
subject
}
"`
,
)
}
catch
(
e
)
{
}
catch
(
e
)
{
logger
.
error
(
e
)
throw
new
Error
(
e
)
throw
new
Error
(
e
)
}
}
}
}
}
}
module
.
exports
=
Email
module
.
exports
=
Email
Template
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment