forked from GNUsocial/gnu-social
Twitter-compatible API: support for new in_reply_to_status_id in statuses/update
darcs-hash:20080815185317-ca946-11c3f9f7255180d5d6ea7b115b3e33b2abb7fe93.gz
This commit is contained in:
parent
a95242bd1d
commit
35d1714621
@ -375,9 +375,9 @@ class TwitapistatusesAction extends TwitterapiAction {
|
|||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
|
|
||||||
$user = $apidata['user'];
|
$user = $apidata['user'];
|
||||||
|
|
||||||
$status = $this->trimmed('status');
|
$status = $this->trimmed('status');
|
||||||
$source = $this->trimmed('source');
|
$source = $this->trimmed('source');
|
||||||
|
$in_reply_to_status_id = intval($this->trimmed('in_reply_to_status_id'));
|
||||||
|
|
||||||
if (!$source) {
|
if (!$source) {
|
||||||
$source = 'api';
|
$source = 'api';
|
||||||
@ -397,16 +397,30 @@ class TwitapistatusesAction extends TwitterapiAction {
|
|||||||
// as "truncated." Sending this error may screw up some clients
|
// as "truncated." Sending this error may screw up some clients
|
||||||
// that assume Twitter will truncate for them. Should we just
|
// that assume Twitter will truncate for them. Should we just
|
||||||
// truncate too? -- Zach
|
// truncate too? -- Zach
|
||||||
header('HTTP/1.1 406 Not Acceptable');
|
$this->client_error('That\'s too long. Max notice size is 140 chars.', $code = 406, $apidata['content-type']);
|
||||||
print "That's too long. Max notice size is 140 chars.\n";
|
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
$notice = Notice::saveNew($user->id, $status, $source);
|
$reply_to = NULL;
|
||||||
|
|
||||||
|
if ($in_reply_to_status_id) {
|
||||||
|
|
||||||
|
// check whether notice actually exists
|
||||||
|
$reply = Notice::staticGet($in_reply_to_status_id);
|
||||||
|
|
||||||
|
if ($reply) {
|
||||||
|
$reply_to = $in_reply_to_status_id;
|
||||||
|
} else {
|
||||||
|
$this->client_error('Not found', $code = 404, $apidata['content-type']);
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$notice = Notice::saveNew($user->id, $status, $source, 1, $reply_to);
|
||||||
|
|
||||||
if (is_string($notice)) {
|
if (is_string($notice)) {
|
||||||
$this->server_error($notice);
|
$this->server_error($notice);
|
||||||
return;
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
common_broadcast_notice($notice);
|
common_broadcast_notice($notice);
|
||||||
|
@ -76,11 +76,12 @@ class Notice extends DB_DataObject
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function saveNew($profile_id, $content, $source=NULL, $is_local=1) {
|
static function saveNew($profile_id, $content, $source=NULL, $is_local=1, $reply_to=NULL) {
|
||||||
|
|
||||||
$notice = new Notice();
|
$notice = new Notice();
|
||||||
$notice->profile_id = $profile_id;
|
$notice->profile_id = $profile_id;
|
||||||
$notice->is_local = $is_local;
|
$notice->is_local = $is_local;
|
||||||
|
$notice->reply_to = $reply_to;
|
||||||
$notice->created = DB_DataObject_Cast::dateTime();
|
$notice->created = DB_DataObject_Cast::dateTime();
|
||||||
$notice->content = $content;
|
$notice->content = $content;
|
||||||
$notice->rendered = common_render_content($notice->content, $notice);
|
$notice->rendered = common_render_content($notice->content, $notice);
|
||||||
|
@ -158,13 +158,15 @@ class TwitterapiAction extends Action {
|
|||||||
$notice = Notice::staticGet($id);
|
$notice = Notice::staticGet($id);
|
||||||
|
|
||||||
if ($notice) {
|
if ($notice) {
|
||||||
|
|
||||||
if ($apidata['content-type'] == 'xml') {
|
if ($apidata['content-type'] == 'xml') {
|
||||||
$this->show_single_xml_status($notice);
|
$this->show_single_xml_status($notice);
|
||||||
} elseif ($apidata['content-type'] == 'json') {
|
} elseif ($apidata['content-type'] == 'json') {
|
||||||
$this->show_single_json_status($notice);
|
$this->show_single_json_status($notice);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
// XXX: This is all that Twitter does. It doesn't show an XML or JSON error msg.
|
||||||
|
// Should we call client_error() to be more consistent?
|
||||||
header('HTTP/1.1 404 Not Found');
|
header('HTTP/1.1 404 Not Found');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user