Skip to content

Commit 9c218b2

Browse files
committed
feat(channel): add --team-ids server-side filter to channel list
The curated `channel list` exposed only `--name` (a client-side substring filter), shadowing the generated twin that carries the API's `team_ids` filter. So there was no way to ask the server for a single team's channels — callers had to fetch all channels and filter locally, which scales poorly (server default caps the page at 100 rows) and, in fc-safari's /init scanner, made team-scoped incident totals impossible to compute correctly. Wire ListChannelsRequest.TeamIDs to a new --team-ids flag (empty = all teams, behavior unchanged). Intended release: minor bump v1.4.0.
1 parent 6c2d053 commit 9c218b2

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

internal/cli/channel.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,21 @@ type channelRow struct {
3939

4040
func newChannelListCmd() *cobra.Command {
4141
var name string
42+
var teamIDs []int64
4243

4344
cmd := &cobra.Command{
4445
Use: "list",
4546
Short: "List channels",
46-
Long: curatedLong("List channels in the account, optionally filtered by name.", "Channels", "ChannelList"),
47+
Long: curatedLong("List channels in the account, optionally filtered by name or owning team.", "Channels", "ChannelList"),
4748
RunE: func(cmd *cobra.Command, args []string) error {
4849
return runCommand(cmd, args, func(ctx *RunContext) error {
4950
// Legacy parity: the hand-written SDK called /channel/list with an
5051
// empty body and applied the --name filter client-side as a
5152
// case-insensitive substring match. go-flashduty's ChannelName field
5253
// is an exact-match server filter, so we keep the client-side filter
53-
// to preserve behavior.
54-
result, _, err := ctx.Client.Channels.ChannelList(cmdContext(ctx.Cmd), &flashduty.ListChannelsRequest{})
54+
// to preserve behavior. --team-ids, by contrast, is a server-side
55+
// filter on the channel's owning team (empty = all teams, unchanged).
56+
result, _, err := ctx.Client.Channels.ChannelList(cmdContext(ctx.Cmd), &flashduty.ListChannelsRequest{TeamIDs: teamIDs})
5557
if err != nil {
5658
return err
5759
}
@@ -87,6 +89,7 @@ func newChannelListCmd() *cobra.Command {
8789
}
8890

8991
cmd.Flags().StringVar(&name, "name", "", "Search by name")
92+
cmd.Flags().Int64SliceVar(&teamIDs, "team-ids", nil, "Filter by owning team ID(s), server-side (repeatable or comma-separated)")
9093

9194
return cmd
9295
}

0 commit comments

Comments
 (0)