Assign emoji for different /edcal article statuses

Thanks to Nia for deciding the emoji!
This commit is contained in:
Hippo 2021-03-29 19:21:16 +05:30
parent 1b9d542b88
commit 4b0cde33e6

View file

@ -74,10 +74,26 @@ app.post("/edcal", (req, res) => {
} }
if (req.body.command != 'edcal') { 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 articleTable = (articles
.reverse() .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")) .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({ res.send({
response_type: "in_channel", response_type: "in_channel",
text: ` text: `
@ -86,6 +102,7 @@ app.post("/edcal", (req, res) => {
|:roundpup: Title|PP|Due Date|Publish Date|Status| |:roundpup: Title|PP|Due Date|Publish Date|Status|
|:---------------|:-|:-------|:-----------|:-----| |:---------------|:-|:-------|:-----------|:-----|
${articleTable} ${articleTable}
${emojiKey}
`, `,
}) })
} else { } else {