better handling of api comments/replies
This commit is contained in:
parent
0c9f033505
commit
b0a9ec0a73
2 changed files with 29 additions and 6 deletions
|
@ -401,8 +401,16 @@
|
||||||
|
|
||||||
// convert $_POST array items to the form we use for web posts.
|
// convert $_POST array items to the form we use for web posts.
|
||||||
|
|
||||||
|
// logger('api_post: ' . print_r($_POST,true));
|
||||||
|
|
||||||
$_POST['body'] = urldecode(requestdata('status'));
|
$_POST['body'] = urldecode(requestdata('status'));
|
||||||
$_POST['parent'] = requestdata('in_reply_to_status_id');
|
|
||||||
|
$parent = requestdata('in_reply_to_status_id');
|
||||||
|
if(ctype_digit($parent))
|
||||||
|
$_POST['parent'] = $parent;
|
||||||
|
else
|
||||||
|
$_POST['parent_uri'] = $parent;
|
||||||
|
|
||||||
if(requestdata('lat') && requestdata('long'))
|
if(requestdata('lat') && requestdata('long'))
|
||||||
$_POST['coord'] = sprintf("%s %s",requestdata('lat'),requestdata('long'));
|
$_POST['coord'] = sprintf("%s %s",requestdata('lat'),requestdata('long'));
|
||||||
$_POST['profile_uid'] = local_user();
|
$_POST['profile_uid'] = local_user();
|
||||||
|
|
25
mod/item.php
25
mod/item.php
|
@ -34,21 +34,34 @@ function item_post(&$a) {
|
||||||
call_hooks('post_local_start', $_POST);
|
call_hooks('post_local_start', $_POST);
|
||||||
|
|
||||||
$parent = ((x($_POST,'parent')) ? intval($_POST['parent']) : 0);
|
$parent = ((x($_POST,'parent')) ? intval($_POST['parent']) : 0);
|
||||||
|
$parent_uri = ((x($_POST,'parent_uri')) ? trim($_POST['parent_uri']) : '');
|
||||||
|
|
||||||
$parent_item = null;
|
$parent_item = null;
|
||||||
$parent_contact = null;
|
$parent_contact = null;
|
||||||
|
$r = false;
|
||||||
|
|
||||||
if($parent) {
|
if($parent || $parent_uri) {
|
||||||
$r = q("SELECT * FROM `item` WHERE `id` = %d LIMIT 1",
|
if($parent) {
|
||||||
intval($parent)
|
$r = q("SELECT * FROM `item` WHERE `id` = %d LIMIT 1",
|
||||||
);
|
intval($parent)
|
||||||
if(! count($r)) {
|
);
|
||||||
|
}
|
||||||
|
elseif($parent_uri && local_user()) {
|
||||||
|
// This is coming from an API source, we are logged in
|
||||||
|
$r = q("SELECT * FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
|
||||||
|
dbesc($parent_uri),
|
||||||
|
intval(local_user())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(($r === false) || (! count($r))) {
|
||||||
notice( t('Unable to locate original post.') . EOL);
|
notice( t('Unable to locate original post.') . EOL);
|
||||||
if(x($_POST,'return'))
|
if(x($_POST,'return'))
|
||||||
goaway($a->get_baseurl() . "/" . $_POST['return'] );
|
goaway($a->get_baseurl() . "/" . $_POST['return'] );
|
||||||
killme();
|
killme();
|
||||||
}
|
}
|
||||||
$parent_item = $r[0];
|
$parent_item = $r[0];
|
||||||
|
$parent = $r[0]['id'];
|
||||||
if($parent_item['contact-id'] && $uid) {
|
if($parent_item['contact-id'] && $uid) {
|
||||||
$r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
|
$r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
|
||||||
intval($parent_item['contact-id']),
|
intval($parent_item['contact-id']),
|
||||||
|
@ -59,6 +72,8 @@ function item_post(&$a) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($parent) logger('mod_post: parent=' . $parent);
|
||||||
|
|
||||||
$profile_uid = ((x($_POST,'profile_uid')) ? intval($_POST['profile_uid']) : 0);
|
$profile_uid = ((x($_POST,'profile_uid')) ? intval($_POST['profile_uid']) : 0);
|
||||||
$post_id = ((x($_POST['post_id'])) ? intval($_POST['post_id']) : 0);
|
$post_id = ((x($_POST['post_id'])) ? intval($_POST['post_id']) : 0);
|
||||||
$app = ((x($_POST['source'])) ? strip_tags($_POST['source']) : '');
|
$app = ((x($_POST['source'])) ? strip_tags($_POST['source']) : '');
|
||||||
|
|
Loading…
Reference in a new issue