Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expose writer support for bots #21953

Merged
merged 1 commit into from
Jan 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions go/client/cmd_chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ func NewCmdChat(cl *libcmdline.CommandLine, g *libkb.GlobalContext) cli.Command
newCmdChatSearchRegexp(cl, g),
newCmdChatSend(cl, g),
newCmdChatUpload(cl, g),
newCmdChatAddBotMember(cl, g),
newCmdChatRemoveBotMember(cl, g),
newCmdChatEditBotMember(cl, g),
newCmdChatBotMemberSettings(cl, g),
newCmdChatFeaturedBots(cl, g),
newCmdChatSearchBots(cl, g),
}
subcommands = append(subcommands, getBuildSpecificChatCommands(cl, g)...)
return cli.Command{
Expand Down
2 changes: 1 addition & 1 deletion go/client/cmd_chat_add_bot_member.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func newCmdChatAddBotMember(cl *libcmdline.CommandLine, g *libkb.GlobalContext)
})
return cli.Command{
Name: "add-bot-member",
Usage: "Add a bot or a restricted bot to a conversation",
Usage: "Add a bot or a restricted bot to a conversation.",
ArgumentHelp: "[conversation]",
Action: func(c *cli.Context) {
cl.ChooseCommand(NewCmdChatAddBotMemberRunner(g), "add-bot-member", c)
Expand Down
2 changes: 1 addition & 1 deletion go/client/cmd_chat_bot_member_settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func newCmdChatBotMemberSettings(cl *libcmdline.CommandLine, g *libkb.GlobalCont
})
return cli.Command{
Name: "bot-member-settings",
Usage: "View or modify a restricted bot's isolation settings",
Usage: "View or modify a restricted bot's isolation settings.",
ArgumentHelp: "[conversation]",
Action: func(c *cli.Context) {
cl.ChooseCommand(NewCmdChatBotMemberSettingsRunner(g), "bot-member-settings", c)
Expand Down
2 changes: 1 addition & 1 deletion go/client/cmd_chat_edit_bot_member.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func newCmdChatEditBotMember(cl *libcmdline.CommandLine, g *libkb.GlobalContext)
})
return cli.Command{
Name: "edit-bot-member",
Usage: "Edit the role bot or a restricted bot in a conversation",
Usage: "Edit the role bot or a restricted bot in a conversation.",
ArgumentHelp: "[conversation]",
Action: func(c *cli.Context) {
cl.ChooseCommand(NewCmdChatEditBotMemberRunner(g), "edit-bot-member", c)
Expand Down
5 changes: 2 additions & 3 deletions go/client/cmd_chat_min_writer_role.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,8 @@ Disable a previously set policy
},
Flags: append(getConversationResolverFlags(), []cli.Flag{
cli.StringFlag{
Name: "r, role",
// TODO HOTPOT-599 add bot (but not restricted bot) role
Usage: "team role (owner, admin, writer, reader, none)",
Name: "r, role",
Usage: "team role (owner, admin, writer, reader, bot, none)",
},
}...),
}
Expand Down
1 change: 1 addition & 0 deletions go/client/cmd_team.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ func NewCmdTeam(cl *libcmdline.CommandLine, g *libkb.GlobalContext) cli.Command
newCmdTeamSettings(cl, g),
newCmdTeamProfileLoad(cl, g),
newCmdTeamFTL(cl, g),
newCmdTeamBotSettings(cl, g),
}
subcommands = append(subcommands, getBuildSpecificTeamCommands(cl, g)...)
return cli.Command{
Expand Down
10 changes: 3 additions & 7 deletions go/client/cmd_team_add_member.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,8 @@ func newCmdTeamAddMember(cl *libcmdline.CommandLine, g *libkb.GlobalContext) cli
Usage: "phone number to invite",
},
cli.StringFlag{
Name: "r, role",
// TODO HOTPOT-599 add bot roles
Usage: "team role (owner, admin, writer, reader) [required]",
Name: "r, role",
Usage: "team role (owner, admin, writer, reader, bot, restrictedbot) [required]",
},
cli.BoolFlag{
Name: "s, skip-chat-message",
Expand All @@ -59,10 +58,7 @@ func newCmdTeamAddMember(cl *libcmdline.CommandLine, g *libkb.GlobalContext) cli
Description: teamAddMemberDoc,
}

// TODO HOTPOT-599 expose publicly
if g.Env.GetRunMode() == libkb.DevelRunMode || libkb.IsKeybaseAdmin(g.GetMyUID()) {
cmd.Flags = append(cmd.Flags, botSettingsFlags...)
}
cmd.Flags = append(cmd.Flags, botSettingsFlags...)
return cmd
}

Expand Down
25 changes: 10 additions & 15 deletions go/client/cmd_team_add_members_bulk.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ func newCmdTeamAddMembersBulk(cl *libcmdline.CommandLine, g *libkb.GlobalContext
cl.ChooseCommand(cmd, "add-members-bulk", c)
},
Flags: []cli.Flag{
cli.StringFlag{
Name: "b, bots",
Usage: "specify bots to add",
},
cli.StringFlag{
Name: "r, readers",
Usage: "specify readers to add",
Expand All @@ -54,13 +58,6 @@ func newCmdTeamAddMembersBulk(cl *libcmdline.CommandLine, g *libkb.GlobalContext
Description: teamAddMembersBulkDoc,
}

// TODO HOTPOT-599 expose publicly
if g.Env.GetRunMode() == libkb.DevelRunMode || libkb.IsKeybaseAdmin(g.GetMyUID()) {
cmd.Flags = append(cmd.Flags, cli.StringFlag{
Name: "b, bots",
Usage: "specify bots to add",
})
}
return cmd
}

Expand Down Expand Up @@ -110,8 +107,7 @@ func (c *CmdTeamAddMembersBulk) ParseArgv(ctx *cli.Context) (err error) {
tot += n
}
if tot == 0 {
// TODO HOTPOT-599 add --bots
return errors.New("Need at least one of --readers, --writers, --admins or --owners")
return errors.New("Need at least one of --bots, --readers, --writers, --admins or --owners")
}
c.arg.SendChatNotification = !ctx.Bool("skip-chat-message")
return nil
Expand Down Expand Up @@ -145,7 +141,6 @@ func (c *CmdTeamAddMembersBulk) GetUsage() libkb.Usage {
}
}

