Skip to content

Commit b2ee5b5

Browse files
author
cuiko
committed
docs(contact): Cross-reference report reason keyword lists
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.
1 parent db26707 commit b2ee5b5

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

internal/action/contact/report.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ import (
99
"github.com/vika2603/telegram-cli/internal/ui"
1010
)
1111

12-
// ReportReasons are the keywords accepted by `tg contact report --reason`,
13-
// mapped (in the telegram layer) to a tg.ReportReasonClass.
12+
// ReportReasons are the keywords accepted by `tg contact report --reason`.
13+
// Keep this set in sync with reportReason() in internal/telegram/contacts.go,
14+
// which maps each keyword to a tg.ReportReasonClass — a keyword present here but
15+
// missing there would silently report as spam.
1416
var ReportReasons = map[string]bool{
1517
"spam": true,
1618
"violence": true,

internal/telegram/contacts.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,10 @@ func ReportPeer(ctx context.Context, api *tg.Client, resolver *peer.Resolver, q
138138
return nil
139139
}
140140

141-
// reportReason maps a validated reason keyword to a tg.ReportReasonClass.
141+
// reportReason maps a validated reason keyword to a tg.ReportReasonClass. Keep
142+
// the cases in sync with ReportReasons in internal/action/contact/report.go;
143+
// the action layer validates the keyword before it reaches here, so the default
144+
// is only a safety net.
142145
func reportReason(reason string) tg.ReportReasonClass {
143146
switch reason {
144147
case "violence":

0 commit comments

Comments
 (0)