Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"primus-emitter": "~3.0.2",
"primus": "~2.3.0",
"xmpp-ftw": "~1.14.4",
"xmpp-ftw-buddycloud": "~1.12.1",
"xmpp-ftw-buddycloud": "~1.15.0",
"socket.io": "~0.9.16",
"winston": "0.7.x",
"express-winston": "0.2.x"
Expand Down
9 changes: 7 additions & 2 deletions src/subscriptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ function findUserAffiliations(rootEl) {
return rootEl.getChildrenByFilter(function (c) {
return typeof c != 'string' &&
c.getName() == 'affiliation' &&
c.getNS() == pubsub.ns &&
c.getNS() == pubsub.ownerNS &&
c.attr('node') && c.attr('node').indexOf('/user/') == 0;
}, true);
}
Expand All @@ -100,7 +100,7 @@ function findNodeAffiliations(rootEl) {
return rootEl.getChildrenByFilter(function (c) {
return typeof c != 'string' &&
c.getName() == 'affiliation' &&
c.getNS() == pubsub.ownerNS &&
c.getNS() == pubsub.ns &&
c.attr('jid') && c.attr('jid').indexOf('@') != 0;
}, true);
}
Expand Down Expand Up @@ -236,6 +236,11 @@ function changeNodeSubscriptions(req, res) {
//// GET /<channel>/subscribers/<node>/approve /////////////////////////////////////////

function getPendingNodeSubscriptions(req, res) {
if (!req.user) {
api.sendUnauthorized(res);
return;
}

var channel = req.params.channel;
var node = req.params.node;
requestNodeSubscriptions(req, res, channel, node, function(reply) {
Expand Down
8 changes: 6 additions & 2 deletions src/websocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ var Emitter = require('primus-emitter')
, xmpp = require('xmpp-ftw')
, Buddycloud = require('xmpp-ftw-buddycloud');

var cache = {}

module.exports = function(config, server, logger) {
var options = {
transformer: 'socket.io',
Expand All @@ -23,12 +25,14 @@ module.exports = function(config, server, logger) {
primus.on('connection', function(socket) {
logger.debug('Websocket connection made');
var xmppFtw = new xmpp.Xmpp(socket);
xmppFtw.addListener(new Buddycloud());
var buddycloud = new Buddycloud();
buddycloud.setCache(cache);
xmppFtw.addListener(buddycloud);
socket.xmppFtw = xmppFtw;
})

primus.on('disconnection', function(socket) {
logger.debug('Client disconnected, logging them out');
socket.xmppFtw.logout();
})
}
}
8 changes: 4 additions & 4 deletions test/subscriptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ var mockConfig = {
</pubsub>\
</iq>':
'<iq type="result">\
<pubsub xmlns="http://jabber.org/protocol/pubsub">\
<pubsub xmlns="http://jabber.org/protocol/pubsub#owner">\
<affiliations>\
<affiliation node="/user/alice@localhost/posts" \
affiliation="owner"/>\
Expand All @@ -67,7 +67,7 @@ var mockConfig = {
</pubsub>\
</iq>':
'<iq type="result">\
<pubsub xmlns="http://jabber.org/protocol/pubsub#owner">\
<pubsub xmlns="http://jabber.org/protocol/pubsub">\
<affiliations node="/user/alice@localhost/posts">\
<affiliation jid="alice@localhost" affiliation="owner"/>\
<affiliation jid="bob@localhost" affiliation="subscriber"/>\
Expand Down Expand Up @@ -98,7 +98,7 @@ var mockConfig = {
</pubsub>\
</iq>':
'<iq type="result">\
<pubsub xmlns="http://jabber.org/protocol/pubsub#owner">\
<pubsub xmlns="http://jabber.org/protocol/pubsub">\
<affiliations node="/user/alice@localhost/posts">\
<affiliation jid="alice@localhost" affiliation="owner"/>\
<affiliation jid="bob@localhost" affiliation="subscriber"/>\
Expand All @@ -125,7 +125,7 @@ var mockConfig = {
</pubsub>\
</iq>':
'<iq type="result">\
<pubsub xmlns="http://jabber.org/protocol/pubsub#owner">\
<pubsub xmlns="http://jabber.org/protocol/pubsub">\
<affiliations node="/user/alice@localhost/posts">\
<affiliation jid="alice@localhost" affiliation="owner"/>\
<affiliation jid="bob@localhost" affiliation="subscriber"/>\
Expand Down