diff --git a/scripts/newsletter-weekly.sh b/scripts/newsletter-weekly.sh index b36042f..82800d2 100755 --- a/scripts/newsletter-weekly.sh +++ b/scripts/newsletter-weekly.sh @@ -7,4 +7,21 @@ if [ -d "$HOME/.nvm/versions/node" ]; then NODE_BIN="$(ls -d "$HOME"/.nvm/versions/node/*/bin 2>/dev/null | sort -V | tail -1)" [ -n "$NODE_BIN" ] && export PATH="$NODE_BIN:$PATH" fi -exec npx tsx scripts/newsletter-weekly.ts + +OUT="$(npx tsx scripts/newsletter-weekly.ts)" +printf '%s\n' "$OUT" + +# Let the admins know a draft is waiting. This is a content-free NIP-17 DM; the +# push service wakes their phones, and the message contains only the issue +# number and the /newsletter URL. A failed notice must never fail the draft. +META="$(printf '%s' "$OUT" | node -e "let s='';process.stdin.on('data',d=>s+=d).on('end',()=>{try{const j=JSON.parse(s);process.stdout.write([j.issue,j.autoPublished===true?'published':'draft'].join(':'))}catch{process.stdout.write('')}})")" +NUMBER="${META%%:*}" +MODE="${META##*:}" +if [ -n "$NUMBER" ]; then + if [ "$MODE" = "published" ]; then + MSG="Weekly newsletter #${NUMBER} is published: https://skate-spots.org/newsletter" + else + MSG="Weekly newsletter draft #${NUMBER} is ready for review: https://skate-spots.org/newsletter (admin banner → Load draft). Nothing is public until you publish." + fi + scripts/send-ops-alert.sh "$MSG" >/dev/null 2>&1 || true +fi