aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2017-04-20 20:19:15 -0700
committerzotlabs <mike@macgirvin.com>2017-04-20 20:19:15 -0700
commit94f15e355166f0abd3698414948abff2397a7ad0 (patch)
tree48202430a91a6498aca71a0f4bf3ae90076169ba /include
parent2d90b831f0af1c276cc590a5fcec427de3eb32f8 (diff)
downloadvolse-hubzilla-94f15e355166f0abd3698414948abff2397a7ad0.tar.gz
volse-hubzilla-94f15e355166f0abd3698414948abff2397a7ad0.tar.bz2
volse-hubzilla-94f15e355166f0abd3698414948abff2397a7ad0.zip
The rest of the library and backend changes to support client-side e2ee and deprecate previous uses of item_obscured.
Diffstat (limited to 'include')
-rwxr-xr-xinclude/items.php35
-rw-r--r--include/text.php15
2 files changed, 10 insertions, 40 deletions
diff --git a/include/items.php b/include/items.php
index f290b5ec1..c71e8011d 100755
--- a/include/items.php
+++ b/include/items.php
@@ -605,6 +605,9 @@ function get_item_elements($x,$allow_code = false) {
if(in_array('notshown',$x['flags']))
$arr['item_notshown'] = 1;
+ if(in_array('obscured',$x['flags']))
+ $arr['item_obscured'] = 1;
+
// hidden item are no longer propagated - notshown may be a suitable alternative
if(in_array('hidden',$x['flags']))
@@ -707,7 +710,7 @@ function get_item_elements($x,$allow_code = false) {
// local only $arr['item_relay'] = $x['item_relay'];
$arr['item_mentionsme'] = $x['item_mentionsme'];
$arr['item_nocomment'] = $x['item_nocomment'];
- // local only $arr['item_obscured'] = $x['item_obscured'];
+ $arr['item_obscured'] = $x['item_obscured'];
// local only $arr['item_verified'] = $x['item_verified'];
$arr['item_retained'] = $x['item_retained'];
$arr['item_rss'] = $x['item_rss'];
@@ -955,13 +958,6 @@ function encode_item($item,$mirror = false) {
$key = get_config('system','prvkey');
- if(array_key_exists('item_obscured',$item) && intval($item['item_obscured'])) {
- if($item['title'])
- $item['title'] = crypto_unencapsulate(json_decode($item['title'],true),$key);
- if($item['body'])
- $item['body'] = crypto_unencapsulate(json_decode($item['body'],true),$key);
- }
-
// If we're trying to backup an item so that it's recoverable or for export/imprt,
// add all the attributes we need to recover it
@@ -1309,7 +1305,9 @@ function encode_item_flags($item) {
$ret[] = 'nsfw';
if(intval($item['item_consensus']))
$ret[] = 'consensus';
- if(intval($item['item_private']))
+ if(intval($item['item_obscured']))
+ $ret[] = 'obscured';
+ if(intval($item['item_privat']))
$ret[] = 'private';
return $ret;
@@ -2479,15 +2477,7 @@ function tag_deliver($uid, $item_id) {
// Now let's check if this mention was inside a reshare so we don't spam a forum
// If it's private we may have to unobscure it momentarily so that we can parse it.
- $body = '';
-
- if(intval($item['item_obscured'])) {
- $key = get_config('system','prvkey');
- if($item['body'])
- $body = crypto_unencapsulate(json_decode($item['body'],true),$key);
- }
- else
- $body = $item['body'];
+ $body = $item['body'];
$body = preg_replace('/\[share(.*?)\[\/share\]/','',$body);
@@ -2638,11 +2628,6 @@ function tgroup_check($uid,$item) {
$body = $item['body'];
- if(array_key_exists('item_obscured',$item) && intval($item['item_obscured']) && $body) {
- $key = get_config('system','prvkey');
- $body = crypto_unencapsulate(json_decode($body,true),$key);
- }
-
$body = preg_replace('/\[share(.*?)\[\/share\]/','',$body);
// $pattern = '/@\!?\[zrl\=' . preg_quote($term['url'],'/') . '\]' . preg_quote($term['term'] . '+','/') . '\[\/zrl\]/';
@@ -2736,7 +2721,6 @@ function start_delivery_chain($channel, $item, $item_id, $parent) {
$item_origin = 1;
$item_uplink = 0;
$item_nocomment = 0;
- $item_obscured = 0;
$flag_bits = $item['item_flags'];
@@ -2759,11 +2743,10 @@ function start_delivery_chain($channel, $item, $item_id, $parent) {
$title = $item['title'];
$body = $item['body'];
- $r = q("update item set item_uplink = %d, item_nocomment = %d, item_obscured = %d, item_flags = %d, owner_xchan = '%s', allow_cid = '%s', allow_gid = '%s',
+ $r = q("update item set item_uplink = %d, item_nocomment = %d, item_flags = %d, owner_xchan = '%s', allow_cid = '%s', allow_gid = '%s',
deny_cid = '%s', deny_gid = '%s', item_private = %d, public_policy = '%s', comment_policy = '%s', title = '%s', body = '%s', item_wall = %d, item_origin = %d where id = %d",
intval($item_uplink),
intval($item_nocomment),
- intval($item_obscured),
intval($flag_bits),
dbesc($channel['channel_hash']),
dbesc($channel['channel_allow_cid']),
diff --git a/include/text.php b/include/text.php
index d276595ae..1a4e2b223 100644
--- a/include/text.php
+++ b/include/text.php
@@ -1372,20 +1372,7 @@ function link_compare($a, $b) {
function unobscure(&$item) {
- if(array_key_exists('item_obscured',$item) && intval($item['item_obscured'])) {
- $key = get_config('system','prvkey');
- if($item['title'])
- $item['title'] = crypto_unencapsulate(json_decode($item['title'],true),$key);
- if($item['body'])
- $item['body'] = crypto_unencapsulate(json_decode($item['body'],true),$key);
- if(get_config('system','item_cache')) {
- q("update item set title = '%s', body = '%s', item_obscured = 0 where id = %d",
- dbesc($item['title']),
- dbesc($item['body']),
- intval($item['id'])
- );
- }
- }
+ return;
}
function unobscure_mail(&$item) {