Skip to content

Commit

Permalink
fix: remove chat_id and uid_type from outcoming message of notificati…
Browse files Browse the repository at this point in the history
…on v2 (#63)
  • Loading branch information
crispgm authored Dec 13, 2023
1 parent 26ed303 commit d08380b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
2 changes: 1 addition & 1 deletion api_notification.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (bot *Bot) PostNotificationV2(om OutcomingMessage) (*PostNotificationV2Resp
return nil, ErrBotTypeError
}

params := BuildOutcomingMessageReq(om)
params := buildOutcomingNotification(om)
var respData PostNotificationV2Resp
err := bot.PostAPIRequest("PostNotificationV2", bot.webhook, false, params, &respData)
return &respData, err
Expand Down
31 changes: 31 additions & 0 deletions message_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,34 @@ func BuildOutcomingMessageReq(om OutcomingMessage) map[string]interface{} {
params["content"] = content
return params
}

func buildOutcomingNotification(om OutcomingMessage) map[string]interface{} {
params := map[string]interface{}{
"msg_type": om.MsgType,
}
if len(om.RootID) > 0 {
params["root_id"] = om.RootID
}
content := make(map[string]interface{})
if om.Content.Text != nil {
content["text"] = om.Content.Text.Text
}
if om.Content.Image != nil {
content["image_key"] = om.Content.Image.ImageKey
}
if om.Content.ShareChat != nil {
content["share_open_chat_id"] = om.Content.ShareChat.ChatID
}
if om.Content.Post != nil {
content["post"] = *om.Content.Post
}
if om.MsgType == MsgInteractive && om.Content.Card != nil {
params["card"] = *om.Content.Card
}
if len(om.Sign) > 0 {
params["sign"] = om.Sign
params["timestamp"] = strconv.FormatInt(om.Timestamp, 10)
}
params["content"] = content
return params
}

0 comments on commit d08380b

Please sign in to comment.