pilosus / dienstplan

Slack bot app for duty rotations
https://dienstplan-slack.pilosus.org
Other
21 stars 1 forks source link

[FEATURE] Add support for Slack user groups in rotations #115

Closed gabriel-loo closed 4 months ago

gabriel-loo commented 6 months ago

Slack provides the ability to create user groups to group multiple people together under the same @ handle (e.g. @designers). In some cases, duty rotations apply to user groups rather than to individuals. For example, if I want to assign bug triaging responsibilities to a different team each week, I'd like set that up with the following command:

@dienstplan create bug-triaging @teamA @teamB @teamC
It is your team's turn this week to triage new bug tickets in the backlog.

I think the command currently fails because the formatting is different between mentioning user groups and individual users.

User group ID format: <!subteam^S123ABC456> Individual user ID format: <@U123ABC456>

Could dienstplan be updated to support rotating Slack user groups in addition to individual users?

pilosus commented 6 months ago

Hi @gabriel-loo!

I think we can support user groups.

There are a few things to consider:

  1. The Slack API endpoint for listing users of a user group usergroups.users.list says nothing about the order. Is it deterministic? Is it guaranteed that requesting the endpoint multiple times yields the same results as long as no user added or removed? If it's deterministic, then we can rely on the endpoint without saving user ids of the group to the database and be sure round-robin rotations work properly. If it's not, then we will need to save the users to the database and subscribe to the events of the usergroup changes (new user added, user removed, etc.). We can probably use one of these:
  1. What happens if a user of a usergroup gets removed from the usergroup while the user is a current duty in dienstplan rotation? Probably, it should be an equivalent of @dienstplan update that recreates the rota and assigns current duty to the first user in the usergroup.
gabriel-loo commented 6 months ago

Hi @pilosus,

I was actually thinking of treating user groups handles the same way individual users are managed.

Using this example:

@dienstplan create bug-triaging @teamA @teamB @teamC
It is your team's turn this week to triage new bug tickets in the backlog.

This would first assign the rotation to @teamA (and not just the first user in team A).


@dienstplan rotate bug-triaging

This would set it to @teamB which is next in the rotation.


@dienstplan who bug-triaging

would show

Hey @teamB, you are an on-call person for `bug-triaging` rotation.
It is your team's turn this week to triage new bug tickets in the backlog.

(Note: we may have to switch it to "you are on call for..." rather than "you are the on-call person for...")

pilosus commented 6 months ago

@gabriel-loo ah, I see what you mean. Yes, it makes sense to support this kind of mention, i.e. dienstplan doesn't care if it's an individual user or a user group, it just uses the entity in rotation.

It should be probably easy to do: the regex here must be amended to something like:

(?s)(?<userid>\<(@|!subteam\^)[A-Z0-9]+\>)

but I haven't tested it myself.

Plus, the wording here.

If you want to draft a PR feel free to do so. Otherwise, I'd be able to do it myself in a couple of weeks.

pilosus commented 4 months ago

@gabriel-loo done in release 1.1.109