summaryrefslogtreecommitdiff
path: root/plugins/OStatus/classes
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/OStatus/classes')
-rw-r--r--plugins/OStatus/classes/FeedSub.php9
-rw-r--r--plugins/OStatus/classes/HubSub.php13
-rw-r--r--plugins/OStatus/classes/Magicsig.php4
-rw-r--r--plugins/OStatus/classes/Ostatus_profile.php126
-rw-r--r--plugins/OStatus/classes/Ostatus_source.php4
5 files changed, 70 insertions, 86 deletions
diff --git a/plugins/OStatus/classes/FeedSub.php b/plugins/OStatus/classes/FeedSub.php
index 6f9e0856a..58beec673 100644
--- a/plugins/OStatus/classes/FeedSub.php
+++ b/plugins/OStatus/classes/FeedSub.php
@@ -39,7 +39,6 @@ PuSH subscription flow:
hub sends us updates via POST
*/
-
class FeedDBException extends FeedSubException
{
public $obj;
@@ -88,7 +87,6 @@ class FeedSub extends Memcached_DataObject
*
* @return array array of column definitions
*/
-
function table()
{
return array('id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
@@ -143,7 +141,6 @@ class FeedSub extends Memcached_DataObject
*
* @return array key definitions
*/
-
function keys()
{
return array_keys($this->keyTypes());
@@ -157,7 +154,6 @@ class FeedSub extends Memcached_DataObject
*
* @return array key definitions
*/
-
function keyTypes()
{
return array('id' => 'K', 'uri' => 'U');
@@ -249,7 +245,7 @@ class FeedSub extends Memcached_DataObject
// We'll never actually get updates in this mode.
return true;
} else {
- throw new ServerException("Attempting to start PuSH subscription for feed with no hub.");
+ throw new ServerException(_m('Attempting to start PuSH subscription for feed with no hub.'));
}
}
@@ -279,7 +275,7 @@ class FeedSub extends Memcached_DataObject
// We'll never actually get updates in this mode.
return true;
} else {
- throw new ServerException("Attempting to end PuSH subscription for feed with no hub.");
+ throw new ServerException(_m('Attempting to end PuSH subscription for feed with no hub.'));
}
}
@@ -500,5 +496,4 @@ class FeedSub extends Memcached_DataObject
}
return false;
}
-
}
diff --git a/plugins/OStatus/classes/HubSub.php b/plugins/OStatus/classes/HubSub.php
index e01ae4e79..825d36ebd 100644
--- a/plugins/OStatus/classes/HubSub.php
+++ b/plugins/OStatus/classes/HubSub.php
@@ -54,7 +54,6 @@ class HubSub extends Memcached_DataObject
*
* @return array array of column definitions
*/
-
function table()
{
return array('hashkey' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
@@ -112,7 +111,6 @@ class HubSub extends Memcached_DataObject
*
* @return array key definitions
*/
-
function keyTypes()
{
return array('hashkey' => 'K');
@@ -206,8 +204,8 @@ class HubSub extends Memcached_DataObject
if ($status >= 200 && $status < 300) {
common_log(LOG_INFO, "Verified $mode of $this->callback:$this->topic");
} else {
- // @todo i18n FIXME: add i18n and use sprintf for parameter.
- throw new ClientException("Hub subscriber verification returned HTTP $status");
+ // TRANS: Client exception. %s is a HTTP status code.
+ throw new ClientException(sprintf(_m('Hub subscriber verification returned HTTP %s.'),$status));
}
$old = HubSub::staticGet($this->topic, $this->callback);
@@ -353,10 +351,9 @@ class HubSub extends Memcached_DataObject
if ($response->isOk()) {
return true;
} else {
- throw new Exception("Callback returned status: " .
- $response->getStatus() .
- "; body: " .
- trim($response->getBody()));
+ // TRANS: Exception. %1$s is a response status code, %2$s is the body of the response.
+ throw new Exception(sprintf(_m('Callback returned status: %1$s. Body: %2$s'),
+ $response->getStatus(),trim($response->getBody())));
}
}
}
diff --git a/plugins/OStatus/classes/Magicsig.php b/plugins/OStatus/classes/Magicsig.php
index e39a6d8f7..20025c37a 100644
--- a/plugins/OStatus/classes/Magicsig.php
+++ b/plugins/OStatus/classes/Magicsig.php
@@ -31,7 +31,6 @@ require_once 'Crypt/RSA.php';
class Magicsig extends Memcached_DataObject
{
-
const PUBLICKEYREL = 'magic-public-key';
public $__table = 'magicsig';
@@ -86,7 +85,6 @@ class Magicsig extends Memcached_DataObject
64, false));
}
-
function keys()
{
return array_keys($this->keyTypes());
@@ -126,7 +124,6 @@ class Magicsig extends Memcached_DataObject
$this->insert();
}
-
public function toString($full_pair = true)
{
$mod = Magicsig::base64_url_encode($this->publicKey->modulus->toBytes());
@@ -197,7 +194,6 @@ class Magicsig extends Memcached_DataObject
case 'RSA-SHA256':
return 'sha256';
}
-
}
public function sign($bytes)
diff --git a/plugins/OStatus/classes/Ostatus_profile.php b/plugins/OStatus/classes/Ostatus_profile.php
index bf2bcb44f..047435f66 100644
--- a/plugins/OStatus/classes/Ostatus_profile.php
+++ b/plugins/OStatus/classes/Ostatus_profile.php
@@ -21,7 +21,6 @@
* @package OStatusPlugin
* @maintainer Brion Vibber <brion@status.net>
*/
-
class Ostatus_profile extends Memcached_DataObject
{
public $__table = 'ostatus_profile';
@@ -51,7 +50,6 @@ class Ostatus_profile extends Memcached_DataObject
*
* @return array array of column definitions
*/
-
function table()
{
return array('uri' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
@@ -92,7 +90,6 @@ class Ostatus_profile extends Memcached_DataObject
*
* @return array key definitions
*/
-
function keys()
{
return array_keys($this->keyTypes());
@@ -106,7 +103,6 @@ class Ostatus_profile extends Memcached_DataObject
*
* @return array key definitions
*/
-
function keyTypes()
{
return array('uri' => 'K', 'profile_id' => 'U', 'group_id' => 'U', 'feeduri' => 'U');
@@ -188,11 +184,11 @@ class Ostatus_profile extends Memcached_DataObject
} else if ($this->group_id && !$this->profile_id) {
return true;
} else if ($this->group_id && $this->profile_id) {
- // @todo i18n FIXME: use sprintf and add i18n.
- throw new ServerException("Invalid ostatus_profile state: both group and profile IDs set for $this->uri.");
+ // TRANS: Server exception.
+ throw new ServerException(sprintf(_m('Invalid ostatus_profile state: both group and profile IDs set for %s.'),$this->uri));
} else {
- // @todo i18n FIXME: use sprintf and add i18n.
- throw new ServerException("Invalid ostatus_profile state: both group and profile IDs empty for $this->uri.");
+ // TRANS: Server exception.
+ throw new ServerException(sprintf(_m('Invalid ostatus_profile state: both group and profile IDs empty for %s.'),$this->uri));
}
}
@@ -280,7 +276,9 @@ class Ostatus_profile extends Memcached_DataObject
if ($type == 'object') {
$type = get_class($actor);
}
- throw new ServerException("Invalid actor passed to " . __METHOD__ . ": " . $type);
+ // TRANS: Server exception.
+ // TRANS: %1$s is the method name the exception occured in, %2$s is the actor type.
+ throw new ServerException(sprintf(_m('Invalid actor passed to %1$s: %2$s.'),__METHOD__,$type));
}
if ($object == null) {
$object = $this;
@@ -372,8 +370,8 @@ class Ostatus_profile extends Memcached_DataObject
} else if ($entry instanceof Notice) {
return $preamble . $entry->asAtomEntry(true, true);
} else {
- // @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.");
+ // TRANS: Server exception.
+ throw new ServerException(_m('Invalid type passed to Ostatus_profile::notify. It must be XML string or Activity entry.'));
}
}
@@ -403,7 +401,7 @@ class Ostatus_profile extends Memcached_DataObject
} else if ($feed->localName == 'rss') { // @fixme check namespace
$this->processRssFeed($feed, $source);
} else {
- throw new Exception("Unknown feed format.");
+ throw new Exception(_m('Unknown feed format.'));
}
}
@@ -426,7 +424,7 @@ class Ostatus_profile extends Memcached_DataObject
$channels = $rss->getElementsByTagName('channel');
if ($channels->length == 0) {
- throw new Exception("RSS feed without a channel.");
+ throw new Exception(_m('RSS feed without a channel.'));
} else if ($channels->length > 1) {
common_log(LOG_WARNING, __METHOD__ . ": more than one channel in an RSS feed");
}
@@ -470,7 +468,8 @@ class Ostatus_profile extends Memcached_DataObject
}
break;
default:
- throw new ClientException("Can't handle that kind of post.");
+ // TRANS: Client exception.
+ throw new ClientException(_m('Can\'t handle that kind of post.'));
}
Event::handle('EndHandleFeedEntry', array($activity));
@@ -552,8 +551,8 @@ class Ostatus_profile extends Memcached_DataObject
$sourceContent = $note->title;
} else {
// @fixme fetch from $sourceUrl?
- // @todo i18n FIXME: use sprintf and add i18n.
- throw new ClientException("No content for notice {$sourceUri}.");
+ // TRANS: Client exception. %s is a source URL.
+ throw new ClientException(sprintf(_m('No content for notice %s.'),$sourceUri));
}
// Get (safe!) HTML and text versions of the content
@@ -584,14 +583,17 @@ class Ostatus_profile extends Memcached_DataObject
// We mark up the attachment link specially for the HTML output
// so we can fold-out the full version inline.
+
+ // TRANS: Shown when a notice is longer than supported and/or when attachments are present.
+ $showMoreText = _m('Show more');
$attachUrl = common_local_url('attachment',
array('attachment' => $attachment->id));
$rendered = common_render_text($shortSummary) .
'<a href="' . htmlspecialchars($attachUrl) .'"'.
' class="attachment more"' .
- ' title="'. htmlspecialchars(_m('Show more')) . '">' .
+ ' title="'. htmlspecialchars($showMoreText) . '">' .
'&#8230;' .
- '</a>'; // @todo i18n FIXME: add translator hint/context.
+ '</a>';
}
}
@@ -703,23 +705,7 @@ class Ostatus_profile extends Memcached_DataObject
continue;
}
- // Is the recipient a remote group?
- $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 {
- // may be canonicalized or something
- $replies[] = $oprofile->uri;
- }
- continue;
- }
-
// Is the recipient a local group?
- // @fixme uri on user_group isn't reliable yet
// $group = User_group::staticGet('uri', $recipient);
$id = OStatusPlugin::localGroupFromUrl($recipient);
if ($id) {
@@ -738,7 +724,22 @@ class Ostatus_profile extends Memcached_DataObject
}
}
- common_log(LOG_DEBUG, "Skipping reply to unrecognized profile $recipient");
+ // Is the recipient a remote user or group?
+ try {
+ $oprofile = Ostatus_profile::ensureProfileURI($recipient);
+ if ($oprofile->isGroup()) {
+ // Deliver to local members of this remote group.
+ // @fixme sender verification?
+ $groups[] = $oprofile->group_id;
+ } else {
+ // may be canonicalized or something
+ $replies[] = $oprofile->uri;
+ }
+ continue;
+ } catch (Exception $e) {
+ // Neither a recognizable local nor remote user!
+ common_log(LOG_DEBUG, "Skipping reply to unrecognized profile $recipient: " . $e->getMessage());
+ }
}
$attention_uris = $replies;
@@ -776,8 +777,8 @@ class Ostatus_profile extends Memcached_DataObject
$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);
+ // TRANS: Exception. %s is a profile URL.
+ throw new Exception(sprintf(_m('Could not reach profile page %s.'),$profile_url));
}
// Check if we have a non-canonical URL
@@ -834,8 +835,8 @@ class Ostatus_profile extends Memcached_DataObject
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);
+ // TRANS: Exception.
+ throw new Exception(sprintf(_m('Could not find a feed URL for profile page %s.'),$finalUrl));
}
/**
@@ -867,7 +868,7 @@ class Ostatus_profile extends Memcached_DataObject
$user = User::staticGet('id', $profile->id);
if (!empty($user)) {
- // @todo i18n FIXME: use sprintf and add i18n.
+ // @todo i18n FIXME: use sprintf and add i18n (?)
throw new OStatusShadowException($profile, "'$profile_url' is the profile for local user '{$user->nickname}'.");
}
@@ -972,8 +973,7 @@ class Ostatus_profile extends Memcached_DataObject
}
// XXX: make some educated guesses here
-
- throw new FeedSubException("Can't find enough profile information to make a feed.");
+ throw new FeedSubException(_m('Can\'t find enough profile information to make a feed.'));
}
/**
@@ -1271,13 +1271,13 @@ class Ostatus_profile extends Memcached_DataObject
$user = User::staticGet('uri', $homeuri);
if ($user) {
- // @todo i18n FIXME: add i18n.
- throw new Exception("Local user can't be referenced as remote.");
+ // TRANS: Exception.
+ throw new Exception(_m('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.");
+ // TRANS: Exception.
+ throw new Exception(_m('Local group can\'t be referenced as remote.'));
}
if (array_key_exists('feedurl', $hints)) {
@@ -1328,8 +1328,8 @@ class Ostatus_profile extends Memcached_DataObject
$oprofile->profile_id = $profile->insert();
if (!$oprofile->profile_id) {
- // @todo i18n FIXME: add i18n.
- throw new ServerException("Can't save local profile.");
+ // TRANS: Exception.
+ throw new ServerException(_m('Can\'t save local profile.'));
}
} else {
$group = new User_group();
@@ -1339,16 +1339,16 @@ class Ostatus_profile extends Memcached_DataObject
$oprofile->group_id = $group->insert();
if (!$oprofile->group_id) {
- // @todo i18n FIXME: add i18n.
- throw new ServerException("Can't save local profile.");
+ // TRANS: Exception.
+ throw new ServerException(_m('Can\'t save local profile.'));
}
}
$ok = $oprofile->insert();
if (!$ok) {
- // @todo i18n FIXME: add i18n.
- throw new ServerException("Can't save OStatus profile.");
+ // TRANS: Exception.
+ throw new ServerException(_m('Can\'t save OStatus profile.'));
}
$avatar = self::getActivityObjectAvatar($object, $hints);
@@ -1606,8 +1606,8 @@ class Ostatus_profile extends Memcached_DataObject
if ($uri !== false) {
if (is_null($uri)) {
// Negative cache entry
- // @todo i18n FIXME: add i18n.
- throw new Exception('Not a valid webfinger address.');
+ // TRANS: Exception.
+ throw new Exception(_m('Not a valid webfinger address.'));
}
$oprofile = Ostatus_profile::staticGet('uri', $uri);
if (!empty($oprofile)) {
@@ -1634,8 +1634,8 @@ class Ostatus_profile extends Memcached_DataObject
// 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.');
+ // TRANS: Exception.
+ throw new Exception(_m('Not a valid webfinger address.'));
}
$hints = array('webfinger' => $addr);
@@ -1716,8 +1716,8 @@ class Ostatus_profile extends Memcached_DataObject
if (!$profile_id) {
common_log_db_error($profile, 'INSERT', __FILE__);
- // @todo i18n FIXME: add i18n and use sprintf for parameter.
- throw new Exception("Couldn't save profile for '$addr'.");
+ // TRANS: Exception. %s is a webfinger address.
+ throw new Exception(sprintf(_m('Couldn\'t save profile for "%s".'),$addr));
}
$oprofile = new Ostatus_profile();
@@ -1735,16 +1735,16 @@ class Ostatus_profile extends Memcached_DataObject
if (!$result) {
common_log_db_error($oprofile, 'INSERT', __FILE__);
- // @todo i18n FIXME: add i18n and use sprintf for parameter.
- throw new Exception("Couldn't save ostatus_profile for '$addr'.");
+ // TRANS: Exception. %s is a webfinger address.
+ throw new Exception(sprintf(_m('Couldn\'t save ostatus_profile for "%s".'),$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'");
+ // TRANS: Exception. %s is a webfinger address.
+ throw new Exception(sprintf(_m('Couldn\'t find a valid profile for "%s".'),$addr));
}
/**
@@ -1786,7 +1786,7 @@ class Ostatus_profile extends Memcached_DataObject
if ($file_id === false) {
common_log_db_error($file, "INSERT", __FILE__);
- throw new ServerException(_('Could not store HTML content of long post as file.'));
+ throw new ServerException(_m('Could not store HTML content of long post as file.'));
}
return $file;
diff --git a/plugins/OStatus/classes/Ostatus_source.php b/plugins/OStatus/classes/Ostatus_source.php
index e6ce7d442..b76bbce56 100644
--- a/plugins/OStatus/classes/Ostatus_source.php
+++ b/plugins/OStatus/classes/Ostatus_source.php
@@ -21,7 +21,6 @@
* @package OStatusPlugin
* @maintainer Brion Vibber <brion@status.net>
*/
-
class Ostatus_source extends Memcached_DataObject
{
public $__table = 'ostatus_source';
@@ -43,7 +42,6 @@ class Ostatus_source extends Memcached_DataObject
*
* @return array array of column definitions
*/
-
function table()
{
return array('notice_id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
@@ -69,7 +67,6 @@ class Ostatus_source extends Memcached_DataObject
*
* @return array key definitions
*/
-
function keys()
{
return array_keys($this->keyTypes());
@@ -83,7 +80,6 @@ class Ostatus_source extends Memcached_DataObject
*
* @return array key definitions
*/
-
function keyTypes()
{
return array('notice_id' => 'K');