8 require_once('include/salmon.php');
9 require_once('include/crypto.php');
10 require_once('include/diaspora.php');
14 function receive_post(&$a) {
16 if($a->argc != 3 || $a->argv[1] !== 'users')
17 http_status_exit(500);
21 $r = q("SELECT * FROM `user` WHERE `guid` = '%s' LIMIT 1",
25 http_status_exit(500);
31 logger('mod-diaspora: new salmon ' . $xml, LOGGER_DATA);
34 http_status_exit(500);
36 $msg = diaspora_decode($importer,$xml);
38 http_status_exit(500);
41 $parsed_xml = parse_xml_string($msg);
43 $xmlbase = $parsed_xml->post;
45 // If we reached this point, the message is good.
46 // Now let's figure out if the author is allowed to send us stuff.
48 $r = q("SELECT * FROM `contact` WHERE `network` = 'dspr' AND ( `url` = '%s' OR `alias` = '%s')
49 AND `uid` = %d LIMIT 1",
52 intval($importer['uid'])
55 logger('mod-diaspora: Author unknown to us.');
58 // is this a follower? Or have we ignored the person?
59 // If so we can not accept this post.
60 // However we will accept a sharing e.g. friend request
62 if((count($r)) && (($r[0]['readonly']) || ($r[0]['rel'] == CONTACT_IS_FOLLOWER) || ($r[0]['blocked']))) {
63 if(! $xmlbase->request) {
64 logger('mod-diaspora: Ignoring this author.');
65 http_status_exit(202);
70 require_once('include/items.php');
72 $contact = ((count($r)) ? $r[0] : null);
74 logger('diaspora msg: ' . $msg, LOGGER_DATA);
76 if($xmlbase->request) {
77 diaspora_request($importer,$contact,$xmlbase->request);
79 elseif($xmlbase->status_message) {
80 diaspora_post($importer,$contact,$xmlbase->status_message);
82 elseif($xmlbase->comment) {
83 diaspora_comment($importer,$contact,$xmlbase->comment);
85 elseif($xmlbase->like) {
86 diaspora_like($importer,$contact,$xmlbase->like);
88 elseif($xmlbase->retraction) {
89 diaspora_retraction($importer,$contact,$xmlbase->retraction);
92 logger('mod-diaspora: unknown message type: ' . print_r($xmlbase,true));
95 http_status_exit(200);