Created
September 3, 2019 15:35
-
-
Save scripting/43fc83d0cbfe811dcac284fa3890f291 to your computer and use it in GitHub Desktop.
This is a typical XML-RPC server written in JavaScript as of today. There's still more cleanup to do, for example, you shouldn't have to specify flPostEnabled in config, since XML-RPC calls are only made via POST, it can be handled at the lower level.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const xmlrpc = require ("davexmlrpc"); | |
const utils = require ("daveutils"); | |
const davehttp = require ("davehttp"); | |
const mail = require ("davemail"); | |
const fs = require ("fs"); | |
var config = { | |
port: 1417, | |
flPostEnabled: true, | |
flLogToConsole: true, | |
xmlRpcPath: "/rpc2" | |
} | |
xmlrpc.startServerOverHttp (config, function (xmlRpcRequest) { | |
function mailSend (params, callback) { | |
var recipient = params [0]; | |
var title = params [1]; | |
var mailtext = params [2]; | |
var sender = params [3]; | |
mail.send (recipient, title, mailtext, sender, function (err, data) { | |
callback (err, data); | |
}); | |
} | |
switch (xmlRpcRequest.verb) { | |
case "mail.send": | |
mailSend (xmlRpcRequest.params, xmlRpcRequest.returnVal); | |
return (true); //we handled it | |
} | |
return (false); //we didn't handle it | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment