aboutsummaryrefslogtreecommitdiffstats
path: root/mod
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2012-12-02 15:45:13 -0800
committerfriendica <info@friendica.com>2012-12-02 15:45:13 -0800
commit4cca8f8fa1e0425e0865f4a21d9daec29cc4cb2c (patch)
tree936416be1e0516b2bf26c0a8352589f9eedae1a3 /mod
parent7f1a4a3060036dc909e00c180d5e27c7bcf2d3da (diff)
downloadvolse-hubzilla-4cca8f8fa1e0425e0865f4a21d9daec29cc4cb2c.tar.gz
volse-hubzilla-4cca8f8fa1e0425e0865f4a21d9daec29cc4cb2c.tar.bz2
volse-hubzilla-4cca8f8fa1e0425e0865f4a21d9daec29cc4cb2c.zip
connection notifications
Diffstat (limited to 'mod')
-rw-r--r--mod/ping.php34
1 files changed, 32 insertions, 2 deletions
diff --git a/mod/ping.php b/mod/ping.php
index cdc18a303..9650f2aec 100644
--- a/mod/ping.php
+++ b/mod/ping.php
@@ -93,14 +93,14 @@ function ping_init(&$a) {
if(argc() > 1 && (argv(1) === 'network' || argv(1) === 'home')) {
$result = array();
-dbg(1);
+
$r = q("SELECT * FROM item
WHERE item_restrict = %d and ( item_flags & %d ) and uid = %d",
intval(ITEM_VISIBLE),
intval(ITEM_UNSEEN),
intval(local_user())
);
-dbg(0);
+
if($r) {
xchan_query($r);
foreach($r as $item) {
@@ -115,6 +115,36 @@ dbg(0);
}
+ if(argc() > 1 && (argv(1) === 'connect')) {
+
+ $result = array();
+
+ $r = q("SELECT abook.*, xchan.* FROM abook left join xchan on abook_xchan = xchan_hash
+ WHERE abook_channel = %d and (abook_flags & %d) and not (abook_flags & %d)",
+ intval(local_user()),
+ intval(ABOOK_FLAG_PENDING),
+ intval(ABOOK_FLAG_SELF)
+ );
+
+ if($r) {
+ foreach($r as $rr) {
+ $result[] = array(
+ 'notify_link' => $a->get_baseurl() . '/notify/view-intro/' . $rr['abook_id'],
+ 'name' => $rr['xchan_name'],
+ 'url' => $rr['xchan_url'],
+ 'photo' => $rr['xchan_photo_s'],
+ 'when' => relative_date($rr['abook_created']),
+ 'class' => ('notify-unseen'),
+ 'message' => strip_tags(sprintf( t("Connection request from %s"), $rr['xchan_name']))
+ );
+ }
+ }
+ logger('ping: ' . print_r($result,true));
+ echo json_encode(array( argv(1) => $result));
+ killme();
+
+ }
+
// Normal ping - just the counts