From 764da42d48d7a322e9489e36fcf15001073bf10b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Benqu=C3=A9?= Date: Mon, 22 Jun 2020 13:22:48 +0100 Subject: [PATCH 01/15] add icon to support ticket category dropdown + added an option to add "fa-angle-down" to any dropdown --- www/common/common-ui-elements.js | 5 +++++ www/support/ui.js | 1 + 2 files changed, 6 insertions(+) diff --git a/www/common/common-ui-elements.js b/www/common/common-ui-elements.js index 7d829bdb0..386353339 100644 --- a/www/common/common-ui-elements.js +++ b/www/common/common-ui-elements.js @@ -2155,6 +2155,11 @@ define([ 'class': 'fa fa-caret-down', }).prependTo($button); } + if (config.angleDown) { + $('', { + 'class': 'fa fa-angle-down', + }).prependTo($button); + } // Menu var $innerblock = $('
', {'class': 'cp-dropdown-content'}); diff --git a/www/support/ui.js b/www/support/ui.js index 2be5cff1e..7783cca2e 100644 --- a/www/support/ui.js +++ b/www/support/ui.js @@ -119,6 +119,7 @@ Messages.support_category = "Category"; // XXX }); var dropdownCfg = { text: Messages.support_category, + angleDown: 1, options: categories, container: $(container), isSelect: true From d9b005970db12b432c61d54b08f020ed4cc4b4ad Mon Sep 17 00:00:00 2001 From: ansuz Date: Mon, 22 Jun 2020 09:43:29 -0400 Subject: [PATCH 02/15] update version strings for 3.19.1 (Thylacine's revenge) --- customize.dist/pages.js | 2 +- package-lock.json | 2 +- package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/customize.dist/pages.js b/customize.dist/pages.js index 0e42b9a3a..c37e4b2f5 100644 --- a/customize.dist/pages.js +++ b/customize.dist/pages.js @@ -62,7 +62,7 @@ define([ var imprintUrl = AppConfig.imprint && (typeof(AppConfig.imprint) === "boolean" ? '/imprint.html' : AppConfig.imprint); - Pages.versionString = "CryptPad v3.19.0 (Thylacine)"; + Pages.versionString = "CryptPad v3.19.1 (Thylacine's revenge)"; // used for the about menu Pages.imprintLink = AppConfig.imprint ? footLink(imprintUrl, 'imprint') : undefined; diff --git a/package-lock.json b/package-lock.json index ed2097eff..dcced0ee4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "cryptpad", - "version": "3.19.0", + "version": "3.19.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index be6f77978..8b9bc912c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "cryptpad", "description": "realtime collaborative visual editor with zero knowlege server", - "version": "3.19.0", + "version": "3.19.1", "license": "AGPL-3.0+", "repository": { "type": "git", From 5f74eb532ed14ce2c6fc1e87dc059cb1dbf81787 Mon Sep 17 00:00:00 2001 From: yflory Date: Mon, 22 Jun 2020 15:47:16 +0200 Subject: [PATCH 03/15] Fix margin issue in export modal --- customize.dist/src/less2/include/forms.less | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/customize.dist/src/less2/include/forms.less b/customize.dist/src/less2/include/forms.less index 7663bee51..96f419310 100644 --- a/customize.dist/src/less2/include/forms.less +++ b/customize.dist/src/less2/include/forms.less @@ -30,7 +30,7 @@ div.cp-alertify-type { display: flex; input { - margin: 0; + margin: 0 !important; flex: 1; min-width: 0; } From c0119672718c648069e5d15c8284c7a6a96376bc Mon Sep 17 00:00:00 2001 From: Weblate Date: Mon, 22 Jun 2020 16:42:38 +0200 Subject: [PATCH 04/15] Translated using Weblate (German) Currently translated at 100.0% (1298 of 1298 strings) Translation: CryptPad/App Translate-URL: http://weblate.cryptpad.fr/projects/cryptpad/app/de/ --- www/common/translations/messages.de.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/common/translations/messages.de.json b/www/common/translations/messages.de.json index d40c9e552..3ab3680ea 100644 --- a/www/common/translations/messages.de.json +++ b/www/common/translations/messages.de.json @@ -1087,7 +1087,7 @@ "support_disabledTitle": "Support ist nicht aktiviert", "support_disabledHint": "Diese CryptPad-Instanz wurde noch nicht für die Verwendung eines Support-Formulars konfiguriert.", "support_cat_new": "Neues Ticket", - "support_formTitle": "Titel des Tickets", + "support_formTitle": "Neues Ticket", "support_formHint": "Mit diesem Formular kann ein neues Support-Ticket eröffnet werden. Es erlaubt die sichere Kontaktaufnahme mit den Administratoren zur Lösung von Problemen oder Beantwortung von Fragen. Bitte eröffne kein neues Ticket, wenn du bereits ein offenes Ticket bezüglich des gleichen Problems hast. Verwende stattdessen die Antworten-Schaltfläche, um weitere Informationen hinzuzufügen.", "support_formButton": "Absenden", "support_formTitleError": "Fehler: Titel ist leer", From 020434582ff30612d3539a5186ffe00dcda59193 Mon Sep 17 00:00:00 2001 From: Weblate Date: Mon, 22 Jun 2020 16:42:39 +0200 Subject: [PATCH 05/15] Translated using Weblate (French) Currently translated at 100.0% (1298 of 1298 strings) Translation: CryptPad/App Translate-URL: http://weblate.cryptpad.fr/projects/cryptpad/app/fr/ --- www/common/translations/messages.fr.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/common/translations/messages.fr.json b/www/common/translations/messages.fr.json index ef33ad144..f4272d26a 100644 --- a/www/common/translations/messages.fr.json +++ b/www/common/translations/messages.fr.json @@ -1086,7 +1086,7 @@ "support_disabledTitle": "Le support n'est pas activé", "support_disabledHint": "Cette instance de CryptPad n'est pas encore configurée pour utiliser le formulaire de support.", "support_cat_new": "Nouveau ticket", - "support_formTitle": "Titre du ticket", + "support_formTitle": "Nouveau Ticket", "support_formButton": "Envoyer", "support_formTitleError": "Erreur : le titre est vide", "support_formContentError": "Erreur : le contenu est vide", From f93c164a2ed41a17d5084eabad8a68771c90b701 Mon Sep 17 00:00:00 2001 From: Weblate Date: Mon, 22 Jun 2020 16:42:39 +0200 Subject: [PATCH 06/15] Translated using Weblate (English) Currently translated at 100.0% (1298 of 1298 strings) Translation: CryptPad/App Translate-URL: http://weblate.cryptpad.fr/projects/cryptpad/app/en/ --- www/common/translations/messages.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/common/translations/messages.json b/www/common/translations/messages.json index 2aee6cc19..d99fd8d18 100644 --- a/www/common/translations/messages.json +++ b/www/common/translations/messages.json @@ -1108,7 +1108,7 @@ "support_disabledTitle": "Support is not enabled", "support_disabledHint": "This CryptPad instance is not yet configured to use a support form.", "support_cat_new": "New ticket", - "support_formTitle": "Ticket title", + "support_formTitle": "New Ticket", "support_formHint": "This form can be used to create a new support ticket. Use it to contact the administrators to solve issues or ask any question in a secure way. Please don't create a new ticket if you already have an open ticket about the same issue, but use the reply button to provide more information.", "support_formButton": "Send", "support_formTitleError": "Error: title is empty", From d6129ee21f1fb1c9e50afb856e619afcae33e4e0 Mon Sep 17 00:00:00 2001 From: yflory Date: Mon, 22 Jun 2020 17:37:09 +0200 Subject: [PATCH 07/15] Remove console.log --- www/common/sframe-common-mailbox.js | 1 - www/common/toolbar.js | 1 - 2 files changed, 2 deletions(-) diff --git a/www/common/sframe-common-mailbox.js b/www/common/sframe-common-mailbox.js index bdf1ae81e..4d8b6b73e 100644 --- a/www/common/sframe-common-mailbox.js +++ b/www/common/sframe-common-mailbox.js @@ -188,7 +188,6 @@ define([ onMessageHandlers.push(function (data, el) { var type = data.type; if (types.indexOf(type) === -1 && !(teams && /^team-/.test(type))) { return; } - console.log('okokok'); cfg.onMessage(data, el); }); } diff --git a/www/common/toolbar.js b/www/common/toolbar.js index 3afa55d61..e55cdcf82 100644 --- a/www/common/toolbar.js +++ b/www/common/toolbar.js @@ -1027,7 +1027,6 @@ MessengerUI, Messages) { Common.mailbox.subscribe(['notifications', 'team'], { onMessage: function (data, el) { - console.log(data, el, div); if (el) { $(div).prepend(el); } From 3086eb45c549ecb7d8c7fd10012948dc1b1d1ffd Mon Sep 17 00:00:00 2001 From: ansuz Date: Mon, 22 Jun 2020 14:58:19 -0400 Subject: [PATCH 08/15] enforce asynchronous callbacks in user object migration --- www/common/migrate-user-object.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/common/migrate-user-object.js b/www/common/migrate-user-object.js index 231c39ebd..b13aacb1c 100644 --- a/www/common/migrate-user-object.js +++ b/www/common/migrate-user-object.js @@ -499,7 +499,7 @@ define([ }, 500); progress(0, 0);*/ }).nThen(function () { - Realtime.whenRealtimeSyncs(store.realtime, Util.bake(cb)); + Realtime.whenRealtimeSyncs(store.realtime, Util.mkAsync(Util.bake(cb))); }); }; }); From a79a5f6a2debdac33695471b4163fe80c7e5c6be Mon Sep 17 00:00:00 2001 From: ansuz Date: Mon, 22 Jun 2020 14:58:56 -0400 Subject: [PATCH 09/15] remove some extraneous logs that were used for debugging --- www/common/outer/roster.js | 1 - www/common/sframe-common-mailbox.js | 2 -- www/common/toolbar.js | 1 - 3 files changed, 4 deletions(-) diff --git a/www/common/outer/roster.js b/www/common/outer/roster.js index d7976c8da..cd73c074c 100644 --- a/www/common/outer/roster.js +++ b/www/common/outer/roster.js @@ -798,7 +798,6 @@ var factory = function (Util, Hash, CPNetflux, Sortify, nThen, Crypto) { return void console.error(err); } metadata = ref.internal.metadata = (data && data[0]) || undefined; - console.log("TEAM_METADATA", metadata); }); }).nThen(function (w) { if (!config.keys.teamEdPublic && metadata && metadata.validateKey) { diff --git a/www/common/sframe-common-mailbox.js b/www/common/sframe-common-mailbox.js index bdf1ae81e..c89bdff3c 100644 --- a/www/common/sframe-common-mailbox.js +++ b/www/common/sframe-common-mailbox.js @@ -144,7 +144,6 @@ define([ var onMessage = function (data, cb) { // data = { type: 'type', content: {msg: 'msg', hash: 'hash'} } - console.debug(data.type, data.content); pushMessage(data); if (data.content && typeof (data.content.getFormatText) === "function") { var text = $('
').html(data.content.getFormatText()).text(); @@ -188,7 +187,6 @@ define([ onMessageHandlers.push(function (data, el) { var type = data.type; if (types.indexOf(type) === -1 && !(teams && /^team-/.test(type))) { return; } - console.log('okokok'); cfg.onMessage(data, el); }); } diff --git a/www/common/toolbar.js b/www/common/toolbar.js index 3afa55d61..e55cdcf82 100644 --- a/www/common/toolbar.js +++ b/www/common/toolbar.js @@ -1027,7 +1027,6 @@ MessengerUI, Messages) { Common.mailbox.subscribe(['notifications', 'team'], { onMessage: function (data, el) { - console.log(data, el, div); if (el) { $(div).prepend(el); } From d373b9c290cf6bda2b63fbbd69a04827010a5d97 Mon Sep 17 00:00:00 2001 From: ansuz Date: Mon, 22 Jun 2020 15:00:34 -0400 Subject: [PATCH 10/15] ignore support ticket attachments with hrefs hosted by anything other than the local 'file' app --- www/support/ui.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/www/support/ui.js b/www/support/ui.js index ce3f09702..454dddcfc 100644 --- a/www/support/ui.js +++ b/www/support/ui.js @@ -179,8 +179,6 @@ define([ }).on('change', function (e) { var files = Util.slice(e.target.files); files.forEach(function (file) { - // XXX validate that the href is hosted on the same instance - // use relative URLs or compare it against a list or allowed domains? var ev = {}; ev.callback = function (data) { var x, a; @@ -321,10 +319,11 @@ define([ var attachments = (content.attachments || []).map(function (obj) { if (!obj || !obj.name || !obj.href) { return; } + // only support files explicitly beginning with /file/ so that users can't link outside of the instance + if (!/^\/file\//.test(obj.href)) { return; } var a = h('a', { href: '#' }, obj.name); - // XXX disallow remote URLs $(a).click(function (e) { e.preventDefault(); ctx.common.openURL(obj.href); From a2db04b4f59e9c67b53a8790e6a135639f8bf3ef Mon Sep 17 00:00:00 2001 From: ansuz Date: Mon, 22 Jun 2020 15:02:11 -0400 Subject: [PATCH 11/15] leave a low-priority note to make categories a required field for support tickets in the future --- www/support/ui.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/www/support/ui.js b/www/support/ui.js index 454dddcfc..0519530da 100644 --- a/www/support/ui.js +++ b/www/support/ui.js @@ -66,11 +66,20 @@ define([ var $cat = $form.find('.cp-support-form-category'); var $title = $form.find('.cp-support-form-title'); var $content = $form.find('.cp-support-form-msg'); - // XXX block submission until pending uploads are complete? + // TODO block submission until pending uploads are complete? var $attachments = $form.find('.cp-support-attachments'); + var category = $cat.val().trim(); + /* + // || ($form.closest('.cp-support-list-ticket').data('cat') || "").trim(); + // Messages.support_formCategoryError = "Error: category is empty"; // TODO ensure this is translated before use + + if (!category) { + console.log($cat); + return void UI.alert(Messages.support_formCategoryError); + } + */ - var category = $cat.val().trim(); // XXX make category a required field? var title = $title.val().trim(); if (!title) { return void UI.alert(Messages.support_formTitleError); From c939b4951c6b5a9c6b9ba65fec48187081a48976 Mon Sep 17 00:00:00 2001 From: ansuz Date: Mon, 22 Jun 2020 16:23:16 -0400 Subject: [PATCH 12/15] add some basic styles to the registration page's confirm buttons --- www/register/main.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/www/register/main.js b/www/register/main.js index d052f88b0..289c40df5 100644 --- a/www/register/main.js +++ b/www/register/main.js @@ -115,8 +115,11 @@ define([ }, { ok: Messages.register_writtenPassword, cancel: Messages.register_cancel, - cancelClass: 'safe', - okClass: 'danger', +/* If we're certain that we aren't using these "*Class" APIs + anywhere else then we can deprecate them and make this a + custom modal in common-interface (or here). */ + cancelClass: 'btn.btn-primary', + okClass: 'btn.btn-danger', reverseOrder: true, done: function ($dialog) { $dialog.find('> div').addClass('half'); From 846a9d325288db926d15bfb7a901f22c2816e9d5 Mon Sep 17 00:00:00 2001 From: yflory Date: Tue, 23 Jun 2020 10:43:56 +0200 Subject: [PATCH 13/15] Apply correct style to registration confirm modal --- customize.dist/src/less2/pages/page-register.less | 2 ++ www/common/common-interface.js | 3 --- www/register/main.js | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/customize.dist/src/less2/pages/page-register.less b/customize.dist/src/less2/pages/page-register.less index 314ad7236..cc319a0e4 100644 --- a/customize.dist/src/less2/pages/page-register.less +++ b/customize.dist/src/less2/pages/page-register.less @@ -2,9 +2,11 @@ @import (reference) "../include/colortheme-all.less"; @import (reference) "../include/alertify.less"; @import (reference) "../include/checkmark.less"; +@import (reference) "../include/forms.less"; &.cp-page-register { .infopages_main(); + .forms_main(); .alertify_main(); .checkmark_main(20px); diff --git a/www/common/common-interface.js b/www/common/common-interface.js index 601375b96..d406eccaf 100644 --- a/www/common/common-interface.js +++ b/www/common/common-interface.js @@ -647,9 +647,6 @@ define([ var $ok = $(ok).click(function (ev) { close(true, ev); }); var $cancel = $(cancel).click(function (ev) { close(false, ev); }); - if (opt.cancelClass) { $cancel.addClass(opt.cancelClass); } - if (opt.okClass) { $ok.addClass(opt.okClass); } - listener = listenForKeys(function () { $ok.click(); }, function () { diff --git a/www/register/main.js b/www/register/main.js index 289c40df5..e2c30ea64 100644 --- a/www/register/main.js +++ b/www/register/main.js @@ -118,7 +118,7 @@ define([ /* If we're certain that we aren't using these "*Class" APIs anywhere else then we can deprecate them and make this a custom modal in common-interface (or here). */ - cancelClass: 'btn.btn-primary', + cancelClass: 'btn.btn-safe', okClass: 'btn.btn-danger', reverseOrder: true, done: function ($dialog) { From 17e22d87affcab6576c4fdd28d9cc05c77f5627b Mon Sep 17 00:00:00 2001 From: yflory Date: Tue, 23 Jun 2020 11:02:48 +0200 Subject: [PATCH 14/15] Don't leave the team automatically in case of GET_HISTORY error --- www/common/outer/team.js | 22 +++++++++++++++++++++- www/teams/inner.js | 4 ++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/www/common/outer/team.js b/www/common/outer/team.js index 5c31621f7..8cb9aacb6 100644 --- a/www/common/outer/team.js +++ b/www/common/outer/team.js @@ -474,6 +474,16 @@ define([ // Make sure we have not been kicked from the roster var state = roster.getState(); var me = Util.find(ctx, ['store', 'proxy', 'curvePublic']); + // XXX FIXME roster history temporarily corrupted, don't leave the team + if (!state.members || !Object.keys(state.members).length) { + lm.stop(); + roster.stop(); + lm.proxy = {}; + cb({error: 'EINVAL'}); + waitFor.abort(); + console.error(JSON.stringify(state)); + return; + } if (!state.members[me]) { lm.stop(); roster.stop(); @@ -1660,6 +1670,7 @@ define([ var safe = false; if (['drive', 'teams', 'settings'].indexOf(app) !== -1) { safe = true; } Object.keys(teams).forEach(function (id) { + if (!ctx.teams[id]) { return; } t[id] = { owner: teams[id].owner, name: teams[id].metadata.name, @@ -1716,6 +1727,15 @@ define([ team.removeClient = function (clientId) { removeClient(ctx, clientId); }; + var listTeams = function (cb) { + var t = Util.clone(teams); + Object.keys(t).forEach(function (id) { + // If failure to load the team, don't send it + if (ctx.teams[id]) { return; } + t[id].error = true; + }); + cb(t); + }; team.execCommand = function (clientId, obj, cb) { if (ctx.store.offline) { return void cb({ error: 'OFFLINE' }); @@ -1728,7 +1748,7 @@ define([ return void subscribe(ctx, data, clientId, cb); } if (cmd === 'LIST_TEAMS') { - return void cb(store.proxy.teams); + return void listTeams(cb); } if (cmd === 'OPEN_TEAM_CHAT') { return void openTeamChat(ctx, data, clientId, cb); diff --git a/www/teams/inner.js b/www/teams/inner.js index 86b8acf47..30612f3c3 100644 --- a/www/teams/inner.js +++ b/www/teams/inner.js @@ -418,6 +418,10 @@ define([ ])); common.displayAvatar($(avatar), team.metadata.avatar, team.metadata.name); $(btn).click(function () { + if (team.error) { + UI.warn(Messages.error); // XXX better error message - roster bug, can't load the team for now + return; + } openTeam(common, id, team); }); }); From 87af3569dae3eaff1a7513ed1925ef0b3a61a6b1 Mon Sep 17 00:00:00 2001 From: yflory Date: Tue, 23 Jun 2020 11:29:52 +0200 Subject: [PATCH 15/15] Load team rpc when receiving edit rights --- www/common/outer/team.js | 43 ++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/www/common/outer/team.js b/www/common/outer/team.js index 8cb9aacb6..242802bc5 100644 --- a/www/common/outer/team.js +++ b/www/common/outer/team.js @@ -175,6 +175,23 @@ define([ Pinpad.create(ctx.store.network, data, function (e, call) { if (e) { return void cb(e); } team.rpc = call; + team.pin = function (data, cb) { + if (!team.rpc) { return void cb({error: 'TEAM_RPC_NOT_READY'}); } + if (typeof(cb) !== 'function') { console.error('expected a callback'); } + team.rpc.pin(data, function (e, hash) { + if (e) { return void cb({error: e}); } + cb({hash: hash}); + }); + }; + + team.unpin = function (data, cb) { + if (!team.rpc) { return void cb({error: 'TEAM_RPC_NOT_READY'}); } + if (typeof(cb) !== 'function') { console.error('expected a callback'); } + team.rpc.unpin(data, function (e, hash) { + if (e) { return void cb({error: e}); } + cb({hash: hash}); + }); + }; cb(); }); }); @@ -245,27 +262,7 @@ define([ nThen(function (waitFor) { // Init Team RPC if (!keys.drive.edPrivate) { return; } - initRpc(ctx, team, keys.drive, waitFor(function (err) { - if (err) { return; } - - team.pin = function (data, cb) { - if (!team.rpc) { return void cb({error: 'TEAM_RPC_NOT_READY'}); } - if (typeof(cb) !== 'function') { console.error('expected a callback'); } - team.rpc.pin(data, function (e, hash) { - if (e) { return void cb({error: e}); } - cb({hash: hash}); - }); - }; - - team.unpin = function (data, cb) { - if (!team.rpc) { return void cb({error: 'TEAM_RPC_NOT_READY'}); } - if (typeof(cb) !== 'function') { console.error('expected a callback'); } - team.rpc.unpin(data, function (e, hash) { - if (e) { return void cb({error: e}); } - cb({hash: hash}); - }); - }; - })); + initRpc(ctx, team, keys.drive, waitFor(function () {})); }).nThen(function () { // Create the proxy manager var loadSharedFolder = function (id, data, cb, isNew) { @@ -1132,6 +1129,7 @@ define([ teamData.hash = data.hash; teamData.keys.drive.edPrivate = data.keys.drive.edPrivate; teamData.keys.chat.edit = data.keys.chat.edit; + initRpc(ctx, team, teamData.keys.drive, function () {}); var secret = Hash.getSecrets('team', data.hash, teamData.password); team.secondaryKey = secret && secret.keys.secondaryKey; @@ -1140,6 +1138,9 @@ define([ delete teamData.keys.drive.edPrivate; delete teamData.keys.chat.edit; delete team.secondaryKey; + if (team.rpc && team.rpc.destroy) { + team.rpc.destroy(); + } } updateMyRights(ctx, teamId, data.hash);