Skip to content

Commit 396145a

Browse files
committed
feat: Added multiple maintainers and _lastauthor
fixes #15
1 parent cbd547e commit 396145a

File tree

5 files changed

+8
-11
lines changed

5 files changed

+8
-11
lines changed

.travis.yml

Lines changed: 0 additions & 4 deletions
This file was deleted.

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ A table of checks that will be carried out.
4949
A table of maintainers for pages.
5050

5151
- PagePattern: A regular expression that is matched against the full document path. Parent pages are separated through a "/".
52-
- Maintainer: The user that should receive all notifications for pages matching this pattern
52+
- Maintainer: The users that should receive all notifications for pages matching this pattern (separated by ,). You can
53+
use `_lastauthor` to reference the last author of the page)
5354

5455
### Panel "Notification Template"
5556

lib/api/Notification.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,18 @@ export class Notification {
3636

3737
for (const maintainer of this._configuration.maintainer) {
3838
if (documentInfo.matchesPath(maintainer.pagePattern)) {
39-
documentInfo.author = maintainer.maintainer
39+
documentInfo.author = maintainer.maintainer.replace(/_lastauthor/, documentInfo.author)
4040
}
4141
}
4242

43-
let to = documentInfo.author
43+
let to = documentInfo.author.split(/,/)
4444
if (this._configuration.domain) {
45-
to = `${to}@${this._configuration.domain}`
45+
to = to.map((target) => `${target}@${this._configuration.domain}`)
4646
}
4747

4848
const mailOptions = {
4949
from: this._configuration.notificationFrom,
50-
to: to,
50+
to: to.join(','),
5151
subject: subjectTemplate(documentInfo),
5252
html: bodyTemplate(documentInfo),
5353
}

test/MockServer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ export class MockServer {
118118
</tr>
119119
<tr>
120120
<td>main/Test/.*</td>
121-
<td>maintainer</td>
121+
<td>maintainer,_lastauthor</td>
122122
</tr>
123123
</tbody>
124124
</table>

test/NotificationTest.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ describe('The Notification API', (): void => {
5252
chai.expect(
5353
(transportStub as unknown as SinonStubbedInstance<Mail>).sendMail.calledWith({
5454
from: 'Notification <[email protected]>',
55-
55+
5656
subject: Handlebars.compile(MockServer.NOTIFICATION_SUBJECT)(documentInfo),
5757
html: Handlebars.compile(MockServer.NOTIFICATION_BODY)(documentInfo),
5858
})

0 commit comments

Comments
 (0)