3 * StatusNet - the distributed open-source microblogging tool
4 * Copyright (C) 2009-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 Brion Vibber <brion@status.net>
25 if (!defined('STATUSNET')) {
29 set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__FILE__) . '/extlib/');
31 class FeedSubException extends Exception
33 function __construct($msg=null)
35 $type = get_class($this);
37 parent::__construct("$type: $msg");
39 parent::__construct($type);
44 class OStatusPlugin extends Plugin
47 * Hook for RouterInitialized event.
49 * @param Net_URL_Mapper $m path-to-action mapper
50 * @return boolean hook return
52 function onRouterInitialized($m)
55 $m->connect('main/xrd',
56 array('action' => 'userxrd'));
57 $m->connect('main/ownerxrd',
58 array('action' => 'ownerxrd'));
59 $m->connect('main/ostatus',
60 array('action' => 'ostatusinit'));
61 $m->connect('main/ostatus?nickname=:nickname',
62 array('action' => 'ostatusinit'), array('nickname' => '[A-Za-z0-9_-]+'));
63 $m->connect('main/ostatus?group=:group',
64 array('action' => 'ostatusinit'), array('group' => '[A-Za-z0-9_-]+'));
65 $m->connect('main/ostatussub',
66 array('action' => 'ostatussub'));
67 $m->connect('main/ostatusgroup',
68 array('action' => 'ostatusgroup'));
71 $m->connect('main/push/hub', array('action' => 'pushhub'));
73 $m->connect('main/push/callback/:feed',
74 array('action' => 'pushcallback'),
75 array('feed' => '[0-9]+'));
78 $m->connect('main/salmon/user/:id',
79 array('action' => 'usersalmon'),
80 array('id' => '[0-9]+'));
81 $m->connect('main/salmon/group/:id',
82 array('action' => 'groupsalmon'),
83 array('id' => '[0-9]+'));
88 * Set up queue handlers for outgoing hub pushes
89 * @param QueueManager $qm
90 * @return boolean hook return
92 function onEndInitializeQueueManager(QueueManager $qm)
94 // Prepare outgoing distributions after notice save.
95 $qm->connect('ostatus', 'OStatusQueueHandler');
97 // Outgoing from our internal PuSH hub
98 $qm->connect('hubconf', 'HubConfQueueHandler');
99 $qm->connect('hubprep', 'HubPrepQueueHandler');
101 $qm->connect('hubout', 'HubOutQueueHandler');
103 // Outgoing Salmon replies (when we don't need a return value)
104 $qm->connect('salmon', 'SalmonQueueHandler');
106 // Incoming from a foreign PuSH hub
107 $qm->connect('pushin', 'PushInQueueHandler');
112 * Put saved notices into the queue for pubsub distribution.
114 function onStartEnqueueNotice($notice, &$transports)
116 if ($notice->isLocal()) {
117 // put our transport first, in case there's any conflict (like OMB)
118 array_unshift($transports, 'ostatus');
124 * Add a link header for LRDD Discovery
126 function onStartShowHTML($action)
128 if ($action instanceof ShowstreamAction) {
129 $acct = 'acct:'. $action->profile->nickname .'@'. common_config('site', 'server');
130 $url = common_local_url('userxrd');
131 $url.= '?uri='. $acct;
133 header('Link: <'.$url.'>; rel="'. Discovery::LRDD_REL.'"; type="application/xrd+xml"');
138 * Set up a PuSH hub link to our internal link for canonical timeline
139 * Atom feeds for users and groups.
141 function onStartApiAtom($feed)
145 if ($feed instanceof AtomUserNoticeFeed) {
146 $salmonAction = 'usersalmon';
147 $user = $feed->getUser();
149 $profile = $user->getProfile();
150 $feed->setActivitySubject($profile->asActivityNoun('subject'));
151 } else if ($feed instanceof AtomGroupNoticeFeed) {
152 $salmonAction = 'groupsalmon';
153 $group = $feed->getGroup();
155 $feed->setActivitySubject($group->asActivitySubject());
161 $hub = common_config('ostatus', 'hub');
163 // Updates will be handled through our internal PuSH hub.
164 $hub = common_local_url('pushhub');
166 $feed->addLink($hub, array('rel' => 'hub'));
168 // Also, we'll add in the salmon link
169 $salmon = common_local_url($salmonAction, array('id' => $id));
170 $feed->addLink($salmon, array('rel' => Salmon::REL_SALMON));
172 // XXX: these are deprecated
173 $feed->addLink($salmon, array('rel' => Salmon::NS_REPLIES));
174 $feed->addLink($salmon, array('rel' => Salmon::NS_MENTIONS));
181 * Automatically load the actions and libraries used by the plugin
183 * @param Class $cls the class
185 * @return boolean hook return
188 function onAutoload($cls)
190 $base = dirname(__FILE__);
191 $lower = strtolower($cls);
192 $map = array('activityverb' => 'activity',
193 'activityobject' => 'activity',
194 'activityutils' => 'activity');
195 if (isset($map[$lower])) {
196 $lower = $map[$lower];
198 $files = array("$base/classes/$cls.php",
199 "$base/lib/$lower.php");
200 if (substr($lower, -6) == 'action') {
201 $files[] = "$base/actions/" . substr($lower, 0, -6) . ".php";
203 foreach ($files as $file) {
204 if (file_exists($file)) {
213 * Add in an OStatus subscribe button
215 function onStartProfileRemoteSubscribe($output, $profile)
217 $cur = common_current_user();
220 // Add an OStatus subscribe
221 $output->elementStart('li', 'entity_subscribe');
222 $url = common_local_url('ostatusinit',
223 array('nickname' => $profile->nickname));
224 $output->element('a', array('href' => $url,
225 'class' => 'entity_remote_subscribe'),
226 // TRANS: Link description for link to subscribe to a remote user.
229 $output->elementEnd('li');
235 function onStartGroupSubscribe($output, $group)
237 $cur = common_current_user();
240 // Add an OStatus subscribe
241 $url = common_local_url('ostatusinit',
242 array('group' => $group->nickname));
243 $output->element('a', array('href' => $url,
244 'class' => 'entity_remote_subscribe'),
245 // TRANS: Link description for link to join a remote group.
253 * Find any explicit remote mentions. Accepted forms:
254 * Webfinger: @user@example.com
255 * Profile link: @example.com/mublog/user
256 * @param Profile $sender (os user?)
257 * @param string $text input markup text
258 * @param array &$mention in/out param: set of found mentions
259 * @return boolean hook return value
262 function onEndFindMentions($sender, $text, &$mentions)
266 // Webfinger matches: @user@example.com
267 if (preg_match_all('!(?:^|\s+)@((?:\w+\.)*\w+@(?:\w+\-?\w+\.)*\w+(?:\w+\-\w+)*\.\w+)!',
270 PREG_OFFSET_CAPTURE)) {
271 foreach ($wmatches[1] as $wmatch) {
272 list($target, $pos) = $wmatch;
273 $this->log(LOG_INFO, "Checking webfinger '$target'");
275 $oprofile = Ostatus_profile::ensureWebfinger($target);
276 if ($oprofile && !$oprofile->isGroup()) {
277 $profile = $oprofile->localProfile();
278 $matches[$pos] = array('mentioned' => array($profile),
281 'url' => $profile->profileurl);
283 } catch (Exception $e) {
284 $this->log(LOG_ERR, "Webfinger check failed: " . $e->getMessage());
289 // Profile matches: @example.com/mublog/user
290 if (preg_match_all('!(?:^|\s+)@((?:\w+\.)*\w+(?:\w+\-\w+)*\.\w+(?:/\w+)+)!',
293 PREG_OFFSET_CAPTURE)) {
294 foreach ($wmatches[1] as $wmatch) {
295 list($target, $pos) = $wmatch;
296 $schemes = array('http', 'https');
297 foreach ($schemes as $scheme) {
298 $url = "$scheme://$target";
299 $this->log(LOG_INFO, "Checking profile address '$url'");
301 $oprofile = Ostatus_profile::ensureProfileURL($url);
302 if ($oprofile && !$oprofile->isGroup()) {
303 $profile = $oprofile->localProfile();
304 $matches[$pos] = array('mentioned' => array($profile),
307 'url' => $profile->profileurl);
310 } catch (Exception $e) {
311 $this->log(LOG_ERR, "Profile check failed: " . $e->getMessage());
317 foreach ($mentions as $i => $other) {
318 // If we share a common prefix with a local user, override it!
319 $pos = $other['position'];
320 if (isset($matches[$pos])) {
321 $mentions[$i] = $matches[$pos];
322 unset($matches[$pos]);
325 foreach ($matches as $mention) {
326 $mentions[] = $mention;
333 * Allow remote profile references to be used in commands:
334 * sub update@status.net
335 * whois evan@identi.ca
336 * reply http://identi.ca/evan hey what's up
338 * @param Command $command
340 * @param Profile &$profile
341 * @return hook return code
343 function onStartCommandGetProfile($command, $arg, &$profile)
345 $oprofile = $this->pullRemoteProfile($arg);
346 if ($oprofile && !$oprofile->isGroup()) {
347 $profile = $oprofile->localProfile();
355 * Allow remote group references to be used in commands:
356 * join group+statusnet@identi.ca
357 * join http://identi.ca/group/statusnet
358 * drop identi.ca/group/statusnet
360 * @param Command $command
362 * @param User_group &$group
363 * @return hook return code
365 function onStartCommandGetGroup($command, $arg, &$group)
367 $oprofile = $this->pullRemoteProfile($arg);
368 if ($oprofile && $oprofile->isGroup()) {
369 $group = $oprofile->localGroup();
376 protected function pullRemoteProfile($arg)
379 if (preg_match('!^((?:\w+\.)*\w+@(?:\w+\.)*\w+(?:\w+\-\w+)*\.\w+)$!', $arg)) {
382 return Ostatus_profile::ensureWebfinger($arg);
383 } catch (Exception $e) {
384 common_log(LOG_ERR, 'Webfinger lookup failed for ' .
385 $arg . ': ' . $e->getMessage());
389 // Look for profile URLs, with or without scheme:
391 if (preg_match('!^https?://((?:\w+\.)*\w+(?:\w+\-\w+)*\.\w+(?:/\w+)+)$!', $arg)) {
394 if (preg_match('!^((?:\w+\.)*\w+(?:\w+\-\w+)*\.\w+(?:/\w+)+)$!', $arg)) {
395 $schemes = array('http', 'https');
396 foreach ($schemes as $scheme) {
397 $urls[] = "$scheme://$arg";
401 foreach ($urls as $url) {
403 return Ostatus_profile::ensureProfileURL($url);
404 } catch (Exception $e) {
405 common_log(LOG_ERR, 'Profile lookup failed for ' .
406 $arg . ': ' . $e->getMessage());
413 * Make sure necessary tables are filled out.
415 function onCheckSchema() {
416 $schema = Schema::get();
417 $schema->ensureTable('ostatus_profile', Ostatus_profile::schemaDef());
418 $schema->ensureTable('ostatus_source', Ostatus_source::schemaDef());
419 $schema->ensureTable('feedsub', FeedSub::schemaDef());
420 $schema->ensureTable('hubsub', HubSub::schemaDef());
421 $schema->ensureTable('magicsig', Magicsig::schemaDef());
425 function onEndShowStatusNetStyles($action) {
426 $action->cssLink('plugins/OStatus/theme/base/css/ostatus.css');
430 function onEndShowStatusNetScripts($action) {
431 $action->script('plugins/OStatus/js/ostatus.js');
436 * Override the "from ostatus" bit in notice lists to link to the
437 * original post and show the domain it came from.
439 * @param Notice in $notice
440 * @param string out &$name
441 * @param string out &$url
442 * @param string out &$title
443 * @return mixed hook return code
445 function onStartNoticeSourceLink($notice, &$name, &$url, &$title)
447 if ($notice->source == 'ostatus') {
449 $bits = parse_url($notice->url);
450 $domain = $bits['host'];
451 if (substr($domain, 0, 4) == 'www.') {
452 $name = substr($domain, 4);
458 // TRANSLATE: %s is a domain.
459 $title = sprintf(_m("Sent from %s via OStatus"), $domain);
467 * Send incoming PuSH feeds for OStatus endpoints in for processing.
469 * @param FeedSub $feedsub
470 * @param DOMDocument $feed
471 * @return mixed hook return code
473 function onStartFeedSubReceive($feedsub, $feed)
475 $oprofile = Ostatus_profile::staticGet('feeduri', $feedsub->uri);
477 $oprofile->processFeed($feed, 'push');
479 common_log(LOG_DEBUG, "No ostatus profile for incoming feed $feedsub->uri");
484 * Tell the FeedSub infrastructure whether we have any active OStatus
485 * usage for the feed; if not it'll be able to garbage-collect the
488 * @param FeedSub $feedsub
489 * @param integer $count in/out
490 * @return mixed hook return code
492 function onFeedSubSubscriberCount($feedsub, &$count)
494 $oprofile = Ostatus_profile::staticGet('feeduri', $feedsub->uri);
496 $count += $oprofile->subscriberCount();
502 * When about to subscribe to a remote user, start a server-to-server
503 * PuSH subscription if needed. If we can't establish that, abort.
505 * @fixme If something else aborts later, we could end up with a stray
506 * PuSH subscription. This is relatively harmless, though.
508 * @param Profile $subscriber
509 * @param Profile $other
511 * @return hook return code
515 function onStartSubscribe($subscriber, $other)
517 $user = User::staticGet('id', $subscriber->id);
523 $oprofile = Ostatus_profile::staticGet('profile_id', $other->id);
525 if (empty($oprofile)) {
529 if (!$oprofile->subscribe()) {
531 throw new Exception(_m('Could not set up remote subscription.'));
536 * Having established a remote subscription, send a notification to the
537 * remote OStatus profile's endpoint.
539 * @param Profile $subscriber
540 * @param Profile $other
542 * @return hook return code
546 function onEndSubscribe($subscriber, $other)
548 $user = User::staticGet('id', $subscriber->id);
554 $oprofile = Ostatus_profile::staticGet('profile_id', $other->id);
556 if (empty($oprofile)) {
560 $sub = Subscription::pkeyGet(array('subscriber' => $subscriber->id,
561 'subscribed' => $other->id));
563 $act = $sub->asActivity();
565 $oprofile->notifyActivity($act, $subscriber);
571 * Notify remote server and garbage collect unused feeds on unsubscribe.
572 * @fixme send these operations to background queues
575 * @param Profile $other
576 * @return hook return value
578 function onEndUnsubscribe($profile, $other)
580 $user = User::staticGet('id', $profile->id);
586 $oprofile = Ostatus_profile::staticGet('profile_id', $other->id);
588 if (empty($oprofile)) {
592 // Drop the PuSH subscription if there are no other subscribers.
593 $oprofile->garbageCollect();
595 $act = new Activity();
597 $act->verb = ActivityVerb::UNFOLLOW;
599 $act->id = TagURI::mint('unfollow:%d:%d:%s',
602 common_date_iso8601(time()));
605 $act->title = _m('Unfollow');
606 // TRANS: Success message for unsubscribe from user attempt through OStatus.
607 // TRANS: %1$s is the unsubscriber's name, %2$s is the unsubscribed user's name.
608 $act->content = sprintf(_m('%1$s stopped following %2$s.'),
609 $profile->getBestName(),
610 $other->getBestName());
612 $act->actor = ActivityObject::fromProfile($profile);
613 $act->object = ActivityObject::fromProfile($other);
615 $oprofile->notifyActivity($act, $profile);
621 * When one of our local users tries to join a remote group,
622 * notify the remote server. If the notification is rejected,
625 * @param User_group $group
628 * @return mixed hook return value
631 function onStartJoinGroup($group, $user)
633 $oprofile = Ostatus_profile::staticGet('group_id', $group->id);
635 if (!$oprofile->subscribe()) {
636 throw new Exception(_m('Could not set up remote group membership.'));
639 // NOTE: we don't use Group_member::asActivity() since that record
640 // has not yet been created.
642 $member = Profile::staticGet($user->id);
644 $act = new Activity();
645 $act->id = TagURI::mint('join:%d:%d:%s',
648 common_date_iso8601(time()));
650 $act->actor = ActivityObject::fromProfile($member);
651 $act->verb = ActivityVerb::JOIN;
652 $act->object = $oprofile->asActivityObject();
655 $act->title = _m("Join");
656 // TRANS: Success message for subscribe to group attempt through OStatus.
657 // TRANS: %1$s is the member name, %2$s is the subscribed group's name.
658 $act->content = sprintf(_m('%1$s has joined group %2$s.'),
659 $member->getBestName(),
660 $oprofile->getBestName());
662 if ($oprofile->notifyActivity($act, $member)) {
665 $oprofile->garbageCollect();
667 throw new Exception(_m("Failed joining remote group."));
673 * When one of our local users leaves a remote group, notify the remote
676 * @fixme Might be good to schedule a resend of the leave notification
677 * if it failed due to a transitory error. We've canceled the local
678 * membership already anyway, but if the remote server comes back up
679 * it'll be left with a stray membership record.
681 * @param User_group $group
684 * @return mixed hook return value
687 function onEndLeaveGroup($group, $user)
689 $oprofile = Ostatus_profile::staticGet('group_id', $group->id);
691 // Drop the PuSH subscription if there are no other subscribers.
692 $oprofile->garbageCollect();
694 $member = Profile::staticGet($user->id);
696 $act = new Activity();
697 $act->id = TagURI::mint('leave:%d:%d:%s',
700 common_date_iso8601(time()));
702 $act->actor = ActivityObject::fromProfile($member);
703 $act->verb = ActivityVerb::LEAVE;
704 $act->object = $oprofile->asActivityObject();
707 $act->title = _m("Leave");
708 // TRANS: Success message for unsubscribe from group attempt through OStatus.
709 // TRANS: %1$s is the member name, %2$s is the unsubscribed group's name.
710 $act->content = sprintf(_m('%1$s has left group %2$s.'),
711 $member->getBestName(),
712 $oprofile->getBestName());
714 $oprofile->notifyActivity($act, $member);
719 * Notify remote users when their notices get favorited.
721 * @param Profile or User $profile of local user doing the faving
722 * @param Notice $notice being favored
723 * @return hook return value
725 function onEndFavorNotice(Profile $profile, Notice $notice)
727 $user = User::staticGet('id', $profile->id);
733 $oprofile = Ostatus_profile::staticGet('profile_id', $notice->profile_id);
735 if (empty($oprofile)) {
739 $fav = Fave::pkeyGet(array('user_id' => $user->id,
740 'notice_id' => $notice->id));
747 $act = $fav->asActivity();
749 $oprofile->notifyActivity($act, $profile);
755 * Notify remote users when their notices get de-favorited.
757 * @param Profile $profile Profile person doing the de-faving
758 * @param Notice $notice Notice being favored
760 * @return hook return value
763 function onEndDisfavorNotice(Profile $profile, Notice $notice)
765 $user = User::staticGet('id', $profile->id);
771 $oprofile = Ostatus_profile::staticGet('profile_id', $notice->profile_id);
773 if (empty($oprofile)) {
777 $act = new Activity();
779 $act->verb = ActivityVerb::UNFAVORITE;
780 $act->id = TagURI::mint('disfavor:%d:%d:%s',
783 common_date_iso8601(time()));
785 $act->title = _m('Disfavor');
786 // TRANS: Success message for remove a favorite notice through OStatus.
787 // TRANS: %1$s is the unfavoring user's name, %2$s is URI to the no longer favored notice.
788 $act->content = sprintf(_m('%1$s marked notice %2$s as no longer a favorite.'),
789 $profile->getBestName(),
792 $act->actor = ActivityObject::fromProfile($profile);
793 $act->object = ActivityObject::fromNotice($notice);
795 $oprofile->notifyActivity($act, $profile);
800 function onStartGetProfileUri($profile, &$uri)
802 $oprofile = Ostatus_profile::staticGet('profile_id', $profile->id);
803 if (!empty($oprofile)) {
804 $uri = $oprofile->uri;
810 function onStartUserGroupHomeUrl($group, &$url)
812 return $this->onStartUserGroupPermalink($group, $url);
815 function onStartUserGroupPermalink($group, &$url)
817 $oprofile = Ostatus_profile::staticGet('group_id', $group->id);
819 // @fixme this should probably be in the user_group table
820 // @fixme this uri not guaranteed to be a profile page
821 $url = $oprofile->uri;
826 function onStartShowSubscriptionsContent($action)
828 $this->showEntityRemoteSubscribe($action);
833 function onStartShowUserGroupsContent($action)
835 $this->showEntityRemoteSubscribe($action, 'ostatusgroup');
840 function onEndShowSubscriptionsMiniList($action)
842 $this->showEntityRemoteSubscribe($action);
847 function onEndShowGroupsMiniList($action)
849 $this->showEntityRemoteSubscribe($action, 'ostatusgroup');
854 function showEntityRemoteSubscribe($action, $target='ostatussub')
856 $user = common_current_user();
857 if ($user && ($user->id == $action->profile->id)) {
858 $action->elementStart('div', 'entity_actions');
859 $action->elementStart('p', array('id' => 'entity_remote_subscribe',
860 'class' => 'entity_subscribe'));
861 $action->element('a', array('href' => common_local_url($target),
862 'class' => 'entity_remote_subscribe'),
863 // TRANS: Link text for link to remote subscribe.
865 $action->elementEnd('p');
866 $action->elementEnd('div');
871 * Ping remote profiles with updates to this profile.
872 * Salmon pings are queued for background processing.
874 function onEndBroadcastProfile(Profile $profile)
876 $user = User::staticGet('id', $profile->id);
878 // Find foreign accounts I'm subscribed to that support Salmon pings.
880 // @fixme we could run updates through the PuSH feed too,
881 // in which case we can skip Salmon pings to folks who
882 // are also subscribed to me.
883 $sql = "SELECT * FROM ostatus_profile " .
884 "WHERE profile_id IN " .
885 "(SELECT subscribed FROM subscription WHERE subscriber=%d) " .
887 "(SELECT group_id FROM group_member WHERE profile_id=%d)";
888 $oprofile = new Ostatus_profile();
889 $oprofile->query(sprintf($sql, $profile->id, $profile->id));
891 if ($oprofile->N == 0) {
892 common_log(LOG_DEBUG, "No OStatus remote subscribees for $profile->nickname");
896 $act = new Activity();
898 $act->verb = ActivityVerb::UPDATE_PROFILE;
899 $act->id = TagURI::mint('update-profile:%d:%s',
901 common_date_iso8601(time()));
903 // TRANS: Title for activity.
904 $act->title = _m("Profile update");
905 // TRANS: Ping text for remote profile update through OStatus.
906 // TRANS: %s is user that updated their profile.
907 $act->content = sprintf(_m("%s has updated their profile page."),
908 $profile->getBestName());
910 $act->actor = ActivityObject::fromProfile($profile);
911 $act->object = $act->actor;
913 while ($oprofile->fetch()) {
914 $oprofile->notifyDeferred($act, $profile);
920 function onStartProfileListItemActionElements($item)
922 if (!common_logged_in()) {
924 $profileUser = User::staticGet('id', $item->profile->id);
926 if (!empty($profileUser)) {
928 $output = $item->out;
930 // Add an OStatus subscribe
931 $output->elementStart('li', 'entity_subscribe');
932 $url = common_local_url('ostatusinit',
933 array('nickname' => $profileUser->nickname));
934 $output->element('a', array('href' => $url,
935 'class' => 'entity_remote_subscribe'),
936 // TRANS: Link text for a user to subscribe to an OStatus user.
938 $output->elementEnd('li');
945 function onPluginVersion(&$versions)
947 $versions[] = array('name' => 'OStatus',
948 'version' => STATUSNET_VERSION,
949 'author' => 'Evan Prodromou, James Walker, Brion Vibber, Zach Copley',
950 'homepage' => 'http://status.net/wiki/Plugin:OStatus',
951 // TRANS: Plugin description.
952 'rawdescription' => _m('Follow people across social networks that implement '.
953 '<a href="http://ostatus.org/">OStatus</a>.'));
959 * Utility function to check if the given URI is a canonical group profile
960 * page, and if so return the ID number.
963 * @return mixed int or false
965 public static function localGroupFromUrl($url)
967 $group = User_group::staticGet('uri', $url);
969 $local = Local_group::staticGet('group_id', $group->id);
974 // To find local groups which haven't had their uri fields filled out...
975 // If the domain has changed since a subscriber got the URI, it'll
977 $template = common_local_url('groupbyid', array('id' => '31337'));
978 $template = preg_quote($template, '/');
979 $template = str_replace('31337', '(\d+)', $template);
980 if (preg_match("/$template/", $url, $matches)) {
981 return intval($matches[1]);
987 public function onStartProfileGetAtomFeed($profile, &$feed)
989 $oprofile = Ostatus_profile::staticGet('profile_id', $profile->id);
991 if (empty($oprofile)) {
995 $feed = $oprofile->feeduri;
999 function onStartGetProfileFromURI($uri, &$profile) {
1001 // XXX: do discovery here instead (OStatus_profile::ensureProfileURI($uri))
1003 $oprofile = Ostatus_profile::staticGet('uri', $uri);
1005 if (!empty($oprofile) && !$oprofile->isGroup()) {
1006 $profile = $oprofile->localProfile();
1013 function onStartHostMetaLinks(&$links) {
1014 $url = common_local_url('userxrd');
1015 $url.= '?uri={uri}';
1016 $links[] = array('rel' => Discovery::LRDD_REL,
1018 'title' => array('Resource Descriptor'));