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
37 $nick = $this->user->nickname;
39 if (empty($this->xrd)) {
45 if (empty($xrd->subject)) {
46 $xrd->subject = Discovery::normalize($this->uri);
48 $xrd->alias[] = $this->user->uri;
49 $xrd->links[] = array('rel' => Discovery::PROFILEPAGE,
50 'type' => 'text/html',
51 'href' => $this->user->uri);
53 $xrd->links[] = array('rel' => Discovery::UPDATESFROM,
54 'href' => common_local_url('ApiTimelineUser',
55 array('id' => $this->user->id,
57 'type' => 'application/atom+xml');
60 $xrd->links[] = array('rel' => Discovery::HCARD,
61 'type' => 'text/html',
62 'href' => common_local_url('hcard', array('nickname' => $nick)));
65 $xrd->links[] = array('rel' => 'http://gmpg.org/xfn/11',
66 'type' => 'text/html',
67 'href' => $this->user->uri);
69 $xrd->links[] = array('rel' => 'describedby',
70 'type' => 'application/rdf+xml',
71 'href' => common_local_url('foaf',
72 array('nickname' => $nick)));
75 $salmon_url = common_local_url('usersalmon',
76 array('id' => $this->user->id));
78 $xrd->links[] = array('rel' => Salmon::REL_SALMON,
79 'href' => $salmon_url);
80 // XXX : Deprecated - to be removed.
81 $xrd->links[] = array('rel' => Salmon::NS_REPLIES,
82 'href' => $salmon_url);
84 $xrd->links[] = array('rel' => Salmon::NS_MENTIONS,
85 'href' => $salmon_url);
87 // Get this user's keypair
88 $magickey = Magicsig::staticGet('user_id', $this->user->id);
90 // No keypair yet, let's generate one.
91 $magickey = new Magicsig();
92 $magickey->generate($this->user->id);
95 $xrd->links[] = array('rel' => Magicsig::PUBLICKEYREL,
96 'href' => 'data:application/magic-public-key,'. $magickey->toString(false));
98 // TODO - finalize where the redirect should go on the publisher
99 $url = common_local_url('ostatussub') . '?profile={uri}';
100 $xrd->links[] = array('rel' => 'http://ostatus.org/schema/1.0/subscribe',
101 'template' => $url );
103 header('Content-type: application/xrd+xml');