notification client does not respect json_encoder settings
popbones opened this issue · 2 comments
Currently when calling the notify method on a pusher client with custom JSON encoder specified, that json_encoder
is not used by the underlying notification_client
, which is pretty inconvenient.
The json_encoder
is used when triggering events to encode the payload of each event as a string, which is then sent in the json body of the request itself. Only this payload is encoded by the json_encoder
. For example, if we .trigger("c", "e", { "foo": "bar" })
then the json of the request is
{"name": "e", "channels": ["c"], "data": "{\"foo\": \"bar\"}"}
Note that data
is just a string – this is the only bit that gets touched by the json_encoder
. The push notification API doesn't have this extra level of encoding, everything is just in the root JSON object. i.e. if we .trigger(["i"], { "foo": "bar" })
the body of the response is just
{"interests": ["i"], "foo": "bar"}
There's no double encoding.
That being said, what is your use case for using the json_encoder
for the notify? It certainly might be worth us looking at utilising it regardless.
Closing because I think @callum-oakley's response explains the current state well, and there has been no more discussion.