Skip to content

Commit 09bba13

Browse files
committed
Make post URL logging null-safer
1 parent 6a9630a commit 09bba13

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

lib/publishBlueSky.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ module.exports = async (post) => {
2525
}
2626
})
2727

28-
logger.info(`[${colors.green('✔')}] BlueSky post published: ${JSON.stringify(res)}`)
28+
logger.info(`[${colors.green('✔')}] BlueSky post published: ${res?.data?.uri}`)
2929
} catch (error) {
3030
logger.warn(`[${colors.red('❌')}] BlueSky post failed: ${colors.red(error)}`)
3131
}

lib/publishMastodon.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ module.exports = async (status) => {
1515
if (process.env.PUBLISHING_MODE) {
1616
try {
1717
const res = await masto.v1.statuses.create({ status })
18-
logger.info(`[${colors.green('✔')}] Mastodon post published: ${res.url}`)
18+
logger.info(`[${colors.green('✔')}] Mastodon post published: ${res?.url}`)
1919
} catch (error) {
2020
logger.warn(`[${colors.red('❌')}] Mastodon post failed: ${colors.red(error)}`)
2121
}

lib/publishReddit.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ module.exports = (text, title) => {
1818
if (process.env.PUBLISHING_MODE) {
1919
R.api.post('/api/submit', { api_type: 'json', sr: 'owasp_juiceshop', kind: 'self', title, text })
2020
.then(function (res) {
21-
logger.info(`[${colors.green('✔')}] Reddit post published: ${res[1].json.data.url}`)
21+
logger.info(`[${colors.green('✔')}] Reddit post published: ${res[1]?.json?.data?.url}`)
2222
})
2323
.catch(function (error) {
2424
logger.warn(`[${colors.red('❌')}] Reddit post failed: ${colors.red(error)}`)

0 commit comments

Comments
 (0)