mirror of
https://github.com/cryptpad/cryptpad.git
synced 2026-09-14 11:05:41 +05:00
Remove messaging component from www
This commit is contained in:
parent
a9994a4dac
commit
b7a87376de
@ -16,7 +16,6 @@ const map = {
|
||||
'./src/common/common-credential.js': './www/common/common-credential.js',
|
||||
'./src/common/common-feedback.js': './www/common/common-feedback.js',
|
||||
'./src/common/common-hash.js': './www/common/common-hash.js',
|
||||
'./src/common/common-messaging.js': './www/common/common-messaging.js',
|
||||
'./src/common/common-realtime.js': './www/common/common-realtime.js',
|
||||
'./src/common/common-signing-keys.js': './www/common/common-signing-keys.js',
|
||||
'./src/common/common-util.js': './www/common/common-util.js',
|
||||
|
||||
@ -3453,7 +3453,7 @@ if (typeof(module) !== 'undefined' && module.exports) {
|
||||
require('../common/common-constants'),
|
||||
require('../common/common-feedback'),
|
||||
require('../common/common-realtime'),
|
||||
require('../common/common-messaging'),
|
||||
require('./components/messaging'),
|
||||
require('../common/pinpad'),
|
||||
require('../common/rpc'),
|
||||
require('./components/merge-drive'),
|
||||
@ -3493,7 +3493,7 @@ if (typeof(module) !== 'undefined' && module.exports) {
|
||||
'/common/common-constants.js', // OK
|
||||
'/common/common-feedback.js', // OK
|
||||
'/common/common-realtime.js', // OK
|
||||
'/common/common-messaging.js', // OK
|
||||
'/common/outer/messaging.js', // OK
|
||||
'/common/pinpad.js', // OK
|
||||
'/common/rpc.js', // OK
|
||||
'/common/merge-drive.js', // OK
|
||||
|
||||
@ -985,7 +985,7 @@ const factory = (Messaging, Hash, Util, Crypto, Block) => {
|
||||
|
||||
if (typeof(module) !== 'undefined' && module.exports) {
|
||||
module.exports = factory(
|
||||
require('../../common/common-messaging'),
|
||||
require('./messaging'),
|
||||
require('../../common/common-hash'),
|
||||
require('../../common/common-util'),
|
||||
require('chainpad-crypto'),
|
||||
@ -993,7 +993,7 @@ if (typeof(module) !== 'undefined' && module.exports) {
|
||||
);
|
||||
} else if ((typeof(define) !== 'undefined' && define !== null) && (define.amd !== null)) {
|
||||
define([
|
||||
'/common/common-messaging.js',
|
||||
'/common/outer/messaging.js',
|
||||
'/common/common-hash.js',
|
||||
'/common/common-util.js',
|
||||
'/components/chainpad-crypto/crypto.js',
|
||||
|
||||
@ -142,10 +142,10 @@ const factory = (Crypto, Hash, Util, Constants, Realtime) => {
|
||||
if (typeof(module) !== 'undefined' && module.exports) {
|
||||
module.exports = factory(
|
||||
require('chainpad-crypto'),
|
||||
require('./common-hash'),
|
||||
require('./common-util'),
|
||||
require('./common-constants'),
|
||||
require('./common-realtime')
|
||||
require('../../common/common-hash'),
|
||||
require('../../common/common-util'),
|
||||
require('../../common/common-constants'),
|
||||
require('../../common/common-realtime')
|
||||
);
|
||||
} else if ((typeof(define) !== 'undefined' && define !== null) && (define.amd !== null)) {
|
||||
define([
|
||||
@ -512,7 +512,7 @@ if (typeof(module) !== 'undefined' && module.exports) {
|
||||
require('../../common/common-feedback'),
|
||||
require('../../common/common-hash'),
|
||||
require('../../common/common-util'),
|
||||
require('../../common/common-messaging'),
|
||||
require('./messaging'),
|
||||
require('../../common/cryptget'),
|
||||
require('../modules/mailbox'),
|
||||
undefined,
|
||||
@ -525,7 +525,7 @@ if (typeof(module) !== 'undefined' && module.exports) {
|
||||
'/common/common-feedback.js',
|
||||
'/common/common-hash.js',
|
||||
'/common/common-util.js',
|
||||
'/common/common-messaging.js',
|
||||
'/common/outer/messaging.js',
|
||||
'/common/cryptget.js',
|
||||
'/common/outer/mailbox.js',
|
||||
'/customize/messages.js',
|
||||
|
||||
@ -679,7 +679,7 @@ if (typeof(module) !== 'undefined' && module.exports) {
|
||||
require('../../common/common-util'),
|
||||
require('../../common/common-hash'),
|
||||
require('../../common/common-realtime'),
|
||||
require('../../common/common-messaging'),
|
||||
require('../components/messaging'),
|
||||
require('../../common/notify'),
|
||||
require('../components/mailbox-handlers'),
|
||||
require('chainpad-netflux'),
|
||||
@ -691,7 +691,7 @@ if (typeof(module) !== 'undefined' && module.exports) {
|
||||
'/common/common-util.js',
|
||||
'/common/common-hash.js',
|
||||
'/common/common-realtime.js',
|
||||
'/common/common-messaging.js',
|
||||
'/common/outer/messaging.js',
|
||||
'/common/notify.js',
|
||||
'/common/outer/mailbox-handlers.js',
|
||||
'chainpad-netflux',
|
||||
|
||||
@ -1126,7 +1126,7 @@ if (typeof(module) !== 'undefined' && module.exports) {
|
||||
require('../../common/common-hash'),
|
||||
require('../../common/common-util'),
|
||||
require('../../common/common-realtime'),
|
||||
require('../../common/common-messaging'),
|
||||
require('../components/messaging'),
|
||||
require('../../common/common-constants'),
|
||||
undefined,
|
||||
require('../../common/pad-types'),
|
||||
@ -1138,7 +1138,7 @@ if (typeof(module) !== 'undefined' && module.exports) {
|
||||
'/common/common-hash.js',
|
||||
'/common/common-util.js',
|
||||
'/common/common-realtime.js',
|
||||
'/common/common-messaging.js',
|
||||
'/common/outer/messaging.js',
|
||||
'/common/common-constants.js',
|
||||
'/customize/messages.js',
|
||||
'/common/pad-types.js',
|
||||
|
||||
@ -2237,7 +2237,7 @@ if (typeof(module) !== 'undefined' && module.exports) {
|
||||
require('../../common/user-object'),
|
||||
require('../components/sharedfolder'),
|
||||
require('../components/roster'),
|
||||
require('../../common/common-messaging'),
|
||||
require('../components/messaging'),
|
||||
require('../../common/common-feedback'),
|
||||
require('../components/invitation'),
|
||||
require('../../common/cryptget'),
|
||||
@ -2262,7 +2262,7 @@ if (typeof(module) !== 'undefined' && module.exports) {
|
||||
'/common/user-object.js',
|
||||
'/common/outer/sharedfolder.js',
|
||||
'/common/outer/roster.js',
|
||||
'/common/common-messaging.js',
|
||||
'/common/outer/messaging.js',
|
||||
'/common/common-feedback.js',
|
||||
'/common/outer/invitation.js',
|
||||
'/common/cryptget.js',
|
||||
|
||||
@ -11,7 +11,6 @@ import * as Util from '../common/common-util.js';
|
||||
import * as Hash from '../common/common-hash.js';
|
||||
import * as Feedback from '../common/common-feedback.js';
|
||||
import * as Realtime from '../common/common-realtime.js';
|
||||
import * as Messaging from '../common/common-messaging.js';
|
||||
import * as Constants from '../common/common-constants.js';
|
||||
import * as Credential from '../common/common-credential.js';
|
||||
import * as ProxyManager from '../common/proxy-manager.js';
|
||||
@ -32,6 +31,7 @@ import * as AsyncConnector from './core/async-connector.js';
|
||||
|
||||
// Components
|
||||
import * as Migrate from './components/migrate-user-object.js';
|
||||
import * as Messaging from './components/messaging.js';
|
||||
|
||||
// Modules
|
||||
import * as Mailbox from './modules/mailbox.js';
|
||||
|
||||
@ -1,161 +0,0 @@
|
||||
// SPDX-FileCopyrightText: 2023 XWiki CryptPad Team <contact@cryptpad.org> and contributors
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
(() => {
|
||||
const factory = (Crypto, Hash, Util, Constants, Realtime) => {
|
||||
var Msg = {};
|
||||
|
||||
var createData = Msg.createData = function (proxy, hash) {
|
||||
var data = {
|
||||
channel: hash || Hash.createChannelId(),
|
||||
displayName: proxy['cryptpad.username'],
|
||||
profile: proxy.profile && proxy.profile.view,
|
||||
edPublic: proxy.edPublic,
|
||||
curvePublic: proxy.curvePublic,
|
||||
notifications: Util.find(proxy, ['mailboxes', 'notifications', 'channel']),
|
||||
avatar: proxy.profile && proxy.profile.avatar,
|
||||
uid: proxy.uid,
|
||||
};
|
||||
if (hash === false) { delete data.channel; }
|
||||
return data;
|
||||
};
|
||||
|
||||
var getFriend = Msg.getFriend = function (proxy, pubkey) {
|
||||
if (!pubkey) { return; }
|
||||
if (pubkey === proxy.curvePublic) {
|
||||
var data = createData(proxy);
|
||||
delete data.channel;
|
||||
return data;
|
||||
}
|
||||
return proxy.friends ? proxy.friends[pubkey] : undefined;
|
||||
};
|
||||
|
||||
var getFriendList = Msg.getFriendList = function (proxy) {
|
||||
if (!proxy.friends) { proxy.friends = {}; }
|
||||
return proxy.friends;
|
||||
};
|
||||
|
||||
var eachFriend = function (friends, cb) {
|
||||
Object.keys(friends).forEach(function (id) {
|
||||
if (id === 'me') { return; }
|
||||
cb(friends[id], id, friends);
|
||||
});
|
||||
};
|
||||
|
||||
Msg.getFriendChannelsList = function (proxy) {
|
||||
var list = [];
|
||||
eachFriend(proxy.friends, function (friend) {
|
||||
list.push(friend.channel);
|
||||
});
|
||||
return list;
|
||||
};
|
||||
|
||||
Msg.declineFriendRequest = function (store, data, cb) {
|
||||
store.mailbox.sendTo('DECLINE_FRIEND_REQUEST', {}, {
|
||||
channel: data.notifications,
|
||||
curvePublic: data.curvePublic
|
||||
}, function (obj) {
|
||||
cb(obj);
|
||||
});
|
||||
};
|
||||
Msg.acceptFriendRequest = function (store, data, cb) {
|
||||
var friend = getFriend(store.proxy, data.curvePublic) || {};
|
||||
var myData = createData(store.proxy, friend.channel || data.channel);
|
||||
store.mailbox.sendTo('ACCEPT_FRIEND_REQUEST', { user: myData }, {
|
||||
channel: data.notifications,
|
||||
curvePublic: data.curvePublic
|
||||
}, function (obj) {
|
||||
cb(obj);
|
||||
});
|
||||
};
|
||||
Msg.addToFriendList = function (cfg, data, cb) {
|
||||
var proxy = cfg.proxy;
|
||||
var friends = getFriendList(proxy);
|
||||
var pubKey = data.curvePublic; // todo validata data
|
||||
|
||||
if (pubKey === proxy.curvePublic) { return void cb("E_MYKEY"); }
|
||||
|
||||
friends[pubKey] = data;
|
||||
|
||||
Realtime.whenRealtimeSyncs(cfg.realtime, function () {
|
||||
cb();
|
||||
cfg.pinPads([data.channel], function (res) {
|
||||
if (res.error) { console.error(res.error); }
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
Msg.updateMyData = function (store, curve) {
|
||||
var myData = createData(store.proxy, false);
|
||||
if (store.proxy.friends) {
|
||||
store.proxy.friends.me = Util.clone(myData);
|
||||
delete store.proxy.friends.me.channel;
|
||||
}
|
||||
if (store.modules['team']) {
|
||||
store.modules['team'].updateMyData(myData);
|
||||
}
|
||||
var todo = function (friend) {
|
||||
if (!friend || !friend.notifications) { return; }
|
||||
delete friend.user;
|
||||
myData.channel = friend.channel;
|
||||
store.mailbox.sendTo('UPDATE_DATA', myData, {
|
||||
channel: friend.notifications,
|
||||
curvePublic: friend.curvePublic
|
||||
}, function (obj) {
|
||||
if (obj && obj.error) { console.error(obj); }
|
||||
});
|
||||
};
|
||||
if (curve) {
|
||||
var friend = getFriend(store.proxy, curve);
|
||||
return void todo(friend);
|
||||
}
|
||||
eachFriend(store.proxy.friends || {}, todo);
|
||||
};
|
||||
|
||||
Msg.removeFriend = function (store, curvePublic, cb) {
|
||||
var proxy = store.proxy;
|
||||
var friend = proxy.friends[curvePublic];
|
||||
if (!friend) { return void cb({error: 'ENOENT'}); }
|
||||
if (!friend.notifications) { return void cb({error: 'EINVAL'}); }
|
||||
|
||||
store.mailbox.sendTo('UNFRIEND', {
|
||||
curvePublic: proxy.curvePublic
|
||||
}, {
|
||||
channel: friend.notifications,
|
||||
curvePublic: friend.curvePublic
|
||||
}, function (obj) {
|
||||
if (obj && obj.error) {
|
||||
return void cb(obj);
|
||||
}
|
||||
store.messenger.onFriendRemoved(curvePublic, friend.channel);
|
||||
delete proxy.friends[curvePublic];
|
||||
Realtime.whenRealtimeSyncs(store.realtime, function () {
|
||||
cb(obj);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
return Msg;
|
||||
};
|
||||
|
||||
if (typeof(module) !== 'undefined' && module.exports) {
|
||||
module.exports = factory(
|
||||
require('chainpad-crypto'),
|
||||
require('./common-hash'),
|
||||
require('./common-util'),
|
||||
require('./common-constants'),
|
||||
require('./common-realtime')
|
||||
);
|
||||
} else if ((typeof(define) !== 'undefined' && define !== null) && (define.amd !== null)) {
|
||||
define([
|
||||
'/components/chainpad-crypto/crypto.js',
|
||||
'/common/common-hash.js',
|
||||
'/common/common-util.js',
|
||||
'/common/common-constants.js',
|
||||
'/common/common-realtime.js',
|
||||
], factory);
|
||||
} else {
|
||||
// unsupported initialization
|
||||
}
|
||||
})();
|
||||
@ -9,7 +9,6 @@ define([
|
||||
'/common/common-util.js',
|
||||
'/common/common-hash.js',
|
||||
'/common/outer/cache-store.js',
|
||||
'/common/common-messaging.js',
|
||||
'/common/common-constants.js',
|
||||
'/common/common-feedback.js',
|
||||
'/common/visible.js',
|
||||
@ -25,7 +24,7 @@ define([
|
||||
'/components/nthen/index.js',
|
||||
'/components/tweetnacl/nacl-fast.min.js'
|
||||
], function (Config, Broadcast, Messages, Util, Hash, Cache,
|
||||
Messaging, Constants, Feedback, Visible, UserObject, LocalStore, Channel, Block,
|
||||
Constants, Feedback, Visible, UserObject, LocalStore, Channel, Block,
|
||||
Cred, Login, Store, AppConfig, nThen) {
|
||||
|
||||
/* This file exposes functionality which is specific to Cryptpad, but not to
|
||||
|
||||
Loading…
Reference in New Issue
Block a user