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')) {
29 class XrdAction extends Action
39 $nick = $this->user->nickname;
41 if (empty($this->xrd)) {
47 if (empty($xrd->subject)) {
48 $xrd->subject = Discovery::normalize($this->uri);
50 $xrd->alias[] = $this->user->uri;
51 $xrd->links[] = array('rel' => Discovery::PROFILEPAGE,
52 'type' => 'text/html',
53 'href' => $this->user->uri);
55 $xrd->links[] = array('rel' => Discovery::UPDATESFROM,
56 'href' => common_local_url('ApiTimelineUser',
57 array('id' => $this->user->id,
59 'type' => 'application/atom+xml');
62 $xrd->links[] = array('rel' => Discovery::HCARD,
63 'type' => 'text/html',
64 'href' => common_local_url('hcard', array('nickname' => $nick)));
67 $xrd->links[] = array('rel' => 'http://gmpg.org/xfn/11',
68 'type' => 'text/html',
69 'href' => $this->user->uri);
71 $xrd->links[] = array('rel' => 'describedby',
72 'type' => 'application/rdf+xml',
73 'href' => common_local_url('foaf',
74 array('nickname' => $nick)));
77 $salmon_url = common_local_url('usersalmon',
78 array('id' => $this->user->id));
80 $xrd->links[] = array('rel' => Salmon::REL_SALMON,
81 'href' => $salmon_url);
82 // XXX : Deprecated - to be removed.
83 $xrd->links[] = array('rel' => Salmon::NS_REPLIES,
84 'href' => $salmon_url);
86 $xrd->links[] = array('rel' => Salmon::NS_MENTIONS,
87 'href' => $salmon_url);
89 // Get this user's keypair
90 $magickey = Magicsig::staticGet('user_id', $this->user->id);
92 // No keypair yet, let's generate one.
93 $magickey = new Magicsig();
94 $magickey->generate($this->user->id);
97 $xrd->links[] = array('rel' => Magicsig::PUBLICKEYREL,
98 'href' => 'data:application/magic-public-key,'. $magickey->toString(false));
100 // TODO - finalize where the redirect should go on the publisher
101 $url = common_local_url('ostatussub') . '?profile={uri}';
102 $xrd->links[] = array('rel' => 'http://ostatus.org/schema/1.0/subscribe',
103 'template' => $url );
105 header('Content-type: application/xrd+xml');