From a817242fe5a8f58c0a6d6ec2ef26ee189be661bf Mon Sep 17 00:00:00 2001 From: yflory Date: Wed, 18 Dec 2019 13:05:01 +0100 Subject: [PATCH] Fix join team for anon users --- www/common/cryptpad-common.js | 5 +++++ www/common/outer/async-store.js | 6 ++++++ www/common/outer/store-rpc.js | 2 ++ www/common/outer/team.js | 4 ++++ www/common/sframe-common-outer.js | 4 ++++ www/teams/inner.js | 14 ++++++++++++-- 6 files changed, 33 insertions(+), 2 deletions(-) diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js index 40db70457..c869967af 100644 --- a/www/common/cryptpad-common.js +++ b/www/common/cryptpad-common.js @@ -779,6 +779,11 @@ define([ postMessage("SEND_FRIEND_REQUEST", data, cb); }; + // Team + common.anonGetPreviewContent = function (data, cb) { + postMessage("ANON_GET_PREVIEW_CONTENT", data, cb); + }; + // Onlyoffice var onlyoffice = common.onlyoffice = {}; onlyoffice.execCommand = function (data, cb) { diff --git a/www/common/outer/async-store.js b/www/common/outer/async-store.js index c5b6f6a42..870a539e7 100644 --- a/www/common/outer/async-store.js +++ b/www/common/outer/async-store.js @@ -1273,6 +1273,12 @@ define([ }); }; + Store.anonGetPreviewContent = function (clientId, data, cb) { + Team.anonGetPreviewContent({ + store: store + }, data, cb); + }; + // Get hashes for the share button // If we can find a stronger hash Store.getStrongerHash = function (clientId, data, _cb) { diff --git a/www/common/outer/store-rpc.js b/www/common/outer/store-rpc.js index 12b5ff6e5..49250582f 100644 --- a/www/common/outer/store-rpc.js +++ b/www/common/outer/store-rpc.js @@ -60,6 +60,8 @@ define([ // Messaging ANSWER_FRIEND_REQUEST: Store.answerFriendRequest, SEND_FRIEND_REQUEST: Store.sendFriendRequest, + // Team invitation + ANON_GET_PREVIEW_CONTENT: Store.anonGetPreviewContent, // OnlyOffice OO_COMMAND: Store.onlyoffice.execCommand, // Cursor diff --git a/www/common/outer/team.js b/www/common/outer/team.js index 81fe1b82f..f70fcbf36 100644 --- a/www/common/outer/team.js +++ b/www/common/outer/team.js @@ -1684,6 +1684,10 @@ define([ return team; }; + Team.anonGetPreviewContent = function (cfg, data, cb) { + getPreviewContent(cfg, data, null, cb); + }; + return Team; }); diff --git a/www/common/sframe-common-outer.js b/www/common/sframe-common-outer.js index 82b9bf2e7..05cafbdec 100644 --- a/www/common/sframe-common-outer.js +++ b/www/common/sframe-common-outer.js @@ -675,6 +675,10 @@ define([ Cryptpad.messaging.answerFriendRequest(data, cb); }); + sframeChan.on('Q_ANON_GET_PREVIEW_CONTENT', function (data, cb) { + Cryptpad.anonGetPreviewContent(data, cb); + }); + // History sframeChan.on('Q_GET_FULL_HISTORY', function (data, cb) { var crypto = Crypto.createEncryptor(secret.keys); diff --git a/www/teams/inner.js b/www/teams/inner.js index a00c035b7..35fd8a9fb 100644 --- a/www/teams/inner.js +++ b/www/teams/inner.js @@ -1149,8 +1149,18 @@ define([ }; nThen(function (waitFor) { - // XXX XXX Check number of teams first! - APP.module.execCommand("GET_PREVIEW_CONTENT", { + // Get preview content. + // Use the team module if we're logged in, or sframeChan if we're not + var f = function (data, cb) { + if (driveAPP.loggedIn) { + return void APP.module.execCommand('GET_PREVIEW_CONTENT', data, cb); + } + var sframeChan = common.getSframeChannel(); + sframeChan.query('Q_ANON_GET_PREVIEW_CONTENT', data, function (err, json) { + cb(json); + }); + }; + f({ seeds: seeds, }, waitFor(function (json) { if (json && json.error) { // XXX this is failing with "team is disabled"