Add shared folder module

pull/1/head
yflory 5 years ago
parent 3745bb76dc
commit 7658dbcaeb

@ -10,6 +10,7 @@ define([
'/common/common-realtime.js', '/common/common-realtime.js',
'/common/common-messaging.js', '/common/common-messaging.js',
'/common/common-messenger.js', '/common/common-messenger.js',
'/common/outer/sharedfolder.js',
'/common/outer/cursor.js', '/common/outer/cursor.js',
'/common/outer/onlyoffice.js', '/common/outer/onlyoffice.js',
'/common/outer/mailbox.js', '/common/outer/mailbox.js',
@ -24,8 +25,9 @@ define([
'/bower_components/chainpad-listmap/chainpad-listmap.js', '/bower_components/chainpad-listmap/chainpad-listmap.js',
'/bower_components/nthen/index.js', '/bower_components/nthen/index.js',
'/bower_components/saferphore/index.js', '/bower_components/saferphore/index.js',
], function (Sortify, UserObject, ProxyManager, Migrate, Hash, Util, Constants, Feedback, Realtime, Messaging, Messenger, ], function (Sortify, UserObject, ProxyManager, Migrate, Hash, Util, Constants, Feedback,
Cursor, OnlyOffice, Mailbox, Profile, Team, NetConfig, AppConfig, Realtime, Messaging, Messenger,
SF, Cursor, OnlyOffice, Mailbox, Profile, Team, NetConfig, AppConfig,
Crypto, ChainPad, CpNetflux, Listmap, nThen, Saferphore) { Crypto, ChainPad, CpNetflux, Listmap, nThen, Saferphore) {
var create = function () { var create = function () {
@ -1503,31 +1505,11 @@ define([
// SHARED FOLDERS // SHARED FOLDERS
var loadSharedFolder = Store.loadSharedFolder = function (id, data, cb) { var loadSharedFolder = Store.loadSharedFolder = function (id, data, cb) {
var parsed = Hash.parsePadUrl(data.href); var rt = SF.load({
var secret = Hash.getSecrets('drive', parsed.hash, data.password);
var owners = data.owners;
var listmapConfig = {
data: {},
websocketURL: NetConfig.getWebsocketURL(),
channel: secret.channel,
readOnly: false,
crypto: Crypto.createEncryptor(secret.keys),
userName: 'sharedFolder',
logLevel: 1,
ChainPad: ChainPad,
classic: true,
network: store.network, network: store.network,
metadata: { manager: store.manager
validateKey: secret.keys.validateKey || undefined, }, id, data, cb);
owners: owners
}
};
var rt = Listmap.create(listmapConfig);
store.sharedFolders[id] = rt; store.sharedFolders[id] = rt;
rt.proxy.on('ready', function (info) {
store.manager.addProxy(id, rt.proxy, info.leave);
cb(rt, info.metadata);
});
if (store.driveEvents) { if (store.driveEvents) {
registerProxyEvents(rt.proxy, id); registerProxyEvents(rt.proxy, id);
} }

@ -0,0 +1,47 @@
define([
'/common/common-hash.js',
'/bower_components/chainpad-crypto/crypto.js',
'/bower_components/chainpad-listmap/chainpad-listmap.js',
'/bower_components/chainpad/chainpad.dist.js',
], function (Hash, Crypto, Listmap, ChainPad) {
var SF = {};
SF.load = function (config, id, data, cb) {
var network = config.network;
var manager = config.manager;
var parsed = Hash.parsePadUrl(data.href);
var secret = Hash.getSecrets('drive', parsed.hash, data.password);
var owners = data.owners;
var listmapConfig = {
data: {},
channel: secret.channel,
readOnly: false,
crypto: Crypto.createEncryptor(secret.keys),
userName: 'sharedFolder',
logLevel: 1,
ChainPad: ChainPad,
classic: true,
network: network,
metadata: {
validateKey: secret.keys.validateKey || undefined,
owners: owners
}
};
var rt = Listmap.create(listmapConfig);
//store.sharedFolders[id] = rt; // XXX
rt.proxy.on('ready', function (info) {
manager.addProxy(id, rt.proxy, info.leave);
cb(rt, info.metadata);
});
// XXX
/*if (store.driveEvents) {
registerProxyEvents(rt.proxy, id);
}*/
return rt;
};
return SF;
});

@ -91,7 +91,6 @@ define([
initializeTeams(ctx, waitFor(function (err) { initializeTeams(ctx, waitFor(function (err) {
if (err) { return; } if (err) { return; }
openChannel(ctx);
})); }));
Object.keys(teams).forEach(function (id) { Object.keys(teams).forEach(function (id) {

Loading…
Cancel
Save