userDigest.getUsersInterval(uid) returns false even if default digest is set to daily
-
I'm trying to get user digest interval by uid.
there is a user digest library here to be used
const userDigest = require.main.require('./src/user/digest');
and there is a function
Digest.getUsersInterval = async (uids) => {...
that returns the users digest interval
My problem is that this functions returns false, if user has set the digest to false, and also return false if the user has the default value set, and default value is different to "off" (daily or weekly or monthly). So I can't tell the difference if a user is subscribed to digest or not.
Am I doing this query wrong? should I be using another library / function ?
-
@Sebastián-Cisneros I just noticed one thing related to this issue.
if a users sets digest to "off", digest are not actually deactivated but forced to "default". So there is no real way do unsusbcribe to digest if digest default value if different to "off" .
is this right? or Am I gettting it wrong?
-
@baris I'm actually looking to get the digest setting of one uid.
what I just noticed is that, if you set in ACP the default "subscribe to digest" value to other than "OFF", indivudual users can't avoid receiving these digest. If a user sets in his personal profile settings "subscribe to digest" to "OFF" , and default value is "weeekly" the user will get the digest, event if the usr has set it to "OFF", beacuse it seems that "OFF" seams to be the same as Default.
-
-
@baris are you sure? if you check the source code here
NodeBB/src/user/digest.js at master · NodeBB/NodeBB
Node.js based forum software built for the modern web - NodeBB/src/user/digest.js at master · NodeBB/NodeBB
GitHub (github.com)
const settings = await Promise.all([ db.isSortedSetMembers('digest:day:uids', uids), db.isSortedSetMembers('digest:week:uids', uids), db.isSortedSetMembers('digest:biweek:uids', uids), db.isSortedSetMembers('digest:month:uids', uids), ]); const interval = uids.map((uid, index) => { if (settings[0][index]) { return 'day'; } else if (settings[1][index]) { return 'week'; } else if (settings[2][index]) { return 'biweek'; } else if (settings[3][index]) { return 'month'; } return false; });
you can see that is only asking if the setting is day, week, biweek, or month. Anything different from that is false. So Off and default are the same (false)
I will be doing a clean install of nodebb tomorrow in a new enviroment, and will tetst it, but Im pretty sure that is how is working now (Off = Default).
-
@Sebastián-Cisneros The code you pasted isn't used to determine who to send the digest emails to, it is only used to show the setting of the user in the acp page at https://community.nodebb.org/admin/manage/digest.
If they set their setting to
off
thenDigest.getSubscribers
will not consider that user for the digest. -
@baris I recommend you giving this a test. I just made a clean nodebb 2.0 install, and its working like I'm telling you, off = default , so if user sets digest to OFF, and default is set to weekly, the user will get the digest anyway.
-
This was my test, I've installed a clean nodebb 2.0 install in my local. I have 2 users, 1 admin, one regular user with email validated.
-
I've added a filter:email.send to persona theme just to consol.log when email is sent
-
with admin user, go to ACP, set digest default to weekly
-
with regular user go to front end user settings, and you will see the digest set weekly, this is ok, as its defaulted to weekly. In the same settings page make any changes to the profile, keep digest to weekly, save.
-
with admin user in ACP you can in MANAGE->DIGEST you can force send the digest, you also have in that page a column with "Subscription Type". If you search for the regular user there, you will see the subscription set to "week", if you click "resend digest" you will send the digest to that user, and you will see the console.log we've set before. This is OK so far.
-
with regular user go to front end user settings, and you will see the digest set weekly, this is ok, change it to OFF, and save.
-
with admin user in ACP go to MANAGE->DIGEST. If you search for the regular user there, you will see the subscription set to "System default". But wait.... the user has set it to OFF, here is the error. If you click "resend digest" the user will get the digest email, and the user has digest set to OFF.
I really this this is a problem on nodebb core. Let me know what you think.
-
-
As far as I know clicking
1
will always send a digest to that user because it uses the uid of the user directly. https://github.com/NodeBB/NodeBB/blob/master/src/socket.io/admin/digest.js#L19Clicking
2
should respect the settings of the users. Which one did you use for the testing? -
So I tested with the above config, I have two users admin (uid1) emailtest(uid 2).
// uid2 digest set to "weekly" // "resend button" sending to [ '2' ] // "weekly button" sending to [ '1', '2' ]
After changing emailtest digest setting to
off
uid2 digest set to "off" // "resend button" sending to [ '2' ] // "weekly button" sending to [ '1' ] // it didn't send to uid 2 since setting is off
-
@baris got it. I think you are right. Sorry about all the confussion. I did your testing and is working like you say. I will do more testing in the next few days, but I think you are right. I was testing with "1", and that one always send the digest. and "2" only sends the digest to the users that should received it.
-
@Sebastián-Cisneros here is my confussion,
if emailtest user has set digest to off, here you will see system default in the "subscription type" column. Shouldn't it say off? should the emailtest user have the option to set the digest back to nodebb default at some point (like adding a new option in the digest select "default")? just wondering....
-
@Sebastián-Cisneros Yeah I think that label should say off if the user set it to off in their settings. I will open an issue for that.
acp>manage>digest shows system default even if user sets their digest to off · Issue #10631 · NodeBB/NodeBB
https://community.nodebb.org/topic/16483/userdigest-getusersinterval-uid-returns-false-even-if-default-digest-is-set-to-daily/15
GitHub (github.com)
-
@baris thanks! This was very helpful. @Sebastián-Cisneros and I really appreciate it.