From 13788af90838d66b1c701f935862a37fcc7262f4 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 13 Sep 2017 19:20:16 -0700 Subject: Zot6: some things that need to be done ahead of time so we can turbocharge the delivery engine and split off site records from channel records. --- Zotlabs/Daemon/Deliver.php | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) (limited to 'Zotlabs/Daemon/Deliver.php') diff --git a/Zotlabs/Daemon/Deliver.php b/Zotlabs/Daemon/Deliver.php index dbc311cf5..7c1ff717f 100644 --- a/Zotlabs/Daemon/Deliver.php +++ b/Zotlabs/Daemon/Deliver.php @@ -53,22 +53,29 @@ class Deliver { remove_queue_item($r[0]['outq_hash']); if($dresult && is_array($dresult)) { - foreach($dresult as $xx) { - if(is_array($xx) && array_key_exists('message_id',$xx)) { - if(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']), - dbesc($xx['recipient']), - dbesc($xx['status']), - dbesc(datetime_convert($xx['date'])), - dbesc($xx['sender']) - ); + if(array_key_exists('iv',$dresult)) { + $dresult = json_decode(crypto_unencapsulate($dresult,get_config('system','prvkey')),true); + } + if(! $dresult) { + logger('dreport decryption failure'); + } + else { + foreach($dresult as $xx) { + if(is_array($xx) && array_key_exists('message_id',$xx)) { + if(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']), + dbesc($xx['recipient']), + dbesc($xx['status']), + dbesc(datetime_convert($xx['date'])), + dbesc($xx['sender']) + ); + } } } } } - q("delete from dreport where dreport_queue = '%s'", dbesc($argv[$x]) ); -- cgit v1.2.3 From 3456c192feeab9495693e2cbdcff16fe99bff932 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 21 Sep 2017 23:37:13 -0700 Subject: encrypt delivery reports. This will cause a bit of consternation because this is not backward compatible and older sites will see some incorrect delivery reports from newer sites until the next upgrade; as their systems will not know how to read the ecnrypted final reports. --- Zotlabs/Daemon/Deliver.php | 1 + 1 file changed, 1 insertion(+) (limited to 'Zotlabs/Daemon/Deliver.php') diff --git a/Zotlabs/Daemon/Deliver.php b/Zotlabs/Daemon/Deliver.php index 7c1ff717f..39c9ffdb1 100644 --- a/Zotlabs/Daemon/Deliver.php +++ b/Zotlabs/Daemon/Deliver.php @@ -53,6 +53,7 @@ class Deliver { remove_queue_item($r[0]['outq_hash']); if($dresult && is_array($dresult)) { + if(array_key_exists('iv',$dresult)) { $dresult = json_decode(crypto_unencapsulate($dresult,get_config('system','prvkey')),true); } -- cgit v1.2.3 From aef239f4212244997a09c10445072f886c8bf368 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 21 Sep 2017 23:51:04 -0700 Subject: delivery report decryption is not needed for local delivery --- Zotlabs/Daemon/Deliver.php | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) (limited to 'Zotlabs/Daemon/Deliver.php') diff --git a/Zotlabs/Daemon/Deliver.php b/Zotlabs/Daemon/Deliver.php index 39c9ffdb1..394a7bf3e 100644 --- a/Zotlabs/Daemon/Deliver.php +++ b/Zotlabs/Daemon/Deliver.php @@ -54,29 +54,24 @@ class Deliver { if($dresult && is_array($dresult)) { - if(array_key_exists('iv',$dresult)) { - $dresult = json_decode(crypto_unencapsulate($dresult,get_config('system','prvkey')),true); - } - if(! $dresult) { - logger('dreport decryption failure'); - } - else { - foreach($dresult as $xx) { - if(is_array($xx) && array_key_exists('message_id',$xx)) { - if(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']), - dbesc($xx['recipient']), - dbesc($xx['status']), - dbesc(datetime_convert($xx['date'])), - dbesc($xx['sender']) - ); - } + // delivery reports for local deliveries do not require encryption + + foreach($dresult as $xx) { + if(is_array($xx) && array_key_exists('message_id',$xx)) { + if(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']), + dbesc($xx['recipient']), + dbesc($xx['status']), + dbesc(datetime_convert($xx['date'])), + dbesc($xx['sender']) + ); } } } } + q("delete from dreport where dreport_queue = '%s'", dbesc($argv[$x]) ); -- cgit v1.2.3