[feature] implement scheduled message unpublishing via DELETE request to /{topic}/{messageId}#1142
Conversation
/topic/{messageId}/{topic}/{messageId}
|
+1 for unpublishing scheduled messages. My usecase is rescheduling reminders and due date notifications. |
|
This is awesome. I will 100% get this in for the next release. I already rebased this on top of the main branch locally, but I have a question. Given the latest feature (https://docs.ntfy.sh/publish/#updating-deleting-notifications) already implements the DELETE endpoint, my thinking was this:
Analogously, publishing to /topic/message-id should update the message in the cache if it's not published yet (assuming it has a Delay), or otherwise treat it as a new message?! I'm a bit fuzzy on what should happen here. @wunter8 Thoughts? |
|
I'm very excited about implementing updates on unpublished messages, because that can serve as a dead man's switch |
|
I think what you described, binwiederhier, is the same as what I originally considered here: #303 (comment) Copying some thoughts I had previously: I think we should only keep 1 scheduled message for a particular sequence_id at a time. So a first message can be scheduled with I think deleting entirely might be better than modifying it's timestamp field or published field because if we change the DB to show the message was published and don't send anything to the client (since it wasn't actually sent), if the client polls the server for all messages in the cache for a topic, they'd get a bunch of scheduled revisions that were never supposed to be sent. If we delete the revisions, using the subscriber API, you could still check for scheduled messages on a particular topic, but you wouldn't be able to see a history of revisions for the scheduled message, only the most recent. However, I'm now considering the scenario when you send (assuming all these have the same Option A: the scheduled message is deleted/unscheduled I think clearing a message doesn't have the same problem because you can't clear something that hasn't sent yet. So I think just DELETE has these extra considerations |
|
One way to distinguish between deleting an existing message and deleting a scheduled message could be to require setting a delay when deleting a scheduled message (even though the delete will happen immediately) So would delete an existing/already sent message with And would delete a scheduled/delayed message with |
|
Your comment is great. It's very complicated. My brain is not working right because I didn't sleep. I will re-read later/tmr and respond. I think we somehow need to restrict sequences with scheduled messages, so that there can never be more than one scheduled message in a sequence in the DB. This is what I was trying to come up with: |
|
@wunter8 I tried re-reading your comment and even with "awake-brain" I still have trouble understanding it. So let me try to analyze it one paragraph at a time:
Yes! So basically, if you try to update or delete a scheduled message with a sequence ID, we must look it up and delete the previous versions of it:
Agreed. We must ensure that only one scheduled message per sequence ID exists in the database.
So if we do
(I renamed the options to 1..4 to avoid confusion with message A + B.) This is the scenario you described: Honestly, I don't know. This is clearly ambigious. Maybe unpublish is a separate API endpoint, like
👍 |
|
Yes, you understood it all correctly! Did you see my second message with a possible way of resolving the ambiguity? |
I did! And I hate it, haha. I just had a realization regarding the 4 options. How about this: |
|
Deleting a sent message feels like it should be different from deleting a scheduled message. But I can also understand your perspective since we're dealing with whole "sequence_ids" and not individual messages |
|
This works wonderfully. 100% written by Cursor: #1556
I read the code and it all looks sound. I need to update the attachment deletion for unpublished messages, then I'll merge it and deploy it to staging. |
|
Superseded by #1556 Thanks @GamerGirlandCo for implementing this. Due to the complexity of this (with the other "update and delete notifications" code since added), I can't merge this. I gave you credit in the release notes! |
This PR contains the following updates: | Package | Update | Change | |---|---|---| | [binwiederhier/ntfy](https://ntfy.sh/) ([source](https://github.com/binwiederhier/ntfy)) | minor | `v2.15.0` → `v2.16.0` | --- >⚠️ **Warning** > > Some dependencies could not be looked up. Check the Dependency Dashboard for more information. --- ### Release Notes <details> <summary>binwiederhier/ntfy (binwiederhier/ntfy)</summary> ### [`v2.16.0`](https://github.com/binwiederhier/ntfy/releases/tag/v2.16.0) [Compare Source](binwiederhier/ntfy@v2.15.0...v2.16.0) This release adds support for [updating and deleting notifications](https://docs.ntfy.sh/publish/#updating-deleting-notifications), [heartbeat-style / dead man's switch notifications](https://docs.ntfy.sh/publish/#scheduled-delivery), [custom Twilio call format](https://docs.ntfy.sh/config/#phone-calls), and makes `ntfy serve` work on Windows. It also adds a "New version available" banner to the web app. This one is very exciting, as it brings a lot of highly requested features to ntfy. **Features:** - Support for [updating and deleting notifications](https://docs.ntfy.sh/publish/#updating-deleting-notifications) ([#​303](binwiederhier/ntfy#303), [#​1536](binwiederhier/ntfy#1536), [ntfy-android#151](binwiederhier/ntfy-android#151), thanks to [@​wunter8](https://github.com/wunter8) for the initial implementation) - Support for heartbeat-style / [dead man's switch](https://en.wikipedia.org/wiki/Dead_man%27s_switch) notifications aka [updating and deleting scheduled notifications](https://docs.ntfy.sh/publish/#scheduled-delivery) ([#​1556](binwiederhier/ntfy#1556), [#​1142](binwiederhier/ntfy#1142), [#​954](binwiederhier/ntfy#954), thanks to [@​GamerGirlandCo](https://github.com/GamerGirlandCo) for the initial implementation) - Configure [custom Twilio call format](https://docs.ntfy.sh/config/#phone-calls) for phone calls ([#​1289](binwiederhier/ntfy#1289), thanks to [@​mmichaa](https://github.com/mmichaa) for the initial implementation) - `ntfy serve` now works on Windows, including support for running it as a Windows service ([#​1104](binwiederhier/ntfy#1104), [#​1552](binwiederhier/ntfy#1552), originally [#​1328](binwiederhier/ntfy#1328), thanks to [@​wtf911](https://github.com/wtf911)) - Web app: "New version available" banner ([#​1554](binwiederhier/ntfy#1554)) </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0Mi42OS4yIiwidXBkYXRlZEluVmVyIjoiNDIuNjkuMiIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiaW1hZ2UiXX0=--> Reviewed-on: https://gitea.alexlebens.dev/alexlebens/infrastructure/pulls/3334 Co-authored-by: Renovate Bot <renovate-bot@alexlebens.net> Co-committed-by: Renovate Bot <renovate-bot@alexlebens.net>
Test cases are included.
Related: #303
closes #954