Hook to avoid unread topics management (related to nodebb-plugin-ignored-users).
-
Hi,
I would like to add the following functionality to nodebb-plugin-ignored-users:
- When you are ignoring a certain user, if that user replies in a topic you are following (or you are the OP of that thread) then ommit notifications and the topic showing on the unread page (adding +1 on the unread count also).
So, regarding to notifications, i was able to achieve the goal using this 2 filters:
- list itemfilter:notification.push
- list itemfilter:notifications.merge
For unread ommitment, i thought i could use filter:unread.build, as it was included in the docs (https://github.com/NodeBB/NodeBB/wiki/Hooks) but the hooks page seems out of date, and that hook seems to be removed on 1.1.0.
Is there any way i could avoid the topic becoming listed as unread by using any filter hook and delete that tid from the normal processing?
Thanks in advance @3rd-Party-Developers @administrators
-
@jarey said in Hook to avoid unread topics management (related to nodebb-plugin-ignored-users).:
filter:unread.build
Hook is not removed... it's just moved to middleware instead of the controller.
-
@pichalite thanks, i'll try with it and see if it solves my problem.
What is needed in order to update the hooks documentation? Would help in this cases, even thought this was my fault because of not searching too much.
Thanks again.
-
That's a good question. The format is a bit different than other hooks, to maintain compatibility with existing plugins. The hook right now is '
filter:*.build
', which isn't recognized by the generator (it would just see'filter:'
).We could either change the generator so that it recognizes that form of hook (we could filter out the variable pattern for a star), or change the hook to a format the generator recognizes, like
'filter:render.*'
, which would be a huge breaking change, but possibly better in the long-run. -
Seems that filter:unread.build was not the hook i was looking for because when a reply is made in a topic, the hook is not fired.
I'm looking for a hook that would let me stop the new post from increasing unread count and appearing in the unread list of a certain user.
Anyone knows what hook could i use?
Currently i'm having a look at: Topics/create.js-> Topics.Create if i can see where the unread management is made and if there's some hook i can use.
Thanks again.
EDIT: From now i have one candidate that is filter:sockets.sendNewPostToUids to the websocket notification, i think i'm lacking the unread persistence to the database right now.
EDIT2: Yes, as i said i'm now able to ommit the real time notification using filter:sockets.sendNewPostToUids, but the post is stored in the database in the unread hash. Just that detail to go! If anyone now some details on how that is made, it should help me a lot because i'm kind of stuck on that (can't see where it's done).
-
I'm a bit confused, i thought the hash containing the topic ids that are unread for a certain user was: uid:THE_UID:tids_unread. So when a user calls for the route /unread among other filters (ignored cids, ignored tids etc) that hash was included in the search and its results included in the unread result list.
What i got is 2 users, jarey and jareUser on my dev instance. One writes (jareUser), and the other receives the topics on his unread box.
So i got 1 unread topic on the jarey account, with uid:1, i can see it on the unread page, but the uid:1:tids_unread hash, does not exist on the database. Anyone knows what could be the case or if i'm completely wrong on my thinking?db.getCollection('objects').find({_key:"user:1"}) (1) ObjectId("579396cebf53a29647222904") 25 fields. jarey, online etc db.getCollection('objects').find({_key:"uid:1:tids_unread"}) Fetched 0 record(s) in 1ms
My aproach was to try not creating the uid:1:tids_unread with the tid where the reply its posted, (if it didn`t exists already) if the user replying is ignored... but that got me stucked.
-
You should be able to just call
Topics.markAsRead([tid], uid)
duringaction:post.save
It adds a sorted set member to
uid:X:tids_read
The unread count is taken from
(topics:recent + uid:X:tids_unread) - uid:X:tids_read
So, if it's recent and not read, then it's automatically unread.
-
Happy to help!