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 devices field is not compatible with Sygnal #1947

Closed
1 of 2 tasks
vanyasem opened this issue Oct 28, 2024 · 5 comments · May be fixed by #1949
Closed
1 of 2 tasks

PushNotification's devices field is not compatible with Sygnal #1947

vanyasem opened this issue Oct 28, 2024 · 5 comments · May be fixed by #1949
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 mandatory devices field: https://github.com/famedly/matrix-dart-sdk/blob/v0.34.0/lib/src/utils/push_notification.dart#L20 which is not sent by Sygnal

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

See matrix-org/sygnal#319 for comments of the maintainer of Sygnal

As far as I could tell, despite being required, it's not used by the SDK in any capacity

I believe the confusion happened because of the following text in the matrix push gateway API spec: https://spec.matrix.org/v1.12/push-gateway-api/

This field is only marked as required for server-side endpoints of the push gateway, and should not be required on the client-side

I made a PR that makes the devices field optional: #1949

@vanyasem
Copy link
Author

vanyasem commented Oct 28, 2024

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

@vanyasem vanyasem changed the title PushNotification object is not compatible with Sygnal PushNotification's devices field is not compatible with Sygnal Oct 28, 2024
@vanyasem
Copy link
Author

vanyasem commented Oct 28, 2024

An example of an event_id_only push FCM message from Sygnal:

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

@krille-chan
Copy link
Contributor

Same with #1948

@vanyasem
Copy link
Author

vanyasem commented Nov 11, 2024

@krille-chan the documentation that you linked specifies the JSON model for the API endpoint /_matrix/push/v1/notify, for which the devices field is indeed mandatory

You misunderstood the meaning of the model linked above. It's a server-side model for the Push Gateway itself. It's not meant to be sent back to users devices

sygnal is a reference Push Gateway by the Matrix Foundation

The definition of "reference" is:

A software example of a specification, intended to help others implement their own version of the specification or find problems during the creation of a specification.

You can learn more about the meaning of a "reference implementation" here: https://en.wikipedia.org/wiki/Reference_implementation

Arguing that an official reference implementation is somehow wrong, and your specific interpretation of the documentation is right is really bold.

Just to be sure, the field in question has been discussed directly with the Matrix team, and they confirmed that devices is only mandatory on the server-side, and that it makes no sense to include it in the model when sending a notification back to the device. See matrix-org/sygnal#319 for more details

Your implementation is the only one that does that, yet you still choose to stand by your incorrect interpretation of the docs.

@vanyasem
Copy link
Author

Btw the correct documentation to link would be https://github.com/matrix-org/sygnal/blob/main/docs/applications.md#firebase-cloud-messaging, which specifies the client-side model for the push:

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

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

Successfully merging a pull request may close this issue.

2 participants