Add tests. Kill the vfs connection when a users access level is changed too.

pull/365/head
Tim Robinson 2016-09-29 20:41:28 +00:00
rodzic 586ea62b29
commit 820ff42781
1 zmienionych plików z 7 dodań i 5 usunięć

Wyświetl plik

@ -340,21 +340,23 @@ function plugin(options, imports, register) {
var message = JSON.parse(messageString);
switch (message.action) {
case "remove_member":
handleRemoveProjectMember(vfs, message);
case "update_member_access":
handleProjectMemberAccessChange(vfs, message);
break;
default:
break;
}
}
function handleRemoveProjectMember(vfs, message) {
function handleProjectMemberAccessChange(vfs, message) {
if (vfs.uid !== message.body.uid) return;
console.log("Removing ", vfs.id, " for user ", vfs.uid, " project ", vfs.pid, " from the vfs connection cache");
// Remove after 2s so client has time to recieve final "You've been removed" PubSub message.
setTimeout(function() {
// Remove next tick so client has time to recieve final "You've been removed" PubSub message.
process.nextTick(function() {
cache.remove(vfs.id);
}, 2000);
});
}
register(null, {