Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed 405 error when send list message #461

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions mdtest/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,43 @@ func handleCmd(cmd string, args []string) {
if err != nil {
log.Errorf("Error changing chat's pin state: %v", err)
}
case "sendlist":
if len(args) < 1 {
log.Errorf("Usage: sendlist <jid>")
return
}
recipient, ok := parseJID(args[0])
if !ok {
return
}
msg := &waProto.Message{
ListMessage: &waProto.ListMessage{
Description: proto.String("Description"),
ButtonText: proto.String("ButtonText"),
ListType: waProto.ListMessage_SINGLE_SELECT.Enum(),
Sections: []*waProto.ListMessage_Section{
{
Title: proto.String(""),
Rows: []*waProto.ListMessage_Row{
{
Title: proto.String("Row 1 title"),
RowId: proto.String("Row1"),
},
{
Title: proto.String("Row 2 title"),
RowId: proto.String("Row2"),
},
},
},
},
},
}
resp, err := cli.SendMessage(context.Background(), recipient, msg)
if err != nil {
log.Errorf("Error sending message: %v", err)
} else {
log.Infof("Message sent (server timestamp: %s)", resp.Timestamp)
}
}
}

Expand Down
5 changes: 3 additions & 2 deletions send.go
Original file line number Diff line number Diff line change
Expand Up @@ -644,8 +644,9 @@ func getButtonAttributes(msg *waProto.Message) waBinary.Attrs {
return waBinary.Attrs{}
case msg.ListMessage != nil:
return waBinary.Attrs{
"v": "2",
"type": strings.ToLower(waProto.ListMessage_ListType_name[int32(msg.ListMessage.GetListType())]),
"v": "2",
// Force list message sent as product_list instead of single_select
"type": strings.ToLower(waProto.ListMessage_ListType_name[int32(*waProto.ListMessage_PRODUCT_LIST.Enum())]),
}
default:
return waBinary.Attrs{}
Expand Down
Loading