@PitaJ I think I have a very edge-case scenario, I've found a solution for guests and logged in users.
Thanks for your help and point in the right direction!
@PitaJ I think I have a very edge-case scenario, I've found a solution for guests and logged in users.
Thanks for your help and point in the right direction!
@PitaJ OK, I'll check it again - it seems to change the timedate for guests, nothing else gets translated. It's only logged-in users which seem to be effected by the config.userLang
Passing the ?lang=
for a guest doesn't seem to work either
@PitaJ Does config.userLang set the language for guests? Or is that a different property?
@PitaJ Perfect, thank you. That's done the trick
Is there a way to set the NodeBB language in either the server or client js?
I have a cookie that contains the language code I want to set the forum to.
Is there a hook I can use on the server-side to set the language, or equally something on the client side I can use to change the locale?
Is there a way I can hook into the User's 'language' selector options to roll my own solution?
Note: passing ?lang=[LANGAUGE]
in the URL isn't an option
Note: Using the User settings isn't an option as I need to set the language before this point, from a Cookie
Is there a way to read cookies in the middleware.autoLocale
function? (src/middleware/headers.js) req.cookies = {} at this point.
However, inside the function translate(str, req, res, next) {
req.cookies is a full object as I expect (src/middleware/render.js)
Thanks!
The Bleeding Edge forum uses NodeBB - https://www.bleedingedge.com/forums
I re-wrote the category controller (src > controllers > category.js
) to handle passing ?term=x
query through and only getting the relevant topics.
Is there a way to be able to filter topics on a category page by:
The functionality that exists on the 'popular' page in NodeBB has the functionality I need, but adding ?term=daily
into the URL doesn't update the category page listings.
Thanks @baris, the latter approach works so I'll go with that
I've added a couple of hooks which add a new node on to topic data, which is either true or false depending on other some logic I've written.
{
"hook": "filter:topic.create",
"method": "createTopic"
},
{
"hook": "filter:topic.edit",
"method": "editTopic"
}
When topics are loaded onto a category page, I want to return only those which have the new node === true
In src > categories > topics.js
, there's a function Categories.buildTopicsSortedSet
. In it, topics can be ordered by 'most_posts' like so set = 'cid:' + cid + ':tids:posts'
Is there a way that I can manipulate this to look for my new node condition? (I need to be able to fetch these topics at this point in the query because of pagination. If I fetch 5 topics at a time and filter them after this point, I could end up with 0 matched topics. I always want to fetch the maximum number of matching topics).
--
Edit: I should also mention I'm using a Postgres DB
@baris Yes, thanks.
I had to include this line, the function is in there:
var groups = require.main.require('./src/groups');
@labaguette This looks perfect for what I need, however, this part is giving an error:
function (next) {
groups.getUserGroups([userData.uid], next);
},
ReferenceError: groups is not defined
Do you know what I need to use instead?
I'm wondering if there's a missing function that I need getUserGroups
?
Thanks!
Is there a way to show all the group badges a user belongs to, without them having to select them all from the edit profile page?
Thank you both, this resolved the issue
I'm currently experiencing an issue where I create a new category/subcategory and it doesn't show for all users (with privileges set to allow everyone to view/read).
I'm running NodeBB on two server instances (on Azure). It seems that the server which is used to create the new category shows on the frontend. The other server instance, however, doesn't show the new category.
I've checked the category API, in the server that was used to create the category it appears in the JSON, but it doesn't appear in the API on the other server instance.
The two servers only share 1 database, so the category data must be there. How long does it take for the cache to refresh?
@julian Hey Julian, I did actually manage to resolve this with a combination of two things:
We have a very niche setup for our forum (Azure + Node.js Proxy) which I think gave a few red herrings along the way, however, I do think we can suggest some updates to documentation & possible feature requests of NodeBB which might help other users in the future
Thanks for your help and the other regular contributors who have answered other questions I've asked along the way
@julian Thanks for your reply. That hasn't worked, unfortunately
It looked like it was supposed to be a string from this post - https://community.nodebb.org/topic/13388/faq-websockets-not-working-due-to-misconfigured-origins
I'm not sure if the problem is specific to Azure or it's to do with these origins. Azure (webapp) to Azure (NodeBB) doesn't like the websocket part, but polling is fine (there is a couple of failing polls every 5minutes or so, but generally works). With the websocket request the '2probe' message is sent but nothing is received.
Local (webapp) to Azure (NodeBB) is working perfectly with the WebSocket messages being sent and received.
I have 2 webapps running on Azure (linux servers).
One webapp is running NodeBB (v1.12.1) - https://my-forum.azurewebsites.net
This app should not be accessed directly, instead, it is proxied into the second web app running on Azure.
The NodeBB config is set up so that the 'url' is 'https://my-website.azurewebsites.net/forums/'
I have added URLs in the socket.io:origins
nconf to be able to make WebSocket requests from other URLs. The values look like this:
http://my-website.azurewebsites.net:* https://my-website.azurewebsites.net:* https://my-forum.azurewebsites.net:* https://localhost:*
The main website (https://my-website.azurewebsites.net) is a Node.js & Express app with some frontend routes, api routes and uses the http-proxy-middleware
module to proxy requests to the forum. The setup and configuration of that looks like this:
...
const proxy = require('http-proxy-middleware');
const forumProxy = proxy({
target: process.env.FORUM_URL,
changeOrigin: true,
ws: true,
secure: true,
xfwd: true,
logLevel: 'debug'
});
app.use('/forums', forumProxy);
const mainserver = http.createServer(app);
... other config
mainserver.on('upgrade', forumProxy.upgrade);
When I run the main website locally (https://localhost:3000) and Proxy the NodeBB forum, I can see that WebSockets are established correctly and messages are exchanged between the local version of the website and the Azure hosted NodeBB forum.
However, when the website is on Azure it Proxy's the URLs and the site perfectly fine but the WebSocket connection does not work. A '2probe' message is sent by the main website but a connection is never established and messages are not exchanged.
Accessing the forum URL directly works as expected, including WebSocket messages being exchanged.
Both the main website and forum have a web.config which contains:
<system.webServer>
<webSocket enabled="false"/>
</system.webServer>
Both apps also have the --web-sockets-enabled=true value set on the server (which was set via PowerShell).
As I understand it, this makes WebSocket enabled on the server and the value in the web.config of 'false' is to turn off iis WebSockets and let Node.js handle it.
There seems to be a problem with 2 Azure servers talking to each other via WebSockets. Local to Azure works fine.
Why is it that 'https://my-website.azurewebsites.net' cannot establish a WebSocket to 'https://my-forum.azurewebsites.net'? but Local to Azure can?