join, leave, accept, reject: handlers + UI, #2588

This commit is contained in:
Julian Lam
2015-01-08 17:23:40 -05:00
parent b0182f702f
commit 96c37c25b0
3 changed files with 55 additions and 4 deletions

View File

@@ -59,4 +59,32 @@ SocketGroups.rescind = function(socket, data, callback) {
});
};
SocketGroups.accept = function(socket, data, callback) {
if (!data) {
return callback(new Error('[[error:invalid-data]]'));
}
groups.ownership.isOwner(socket.uid, data.groupName, function(err, isOwner) {
if (!isOwner) {
return callback(new Error('[[error:no-privileges]]'));
}
groups.acceptMembership(data.groupName, data.toUid, callback);
});
};
SocketGroups.reject = function(socket, data, callback) {
if (!data) {
return callback(new Error('[[error:invalid-data]]'));
}
groups.ownership.isOwner(socket.uid, data.groupName, function(err, isOwner) {
if (!isOwner) {
return callback(new Error('[[error:no-privileges]]'));
}
groups.rejectMembership(data.groupName, data.toUid, callback);
});
};
module.exports = SocketGroups;