Merge branch 'staging' into soon

pull/1/head
ansuz 4 years ago
commit c3627f3235

@ -16,6 +16,7 @@ server.js
www/common/old-media-tag.js
www/scratch
www/lib
www/accounts
www/common/toolbar.js
www/common/hyperscript.js

@ -123,7 +123,10 @@ define([
};
});
var init = false;
CodeMirror.registerHelper("orgmode", "init", function (editor) {
if (init) { return; }
editor.setOption("extraKeys", {
"Tab": function(cm) { org_cycle(cm); },
"Shift-Tab": function(cm){ org_shifttab(cm); },
@ -139,6 +142,7 @@ define([
"Shift-Right": function(cm){ org_shiftright(cm); }
});
init = true;
editor.on('mousedown', toggleHandler);
editor.on('touchstart', toggleHandler);
editor.on('gutterClick', foldLine);
@ -155,6 +159,9 @@ define([
});
CodeMirror.registerHelper("orgmode", "destroy", function (editor) {
if (!init) { return; }
init = false;
editor.off('mousedown', toggleHandler);
editor.off('touchstart', toggleHandler);
editor.off('gutterClick', foldLine);

@ -2254,7 +2254,12 @@ define([
});
$container.keydown(function (e) {
var $value = $innerblock.find('[data-value].cp-dropdown-element-active:visible');
if (!$value.length) {
$value = $innerblock.find('[data-value]').first();
}
if (e.which === 38) { // Up
e.preventDefault();
e.stopPropagation();
if ($value.length) {
$value.mouseleave();
var $prev = $value.prev();
@ -2263,6 +2268,8 @@ define([
}
}
if (e.which === 40) { // Down
e.preventDefault();
e.stopPropagation();
if ($value.length) {
$value.mouseleave();
var $next = $value.next();
@ -2271,12 +2278,16 @@ define([
}
}
if (e.which === 13) { //Enter
e.preventDefault();
e.stopPropagation();
if ($value.length) {
$value.click();
hide();
}
}
if (e.which === 27) { // Esc
e.preventDefault();
e.stopPropagation();
$value.mouseleave();
hide();
}

@ -1,5 +1,6 @@
define([
'jquery',
'/api/config/',
'/common/toolbar.js',
'json.sortify',
'/common/common-util.js',
@ -19,6 +20,7 @@ define([
'/customize/messages.js',
], function (
$,
ApiConfig,
Toolbar,
JSONSortify,
Util,
@ -2339,8 +2341,10 @@ define([
msg = Messages._getKey('fm_info_sharedFolderHistory', [sfName]);
return $(common.fixLinks($box.html(msg)));
}
Messages.fm_info_anonymous = "You are not logged in so your pads will expire after {0} days (<a href=\"https://blog.cryptpad.fr/2017/05/17/You-gotta-log-in/\" target=\"_blank\">find out more</a>). They are stored in your browser so clearing history may make them disappear.<br><a href=\"/register/\">Sign up</a> or <a href=\"/login/\">Log in</a> to keep them alive.<br>"; // XXX XXX
// XXX update this key to use "{0} days" instead of "3 months"
if (!APP.loggedIn) {
msg = APP.newSharedFolder ? Messages.fm_info_sharedFolder : Messages.fm_info_anonymous;
msg = APP.newSharedFolder ? Messages.fm_info_sharedFolder : Messages._getKey('fm_info_anonymous', [ApiConfig.inactiveTime || 90]);
return $(common.fixLinks($box.html(msg)));
}
if (!msg || APP.store['hide-info-' + path[0]] === '1') {

@ -312,7 +312,7 @@ define([
}
};
handlers['INVITE_TO_TEAM_ANSWER'] = function(common, data) {
handlers['INVITE_TO_TEAM_ANSWERED'] = function(common, data) {
var content = data.content;
var msg = content.msg;

File diff suppressed because one or more lines are too long

Binary file not shown.

Before

Width:  |  Height:  |  Size: 52 KiB

After

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 115 KiB

After

Width:  |  Height:  |  Size: 121 KiB

@ -109,6 +109,13 @@ define([
delete localStorage[k];
delete sessionStorage[k];
});
try {
Object.keys(localStorage || {}).forEach(function (k) {
// Remvoe everything in localStorage except CACHE and FS_hash
if (/^CRYPTPAD_CACHE/.test(k) || /^LESS_CACHE/.test(k) || k === Constants.fileHashKey) { return; }
delete localStorage[k];
});
} catch (e) { console.error(e); }
LocalStore.clearThumbnail();
// Make sure we have an FS_hash in localStorage before reloading all the tabs
// so that we don't end up with tabs using different anon hashes

@ -444,11 +444,21 @@ define([
// If they declined the invitation, remove them from the roster (as a pending member)
try {
var module = ctx.store.modules['team'];
module.removeFromTeam(teamId, msg.author);
module.removeFromTeam(teamId, msg.author, true);
} catch (e) { console.error(e); }
}
cb(false);
var userData = content.user || content;
box.sendMessage({
type: 'INVITE_TO_TEAM_ANSWERED',
content: {
user: userData,
team: team,
answer: content.answer
}
}, function () {});
cb(true);
};
handlers['TEAM_EDIT_RIGHTS'] = function (ctx, box, data, cb) {
@ -648,9 +658,15 @@ define([
if (!data.msg) { return void cb(true); }
// Check if the request is valid (sent by the correct user)
var myCurve = Util.find(ctx, ['store', 'proxy', 'curvePublic']);
var curve = Util.find(data, ['msg', 'content', 'user', 'curvePublic']) ||
Util.find(data, ['msg', 'content', 'curvePublic']);
if (curve && data.msg.author !== curve) { console.error('blocked'); return void cb(true); }
// Block messages that are not coming from the user described in the message
// except if the author is ourselves.
if (curve && data.msg.author !== curve && data.msg.author !== myCurve) {
console.error('blocked');
return void cb(true);
}
var type = data.msg.type;

@ -206,6 +206,10 @@ proxy.mailboxes = {
if (!box) { return void cb(); }
if (!box.cpNf || typeof(box.cpNf.stop) !== "function") { return void cb('EINVAL'); }
box.cpNf.stop();
Object.keys(box.content).forEach(function (h) {
Handlers.remove(ctx, box, box.content[h], h);
hideMessage(ctx, type, h, ctx.clients);
});
delete ctx.boxes[type];
};
var openChannel = function (ctx, type, m, onReady, opts) {

@ -578,6 +578,12 @@ var factory = function (Util, Hash, CPNetflux, Sortify, nThen, Crypto) {
console.error("CHANNEL_ERROR", info);
};
var onConnectionChange = function (info) {
if (info.state) { return; }
// Disconnect: don't send event anymore until ready
ready = false;
};
var onConnect = function (/* wc, sendMessage */) {
console.log("ROSTER CONNECTED");
};
@ -621,12 +627,12 @@ var factory = function (Util, Hash, CPNetflux, Sortify, nThen, Crypto) {
// if a checkpoint was successfully applied, emit an event
if (parsed[0] === 'CHECKPOINT' && changed) {
events.checkpoint.fire(hash);
if (isReady()) { events.checkpoint.fire(hash); }
// reset the counter for messages since the last checkpoint
ref.internal.sinceLastCheckpoint = 0;
ref.internal.lastCheckpointHash = hash;
} else if (changed) {
events.change.fire();
if (isReady()) { events.change.fire(); }
}
// CHECKPOINT logic...
@ -833,7 +839,7 @@ var factory = function (Util, Hash, CPNetflux, Sortify, nThen, Crypto) {
onChannelError: onChannelError,
onReady: onReady,
onConnect: onConnect,
onConnectionChange: function () {},
onConnectionChange: onConnectionChange,
onMessage: onMessage,
noChainPad: true,

@ -221,6 +221,11 @@ define([
roster.on('change', function () {
var state = roster.getState();
var me = Util.find(ctx, ['store', 'proxy', 'curvePublic']);
if (!state.members || !Object.keys(state.members).length) {
// invalid roster, don't leave the team
console.error(JSON.stringify(state));
return;
}
if (!state.members[me]) {
return void closeTeam(ctx, id);
}
@ -1698,8 +1703,22 @@ define([
team.getTeams = function () {
return Object.keys(ctx.teams);
};
team.removeFromTeam = function (teamId, curve) {
var isPending = function (teamId, curve) {
var team = ctx.teams[teamId];
if (!team) { return; }
var state = team.roster && team.roster.getState();
if (!state.members) { return; }
var m = state.members[curve] || {};
return m.pending;
};
team.removeFromTeam = function (teamId, curve, pendingOnly) {
if (!teams[teamId]) { return; }
// When receiving a negative answer to a team invitation, remove
// the pending user from the roster.
if (pendingOnly && !isPending(teamId, curve)) { return; }
if (ctx.onReadyHandlers[teamId]) {
ctx.onReadyHandlers[teamId].push({cb : function () {
ctx.teams[teamId].roster.remove([curve], function (err) {

Loading…
Cancel
Save