Commit 5fd60532 authored by mmn's avatar mmn

Code cleanup and enabling User object's etc. getUri()

parent 0883f54f
...@@ -90,11 +90,10 @@ class FoafAction extends Action ...@@ -90,11 +90,10 @@ class FoafAction extends Action
// This is the document about the user // This is the document about the user
$this->showPpd('', $this->user->uri); $this->showPpd('', $this->user->getUri());
// Would be nice to tell if they were a Person or not (e.g. a #person usertag?) // Would be nice to tell if they were a Person or not (e.g. a #person usertag?)
$this->elementStart('Agent', array('rdf:about' => $this->elementStart('Agent', array('rdf:about' => $this->user->getUri()));
$this->user->uri));
if ($this->user->email) { if ($this->user->email) {
$this->element('mbox_sha1sum', null, sha1('mailto:' . $this->user->email)); $this->element('mbox_sha1sum', null, sha1('mailto:' . $this->user->email));
} }
...@@ -158,7 +157,7 @@ class FoafAction extends Action ...@@ -158,7 +157,7 @@ class FoafAction extends Action
} }
$person = $this->showMicrobloggingAccount($this->profile, $person = $this->showMicrobloggingAccount($this->profile,
common_root_url(), $this->user->uri, common_root_url(), $this->user->getUri(),
/*$fetchSubscriptions*/true, /*$fetchSubscriptions*/true,
/*$isSubscriber*/false); /*$isSubscriber*/false);
...@@ -171,7 +170,7 @@ class FoafAction extends Action ...@@ -171,7 +170,7 @@ class FoafAction extends Action
if ($sub->find()) { if ($sub->find()) {
while ($sub->fetch()) { while ($sub->fetch()) {
$profile = Profile::getKV('id', $sub->subscriber); $profile = Profile::getKV('id', $sub->subscriber);
if (empty($profile)) { if (!$profile instanceof Profile) {
common_debug('Got a bad subscription: '.print_r($sub,true)); common_debug('Got a bad subscription: '.print_r($sub,true));
continue; continue;
} }
...@@ -209,7 +208,7 @@ class FoafAction extends Action ...@@ -209,7 +208,7 @@ class FoafAction extends Action
$profile = Profile::getKV($id); $profile = Profile::getKV($id);
$this->elementStart('Agent', array('rdf:about' => $uri)); $this->elementStart('Agent', array('rdf:about' => $uri));
if ($type == BOTH) { if ($type == BOTH) {
$this->element('knows', array('rdf:resource' => $this->user->uri)); $this->element('knows', array('rdf:resource' => $this->user->getUri()));
} }
$this->showMicrobloggingAccount($profile, $this->showMicrobloggingAccount($profile,
($local == 'local') ? common_root_url() : null, ($local == 'local') ? common_root_url() : null,
...@@ -301,7 +300,7 @@ class FoafAction extends Action ...@@ -301,7 +300,7 @@ class FoafAction extends Action
unset($sub); unset($sub);
} else if ($isSubscriber) { } else if ($isSubscriber) {
// Just declare that they follow the user whose FOAF we're showing. // Just declare that they follow the user whose FOAF we're showing.
$this->element('sioc:follows', array('rdf:resource' => $this->user->uri . '#acct')); $this->element('sioc:follows', array('rdf:resource' => $this->user->getUri() . '#acct'));
} }
$this->elementEnd('OnlineAccount'); $this->elementEnd('OnlineAccount');
......
...@@ -1389,6 +1389,11 @@ class Profile extends Managed_DataObject ...@@ -1389,6 +1389,11 @@ class Profile extends Managed_DataObject
return $this->profileurl; return $this->profileurl;
} }
public function getNickname()
{
return $this->nickname;
}
/** /**
* Returns the best URI for a profile. Plugins may override. * Returns the best URI for a profile. Plugins may override.
* *
...@@ -1403,9 +1408,8 @@ class Profile extends Managed_DataObject ...@@ -1403,9 +1408,8 @@ class Profile extends Managed_DataObject
// check for a local user first // check for a local user first
$user = User::getKV('id', $this->id); $user = User::getKV('id', $this->id);
if ($user instanceof User) {
if (!empty($user)) { $uri = $user->getUri();
$uri = $user->uri;
} }
Event::handle('EndGetProfileUri', array($this, &$uri)); Event::handle('EndGetProfileUri', array($this, &$uri));
......
...@@ -132,6 +132,11 @@ class User extends Managed_DataObject ...@@ -132,6 +132,11 @@ class User extends Managed_DataObject
return $this->_profile; return $this->_profile;
} }
public function getUri()
{
return $this->uri;
}
function isSubscribed(Profile $other) function isSubscribed(Profile $other)
{ {
return $this->getProfile()->isSubscribed($other); return $this->getProfile()->isSubscribed($other);
......
...@@ -86,7 +86,7 @@ class AccountMover extends QueueHandler ...@@ -86,7 +86,7 @@ class AccountMover extends QueueHandler
$qm = QueueManager::get(); $qm = QueueManager::get();
foreach ($acts as $act) { foreach ($acts as $act) {
$qm->enqueue(array($act, $sink, $user->uri, $remote), 'actmove'); $qm->enqueue(array($act, $sink, $user->getUri(), $remote), 'actmove');
} }
$this->log(LOG_INFO, $this->log(LOG_INFO,
......
...@@ -28,11 +28,7 @@ ...@@ -28,11 +28,7 @@
* @link http://status.net/ * @link http://status.net/
*/ */
if (!defined('STATUSNET')) { if (!defined('GNUSOCIAL')) { exit(1); }
// This check helps protect against security problems;
// your code file can't be executed directly from the web.
exit(1);
}
/** /**
* Class comment * Class comment
...@@ -104,13 +100,13 @@ class ActivityImporter extends QueueHandler ...@@ -104,13 +100,13 @@ class ActivityImporter extends QueueHandler
$other = $activity->actor; $other = $activity->actor;
$otherUser = User::getKV('uri', $other->id); $otherUser = User::getKV('uri', $other->id);
if (!empty($otherUser)) { if (!$otherUser instanceof User) {
$otherProfile = $otherUser->getProfile();
} else {
// TRANS: Client exception thrown when trying to force a remote user to subscribe. // TRANS: Client exception thrown when trying to force a remote user to subscribe.
throw new Exception(_('Cannot force remote user to subscribe.')); throw new Exception(_('Cannot force remote user to subscribe.'));
} }
$otherProfile = $otherUser->getProfile();
// XXX: don't do this for untrusted input! // XXX: don't do this for untrusted input!
Subscription::start($otherProfile, $profile); Subscription::start($otherProfile, $profile);
...@@ -141,7 +137,7 @@ class ActivityImporter extends QueueHandler ...@@ -141,7 +137,7 @@ class ActivityImporter extends QueueHandler
$group = User_group::getKV('uri', $uri); $group = User_group::getKV('uri', $uri);
if (empty($group)) { if (!$group instanceof User_group) {
$oprofile = Ostatus_profile::ensureActivityObjectProfile($activity->objects[0]); $oprofile = Ostatus_profile::ensureActivityObjectProfile($activity->objects[0]);
if (!$oprofile->isGroup()) { if (!$oprofile->isGroup()) {
// TRANS: Client exception thrown when trying to join a remote group that is not a group. // TRANS: Client exception thrown when trying to join a remote group that is not a group.
...@@ -170,7 +166,7 @@ class ActivityImporter extends QueueHandler ...@@ -170,7 +166,7 @@ class ActivityImporter extends QueueHandler
$notice = Notice::getKV('uri', $sourceUri); $notice = Notice::getKV('uri', $sourceUri);
if (!empty($notice)) { if ($notice instanceof Notice) {
common_log(LOG_INFO, "Notice {$sourceUri} already exists."); common_log(LOG_INFO, "Notice {$sourceUri} already exists.");
...@@ -180,8 +176,8 @@ class ActivityImporter extends QueueHandler ...@@ -180,8 +176,8 @@ class ActivityImporter extends QueueHandler
$uri = $profile->getUri(); $uri = $profile->getUri();
if ($uri == $author->id) { if ($uri === $author->id) {
common_log(LOG_INFO, "Updating notice author from $author->id to $user->uri"); common_log(LOG_INFO, sprintf('Updating notice author from %s to %s', $author->id, $user->getUri()));
$orig = clone($notice); $orig = clone($notice);
$notice->profile_id = $user->id; $notice->profile_id = $user->id;
$notice->update($orig); $notice->update($orig);
...@@ -244,9 +240,8 @@ class ActivityImporter extends QueueHandler ...@@ -244,9 +240,8 @@ class ActivityImporter extends QueueHandler
// Maintain direct reply associations // Maintain direct reply associations
// @fixme what about conversation ID? // @fixme what about conversation ID?
if (!empty($activity->context->replyToID)) { if (!empty($activity->context->replyToID)) {
$orig = Notice::getKV('uri', $orig = Notice::getKV('uri', $activity->context->replyToID);
$activity->context->replyToID); if ($orig instanceof Notice) {
if (!empty($orig)) {
$options['reply_to'] = $orig->id; $options['reply_to'] = $orig->id;
} }
} }
......
...@@ -121,7 +121,7 @@ class ActivityMover extends QueueHandler ...@@ -121,7 +121,7 @@ class ActivityMover extends QueueHandler
} }
break; break;
case ActivityVerb::FOLLOW: case ActivityVerb::FOLLOW:
if ($act->actor->id == $user->uri) { if ($act->actor->id === $user->getUri()) {
$this->log(LOG_INFO, $this->log(LOG_INFO,
"Moving subscription to {$act->objects[0]->id} by ". "Moving subscription to {$act->objects[0]->id} by ".
"{$act->actor->id} to {$remote->nickname}."); "{$act->actor->id} to {$remote->nickname}.");
......
...@@ -154,7 +154,7 @@ class UserActivityStream extends AtomUserNoticeFeed ...@@ -154,7 +154,7 @@ class UserActivityStream extends AtomUserNoticeFeed
try { try {
if ($format == Feed::ATOM) { if ($format == Feed::ATOM) {
// Only show the author sub-element if it's different from default user // Only show the author sub-element if it's different from default user
$act->outputTo($this, false, ($act->actor->id != $this->user->uri)); $act->outputTo($this, false, ($act->actor->id != $this->user->getUri()));
} else { } else {
if ($haveOne) { if ($haveOne) {
fwrite($handle, ","); fwrite($handle, ",");
......
...@@ -2048,7 +2048,7 @@ function common_profile_uri($profile) ...@@ -2048,7 +2048,7 @@ function common_profile_uri($profile)
if (Event::handle('StartCommonProfileURI', array($profile, &$uri))) { if (Event::handle('StartCommonProfileURI', array($profile, &$uri))) {
$user = User::getKV('id', $profile->id); $user = User::getKV('id', $profile->id);
if ($user instanceof User) { if ($user instanceof User) {
$uri = $user->uri; $uri = $user->getUri();
} }
Event::handle('EndCommonProfileURI', array($profile, &$uri)); Event::handle('EndCommonProfileURI', array($profile, &$uri));
} }
......
...@@ -75,10 +75,12 @@ class AutoSandboxPlugin extends Plugin ...@@ -75,10 +75,12 @@ class AutoSandboxPlugin extends Plugin
if (isset($this->contact)) { if (isset($this->contact)) {
$contactuser = User::getKV('nickname', $this->contact); $contactuser = User::getKV('nickname', $this->contact);
if (!empty($contactuser)) { if ($contactuser instanceof User) {
$contactlink = "@<a href=\"$contactuser->uri\">$contactuser->nickname</a>"; $contactlink = sprintf('@<a href="%s">%s</a>',
htmlspecialchars($contactuser->getProfile()->getUrl()),
htmlspecialchars($contactuser->getProfile()->getNickname()));
// TRANS: User instructions after registration. // TRANS: User instructions after registration.
// TRANS: %s is a clickable e-mailaddress. // TRANS: %s is a clickable OStatus profile URL.
$instr = sprintf(_m('Note you will initially be "sandboxed" so your posts will not appear in the public timeline. '. $instr = sprintf(_m('Note you will initially be "sandboxed" so your posts will not appear in the public timeline. '.
'Send a message to %s to speed up the unsandboxing process.'),$contactlink); 'Send a message to %s to speed up the unsandboxing process.'),$contactlink);
} }
......
...@@ -91,9 +91,9 @@ class UsersalmonAction extends SalmonAction ...@@ -91,9 +91,9 @@ class UsersalmonAction extends SalmonAction
throw new ClientException(_m('In reply to a notice not by this user and not mentioning this user.')); throw new ClientException(_m('In reply to a notice not by this user and not mentioning this user.'));
} }
} else if (!empty($context->attention)) { } else if (!empty($context->attention)) {
if (!array_key_exists($this->user->uri, $context->attention) && if (!array_key_exists($this->user->getUri(), $context->attention) &&
!array_key_exists(common_profile_url($this->user->nickname), $context->attention)) { !array_key_exists(common_profile_url($this->user->nickname), $context->attention)) {
common_log(LOG_ERR, "{$this->user->uri} not in attention list (".implode(',', array_keys($context->attention)).')'); common_log(LOG_ERR, $this->user->getUri() . "not in attention list (".implode(',', array_keys($context->attention)).')');
// TRANS: Client exception. // TRANS: Client exception.
throw new ClientException(_m('To the attention of user(s), not including this one.')); throw new ClientException(_m('To the attention of user(s), not including this one.'));
} }
...@@ -103,9 +103,8 @@ class UsersalmonAction extends SalmonAction ...@@ -103,9 +103,8 @@ class UsersalmonAction extends SalmonAction
} }
$existing = Notice::getKV('uri', $this->activity->objects[0]->id); $existing = Notice::getKV('uri', $this->activity->objects[0]->id);
if ($existing instanceof Notice) {
if (!empty($existing)) { common_log(LOG_ERR, "Not saving notice '".$existing->getUri()."'; already exists.");
common_log(LOG_ERR, "Not saving notice '{$existing->uri}'; already exists.");
return; return;
} }
...@@ -120,7 +119,7 @@ class UsersalmonAction extends SalmonAction ...@@ -120,7 +119,7 @@ class UsersalmonAction extends SalmonAction
{ {
$oprofile = $this->ensureProfile(); $oprofile = $this->ensureProfile();
if ($oprofile) { if ($oprofile) {
common_log(LOG_INFO, "Setting up subscription from remote {$oprofile->uri} to local {$this->user->nickname}"); common_log(LOG_INFO, sprintf('Setting up subscription from remote %s to local %s', $oprofile->getUri(), $this->user->getNickname()));
Subscription::start($oprofile->localProfile(), Subscription::start($oprofile->localProfile(),
$this->user->getProfile()); $this->user->getProfile());
} else { } else {
...@@ -138,7 +137,7 @@ class UsersalmonAction extends SalmonAction ...@@ -138,7 +137,7 @@ class UsersalmonAction extends SalmonAction
{ {
$oprofile = $this->ensureProfile(); $oprofile = $this->ensureProfile();
if ($oprofile) { if ($oprofile) {
common_log(LOG_INFO, "Canceling subscription from remote {$oprofile->uri} to local {$this->user->nickname}"); common_log(LOG_INFO, sprintf('Canceling subscription from remote %s to local %s', $oprofile->getUri(), $this->user->getNickname()));
Subscription::cancel($oprofile->localProfile(), $this->user->getProfile()); Subscription::cancel($oprofile->localProfile(), $this->user->getProfile());
} else { } else {
common_log(LOG_ERR, "Can't cancel subscription from remote, didn't find the profile"); common_log(LOG_ERR, "Can't cancel subscription from remote, didn't find the profile");
......
...@@ -198,7 +198,7 @@ class FeedSub extends Managed_DataObject ...@@ -198,7 +198,7 @@ class FeedSub extends Managed_DataObject
public function subscribe() public function subscribe()
{ {
if ($this->sub_state && $this->sub_state != 'inactive') { if ($this->sub_state && $this->sub_state != 'inactive') {
common_log(LOG_WARNING, "Attempting to (re)start PuSH subscription to {$this->uri} in unexpected state {$this->sub_state}"); common_log(LOG_WARNING, sprintf('Attempting to (re)start PuSH subscription to %s in unexpected state %s', $this->getUri(), $this->sub_state));
} }
if (!Event::handle('FeedSubscribe', array($this))) { if (!Event::handle('FeedSubscribe', array($this))) {
...@@ -235,7 +235,7 @@ class FeedSub extends Managed_DataObject ...@@ -235,7 +235,7 @@ class FeedSub extends Managed_DataObject
*/ */
public function unsubscribe() { public function unsubscribe() {
if ($this->sub_state != 'active') { if ($this->sub_state != 'active') {
common_log(LOG_WARNING, "Attempting to (re)end PuSH subscription to {$this->uri} in unexpected state {$this->sub_state}"); common_log(LOG_WARNING, sprintf('Attempting to (re)end PuSH subscription to %s in unexpected state %s', $this->getUri(), $this->sub_state));
} }
if (!Event::handle('FeedUnsubscribe', array($this))) { if (!Event::handle('FeedUnsubscribe', array($this))) {
...@@ -278,10 +278,10 @@ class FeedSub extends Managed_DataObject ...@@ -278,10 +278,10 @@ class FeedSub extends Managed_DataObject
Event::handle('FeedSubSubscriberCount', array($this, &$count)); Event::handle('FeedSubSubscriberCount', array($this, &$count));
if ($count) { if ($count) {
common_log(LOG_INFO, __METHOD__ . ': ok, ' . $count . ' user(s) left for ' . $this->uri); common_log(LOG_INFO, __METHOD__ . ': ok, ' . $count . ' user(s) left for ' . $this->getUri());
return false; return false;
} else { } else {
common_log(LOG_INFO, __METHOD__ . ': unsubscribing, no users left for ' . $this->uri); common_log(LOG_INFO, __METHOD__ . ': unsubscribing, no users left for ' . $this->getUri());
return $this->unsubscribe(); return $this->unsubscribe();
} }
} }
...@@ -331,7 +331,7 @@ class FeedSub extends Managed_DataObject ...@@ -331,7 +331,7 @@ class FeedSub extends Managed_DataObject
'hub.verify_token' => 'Deprecated-since-PuSH-0.4', // TODO: rm! 'hub.verify_token' => 'Deprecated-since-PuSH-0.4', // TODO: rm!
'hub.secret' => $this->secret, 'hub.secret' => $this->secret,
'hub.topic' => $this->uri); 'hub.topic' => $this->getUri());
$client = new HTTPClient(); $client = new HTTPClient();
if ($this->huburi) { if ($this->huburi) {
$hub = $this->huburi; $hub = $this->huburi;
...@@ -359,7 +359,7 @@ class FeedSub extends Managed_DataObject ...@@ -359,7 +359,7 @@ class FeedSub extends Managed_DataObject
} }
} catch (Exception $e) { } catch (Exception $e) {
// wtf! // wtf!
common_log(LOG_ERR, __METHOD__ . ": error \"{$e->getMessage()}\" hitting hub $this->huburi subscribing to $this->uri"); common_log(LOG_ERR, __METHOD__ . ": error \"{$e->getMessage()}\" hitting hub $this->huburi subscribing to " . $this->getUri());
$orig = clone($this); $orig = clone($this);
$this->sub_state = 'inactive'; $this->sub_state = 'inactive';
...@@ -425,10 +425,10 @@ class FeedSub extends Managed_DataObject ...@@ -425,10 +425,10 @@ class FeedSub extends Managed_DataObject
*/ */
public function receive($post, $hmac) public function receive($post, $hmac)
{ {
common_log(LOG_INFO, __METHOD__ . ": packet for \"$this->uri\"! $hmac $post"); common_log(LOG_INFO, __METHOD__ . ": packet for \"" . $this->getUri() . "\"! $hmac $post");
if ($this->sub_state != 'active') { if ($this->sub_state != 'active') {
common_log(LOG_ERR, __METHOD__ . ": ignoring PuSH for inactive feed $this->uri (in state '$this->sub_state')"); common_log(LOG_ERR, __METHOD__ . ": ignoring PuSH for inactive feed " . $this->getUri() . " (in state '$this->sub_state')");
return; return;
} }
...@@ -483,9 +483,9 @@ class FeedSub extends Managed_DataObject ...@@ -483,9 +483,9 @@ class FeedSub extends Managed_DataObject
if ($tempfile) { if ($tempfile) {
file_put_contents($tempfile, $post); file_put_contents($tempfile, $post);
} }
common_log(LOG_ERR, __METHOD__ . ": ignoring PuSH with bad SHA-1 HMAC: got $their_hmac, expected $our_hmac for feed $this->uri on $this->huburi; saved to $tempfile"); common_log(LOG_ERR, __METHOD__ . ": ignoring PuSH with bad SHA-1 HMAC: got $their_hmac, expected $our_hmac for feed " . $this->getUri() . " on $this->huburi; saved to $tempfile");
} else { } else {
common_log(LOG_ERR, __METHOD__ . ": ignoring PuSH with bad SHA-1 HMAC: got $their_hmac, expected $our_hmac for feed $this->uri on $this->huburi"); common_log(LOG_ERR, __METHOD__ . ": ignoring PuSH with bad SHA-1 HMAC: got $their_hmac, expected $our_hmac for feed " . $this->getUri() . " on $this->huburi");
} }
} else { } else {
common_log(LOG_ERR, __METHOD__ . ": ignoring PuSH with bogus HMAC '$hmac'"); common_log(LOG_ERR, __METHOD__ . ": ignoring PuSH with bogus HMAC '$hmac'");
......
...@@ -76,6 +76,11 @@ class Ostatus_profile extends Managed_DataObject ...@@ -76,6 +76,11 @@ class Ostatus_profile extends Managed_DataObject
); );
} }
public function getUri()
{
return $this->uri;
}
/** /**
* Fetch the StatusNet-side profile for this feed * Fetch the StatusNet-side profile for this feed
* @return Profile * @return Profile
...@@ -165,10 +170,10 @@ class Ostatus_profile extends Managed_DataObject ...@@ -165,10 +170,10 @@ class Ostatus_profile extends Managed_DataObject
return true; return true;
} else if ($this->group_id && ($this->profile_id || $this->peopletag_id)) { } else if ($this->group_id && ($this->profile_id || $this->peopletag_id)) {
// TRANS: Server exception. %s is a URI // TRANS: Server exception. %s is a URI
throw new ServerException(sprintf(_m('Invalid ostatus_profile state: Two or more IDs set for %s.'), $this->uri)); throw new ServerException(sprintf(_m('Invalid ostatus_profile state: Two or more IDs set for %s.'), $this->getUri()));
} else { } else {
// TRANS: Server exception. %s is a URI // TRANS: Server exception. %s is a URI
throw new ServerException(sprintf(_m('Invalid ostatus_profile state: All IDs empty for %s.'), $this->uri)); throw new ServerException(sprintf(_m('Invalid ostatus_profile state: All IDs empty for %s.'), $this->getUri()));
} }
} }
...@@ -183,10 +188,10 @@ class Ostatus_profile extends Managed_DataObject ...@@ -183,10 +188,10 @@ class Ostatus_profile extends Managed_DataObject
return true; return true;
} else if ($this->peopletag_id && ($this->profile_id || $this->group_id)) { } else if ($this->peopletag_id && ($this->profile_id || $this->group_id)) {
// TRANS: Server exception. %s is a URI // TRANS: Server exception. %s is a URI
throw new ServerException(sprintf(_m('Invalid ostatus_profile state: Two or more IDs set for %s.'), $this->uri)); throw new ServerException(sprintf(_m('Invalid ostatus_profile state: Two or more IDs set for %s.'), $this->getUri()));
} else { } else {
// TRANS: Server exception. %s is a URI // TRANS: Server exception. %s is a URI
throw new ServerException(sprintf(_m('Invalid ostatus_profile state: All IDs empty for %s.'), $this->uri)); throw new ServerException(sprintf(_m('Invalid ostatus_profile state: All IDs empty for %s.'), $this->getUri()));
} }
} }
...@@ -954,7 +959,7 @@ class Ostatus_profile extends Managed_DataObject ...@@ -954,7 +959,7 @@ class Ostatus_profile extends Managed_DataObject
$groups[] = $oprofile->group_id; $groups[] = $oprofile->group_id;
} else { } else {
// may be canonicalized or something // may be canonicalized or something
$replies[] = $oprofile->uri; $replies[] = $oprofile->getUri();
} }
continue; continue;
} catch (Exception $e) { } catch (Exception $e) {
...@@ -1227,7 +1232,7 @@ class Ostatus_profile extends Managed_DataObject ...@@ -1227,7 +1232,7 @@ class Ostatus_profile extends Managed_DataObject
throw new ServerException(sprintf( throw new ServerException(sprintf(
// TRANS: Server exception. %s is a URI. // TRANS: Server exception. %s is a URI.
_m('Tried to update avatar for unsaved remote profile %s.'), _m('Tried to update avatar for unsaved remote profile %s.'),
$this->uri)); $this->getUri()));
} }
// @todo FIXME: This should be better encapsulated // @todo FIXME: This should be better encapsulated
...@@ -1459,7 +1464,7 @@ class Ostatus_profile extends Managed_DataObject ...@@ -1459,7 +1464,7 @@ class Ostatus_profile extends Managed_DataObject
} }
$user = User::getKV('uri', $homeuri); $user = User::getKV('uri', $homeuri);
if ($user) { if ($user instanceof User) {
// TRANS: Exception. // TRANS: Exception.
throw new Exception(_m('Local user cannot be referenced as remote.')); throw new Exception(_m('Local user cannot be referenced as remote.'));
} }
...@@ -1914,7 +1919,7 @@ class Ostatus_profile extends Managed_DataObject ...@@ -1914,7 +1919,7 @@ class Ostatus_profile extends Managed_DataObject
$oprofile = Ostatus_profile::getKV('uri', 'acct:'.$addr); $oprofile = Ostatus_profile::getKV('uri', 'acct:'.$addr);
if ($oprofile instanceof Ostatus_profile) { if ($oprofile instanceof Ostatus_profile) {
self::cacheSet(sprintf('ostatus_profile:webfinger:%s', $addr), $oprofile->uri); self::cacheSet(sprintf('ostatus_profile:webfinger:%s', $addr), $oprofile->getUri());
return $oprofile; return $oprofile;
} }
...@@ -1952,7 +1957,7 @@ class Ostatus_profile extends Managed_DataObject ...@@ -1952,7 +1957,7 @@ class Ostatus_profile extends Managed_DataObject
try { try {
common_log(LOG_INFO, "Discovery on acct:$addr with feed URL " . $hints['feedurl']); common_log(LOG_INFO, "Discovery on acct:$addr with feed URL " . $hints['feedurl']);
$oprofile = self::ensureFeedURL($hints['feedurl'], $hints); $oprofile = self::ensureFeedURL($hints['feedurl'], $hints);
self::cacheSet(sprintf('ostatus_profile:webfinger:%s', $addr), $oprofile->uri); self::cacheSet(sprintf('ostatus_profile:webfinger:%s', $addr), $oprofile->getUri());
return $oprofile; return $oprofile;
} catch (Exception $e) { } catch (Exception $e) {
common_log(LOG_WARNING, "Failed creating profile from feed URL '$feedUrl': " . $e->getMessage()); common_log(LOG_WARNING, "Failed creating profile from feed URL '$feedUrl': " . $e->getMessage());
...@@ -1965,7 +1970,7 @@ class Ostatus_profile extends Managed_DataObject ...@@ -1965,7 +1970,7 @@ class Ostatus_profile extends Managed_DataObject
try { try {
common_log(LOG_INFO, "Discovery on acct:$addr with profile URL $profileUrl"); common_log(LOG_INFO, "Discovery on acct:$addr with profile URL $profileUrl");
$oprofile = self::ensureProfileURL($hints['profileurl'], $hints); $oprofile = self::ensureProfileURL($hints['profileurl'], $hints);
self::cacheSet(sprintf('ostatus_profile:webfinger:%s', $addr), $oprofile->uri); self::cacheSet(sprintf('ostatus_profile:webfinger:%s', $addr), $oprofile->getUri());
return $oprofile; return $oprofile;
} catch (OStatusShadowException $e) { } catch (OStatusShadowException $e) {
// We've ended up with a remote reference to a local user or group. // We've ended up with a remote reference to a local user or group.
...@@ -2029,7 +2034,7 @@ class Ostatus_profile extends Managed_DataObject ...@@ -2029,7 +2034,7 @@ class Ostatus_profile extends Managed_DataObject
throw new Exception(sprintf(_m('Could not save OStatus profile for "%s".'),$addr)); throw new Exception(sprintf(_m('Could not save OStatus profile for "%s".'),$addr));
} }
self::cacheSet(sprintf('ostatus_profile:webfinger:%s', $addr), $oprofile->uri); self::cacheSet(sprintf('ostatus_profile:webfinger:%s', $addr), $oprofile->getUri());
return $oprofile; return $oprofile;
} }
...@@ -2133,7 +2138,7 @@ class Ostatus_profile extends Managed_DataObject ...@@ -2133,7 +2138,7 @@ class Ostatus_profile extends Managed_DataObject
// Groups can't post notices in StatusNet. // Groups can't post notices in StatusNet.
common_log(LOG_WARNING, common_log(LOG_WARNING,
"OStatus: skipping post with group listed ". "OStatus: skipping post with group listed ".
"as author: $oprofile->uri in feed from $this->uri"); "as author: " . $oprofile->getUri() . " in feed from " . $this->getUri());
return false; return false;
} }
} else { } else {
...@@ -2141,7 +2146,7 @@ class Ostatus_profile extends Managed_DataObject ...@@ -2141,7 +2146,7 @@ class Ostatus_profile extends Managed_DataObject
if (empty($actor)) { if (empty($actor)) {
// OK here! assume the default // OK here! assume the default
} else if ($actor->id == $this->uri || $actor->link == $this->uri) { } else if ($actor->id == $this->getUri() || $actor->link == $this->getUri()) {
$this->updateFromActivityObject($actor); $this->updateFromActivityObject($actor);
} else if ($actor->id) { } else if ($actor->id) {
// We have an ActivityStreams actor with an explicit ID that doesn't match the feed owner. // We have an ActivityStreams actor with an explicit ID that doesn't match the feed owner.
...@@ -2150,7 +2155,7 @@ class Ostatus_profile extends Managed_DataObject ...@@ -2150,7 +2155,7 @@ class Ostatus_profile extends Managed_DataObject
// Most likely this is a plain ol' blog feed of some kind which // Most likely this is a plain ol' blog feed of some kind which
// doesn't match our expectations. We'll take the entry, but ignore // doesn't match our expectations. We'll take the entry, but ignore
// the <author> info. // the <author> info.
common_log(LOG_WARNING, "Got an actor '{$actor->title}' ({$actor->id}) on single-user feed for {$this->uri}"); common_log(LOG_WARNING, "Got an actor '{$actor->title}' ({$actor->id}) on single-user feed for " . $this->getUri());
} else { } else {