Some documentation in mod/ping.php an reduced default logging.
It is now LOGGER_DATA as it returns the json data contents.
This commit is contained in:
parent
6bd9492e77
commit
13098ba8d8
48
mod/ping.php
48
mod/ping.php
@ -1,9 +1,21 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file mod/ping.php
|
||||
*
|
||||
*/
|
||||
|
||||
require_once('include/bbcode.php');
|
||||
require_once('include/notify.php');
|
||||
|
||||
/**
|
||||
* @brief do several updates when pinged.
|
||||
*
|
||||
* This function does several tasks. Whenever called it checks for new messages,
|
||||
* introductions, notifications, etc. and returns a json with the results.
|
||||
*
|
||||
* @param App &$a
|
||||
* @result JSON
|
||||
*/
|
||||
function ping_init(&$a) {
|
||||
|
||||
$result = array();
|
||||
@ -48,7 +60,6 @@ function ping_init(&$a) {
|
||||
killme();
|
||||
}
|
||||
|
||||
|
||||
if(get_observer_hash() && (! $result['invalid'])) {
|
||||
$r = q("select cp_id, cp_room from chatpresence where cp_xchan = '%s' and cp_client = '%s' and cp_room = 0 limit 1",
|
||||
dbesc(get_observer_hash()),
|
||||
@ -80,8 +91,8 @@ function ping_init(&$a) {
|
||||
killme();
|
||||
}
|
||||
|
||||
// mark all items read
|
||||
if(x($_REQUEST, 'markRead') && local_user()) {
|
||||
|
||||
switch($_REQUEST['markRead']) {
|
||||
case 'network':
|
||||
$r = q("update item set item_flags = ( item_flags ^ %d ) where (item_flags & %d) and uid = %d",
|
||||
@ -90,7 +101,6 @@ function ping_init(&$a) {
|
||||
intval(local_user())
|
||||
);
|
||||
break;
|
||||
|
||||
case 'home':
|
||||
$r = q("update item set item_flags = ( item_flags ^ %d ) where (item_flags & %d) and (item_flags & %d) and uid = %d",
|
||||
intval(ITEM_UNSEEN),
|
||||
@ -111,19 +121,16 @@ function ping_init(&$a) {
|
||||
intval(local_user())
|
||||
);
|
||||
break;
|
||||
|
||||
case 'notify':
|
||||
$r = q("update notify set seen = 1 where uid = %d",
|
||||
intval(local_user())
|
||||
);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(argc() > 1 && argv(1) === 'notify') {
|
||||
$t = q("select count(*) as total from notify where uid = %d and seen = 0",
|
||||
intval(local_user())
|
||||
@ -163,12 +170,9 @@ function ping_init(&$a) {
|
||||
|
||||
echo json_encode(array('notify' => $notifs));
|
||||
killme();
|
||||
|
||||
}
|
||||
|
||||
|
||||
if(argc() > 1 && argv(1) === 'messages') {
|
||||
|
||||
$channel = $a->get_channel();
|
||||
$t = q("select mail.*, xchan.* from mail left join xchan on xchan_hash = from_xchan
|
||||
where channel_id = %d and not ( mail_flags & %d ) and not (mail_flags & %d )
|
||||
@ -196,14 +200,9 @@ function ping_init(&$a) {
|
||||
|
||||
echo json_encode(array('notify' => $notifs));
|
||||
killme();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if(argc() > 1 && (argv(1) === 'network' || argv(1) === 'home')) {
|
||||
|
||||
$result = array();
|
||||
|
||||
$r = q("SELECT * FROM item
|
||||
@ -221,14 +220,12 @@ function ping_init(&$a) {
|
||||
$result[] = format_notification($item);
|
||||
}
|
||||
}
|
||||
logger('ping: ' . print_r($result,true));
|
||||
logger('ping (network||home): ' . print_r($result, true), LOGGER_DATA);
|
||||
echo json_encode(array('notify' => $result));
|
||||
killme();
|
||||
|
||||
}
|
||||
|
||||
if(argc() > 1 && (argv(1) === 'intros')) {
|
||||
|
||||
$result = array();
|
||||
|
||||
$r = q("SELECT abook.*, xchan.* FROM abook left join xchan on abook_xchan = xchan_hash
|
||||
@ -251,14 +248,12 @@ function ping_init(&$a) {
|
||||
);
|
||||
}
|
||||
}
|
||||
logger('ping: ' . print_r($result,true));
|
||||
logger('ping (intros): ' . print_r($result, true), LOGGER_DATA);
|
||||
echo json_encode(array('notify' => $result));
|
||||
killme();
|
||||
|
||||
}
|
||||
|
||||
if(argc() > 1 && (argv(1) === 'all_events')) {
|
||||
|
||||
$bd_format = t('g A l F d') ; // 8 AM Friday January 18
|
||||
|
||||
$result = array();
|
||||
@ -283,7 +278,6 @@ function ping_init(&$a) {
|
||||
|
||||
$when = day_translate(datetime_convert('UTC', $rr['adjust'] ? date_default_timezone_get() : 'UTC', $rr['start'], $bd_format)) . (($today) ? ' ' . t('[today]') : '');
|
||||
|
||||
|
||||
$result[] = array(
|
||||
'notify_link' => $a->get_baseurl() . '/events', // FIXME this takes you to an edit page and it may not be yours, we really want to just view the single event --> '/events/event/' . $rr['event_hash'],
|
||||
'name' => $rr['xchan_name'],
|
||||
@ -295,22 +289,18 @@ function ping_init(&$a) {
|
||||
);
|
||||
}
|
||||
}
|
||||
logger('ping: ' . print_r($result,true));
|
||||
logger('ping (all_events): ' . print_r($result, true), LOGGER_DATA);
|
||||
echo json_encode(array('notify' => $result));
|
||||
killme();
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Normal ping - just the counts
|
||||
|
||||
$t = q("select count(*) as total from notify where uid = %d and seen = 0",
|
||||
intval(local_user())
|
||||
);
|
||||
if($t)
|
||||
$result['notify'] = intval($t[0]['total']);
|
||||
|
||||
|
||||
$t1 = dba_timer();
|
||||
|
||||
$r = q("SELECT id, item_restrict, item_flags FROM item
|
||||
@ -321,7 +311,6 @@ function ping_init(&$a) {
|
||||
);
|
||||
|
||||
if(count($r)) {
|
||||
|
||||
$arr = array('items' => $r);
|
||||
call_hooks('network_ping', $arr);
|
||||
|
||||
@ -333,7 +322,6 @@ function ping_init(&$a) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$t2 = dba_timer();
|
||||
|
||||
$intr = q("select count(abook_id) as total from abook where (abook_flags & %d) and abook_channel = %d",
|
||||
@ -409,6 +397,4 @@ function ping_init(&$a) {
|
||||
|
||||
echo $x;
|
||||
killme();
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user