diff options
author | Evan Prodromou <evan@status.net> | 2010-11-15 11:54:42 -0500 |
---|---|---|
committer | Evan Prodromou <evan@status.net> | 2010-11-15 11:54:42 -0500 |
commit | cb371d65c18771f8fcdcbeb450c063b844c000df (patch) | |
tree | 32bb77f9c1628bf76cd167cd7b1feec0d125bd85 /actions | |
parent | b60b9b4fa2863a398291706350b3f68f725f7687 (diff) |
add hooks for atom pub posts
Diffstat (limited to 'actions')
-rw-r--r-- | actions/apitimelineuser.php | 46 |
1 files changed, 30 insertions, 16 deletions
diff --git a/actions/apitimelineuser.php b/actions/apitimelineuser.php index 69cd9c2cb..7e7663646 100644 --- a/actions/apitimelineuser.php +++ b/actions/apitimelineuser.php @@ -325,20 +325,38 @@ class ApiTimelineUserAction extends ApiBareAuthAction $activity = new Activity($dom->documentElement); - if ($activity->verb != ActivityVerb::POST) { - $this->clientError(_('Can only handle post activities.')); - return; - } + if (Event::handle('StartAtomPubNewActivity', array(&$activity))) { - $note = $activity->objects[0]; + if ($activity->verb != ActivityVerb::POST) { + $this->clientError(_('Can only handle post activities.')); + return; + } - if (!in_array($note->type, array(ActivityObject::NOTE, - ActivityObject::BLOGENTRY, - ActivityObject::STATUS))) { - $this->clientError(sprintf(_('Cannot handle activity object type "%s"', - $note->type))); - return; + $note = $activity->objects[0]; + + if (!in_array($note->type, array(ActivityObject::NOTE, + ActivityObject::BLOGENTRY, + ActivityObject::STATUS))) { + $this->clientError(sprintf(_('Cannot handle activity object type "%s"', + $note->type))); + return; + } + + $saved = $this->postNote($activity); + + Event::handle('EndAtomPubNewActivity', array($activity, $saved)); + } + + if (!empty($saved)) { + header("Location: " . common_local_url('ApiStatusesShow', array('notice_id' => $saved->id, + 'format' => 'atom'))); + $this->showSingleAtomStatus($saved); } + } + + function postNote($activity) + { + $note = $activity->objects[0]; // Use summary as fallback for content @@ -458,11 +476,7 @@ class ApiTimelineUserAction extends ApiBareAuthAction 'atompub', // TODO: deal with this $options); - if (!empty($saved)) { - header("Location: " . common_local_url('ApiStatusesShow', array('notice_id' => $saved->id, - 'format' => 'atom'))); - $this->showSingleAtomStatus($saved); - } + return $saved; } function purify($content) |