fix: sync DrKLO report selection support
This commit is contained in:
parent
70e57b4d07
commit
840ef6237c
4 changed files with 93 additions and 0 deletions
|
|
@ -449,6 +449,36 @@ func TestTDesktopPassiveChannelStubs(t *testing.T) {
|
|||
if ok, err := r.onMessagesReportSpam(ownerCtx, inputPeerChannel(channel)); err != nil || !ok {
|
||||
t.Fatalf("messages.reportSpam = ok %v err %v, want true nil", ok, err)
|
||||
}
|
||||
if _, err := r.onMessagesReport(ownerCtx, &tg.MessagesReportRequest{
|
||||
Peer: inputPeerChannel(channel),
|
||||
}); err == nil || !strings.Contains(err.Error(), "MESSAGE_ID_REQUIRED") {
|
||||
t.Fatalf("desktop messages.report without ids err = %v, want MESSAGE_ID_REQUIRED", err)
|
||||
}
|
||||
androidReportOptions, err := r.onMessagesReport(
|
||||
WithClientInfo(ownerCtx, ClientInfo{
|
||||
Type: ClientTypeAndroid,
|
||||
AppVersion: "12.9.0 (69669) pbeta",
|
||||
}),
|
||||
&tg.MessagesReportRequest{Peer: inputPeerChannel(channel)},
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("android messages.report initial options: %v", err)
|
||||
}
|
||||
if choices, ok := androidReportOptions.(*tg.ReportResultChooseOption); !ok || len(choices.Options) == 0 {
|
||||
t.Fatalf("android messages.report initial options = %#v, want chooseOption", androidReportOptions)
|
||||
}
|
||||
if got := moderationReports.Reports(); len(got) != 1 {
|
||||
t.Fatalf("android initial report option discovery persisted reports = %+v, want only earlier reportSpam", got)
|
||||
}
|
||||
if _, err := r.onMessagesReport(
|
||||
WithClientInfo(ownerCtx, ClientInfo{Type: ClientTypeAndroid}),
|
||||
&tg.MessagesReportRequest{
|
||||
Peer: inputPeerChannel(channel),
|
||||
Option: []byte("spam"),
|
||||
},
|
||||
); err == nil || !strings.Contains(err.Error(), "MESSAGE_ID_REQUIRED") {
|
||||
t.Fatalf("android selected report option without ids err = %v, want MESSAGE_ID_REQUIRED", err)
|
||||
}
|
||||
reportOptions, err := r.onMessagesReport(ownerCtx, &tg.MessagesReportRequest{
|
||||
Peer: inputPeerChannel(channel),
|
||||
ID: []int{1},
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import (
|
|||
"github.com/iamxvbaba/td/tg"
|
||||
"github.com/iamxvbaba/td/tgerr"
|
||||
|
||||
compatandroid "telesrv/internal/compat/android"
|
||||
"telesrv/internal/domain"
|
||||
)
|
||||
|
||||
|
|
@ -52,6 +53,14 @@ func (r *Router) onMessagesReport(ctx context.Context, req *tg.MessagesReportReq
|
|||
return nil, err
|
||||
}
|
||||
if len(req.ID) == 0 {
|
||||
if compatandroid.OfferInitialMessageReportOptions(
|
||||
string(ClientTypeFrom(ctx)),
|
||||
len(req.ID),
|
||||
req.Option,
|
||||
req.Message,
|
||||
) {
|
||||
return reportResultForOption("")
|
||||
}
|
||||
return nil, tgerr.New(400, "MESSAGE_ID_REQUIRED")
|
||||
}
|
||||
if len(req.ID) > maxGetMessagesIDs || len(req.Option) > maxReportOptionLength || utf8.RuneCountInString(req.Message) > maxReportCommentLength {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue