diff options
author | mrjive <mrjive@mrjive.it> | 2015-10-26 21:55:47 +0100 |
---|---|---|
committer | mrjive <mrjive@mrjive.it> | 2015-10-26 21:55:47 +0100 |
commit | a4c3058f845a1c38d06b2201a10700c5f878366d (patch) | |
tree | bab86468397e523457ba25199cb9a67265980e00 /include/zot.php | |
parent | 32522b61f235266384c81c0669fceaf58afeb4fe (diff) | |
parent | 6cb7afcbc0447b60de0128f9a912e10ae125ba45 (diff) | |
download | volse-hubzilla-a4c3058f845a1c38d06b2201a10700c5f878366d.tar.gz volse-hubzilla-a4c3058f845a1c38d06b2201a10700c5f878366d.tar.bz2 volse-hubzilla-a4c3058f845a1c38d06b2201a10700c5f878366d.zip |
Merge pull request #7 from redmatrix/master
updating from original codebase
Diffstat (limited to 'include/zot.php')
-rw-r--r-- | include/zot.php | 67 |
1 files changed, 61 insertions, 6 deletions
diff --git a/include/zot.php b/include/zot.php index dd9222bf3..793eb6b39 100644 --- a/include/zot.php +++ b/include/zot.php @@ -503,7 +503,7 @@ function zot_refresh($them, $channel = null, $force = false) { if($new_connection) { if($new_perms != $previous_perms) - proc_run('php','include/notifier.php','permission_update',$new_connection[0]['abook_id']); + proc_run('php','include/notifier.php','permission_create',$new_connection[0]['abook_id']); require_once('include/enotify.php'); notification(array( 'type' => NOTIFY_INTRO, @@ -965,7 +965,7 @@ function zot_process_response($hub, $arr, $outq) { 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)) { + if(is_array($xx) && array_key_exists('message_id',$xx) && delivery_report_is_storable($xx)) { q("insert into dreport ( dreport_mid, dreport_site, dreport_recip, dreport_result, dreport_time, dreport_xchan ) values ( '%s', '%s','%s','%s','%s','%s' ) ", dbesc($xx['message_id']), dbesc($xx['location']), @@ -2739,6 +2739,7 @@ function import_site($arr, $pubkey) { $sellpage = htmlspecialchars($arr['sellpage'],ENT_COMPAT,'UTF-8',false); $site_location = htmlspecialchars($arr['location'],ENT_COMPAT,'UTF-8',false); $site_realm = htmlspecialchars($arr['realm'],ENT_COMPAT,'UTF-8',false); + $site_project = htmlspecialchars($arr['project'],ENT_COMPAT,'UTF-8',false); // You can have one and only one primary directory per realm. // Downgrade any others claiming to be primary. As they have @@ -2757,13 +2758,15 @@ function import_site($arr, $pubkey) { || ($siterecord['site_sellpage'] != $sellpage) || ($siterecord['site_location'] != $site_location) || ($siterecord['site_register'] != $register_policy) + || ($siterecord['site_project'] != $site_project) || ($siterecord['site_realm'] != $site_realm)) { $update = true; // logger('import_site: input: ' . print_r($arr,true)); // logger('import_site: stored: ' . print_r($siterecord,true)); - $r = q("update site set site_dead = 0, site_location = '%s', site_flags = %d, site_access = %d, site_directory = '%s', site_register = %d, site_update = '%s', site_sellpage = '%s', site_realm = '%s', site_type = %d + + $r = q("update site set site_dead = 0, site_location = '%s', site_flags = %d, site_access = %d, site_directory = '%s', site_register = %d, site_update = '%s', site_sellpage = '%s', site_realm = '%s', site_type = %d, site_project = '%s' where site_url = '%s'", dbesc($site_location), intval($site_directory), @@ -2774,6 +2777,7 @@ function import_site($arr, $pubkey) { dbesc($sellpage), dbesc($site_realm), intval(SITE_TYPE_ZOT), + dbesc($site_project), dbesc($url) ); if(! $r) { @@ -2790,8 +2794,9 @@ function import_site($arr, $pubkey) { } else { $update = true; - $r = q("insert into site ( site_location, site_url, site_access, site_flags, site_update, site_directory, site_register, site_sellpage, site_realm, site_type ) - values ( '%s', '%s', %d, %d, '%s', '%s', %d, '%s', '%s', %d )", + + $r = q("insert into site ( site_location, site_url, site_access, site_flags, site_update, site_directory, site_register, site_sellpage, site_realm, site_type, site_project ) + values ( '%s', '%s', %d, %d, '%s', '%s', %d, '%s', '%s', %d, '%s' )", dbesc($site_location), dbesc($url), intval($access_policy), @@ -2801,7 +2806,8 @@ function import_site($arr, $pubkey) { intval($register_policy), dbesc($sellpage), dbesc($site_realm), - intval(SITE_TYPE_ZOT) + intval(SITE_TYPE_ZOT), + dbesc($site_project) ); if(! $r) { logger('import_site: record create failed. ' . print_r($arr,true)); @@ -3002,6 +3008,12 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) { if(array_key_exists('chatroom',$arr) && $arr['chatroom']) sync_chatrooms($channel,$arr['chatroom']); + if(array_key_exists('conv',$arr) && $arr['conv']) + import_conv($channel,$arr['conv']); + + if(array_key_exists('mail',$arr) && $arr['mail']) + import_mail($channel,$arr['mail']); + if(array_key_exists('event',$arr) && $arr['event']) sync_events($channel,$arr['event']); @@ -3804,6 +3816,7 @@ function zotinfo($arr) { $ret['site']['sellpage'] = get_config('system','sellpage'); $ret['site']['location'] = get_config('system','site_location'); $ret['site']['realm'] = get_directory_realm(); + $ret['site']['project'] = PLATFORM_NAME; } @@ -3876,3 +3889,45 @@ function check_zotinfo($channel,$locations,&$ret) { } } } + +function delivery_report_is_storable($dr) { + + call_hooks('dreport_is_storable',$dr); + + // let plugins accept or reject - if neither, continue on + if(array_key_exists('accept',$dr) && intval($dr['accept'])) + return true; + if(array_key_exists('reject',$dr) && intval($dr['reject'])) + return false; + + if(! ($dr['sender'])) + return false; + + // Is the sender one of our channels? + + $c = q("select channel_id from channel where channel_hash = '%s' limit 1", + dbesc($dr['sender']) + ); + if(! $c) + return false; + + // is the recipient one of our connections, or do we want to store every report? + + $r = explode(' ', $dr['recipient']); + $rxchan = $r[0]; + $pcf = get_pconfig($c[0]['channel_id'],'system','dreport_store_all'); + if($pcf) + return true; + + $r = q("select abook_id from abook where abook_xchan = '%s' and abook_channel = %d limit 1", + dbesc($rxchan), + intval($c[0]['channel_id']) + ); + if($r) + return true; + + return false; + +} + + |