appleboy / gorush

A push notification server written in Go (Golang).
MIT License
7.99k stars 841 forks source link

Bug with nested payload in FCM messages #784

Closed alikhanz closed 3 months ago

alikhanz commented 3 months ago

Hello! When you migrate to official FCM client, field type Data in message changed from map[string]interface{} to map[string]string. And you changed json.Marshall(message) to fcm message structure. And nested structures in Data field now converting to golang structures. Bug here: https://github.com/appleboy/gorush/blob/master/notify/notification_fcm.go#L95

See how Sprintf works with maps: https://go.dev/play/p/MvW0VpkGM3v

If i send structure like this:

{
  "data": {
    "someField": {
      "innerField": "test",
      "innerField2": "test",
    }
  }
}

It will be converted to incorrect string:

someField = "map[field1:test field2:test]"

I propose solution for better backward compatibility with json.Marshall for non-string fields. I'll create PR

appleboy commented 3 months ago

https://github.com/appleboy/gorush/releases/tag/v1.18.4