mrchainman / Gotify-Nextcloud

A python script that fetches notifications from the nextcloud talk api and pushes them to a gotify server.
GNU General Public License v2.0
11 stars 4 forks source link

Persistent Storage #3

Open mrchainman opened 4 years ago

mrchainman commented 4 years ago

We could achieve persistent storage, by dumping the pushed notifications list to a json file and trying to load in on startup, @berdosi What do you think about that?

berdosi commented 4 years ago

I thought about it, and I consider it as a nice-to-have:

The app re-sending the notifications looks somewhat sloppy, indeed.

However, this happens when someone restarts the app, without having marked their notifications as read. I would say that this is even useful during development, but doesn't normally happen on the everyday usage (as the app isn't supposed to be restarted that often)

mrchainman commented 4 years ago

The problem is that if the nextcloudserver is unavailable even for just a moment the app crashes, i have it running as a systemd service with autorestart and it restarts every other day, as my server is quite slow. It would be 5 lines of code to implement it, so not a big deal.

mrchainman commented 4 years ago

@berdosi I noticed that it does not only happen when restarting the app. Everytime a new notification is pulled, all the ones not marked as read are resend.

berdosi commented 4 years ago

Hm. Perhaps m["ocs"]["data"][i]["notification_id"] is treated as an object, and its equality is tested by reference? If so, converting it explicitly to a string could solve the issue. I'm not very experienced in Python, my argument may be invalid.

mrchainman commented 4 years ago

Haven't thought about that. I will look into it as soon as I have the time.