openhab / openhab-cloud

Cloud companion for openHAB instances
Eclipse Public License 2.0
315 stars 161 forks source link

Add new notification properties to `api/v1/notifications` endpoint #466

Closed mueller-ma closed 4 months ago

mueller-ma commented 4 months ago

It seems that the new notification properties haven't been added to the endpoint api/v1/notifications. This endpoint is used for the notification list and in the un-googled version of the Android app. I'm not sure if the actions should be shown in the notification list, but at least the title should be shown there.

mueller-ma commented 4 months ago

@digitaldan

digitaldan commented 4 months ago

Yeah, title for sure would be a good one. I refactored the cloud code to care as little as possible about the notification payload, basically to act as a pass through medium from openHAB to the device, only touching/modifying the data when necessary. Was hoping to not have to update it overtime we add a new payload value. I think i might store the raw JSON payload in mongod, and return a combined result (so all keys). I'll take a look.

digitaldan commented 4 months ago

with #467 notifications would return what they did before, plus the raw payload of what openHAB sent, for example

{
    "_id": "668096d5fc15ce1a1d37f103",
    "message": "Test Message",
    "payload": {
        "media-attachment-url": "item:imageItem",
        "message": "Test Message",
        "title": "Test",
        "on-click": "ui:popup:widget:test",
        "actions": [
            {
                "title": "Button 1",
                "action": "command:myItem:ON"
            },
            {
                "title": "Button 2",
                "action": "ui:popup:widget:myWidget"
            }
        ]
    },
    "created": "2024-06-29T23:20:53.216Z",
    "__v": 0
}

Does this work for you ?

digitaldan commented 4 months ago

Additionally , in time, we can remove the duplicate fields like message, icon and severity from the original structure and just rely on the payload,.

mueller-ma commented 4 months ago

Yes, that works for me 👍 I'll update the Android app to use only payload and come back here when the app has been rolled out, so you can remove the old fields then.

digitaldan commented 4 months ago

Great, i'll deploy this today after i run a few more tests.

digitaldan commented 4 months ago

Thats deployed