Skip to content

feat(slack): replace email references with Slack @mentions#516

Closed
ptone wants to merge 4 commits into
mainfrom
scion/514-slack-mention-replacement
Closed

feat(slack): replace email references with Slack @mentions#516
ptone wants to merge 4 commits into
mainfrom
scion/514-slack-mention-replacement

Conversation

@ptone

@ptone ptone commented Jul 18, 2026

Copy link
Copy Markdown
Owner

Summary

  • Port resolveOutboundMentions() from Telegram broker to the Slack broker
  • Uses the same regex, URL/mailto guards, and reverse-order processing
  • Replaces user:email and standalone email references with Slack <@user_id> mentions via GetUserMappingByEmail() store lookup
  • Wired into Publish() before message formatting

Test plan

  • Port all test cases from Telegram: user:email, standalone email, unknown user, URL email, mailto, multiple emails, edge positions
  • All 13 test cases pass
  • Full Slack package test suite passes

Partial #514

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request introduces outbound mention resolution in the Slack broker, automatically replacing Scion user emails with Slack @mentions in outgoing messages. A review comment points out a potential data race issue caused by mutating the shared msg pointer in-place, and suggests performing a shallow copy of the message struct to prevent unexpected side effects.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +443 to +445
if msg != nil && store != nil {
msg.Msg = resolveOutboundMentions(ctx, store, msg.Msg)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

Mutating msg.Msg in-place modifies the shared msg pointer. Since Publish can be called concurrently across different brokers, or sequentially where other components rely on the original message content (e.g., for dedup key generation or logging), mutating the message in-place can lead to data races and unexpected side effects.

Additionally, msg is already checked for nil earlier in this function (line 363), making the msg != nil check redundant.

Instead, perform a shallow copy of the message struct and update the local pointer.

Suggested change
if msg != nil && store != nil {
msg.Msg = resolveOutboundMentions(ctx, store, msg.Msg)
}
if store != nil {
msgCopy := *msg
msgCopy.Msg = resolveOutboundMentions(ctx, store, msg.Msg)
msg = &msgCopy
}

@ptone

ptone commented Jul 18, 2026

Copy link
Copy Markdown
Owner Author

Superseded by squash-merged upstream PR. Closing fork PR.

@ptone ptone closed this Jul 18, 2026
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