add hooks to allow plugins to handle different kinds of activities

This commit is contained in:
Evan Prodromou 2010-08-13 13:14:47 -07:00
parent 4217277d14
commit 8dec16aeeb

View File

@ -445,10 +445,13 @@ class Ostatus_profile extends Memcached_DataObject
* @param DOMElement $feed for context
* @param string $source identifier ("push" or "salmon")
*/
public function processEntry($entry, $feed, $source)
{
$activity = new Activity($entry, $feed);
if (Event::handle('StartHandleFeedEntry', array($activity))) {
// @todo process all activity objects
switch ($activity->objects[0]->type) {
case ActivityObject::ARTICLE:
@ -456,15 +459,17 @@ class Ostatus_profile extends Memcached_DataObject
case ActivityObject::NOTE:
case ActivityObject::STATUS:
case ActivityObject::COMMENT:
if ($activity->verb == ActivityVerb::POST) {
$this->processPost($activity, $source);
} else {
common_log(LOG_INFO, "Ignoring activity with unrecognized verb $activity->verb");
}
break;
default:
throw new ClientException("Can't handle that kind of post.");
}
if ($activity->verb == ActivityVerb::POST) {
$this->processPost($activity, $source);
} else {
common_log(LOG_INFO, "Ignoring activity with unrecognized verb $activity->verb");
Event::handle('EndHandleFeedEntry', array($activity));
}
}