forked from GNUsocial/gnu-social
Switching variable access in ApiTimelineUser to GNUsocial improvements
This commit is contained in:
parent
3013b84e98
commit
216a04df86
@ -34,9 +34,7 @@
|
|||||||
* @link http://status.net/
|
* @link http://status.net/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('STATUSNET')) {
|
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the most recent notices (default 20) posted by the authenticating
|
* Returns the most recent notices (default 20) posted by the authenticating
|
||||||
@ -115,11 +113,11 @@ class ApiTimelineUserAction extends ApiBareAuthAction
|
|||||||
{
|
{
|
||||||
// We'll use the shared params from the Atom stub
|
// We'll use the shared params from the Atom stub
|
||||||
// for other feed types.
|
// for other feed types.
|
||||||
$atom = new AtomUserNoticeFeed($this->target->getUser(), $this->auth_user);
|
$atom = new AtomUserNoticeFeed($this->target->getUser(), $this->scoped);
|
||||||
|
|
||||||
$link = common_local_url(
|
$link = common_local_url(
|
||||||
'showstream',
|
'showstream',
|
||||||
array('nickname' => $this->target->nickname)
|
array('nickname' => $this->target->getNickname())
|
||||||
);
|
);
|
||||||
|
|
||||||
$self = $this->getSelfUri();
|
$self = $this->getSelfUri();
|
||||||
@ -127,7 +125,7 @@ class ApiTimelineUserAction extends ApiBareAuthAction
|
|||||||
// FriendFeed's SUP protocol
|
// FriendFeed's SUP protocol
|
||||||
// Also added RSS and Atom feeds
|
// Also added RSS and Atom feeds
|
||||||
|
|
||||||
$suplink = common_local_url('sup', null, null, $this->target->id);
|
$suplink = common_local_url('sup', null, null, $this->target->getID());
|
||||||
header('X-SUP-ID: ' . $suplink);
|
header('X-SUP-ID: ' . $suplink);
|
||||||
|
|
||||||
|
|
||||||
@ -135,7 +133,7 @@ class ApiTimelineUserAction extends ApiBareAuthAction
|
|||||||
$nextUrl = !empty($this->next_id)
|
$nextUrl = !empty($this->next_id)
|
||||||
? common_local_url('ApiTimelineUser',
|
? common_local_url('ApiTimelineUser',
|
||||||
array('format' => $this->format,
|
array('format' => $this->format,
|
||||||
'id' => $this->target->id),
|
'id' => $this->target->getID()),
|
||||||
array('max_id' => $this->next_id))
|
array('max_id' => $this->next_id))
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
@ -147,11 +145,11 @@ class ApiTimelineUserAction extends ApiBareAuthAction
|
|||||||
|
|
||||||
$prevUrl = common_local_url('ApiTimelineUser',
|
$prevUrl = common_local_url('ApiTimelineUser',
|
||||||
array('format' => $this->format,
|
array('format' => $this->format,
|
||||||
'id' => $this->target->id),
|
'id' => $this->target->getID()),
|
||||||
$prevExtra);
|
$prevExtra);
|
||||||
$firstUrl = common_local_url('ApiTimelineUser',
|
$firstUrl = common_local_url('ApiTimelineUser',
|
||||||
array('format' => $this->format,
|
array('format' => $this->format,
|
||||||
'id' => $this->target->id));
|
'id' => $this->target->getID()));
|
||||||
|
|
||||||
switch($this->format) {
|
switch($this->format) {
|
||||||
case 'xml':
|
case 'xml':
|
||||||
@ -206,7 +204,7 @@ class ApiTimelineUserAction extends ApiBareAuthAction
|
|||||||
break;
|
break;
|
||||||
case 'as':
|
case 'as':
|
||||||
header('Content-Type: ' . ActivityStreamJSONDocument::CONTENT_TYPE);
|
header('Content-Type: ' . ActivityStreamJSONDocument::CONTENT_TYPE);
|
||||||
$doc = new ActivityStreamJSONDocument($this->auth_user);
|
$doc = new ActivityStreamJSONDocument($this->scoped);
|
||||||
$doc->setTitle($atom->title);
|
$doc->setTitle($atom->title);
|
||||||
$doc->addLink($link, 'alternate', 'text/html');
|
$doc->addLink($link, 'alternate', 'text/html');
|
||||||
$doc->addItemsFromNotices($this->notices);
|
$doc->addItemsFromNotices($this->notices);
|
||||||
@ -307,9 +305,9 @@ class ApiTimelineUserAction extends ApiBareAuthAction
|
|||||||
return '"' . implode(
|
return '"' . implode(
|
||||||
':',
|
':',
|
||||||
array($this->arg('action'),
|
array($this->arg('action'),
|
||||||
common_user_cache_hash($this->auth_user),
|
common_user_cache_hash($this->scoped),
|
||||||
common_language(),
|
common_language(),
|
||||||
$this->target->id,
|
$this->target->getID(),
|
||||||
strtotime($this->notices[0]->created),
|
strtotime($this->notices[0]->created),
|
||||||
strtotime($this->notices[$last]->created))
|
strtotime($this->notices[$last]->created))
|
||||||
)
|
)
|
||||||
@ -321,10 +319,10 @@ class ApiTimelineUserAction extends ApiBareAuthAction
|
|||||||
|
|
||||||
function handlePost()
|
function handlePost()
|
||||||
{
|
{
|
||||||
if (empty($this->auth_user) ||
|
if (empty($this->scoped) ||
|
||||||
$this->auth_user->id != $this->target->id) {
|
$this->target->sameAs($this->scoped)) {
|
||||||
// TRANS: Client error displayed trying to add a notice to another user's timeline.
|
// TRANS: Client error displayed trying to add a notice to another user's timeline.
|
||||||
$this->clientError(_('Only the user can add to their own timeline.'));
|
$this->clientError(_('Only the user can add to their own timeline.'), 403);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only handle posts for Atom
|
// Only handle posts for Atom
|
||||||
@ -412,7 +410,7 @@ class ApiTimelineUserAction extends ApiBareAuthAction
|
|||||||
$rendered = common_purify($sourceContent);
|
$rendered = common_purify($sourceContent);
|
||||||
$content = common_strip_html($rendered);
|
$content = common_strip_html($rendered);
|
||||||
|
|
||||||
$shortened = $this->auth_user->shortenLinks($content);
|
$shortened = $this->target->shortenLinks($content);
|
||||||
|
|
||||||
$options = array('is_local' => Notice::LOCAL_PUBLIC,
|
$options = array('is_local' => Notice::LOCAL_PUBLIC,
|
||||||
'rendered' => $rendered,
|
'rendered' => $rendered,
|
||||||
@ -501,7 +499,7 @@ class ApiTimelineUserAction extends ApiBareAuthAction
|
|||||||
$options['urls'][] = $href;
|
$options['urls'][] = $href;
|
||||||
}
|
}
|
||||||
|
|
||||||
$saved = Notice::saveNew($this->target->id,
|
$saved = Notice::saveNew($this->target->getID(),
|
||||||
$content,
|
$content,
|
||||||
'atompub', // TODO: deal with this
|
'atompub', // TODO: deal with this
|
||||||
$options);
|
$options);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user