Fork of nodebb-plugin-shoutbox with room support

NodeBB Plugins
  • Hello guys,

    I just must say that I love nodebb and starting to love nodejs. I primarely program in pyhton and use django , but this is good for me to learn.
    I have created a fork of the original shoutbox plugin and added room support. Rooms are created on fly when you enter /chat/RoomName, RoomName could be anything .
    My first test works as expected, but if I add in the custom route in navigation , like /chat/RoomName , when I click first time , the connection stalls, but if I refresh the page it loads ok , or if I enter the full url in browser it loads from first time as expected, this issue I haven`t managed to solve.
    Sorry for the original name which I have not changed, I hope I will change the name in the future. I will try to solve this issue also.

    The repository url is : https://github.com/claudiutraistaru/nodebb-plugin-shoutbox

  • router.get('/chat/:room', params.middleware.buildHeader, renderChatRoom);
    router.get('/api/chat/:room', params.middleware.buildHeader, renderChatRoom);
    

    API routes don't need the buildHeader middleware, not sure if that is causing the problem though.

  • The api should not get the buildHeader, or am I wrong?
    This shouldn`t be?:

    router.get('/chat/:room', params.middleware.buildHeader, renderChatRoom);
    router.get('/api/chat/:room', renderChatRoom);

    Also tried with :

    router.get('/api/chat/:room',function (req,res){});

    Same issue 😞

  • Right now when testing on my dev system I was able to get an error in chrome:
    Uncaught TypeError: Cannot read property 'name' of undefined , in nodebb.min.js, the part of code that gives error is :

    ajaxify.variables.flush();
    ajaxify.loadData(url, function(err, data) {
    if (err) {
    return onAjaxError(err, url, callback, quiet);
    }

    		app.template = data.template.name;
    
    		require(['translator'], function(translator) {
    			translator.load(config.defaultLang, data.template.name);
    			renderTemplate(url, data.template.name, data, callback);
    		});
    	});
    

    The line with error is : app.template = data.template.name;
    On reload everything is ok as I have said, but doesn`t matter how many times I click on the shortcut or href inside nodebb the connection stalls .

  • What do you get when you go the the route /api/chat/:room in your browser? The data should have a template section with name in it.

  • I get :
    {
    "features": [],
    "room": ":room",
    "loggedIn": true,
    "template": {
    "name": "shoutbox",
    "shoutbox": true
    }
    }

  • Ok I think it was an issue on my side , don`t know witch , now it seems to work . I left everything like in my git, including router.get('/api/chat/:room', renderChatRoom); . I will extend my project and try to add an external widget in the rooms :).

  • Hey @Scuzz, maybe you'll be interested in this 😉

  • If this is updated and compatible with v0.7 then i probably will. @Schamper is slacking and by the time he updates the shoutbox v1.0 will be out 😛

    I'll give it a try on a dev machine.

  • @Scuzz. For the moment for it to work on 0.7 on my install I have removed the hooks for usersettings, but if I have any time soon I will try to make those work also. This at the moment was shown that maybe someone will make use of the code before I will make it stable.


Suggested Topics