]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - plugins/OStatus/actions/salmon.php
OStatus: check only direct children in ActivityUtil::child; fixes pulling actor's...
[quix0rs-gnu-social.git] / plugins / OStatus / actions / salmon.php
1 <?php
2 /*
3  * StatusNet - the distributed open-source microblogging tool
4  * Copyright (C) 2010, StatusNet, Inc.
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU Affero General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU Affero General Public License for more details.
15  *
16  * You should have received a copy of the GNU Affero General Public License
17  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18  */
19
20 /**
21  * @package OStatusPlugin
22  * @author James Walker <james@status.net>
23  */
24
25 if (!defined('STATUSNET')) {
26     exit(1);
27 }
28
29 class SalmonAction extends Action
30 {
31     var $user     = null;
32     var $xml      = null;
33     var $activity = null;
34
35     function prepare($args)
36     {
37         if ($_SERVER['REQUEST_METHOD'] != 'POST') {
38             $this->clientError(_('This method requires a POST.'));
39         }
40
41         if ($_SERVER['CONTENT_TYPE'] != 'application/atom+xml') {
42             $this->clientError(_('Salmon requires application/atom+xml'));
43         }
44
45         $id = $this->trimmed('id');
46
47         if (!$id) {
48             $this->clientError(_('No ID.'));
49         }
50
51         $this->user = User::staticGet($id);
52
53         if (empty($this->user)) {
54             $this->clientError(_('No such user.'));
55         }
56
57         $xml = file_get_contents('php://input');
58
59         $dom = DOMDocument::loadXML($xml);
60
61         // XXX: check that document element is Atom entry
62         // XXX: check the signature
63
64         $this->act = new Activity($dom->documentElement);
65     }
66
67     function handle($args)
68     {
69         common_log(LOG_DEBUG, 'Salmon: incoming post for user: '. $user_id);
70
71         // TODO : Insert new $xml -> notice code
72
73         switch ($this->act->verb)
74         {
75         case Activity::POST:
76         case Activity::SHARE:
77         case Activity::FAVORITE:
78         case Activity::FOLLOW:
79         }
80     }
81 }