← All manuals IM2

Background Job — Notifications (Slack + SMS, Rush alerting)

(background process — no screen)
Technical Spec Ver 1 Updated 2026-09-06 Matches the live screen

Background Job — Notifications (Slack + SMS)

Code: app/notify.py. Two transports (notify_slack, notify_sms) plus one assembler (notify_rush) and one written-but-unwired function (notify_release).

Trigger / schedule

Not scheduled — event-driven, in-request. The only live call site is app/rush.py (~line 289), at the end of the Rush RO create handler (POST /ro/rush), after the RO has committed:

The whole call is wrapped in try/except in rush.py as well as inside notify.py, so a notification failure can never fail or roll back the RO.

notify_release() (text the requester "RO 799013 ordered - PO 1234 - Elliott") is complete but has no call site on purpose: IM2 never creates a real QB PO yet and po_buy_list.released_at is written nowhere, so there is no "PO released" event to hook.

Settings and inputs

Setting (app_settings, Settings screen)Ships asRead by
rush_notify_slackYesnotify_rush → Slack
rush_notify_smsNo (off until ClickSend auto-recharge is fixed)notify_rush → SMS
rush_notify_tech_smsYesnotify_release (unwired)

Read via im2.setting_bool() (imported locally to avoid an im2↔notify import cycle).

Recipients: im2.rush_alert_contactselect phone from rush_alert_contact where active order by name, maintained on the Rush Alert Contacts admin screen. notify_release would read app_users.phone.

Message body: RUSH RO {order_no} - {job_name} - {n} line(s)[ - vendor: X] - from {tech}; the Slack copy appends IM2_PUBLIC_URL + /po/workbench?priority=R.

Environment (all in /opt/im2/env)

External calls

Tables written

None. This module is write-free — no delivery log, no receipt table.

Failure behaviour / idempotency

Logs to look at

journalctl -u im2 on the droplet, logger name im2.notify: notify_slack: RUSH_SLACK_WEBHOOK_URL not set — message dropped: …, notify_sms: ClickSend returned …, notify_rush: slack step failed for RO ….

Known limits / gaps