Skip to content

feat(chat): Add fine-grained admin rights to promote#26

Merged
cuiko merged 1 commit into
vika2603:mainfrom
cuiko:feat/admin-fine-grained-rights
Jun 4, 2026
Merged

feat(chat): Add fine-grained admin rights to promote#26
cuiko merged 1 commit into
vika2603:mainfrom
cuiko:feat/admin-fine-grained-rights

Conversation

@cuiko

@cuiko cuiko commented Jun 3, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • tg chat admin promote previously granted a fixed broad admin set. Add a --rights flag taking admin-rights keywords (info, post, edit, delete, ban, invite, pin, add_admins, anonymous, call, topics, post_stories, edit_stories, delete_stories) so callers can grant exactly the rights they want.
  • Omitting --rights keeps the previous broad default set (backward compatible). --rights is rejected on demote.
  • promote/demote now return a RightsRow; the new granted field surfaces the applied admin rights in both JSON (--json) and table output.

Test plan

  • go build ./..., go vet ./..., golangci-lint run, go test ./...
  • Unit tests: rights pass-through, unknown-keyword rejection, --rights + demote rejection.
  • Live verification in a fixture supergroup:
    • promote --rights pin,delete / --rights info,invitegranted echoes the requested set in canonical order; member role flips to admin.
    • Behavioral: granting only info let the target edit group info; re-promoting with only pin then returned CHAT_ADMIN_REQUIRED on the same edit — confirming the mask is actually enforced, not just echoed.
    • demote → role returns to member, no granted field.

`tg chat admin promote` granted a fixed broad admin set with no way to
scope it. Add a --rights flag accepting admin-rights keywords (info, post,
edit, delete, ban, invite, pin, add_admins, anonymous, call, topics,
post/edit/delete_stories) so callers grant exactly the rights they want;
omitting --rights keeps the previous broad default. promote/demote now
return a RightsRow whose `granted` field surfaces the applied rights in
both JSON and table output.

Also scrub a stray test account name from the launchd label doc comment.
@cuiko
cuiko merged commit 43e1b7b into vika2603:main Jun 4, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant