summaryrefslogtreecommitdiff
path: root/plugins/OStatus/classes
diff options
context:
space:
mode:
authorSiebrand Mazeland <s.mazeland@xs4all.nl>2010-09-03 01:35:04 +0200
committerSiebrand Mazeland <s.mazeland@xs4all.nl>2010-09-03 01:35:04 +0200
commit1bfbe9badfbe3e79f82e7216d1401f05a2750677 (patch)
treebba78cb3dc884c27558c005e101da196afbc1245 /plugins/OStatus/classes
parente365e709c5bab7d593ee1cde26c8bcfdddcc6780 (diff)
* i18n/L10n updates and FIXMEs added
* whitespace fixes
Diffstat (limited to 'plugins/OStatus/classes')
-rw-r--r--plugins/OStatus/classes/FeedSub.php5
-rw-r--r--plugins/OStatus/classes/HubSub.php6
-rw-r--r--plugins/OStatus/classes/Magicsig.php26
-rw-r--r--plugins/OStatus/classes/Ostatus_profile.php46
4 files changed, 48 insertions, 35 deletions
diff --git a/plugins/OStatus/classes/FeedSub.php b/plugins/OStatus/classes/FeedSub.php
index dd1968db1..6f9e0856a 100644
--- a/plugins/OStatus/classes/FeedSub.php
+++ b/plugins/OStatus/classes/FeedSub.php
@@ -249,7 +249,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("Attempting to start PuSH subscription for feed with no hub.");
}
}
@@ -279,7 +279,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("Attempting to end PuSH subscription for feed with no hub.");
}
}
@@ -502,4 +502,3 @@ class FeedSub extends Memcached_DataObject
}
}
-
diff --git a/plugins/OStatus/classes/HubSub.php b/plugins/OStatus/classes/HubSub.php
index 7db528a4e..e01ae4e79 100644
--- a/plugins/OStatus/classes/HubSub.php
+++ b/plugins/OStatus/classes/HubSub.php
@@ -206,6 +206,7 @@ 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");
}
@@ -307,9 +308,9 @@ class HubSub extends Memcached_DataObject
/**
* Queue up a large batch of pushes to multiple subscribers
* for this same topic update.
- *
+ *
* If queues are disabled, this will run immediately.
- *
+ *
* @param string $atom well-formed Atom feed
* @param array $pushCallbacks list of callback URLs
*/
@@ -359,4 +360,3 @@ class HubSub extends Memcached_DataObject
}
}
}
-
diff --git a/plugins/OStatus/classes/Magicsig.php b/plugins/OStatus/classes/Magicsig.php
index f8c56a05f..e39a6d8f7 100644
--- a/plugins/OStatus/classes/Magicsig.php
+++ b/plugins/OStatus/classes/Magicsig.php
@@ -33,21 +33,21 @@ class Magicsig extends Memcached_DataObject
{
const PUBLICKEYREL = 'magic-public-key';
-
+
public $__table = 'magicsig';
public $user_id;
public $keypair;
public $alg;
-
+
public $publicKey;
public $privateKey;
-
+
public function __construct($alg = 'RSA-SHA256')
{
$this->alg = $alg;
}
-
+
public /*static*/ function staticGet($k, $v=null)
{
$obj = parent::staticGet(__CLASS__, $k, $v);
@@ -111,7 +111,7 @@ class Magicsig extends Memcached_DataObject
public function generate($user_id)
{
$rsa = new Crypt_RSA();
-
+
$keypair = $rsa->createKey();
$rsa->loadKey($keypair['privatekey']);
@@ -121,7 +121,7 @@ class Magicsig extends Memcached_DataObject
$this->publicKey = new Crypt_RSA();
$this->publicKey->loadKey($keypair['publickey']);
-
+
$this->user_id = $user_id;
$this->insert();
}
@@ -136,13 +136,13 @@ class Magicsig extends Memcached_DataObject
$private_exp = '.' . Magicsig::base64_url_encode($this->privateKey->exponent->toBytes());
}
- return 'RSA.' . $mod . '.' . $exp . $private_exp;
+ return 'RSA.' . $mod . '.' . $exp . $private_exp;
}
-
+
public static function fromString($text)
{
$magic_sig = new Magicsig();
-
+
// remove whitespace
$text = preg_replace('/\s+/', '', $text);
@@ -150,7 +150,7 @@ class Magicsig extends Memcached_DataObject
if (!preg_match('/RSA\.([^\.]+)\.([^\.]+)(.([^\.]+))?/', $text, $matches)) {
return false;
}
-
+
$mod = $matches[1];
$exp = $matches[2];
if (!empty($matches[4])) {
@@ -184,7 +184,7 @@ class Magicsig extends Memcached_DataObject
$this->publicKey = $rsa;
}
}
-
+
public function getName()
{
return $this->alg;
@@ -199,7 +199,7 @@ class Magicsig extends Memcached_DataObject
}
}
-
+
public function sign($bytes)
{
$sig = $this->privateKey->sign($bytes);
@@ -223,5 +223,3 @@ class Magicsig extends Memcached_DataObject
return base64_decode(strtr($input, '-_', '+/'));
}
}
-
-
diff --git a/plugins/OStatus/classes/Ostatus_profile.php b/plugins/OStatus/classes/Ostatus_profile.php
index 898c63e83..6a0fd1f3b 100644
--- a/plugins/OStatus/classes/Ostatus_profile.php
+++ b/plugins/OStatus/classes/Ostatus_profile.php
@@ -188,9 +188,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) {
- 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.");
}
}
@@ -370,7 +372,8 @@ class Ostatus_profile extends Memcached_DataObject
} 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.");
}
}
@@ -549,7 +552,8 @@ class Ostatus_profile extends Memcached_DataObject
$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
@@ -587,7 +591,7 @@ class Ostatus_profile extends Memcached_DataObject
' class="attachment more"' .
' title="'. htmlspecialchars(_m('Show more')) . '">' .
'&#8230;' .
- '</a>';
+ '</a>'; // @todo i18n FIXME: add translator hint/context.
}
}
@@ -772,6 +776,7 @@ 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);
}
@@ -829,6 +834,7 @@ 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);
}
@@ -861,6 +867,7 @@ class Ostatus_profile extends Memcached_DataObject
$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}'.");
}
@@ -1025,7 +1032,7 @@ class Ostatus_profile extends Memcached_DataObject
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()) {
@@ -1035,7 +1042,7 @@ class Ostatus_profile extends Memcached_DataObject
}
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));
}
@@ -1043,7 +1050,7 @@ class Ostatus_profile extends Memcached_DataObject
// 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()) {
@@ -1226,7 +1233,7 @@ class Ostatus_profile extends Memcached_DataObject
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.");
}
/**
@@ -1256,10 +1263,12 @@ 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.");
}
if (OStatusPlugin::localGroupFromUrl($homeuri)) {
+ // @todo i18n FIXME: add i18n.
throw new Exception("Local group can't be referenced as remote.");
}
@@ -1311,7 +1320,8 @@ class Ostatus_profile extends Memcached_DataObject
$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();
@@ -1321,14 +1331,16 @@ class Ostatus_profile extends Memcached_DataObject
$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);
@@ -1586,6 +1598,7 @@ 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.');
}
$oprofile = Ostatus_profile::staticGet('uri', $uri);
@@ -1613,6 +1626,7 @@ 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.');
}
@@ -1694,7 +1708,8 @@ class Ostatus_profile extends Memcached_DataObject
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();
@@ -1712,13 +1727,15 @@ class Ostatus_profile extends Memcached_DataObject
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'");
}
@@ -1818,4 +1835,3 @@ class OStatusShadowException extends Exception
parent::__construct($message);
}
}
-