1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/jappix_ynh.git synced 2024-09-03 19:26:19 +02:00
jappix_ynh/source/js/httpreply.js
titoko titoko 96663cd7da add source
2013-11-27 12:56:15 +01:00

41 lines
969 B
JavaScript
Executable file

/*
Jappix - An open social platform
These are the http-reply JS scripts for Jappix
-------------------------------------------------
License: AGPL
Author: Valérian Saliou
Last revision: 16/04/13
*/
// Replies to a HTTP request
function requestReply(value, xml) {
// We parse the xml content
var from = fullXID(getStanzaFrom(xml));
var confirm = $(xml.getNode()).find('confirm');
var xmlns = confirm.attr('xmlns');
var id = confirm.attr('id');
var method = confirm.attr('method');
var url = confirm.attr('url');
// We generate the reply message
var aMsg = new JSJaCMessage();
aMsg.setTo(from);
// If "no"
if(value == 'no') {
aMsg.setType('error');
aMsg.appendNode('error', {'code': '401', 'type': 'auth'});
}
// We set the confirm node
aMsg.appendNode('confirm', {'xmlns': xmlns, 'url': url, 'id': id, 'method': method});
// We send the message
con.send(aMsg, handleErrorReply);
logThis('Replying HTTP auth request: ' + from, 3);
}