From f4a4cf140268db48fa5fb49d10e7149b3fb7c4cf Mon Sep 17 00:00:00 2001 From: redmatrix Date: Sat, 19 Sep 2015 15:36:07 -0700 Subject: clone new connection requests --- include/zot.php | 37 +++++++++++++++++++------------------ version.inc | 2 +- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/include/zot.php b/include/zot.php index 4b3e23eea..d01613225 100644 --- a/include/zot.php +++ b/include/zot.php @@ -488,21 +488,17 @@ function zot_refresh($them, $channel = null, $force = false) { if($y) { logger("New introduction received for {$channel['channel_name']}"); $new_perms = get_all_perms($channel['channel_id'],$x['hash']); - if($new_perms != $previous_perms) { - // Send back a permissions update if permissions have changed - $z = q("select * from abook where abook_xchan = '%s' and abook_channel = %d and not (abook_flags & %d) > 0 limit 1", - dbesc($x['hash']), - intval($channel['channel_id']), - intval(ABOOK_FLAG_SELF) - ); - if($z) - proc_run('php','include/notifier.php','permission_update',$z[0]['abook_id']); - } - $new_connection = q("select abook_id, abook_flags from abook where abook_channel = %d and abook_xchan = '%s' order by abook_created desc limit 1", + + // Send a clone sync packet and a permissions update if permissions have changed + $new_connection = q("select * from abook where abook_xchan = '%s' and abook_channel = %d and not (abook_flags & %d) > 0 order by abook_created desc limit 1", + dbesc($x['hash']), intval($channel['channel_id']), - dbesc($x['hash']) + intval(ABOOK_FLAG_SELF) ); + if($new_connection) { + if($new_perms != $previous_perms) + proc_run('php','include/notifier.php','permission_update',$new_connection[0]['abook_id']); require_once('include/enotify.php'); notification(array( 'type' => NOTIFY_INTRO, @@ -510,12 +506,17 @@ function zot_refresh($them, $channel = null, $force = false) { 'to_xchan' => $channel['channel_hash'], 'link' => z_root() . '/connedit/' . $new_connection[0]['abook_id'], )); - } + + if($their_perms & PERMS_R_STREAM) { + if(($channel['channel_w_stream'] & PERMS_PENDING) + || (! ($new_connection[0]['abook_flags'] & ABOOK_FLAG_PENDING)) ) + proc_run('php','include/onepoll.php',$new_connection[0]['abook_id']); + } - if($new_connection && ($their_perms & PERMS_R_STREAM)) { - if(($channel['channel_w_stream'] & PERMS_PENDING) - || (! ($new_connection[0]['abook_flags'] & ABOOK_FLAG_PENDING)) ) - proc_run('php','include/onepoll.php',$new_connection[0]['abook_id']); + unset($new_connection[0]['abook_id']); + unset($new_connection[0]['abook_account']); + unset($new_connection[0]['abook_channel']); + build_sync_packet($channel['channel_id'], array('abook' => $new_connection)); } } } @@ -995,7 +996,7 @@ function zot_process_response($hub, $arr, $outq) { ); } - logger('zot_process_response: ' . print_r($x,true), LOGGER_DATA); + logger('zot_process_response: ' . print_r($x,true), LOGGER_DEBUG); } /** diff --git a/version.inc b/version.inc index 2d7153d51..4a93ab93e 100644 --- a/version.inc +++ b/version.inc @@ -1 +1 @@ -2015-09-18.1159 +2015-09-19.1160 -- cgit v1.2.3 From 5d6f59a598fdf700b90d7d14bb5c9087c0968cb9 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Sat, 19 Sep 2015 22:46:59 -0700 Subject: clone new connections --- include/zot.php | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/include/zot.php b/include/zot.php index 6c5a8c289..52ae23ba5 100644 --- a/include/zot.php +++ b/include/zot.php @@ -487,20 +487,16 @@ function zot_refresh($them, $channel = null, $force = false) { if($y) { logger("New introduction received for {$channel['channel_name']}"); $new_perms = get_all_perms($channel['channel_id'],$x['hash']); - if($new_perms != $previous_perms) { - // Send back a permissions update if permissions have changed - $z = q("select * from abook where abook_xchan = '%s' and abook_channel = %d and abook_self = 0 limit 1", - dbesc($x['hash']), - intval($channel['channel_id']) - ); - if($z) - proc_run('php','include/notifier.php','permission_update',$z[0]['abook_id']); - } - $new_connection = q("select abook_id, abook_pending from abook where abook_channel = %d and abook_xchan = '%s' order by abook_created desc limit 1", - intval($channel['channel_id']), - dbesc($x['hash']) + + // Send a clone sync packet and a permissions update if permissions have changed + $new_connection = q("select * from abook where abook_xchan = '%s' and abook_channel = %d and abook_self = 0 order by abook_created desc limit 1", + dbesc($x['hash']), + intval($channel['channel_id']) ); + if($new_connection) { + if($new_perms != $previous_perms) + proc_run('php','include/notifier.php','permission_update',$new_connection[0]['abook_id']); require_once('include/enotify.php'); notification(array( 'type' => NOTIFY_INTRO, @@ -508,12 +504,17 @@ function zot_refresh($them, $channel = null, $force = false) { 'to_xchan' => $channel['channel_hash'], 'link' => z_root() . '/connedit/' . $new_connection[0]['abook_id'], )); - } + + if($their_perms & PERMS_R_STREAM) { + if(($channel['channel_w_stream'] & PERMS_PENDING) + || (! intval($new_connection[0]['abook_pending'])) ) + proc_run('php','include/onepoll.php',$new_connection[0]['abook_id']); + } - if($new_connection && ($their_perms & PERMS_R_STREAM)) { - if(($channel['channel_w_stream'] & PERMS_PENDING) - || (! intval($new_connection[0]['abook_pending'])) ) - proc_run('php','include/onepoll.php',$new_connection[0]['abook_id']); + unset($new_connection[0]['abook_id']); + unset($new_connection[0]['abook_account']); + unset($new_connection[0]['abook_channel']); + build_sync_packet($channel['channel_id'], array('abook' => $new_connection)); } } } -- cgit v1.2.3 From 77df590f6516435e5c43a8d0f20e857951264941 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Sun, 20 Sep 2015 00:27:25 -0700 Subject: initial checkin delivery report class --- include/DReport.php | 46 ++++++++++++++++++++++++++++++++++++++++++++++ version.inc | 2 +- 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 include/DReport.php diff --git a/include/DReport.php b/include/DReport.php new file mode 100644 index 000000000..6c7bf354a --- /dev/null +++ b/include/DReport.php @@ -0,0 +1,46 @@ +location = $location; + $this->sender = $sender; + $this->recipient = $recipient; + $this->message_id = $message_id; + $this->status = $status; + $this->date = datetime_convert(); + } + + function update($status) { + $this->status = $status; + $this->date = datetime_convert(); + } + + function set($arr) { + $this->location = $arr['location']; + $this->sender = $arr['sender']; + $this->recipient = $arr['recipient']; + $this->message_id = $arr['message_id']; + $this->status = $arr['status']; + $this->date = $arr['date']; + } + + function get() { + return array( + 'location' => $this->location, + 'sender' => $this->sender, + 'recipient' => $this->recipient, + 'message_id' => $this->message_id, + 'status' => $this->status, + 'date' => $this->date + ); + } +} diff --git a/version.inc b/version.inc index 4a93ab93e..e412e1495 100644 --- a/version.inc +++ b/version.inc @@ -1 +1 @@ -2015-09-19.1160 +2015-09-20.1161 -- cgit v1.2.3 From c38687725d3decdd26abbc4acfd8696c0ddd36b0 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sun, 20 Sep 2015 22:12:00 +0200 Subject: kick right aside out a little earlier --- view/php/default.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/view/php/default.php b/view/php/default.php index 4c8311ef0..6a9cc5517 100644 --- a/view/php/default.php +++ b/view/php/default.php @@ -14,7 +14,7 @@
- +
-- cgit v1.2.3 From 9de8df496a98019d4b4a3e7549e0d5047dd87024 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Sun, 20 Sep 2015 16:52:21 -0700 Subject: we need the xchan record also --- include/zot.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/zot.php b/include/zot.php index d01613225..57645f631 100644 --- a/include/zot.php +++ b/include/zot.php @@ -490,7 +490,7 @@ function zot_refresh($them, $channel = null, $force = false) { $new_perms = get_all_perms($channel['channel_id'],$x['hash']); // Send a clone sync packet and a permissions update if permissions have changed - $new_connection = q("select * from abook where abook_xchan = '%s' and abook_channel = %d and not (abook_flags & %d) > 0 order by abook_created desc limit 1", + $new_connection = q("select * from abook left join xchan on abook_xchan = xchan_hash where abook_xchan = '%s' and abook_channel = %d and not (abook_flags & %d) > 0 order by abook_created desc limit 1", dbesc($x['hash']), intval($channel['channel_id']), intval(ABOOK_FLAG_SELF) -- cgit v1.2.3 From 35f09f4f746fa53fc3c495f71e0f8379c24207fa Mon Sep 17 00:00:00 2001 From: redmatrix Date: Sun, 20 Sep 2015 17:45:23 -0700 Subject: remove system flags from channel import packet --- include/zot.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/include/zot.php b/include/zot.php index 57645f631..db53ccfc5 100644 --- a/include/zot.php +++ b/include/zot.php @@ -2925,11 +2925,15 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) { } if(array_key_exists('channel',$arr) && is_array($arr['channel']) && count($arr['channel'])) { - if(array_key_exists('channel_removed',$arr['channel'])) - $arr['channel_pageflags'] |= PAGE_REMOVED; - if(array_key_exists('channel_system',$arr['channel'])) - $arr['channel_pageflags'] |= PAGE_SYSTEM; - + + // These flags cannot be sync'd. + // If these bits aren't set locally, remove the bits from the incoming flags. + + if(! ($channel['channel_pageflags'] & PAGE_REMOVED)) + $arr['channel_pageflags'] = $arr['channel_pageflags'] & PAGE_REMOVED; + if(! ($channel['channel_pageflags'] & PAGE_SYSTEM)) + $arr['channel_pageflags'] = $arr['channel_pageflags'] & PAGE_SYSTEM; + $disallowed = array('channel_id','channel_account_id','channel_primary','channel_prvkey', 'channel_address', 'channel_notifyflags', 'channel_removed', 'channel_system'); $clean = array(); -- cgit v1.2.3 From 59a56ac77fcef3348bcf82db043d526b33f5bc9f Mon Sep 17 00:00:00 2001 From: redmatrix Date: Sun, 20 Sep 2015 17:47:41 -0700 Subject: catch the timestamp also --- include/zot.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/zot.php b/include/zot.php index db53ccfc5..f01789216 100644 --- a/include/zot.php +++ b/include/zot.php @@ -2934,7 +2934,7 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) { if(! ($channel['channel_pageflags'] & PAGE_SYSTEM)) $arr['channel_pageflags'] = $arr['channel_pageflags'] & PAGE_SYSTEM; - $disallowed = array('channel_id','channel_account_id','channel_primary','channel_prvkey', 'channel_address', 'channel_notifyflags', 'channel_removed', 'channel_system'); + $disallowed = array('channel_id','channel_account_id','channel_primary','channel_prvkey', 'channel_address', 'channel_notifyflags', 'channel_removed', 'channel_system', 'channel_deleted' ); $clean = array(); foreach($arr['channel'] as $k => $v) { -- cgit v1.2.3 From efcb4abfd0ceb8155626a9d55016a92601a4780c Mon Sep 17 00:00:00 2001 From: redmatrix Date: Sun, 20 Sep 2015 18:08:06 -0700 Subject: improve on the last attempt --- include/zot.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/zot.php b/include/zot.php index f01789216..e23bad4fe 100644 --- a/include/zot.php +++ b/include/zot.php @@ -2929,10 +2929,10 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) { // These flags cannot be sync'd. // If these bits aren't set locally, remove the bits from the incoming flags. - if(! ($channel['channel_pageflags'] & PAGE_REMOVED)) - $arr['channel_pageflags'] = $arr['channel_pageflags'] & PAGE_REMOVED; - if(! ($channel['channel_pageflags'] & PAGE_SYSTEM)) - $arr['channel_pageflags'] = $arr['channel_pageflags'] & PAGE_SYSTEM; + if((! ($channel['channel_pageflags'] & PAGE_REMOVED)) && ($arr['channel_pageflags'] & PAGE_REMOVED)) + $arr['channel_pageflags'] = $arr['channel_pageflags'] - PAGE_REMOVED; + if((! ($channel['channel_pageflags'] & PAGE_SYSTEM)) && ($arr['channel_pageflags'] & PAGE_SYSTEM)) + $arr['channel_pageflags'] = $arr['channel_pageflags'] - PAGE_SYSTEM; $disallowed = array('channel_id','channel_account_id','channel_primary','channel_prvkey', 'channel_address', 'channel_notifyflags', 'channel_removed', 'channel_system', 'channel_deleted' ); -- cgit v1.2.3 From a679081993945d409cf88b6442610ad5b3dbd8b5 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Sun, 20 Sep 2015 20:21:54 -0700 Subject: new delivery report format --- include/DReport.php | 9 +++++++++ include/zot.php | 46 +++++++++++++++++++++++++++++++++------------- 2 files changed, 42 insertions(+), 13 deletions(-) diff --git a/include/DReport.php b/include/DReport.php index 6c7bf354a..ef86c8cbc 100644 --- a/include/DReport.php +++ b/include/DReport.php @@ -24,6 +24,15 @@ class DReport { $this->date = datetime_convert(); } + function addto_recipient($name) { + $this->recipient = $this->recipient . ' ' . $name; + } + + function addto_update($status) { + $this->status = $this->status . ' ' . $status; + } + + function set($arr) { $this->location = $arr['location']; $this->sender = $arr['sender']; diff --git a/include/zot.php b/include/zot.php index e23bad4fe..ddcd6b41f 100644 --- a/include/zot.php +++ b/include/zot.php @@ -1547,6 +1547,7 @@ function allowed_public_recips($msg) { function process_delivery($sender, $arr, $deliveries, $relay, $public = false, $request = false) { $result = array(); + require_once('include/DReport.php'); $result['site'] = z_root(); @@ -1561,16 +1562,22 @@ function process_delivery($sender, $arr, $deliveries, $relay, $public = false, $ foreach($deliveries as $d) { $local_public = $public; + + $DR = new DReport(z_root(),$sender['hash'],$d['hash'],$arr['mid']); + $r = q("select * from channel where channel_hash = '%s' limit 1", dbesc($d['hash']) ); if(! $r) { - $result[] = array($d['hash'], 'recipients not found'); + $DR->update('recipient not found'); + $result[] = $DR->get(); continue; } $channel = $r[0]; + $DR->addto_recipient($channel['channel_name'] . ' <' . $channel['channel_address'] . '@' . get_app()->get_hostname() . '>'); + // allow public postings to the sys channel regardless of permissions, but not // for comments travelling upstream. Wait and catch them on the way down. @@ -1609,7 +1616,8 @@ function process_delivery($sender, $arr, $deliveries, $relay, $public = false, $ if((! perm_is_allowed($channel['channel_id'],$sender['hash'],$perm)) && (! $tag_delivery) && (! $local_public)) { logger("permission denied for delivery to channel {$channel['channel_id']} {$channel['channel_address']}"); - $result[] = array($d['hash'],'permission denied',$channel['channel_name'] . ' <' . $channel['channel_address'] . '@' . get_app()->get_hostname() . '>',$arr['mid']); + $DR->update('permission denied'); + $result[] = $DR->get(); continue; } @@ -1626,7 +1634,8 @@ function process_delivery($sender, $arr, $deliveries, $relay, $public = false, $ intval($channel['channel_id']) ); if(! $r) { - $result[] = array($d['hash'],'comment parent not found',$channel['channel_name'] . ' <' . $channel['channel_address'] . '@' . get_app()->get_hostname() . '>',$arr['mid']); + $DR->update('comment parent not found'); + $result[] = $DR->get(); // We don't seem to have a copy of this conversation or at least the parent // - so request a copy of the entire conversation to date. @@ -1681,7 +1690,8 @@ function process_delivery($sender, $arr, $deliveries, $relay, $public = false, $ if($last_hop && $last_hop != $sender['hash']) { logger('comment route mismatch: parent route = ' . $r[0]['route'] . ' expected = ' . $current_route, LOGGER_DEBUG); logger('comment route mismatch: parent msg = ' . $r[0]['id'],LOGGER_DEBUG); - $result[] = array($d['hash'],'comment route mismatch',$channel['channel_name'] . ' <' . $channel['channel_address'] . '@' . get_app()->get_hostname() . '>',$arr['mid']); + $DR->update('comment route mismatch'); + $result[] = $DR->get(); continue; } @@ -1710,12 +1720,14 @@ function process_delivery($sender, $arr, $deliveries, $relay, $public = false, $ $arr['uid'] = $channel['channel_id']; $item_id = delete_imported_item($sender,$arr,$channel['channel_id'],$relay); - $result[] = array($d['hash'],(($item_id) ? 'deleted' : 'delete_failed'),$channel['channel_name'] . ' <' . $channel['channel_address'] . '@' . get_app()->get_hostname() . '>',$arr['mid']); + $DR->update(($item_id) ? 'deleted' : 'delete_failed'); + $result[] = $DR->get(); if($relay && $item_id) { logger('process_delivery: invoking relay'); proc_run('php','include/notifier.php','relay',intval($item_id)); - $result[] = array($d['hash'],'relayed',$channel['channel_name'] . ' <' . $channel['channel_address'] . '@' . get_app()->get_hostname() . '>',$arr['mid']); + $DR->update('relayed'); + $result[] = $DR->get(); } continue; @@ -1730,7 +1742,8 @@ function process_delivery($sender, $arr, $deliveries, $relay, $public = false, $ $item_id = $r[0]['id']; if($r[0]['item_restrict'] & ITEM_DELETED) { // It was deleted locally. - $result[] = array($d['hash'],'update ignored',$channel['channel_name'] . ' <' . $channel['channel_address'] . '@' . get_app()->get_hostname() . '>',$arr['mid']); + $DR->update('update ignored'); + $result[] = $DR->get(); continue; } // Maybe it has been edited? @@ -1738,17 +1751,21 @@ function process_delivery($sender, $arr, $deliveries, $relay, $public = false, $ $arr['id'] = $r[0]['id']; $arr['uid'] = $channel['channel_id']; if(($arr['mid'] == $arr['parent_mid']) && (! post_is_importable($arr,$abook))) { - $result[] = array($d['hash'],'update ignored',$channel['channel_name'] . ' <' . $channel['channel_address'] . '@' . get_app()->get_hostname() . '>',$arr['mid']); + $DR->update('update ignored'); + $result[] = $DR->get(); } else { update_imported_item($sender,$arr,$channel['channel_id']); - $result[] = array($d['hash'],'updated',$channel['channel_name'] . ' <' . $channel['channel_address'] . '@' . get_app()->get_hostname() . '>',$arr['mid']); + $DR->update('updated'); + $result[] = $DR->get(); if(! $relay) add_source_route($item_id,$sender['hash']); } } else { - $result[] = array($d['hash'],'update ignored',$channel['channel_name'] . ' <' . $channel['channel_address'] . '@' . get_app()->get_hostname() . '>',$arr['mid']); + $DR->update('update ignored'); + $result[] = $DR->get(); + // We need this line to ensure wall-to-wall comments are relayed (by falling through to the relay bit), // and at the same time not relay any other relayable posts more than once, because to do so is very wasteful. if(! ($r[0]['item_flags'] & ITEM_ORIGIN)) @@ -1768,7 +1785,8 @@ function process_delivery($sender, $arr, $deliveries, $relay, $public = false, $ $item_id = 0; if(($arr['mid'] == $arr['parent_mid']) && (! post_is_importable($arr,$abook))) { - $result[] = array($d['hash'],'post ignored',$channel['channel_name'] . ' <' . $channel['channel_address'] . '@' . get_app()->get_hostname() . '>',$arr['mid']); + $DR->update('post ignored'); + $result[] = $DR->get(); } else { $item_result = item_store($arr); @@ -1780,14 +1798,16 @@ function process_delivery($sender, $arr, $deliveries, $relay, $public = false, $ if(! $relay) add_source_route($item_id,$sender['hash']); } - $result[] = array($d['hash'],(($item_id) ? 'posted' : 'storage failed:' . $item_result['message']),$channel['channel_name'] . ' <' . $channel['channel_address'] . '@' . get_app()->get_hostname() . '>',$arr['mid']); + $DR->update(($item_id) ? 'posted' : 'storage failed: ' . $item_result['message']); + $result[] = $DR->get(); } } if($relay && $item_id) { logger('process_delivery: invoking relay'); proc_run('php','include/notifier.php','relay',intval($item_id)); - $result[] = array($d['hash'],'relayed',$channel['channel_name'] . ' <' . $channel['channel_address'] . '@' . get_app()->get_hostname() . '>',$arr['mid']); + $DR->addto_update('relayed'); + $result[] = $DR->get(); } } -- cgit v1.2.3 From d2565d0f61c139df6536ec9d90c10d7af29ef9e5 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Sun, 20 Sep 2015 21:37:18 -0700 Subject: looks like chat has been neglected a bit recently --- include/chat.php | 2 +- include/nav.php | 5 ++--- mod/chat.php | 2 +- view/tpl/bookmarkedchats.tpl | 2 +- view/tpl/chatroom_new.tpl | 2 +- view/tpl/chatrooms.tpl | 2 +- 6 files changed, 7 insertions(+), 8 deletions(-) diff --git a/include/chat.php b/include/chat.php index a0646265a..81c5c5d62 100644 --- a/include/chat.php +++ b/include/chat.php @@ -91,7 +91,7 @@ function chatroom_destroy($channel,$arr) { return $ret; } - create_sync_packet($channel['channel_id'],array('chatroom' => $r)); + build_sync_packet($channel['channel_id'],array('chatroom' => $r)); q("delete from chatroom where cr_id = %d", intval($r[0]['cr_id']) diff --git a/include/nav.php b/include/nav.php index 59a7c83a3..972795e83 100644 --- a/include/nav.php +++ b/include/nav.php @@ -94,9 +94,8 @@ EOT; require_once('include/chat.php'); $has_chats = chatroom_list_count(local_channel()); - if($has_chats) { - $nav['usermenu'][] = Array('chat/' . $channel['channel_address'],t('Chat'),"",t('Your chatrooms'),'chat_nav_btn'); - } + $nav['usermenu'][] = Array('chat/' . $channel['channel_address'] . (($has_chats) ? '' : '/new'), t('Chat'),"",t('Your chatrooms'),'chat_nav_btn'); + require_once('include/menu.php'); $has_bookmarks = menu_list_count(local_channel(),'',MENU_BOOKMARK) + menu_list_count(local_channel(),'',MENU_SYSTEM|MENU_BOOKMARK); diff --git a/mod/chat.php b/mod/chat.php index 9ad58bc32..ef9089b6f 100644 --- a/mod/chat.php +++ b/mod/chat.php @@ -67,7 +67,7 @@ function chat_post(&$a) { intval(local_channel()) ); - create_sync_packet(0, array('chatroom' => $x)); + build_sync_packet(0, array('chatroom' => $x)); if($x) goaway(z_root() . '/chat/' . $channel['channel_address'] . '/' . $x[0]['cr_id']); diff --git a/view/tpl/bookmarkedchats.tpl b/view/tpl/bookmarkedchats.tpl index 7635bb826..ab4372c25 100644 --- a/view/tpl/bookmarkedchats.tpl +++ b/view/tpl/bookmarkedchats.tpl @@ -1,7 +1,7 @@ {{if $rooms}}

{{$header}}

-
    +
-- cgit v1.2.3 From 4b13f0e025b08263d7231845bc76034d9adc7847 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Tue, 22 Sep 2015 04:08:03 -0700 Subject: since this is now usable, protect the displayed delivery reports from XSS injection --- mod/dreport.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mod/dreport.php b/mod/dreport.php index 3c74a9e33..a20e17372 100644 --- a/mod/dreport.php +++ b/mod/dreport.php @@ -32,7 +32,7 @@ function dreport_content(&$a) { foreach($r as $rr) { $name = escape_tags(substr($rr['dreport_recip'],strpos($rr['dreport_recip'],' '))); - $o .= '' . $name . '' . $rr['dreport_result'] . '' . $rr['dreport_time'] . ''; + $o .= '' . $name . '' . escape_tags($rr['dreport_result']) . '' . escape_tags($rr['dreport_time']) . ''; } $o .= ''; -- cgit v1.2.3 From f84151e1fe830dca59ae83de429670dfde76b7d2 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Tue, 22 Sep 2015 04:24:54 -0700 Subject: fix foreach warning --- include/zot.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/zot.php b/include/zot.php index fb55da0fa..d0f4f5680 100644 --- a/include/zot.php +++ b/include/zot.php @@ -957,7 +957,7 @@ function zot_process_response($hub, $arr, $outq) { logger('zot_process_response: headers: ' . print_r($arr['header'],true), LOGGER_DATA); } - if(array_key_exists('delivery_report',$x)) { + if(array_key_exists('delivery_report',$x) && is_array($x['delivery_report'])) { foreach($x['delivery_report'] as $xx) { if(is_array($xx) && array_key_exists('message_id',$xx)) { q("insert into dreport ( dreport_mid, dreport_site, dreport_recip, dreport_result, dreport_time, dreport_xchan ) values ( '%s', '%s','%s','%s','%s','%s' ) ", -- cgit v1.2.3 From 1c1155513a6206b56e45045f762908767049f86e Mon Sep 17 00:00:00 2001 From: redmatrix Date: Tue, 22 Sep 2015 04:28:05 -0700 Subject: add one more test --- include/zot.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/zot.php b/include/zot.php index d0f4f5680..adeedd42e 100644 --- a/include/zot.php +++ b/include/zot.php @@ -957,7 +957,7 @@ function zot_process_response($hub, $arr, $outq) { logger('zot_process_response: headers: ' . print_r($arr['header'],true), LOGGER_DATA); } - if(array_key_exists('delivery_report',$x) && is_array($x['delivery_report'])) { + if(is_array($x) && array_key_exists('delivery_report',$x) && is_array($x['delivery_report'])) { foreach($x['delivery_report'] as $xx) { if(is_array($xx) && array_key_exists('message_id',$xx)) { q("insert into dreport ( dreport_mid, dreport_site, dreport_recip, dreport_result, dreport_time, dreport_xchan ) values ( '%s', '%s','%s','%s','%s','%s' ) ", -- cgit v1.2.3 From 7dd61c05dcf169807aed91d305ea235bcaa9035e Mon Sep 17 00:00:00 2001 From: redmatrix Date: Tue, 22 Sep 2015 04:39:36 -0700 Subject: allow self delivery until we figure out why clone sync of posted items isn't doing it's thing --- include/zot.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/include/zot.php b/include/zot.php index adeedd42e..4b4be477f 100644 --- a/include/zot.php +++ b/include/zot.php @@ -1583,11 +1583,12 @@ function process_delivery($sender, $arr, $deliveries, $relay, $public = false, $ $DR->addto_recipient($channel['channel_name'] . ' <' . $channel['channel_address'] . '@' . get_app()->get_hostname() . '>'); - if($d['hash'] === $sender['hash']) { - $DR->update('self delivery ignored'); - $result[] = $DR->get(); - continue; - } +// uncomment this once we find out what's stopping the clone sync of the item from working +// if($d['hash'] === $sender['hash']) { +// $DR->update('self delivery ignored'); +// $result[] = $DR->get(); +// continue; +// } // allow public postings to the sys channel regardless of permissions, but not -- cgit v1.2.3 From c2dcc6880302406de6e1abf90c985975e8a4f13a Mon Sep 17 00:00:00 2001 From: redmatrix Date: Tue, 22 Sep 2015 16:19:08 -0700 Subject: backport item sync --- include/items.php | 8 ++++-- include/zot.php | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+), 2 deletions(-) diff --git a/include/items.php b/include/items.php index 3669628b4..86da7941f 100755 --- a/include/items.php +++ b/include/items.php @@ -805,10 +805,14 @@ function title_is_body($title, $body) { } -function get_item_elements($x) { +function get_item_elements($x,$allow_code = false) { $arr = array(); - $arr['body'] = (($x['body']) ? htmlspecialchars($x['body'],ENT_COMPAT,'UTF-8',false) : ''); + + if($allow_code) + $arr['body'] = $x['body']; + else + $arr['body'] = (($x['body']) ? htmlspecialchars($x['body'],ENT_COMPAT,'UTF-8',false) : ''); $key = get_config('system','pubkey'); diff --git a/include/zot.php b/include/zot.php index ddcd6b41f..a41295aad 100644 --- a/include/zot.php +++ b/include/zot.php @@ -3273,6 +3273,14 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) { } } + + if(array_key_exists('item',$arr) && $arr['item']) + sync_items($channel,$arr['item']); + + if(array_key_exists('item_id',$arr) && $arr['item_id']) + sync_items($channel,$arr['item_id']); + + $result[] = array($d['hash'],'channel sync updated',$channel['channel_name'],''); } @@ -3431,3 +3439,80 @@ function zot_process_message_request($data) { return $ret; } + + + +function import_items($channel,$items) { + + if($channel && $items) { + $allow_code = false; + $r = q("select account_id, account_roles, channel_pageflags from account left join channel on channel_account_id = account_id + where channel_id = %d limit 1", + intval($channel['channel_id']) + ); + if($r) { + if(($r[0]['account_roles'] & ACCOUNT_ROLE_ALLOWCODE) || ($r[0]['channel_pageflags'] & PAGE_ALLOWCODE)) { + $allow_code = true; + } + } + + foreach($items as $i) { + $item = get_item_elements($i,$allow_code); + if(! $item) + continue; + + $r = q("select id, edited from item where mid = '%s' and uid = %d limit 1", + dbesc($item['mid']), + intval($channel['channel_id']) + ); + if($r) { + if($item['edited'] > $r[0]['edited']) { + $item['id'] = $r[0]['id']; + $item['uid'] = $channel['channel_id']; + item_store_update($item); + continue; + } + } + else { + $item['aid'] = $channel['channel_account_id']; + $item['uid'] = $channel['channel_id']; + $item_result = item_store($item); + } + + } + } +} + + +function sync_items($channel,$items) { + import_items($channel,$items); +} + + + +function import_item_ids($channel,$itemids) { + if($channel && $itemids) { + foreach($itemids as $i) { + $r = q("select id from item where mid = '%s' and uid = %d limit 1", + dbesc($i['mid']), + intval($channel['channel_id']) + ); + if(! $r) + continue; + $z = q("select * from item_id where service = '%s' and sid = '%s' and iid = %d and uid = %d limit 1", + dbesc($i['service']), + dbesc($i['sid']), + intval($r[0]['id']), + intval($channel['channel_id']) + ); + if(! $z) { + q("insert into item_id (iid,uid,sid,service) values(%d,%d,'%s','%s')", + intval($r[0]['id']), + intval($channel['channel_id']), + dbesc($i['sid']), + dbesc($i['service']) + ); + } + } + } +} -- cgit v1.2.3 From 642f460dcad84b8254126f316db4c0225a958958 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Tue, 22 Sep 2015 16:43:36 -0700 Subject: report the channel sync --- include/zot.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/include/zot.php b/include/zot.php index a41295aad..eb04e421c 100644 --- a/include/zot.php +++ b/include/zot.php @@ -3281,7 +3281,17 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) { sync_items($channel,$arr['item_id']); - $result[] = array($d['hash'],'channel sync updated',$channel['channel_name'],''); + // we should probably do this for all items, but usually we only send one. + + require_once('include/DReport.php'); + + if(array_key_exists('item',$arr) && is_array($arr['item'][0])) + $DR = new DReport(z_root(),$d['hash'],$d['hash'],$arr['item'][0]['message_id'],'channel sync processed'); + else + $DR = new DReport(z_root(),$d['hash'],$d['hash'],'sync packet','channel sync delivered'); + + $result[] = $DR->get(); + } return $result; -- cgit v1.2.3 From 34291d593845c1ec4c2d68dcc4662b020db33f32 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Tue, 22 Sep 2015 16:50:08 -0700 Subject: add names to delivery report for sync delivery --- include/zot.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/zot.php b/include/zot.php index eb04e421c..0b1aaa989 100644 --- a/include/zot.php +++ b/include/zot.php @@ -3285,8 +3285,10 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) { require_once('include/DReport.php'); - if(array_key_exists('item',$arr) && is_array($arr['item'][0])) + if(array_key_exists('item',$arr) && is_array($arr['item'][0])) { $DR = new DReport(z_root(),$d['hash'],$d['hash'],$arr['item'][0]['message_id'],'channel sync processed'); + $DR->addto_recipient($channel['channel_name'] . ' <' . $channel['channel_address'] . '@' . get_app()->get_hostname() . '>'); + } else $DR = new DReport(z_root(),$d['hash'],$d['hash'],'sync packet','channel sync delivered'); -- cgit v1.2.3 From 15feeb7bfe324bbe87e689ee7920a6be20cc204c Mon Sep 17 00:00:00 2001 From: redmatrix Date: Tue, 22 Sep 2015 18:40:03 -0700 Subject: inverted logic syncing deleted hublocs --- include/zot.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/zot.php b/include/zot.php index 0b1aaa989..236b55522 100644 --- a/include/zot.php +++ b/include/zot.php @@ -2363,7 +2363,7 @@ function sync_locations($sender, $arr, $absolute = false) { foreach($xisting as $x) { if(! array_key_exists('updated',$x)) { logger('sync_locations: deleting unreferenced hub location ' . $x['hubloc_url']); - $r = q("update hubloc set hubloc_flags = (hubloc_flags & ~%d), hubloc_updated = '%s' where hubloc_id = %d", + $r = q("update hubloc set hubloc_flags = (hubloc_flags | %d), hubloc_updated = '%s' where hubloc_id = %d", intval(HUBLOC_FLAGS_DELETED), dbesc(datetime_convert()), intval($x['hubloc_id']) -- cgit v1.2.3 From d16ac62a511ed32e7bcd50ee25148c0771b5e765 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Tue, 22 Sep 2015 19:13:10 -0700 Subject: don't send sync packets to deleted hubloc locations --- include/zot.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/zot.php b/include/zot.php index 236b55522..aae429709 100644 --- a/include/zot.php +++ b/include/zot.php @@ -2802,8 +2802,10 @@ function build_sync_packet($uid = 0, $packet = null, $groups_changed = false) { $channel = $r[0]; - $h = q("select * from hubloc where hubloc_hash = '%s'", - dbesc($channel['channel_hash']) + $h = q("select * from hubloc where hubloc_hash = '%s' and not (hubloc_flags & %d) > 0 and not (hubloc_status & %d) > 0", + dbesc($channel['channel_hash']), + intval(HUBLOC_FLAGS_DELETED), + intval(HUBLOC_OFFLINE) ); if(! $h) -- cgit v1.2.3 From d35c5bcb2f425bf498eae53c5ac268a96c808cb9 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Tue, 22 Sep 2015 19:16:13 -0700 Subject: merge issue --- include/zot.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/include/zot.php b/include/zot.php index 86e9da5f3..288493b07 100644 --- a/include/zot.php +++ b/include/zot.php @@ -2816,10 +2816,8 @@ function build_sync_packet($uid = 0, $packet = null, $groups_changed = false) { $channel = $r[0]; - $h = q("select * from hubloc where hubloc_hash = '%s' and not (hubloc_flags & %d) > 0 and not (hubloc_status & %d) > 0", - dbesc($channel['channel_hash']), - intval(HUBLOC_FLAGS_DELETED), - intval(HUBLOC_OFFLINE) + $h = q("select * from hubloc where hubloc_hash = '%s' and hubloc_deleted = 0", + dbesc($channel['channel_hash']) ); if(! $h) -- cgit v1.2.3 From 7734bbfe4d7730abed39e4e23287a68461d86040 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Tue, 22 Sep 2015 22:30:09 -0700 Subject: problems with extended item import and signatures --- include/items.php | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 62 insertions(+), 3 deletions(-) diff --git a/include/items.php b/include/items.php index 86da7941f..eed9dabb2 100755 --- a/include/items.php +++ b/include/items.php @@ -807,6 +807,7 @@ function title_is_body($title, $body) { function get_item_elements($x,$allow_code = false) { + $arr = array(); if($allow_code) @@ -922,7 +923,6 @@ function get_item_elements($x,$allow_code = false) { logger('get_item_elements: message verification failed.'); } - // if it's a private post, encrypt it in the DB. // We have to do that here because we need to cleanse the input and prevent bad stuff from getting in, // and we need plaintext to do that. @@ -949,9 +949,68 @@ function get_item_elements($x,$allow_code = false) { $arr['postopts'] = $x['postopts']; $arr['resource_id'] = $x['resource_id']; $arr['resource_type'] = $x['resource_type']; - $arr['item_restrict'] = $x['item_restrict']; - $arr['item_flags'] = $x['item_flags']; $arr['attach'] = $x['attach']; + + if(! array_key_exists('item_origin',$x)) { + $arr['item_restrict'] = $x['item_restrict']; + $arr['item_flags'] = $x['item_flags']; + } + + if(array_key_exists('item_origin',$x) && intval($x['item_origin'])) + $arr['item_flags'] |= ITEM_ORIGIN; + if(array_key_exists('item_unseen',$x) && intval($x['item_unseen'])) + $arr['item_flags'] |= ITEM_UNSEEN; + if(array_key_exists('item_starred',$x) && intval($x['item_starred'])) + $arr['item_flags'] |= ITEM_STARRED; + if(array_key_exists('item_uplink',$x) && intval($x['item_uplink'])) + $arr['item_flags'] |= ITEM_UPLINK; + if(array_key_exists('item_consensus',$x) && intval($x['item_consensus'])) + $arr['item_flags'] |= ITEM_CONSENSUS; + if(array_key_exists('item_wall',$x) && intval($x['item_wall'])) + $arr['item_flags'] |= ITEM_WALL; + if(array_key_exists('item_thread_top',$x) && intval($x['item_thread_top'])) + $arr['item_flags'] |= ITEM_THREAD_TOP; + if(array_key_exists('item_notshown',$x) && intval($x['item_notshown'])) + $arr['item_flags'] |= ITEM_NOTSHOWN; + if(array_key_exists('item_nsfw',$x) && intval($x['item_nsfw'])) + $arr['item_flags'] |= ITEM_NSFW; + if(array_key_exists('item_mentionsme',$x) && intval($x['item_mentionsme'])) + $arr['item_flags'] |= ITEM_MENTIONSME; + if(array_key_exists('item_nocomment',$x) && intval($x['item_nocomment'])) + $arr['item_flags'] |= ITEM_NOCOMMENT; + if(array_key_exists('item_retained',$x) && intval($x['item_retained'])) + $arr['item_flags'] |= ITEM_RETAINED; + if(array_key_exists('item_rss',$x) && intval($x['item_rss'])) + $arr['item_flags'] |= ITEM_RSS; + + + if(array_key_exists('item_deleted',$x)&& intval($x['item_deleted'])) + $arr['item_restrict'] |= ITEM_DELETED; + if(array_key_exists('item_unpublished',$x)&& intval($x['item_unpublished'])) + $arr['item_restrict'] |= ITEM_UNPUBLISHED; + if(array_key_exists('item_delayed',$x)&& intval($x['item_delayed'])) + $arr['item_restrict'] |= ITEM_DELAYED_PUBLISH; + if(array_key_exists('item_pending_remove',$x)&& intval($x['item_pending_remove'])) + $arr['item_restrict'] |= ITEM_PENDING_REMOVE; + if(array_key_exists('item_type',$x)) { + switch(intval($x['item_type'])) { + case 1: + $arr['item_restrict'] |= ITEM_BUILDBLOCK; + break; + case 2: + $arr['item_restrict'] |= ITEM_PDL; + break; + case 3: + $arr['item_restrict'] |= ITEM_WEBPAGE; + break; + case 4: + $arr['item_restrict'] |= ITEM_BUG; + break; + case 0: + default: + break; + } + } } return $arr; -- cgit v1.2.3