// TODO HOTPOT-599 add --bots here too
const teamAddMembersBulkDoc = `"keybase team add-members-bulk" allows you to add multiple users to a team, in bulk

EXAMPLES:
Expand All @@ -156,14 +151,14 @@ Add existing keybase users as writers:

Add users via social assertions:

keybase team add-members-bulk acme --writers=alice+alice@github,bob@github,jerry@redder --readers=jon,bob32
keybase team add-members-bulk acme --writers=alice+alice@github,bob@github,jerry@redder --readers=jon,bob32 --bots=botua

Add users via email:

keybase team add-members-bulk acme --readers='[max43@gmail.com]@email,[bill32@yahoo.com]@email' --writers='[lucy32@poems.com]@email'

You can specify one or more of --readers, --writers, --admins, --owners, to add multiple
roles at one go. For each of those lists, you can mix and match Keybase users, social
assertions, and email addresses. Email addresses cannot be combined with other assertions,
however.
You can specify one or more of --bots, --readers, --writers, --admins,
--owners, to add multiple roles at one go. For each of those lists, you can mix
and match Keybase users, social assertions, and email addresses. Email
addresses cannot be combined with other assertions, however.
`
2 changes: 1 addition & 1 deletion go/client/cmd_team_bot_settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func newCmdTeamBotSettings(cl *libcmdline.CommandLine, g *libkb.GlobalContext) c
return cli.Command{
Name: "bot-settings",
ArgumentHelp: "<team name>",
Usage: "Modify the bot settings of the given user. User must be a member of the given team with role restrictedbot",
Usage: "Modify the bot settings of the given user. User must be a member of the given team with role restrictedbot.",
Action: func(c *cli.Context) {
cl.ChooseCommand(NewCmdTeamBotSettingsRunner(g), "bot-settings", c)
},
Expand Down
13 changes: 4 additions & 9 deletions go/client/cmd_team_edit_member.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ type CmdTeamEditMember struct {

func newCmdTeamEditMember(cl *libcmdline.CommandLine, g *libkb.GlobalContext) cli.Command {
cmd := cli.Command{
Name: "edit-member",
// TODO HOTPOT-599 add bot roles
ArgumentHelp: "<team name> --user=<username> --role=<owner|admin|writer|reader>",
Name: "edit-member",
ArgumentHelp: "<team name> --user=<username> --role=<owner|admin|writer|reader|bot|restrictedbot>",
Usage: "Change a user's role on a team.",
Action: func(c *cli.Context) {
cmd := &CmdTeamEditMember{Contextified: libkb.NewContextified(g)}
Expand All @@ -36,18 +35,14 @@ func newCmdTeamEditMember(cl *libcmdline.CommandLine, g *libkb.GlobalContext) cl
Name: "u, user",
Usage: "username",
},
// TODO HOTPOT-599 add bot roles
cli.StringFlag{
Name: "r, role",
Usage: "team role (owner, admin, writer, reader)",
Usage: "team role (owner, admin, writer, reader, bot, restrictedbot)",
},
},
}

// TODO HOTPOT-599 expose publicly
if g.Env.GetRunMode() == libkb.DevelRunMode || libkb.IsKeybaseAdmin(g.GetMyUID()) {
cmd.Flags = append(cmd.Flags, botSettingsFlags...)
}
cmd.Flags = append(cmd.Flags, botSettingsFlags...)
return cmd
}

Expand Down
11 changes: 1 addition & 10 deletions go/client/commands_devel.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,11 @@ func getBuildSpecificChatCommands(cl *libcmdline.CommandLine, g *libkb.GlobalCon
newCmdChatSetRetentionDev(cl, g),
newCmdChatKBFSUpgrade(cl, g),
newCmdChatProfileSearchDev(cl, g),
newCmdChatAddBotMember(cl, g),
newCmdChatRemoveBotMember(cl, g),
newCmdChatEditBotMember(cl, g),
newCmdChatBotMemberSettings(cl, g),
newCmdChatFeaturedBots(cl, g),
newCmdChatSearchBots(cl, g),
}
}

func getBuildSpecificTeamCommands(cl *libcmdline.CommandLine, g *libkb.GlobalContext) []cli.Command {
return []cli.Command{
// TODO HOTPOT-599 move to production
newCmdTeamBotSettings(cl, g),
}
return nil
}

func getBuildSpecificAccountCommands(cl *libcmdline.CommandLine, g *libkb.GlobalContext) []cli.Command {
Expand Down
3 changes: 1 addition & 2 deletions go/client/team_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ func ParseRole(ctx *cli.Context) (keybase1.TeamRole, error) {

role, ok := keybase1.TeamRoleMap[strings.ToUpper(srole)]
if !ok {
// TODO(HOTPOT-599) update to include bot roles
return 0, errors.New("invalid team role, please use owner, admin, writer, or reader")
return 0, errors.New("invalid team role, please use owner, admin, writer, reader, bot, or restrictedbot")
}

return role, nil
Expand Down