server
server copied to clipboard
Update Message for ongoing tasks
Is your feature request related to a problem? Please describe. My backup-program creates multiple notifications. Currently each time a new state is reached, a new notification is created. This creates many single entries that can get quiet cluttered.
Describe the solution you'd like If an app creates a message, it should return the messageid. This messageid can then be used to update said message. The client simply acts as if a new message arrived, and removes the old one.
This could be achieved by deleting the previous message before sending the new one. Adding a message already returns the message id.
http POST "https://p.example.org/message?token=Axxxxxxxxx&message=test" | jq .
{
"id": 195,
"appid": 3,
"message": "test",
"title": "title",
"priority": 0,
"date": "2020-04-20T18:36:51.08118495+02:00"
}
I don't think that many users need this, therefore I'm waiting for more user feedback for this feature.
Oh yeah, i could have checked that.
I experimented with the delete command, but it does not work. I always get a 401 code. I have created the curl command with your swagger documentation (inclusive tokens and so on)
curl -X DELETE "https://domain.com/gotify/message/134" -H "accept: application/json" -H "X-Gotify-Key: cooltoken"
Do you know why this is wrong?
(i can send using the token, so the url and token should be valid)
You need a client token to delete messages, application tokens are only allowed to send messages.
Ah that was the error, now it works
I wrote a small script that generally archieves what i want, with one (two) drawbacks.
The "problem" is that the clients do not get notified about deleted messages, they need to refresh before the deleted messages (and their notifications) vanish. This basically results in a cleaned history, but does not fix the problem i am facing.
The second thing is, and this is not really important but to keep in mind, you need an app token and a client token
The script if anyone is interested: https://gist.github.com/newhinton/a53541611f181863384652726ee049eb
See https://github.com/gotify/server/issues/266
I like this idea. I have very similar use cases.
I think it would make sense if applications could delete their own messages:
- To me it was quite surprising that they can't: I spend quite a while figuring out why
DELETE
returned 401 before discovering it needs a client token. - If you want to give a script delete access, it needs a client token. But that gives it access to all messages. With application tokens the server could check that the message actually belongs to the application that wants to modify it.
(Being able to update messages using PUT
seems neater than DELETE
+POST
, but I'm having a hard time coming up with actual scenarios where deleting+posting a new message wouldn't work. I guess you could use it to show that some alarm has been resolved without having it pop back to the top of al messages?)
i would not like my applications to be able to delete sent notifications
This could be achieved by deleting the previous message before sending the new one. Adding a message already returns the message id.
http POST "https://p.example.org/message?token=Axxxxxxxxx&message=test" | jq . { "id": 195, "appid": 3, "message": "test", "title": "title", "priority": 0, "date": "2020-04-20T18:36:51.08118495+02:00" }
I don't think that many users need this, therefore I'm waiting for more user feedback for this feature.
Such update API exists in Telegram which is quite handy, example of the use case is Frigate NVR event:
- When object is detected - initial notification sent with snapshot
- Frigate detection processing is finished and final snapshot created with detected object
- Previous notification message (with saved ID) is updated with new snapshot