diff --git a/index.js b/index.js index 853c1ef..6ad4e54 100644 --- a/index.js +++ b/index.js @@ -74,10 +74,26 @@ app.post("/edcal", (req, res) => { } if (req.body.command != 'edcal') { + let statusToEmoji = new Map([ + ['Published', ':grin:'], + ['Scheduled', ':alarm_clock:'], + ['WIP', ':roundpup:'], + ['Waiting for response', ':zzz:'], + ['Stalled', ':clown_face:'], + ]) + + // format the articles into a table articleTable = (articles .reverse() - .map(a => `|${a.title}|${a.in_charge.map(u=>u.name[0]).join(',')}|${a.due_date}|${a.publish_date}|${a.status}|`) + .map(a => `|${a.title}|${a.in_charge.map(u=>u.name[0]).join(',')}|${a.due_date}|${a.publish_date}|${statusToEmoji.get(a.status) || a.status}|`) .join("\n")) + + // an emoji -> status message legend to display at the end + emojiKey = ([...statusToEmoji.entries()] + .map((x) => `${x[1]} ${x[0]}`) + .join(' ')) + + // ...and we're out! res.send({ response_type: "in_channel", text: ` @@ -86,6 +102,7 @@ app.post("/edcal", (req, res) => { |:roundpup: Title|PP|Due Date|Publish Date|Status| |:---------------|:-|:-------|:-----------|:-----| ${articleTable} +${emojiKey} `, }) } else {