Skip to content

Commit ad852d2

Browse files
committed
Use config.email[to|from|subject|body]
Mustache templates are used for `subject` and `body`
1 parent b75a98d commit ad852d2

File tree

1 file changed

+34
-18
lines changed

1 file changed

+34
-18
lines changed

index.js

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -78,25 +78,9 @@ var gDate = path.basename(dstDir);
7878
gDate = gDate.match(/([0-9]{4}-[0-9]{2}-[0-9]{2})/)[1];
7979

8080
// configure scrawl
81-
scrawl.group = 'JSON-LD CG Telecon';
81+
scrawl.group = config.group || 'Telecon';
8282
scrawl.people = JSON.parse(peopleJson);
8383

84-
const EMAIL_TO = 'JSON-LD CG <public-linked-json@w3.org>';
85-
const EMAIL_FROM = 'gregg@greggkellogg.net';
86-
// Mustache template -- vars: gDate
87-
const EMAIL_SUBJECT = '[MINUTES] W3C JSON-LD CG Call - {{gDate}} 12pm ET';
88-
// Mustache template -- vars: scribe, gDate, content
89-
const EMAIL_BODY = `Thanks to {{scribe}} for scribing this week! The minutes
90-
for this week's JSON-LD CG telecon are now available:
91-
92-
https://json-ld.github.io/minutes/{{gDate}}/
93-
94-
Full text of the discussion follows for W3C archival purposes.
95-
Audio from the meeting is available as well (link provided below).
96-
97-
----------------------------------------------------------------
98-
{{{content}}}`;
99-
10084
// Mustache template - vars: gDate, formattedItems, content
10185
const GPLUS_BODY = `*JSON-LD CG Meeting Summary for {{gDate}}*
10286
@@ -353,11 +337,43 @@ async.waterfall([ function(callback) {
353337
console.log('scrawl: Sending new minutes email.');
354338
}
355339

340+
if (!('email' in config)) {
341+
callback('Error: Email configuration is missing');
342+
return;
343+
} else if (!('from' in config.email) || !('to' in config.email)) {
344+
callback('Error: You must supply a `to` and `from` config value');
345+
return;
346+
}
347+
348+
// see sendEmail()
349+
// TODO: don't use global constants...
350+
const EMAIL_TO = config.email.to;
351+
const EMAIL_FROM = config.email.from;
352+
353+
// Mustache template -- vars: gDate
354+
// TODO: dates are always Eastern Time...maybe the world is round?
355+
// TODO: also the time is still hard coded T_T
356+
const EMAIL_SUBJECT = config.email.subject || '[MINUTES] {{gDate}} 12pm ET';
357+
// Mustache template -- vars: scribe, gDate, content, minutes_base_url, haveAudio
358+
const EMAIL_BODY = config.email.body || `Thanks to {{scribe}} for scribing this week! The minutes
359+
for this week's telecon are now available:
360+
361+
{{{minutes_base_url}}}{{gDate}}/
362+
363+
Full text of the discussion follows for archival purposes.
364+
{{#haveAudio}}Audio from the meeting is available as well (link provided below).{{/haveAudio}}
365+
366+
----------------------------------------------------------------
367+
{{{content}}}`;
368+
356369
// generate the body of the email
357370
var content = scrawl.generateMinutes(gLogData, 'text', gDate, haveAudio);
358371
var scribe = content.match(/Scribe:\n\s(.*)\n/g)[0]
359372
.replace(/\n/g, '').replace('Scribe: ', '');
360-
content = Mustache.render(EMAIL_BODY, {scribe, gDate, content});
373+
content = Mustache.render(EMAIL_BODY,
374+
{scribe, gDate, content,
375+
minutes_base_url: scrawl.minutes_base_url,
376+
haveAudio});
361377

362378
if(process.env.SCRAWL_EMAIL_USERNAME && process.env.SCRAWL_EMAIL_PASSWORD &&
363379
process.env.SCRAWL_EMAIL_SERVER) {

0 commit comments

Comments
 (0)