open-zaak / open-notificaties

API voor ontvangen en distribueren van notificaties
Other
0 stars 8 forks source link

abonnement filter key stored as snake_case #171

Closed paul-ritense closed 3 weeks ago

paul-ritense commented 2 months ago

In the Notifications API when updating an abonnement the key in the filters is stored as snake_case. objectType is stored as object_type, while filtering on objecttype only works with objectType in camelCase. Steps to reproduce:

See an example notifications_API.txt with curl in the attachment.

joeribekker commented 1 month ago

This ticket was approved by DH so it can be picked up.

JanBrek commented 1 month ago

@joeribekker Any estimation for when this will be picked up?

joeribekker commented 1 month ago

It will be discussed tomorrow, I know more by then

joeribekker commented 1 month ago

So, the tasks here are:

annashamray commented 3 weeks ago

This bug happens because of inconsistency of using camelCase and snake_case in 3 places:

As is:

  1. In the Objects API: when we register a kanaal (with register_kanalen management command) it's created with name objecten and kenmerken ["object_type"]
  2. In the Notifications API: when we create or update an abonnement via API its filters are always converted to snake_case, i.e. even if it's created with "filters" : {"objectType": <some-url>}, the filter will be saved as object_type
  3. In the Objects API: when an object is created, the notification is sent with "kenmerken": {"objectType": <some-url>}, because Objects API camelizes the notification message before sending it to Notifications API

And then Notifications API can't match abonnement,filters and notification,kenmerken

Possible solutions

  1. Leave everything as it is, and just improve matching in Notifications API, so it could process and compare both camelCase and snake_case. I think it's the easiest solution, which won't affect much.

  2. Make everything cameCase as Joeri suggested. In this case we will have to make quite a lot of changes including data migrations:

    • Objecttypes API: create kanaal with kenmerken ["objectType"]
    • Notifications API: make data migration to change existing objecten kanaal
    • Notifications API: save Abonnementen filters with camelCase (this one is quite tricky to be honest, I don't know how to do it easily without switching renderer and parser)
    • Notifications API: make data migration to change existing abonnementen filters

Which one should we choose? @joeribekker @alextreme Could you help me please?

alextreme commented 3 weeks ago

@annashamray considering the impact of Joeri's suggestion lets go with the first solution you suggested.