Include per-group count of unseen items in /ping output

See #1718
Unfinished work
This commit is contained in:
Sandro Santilli 2015-11-08 15:33:12 +01:00
parent e74916d395
commit ba158dfeb1

View file

@ -33,6 +33,7 @@ function ping_init(&$a) {
$home = 0; $home = 0;
$network = 0; $network = 0;
$network_group = array();
$r = q("SELECT `item`.`id`,`item`.`parent`, `item`.`verb`, `item`.`wall`, `item`.`author-name`, $r = q("SELECT `item`.`id`,`item`.`parent`, `item`.`verb`, `item`.`wall`, `item`.`author-name`,
`item`.`contact-id`, `item`.`author-link`, `item`.`author-avatar`, `item`.`created`, `item`.`object`, `item`.`contact-id`, `item`.`author-link`, `item`.`author-avatar`, `item`.`created`, `item`.`object`,
@ -84,6 +85,25 @@ function ping_init(&$a) {
} }
} }
if ( $network )
{
# Find out how unseen network posts are spread across groups
$sql = "SELECT g.id, g.name, count(i.id) gm
FROM `group` g, group_member gm, item i
WHERE g.uid = %d
AND i.uid = %d
AND i.unseen AND i.visible
AND NOT i.deleted
AND i.`contact-id` = gm.`contact-id`
AND gm.gid = g.id GROUP BY g.id";
#echo '<SQL id="' . intval(local_user()) . '">' . $sql . '</SQL>';
$r = q(sql, intval(local_user()), intval(local_user()));
#echo $r;
foreach ($r as $it) {
$network_group[] = $it;
}
}
$intros1 = q("SELECT `intro`.`id`, `intro`.`datetime`, $intros1 = q("SELECT `intro`.`id`, `intro`.`datetime`,
`fcontact`.`name`, `fcontact`.`url`, `fcontact`.`photo` `fcontact`.`name`, `fcontact`.`url`, `fcontact`.`photo`
FROM `intro` LEFT JOIN `fcontact` ON `intro`.`fid` = `fcontact`.`id` FROM `intro` LEFT JOIN `fcontact` ON `intro`.`fid` = `fcontact`.`id`
@ -202,6 +222,13 @@ function ping_init(&$a) {
<net>$network</net> <net>$network</net>
<home>$home</home>\r\n"; <home>$home</home>\r\n";
if ($register!=0) echo "<register>$register</register>"; if ($register!=0) echo "<register>$register</register>";
if ( count($network_group) ) {
echo '<groups uid="' . intval(local_user()) . '">';
foreach ($network_group as $it) {
echo '<group id="' . $it['id'] . '">' . $it['count'] . "</group>";
}
echo "</groups>";
}
echo "<all-events>$all_events</all-events> echo "<all-events>$all_events</all-events>
<all-events-today>$all_events_today</all-events-today> <all-events-today>$all_events_today</all-events-today>