diff options
Diffstat (limited to 'include/items.php')
-rwxr-xr-x | include/items.php | 65 |
1 files changed, 11 insertions, 54 deletions
diff --git a/include/items.php b/include/items.php index 4e85bef37..42ff3cb8b 100755 --- a/include/items.php +++ b/include/items.php @@ -417,14 +417,6 @@ function post_activity_item($arr) { $arr['item_flags'] = $arr['item_flags'] | ITEM_VERIFIED; } } - - logger('Encrypting local storage'); - $key = get_config('system','pubkey'); - $arr['item_flags'] = $arr['item_flags'] | ITEM_OBSCURED; - if($arr['title']) - $arr['title'] = json_encode(crypto_encapsulate($arr['title'],$key)); - if($arr['body']) - $arr['body'] = json_encode(crypto_encapsulate($arr['body'],$key)); } $arr['mid'] = ((x($arr,'mid')) ? $arr['mid'] : item_message_id()); @@ -851,7 +843,7 @@ function get_item_elements($x) { $arr['sig'] = (($x['signature']) ? htmlspecialchars($x['signature'], ENT_COMPAT,'UTF-8',false) : ''); - $arr['diaspora_meta'] = (($x['diaspora_signature']) ? json_encode(crypto_encapsulate($x['diaspora_signature'],$key)) : ''); + $arr['diaspora_meta'] = (($x['diaspora_signature']) ? json_encode($x['diaspora_signature']) : ''); $arr['object'] = activity_sanitise($x['object']); $arr['target'] = activity_sanitise($x['target']); @@ -900,21 +892,6 @@ function get_item_elements($x) { 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. - - - if(intval($arr['item_private'])) { - $arr['item_flags'] = $arr['item_flags'] | ITEM_OBSCURED; - if($arr['title']) - $arr['title'] = json_encode(crypto_encapsulate($arr['title'],$key)); - if($arr['body']) - $arr['body'] = json_encode(crypto_encapsulate($arr['body'],$key)); - } - - if(array_key_exists('revision',$x)) { // extended export encoding @@ -1178,9 +1155,15 @@ function encode_item($item,$mirror = false) { if($item['term']) $x['tags'] = encode_item_terms($item['term']); - if($item['diaspora_meta']) - $x['diaspora_signature'] = crypto_unencapsulate(json_decode($item['diaspora_meta'],true),$key); - + if($item['diaspora_meta']) { + $z = json_decode($item['diaspora_meta'],true); + if($z) { + if(array_key_exists('iv',$z)) + $x['diaspora_signature'] = crypto_unencapsulate($z,$key); + else + $x['diaspora_signature'] = $z; + } + } logger('encode_item: ' . print_r($x,true), LOGGER_DATA); return $x; @@ -2063,14 +2046,6 @@ function item_store($arr, $allow_exec = false) { } $arr = $translate['item']; } - if($arr['item_private']) { - $key = get_config('system','pubkey'); - $arr['item_flags'] = $arr['item_flags'] | ITEM_OBSCURED; - if($arr['title']) - $arr['title'] = json_encode(crypto_encapsulate($arr['title'],$key)); - if($arr['body']) - $arr['body'] = json_encode(crypto_encapsulate($arr['body'],$key)); - } } if((x($arr,'object')) && is_array($arr['object'])) { @@ -2460,14 +2435,6 @@ function item_store_update($arr,$allow_exec = false) { } $arr = $translate['item']; } - if($arr['item_private']) { - $key = get_config('system','pubkey'); - $arr['item_flags'] = $arr['item_flags'] | ITEM_OBSCURED; - if($arr['title']) - $arr['title'] = json_encode(crypto_encapsulate($arr['title'],$key)); - if($arr['body']) - $arr['body'] = json_encode(crypto_encapsulate($arr['body'],$key)); - } } if((x($arr,'object')) && is_array($arr['object'])) { @@ -3173,17 +3140,7 @@ function start_delivery_chain($channel, $item, $item_id, $parent) { $title = $item['title']; $body = $item['body']; - if($private) { - if(!($flag_bits & ITEM_OBSCURED)) { - $key = get_config('system','pubkey'); - $flag_bits = $flag_bits|ITEM_OBSCURED; - if($title) - $title = json_encode(crypto_encapsulate($title,$key)); - if($body) - $body = json_encode(crypto_encapsulate($body,$key)); - } - } - else { + if(! $private) { if($flag_bits & ITEM_OBSCURED) { $key = get_config('system','prvkey'); $flag_bits = $flag_bits ^ ITEM_OBSCURED; |