Skip to content

Commit

Permalink
update block builders to account for null values
Browse files Browse the repository at this point in the history
  • Loading branch information
kieran committed Sep 13, 2024
1 parent 4fb25ad commit 018e85f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions functions/request-invitation.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ const slack_payload = ({name, email, company, bio, github, website, avatar, crea
// "created_at": "2008-03-19T21:02:08Z",
// "iat": 1724362049
// }
const header = (text='(undefined)') => { return { type: "header", text: { type: "plain_text", text } } }
const para = (text='undefined') => { return { type: "section", text: { type: "mrkdwn", text } } }
const header = (text) => { return { type: 'header', text: { type: 'plain_text', text: text || 'undefined' } } }
const para = (text) => { return { type: 'section', text: { type: 'mrkdwn', text: text || 'undefined' } } }
const section = (obj={}) => { return { type: 'section', fields: Object.entries(obj).map( ([key, val]) => field(key, val) ) } }
const field = (name, value='undefined') => { return { type: 'mrkdwn', text: `*${name}*\n${value}` } }
const bio_with_avatar = (text='undefined', image_url='https://www.gravatar.com/avatar/?d=identicon') => { return { type: 'section', text: { type: "mrkdwn", text }, accessory: { type: "image", image_url, alt_text: 'Github Avatar' } } }
const divider = () => { return { type: "divider" } }
const field = (name, value) => { return { type: 'mrkdwn', text: `*${name || 'undefined'}*\n${value || 'undefined'}` } }
const bio_with_avatar = (text, image_url) => { return { type: 'section', text: { type: 'mrkdwn', text: text || 'undefined' }, accessory: { type: 'image', image_url: image_url || 'https://www.gravatar.com/avatar/?d=identicon', alt_text: 'Github Avatar' } } }
const divider = () => { return { type: 'divider' } }

return {
channel: process.env.SLACK_CHANNEL,
Expand Down

0 comments on commit 018e85f

Please sign in to comment.