diff options
Diffstat (limited to 'plugins/OStatus/classes/Ostatus_profile.php')
-rw-r--r-- | plugins/OStatus/classes/Ostatus_profile.php | 54 |
1 files changed, 39 insertions, 15 deletions
diff --git a/plugins/OStatus/classes/Ostatus_profile.php b/plugins/OStatus/classes/Ostatus_profile.php index 898c63e83..19fe5169b 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')) . '">' . '…' . - '</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()) { @@ -1058,6 +1065,14 @@ class Ostatus_profile extends Memcached_DataObject null, common_timestamp()); rename($temp_filename, Avatar::path($filename)); + // @fixme hardcoded chmod is lame, but seems to be necessary to + // keep from accidentally saving images from command-line (queues) + // that can't be read from web server, which causes hard-to-notice + // problems later on: + // + // http://status.net/open-source/issues/2663 + chmod(Avatar::path($filename), 0644); + $self->setOriginal($filename); $orig = clone($this); @@ -1226,7 +1241,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 +1271,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 +1328,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 +1339,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 +1606,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 +1634,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 +1716,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 +1735,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 +1843,3 @@ class OStatusShadowException extends Exception parent::__construct($message); } } - |