summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/OStatus/README4
-rw-r--r--plugins/OStatus/classes/Ostatus_profile.php29
-rw-r--r--plugins/OStatus/lib/salmonaction.php55
3 files changed, 34 insertions, 54 deletions
diff --git a/plugins/OStatus/README b/plugins/OStatus/README
index 09a59e349..3a98b7b25 100644
--- a/plugins/OStatus/README
+++ b/plugins/OStatus/README
@@ -12,10 +12,6 @@ $config['ostatus']['hub_retries']
(default 0)
Number of times to retry a PuSH send to consumers if using internal hub
-$config['ostatus']['purify_cache']
- (default cache disabled)
- Set to a writable cache directory for HTMLPurifier's configuration settings, can speed up processing of remote messages (have not tested by how much)
-
For testing, shouldn't be used in production:
diff --git a/plugins/OStatus/classes/Ostatus_profile.php b/plugins/OStatus/classes/Ostatus_profile.php
index c755a094e..a366c1c2c 100644
--- a/plugins/OStatus/classes/Ostatus_profile.php
+++ b/plugins/OStatus/classes/Ostatus_profile.php
@@ -668,28 +668,9 @@ class Ostatus_profile extends Memcached_DataObject
*/
protected function purify($html)
{
- require_once(INSTALLDIR.'/extlib/HTMLPurifier/HTMLPurifier.auto.php');
-
- // By default Purifier wants to cache data to its own code directories,
- // and spews error messages if they're not writable.
- $config = HTMLPurifier_Config::createDefault();
- if (common_config('ostatus', 'purify_cache')) {
- $config->set('Cache.SerializerPath', common_config('ostatus', 'purify_cache'));
- } else {
- // Although recommended in the documentation, this produces a notice:
- // "Core.DefinitionCache is an alias, preferred directive name is Cache.DefinitionImpl"
- // If I then follow *those* directions, I get a warning and it doesn't work:
- // "Cannot set undefined directive Core.DefinitionImpl"
- // So... lesser of two evils. Suppressing the notice from output,
- // though it'll still be seen and logged by StatusNet's error handler.
- $old = error_reporting();
- error_reporting($old & ~E_NOTICE);
- $config->set('Core.DefinitionCache', null);
- error_reporting($old);
- }
-
- $purifier = new HTMLPurifier($config);
- return $purifier->purify($html);
+ require_once INSTALLDIR.'/extlib/htmLawed/htmLawed.php';
+ $config = array('safe' => 1);
+ return htmLawed($html, $config);
}
/**
@@ -971,7 +952,7 @@ class Ostatus_profile extends Memcached_DataObject
* @param Activity $activity
* @return mixed matching Ostatus_profile or false if none known
*/
- protected static function getActorProfile($activity)
+ public static function getActorProfile($activity)
{
return self::getActivityObjectProfile($activity->actor);
}
@@ -1109,7 +1090,7 @@ class Ostatus_profile extends Memcached_DataObject
* @param ActivityObject $object
* @param array $hints
*/
- protected function updateFromActivityObject($object, $hints=array())
+ public function updateFromActivityObject($object, $hints=array())
{
if ($this->isGroup()) {
$group = $this->localGroup();
diff --git a/plugins/OStatus/lib/salmonaction.php b/plugins/OStatus/lib/salmonaction.php
index 9aac2ed52..a03169101 100644
--- a/plugins/OStatus/lib/salmonaction.php
+++ b/plugins/OStatus/lib/salmonaction.php
@@ -38,11 +38,11 @@ class SalmonAction extends Action
parent::prepare($args);
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
- $this->clientError(_('This method requires a POST.'));
+ $this->clientError(_m('This method requires a POST.'));
}
if (empty($_SERVER['CONTENT_TYPE']) || $_SERVER['CONTENT_TYPE'] != 'application/atom+xml') {
- $this->clientError(_('Salmon requires application/atom+xml'));
+ $this->clientError(_m('Salmon requires application/atom+xml'));
}
$xml = file_get_contents('php://input');
@@ -76,8 +76,7 @@ class SalmonAction extends Action
{
StatusNet::setApi(true); // Send smaller error pages
- // TODO : Insert new $xml -> notice code
-
+ common_log(LOG_DEBUG, "Got a " . $this->act->verb);
if (Event::handle('StartHandleSalmon', array($this->activity))) {
switch ($this->act->verb)
{
@@ -106,8 +105,11 @@ class SalmonAction extends Action
case ActivityVerb::LEAVE:
$this->handleLeave();
break;
+ case ActivityVerb::UPDATE_PROFILE:
+ $this->handleUpdateProfile();
+ break;
default:
- throw new ClientException(_("Unimplemented."));
+ throw new ClientException(_m("Unrecognized activity type."));
}
Event::handle('EndHandleSalmon', array($this->activity));
}
@@ -115,56 +117,57 @@ class SalmonAction extends Action
function handlePost()
{
- throw new ClientException(_("Unimplemented!"));
+ throw new ClientException(_m("This target doesn't understand posts."));
}
function handleFollow()
{
- throw new ClientException(_("Unimplemented!"));
+ throw new ClientException(_m("This target doesn't understand follows."));
}
function handleUnfollow()
{
- throw new ClientException(_("Unimplemented!"));
+ throw new ClientException(_m("This target doesn't understand unfollows."));
}
function handleFavorite()
{
- throw new ClientException(_("Unimplemented!"));
+ throw new ClientException(_m("This target doesn't understand favorites."));
}
- /**
- * Remote user doesn't like one of our posts after all!
- * Confirm the post is ours, and delete a local favorite event.
- */
-
function handleUnfavorite()
{
- throw new ClientException(_("Unimplemented!"));
+ throw new ClientException(_m("This target doesn't understand unfavorites."));
}
- /**
- * Hmmmm
- */
function handleShare()
{
- throw new ClientException(_("Unimplemented!"));
+ throw new ClientException(_m("This target doesn't understand share events."));
}
- /**
- * Hmmmm
- */
function handleJoin()
{
- throw new ClientException(_("Unimplemented!"));
+ throw new ClientException(_m("This target doesn't understand joins."));
+ }
+
+ function handleLeave()
+ {
+ throw new ClientException(_m("This target doesn't understand leave events."));
}
/**
- * Hmmmm
+ * Remote user sent us an update to their profile.
+ * If we already know them, accept the updates.
*/
- function handleLeave()
+ function handleUpdateProfile()
{
- throw new ClientException(_("Unimplemented!"));
+ $oprofile = Ostatus_profile::getActorProfile($this->act);
+ if ($oprofile) {
+ common_log(LOG_INFO, "Got a profile-update ping from $oprofile->uri");
+ $oprofile->updateFromActivityObject($this->act->actor);
+ } else {
+ common_log(LOG_INFO, "Ignoring profile-update ping from unknown " . $this->act->actor->id);
+ }
}
/**