preserve event item[uri] if present
This commit is contained in:
parent
45be26dd81
commit
127b605f32
@ -802,6 +802,14 @@ require_once('include/security.php');
|
|||||||
if ($exclude_replies > 0)
|
if ($exclude_replies > 0)
|
||||||
$sql_extra .= ' AND `item`.`parent` = `item`.`id`';
|
$sql_extra .= ' AND `item`.`parent` = `item`.`id`';
|
||||||
|
|
||||||
|
if (api_user() != $user_info['uid']) {
|
||||||
|
$observer = get_app()->get_observer();
|
||||||
|
require_once('include/permissions.php');
|
||||||
|
if(! perm_is_allowed($user_info['uid'],(($observer) ? $observer['xchan_hash'] : ''),'view_stream'))
|
||||||
|
return '';
|
||||||
|
$sql_extra .= " and item_private = 0 ";
|
||||||
|
}
|
||||||
|
|
||||||
$r = q("SELECT * from item WHERE uid = %d and item_restrict = 0
|
$r = q("SELECT * from item WHERE uid = %d and item_restrict = 0
|
||||||
$sql_extra
|
$sql_extra
|
||||||
AND id > %d
|
AND id > %d
|
||||||
@ -820,12 +828,14 @@ require_once('include/security.php');
|
|||||||
// level which items you've seen and which you haven't. If you're looking
|
// level which items you've seen and which you haven't. If you're looking
|
||||||
// at the network timeline just mark everything seen.
|
// at the network timeline just mark everything seen.
|
||||||
|
|
||||||
$r = q("UPDATE `item` SET item_flags = ( item_flags ^ %d )
|
if (api_user() == $user_info['uid']) {
|
||||||
WHERE item_flags & %d and uid = %d",
|
$r = q("UPDATE `item` SET item_flags = ( item_flags ^ %d )
|
||||||
intval(ITEM_UNSEEN),
|
WHERE item_flags & %d and uid = %d",
|
||||||
intval(ITEM_UNSEEN),
|
intval(ITEM_UNSEEN),
|
||||||
intval($user_info['uid'])
|
intval(ITEM_UNSEEN),
|
||||||
);
|
intval($user_info['uid'])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$data = array('$statuses' => $ret);
|
$data = array('$statuses' => $ret);
|
||||||
@ -966,7 +976,7 @@ require_once('include/security.php');
|
|||||||
logger('API: api_statuses_repeat: '.$id);
|
logger('API: api_statuses_repeat: '.$id);
|
||||||
|
|
||||||
//$include_entities = (x($_REQUEST,'include_entities')?$_REQUEST['include_entities']:false);
|
//$include_entities = (x($_REQUEST,'include_entities')?$_REQUEST['include_entities']:false);
|
||||||
|
// FIXME
|
||||||
$r = q("SELECT `item`.*, `item`.`id` AS `item_id`, `contact`.`nick` as `reply_author`,
|
$r = q("SELECT `item`.*, `item`.`id` AS `item_id`, `contact`.`nick` as `reply_author`,
|
||||||
`contact`.`name`, `contact`.`photo`, `contact`.`url` as `reply_url`, `contact`.`rel`,
|
`contact`.`name`, `contact`.`photo`, `contact`.`url` as `reply_url`, `contact`.`rel`,
|
||||||
`contact`.`network`, `contact`.`thumb`, `contact`.`dfrn_id`, `contact`.`self`,
|
`contact`.`network`, `contact`.`thumb`, `contact`.`dfrn_id`, `contact`.`self`,
|
||||||
@ -1008,7 +1018,7 @@ require_once('include/security.php');
|
|||||||
$user_info = api_get_user($a);
|
$user_info = api_get_user($a);
|
||||||
|
|
||||||
// params
|
// params
|
||||||
$id = intval($a->argv[3]);
|
$id = intval(argv(3));
|
||||||
|
|
||||||
logger('API: api_statuses_destroy: '.$id);
|
logger('API: api_statuses_destroy: '.$id);
|
||||||
|
|
||||||
@ -1029,6 +1039,8 @@ require_once('include/security.php');
|
|||||||
* http://developer.twitter.com/doc/get/statuses/mentions
|
* http://developer.twitter.com/doc/get/statuses/mentions
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// FIXME
|
||||||
function api_statuses_mentions(&$a, $type){
|
function api_statuses_mentions(&$a, $type){
|
||||||
if (api_user()===false) return false;
|
if (api_user()===false) return false;
|
||||||
|
|
||||||
@ -1106,6 +1118,7 @@ require_once('include/security.php');
|
|||||||
return api_apply_template("timeline", $type, $data);
|
return api_apply_template("timeline", $type, $data);
|
||||||
}
|
}
|
||||||
api_register_func('api/statuses/mentions','api_statuses_mentions', true);
|
api_register_func('api/statuses/mentions','api_statuses_mentions', true);
|
||||||
|
// FIXME?? I don't think mentions and replies are congruent in this case
|
||||||
api_register_func('api/statuses/replies','api_statuses_mentions', true);
|
api_register_func('api/statuses/replies','api_statuses_mentions', true);
|
||||||
|
|
||||||
|
|
||||||
@ -1113,7 +1126,7 @@ require_once('include/security.php');
|
|||||||
if (api_user()===false) return false;
|
if (api_user()===false) return false;
|
||||||
|
|
||||||
$user_info = api_get_user($a);
|
$user_info = api_get_user($a);
|
||||||
// get last newtork messages
|
// get last network messages
|
||||||
|
|
||||||
|
|
||||||
logger("api_statuses_user_timeline: api_user: ". api_user() .
|
logger("api_statuses_user_timeline: api_user: ". api_user() .
|
||||||
|
@ -205,30 +205,36 @@ function event_store($arr) {
|
|||||||
|
|
||||||
$a = get_app();
|
$a = get_app();
|
||||||
|
|
||||||
$arr['created'] = (($arr['created']) ? $arr['created'] : datetime_convert());
|
$arr['created'] = (($arr['created']) ? $arr['created'] : datetime_convert());
|
||||||
$arr['edited'] = (($arr['edited']) ? $arr['edited'] : datetime_convert());
|
$arr['edited'] = (($arr['edited']) ? $arr['edited'] : datetime_convert());
|
||||||
$arr['type'] = (($arr['type']) ? $arr['type'] : 'event' );
|
$arr['type'] = (($arr['type']) ? $arr['type'] : 'event' );
|
||||||
$arr['event_xchan'] = (($arr['event_xchan']) ? $arr['event_xchan'] : '');
|
$arr['event_xchan'] = (($arr['event_xchan']) ? $arr['event_xchan'] : '');
|
||||||
|
|
||||||
// Existing event being modified
|
// Existing event being modified
|
||||||
|
|
||||||
if($arr['id']) {
|
if($arr['id'] || $arr['event_hash']) {
|
||||||
|
|
||||||
// has the event actually changed?
|
// has the event actually changed?
|
||||||
|
|
||||||
$r = q("SELECT * FROM `event` WHERE `id` = %d AND `uid` = %d LIMIT 1",
|
if($arr['event_hash']) {
|
||||||
intval($arr['id']),
|
$r = q("SELECT * FROM event WHERE event_hash = '%s' AND uid = %d LIMIT 1",
|
||||||
intval($arr['uid'])
|
dbesc($arr['event_hash']),
|
||||||
);
|
|
||||||
if((! $r) || ($r[0]['edited'] === $arr['edited'])) {
|
|
||||||
|
|
||||||
// Nothing has changed. Grab the item id to return.
|
|
||||||
|
|
||||||
$r = q("SELECT id FROM item WHERE resource_type = 'event' and resource_id = '%s' AND uid = %d LIMIT 1",
|
|
||||||
intval($arr['event_hash']),
|
|
||||||
intval($arr['uid'])
|
intval($arr['uid'])
|
||||||
);
|
);
|
||||||
return(($r) ? $r[0]['id'] : 0);
|
}
|
||||||
|
else {
|
||||||
|
$r = q("SELECT * FROM event WHERE id = %d AND uid = %d LIMIT 1",
|
||||||
|
intval($arr['id']),
|
||||||
|
intval($arr['uid'])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(! $r)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if($r[0]['edited'] === $arr['edited']) {
|
||||||
|
// Nothing has changed. Return the ID.
|
||||||
|
return $r[0]['id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
// The event changed. Update it.
|
// The event changed. Update it.
|
||||||
@ -262,12 +268,12 @@ function event_store($arr) {
|
|||||||
dbesc($arr['allow_gid']),
|
dbesc($arr['allow_gid']),
|
||||||
dbesc($arr['deny_cid']),
|
dbesc($arr['deny_cid']),
|
||||||
dbesc($arr['deny_gid']),
|
dbesc($arr['deny_gid']),
|
||||||
intval($arr['id']),
|
intval($r[0]['id']),
|
||||||
intval($arr['uid'])
|
intval($arr['uid'])
|
||||||
);
|
);
|
||||||
|
|
||||||
$r = q("SELECT * FROM item left join xchan on author_xchan = xchan_hash WHERE resource_id = '%s' AND resource_type = 'event' and uid = %d LIMIT 1",
|
$r = q("SELECT * FROM item left join xchan on author_xchan = xchan_hash WHERE resource_id = '%s' AND resource_type = 'event' and uid = %d LIMIT 1",
|
||||||
intval($arr['event_hash']),
|
intval($r[0]['event_hash']),
|
||||||
intval($arr['uid'])
|
intval($arr['uid'])
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -291,6 +297,7 @@ function event_store($arr) {
|
|||||||
|
|
||||||
$private = (($arr['allow_cid'] || $arr['allow_gid'] || $arr['deny_cid'] || $arr['deny_gid']) ? 1 : 0);
|
$private = (($arr['allow_cid'] || $arr['allow_gid'] || $arr['deny_cid'] || $arr['deny_gid']) ? 1 : 0);
|
||||||
|
|
||||||
|
|
||||||
q("UPDATE item SET title = '%s', body = '%s', object = '%s', allow_cid = '%s', allow_gid = '%s', deny_cid = '%s', deny_gid = '%s', edited = '%s', item_flags = %d, item_private = %d WHERE id = %d AND uid = %d LIMIT 1",
|
q("UPDATE item SET title = '%s', body = '%s', object = '%s', allow_cid = '%s', allow_gid = '%s', deny_cid = '%s', deny_gid = '%s', edited = '%s', item_flags = %d, item_private = %d WHERE id = %d AND uid = %d LIMIT 1",
|
||||||
dbesc($arr['summary']),
|
dbesc($arr['summary']),
|
||||||
dbesc(format_event_bbcode($arr)),
|
dbesc(format_event_bbcode($arr)),
|
||||||
@ -321,8 +328,12 @@ function event_store($arr) {
|
|||||||
|
|
||||||
$hash = random_string();
|
$hash = random_string();
|
||||||
|
|
||||||
$r = q("INSERT INTO `event` ( `uid`,`aid`,`event_xchan`,`event_hash`,`created`,`edited`,`start`,`finish`,`summary`, `desc`,`location`,`type`,
|
if(! $arr['uri'])
|
||||||
`adjust`,`nofinish`,`allow_cid`,`allow_gid`,`deny_cid`,`deny_gid`)
|
$arr['uri'] = item_message_id();
|
||||||
|
|
||||||
|
|
||||||
|
$r = q("INSERT INTO event ( uid,aid,event_xchan,event_hash,created,edited,start,finish,summary, desc,location,type,
|
||||||
|
adjust,nofinish,allow_cid,allow_gid,deny_cid,deny_gid)
|
||||||
VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', '%s', '%s', '%s' ) ",
|
VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', '%s', '%s', '%s' ) ",
|
||||||
intval($arr['uid']),
|
intval($arr['uid']),
|
||||||
intval($arr['account']),
|
intval($arr['account']),
|
||||||
@ -345,7 +356,7 @@ function event_store($arr) {
|
|||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
$r = q("SELECT * FROM `event` WHERE `event_hash` = '%s' AND `uid` = %d LIMIT 1",
|
$r = q("SELECT * FROM event WHERE event_hash = '%s' AND uid = %d LIMIT 1",
|
||||||
dbesc($hash),
|
dbesc($hash),
|
||||||
intval($arr['uid'])
|
intval($arr['uid'])
|
||||||
);
|
);
|
||||||
@ -365,17 +376,14 @@ function event_store($arr) {
|
|||||||
$item_flags |= ITEM_ORIGIN;
|
$item_flags |= ITEM_ORIGIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$uri = item_message_id();
|
|
||||||
|
|
||||||
$private = (($arr['allow_cid'] || $arr['allow_gid'] || $arr['deny_cid'] || $arr['deny_gid']) ? 1 : 0);
|
$private = (($arr['allow_cid'] || $arr['allow_gid'] || $arr['deny_cid'] || $arr['deny_gid']) ? 1 : 0);
|
||||||
|
|
||||||
$item_arr = array();
|
$item_arr = array();
|
||||||
|
|
||||||
$item_arr['uid'] = $arr['uid'];
|
$item_arr['uid'] = $arr['uid'];
|
||||||
$item_arr['author_xchan'] = $arr['event_xchan'];
|
$item_arr['author_xchan'] = $arr['event_xchan'];
|
||||||
$item_arr['uri'] = $uri;
|
$item_arr['uri'] = $arr['uri'];
|
||||||
$item_arr['parent_uri'] = $uri;
|
$item_arr['parent_uri'] = $arr['uri'];
|
||||||
|
|
||||||
$item_arr['item_flags'] = $item_flags;
|
$item_arr['item_flags'] = $item_flags;
|
||||||
|
|
||||||
@ -386,13 +394,13 @@ function event_store($arr) {
|
|||||||
$item_arr['allow_gid'] = $arr['allow_gid'];
|
$item_arr['allow_gid'] = $arr['allow_gid'];
|
||||||
$item_arr['deny_cid'] = $arr['deny_cid'];
|
$item_arr['deny_cid'] = $arr['deny_cid'];
|
||||||
$item_arr['deny_gid'] = $arr['deny_gid'];
|
$item_arr['deny_gid'] = $arr['deny_gid'];
|
||||||
$item_arr['private'] = (($arr['private'] || $private) ? 1 : 0);
|
$item_arr['item_private'] = $private;
|
||||||
$item_arr['verb'] = ACTIVITY_POST;
|
$item_arr['verb'] = ACTIVITY_POST;
|
||||||
|
|
||||||
$item_arr['resource_type'] = 'event';
|
$item_arr['resource_type'] = 'event';
|
||||||
$item_arr['resource_id'] = $hash;
|
$item_arr['resource_id'] = $hash;
|
||||||
|
|
||||||
$item_arr['obj_type'] = ACTIVITY_OBJ_EVENT;
|
$item_arr['obj_type'] = ACTIVITY_OBJ_EVENT;
|
||||||
$item_arr['body'] = format_event_bbcode($arr);
|
$item_arr['body'] = format_event_bbcode($arr);
|
||||||
|
|
||||||
$x = q("select * from xchan where xchan_hash = '%s' limit 1",
|
$x = q("select * from xchan where xchan_hash = '%s' limit 1",
|
||||||
|
@ -205,7 +205,7 @@ function html2plain($html, $wraplength = 75, $compact = false)
|
|||||||
if (!$compact) {
|
if (!$compact) {
|
||||||
$counter = 1;
|
$counter = 1;
|
||||||
foreach ($urls as $id=>$url)
|
foreach ($urls as $id=>$url)
|
||||||
if (strpos($message, $url) == false)
|
if ($url && strpos($message, $url) === false)
|
||||||
$message .= "\n".$url." ";
|
$message .= "\n".$url." ";
|
||||||
//$message .= "\n[".($counter++)."] ".$url;
|
//$message .= "\n[".($counter++)."] ".$url;
|
||||||
}
|
}
|
||||||
|
@ -901,16 +901,18 @@ function process_delivery($sender,$arr,$deliveries,$relay) {
|
|||||||
$ev['uid'] = $channel['channel_id'];
|
$ev['uid'] = $channel['channel_id'];
|
||||||
$ev['account'] = $channel['channel_account_id'];
|
$ev['account'] = $channel['channel_account_id'];
|
||||||
$ev['edited'] = $arr['edited'];
|
$ev['edited'] = $arr['edited'];
|
||||||
|
$ev['uri'] = $arr['uri'];
|
||||||
|
$ev['private'] = $arr['item_private'];
|
||||||
|
|
||||||
// is this an edit?
|
// is this an edit?
|
||||||
|
|
||||||
$r = q("SELECT * FROM event left join item on resource_id = event_hash WHERE resource_type = 'event' and
|
$r = q("SELECT resource_id FROM item where uri = '%s' and uid = %d and resource_type = 'event' limit 1",
|
||||||
`uri` = '%s' AND event.uid = %d LIMIT 1",
|
|
||||||
dbesc($arr['uri']),
|
dbesc($arr['uri']),
|
||||||
intval($channel['channel_id'])
|
intval($channel['channel_id'])
|
||||||
);
|
);
|
||||||
if($r)
|
if($r) {
|
||||||
$ev['event_hash'] = $r[0]['event_hash'];
|
$ev['event_hash'] = $r[0]['resource_id'];
|
||||||
|
}
|
||||||
dbg(1);
|
dbg(1);
|
||||||
$xyz = event_store($ev);
|
$xyz = event_store($ev);
|
||||||
dbg(0);
|
dbg(0);
|
||||||
|
@ -1 +1 @@
|
|||||||
2013-01-19.205
|
2013-01-20.206
|
||||||
|
Reference in New Issue
Block a user