3 * StatusNet - the distributed open-source microblogging tool
4 * Copyright (C) 2010, StatusNet, Inc.
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.
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.
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/>.
21 * @package OStatusPlugin
22 * @author James Walker <james@status.net>
25 if (!defined('STATUSNET')) {
29 class SalmonAction extends Action
35 function prepare($args)
37 if ($_SERVER['REQUEST_METHOD'] != 'POST') {
38 $this->clientError(_('This method requires a POST.'));
41 if ($_SERVER['CONTENT_TYPE'] != 'application/atom+xml') {
42 $this->clientError(_('Salmon requires application/atom+xml'));
45 $id = $this->trimmed('id');
48 $this->clientError(_('No ID.'));
51 $this->user = User::staticGet($id);
53 if (empty($this->user)) {
54 $this->clientError(_('No such user.'));
57 $xml = file_get_contents('php://input');
59 $dom = DOMDocument::loadXML($xml);
61 // XXX: check that document element is Atom entry
62 // XXX: check the signature
64 $this->act = Activity::fromAtomEntry($dom->documentElement);
67 function handle($args)
69 common_log(LOG_DEBUG, 'Salmon: incoming post for user: '. $user_id);
71 // TODO : Insert new $xml -> notice code
73 switch ($this->act->verb)
77 case Activity::FAVORITE:
78 case Activity::FOLLOW: