debugging on call, but mostly, specify json headers, etc.

This commit is contained in:
howard-stearns 2017-05-04 14:45:58 -07:00
parent 9954380ce3
commit 25ab8e7e94

View file

@ -21,7 +21,7 @@
if (!DEBUG) { if (!DEBUG) {
return; return;
} }
print([].map.call(arguments, JSON.stringify)); print('tablet-goto.js:', [].map.call(arguments, JSON.stringify));
} }
var gotoQmlSource = "TabletAddressDialog.qml"; var gotoQmlSource = "TabletAddressDialog.qml";
@ -46,6 +46,7 @@
switch (message.method) { switch (message.method) {
case 'request': case 'request':
request(message.params, function (error, data) { request(message.params, function (error, data) {
debug('rpc', request, 'error:', error, 'data:', data);
response.error = error; response.error = error;
response.result = data; response.result = data;
tablet.sendToQml(response); tablet.sendToQml(response);
@ -109,12 +110,14 @@
var stories = {}, pingPong = false; var stories = {}, pingPong = false;
function expire(id) { function expire(id) {
request({ var options = {
uri: location.metaverseServerUrl + '/api/v1/user_stories/' + id, uri: location.metaverseServerUrl + '/api/v1/user_stories/' + id,
method: 'PUT', method: 'PUT',
body: {expired: true} json: true,
}, function (error, response) { body: {expire: "true"}
debug('expired story', id, 'error:', error, 'response:', response); };
request(options, function (error, response) {
debug('expired story', options, 'error:', error, 'response:', response);
if (error || (response.status !== 'success')) { if (error || (response.status !== 'success')) {
print("ERROR expiring story: ", error || response.status); print("ERROR expiring story: ", error || response.status);
} }
@ -147,7 +150,9 @@
var stored = stories[story.id], storedOrNew = stored || story; var stored = stories[story.id], storedOrNew = stored || story;
debug('story exists:', !!stored, storedOrNew); debug('story exists:', !!stored, storedOrNew);
if ((storedOrNew.username === Account.username) && (storedOrNew.place_name !== location.placename)) { if ((storedOrNew.username === Account.username) && (storedOrNew.place_name !== location.placename)) {
expire(story.id); if (storedOrNew.audience == 'for_connections') { // Only expire if we haven't already done so.
expire(story.id);
}
return; // before marking return; // before marking
} }
storedOrNew.pingPong = pingPong; storedOrNew.pingPong = pingPong;
@ -161,6 +166,7 @@
}); });
for (key in stories) { // Any story we were tracking that was not marked, has expired. for (key in stories) { // Any story we were tracking that was not marked, has expired.
if (stories[key].pingPong !== pingPong) { if (stories[key].pingPong !== pingPong) {
debug('removing story', key);
delete stories[key]; delete stories[key];
} }
} }