} else if ($this->group_id && !$this->profile_id) {
return true;
} else if ($this->group_id && $this->profile_id) {
- throw new ServerException("Invalid ostatus_profile state: both group and profile IDs set for $this->uri");
+ // @todo i18n FIXME: use sprintf and add i18n.
+ throw new ServerException("Invalid ostatus_profile state: both group and profile IDs set for $this->uri.");
} else {
- throw new ServerException("Invalid ostatus_profile state: both group and profile IDs empty for $this->uri");
+ // @todo i18n FIXME: use sprintf and add i18n.
+ throw new ServerException("Invalid ostatus_profile state: both group and profile IDs empty for $this->uri.");
}
}
} else if ($entry instanceof Notice) {
return $preamble . $entry->asAtomEntry(true, true);
} else {
- throw new ServerException("Invalid type passed to Ostatus_profile::notify; must be XML string or Activity entry");
+ // @todo i18n FIXME: use sprintf and add i18n.
+ throw new ServerException("Invalid type passed to Ostatus_profile::notify; must be XML string or Activity entry.");
}
}
$sourceContent = $note->title;
} else {
// @fixme fetch from $sourceUrl?
- throw new ClientException("No content for notice {$sourceUri}");
+ // @todo i18n FIXME: use sprintf and add i18n.
+ throw new ClientException("No content for notice {$sourceUri}.");
}
// Get (safe!) HTML and text versions of the content
' class="attachment more"' .
' title="'. htmlspecialchars(_m('Show more')) . '">' .
'…' .
- '</a>';
+ '</a>'; // @todo i18n FIXME: add translator hint/context.
}
}
}
// Is the recipient a remote group?
- $oprofile = Ostatus_profile::staticGet('uri', $recipient);
+ $oprofile = Ostatus_profile::ensureProfileURI($recipient);
+
if ($oprofile) {
if ($oprofile->isGroup()) {
// Deliver to local members of this remote group.
// @fixme sender verification?
$groups[] = $oprofile->group_id;
} else {
- common_log(LOG_DEBUG, "Skipping reply to remote profile $recipient");
+ // may be canonicalized or something
+ $replies[] = $oprofile->uri;
}
continue;
}
$response = $client->get($profile_url);
if (!$response->isOk()) {
+ // @todo i18n FIXME: use sprintf and add i18n.
throw new Exception("Could not reach profile page: " . $profile_url);
}
return self::ensureFeedURL($feedurl, $hints);
}
+ // @todo i18n FIXME: use sprintf and add i18n.
throw new Exception("Could not find a feed URL for profile page " . $finalUrl);
}
$user = User::staticGet('id', $profile->id);
if (!empty($user)) {
+ // @todo i18n FIXME: use sprintf and add i18n.
throw new OStatusShadowException($profile, "'$profile_url' is the profile for local user '{$user->nickname}'.");
}
return;
}
if (!common_valid_http_url($url)) {
- throw new ServerException(sprintf(_m("Invalid avatar URL %s"), $url));
+ throw new ServerException(sprintf(_m("Invalid avatar URL %s."), $url));
}
if ($this->isGroup()) {
}
if (!$self) {
throw new ServerException(sprintf(
- _m("Tried to update avatar for unsaved remote profile %s"),
+ _m("Tried to update avatar for unsaved remote profile %s."),
$this->uri));
}
// ripped from oauthstore.php (for old OMB client)
$temp_filename = tempnam(sys_get_temp_dir(), 'listener_avatar');
if (!copy($url, $temp_filename)) {
- throw new ServerException(sprintf(_m("Unable to fetch avatar from %s"), $url));
+ throw new ServerException(sprintf(_m("Unable to fetch avatar from %s."), $url));
}
if ($this->isGroup()) {
if ($object->link && common_valid_http_url($object->link)) {
return $object->link;
}
- throw new ServerException("No author ID URI found");
+ throw new ServerException("No author ID URI found.");
}
/**
$user = User::staticGet('uri', $homeuri);
if ($user) {
+ // @todo i18n FIXME: add i18n.
throw new Exception("Local user can't be referenced as remote.");
}
if (OStatusPlugin::localGroupFromUrl($homeuri)) {
+ // @todo i18n FIXME: add i18n.
throw new Exception("Local group can't be referenced as remote.");
}
$oprofile->profile_id = $profile->insert();
if (!$oprofile->profile_id) {
- throw new ServerException("Can't save local profile");
+ // @todo i18n FIXME: add i18n.
+ throw new ServerException("Can't save local profile.");
}
} else {
$group = new User_group();
$oprofile->group_id = $group->insert();
if (!$oprofile->group_id) {
- throw new ServerException("Can't save local profile");
+ // @todo i18n FIXME: add i18n.
+ throw new ServerException("Can't save local profile.");
}
}
$ok = $oprofile->insert();
if (!$ok) {
- throw new ServerException("Can't save OStatus profile");
+ // @todo i18n FIXME: add i18n.
+ throw new ServerException("Can't save OStatus profile.");
}
$avatar = self::getActivityObjectAvatar($object, $hints);
if ($uri !== false) {
if (is_null($uri)) {
// Negative cache entry
+ // @todo i18n FIXME: add i18n.
throw new Exception('Not a valid webfinger address.');
}
$oprofile = Ostatus_profile::staticGet('uri', $uri);
// Save negative cache entry so we don't waste time looking it up again.
// @fixme distinguish temporary failures?
self::cacheSet(sprintf('ostatus_profile:webfinger:%s', $addr), null);
+ // @todo i18n FIXME: add i18n.
throw new Exception('Not a valid webfinger address.');
}
if (!$profile_id) {
common_log_db_error($profile, 'INSERT', __FILE__);
- throw new Exception("Couldn't save profile for '$addr'");
+ // @todo i18n FIXME: add i18n and use sprintf for parameter.
+ throw new Exception("Couldn't save profile for '$addr'.");
}
$oprofile = new Ostatus_profile();
if (!$result) {
common_log_db_error($oprofile, 'INSERT', __FILE__);
- throw new Exception("Couldn't save ostatus_profile for '$addr'");
+ // @todo i18n FIXME: add i18n and use sprintf for parameter.
+ throw new Exception("Couldn't save ostatus_profile for '$addr'.");
}
self::cacheSet(sprintf('ostatus_profile:webfinger:%s', $addr), $oprofile->uri);
return $oprofile;
}
+ // @todo i18n FIXME: add i18n and use sprintf for parameter.
throw new Exception("Couldn't find a valid profile for '$addr'");
}
return $file;
}
+
+ static function ensureProfileURI($uri)
+ {
+ $oprofile = null;
+
+ // First, try to query it
+
+ $oprofile = Ostatus_profile::staticGet('uri', $uri);
+
+ // If unfound, do discovery stuff
+
+ if (empty($oprofile)) {
+ if (preg_match("/^(\w+)\:(.*)/", $uri, $match)) {
+ $protocol = $match[1];
+ switch ($protocol) {
+ case 'http':
+ case 'https':
+ $oprofile = Ostatus_profile::ensureProfileURL($uri);
+ break;
+ case 'acct':
+ case 'mailto':
+ $rest = $match[2];
+ $oprofile = Ostatus_profile::ensureWebfinger($rest);
+ default:
+ common_log("Unrecognized URI protocol for profile: $protocol ($uri)");
+ break;
+ }
+ }
+ }
+ return $oprofile;
+ }
}
/**
parent::__construct($message);
}
}
-