chore(newsletter): DM admins when a weekly draft is ready
This commit is contained in:
parent
b8629879e0
commit
ba92eea71b
1 changed files with 18 additions and 1 deletions
|
|
@ -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)"
|
NODE_BIN="$(ls -d "$HOME"/.nvm/versions/node/*/bin 2>/dev/null | sort -V | tail -1)"
|
||||||
[ -n "$NODE_BIN" ] && export PATH="$NODE_BIN:$PATH"
|
[ -n "$NODE_BIN" ] && export PATH="$NODE_BIN:$PATH"
|
||||||
fi
|
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
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue