Skip to content

Dev - #271

Merged
nadernik merged 5 commits into
mainfrom
dev
Aug 8, 2026
Merged

Dev#271
nadernik merged 5 commits into
mainfrom
dev

Conversation

@nadernik

@nadernik nadernik commented Aug 8, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

…struction

Live: "Could not add to 3 channel(s): #help: user_is_ultra_restricted; ..." -- a bare API code
that says nothing about who must do what. It actually means the MEMBER is a single-channel
guest, which Slack caps at one channel, so no bot permission can fix it: a workspace admin has
to change their account type.

explainSlackError() now maps the common codes to a sentence naming the channel and the required
action: user_is_ultra_restricted (single-channel guest -> admin must upgrade the account type),
user_is_restricted, is_archived (drop it from the configured list), channel_not_found (bad id or
private + bot cannot see it), not_in_channel (/invite @BBQs), cant_invite_self. Unknown codes
still pass through verbatim rather than being swallowed.
… instead of one-by-one

Inviting guests one at a time meant discovering "not in the workspace" per person, mid-flow.
A new "Slack invites" button collects everyone whose slack step is still open and classifies
them in one pass, then gives each group its batch action:
  - NOT in the workspace  -> "Copy all emails" (comma-separated) to paste straight into Slack's
    Invite people box as a single group invite;
  - IN the workspace but missing channels -> "Add all to channels" in one click, then re-checks;
  - already complete -> just counted.

Backed by a new action:'bulk_check' on slack-channels: takes people[] (capped at 100, run in
small sequential batches because users.lookupByEmail is rate-limited) and returns
needs_guest_invite / needs_channels / complete, with channel NAMES not ids. Read-only.

tsc clean, guards 3/3.
…ntirely)

Correction: Slack membership is not just "everyone-channels + the young-investigator channel".
Each working group has its own channel, mirroring the wg-*@ Google Groups -- and the function
had no concept of that, so a member's WG channels were never considered.

New SLACK_WG_CHANNELS mapping, e.g.
  "WG-Analytics=C1,WG-Devices=C2|C3,WG-ELSI=C4,WG-Standards=C5"
(a group may map to several channels via "|"; the WG token is matched case-insensitively).
targetsFor() now computes a member's channels as: everyone-channels + YI channels (postdocs and
grad students) + one entry per working group they belong to. Both the single-person resolver and
the bulk triage pass working_groups, so "missing" is per-member and correct.

Also adds action:'list_channels' -- returns every channel the bot can see (id, #name, private,
is_member) plus the CURRENT configured mapping, so channel IDs can be copied from one call
instead of hunted down in Slack.

tsc clean, guards 3/3.
Adding someone to a working group now adds them to that group's Slack channel, the way Google
Groups already work. New trg_sync_slack_channels fires on the same events and calls
slack-channels with action:'sync'.

Fires on INSERT as well as UPDATE, deliberately: the Google-Group trigger is UPDATE-only, which
is exactly why a member created with working groups already set was never provisioned (the
drift group-audit exists to find). This trigger does not repeat that mistake.

The trigger path is untrusted by design. A DB trigger can only send the public anon key, so the
function IGNORES every value in the body except the email, re-reads role/working_groups with the
service role, and syncs from what the database says; it returns a bare {ok} so the path cannot
be used to probe who is in Slack. Admin/curator JWT is still required for all other actions. A
Slack failure never blocks the profile edit.
Analytics channel #bbqs-wg-analytics (C0BP1AN59CZ) was created, completing the mapping:
everyone -> #general; trainees -> #younginvestigators; and one channel per working group.
Documented as the source of truth alongside the note that the same lists exist agent-side in
consortium_settings and must be kept in sync.
@nadernik
nadernik merged commit d12f52f into main Aug 8, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant