Closed paolodina closed 4 years ago
Is this for a Facebook-style notification inbox, where the user can view a list of items and choose which ones to read, and potentially read them out of order?
Personally, I'd consider application data such as messaging/notification inbox items to be separate from an event queue used for realtime delivery, and so I'd probably implement these things separately. In other words, build the inbox feature using its own database tables, and get all the user flows working (add, read, expire, etc) without any live updates. Then use django-eventstream only for the live updates.
This is just a personal preference though. Your way sounds like it would work fine, and it would use less data in the DB since you'd be sharing with django-eventstream's table. Your proposed changes to the lib seem small and reasonable if you want to create a PR.
BTW, another way to share tables could be to implement a custom storage class. Then instead of storing your long term app data in django-eventstream's tables, you could have django-eventstream read from your app's tables. I haven't really explored this yet though.
Ok, the proposed changes weren't easy to implement for me (they had side effects I wasn't able to accomodate in a generic way for a PR), I forked the repo and did the changes I needed. Not ideal but it worked.
Thanks for you support, I think this ticket can be closed.
Thanks for following up. I'm glad you got something working.
Hi, I'm trying to change how the event persistence works. The goal is is to keep track of unread events so that the user can retrieve unread messages. I'd appreciate any opinion on what I'm doing.
In my project each user has a dedicated channel identified by user pk. I was able to accomplish this with the following code:
urls.py:
channelmanager.py subclass:
To keep track of read/unread status I added a model and a post_save signal.
models.py
And this is the context processor I use to pass unread messages counter to the template:
It's a draft and I didn't test it well, but it seems to work. I have a couple of questions:
Questions:
EVENT_TIMEOUT
to, for example 1 year. Would it be possible to change the currentdef trim_event_log(self)
signature todef trim_event_log(self, event_timeout=EVENT_TIMEOUT)
, and use this value to get the cutoff?Event
model configurable insettings.py
, as you did withEVENTSTREAM_STORAGE_CLASS
? I'm using postgresql and was thinking to change the data field fromTextField
as currently is toJSONField
.If you consider these changes useful I and if you want, I could create a pull request.
Thanks