How to filter out previously seen and read activities while retrieving notifications?

折月煮酒 提交于 2021-02-10 19:00:46

问题


In my app We have notification feed for users, with grouping formula

{{ verb }}_{{ time.strftime('%Y-%m-%d') }}

When User1 notifications are retrieved, it is having 1 notification for a “like” action. “Like” notification is having 3 activities, means three users have liked user1’s post. So Notification text displayed is:

3 users likes your post

User1 notification are marked read and seen, After that 2 more users like user1’s post. Now when user1 retrieve notifications, He will get 1 notification and there are 5 activities in the group. Actor count for group is 5.

So Notification text displayed is:

5 users likes your post

As User1 have already seen previous 3 activities and already read those notifications, those are get repeated again. Only two activities are new but User1 is still getting all the 5 activities. Because activities do not know they are seen/read before.

It is still counting older seen and read activities in the group. Can we skip these previously seen and read activities while retrieving notifications ?


回答1:


Read state is kept at the activity group level and it resets from read to unread each time the group is updated (when a new activity is added). So a straight answer to what you are asking would be no, it's not possible to only retrieve the new activities in a group.

From how you describe things, it sounds like you don't really care about grouping and only want to notify about new events. If that's the case you can try to group by {{ id }} so that each activity group will always have 1 activity.



来源:https://stackoverflow.com/questions/57767410/how-to-filter-out-previously-seen-and-read-activities-while-retrieving-notificat

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!