From 79b4642b32b441e8b2d7924577af59c1c15ee092 Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 21 May 2021 06:44:15 +0000 Subject: introduce the direct flag for direct messages --- include/items.php | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'include/items.php') diff --git a/include/items.php b/include/items.php index 30129b0aa..7be3d5286 100644 --- a/include/items.php +++ b/include/items.php @@ -702,7 +702,6 @@ function get_item_elements($x,$allow_code = false) { $arr['mid'] = (($x['message_id']) ? htmlspecialchars($x['message_id'], ENT_COMPAT,'UTF-8',false) : ''); $arr['parent_mid'] = (($x['message_top']) ? htmlspecialchars($x['message_top'], ENT_COMPAT,'UTF-8',false) : ''); $arr['thr_parent'] = (($x['message_parent']) ? htmlspecialchars($x['message_parent'], ENT_COMPAT,'UTF-8',false) : ''); - $arr['plink'] = (($x['permalink']) ? htmlspecialchars($x['permalink'], ENT_COMPAT,'UTF-8',false) : ''); $arr['location'] = (($x['location']) ? htmlspecialchars($x['location'], ENT_COMPAT,'UTF-8',false) : ''); $arr['coord'] = (($x['longlat']) ? htmlspecialchars($x['longlat'], ENT_COMPAT,'UTF-8',false) : ''); @@ -718,18 +717,12 @@ function get_item_elements($x,$allow_code = false) { $arr['comment_policy'] = (($x['comment_scope']) ? htmlspecialchars($x['comment_scope'], ENT_COMPAT,'UTF-8',false) : 'contacts'); $arr['sig'] = (($x['signature']) ? htmlspecialchars($x['signature'], ENT_COMPAT,'UTF-8',false) : ''); - $arr['obj'] = activity_sanitise($x['object']); $arr['target'] = activity_sanitise($x['target']); - $arr['attach'] = activity_sanitise($x['attach']); $arr['term'] = decode_tags($x['tags']); $arr['iconfig'] = decode_item_meta($x['meta']); - - $private_state = (($x['allow_cid'] && !$x['allow_gid']) ? 2 : 1); - $arr['item_private'] = ((array_key_exists('flags',$x) && is_array($x['flags']) && in_array('private',$x['flags'])) ? $private_state : 0); - - $arr['item_flags'] = 0; + $arr['item_flags'] = 0; if(array_key_exists('flags',$x)) { @@ -750,6 +743,12 @@ function get_item_elements($x,$allow_code = false) { if(in_array('hidden',$x['flags'])) $arr['item_hidden'] = 1; + if(in_array('private', $x['flags'])) + $arr['item_private'] = 1; + + if(in_array('private', $x['flags']) && in_array('direct', $x['flags'])) + $arr['item_private'] = 2; + } // Here's the deal - the site might be down or whatever but if there's a new person you've never @@ -1337,7 +1336,13 @@ function encode_item_xchan($xchan) { $ret['id_sig'] = $xchan['xchan_guid_sig']; $ret['key'] = $xchan['xchan_pubkey']; - return $ret; + $hookdata = [ + 'encoded_xchan' => $ret + ]; + + call_hooks('encode_item_xchan', $hookdata); + + return $hookdata['encoded_xchan']; } function encode_item_terms($terms,$mirror = false) { @@ -1552,6 +1557,8 @@ function encode_item_flags($item) { $ret[] = 'obscured'; if(intval($item['item_private'])) $ret[] = 'private'; + if(intval($item['item_private']) === 2) + $ret[] = 'direct'; return $ret; } -- cgit v1.2.3