Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
const config = require('config')
const { get } = require('lodash')
const Email = require('@pubsweet/component-email-templating')
const unsubscribeSlug = config.get('unsubscribe.url')
const {
User,
services,
Fragment,
Collection,
} = require('pubsweet-component-helper-service')
// const { getEmailCopy } = require('./emailCopy')
const helpers = require('./helpers')
const reviewHelpers = require('./reviewerSubmitsReport/helpers')
// const editorialAssistantEmail = config.get('journal.staffEmail')
const { name: journalName, staffEmail } = config.get('journal')
class Notification {
constructor({
baseUrl = '',
fragment = {},
UserModel = {},
collection = {},
newRecommendation = {},
}) {
this.baseUrl = baseUrl
this.fragment = fragment
this.UserModel = UserModel
this.collection = collection
this.newRecommendation = newRecommendation
this.properties = this._getNotificationProperties()
}
async heMakesRecommendation() {
const notificationProperties = this.getNotificationProperties()
}
async eicMakesDecision() {
const notificationProperties = this.getNotificationProperties()
}
async notifyHEWhenReviewerSubmitsReport(reviewerLastName) {
const { eicName, titleText } = this.properties
const { collection } = this
const handlingEditor = get(collection, 'handlingEditor', {})
const { customId } = collection
const collHelper = new Collection({ collection })
const email = new Email({
type: 'user',
toUser: {
email: handlingEditor.email,
name: collHelper.getHELastName(),
},
fromEmail: `${eicName} <${staffEmail}>`,
content: {
signatureName: eicName,
ctaText: 'MANUSCRIPT DETAILS',
subject: `${customId}: A review has been submitted`,
unsubscribeLink: services.createUrl(this.baseUrl, unsubscribeSlug, {
id: handlingEditor.id,
token: handlingEditor.accessTokens.unsubscribe,
}),
ctaLink: services.createUrl(
this.baseUrl,
`/projects/${this.collection.id}/versions/${
this.fragment.id
}/details`,
),
},
})
helpers.sendHandlingEditorEmail({
email,
titleText,
reviewerLastName,
emailType: 'he-review-submitted',
})
}
async _getNotificationProperties() {
const fragmentHelper = new Fragment({ fragment: this.fragment })
const parsedFragment = await fragmentHelper.getFragmentData({
handlingEditor: this.collection.handlingEditor,
})
const { submittingAuthor } = await fragmentHelper.getAuthorData({
UserModel: this.UserModel,
})
const titleText = `the manuscript titled "${parsedFragment.title}" by ${
submittingAuthor.firstName
} ${submittingAuthor.lastName}`
const { recommendation, recommendationType } = this.newRecommendation
return { recommendation, recommendationType, titleText }
}
}
module.exports = Notification