Enable friend requests from secure pads

This commit is contained in:
yflory
2017-08-28 16:21:05 +02:00
parent 147d88d845
commit 88cb4fd83c
7 changed files with 82 additions and 17 deletions

View File

@@ -103,6 +103,17 @@ define([
ctx.sframeChan.query('Q_GET_FULL_HISTORY', null, cb);
};
// Friends
var pendingFriends = [];
funcs.getPendingFriends = function () {
return pendingFriends.slice();
};
funcs.sendFriendRequest = function (netfluxId) {
ctx.sframeChan.query('Q_SEND_FRIEND_REQUEST', netfluxId, $.noop);
pendingFriends.push(netfluxId);
};
// Feedback
funcs.feedback = function (action, force) {
if (force !== true) {
if (!action) { return; }
@@ -297,6 +308,16 @@ define([
ctx.sframeChan.on('EV_RT_CONNECT', function () { CommonRealtime.setConnectionState(true); });
ctx.sframeChan.on('EV_RT_DISCONNECT', function () { CommonRealtime.setConnectionState(false); });
ctx.sframeChan.on('Q_INCOMING_FRIEND_REQUEST', function (confirmMsg, cb) {
Cryptpad.confirm(confirmMsg, cb, null, true);
});
ctx.sframeChan.on('EV_FRIEND_REQUEST', function (data) {
var i = pendingFriends.indexOf(data.sender);
if (i !== -1) { pendingFriends.splice(i, 1); }
Cryptpad.log(data.logText);
});
cb(funcs);
});
} };