|
|
|
@ -1242,10 +1242,9 @@ define([
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Store.requestPadAccess = function (clientId, data, cb) {
|
|
|
|
|
// Get owners from pad metadata
|
|
|
|
|
// Try to find an owner in our friend list
|
|
|
|
|
// Mailbox...
|
|
|
|
|
var owner = data.owner;
|
|
|
|
|
var channel = channels[data.channel];
|
|
|
|
|
if (!channel) { return void cb({error: 'ENOTFOUND'}); }
|
|
|
|
|
if (!data.send && channel && (!channel.data || !channel.data.channel)) {
|
|
|
|
|
var i = 0;
|
|
|
|
|
var it = setInterval(function () {
|
|
|
|
@ -1261,11 +1260,12 @@ define([
|
|
|
|
|
}, 200);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// If the owner was not is the pad metadata, check if it is a friend
|
|
|
|
|
var fData = channel.data || {};
|
|
|
|
|
if (fData.owners) {
|
|
|
|
|
if (!owner && 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; }
|
|
|
|
@ -1276,6 +1276,10 @@ define([
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// If send is true, send the request to the owner.
|
|
|
|
|
if (owner) {
|
|
|
|
|
if (data.send) {
|
|
|
|
|
var myData = Messaging.createData(store.proxy);
|
|
|
|
@ -1293,9 +1297,7 @@ define([
|
|
|
|
|
}
|
|
|
|
|
return void cb({state: true});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
cb({sent: false});
|
|
|
|
|
cb({state: false});
|
|
|
|
|
};
|
|
|
|
|
Store.givePadAccess = function (clientId, data, cb) {
|
|
|
|
|
var edPublic = store.proxy.edPublic;
|
|
|
|
@ -1332,6 +1334,28 @@ define([
|
|
|
|
|
cb();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Store.getPadMetadata = function (clientId, data, cb) {
|
|
|
|
|
if (!data.channel) { return void cb({ error: 'ENOTFOUND'}); }
|
|
|
|
|
var channel = channels[data.channel];
|
|
|
|
|
if (!channel) { return void cb({ error: 'ENOTFOUND' }); }
|
|
|
|
|
if (!channel.data || !channel.data.channel) {
|
|
|
|
|
var i = 0;
|
|
|
|
|
var it = setInterval(function () {
|
|
|
|
|
if (channel.data && channel.data.channel) {
|
|
|
|
|
clearInterval(it);
|
|
|
|
|
Store.getPadMetadata(clientId, data, cb);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (i >= 300) { // One minute timeout
|
|
|
|
|
clearInterval(it);
|
|
|
|
|
}
|
|
|
|
|
i++;
|
|
|
|
|
}, 200);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
cb(channel.data || {});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// GET_FULL_HISTORY from sframe-common-outer
|
|
|
|
|
Store.getFullHistory = function (clientId, data, cb) {
|
|
|
|
|
var network = store.network;
|
|
|
|
|