Skip to content

Bug with nested payload in FCM messages  #784

@alikhanz

Description

@alikhanz

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions