Skip to content

Actually fill in user emails from Slack#451

Closed
HazAT wants to merge 1 commit into
user-email-schemafrom
user-email-sync
Closed

Actually fill in user emails from Slack#451
HazAT wants to merge 1 commit into
user-email-schemafrom
user-email-sync

Conversation

@HazAT

@HazAT HazAT commented Jul 10, 2026

Copy link
Copy Markdown
Member

Slack knows everyone's email — we just never asked. Now we grab it when users are created and during the nightly sync, which doubles as the backfill for everyone who's already here. (2/3)

⚠️ Needs the users:read.email scope added to the Slack app, otherwise Slack keeps it to itself. 🥔

@HazAT HazAT requested a review from a team as a code owner July 10, 2026 11:10

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit ba18f8e. Configure here.

'status' => User::STATUS_ACTIVE,
'slack_user_id' => $slackUser['id'],
'slack_name' => $slackUser['real_name'],
'slack_email' => $slackUser['profile']['email'] ?? null,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nightly sync clears stored emails

Medium Severity

Each active-user sync always patches slack_email from profile.email, using ?? null when Slack omits that field. Without users:read.email (or when the field is absent), every nightly run writes null and can erase emails that were already backfilled or set at creation.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit ba18f8e. Configure here.

@HazAT HazAT force-pushed the user-email-schema branch from 70e8407 to 0b94587 Compare July 10, 2026 11:13
Populate the slack_email column from Slack's users.info response in
both places users are synced:

- UserService::getOrCreateUser() for newly created users
- UpdateUsersCommand (nightly cron) for existing users, which also
  serves as the backfill once the users:read.email OAuth scope is
  granted — no separate backfill command needed

Email falls back to null when Slack doesn't return one (bot users, or
missing users:read.email scope), matching the nullable column.

Note: requires adding the users:read.email scope to the Slack app for
profile.email to be included in users.info responses.
@HazAT HazAT force-pushed the user-email-sync branch from ba18f8e to 0ce5b02 Compare July 10, 2026 11:13
@HazAT

HazAT commented Jul 10, 2026

Copy link
Copy Markdown
Member Author

Folded into #452 — one PR for the whole email story.

@HazAT HazAT deleted the branch user-email-schema July 10, 2026 11:15
@HazAT HazAT closed this Jul 10, 2026
@HazAT HazAT deleted the user-email-sync branch July 10, 2026 11:15
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