Merge branch 'staging' into communities-allow-list

This commit is contained in:
ansuz
2020-02-21 08:40:45 -05:00
12 changed files with 103 additions and 42 deletions

View File

@@ -2091,9 +2091,12 @@ define([
store.onlyoffice.removeClient(clientId);
} catch (e) { console.error(e); }
try {
store.mailbox.removeClient(clientId);
if (store.mailbox) {
store.mailbox.removeClient(clientId);
}
} catch (e) { console.error(e); }
Object.keys(store.modules).forEach(function (key) {
if (!store.modules[key]) { return; }
if (!store.modules[key].removeClient) { return; }
try {
store.modules[key].removeClient(clientId);
@@ -2337,7 +2340,6 @@ define([
initAnonRpc(null, null, waitFor());
initRpc(null, null, waitFor());
}).nThen(function (waitFor) {
loadMailbox(waitFor);
Migrate(proxy, waitFor(), function (version, progress) {
postMessage(clientId, 'LOADING_DRIVE', {
state: (2 + (version / 10)),
@@ -2357,6 +2359,7 @@ define([
loadUniversal(Profile, 'profile', waitFor);
loadUniversal(Team, 'team', waitFor);
loadUniversal(History, 'history', waitFor);
loadMailbox(waitFor); // XXX make sure we don't have new issues with mailboxes being loaded later
cleanFriendRequests();
}).nThen(function () {
var requestLogin = function () {

View File

@@ -494,10 +494,11 @@ define([
try {
var module = ctx.store.modules['team'];
// changeMyRights returns true if we can't change our rights
module.changeMyRights(teamId, content.state, content.teamData);
module.changeMyRights(teamId, content.state, content.teamData, function (done) {
if (!done) { console.error("Can't update team rights"); }
cb(true);
});
} catch (e) { console.error(e); }
cb(true);
};
handlers['OWNED_PAD_REMOVED'] = function (ctx, box, data, cb) {

View File

@@ -1067,14 +1067,25 @@ define([
ctx.emit('ROSTER_CHANGE_RIGHTS', teamId, team.clients);
};
var changeMyRights = function (ctx, teamId, state, data) {
if (!teamId) { return true; }
var changeMyRights = function (ctx, teamId, state, data, cb) {
if (!teamId) { return void cb(false); }
var teamData = Util.find(ctx, ['store', 'proxy', 'teams', teamId]);
if (!teamData) { return true; }
if (!teamData) { return void cb(false); }
var onReady = ctx.onReadyHandlers[teamId];
var team = ctx.teams[teamId];
if (!team) { return true; }
if (teamData.channel !== data.channel || teamData.password !== data.password) { return true; }
if (!team && Array.isArray(onReady)) {
onReady.push({
cb: function () {
changeMyRights(ctx, teamId, state, data, cb);
}
});
return;
}
if (!team) { return void cb(false); }
if (teamData.channel !== data.channel || teamData.password !== data.password) { return void cb(false); }
if (state) {
teamData.hash = data.hash;
@@ -1091,6 +1102,7 @@ define([
}
updateMyRights(ctx, teamId, data.hash);
cb(true);
};
var changeEditRights = function (ctx, teamId, user, state, cb) {
if (!teamId) { return void cb({error: 'EINVAL'}); }
@@ -1632,8 +1644,8 @@ define([
});
};
team.changeMyRights = function (id, edit, teamData) {
changeMyRights(ctx, id, edit, teamData);
team.changeMyRights = function (id, edit, teamData, cb) {
changeMyRights(ctx, id, edit, teamData, cb);
};
team.updateMyData = function (data) {
Object.keys(ctx.teams).forEach(function (id) {