Skip to content

feat(contact): Add contact report to report a peer, with optional ban#31

Merged
cuiko merged 3 commits into
vika2603:mainfrom
cuiko:feat/contact-report
Jun 5, 2026
Merged

feat(contact): Add contact report to report a peer, with optional ban#31
cuiko merged 3 commits into
vika2603:mainfrom
cuiko:feat/contact-report

Conversation

@cuiko

@cuiko cuiko commented Jun 5, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • tg contact report <ref> reports a user/bot/group/channel to Telegram via account.reportPeer.
  • --reason selects the category: spam (default), violence, porn, child-abuse, copyright, fake, drugs, personal-details, geo-irrelevant, other.
  • --message attaches an optional moderation comment; --block also blocks the peer (contacts.block) after a successful report.
  • Confirmation prompts unless --yes, mirroring block/ban. Routes through the daemon (contact.report) like the other contact mutations.

Naming

  • The block flag is --block (not --ban): it calls contacts.block. Terminology is kept consistent across the CLI — "ban" = group/channel scope (chat ban/unban, channels.editBanned), "block" = account scope (contact block/unblock, report --block, contacts.block).

Notes

  • A report has no read-back: account.reportPeer returns only a bool and Telegram exposes no way to list submitted reports. Success = the call returns without error. The --block side effect is verifiable via contact list --blocked.

Test plan

  • go build ./..., go vet, golangci-lint run, go test ./...
  • Unit: reason defaulting to spam, unknown-reason rejection, --message/--block pass-through, decline-skips-dispatch; contact.report added to the daemon registered-methods test.
  • Live (end-to-end, via the daemon): contact report <peer> --reason spam --block --yes (then run as --ban pre-rename) against a real spam DM succeeded; the peer then appeared in contact list --blocked (blocked count 12 → 13), confirming the report call succeeded and the block took effect.

cuiko added 3 commits June 5, 2026 16:35
`tg contact report <ref>` reports a user/bot/group/channel to Telegram via
account.reportPeer. --reason picks the category (spam default; violence, porn,
child-abuse, copyright, fake, drugs, personal-details, geo-irrelevant, other),
--message attaches a moderation comment, and --ban also blocks the peer after
a successful report. Confirmation prompts unless --yes, mirroring block/ban.

Routes through the daemon (contact.report) like the other contact mutations.
The accepted --reason keywords live in both ReportReasons (action, validation)
and reportReason (telegram, mapping); the layers can't share a source. Add
sync notes so adding a reason to one without the other doesn't silently report
as spam.
The flag invokes contacts.block, not channels.editBanned, so call it --block.
This keeps the terminology unambiguous: "ban" is group/channel scope
(chat ban/unban), "block" is account scope (contact block/unblock, report
--block). Also reword the chat ban help so "block" isn't used for a group ban.
@cuiko
cuiko merged commit 3fb05d9 into vika2603:main Jun 5, 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