@julian I will give it a try, Thanks so much.
Sebastián Cisneros
@Sebastián Cisneros
Best posts made by Sebastián Cisneros
-
RE: how can I check if a user is querying this through API and with a valid bearer token?
-
RE: avoid nodebb send email notifications if daily digest is on
I guess the right one is this one
filter:email.cancel
accodring to nodebb documents
const result = await Plugins.hooks.fire('filter:email.cancel', { cancel: false, // set to true in plugin to cancel sending email template: template, params: params, });
right?
-
how can I check if a user is querying this through API and with a valid bearer token?
So, I created a custom plugin just to add a new URL "page" and its API endpoint like this.
Plugin.load = function (params, callback) { var router = params.router; var middleware = params.middleware; // Define the function that renders the custom route. async function render(req, res, next) { if ( ( req.user !== undefined && req.user !== null ) ) { // Get whatever data you want to send to the template here. var data = { query: req.query, }; // This is the path to your template without the .tpl, relative to the templates directory in plugin.json var template = 'comments' // Send the page to the user. res.render(template, data); } else { next(); } } // This actually creates the routes, you need two routes for every page. // The first parameter is the actual path to your page. router.get('/comments', middleware.buildHeader, render); router.get('/api/comments', render); callback(); };
When I do
if ( ( req.user !== undefined && req.user !== null ) ) {
I ensure that the user has to be logged in in order to see the page or API.
But, how can I check if a user is querying this through API and with a valid bearer token?
-
RE: how can I check if a user is querying this through API and with a valid bearer token?
@julian Thanks for your help.
what quickstart ?
also, the res.locals.isAPI its boolean, only tells me if the request is through API, but I still don't know how to check if the request token is valid. I only want to show this page, and the API endpont json output if the token is valid (just like almost all pages on nodebb do)
again thanks for the quick reply on this matter.
-
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 ?
-
RE: userDigest.getUsersInterval(uid) returns false even if default digest is set to daily
@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.
-
hide favicon counter
I'm looking to hide or delete the counter on the favicon.
I've found the code here on the nodebb core.
is there a way to update that payload updateFavicon variable to false?
updateFavicon: true,
Latest posts made by Sebastián Cisneros
-
hide favicon counter
I'm looking to hide or delete the counter on the favicon.
I've found the code here on the nodebb core.
is there a way to update that payload updateFavicon variable to false?
updateFavicon: true,
-
RE: userDigest.getUsersInterval(uid) returns false even if default digest is set to daily
@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....
-
RE: userDigest.getUsersInterval(uid) returns false even if default digest is set to daily
@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.
-
RE: userDigest.getUsersInterval(uid) returns false even if default digest is set to daily
@baris 1 and 2 both sending the digest, and user has personal digest set to off
-
RE: userDigest.getUsersInterval(uid) returns false even if default digest is set to daily
@baris I've clicked 1, I can do testing with 2 in a couple hours. I will let you know the result.
-
RE: userDigest.getUsersInterval(uid) returns false even if default digest is set to daily
@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.
-
-
RE: userDigest.getUsersInterval(uid) returns false even if default digest is set to daily
@baris are you sure? if you check the source code here
https://github.com/NodeBB/NodeBB/blob/master/src/user/digest.js#L53
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).
-
RE: userDigest.getUsersInterval(uid) returns false even if default digest is set to daily
@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.
-
RE: userDigest.getUsersInterval(uid) returns false even if default digest is set to daily
@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?
-
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 ?