9 require_once('include/salmon.php');
10 require_once('include/crypto.php');
11 require_once('include/diaspora.php');
13 function receive_post(App $a) {
14 $enabled = intval(get_config('system', 'diaspora_enabled'));
16 logger('mod-diaspora: disabled');
17 http_status_exit(500);
22 if (($a->argc == 2) && ($a->argv[1] === 'public')) {
26 if ($a->argc != 3 || $a->argv[1] !== 'users') {
27 http_status_exit(500);
31 $importer = dba::select('user', array(), array('guid' => $guid, 'account_expired' => false, 'account_removed' => false), array('limit' => 1));
32 if (!dbm::is_result($importer)) {
33 http_status_exit(500);
37 // It is an application/x-www-form-urlencoded
39 logger('mod-diaspora: receiving post', LOGGER_DEBUG);
41 $xml = urldecode($_POST['xml']);
44 $postdata = file_get_contents("php://input");
45 if ($postdata == '') {
46 http_status_exit(500);
49 logger('mod-diaspora: message is in the new format', LOGGER_DEBUG);
50 $msg = Diaspora::decode_raw($importer, $postdata);
52 logger('mod-diaspora: message is in the old format', LOGGER_DEBUG);
53 $msg = Diaspora::decode($importer, $xml);
56 logger('mod-diaspora: decoded', LOGGER_DEBUG);
58 logger('mod-diaspora: decoded msg: ' . print_r($msg, true), LOGGER_DATA);
60 if (!is_array($msg)) {
61 http_status_exit(500);
64 logger('mod-diaspora: dispatching', LOGGER_DEBUG);
68 Diaspora::dispatch_public($msg);
70 $ret = Diaspora::dispatch($importer, $msg);
73 http_status_exit(($ret) ? 200 : 500);