aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2015-01-22 18:41:10 -0800
committerfriendica <info@friendica.com>2015-01-22 18:41:10 -0800
commit6e0e3b2433fc426b758a55811f56536d58705813 (patch)
treea8d8fb7c63216cea94765e93be935f2b9d2fe227
parente46eba125888704b4381aa8418495e91eeb565c8 (diff)
downloadvolse-hubzilla-6e0e3b2433fc426b758a55811f56536d58705813.tar.gz
volse-hubzilla-6e0e3b2433fc426b758a55811f56536d58705813.tar.bz2
volse-hubzilla-6e0e3b2433fc426b758a55811f56536d58705813.zip
more expanding item flags
-rwxr-xr-xboot.php21
-rw-r--r--include/bb2diaspora.php2
-rw-r--r--include/conversation.php15
-rwxr-xr-xinclude/diaspora.php2
-rw-r--r--include/enotify.php2
-rwxr-xr-xinclude/items.php46
-rw-r--r--include/text.php2
-rw-r--r--mod/editpost.php2
-rw-r--r--mod/editwebpage.php2
-rw-r--r--mod/filer.php3
-rw-r--r--mod/item.php9
-rw-r--r--mod/viewsrc.php4
12 files changed, 37 insertions, 73 deletions
diff --git a/boot.php b/boot.php
index 9544f70af..c52c1bc32 100755
--- a/boot.php
+++ b/boot.php
@@ -531,27 +531,6 @@ define ( 'ITEM_BUILDBLOCK', 0x0100); // Named thusly to make sure nobody co
define ( 'ITEM_PDL', 0x0200); // Page Description Language - e.g. Comanche
define ( 'ITEM_BUG', 0x0400); // Is a bug, can be used by the internal bug tracker
define ( 'ITEM_PENDING_REMOVE', 0x0800); // deleted, notification period has lapsed
-
-/**
- * Item Flags
- */
-
-//define ( 'ITEM_ORIGIN', 0x0001);
-//define ( 'ITEM_UNSEEN', 0x0002);
-//define ( 'ITEM_STARRED', 0x0004);
-//define ( 'ITEM_UPLINK', 0x0008);
-//define ( 'ITEM_CONSENSUS', 0x0010); // an item which may present agree/disagree/abstain options
-//define ( 'ITEM_WALL', 0x0020);
-//define ( 'ITEM_THREAD_TOP', 0x0040);
-//define ( 'ITEM_NOTSHOWN', 0x0080); // technically visible but not normally shown (e.g. like/dislike)
-//define ( 'ITEM_NSFW', 0x0100);
-//define ( 'ITEM_RELAY', 0x0200); // used only in the communication layers, not stored
-//define ( 'ITEM_MENTIONSME', 0x0400);
-//define ( 'ITEM_NOCOMMENT', 0x0800); // commenting/followups are disabled
-define ( 'ITEM_OBSCURED', 0x1000); // bit-mangled to protect from casual browsing by site admin
-define ( 'ITEM_VERIFIED', 0x2000); // Signature verification was successful
-define ( 'ITEM_RETAINED', 0x4000); // We looked at this item once to decide whether or not to expire it, and decided not to.
-define ( 'ITEM_RSS', 0x8000); // Item comes from a feed. Use this to decide whether to link the title
// Don't make us evaluate this same item again.
define ( 'DBTYPE_MYSQL', 0 );
diff --git a/include/bb2diaspora.php b/include/bb2diaspora.php
index e8f81aec4..5b675128f 100644
--- a/include/bb2diaspora.php
+++ b/include/bb2diaspora.php
@@ -304,7 +304,7 @@ function bb2diaspora_itembody($item,$force_update = false) {
$newitem = $item;
- if(array_key_exists('item_flags',$item) && ($item['item_flags'] & ITEM_OBSCURED)) {
+ if(array_key_exists('item_obscured',$item) && intval($item['item_obscured'])) {
$key = get_config('system','prvkey');
$b = json_decode($item['body'],true);
// if called from diaspora_process_outbound, this decoding has already been done.
diff --git a/include/conversation.php b/include/conversation.php
index e81bb49e0..5a9e4a59e 100644
--- a/include/conversation.php
+++ b/include/conversation.php
@@ -357,21 +357,12 @@ function localize_item(&$item){
}
}
*/
- // add sparkle links to appropriate permalinks
-
-// $x = stristr($item['plink'],'/display/');
-// if($x) {
-// $sparkle = false;
-// $y = best_link_url($item,$sparkle,true);
- // if($sparkle)
-// $item['plink'] = $y . '?f=&url=' . $item['plink'];
-// }
// if item body was obscured and we changed it, re-obscure it
// FIXME - we need a better filter than just the string 'data'; try and
// match the fact that it's json encoded
- if(($item['item_flags'] & ITEM_OBSCURED)
+ if(intval($item['item_obscured'])
&& strlen($item['body']) && (! strpos($item['body'],'data'))) {
$item['body'] = json_encode(crypto_encapsulate($item['body'],get_config('system','pubkey')));
}
@@ -655,8 +646,8 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional', $
$likebuttons = false;
$shareable = false;
- $verified = (($item['item_flags'] & ITEM_VERIFIED) ? t('Message signature validated') : '');
- $forged = ((($item['sig']) && (! ($item['item_flags'] & ITEM_VERIFIED))) ? t('Message signature incorrect') : '');
+ $verified = (intval($item['item_verified']) ? t('Message signature validated') : '');
+ $forged = ((($item['sig']) && (! intval($item['item_verified']))) ? t('Message signature incorrect') : '');
$unverified = '';
diff --git a/include/diaspora.php b/include/diaspora.php
index 4e7b968e7..b9c6e5c92 100755
--- a/include/diaspora.php
+++ b/include/diaspora.php
@@ -157,7 +157,7 @@ function diaspora_process_outbound($arr) {
$target_item = $arr['target_item'];
- if($target_item && array_key_exists('item_flags',$target_item) && ($target_item['item_flags'] & ITEM_OBSCURED)) {
+ if($target_item && array_key_exists('item_obscured',$target_item) && intval($target_item['item_obscured'])) {
$key = get_config('system','prvkey');
if($target_item['title'])
$target_item['title'] = crypto_unencapsulate(json_decode($target_item['title'],true),$key);
diff --git a/include/enotify.php b/include/enotify.php
index 53f1ae5ef..34552cc36 100644
--- a/include/enotify.php
+++ b/include/enotify.php
@@ -65,7 +65,7 @@ function notification($params) {
localize_item($i);
$title = $i['title'];
$body = $i['body'];
- $private = (($i['item_private']) || ($i['item_flags'] & ITEM_OBSCURED));
+ $private = (($i['item_private']) || intval($i['item_obscured']));
}
else {
$title = $params['item']['title'];
diff --git a/include/items.php b/include/items.php
index 2478d773c..43739b605 100755
--- a/include/items.php
+++ b/include/items.php
@@ -396,13 +396,13 @@ function post_activity_item($arr) {
if($channel) {
if($channel['channel_hash'] === $arr['author_xchan']) {
$arr['sig'] = base64url_encode(rsa_sign($arr['body'],$channel['channel_prvkey']));
- $arr['item_flags'] = $arr['item_flags'] | ITEM_VERIFIED;
+ $arr['item_verified'] = 1;
}
}
logger('Encrypting local storage');
$key = get_config('system','pubkey');
- $arr['item_flags'] = $arr['item_flags'] | ITEM_OBSCURED;
+ $arr['item_obscured'] = 1;
if($arr['title'])
$arr['title'] = json_encode(crypto_encapsulate($arr['title'],$key));
if($arr['body'])
@@ -870,7 +870,7 @@ function get_item_elements($x) {
dbesc($arr['author_xchan'])
);
if($r && rsa_verify($x['body'],base64url_decode($arr['sig']),$r[0]['xchan_pubkey']))
- $arr['item_flags'] |= ITEM_VERIFIED;
+ $arr['item_verified'] = 1;
else
logger('get_item_elements: message verification failed.');
}
@@ -883,7 +883,7 @@ function get_item_elements($x) {
if(intval($arr['item_private'])) {
- $arr['item_flags'] = $arr['item_flags'] | ITEM_OBSCURED;
+ $arr['item_obscured'] = 1;
if($arr['title'])
$arr['title'] = json_encode(crypto_encapsulate($arr['title'],$key));
if($arr['body'])
@@ -1066,7 +1066,7 @@ function encode_item($item,$mirror = false) {
$key = get_config('system','prvkey');
- if(array_key_exists('item_flags',$item) && ($item['item_flags'] & ITEM_OBSCURED)) {
+ if(array_key_exists('item_obscured',$item) && intval($item['item_obscured'])) {
if($item['title'])
$item['title'] = crypto_unencapsulate(json_decode_plus($item['title']),$key);
if($item['body'])
@@ -1475,7 +1475,7 @@ function get_atom_elements($feed,$item,&$author) {
$res['title'] = unxmlify($item->get_title());
$res['body'] = unxmlify($item->get_content());
$res['plink'] = unxmlify($item->get_link(0));
- $res['item_flags'] = ITEM_RSS;
+ $res['item_rss'] = 1;
// removing the content of the title if its identically to the body
@@ -1956,7 +1956,7 @@ function item_store($arr,$allow_exec = false) {
// only detect language if we have text content, and if the post is private but not yet
// obscured, make it so.
- if(! ($arr['item_flags'] & ITEM_OBSCURED)) {
+ if((! array_key_exists('item_obscured',$arr)) || $arr['item_obscured'] == 0) {
$arr['lang'] = detect_language($arr['body']);
// apply the input filter here - if it is obscured it has been filtered already
@@ -1967,7 +1967,7 @@ function item_store($arr,$allow_exec = false) {
$channel = get_app()->get_channel();
if($channel['channel_hash'] === $arr['author_xchan']) {
$arr['sig'] = base64url_encode(rsa_sign($arr['body'],$channel['channel_prvkey']));
- $arr['item_flags'] |= ITEM_VERIFIED;
+ $arr['item_verified'] = 1;
}
}
@@ -1985,7 +1985,7 @@ function item_store($arr,$allow_exec = false) {
}
if($arr['item_private']) {
$key = get_config('system','pubkey');
- $arr['item_flags'] = $arr['item_flags'] | ITEM_OBSCURED;
+ $arr['item_obscured'] = 1;
if($arr['title'])
$arr['title'] = json_encode(crypto_encapsulate($arr['title'],$key));
if($arr['body'])
@@ -2349,7 +2349,7 @@ function item_store_update($arr,$allow_exec = false) {
return $ret;
}
- if(! ($arr['item_flags'] & ITEM_OBSCURED)) {
+ if((! array_key_exists('item_obscured', $arr)) || $arr['item_obscured'] == 0) {
$arr['lang'] = detect_language($arr['body']);
// apply the input filter here - if it is obscured it has been filtered already
@@ -2377,7 +2377,7 @@ function item_store_update($arr,$allow_exec = false) {
}
if($arr['item_private']) {
$key = get_config('system','pubkey');
- $arr['item_flags'] = $arr['item_flags'] | ITEM_OBSCURED;
+ $arr['item_obscured'] = 1;
if($arr['title'])
$arr['title'] = json_encode(crypto_encapsulate($arr['title'],$key));
if($arr['body'])
@@ -2834,7 +2834,7 @@ function tag_deliver($uid,$item_id) {
$body = '';
- if($item['item_flags'] & ITEM_OBSCURED) {
+ if(intval($item['item_obscured'])) {
$key = get_config('system','prvkey');
if($item['body'])
$body = crypto_unencapsulate(json_decode_plus($item['body']),$key);
@@ -2981,7 +2981,7 @@ function tgroup_check($uid,$item) {
$body = $item['body'];
- if(array_key_exists('item_flags',$item) && ($item['item_flags'] & ITEM_OBSCURED) && $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);
}
@@ -3025,6 +3025,7 @@ 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'];
@@ -3048,30 +3049,31 @@ function start_delivery_chain($channel,$item,$item_id,$parent) {
$body = $item['body'];
if($private) {
- if(!($flag_bits & ITEM_OBSCURED)) {
+ if(! intval($item['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));
+ $item_obscured = 1;
}
}
else {
- if($flag_bits & ITEM_OBSCURED) {
+ if(intval($item['item_obscured'])) {
$key = get_config('system','prvkey');
- $flag_bits = $flag_bits ^ ITEM_OBSCURED;
if($title)
$title = crypto_unencapsulate(json_decode($title,true),$key);
if($body)
$body = crypto_unencapsulate(json_decode($body,true),$key);
+ $item_obscured = 0;
}
}
- $r = q("update item set item_uplink = %d, item_nocomment = %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_obscured = %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']),
@@ -3860,11 +3862,10 @@ function item_expire($uid,$days) {
AND `created` < %s - INTERVAL %s
AND `id` = `parent`
$sql_extra
- AND NOT ( item_flags & %d )>0
+ AND item_retained = 0
AND (item_restrict = 0 ) ",
intval($uid),
- db_utcnow(), db_quoteinterval(intval($days).' DAY'),
- intval(ITEM_RETAINED)
+ db_utcnow(), db_quoteinterval(intval($days).' DAY')
);
if(! $r)
@@ -3901,8 +3902,7 @@ function item_expire($uid,$days) {
}
function retain_item($id) {
- $r = q("update item set item_flags = (item_flags | %d ) where id = %d",
- intval(ITEM_RETAINED),
+ $r = q("update item set item_retained = 1 where id = %d",
intval($id)
);
}
diff --git a/include/text.php b/include/text.php
index 720895810..101d6ca2e 100644
--- a/include/text.php
+++ b/include/text.php
@@ -1152,7 +1152,7 @@ function link_compare($a,$b) {
function unobscure(&$item) {
- if(array_key_exists('item_flags',$item) && ($item['item_flags'] & ITEM_OBSCURED)) {
+ 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_plus($item['title']),$key);
diff --git a/mod/editpost.php b/mod/editpost.php
index dfbc8766e..4ea0c9f2b 100644
--- a/mod/editpost.php
+++ b/mod/editpost.php
@@ -55,7 +55,7 @@ function editpost_content(&$a) {
- if($itm[0]['item_flags'] & ITEM_OBSCURED) {
+ if(intval($itm[0]['item_obscured'])) {
$key = get_config('system','prvkey');
if($itm[0]['title'])
$itm[0]['title'] = crypto_unencapsulate(json_decode_plus($itm[0]['title']),$key);
diff --git a/mod/editwebpage.php b/mod/editwebpage.php
index 191c9a9ac..d7969fb2d 100644
--- a/mod/editwebpage.php
+++ b/mod/editwebpage.php
@@ -95,7 +95,7 @@ function editwebpage_content(&$a) {
intval($owner)
);
- if($itm[0]['item_flags'] & ITEM_OBSCURED) {
+ if(intval($itm[0]['item_obscured'])) {
$key = get_config('system','prvkey');
if($itm[0]['title'])
$itm[0]['title'] = crypto_unencapsulate(json_decode_plus($itm[0]['title']),$key);
diff --git a/mod/filer.php b/mod/filer.php
index 9a409177c..e243687e3 100644
--- a/mod/filer.php
+++ b/mod/filer.php
@@ -27,8 +27,7 @@ function filer_content(&$a) {
intval(local_user())
);
if($r) {
- $x = q("update item set item_flags = ( item_flags | %d ) where id = %d and uid = %d",
- intval(ITEM_RETAINED),
+ $x = q("update item set item_retained = 1 where id = %d and uid = %d",
intval($r[0]['parent']),
intval(local_user())
);
diff --git a/mod/item.php b/mod/item.php
index a6ab99ef5..26985dea4 100644
--- a/mod/item.php
+++ b/mod/item.php
@@ -330,11 +330,6 @@ function item_post(&$a) {
$body = $_REQUEST['body'];
$item_flags = $orig_post['item_flags'];
- // force us to recalculate if we need to obscure this post
-
- if($item_flags & ITEM_OBSCURED)
- $item_flags = ($item_flags ^ ITEM_OBSCURED);
-
$item_restrict = $orig_post['item_restrict'];
$postopts = $orig_post['postopts'];
$created = $orig_post['created'];
@@ -765,13 +760,13 @@ function item_post(&$a) {
if($uid) {
if($channel['channel_hash'] === $datarray['author_xchan']) {
$datarray['sig'] = base64url_encode(rsa_sign($datarray['body'],$channel['channel_prvkey']));
- $datarray['item_flags'] = $datarray['item_flags'] | ITEM_VERIFIED;
+ $datarray['item_verified'] = 1;
}
}
logger('Encrypting local storage');
$key = get_config('system','pubkey');
- $datarray['item_flags'] = $datarray['item_flags'] | ITEM_OBSCURED;
+ $datarray['item_obscured'] = 1;
if($datarray['title'])
$datarray['title'] = json_encode(crypto_encapsulate($datarray['title'],$key));
if($datarray['body'])
diff --git a/mod/viewsrc.php b/mod/viewsrc.php
index 982d1c417..83acb1c23 100644
--- a/mod/viewsrc.php
+++ b/mod/viewsrc.php
@@ -21,14 +21,14 @@ function viewsrc_content(&$a) {
}
if(local_user() && $item_id) {
- $r = q("select item_flags, body from item where item_restrict = 0 and uid in (%d , %d) and id = %d limit 1",
+ $r = q("select id, item_flags, item_obscured, body from item where item_restrict = 0 and uid in (%d , %d) and id = %d limit 1",
intval(local_user()),
intval($sys['channel_id']),
intval($item_id)
);
if($r) {
- if($r[0]['item_flags'] & ITEM_OBSCURED)
+ if(intval($r[0]['item_obscured']))
$r[0]['body'] = crypto_unencapsulate(json_decode($r[0]['body'],true),get_config('system','prvkey'));
$o = (($json) ? json_encode($r[0]['body']) : str_replace("\n",'<br />',$r[0]['body']));
}