diff --git a/data/types.js b/data/types.js index a0479dc..b2835bd 100644 --- a/data/types.js +++ b/data/types.js @@ -4,30 +4,35 @@ module.exports = { { keywords: ["ill", "sick"], emoji: [":ill:", ":face_with_head_bandage:", ":face_with_thermometer:"], + defaultEmoji: "ill", type: "ill", message: ":ill: *Off sick:*" }, { keywords: ["ooo", "office", "out", "busy", "conference", "training"], emoji: [":no_entry_sign:"], + defaultEmoji: "no_entry_sign", type: "ooo", message: ":no_entry_sign: *Out of office:*" }, { keywords: ["home", "wfh", "working", "work"], emoji: [":house:", ":house_with_garden:", ":computer:", ":wfh:"], + defaultEmoji: "house", type: "wfh", message: ":house_with_garden: *WFH:*" }, { keywords: ["birthday", "cake", ":cake:"], emoji: [":birthday:", ":cake:", ":cupcake:"], + defaultEmoji: "birthday", type: "cake", message: "`:cake: *Would like some cake:*" }, { keywords: ["mat", "maternity", "pat", "paternity", "parental"], emoji: [":baby:", ":baby_bottle:", ":pregnant_woman:"], + defaultEmoji: "baby", type: "parent", message: ":baby: *On parental leave:*" }, @@ -45,6 +50,7 @@ module.exports = { "traveling" ], emoji: [":palm_tree:", ":airplane:", ":desert_island", ":sunny:"], + defaultEmoji: "palm_tree", type: "holiday", message: ":palm_tree: *On holiday:*" }, @@ -60,25 +66,29 @@ module.exports = { "breakfast", "snacking" ], - emoji: [":spagbol:", ":spaghetti:", ":desert_island", ":yum:"], + emoji: [":spagbol:", ":spaghetti:", ":yum:"], type: "lunch", + defaultEmoji: "spagbol", message: ":spagbol: *On lunch:*" }, { keywords: ["walk", "walking", "break", "breaking", "air"], emoji: [":walking:", ":woman-walking:", ":man-walking:"], + defaultEmoji: "walking", type: "walking", message: ":walking: *Getting some fresh air:*" }, { keywords: ["caring", "child", "childcare", "entertaining"], emoji: [":child:"], + defaultEmoji: "child", type: "caring", message: ":child: *Looking after someone else:*" }, { keywords: ["unavailable"], emoji: [":blockers:, :no_entry:"], + defaultEmoji: "blockers", type: "unavailable", message: ":blockers: *Unavailable:*" } diff --git a/emojiReact.js b/emojiReact.js index ab832d1..04ef8b1 100644 --- a/emojiReact.js +++ b/emojiReact.js @@ -101,7 +101,7 @@ function addNameToMessage({ text, name, message }) { const originalNames = lastPart[1]; let newNames; if (originalNames.trim()) { - newNames = name + "," + originalNames; + newNames = name + ", " + originalNames; } else { newNames = name; } diff --git a/post.js b/post.js index 919d944..ae1348b 100644 --- a/post.js +++ b/post.js @@ -14,6 +14,7 @@ async function postUpdate({ text, channel, test }) { console.log( `Successfully send message ${result.ts} in conversation ${postingChannel}` ); + return result.ts; } catch (error) { if (error.code === ErrorCode.PlatformError) { console.log(error.data); @@ -35,20 +36,21 @@ async function getMembers({ channel, test }) { const memberSelection = await getStatuses(members); const awayMessage = prepMessage(memberSelection); - + let posting; if (awayMessage !== "") { - const posting = await postUpdate({ + posting = await postUpdate({ text: `In the this channel today: \n\n ${awayMessage}`, channel, test }); } else { - const posting = await postUpdate({ + posting = await postUpdate({ text: `No one in this channel has a status set`, channel, test }); } + return posting; } catch (error) { console.log("getting into error"); if (error.code === ErrorCode.PlatformError) { @@ -208,21 +210,17 @@ function prepMessage(statuses) { return message; } -const times = x => f => { - if (x > 0) { - f(); - times(x - 1)(f); - } -}; +async function addReactions({ channel, post }) {} exports.post = async function(event, context) { try { console.log("message", event.Records[0].Sns.Message); const { channel, test } = JSON.parse(event.Records[0].Sns.Message); - await getMembers({ + const result = await getMembers({ channel, test }); + await addReactions({ channel, post: result }); return { statusCode: 200, body: "success"