diff --git a/joint_teapot/app.py b/joint_teapot/app.py index 139e709..338b8e5 100644 --- a/joint_teapot/app.py +++ b/joint_teapot/app.py @@ -294,6 +294,36 @@ def create_personal_channels_on_mm( tea.pot.create_channels_for_individuals(invite_teaching_team) +@app.command( + "update-group-channels-on-mm", + help="update Mattermost channels for student groups based on team information on Gitea; only add missing members", +) +def update_group_channels_on_mm( + prefix: str = Option("", help="Only process repositories starting with this prefix"), + suffix: str = Option("", help="Only process channels ending with this suffix"), + update_teaching_team: bool = Option(True, "--update-teaching-team/--no-update-teaching-team", help="Whether to update teaching team"), + dry_run: bool = Option(False, "--dry-run/--no-dry-run", help="Dry run: show what would be added without making changes"), +) -> None: + groups = { + group_name: members + for group_name, members in tea.pot.gitea.get_all_teams().items() + if group_name.startswith(prefix) + } + logger.info(f"{len(groups)} group channel(s) to update" + (f" with suffix {suffix}" if suffix else "")) + tea.pot.mattermost.update_channels_for_groups(groups, suffix, update_teaching_team, dry_run) + + +@app.command( + "update-personal-channels-on-mm", + help="update personal Mattermost channels for every student; only add missing members", +) +def update_personal_channels_on_mm( + update_teaching_team: bool = Option(True, "--update-teaching-team/--no-update-teaching-team", help="Whether to update teaching team"), + dry_run: bool = Option(False, "--dry-run/--no-dry-run", help="Dry run: show what would be added without making changes"), +) -> None: + tea.pot.mattermost.update_channels_for_individuals(tea.pot.canvas.students, update_teaching_team, dry_run) + + @app.command( "create-webhooks-for-mm", help="create a pair of webhooks on gitea and mm for all student groups on gitea, "