add hooks for atom pub posts
This commit is contained in:
parent
b60b9b4fa2
commit
cb371d65c1
|
@ -1158,3 +1158,11 @@ StartRevokeRole: when a role is being revoked
|
||||||
EndRevokeRole: when a role has been revoked
|
EndRevokeRole: when a role has been revoked
|
||||||
- $profile: profile that lost the role
|
- $profile: profile that lost the role
|
||||||
- $role: string name of the role
|
- $role: string name of the role
|
||||||
|
|
||||||
|
StartAtomPubNewActivity: When a new activity comes in through Atom Pub API
|
||||||
|
- &$activity: received activity
|
||||||
|
|
||||||
|
EndAtomPubNewActivity: When a new activity comes in through Atom Pub API
|
||||||
|
- $activity: received activity
|
||||||
|
- $notice: notice that was created
|
||||||
|
|
||||||
|
|
|
@ -325,6 +325,8 @@ class ApiTimelineUserAction extends ApiBareAuthAction
|
||||||
|
|
||||||
$activity = new Activity($dom->documentElement);
|
$activity = new Activity($dom->documentElement);
|
||||||
|
|
||||||
|
if (Event::handle('StartAtomPubNewActivity', array(&$activity))) {
|
||||||
|
|
||||||
if ($activity->verb != ActivityVerb::POST) {
|
if ($activity->verb != ActivityVerb::POST) {
|
||||||
$this->clientError(_('Can only handle post activities.'));
|
$this->clientError(_('Can only handle post activities.'));
|
||||||
return;
|
return;
|
||||||
|
@ -340,6 +342,22 @@ class ApiTimelineUserAction extends ApiBareAuthAction
|
||||||
return;
|
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
|
// Use summary as fallback for content
|
||||||
|
|
||||||
if (!empty($note->content)) {
|
if (!empty($note->content)) {
|
||||||
|
@ -458,11 +476,7 @@ class ApiTimelineUserAction extends ApiBareAuthAction
|
||||||
'atompub', // TODO: deal with this
|
'atompub', // TODO: deal with this
|
||||||
$options);
|
$options);
|
||||||
|
|
||||||
if (!empty($saved)) {
|
return $saved;
|
||||||
header("Location: " . common_local_url('ApiStatusesShow', array('notice_id' => $saved->id,
|
|
||||||
'format' => 'atom')));
|
|
||||||
$this->showSingleAtomStatus($saved);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function purify($content)
|
function purify($content)
|
||||||
|
|
Loading…
Reference in New Issue