]> git.mxchange.org Git - friendica.git/blob - mod/post.php
Merge pull request #3149 from annando/1601-new-diaspora-mention
[friendica.git] / mod / post.php
1 <?php
2
3 /**
4  * Zot endpoint
5  */
6
7
8 require_once('include/salmon.php');
9 require_once('include/crypto.php');
10 // not yet ready for prime time
11 //require_once('include/zot.php');
12
13 function post_post(App $a) {
14
15         $bulk_delivery = false;
16
17         if ($a->argc == 1) {
18                 $bulk_delivery = true;
19         }
20         else {
21                 $nickname = $a->argv[2];
22                 $r = q("SELECT * FROM `user` WHERE `nickname` = '%s'
23                                 AND `account_expired` = 0 AND `account_removed` = 0 LIMIT 1",
24                         dbesc($nickname)
25                 );
26                 if (! dbm::is_result($r)) {
27                         http_status_exit(500);
28                 }
29
30                 $importer = $r[0];
31         }
32
33         $xml = file_get_contents('php://input');
34
35         logger('mod-post: new zot: ' . $xml, LOGGER_DATA);
36
37         if(! $xml)
38                 http_status_exit(500);
39
40         $msg = zot_decode($importer,$xml);
41
42         logger('mod-post: decoded msg: ' . print_r($msg,true), LOGGER_DATA);
43
44         if(! is_array($msg))
45                 http_status_exit(500);
46
47         $ret = 0;
48         $ret = zot_incoming($bulk_delivery, $importer,$msg);
49         http_status_exit(($ret) ? $ret : 200);
50         // NOTREACHED
51 }
52