userDigest.getUsersInterval(uid) returns false even if default digest is set to daily

Plugin Development
  • 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?

  • That function doesn't seem to be used to determine the uids to send the digest. The function for that is Digest.getSubscribers.

    Digest.getUsersInterval seems to be used on the ACP page to display the users digest setting.

  • @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.


  • That doesn't sound right, if the user sets their digest setting to off and saves their user settings then on this line dailyDigestFreq will be off meanwhile interval will be one of day/week/biweek/month so it won't send an email to that uid.

  • @baris are you sure? if you check the source code here

    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 =, 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

    If they set their setting to off then Digest.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.

  • 61e8172f-d9d1-4f4a-be9d-f327a7eb08e7-image.png

    As far as I know clicking 1 will always send a digest to that user because it uses the uid of the user directly.

    Clicking 2 should respect the settings of the users. Which one did you use for the testing?

  • @baris I've clicked 1, I can do testing with 2 in a couple hours. I will let you know the result.

  • Try with 2, the button next to the user (1) always sends the digest because of the above code.

  • @baris 1 and 2 both sending the digest, and user has personal digest set to off


  • 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.

  • @baris thanks! This was very helpful. @Sebastián-Cisneros and I really appreciate it.

Suggested Topics

  • 0 Votes
    1 Posts

    Is there some way to hide all topics within a category from all feeds (recent, popular, new, the digest)?

    I need the topics to be accessible (and usable) to all users directly, but not searchable or showing up at random.

  • 0 Votes
    2 Posts

    Hi @avan-sardar, welcome!

    find a topic based on uid and a custom session ID

    Is this a requirement? If your plugin is listening for something like, then you can process the stripe payment.

    The action hook itself also sends the post data, which contains the pid and tid. Without more context, I am afraid I will not be able to help further.

  • 0 Votes
    1 Posts

    I have begun work on a custom email plugin, and while looking at some others that are available to see how they went about things I noticed that all of the available plugins (at least that I have found so far) already have an entry in the email setup list, regardless of if you have downloaded the associated plugin for that service (ex. Sendgrid, Mailgun, etc).

    So my questions is, if I have a custom email plugin, how exactly would I go about making it selectable / usable by the forum? Does it need to be present in the default email list? Is there a way to have my plugin inject itself into that list of providers or is there a way to override that list so that the forum knows not to use the credentials and settings in there, but instead use the ones in the plugin?

    The only real switch I have found is the "Use an external email server to send emails", which I would imagine that if it is turned off, that would not be much help either.

    If anyone has any insight on how the system works in regards to this and can point me in the right direction, I would appreciate it!


  • 0 Votes
    2 Posts

    You need to run event.preventDefault() to prevent the Click from automatically submitting the form

  • Checking Group Membership of UID

    Solved Plugin Development
    0 Votes
    4 Posts

    Thanks to both of you for your quick help!

    Both solution do work indeed. As baris pointed out, my failure was returning values from async functions.

    Here is a working example for each solution:

    var Groups = module.parent.require('./groups'); Groups.isMember(uid, 'administrators', function(err, isMember) { if (err) { next(err); } if (isMember) {'user is an administrator'); Groups.join('administrators', uid); } else {'user is no administrator'); Groups.leave('administrators', uid); } }); var User = module.parent.require('./user'); var Groups = module.parent.require('./groups'); User.isAdministrator(uid, function(err, isAdmin) { if (err) { next(err); } if (isAdmin) {'user is an administrator'); Groups.join('administrators', uid); } else {'user is no administrator'); Groups.leave('administrators', uid); } });