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

PushNotification's counts field is not compatible with Sygnal #1948

Closed
1 of 2 tasks
vanyasem opened this issue Oct 28, 2024 · 4 comments
Closed
1 of 2 tasks

PushNotification's counts field is not compatible with Sygnal #1948

vanyasem opened this issue Oct 28, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@vanyasem
Copy link

vanyasem commented Oct 28, 2024

Checklist

  • I could not find a solution in the documentation, the existing issues or discussions.
  • I already asked for help in the chat

In which Project did the bug appear?

matrix-dart-sdk

On which platform did the bug appear?

Android, iOS

SDK Version

0.34.0

Describe the problem caused by this bug

PushNotification object in martix-dart-sdk is not compatible with the reference implementation of a Push Gateway for Matrix called Sygnal

The PushNotification object in the SDK has a separate counts field that holds a PushNotificationCounts object containing unread and missed_calls fields.

However, Sygnal sends unread and missed_calls fields at the root of the model, which means that they are not recognized by martix-dart-sdk:

An example of an event_id_only push FCM message sent from Sygnal:

{
  "unread": "1",
  "missed_calls": null,
  "prio": "high",
  "event_id": "$3957tyerfgewrf384",
  "room_id": "!slw48wfj34rtnrf:example.org"
}

I have only tested the GCM (FCM) implementation of Sygnal, but by reading the appropriate source code, I can confirm that this issue affects APN notifications as well

Related to #1947

@vanyasem vanyasem added the bug Something isn't working label Oct 28, 2024
@vanyasem
Copy link
Author

You can send a fake test notification to a device with curl: https://github.com/matrix-org/sygnal/blob/v0.15.1/docs/troubleshooting.md#sending-a-notification-to-sygnal-manually-with-curl

Sending the following notification body:

{
  "notification": {
    "event_id": "$3957tyerfgewrf384",
    "room_id": "!slw48wfj34rtnrf:example.org",
    "type": "m.room.message",
    "sender": "@exampleuser:example.org",
    "sender_display_name": "Major Tom",
    "room_name": "Mission Control",
    "room_alias": "#exampleroom:example.org",
    "prio": "high",
    "content": {
      "msgtype": "m.text",
      "body": "I'm floating in a most peculiar way."
    },
    "counts": {
      "unread": 2,
      "missed_calls": 1
    },
    "devices": [
      {
        "app_id": "<APP ID HERE>",
        "pushkey": "<PUSHKEY HERE>",
        "pushkey_ts": 12345678,
        "data": {},
        "tweaks": {
          "sound": "bing"
        }
      }
    ]
  }
}

Results in the following message being transmitted to FCM by Sygnal:

{
  "sender_display_name": "Major Tom",
  "room_name": "Mission Control",
  "sender": "@exampleuser:example.org",
  "unread": "2",
  "missed_calls": "1",
  "prio": "high",
  "type": "m.room.message",
  "event_id": "$3957tyerfgewrf384",
  "content_body": "I'm floating in a most peculiar way.",
  "room_alias": "#exampleroom:example.org",
  "room_id": "!slw48wfj34rtnrf:example.org",
  "content_msgtype": "m.text"
}

This logic is defined here: https://github.com/matrix-org/sygnal/blob/v0.15.1/sygnal/gcmpushkin.py

@krille-chan
Copy link
Contributor

Well Sygnal is then sending a different model which is not part of the spec. You have to bring your own data model then. The correct model is described here: https://spec.matrix.org/v1.12/push-gateway-api/#post_matrixpushv1notify and the matrix dart sdk is parsing it correctly.

@krille-chan krille-chan closed this as not planned Won't fix, can't repro, duplicate, stale Oct 29, 2024
@nico-famedly
Copy link
Member

The counts field isn't required in the link above, is it?

@vanyasem
Copy link
Author

See my reply in #1947 and #1949 : #1947 (comment), #1949 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants