From 2285b3b7a7f3e6812118ca58740758d13eb20dba Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Tue, 14 Apr 2015 06:54:41 +0200 Subject: [PATCH] Storing the parent with every notification --- include/enotify.php | 7 ++++++- include/items.php | 5 +++-- mod/ping.php | 8 ++++---- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/include/enotify.php b/include/enotify.php index 4327e75b83..4316188506 100644 --- a/include/enotify.php +++ b/include/enotify.php @@ -63,6 +63,11 @@ function notification($params) { // e.g. "your post", "David's photo", etc. $possess_desc = t('%s '); + if (isset($params['parent'])) + $parent_id = $params['parent']; + else + $parent_id = 0; + if($params['type'] == NOTIFY_MAIL) { $subject = sprintf( t('[Friendica:Notify] New mail received at %s'),$sitename); @@ -78,7 +83,7 @@ function notification($params) { if($params['type'] == NOTIFY_COMMENT) { // logger("notification: params = " . print_r($params, true), LOGGER_DEBUG); - $parent_id = $params['parent']; + //$parent_id = $params['parent']; $p = q("SELECT `ignored` FROM `thread` WHERE `iid` = %d AND `uid` = %d LIMIT 1", intval($parent_id), diff --git a/include/items.php b/include/items.php index 8a0deb437b..1fecc44215 100644 --- a/include/items.php +++ b/include/items.php @@ -1567,7 +1567,8 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa 'source_link' => $item[0]['author-link'], 'source_photo' => $item[0]['author-avatar'], 'verb' => ACTIVITY_TAG, - 'otype' => 'item' + 'otype' => 'item', + 'parent' => $arr['parent'] )); logger('item_store: Notification sent for contact '.$arr['contact-id'].' and post '.$current_post, LOGGER_DEBUG); } @@ -4021,7 +4022,7 @@ function local_delivery($importer,$data) { 'verb' => $datarray['verb'], 'otype' => 'person', 'activity' => $verb, - + 'parent' => $datarray['parent'] )); } } diff --git a/mod/ping.php b/mod/ping.php index 405edd3c49..6207663391 100644 --- a/mod/ping.php +++ b/mod/ping.php @@ -22,23 +22,23 @@ function ping_init(&$a) { $firehose = intval(get_pconfig(local_user(),'system','notify_full')); - $t = q("select count(*) as total from notify where uid = %d and seen = 0", + $t = q("select count(*) as `total` from `notify` where `uid` = %d and `seen` = 0 AND `msg` != ''", intval(local_user()) ); if($t && intval($t[0]['total']) > 49) { - $z = q("select * from notify where uid = %d + $z = q("select * from notify where uid = %d AND `msg` != '' and seen = 0 order by date desc limit 0, 50", intval(local_user()) ); $sysnotify = $t[0]['total']; } else { - $z1 = q("select * from notify where uid = %d + $z1 = q("select * from notify where uid = %d AND `msg` != '' and seen = 0 order by date desc limit 0, 50", intval(local_user()) ); - $z2 = q("select * from notify where uid = %d + $z2 = q("select * from notify where uid = %d AND `msg` != '' and seen = 1 order by date desc limit 0, %d", intval(local_user()), intval(50 - intval($t[0]['total'])) -- 2.39.5