Skip to content

client: Add option to only bridge DMs - #93

Merged
KishanBagaria merged 24 commits into
mainfrom
kb/dm-only
Aug 12, 2026
Merged

client: Add option to only bridge DMs#93
KishanBagaria merged 24 commits into
mainfrom
kb/dm-only

Conversation

@KishanBagaria

@KishanBagaria KishanBagaria commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Depends on beeper/slackgo#4

Copilot AI lite review requested due to automatic review settings August 7, 2026 17:36

Copilot AI 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.

Pull request overview

Adds a “DM-only” operating mode for the Slack connector, intended to restrict discovery/sync/event handling to direct messages (IMs) and group DMs (MPIMs), while omitting channel data where possible.

Changes:

  • Introduces dm_only configuration and config upgrader support.
  • Uses Slack client boot options to omit channel data when dm_only is enabled.
  • Filters incoming Slack events and adjusts channel sync logic to ignore non-DM conversations in DM-only mode.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
pkg/connector/startchat.go Blocks channel creation when dm_only is enabled.
pkg/connector/login-cookie.go Uses boot options to omit channels during cookie/token login when dm_only is enabled.
pkg/connector/handleslack.go Filters events to DM channels only; adds helper to extract channel ID from events.
pkg/connector/example-config.yaml Documents the new dm_only config option.
pkg/connector/config.go Adds DMOnly to config struct and config upgrade path.
pkg/connector/client.go Tracks DM channel IDs; boots and syncs differently under dm_only.
pkg/connector/capabilities.go Hides public/private channel creation capability when dm_only is enabled.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/connector/handleslack.go
Comment thread pkg/connector/client.go Outdated
for _, ch := range s.BootResp.Channels {
ch.IsMember = true
channels = append(channels, &ch.Channel)
if s.Main.Config.DMOnly || (s.IsRealUser && (strings.HasPrefix(token, "xoxs-") || s.Main.Config.Backfill.ConversationCount == -1)) {
Comment thread pkg/connector/client.go Outdated
Comment thread pkg/connector/client.go Outdated
Comment thread pkg/connector/client.go Outdated
Comment thread pkg/connector/login-cookie.go Outdated
Comment thread pkg/connector/client.go Outdated
}
// TODO do actual warm boots by saving last received ts somewhere
bootResp, err = s.Client.ClientUserBootContext(ctx, time.Time{})
bootResp, err = s.Client.ClientUserBootContext(ctx, time.Time{}, s.Main.Config.DMOnly)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

slack is actually ignoring omit_channels and still returning it. keeping it in case bot logins are different

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

userBoot is only used for users, never bots

Comment thread pkg/connector/chatinfo.go
pages := 0
output = make(map[networkid.UserID]bridgev2.ChatMember)
for limit > 0 {
chunkLimit := limit

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

bug in main - chunkLimit was unused

Comment thread pkg/connector/client.go
const maxSlackPaginationPages = 1000

func slackPageLimit(unlimited bool, remaining int) int {
const maxPage = 200

@KishanBagaria KishanBagaria Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@tulir any reason to do 200 max here? i tested users.conversations accepts limit=999 (it returned my 828 DMs/MPIMs in 1 req)

this will reduce users.conversations from 5 requests to 1 for me

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I assume it's from what the web app does, but probably fine to increase. I don't think slack bans users since most people are paying them

@KishanBagaria

Copy link
Copy Markdown
Contributor Author

@tulir good for re-review

@tulir tulir changed the title Add DM-only mode for local Slack client: Add option to only bridge DMs Aug 10, 2026

@tulir tulir left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The omit_channels thing could be reverted since it's not used for bots, but otherwise looks fine

Comment thread pkg/connector/client.go
const maxSlackPaginationPages = 1000

func slackPageLimit(unlimited bool, remaining int) int {
const maxPage = 200

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I assume it's from what the web app does, but probably fine to increase. I don't think slack bans users since most people are paying them

Comment thread pkg/connector/client.go Outdated
}
// TODO do actual warm boots by saving last received ts somewhere
bootResp, err = s.Client.ClientUserBootContext(ctx, time.Time{})
bootResp, err = s.Client.ClientUserBootContext(ctx, time.Time{}, s.Main.Config.DMOnly)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

userBoot is only used for users, never bots

@KishanBagaria
KishanBagaria merged commit b7a7444 into main Aug 12, 2026
11 checks passed
@KishanBagaria
KishanBagaria deleted the kb/dm-only branch August 12, 2026 12:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants