Skip to content

Commit df77482

Browse files
committed
feat: Added recipients to notification template
1 parent 41a668c commit df77482

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

lib/api/Notification.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { DocumentInfo } from './DocumentInfo'
66
import * as Handlebars from 'handlebars'
77
import { Logger } from 'loglevel'
88
import log = require('loglevel')
9-
import moment = require('moment')
109

1110
export class Notification {
1211
private _configuration: Configuration
@@ -23,16 +22,17 @@ export class Notification {
2322

2423
this._log = log.getLogger('Notification')
2524
this._dryRun = dryRun
25+
Handlebars.registerHelper('getRecipients', (documentInfo: DocumentInfo) => {
26+
return documentInfo.getRecipients(this._configuration.maintainer, this._configuration.domain).join(', ')
27+
})
2628
}
2729

2830
public async notify(documentInfos: Array<DocumentInfo>): Promise<void> {
2931
const workingDocumentInfos = []
3032
documentInfos.forEach((entry) => {
3133
workingDocumentInfos.push(DocumentInfo.fromDocumentInfo(entry))
3234
})
33-
Handlebars.registerHelper('moment', (text, format) => {
34-
return moment(text).format(format)
35-
})
35+
3636
const subjectTemplate = Handlebars.compile(this._configuration.notificationSubjectTemplate)
3737
const bodyTemplate = Handlebars.compile(this._configuration.notificationBodyTemplate)
3838

test/MockServer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export class MockServer {
88
<p>The following document{{#if multipleDocuments}}s{{/if}} are outdated:</p>
99
<ul>
1010
{{#each documents}}
11-
<li><a href="{{url}}">{{title}}</a> ({{lastVersionDate}}) ({{author}} - {{lastVersionMessage}})</li>
11+
<li><a href="{{url}}">{{title}}</a> ({{lastVersionDate}}) ({{author}} - {{lastVersionMessage}}) [notified: {{ getRecipients this }}]</li>
1212
{{/each}}
1313
</ul>
1414
<p>Please check, wether the document needs any updates or save the document again stating that it is still valid.</p>

0 commit comments

Comments
 (0)