request capabilities temp
This commit is contained in:
@@ -1090,6 +1090,7 @@ define([
|
||||
var channels = Store.channels = store.channels = {};
|
||||
|
||||
Store.joinPad = function (clientId, data) {
|
||||
console.log('joining', data.channel);
|
||||
var isNew = typeof channels[data.channel] === "undefined";
|
||||
var channel = channels[data.channel] = channels[data.channel] || {
|
||||
queue: [],
|
||||
@@ -1243,6 +1244,65 @@ define([
|
||||
channel.sendMessage(msg, clientId, cb);
|
||||
};
|
||||
|
||||
Store.requestPadAccess = function (clientId, data, cb) {
|
||||
// Get owners from pad metadata
|
||||
// Try to find an owner in our friend list
|
||||
// Mailbox...
|
||||
var channel = channels[data.channel];
|
||||
if (!data.send && channel && (!channel.data || !channel.data.channel)) {
|
||||
var i = 0;
|
||||
var it = setInterval(function () {
|
||||
if (channel.data && channel.data.channel) {
|
||||
clearInterval(it);
|
||||
Store.requestPadAccess(clientId, data, cb);
|
||||
return;
|
||||
}
|
||||
if (i >= 300) { // One minute timeout
|
||||
clearInterval(it);
|
||||
}
|
||||
i++
|
||||
}, 200);
|
||||
return;
|
||||
};
|
||||
var fData = channel.data || {};
|
||||
if (fData.owners) {
|
||||
var friends = store.proxy.friends || {};
|
||||
if (Object.keys(friends).length > 1) {
|
||||
var owner;
|
||||
fData.owners.some(function (edPublic) {
|
||||
return Object.keys(friends).some(function (curve) {
|
||||
if (curve === "me") { return; }
|
||||
if (edPublic === friends[curve].edPublic &&
|
||||
friends[curve].notifications) {
|
||||
owner = friends[curve];
|
||||
return true;
|
||||
}
|
||||
});
|
||||
});
|
||||
if (owner) {
|
||||
console.log(owner);
|
||||
if (data.send) {
|
||||
// XXX send the pad title here...? or get it from the recipient's drive
|
||||
var myData = Messaging.createData(store.proxy);
|
||||
delete myData.channel;
|
||||
store.mailbox.sendTo('REQUEST_PAD_ACCESS', {
|
||||
channel: data.channel,
|
||||
user: myData
|
||||
}, {
|
||||
channel: owner.notifications,
|
||||
curvePublic: owner.curvePublic
|
||||
}, function () {
|
||||
cb({state: true});
|
||||
});
|
||||
return;
|
||||
}
|
||||
return void cb({state: true});
|
||||
}
|
||||
}
|
||||
}
|
||||
cb({sent: false});
|
||||
};
|
||||
|
||||
// GET_FULL_HISTORY from sframe-common-outer
|
||||
Store.getFullHistory = function (clientId, data, cb) {
|
||||
var network = store.network;
|
||||
|
||||
Reference in New Issue
Block a user