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 * @maintainer James Walker <james@status.net>
25 if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
27 class XrdAction extends Action
38 $nick = $this->user->nickname;
40 if (empty($this->xrd)) {
46 if (empty($xrd->subject)) {
47 $xrd->subject = Discovery::normalize($this->uri);
49 $xrd->alias[] = $this->user->uri;
50 $xrd->links[] = array('rel' => Discovery::PROFILEPAGE,
51 'type' => 'text/html',
52 'href' => $this->user->uri);
54 $xrd->links[] = array('rel' => Discovery::UPDATESFROM,
55 'href' => common_local_url('ApiTimelineUser',
56 array('id' => $this->user->id,
58 'type' => 'application/atom+xml');
61 $xrd->links[] = array('rel' => Discovery::HCARD,
62 'type' => 'text/html',
63 'href' => common_local_url('hcard', array('nickname' => $nick)));
66 $xrd->links[] = array('rel' => 'http://gmpg.org/xfn/11',
67 'type' => 'text/html',
68 'href' => $this->user->uri);
70 $xrd->links[] = array('rel' => 'describedby',
71 'type' => 'application/rdf+xml',
72 'href' => common_local_url('foaf',
73 array('nickname' => $nick)));
76 $salmon_url = common_local_url('usersalmon',
77 array('id' => $this->user->id));
79 $xrd->links[] = array('rel' => Salmon::NS_REPLIES,
80 'href' => $salmon_url);
82 $xrd->links[] = array('rel' => Salmon::NS_MENTIONS,
83 'href' => $salmon_url);
85 // Get this user's keypair
86 $magickey = Magicsig::staticGet('user_id', $this->user->id);
88 // No keypair yet, let's generate one.
89 $magickey = new Magicsig();
90 $magickey->generate($this->user->id);
93 $xrd->links[] = array('rel' => Magicsig::PUBLICKEYREL,
94 'href' => 'data:application/magic-public-key,'. $magickey->toString(false));
96 // TODO - finalize where the redirect should go on the publisher
97 $url = common_local_url('ostatussub') . '?profile={uri}';
98 $xrd->links[] = array('rel' => 'http://ostatus.org/schema/1.0/subscribe',
101 header('Content-type: text/xml');