← All manuals IM2

Background Job — Slack Roster → app_users

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

Background Job — Slack Roster Sync

Two halves, deliberately split because the app has no Slack credentials:

  1. Viktor-side: skills/im2_app/scripts/roster_sync.py writes the Slack directory into the slack_roster table.
  2. App-side: POST /api/users/refresh (im2.py, admin only — the "Refresh from Slack directory" button on the Users screen) reconciles slack_roster into app_users.

Trigger / schedule

Inputs

Tables written (im2 database)

TableByChange
slack_roster (username PK, display_name, email, slack_id, synced_at)roster_sync.pycreate table if not exists, then truncate and full re-insert.
app_users/api/users/refreshinserts missing people at role level3, active true; updates display_name/email and re-activates returners; sets active=false for anyone in app_users but no longer in the roster. Never changes an existing person's role.
audit_log/api/users/refreshone row per add/deactivate: sku='USER:{name}', field_name='roster_sync', new_value = added / deactivated, changed_by = the admin, source='user_admin'.

A manual add path exists for non-Slack people: POST /api/users/add (name + email + level).

External calls

Slack directory listing through the Viktor SDK (sdk.tools.slack_admin_tools). The droplet makes no Slack calls.

Failure behaviour / idempotency

Logs to look at

Known limits / gaps