From 1fa4bc9ac024983d4748262f98c6ddf323ad327c Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 26 May 2021 12:18:59 +0000 Subject: remove most legacy zot quirks --- include/bookmarks.php | 2 +- include/channel.php | 60 ++++-------------------------------------------- include/connections.php | 2 +- include/conversation.php | 2 -- include/import.php | 2 +- include/items.php | 2 +- include/network.php | 25 -------------------- include/permissions.php | 4 ++-- include/socgraph.php | 40 +++++++++++--------------------- include/text.php | 2 +- include/xchan.php | 7 ------ include/zid.php | 2 +- 12 files changed, 26 insertions(+), 124 deletions(-) (limited to 'include') diff --git a/include/bookmarks.php b/include/bookmarks.php index 207cf5a33..95043ae89 100644 --- a/include/bookmarks.php +++ b/include/bookmarks.php @@ -68,7 +68,7 @@ function bookmark_add($channel,$sender,$taxonomy,$private,$opts = null) { function get_bookmark_link($observer) { - if((! $observer) || !in_array($observer['xchan_network'], ['zot6', 'zot'])) + if(!$observer || $observer['xchan_network'] !== 'zot6') return ''; $h = @parse_url($observer['xchan_url']); diff --git a/include/channel.php b/include/channel.php index 804d8c63a..085aa5ea5 100644 --- a/include/channel.php +++ b/include/channel.php @@ -275,7 +275,7 @@ function create_identity($arr) { 'channel_guid' => $guid, 'channel_guid_sig' => $sig, 'channel_hash' => $hash, - 'channel_portable_id' => $zhash, + 'channel_portable_id' => '', 'channel_prvkey' => $key['prvkey'], 'channel_pubkey' => $key['pubkey'], 'channel_pageflags' => intval($pageflags), @@ -337,26 +337,6 @@ function create_identity($arr) { // Create a verified hub location pointing to this site. - $r = hubloc_store_lowlevel( - [ - 'hubloc_guid' => $guid, - 'hubloc_guid_sig' => $zsig, - 'hubloc_hash' => $zhash, - 'hubloc_id_url' => channel_url($ret['channel']), - 'hubloc_addr' => channel_reddress($ret['channel']), - 'hubloc_primary' => intval($primary), - 'hubloc_url' => z_root(), - 'hubloc_url_sig' => base64url_encode(Crypto::sign(z_root(),$ret['channel']['channel_prvkey'])), - 'hubloc_host' => App::get_hostname(), - 'hubloc_callback' => z_root() . '/post', - 'hubloc_sitekey' => get_config('system','pubkey'), - 'hubloc_network' => 'zot', - 'hubloc_updated' => datetime_convert() - ] - ); - if(! $r) - logger('Unable to store hub location (zot)'); - $r = hubloc_store_lowlevel( [ 'hubloc_guid' => $guid, @@ -381,30 +361,6 @@ function create_identity($arr) { $newuid = $ret['channel']['channel_id']; - $r = xchan_store_lowlevel( - [ - 'xchan_hash' => $zhash, - 'xchan_guid' => $guid, - 'xchan_guid_sig' => $zsig, - 'xchan_pubkey' => $key['pubkey'], - 'xchan_photo_mimetype' => (($photo_type) ? $photo_type : 'image/png'), - 'xchan_photo_l' => z_root() . "/photo/profile/l/{$newuid}", - 'xchan_photo_m' => z_root() . "/photo/profile/m/{$newuid}", - 'xchan_photo_s' => z_root() . "/photo/profile/s/{$newuid}", - 'xchan_addr' => channel_reddress($ret['channel']), - 'xchan_url' => z_root() . '/channel/' . $ret['channel']['channel_address'], - 'xchan_follow' => z_root() . '/follow?f=&url=%s', - 'xchan_connurl' => z_root() . '/poco/' . $ret['channel']['channel_address'], - 'xchan_name' => $ret['channel']['channel_name'], - 'xchan_network' => 'zot', - 'xchan_photo_date' => datetime_convert(), - 'xchan_name_date' => datetime_convert(), - 'xchan_system' => $system - ] - ); - if(! $r) - logger('Unable to store xchan (zot)'); - $r = xchan_store_lowlevel( [ 'xchan_hash' => $hash, @@ -981,12 +937,6 @@ function identity_basic_export($channel_id, $sections = null, $zap_compat = fals } - // pick up the zot xchan and hublocs also - - if($ret['channel']['channel_portable_id'] && ! $zot_compat) { - $xchans[] = $ret['channel']['channel_portable_id']; - } - stringify_array_elms($xchans); } @@ -2936,9 +2886,8 @@ function channel_remove($channel_id, $local = true, $unset_session = false) { logger('deleting hublocs',LOGGER_DEBUG); - $r = q("UPDATE hubloc SET hubloc_deleted = 1 WHERE (hubloc_hash = '%s' OR hubloc_hash = '%s') AND hubloc_url = '%s' ", + $r = q("UPDATE hubloc SET hubloc_deleted = 1 WHERE hubloc_hash = '%s' AND hubloc_url = '%s' ", dbesc($channel['channel_hash']), - dbesc($channel['channel_portable_id']), dbesc(z_root()) ); @@ -2953,9 +2902,8 @@ function channel_remove($channel_id, $local = true, $unset_session = false) { $hublocs = count($r); if(! $hublocs) { - $r = q("UPDATE xchan SET xchan_deleted = 1 WHERE xchan_hash = '%s' OR xchan_hash = '%s'", - dbesc($channel['channel_hash']), - dbesc($channel['channel_portable_id']) + $r = q("UPDATE xchan SET xchan_deleted = 1 WHERE xchan_hash = '%s'", + dbesc($channel['channel_hash']) ); } diff --git a/include/connections.php b/include/connections.php index 87db7faa9..a1b27e301 100644 --- a/include/connections.php +++ b/include/connections.php @@ -212,7 +212,7 @@ function mark_orphan_hubsxchans() { return; $r = q("UPDATE hubloc SET hubloc_error = 1 WHERE hubloc_error = 0 - AND hubloc_network IN ('zot6', 'zot') AND hubloc_connected < %s - INTERVAL %s", + AND hubloc_network = 'zot6' AND hubloc_connected < %s - INTERVAL %s", db_utcnow(), db_quoteinterval('36 day') ); diff --git a/include/conversation.php b/include/conversation.php index 04aa1ef5a..9fc70c511 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -1022,8 +1022,6 @@ function author_is_pmable($xchan, $abook) { if($x['result'] !== 'unset') return $x['result']; - if($xchan['xchan_network'] === 'zot' && get_observer_hash()) - return true; return false; } diff --git a/include/import.php b/include/import.php index 379789109..022440676 100644 --- a/include/import.php +++ b/include/import.php @@ -778,7 +778,7 @@ function sync_items($channel, $items, $relocate = null) { // to avoid confusing with cloned channels $size = count($items); for($i = 0; $i < $size; $i++) { - if(($items[$i]['owner']['network'] != 'zot') && ($items[$i]['owner']['network'] != 'zot6')) { + if($items[$i]['owner']['network'] !== 'zot6') { $r = q("SELECT * FROM abook WHERE abook_channel = %d AND abook_xchan = ( SELECT xchan_hash FROM xchan WHERE xchan_guid = '%s' LIMIT 1 ) AND abook_not_here = 0 AND abook_ignored = 0 AND abook_blocked = 0", diff --git a/include/items.php b/include/items.php index a45a266a7..2ee259e51 100644 --- a/include/items.php +++ b/include/items.php @@ -132,7 +132,7 @@ function collect_recipients($item, &$private_envelope,$include_groups = true) { case 'sit': case 'any': case 'con': - if(!in_array($rr['xchan_network'], ['zot6', 'zot'])) + if($rr['xchan_network'] !== 'zot6') break; case 'pub': case '': diff --git a/include/network.php b/include/network.php index 77b7c49d6..194b50885 100644 --- a/include/network.php +++ b/include/network.php @@ -1159,31 +1159,6 @@ function discover_by_webbie($webbie, $protocol = '') { } } } - - foreach($x['links'] as $link) { - if(array_key_exists('rel',$link)) { - - // If we discover zot - don't search further; grab the info and get out of - // here. - - if($link['rel'] === PROTOCOL_ZOT && ((! $protocol) || (strtolower($protocol) === 'zot'))) { - logger('zot found for ' . $webbie, LOGGER_DEBUG); - if(array_key_exists('zot',$x) && $x['zot']['success']) { - $i = import_xchan($x['zot']); - return true; - } - else { - $z = z_fetch_url($link['href']); - if($z['success']) { - $j = json_decode($z['body'],true); - $i = import_xchan($j); - return true; - } - } - } - } - } - } logger('webfinger: ' . print_r($x,true), LOGGER_DATA, LOG_INFO); diff --git a/include/permissions.php b/include/permissions.php index 9dd503132..33b385490 100644 --- a/include/permissions.php +++ b/include/permissions.php @@ -157,7 +157,7 @@ function get_all_perms($uid, $observer_xchan, $check_siteblock = true, $default_ // If we're still here, we have an observer, check the network. if($channel_perm & PERMS_NETWORK) { - if($x && in_array($x[0]['xchan_network'],[ 'zot','zot6'])) { + if($x && $x[0]['xchan_network'] === 'zot6') { $ret[$perm_name] = true; continue; } @@ -366,7 +366,7 @@ function perm_is_allowed($uid, $observer_xchan, $permission, $check_siteblock = // If we're still here, we have an observer, check the network. if($channel_perm & PERMS_NETWORK) { - if ($x && in_array($x[0]['xchan_network'], ['zot','zot6'])) + if ($x && $x[0]['xchan_network'] === 'zot6') return true; } diff --git a/include/socgraph.php b/include/socgraph.php index aaea4550c..03681ff57 100644 --- a/include/socgraph.php +++ b/include/socgraph.php @@ -24,7 +24,7 @@ require_once('include/zot.php'); * * Once the global contact is stored add (if necessary) the contact linkage which associates * the given uid, cid to the global contact entry. There can be many uid/cid combinations - * pointing to the same global contact id. + * pointing to the same global contact id. * * @param string $xchan * @param string $url @@ -127,14 +127,14 @@ function poco_load($xchan = '', $url = null) { $profile_url = $url['value']; continue; } - if(in_array($url['type'], ['zot','zot6'] )) { + if($url['type'] === 'zot6') { $network = $url['type']; $address = str_replace('acct:' , '', $url['value']); continue; } } } - if(x($entry,'photos') && is_array($entry['photos'])) { + if(x($entry,'photos') && is_array($entry['photos'])) { foreach($entry['photos'] as $photo) { if($photo['type'] == 'profile') { $profile_photo = $photo['value']; @@ -145,7 +145,7 @@ function poco_load($xchan = '', $url = null) { if((! $name) || (! $profile_url) || (! $profile_photo) || (! $hash) || (! $address)) { logger('poco_load: missing data'); - continue; + continue; } $x = q("select xchan_hash from xchan where xchan_hash = '%s' limit 1", @@ -168,18 +168,6 @@ function poco_load($xchan = '', $url = null) { continue; } } - if($network === 'zot') { - $j = Zotlabs\Zot\Finger::run($address,null); - if($j['success']) { - import_xchan($j); - } - $x = q("select xchan_hash from xchan where xchan_hash = '%s' limit 1", - dbesc($hash) - ); - if(! $x) { - continue; - } - } } else { continue; @@ -242,7 +230,7 @@ function common_friends($uid,$xchan,$start = 0,$limit=100000000,$shuffle = false if($shuffle) $sql_extra = " order by $rand "; else - $sql_extra = " order by xchan_name asc "; + $sql_extra = " order by xchan_name asc "; $r = q("SELECT * from xchan left join xlink on xlink_link = xchan_hash where xlink_xchan = '%s' and xlink_static = 0 and xlink_link in (select abook_xchan from abook where abook_xchan != '%s' and abook_channel = %d and abook_self = 0 ) $sql_extra limit %d offset %d", @@ -329,8 +317,8 @@ function update_suggestions() { if($ret['success']) { // We will grab fresh data once a day via the poller. Remove anything over a week old because - // the targets may have changed their preferences and don't want to be suggested - and they - // may have simply gone away. + // the targets may have changed their preferences and don't want to be suggested - and they + // may have simply gone away. $r = q("delete from xlink where xlink_xchan = '' and xlink_updated < %s - INTERVAL %s and xlink_static = 0", db_utcnow(), db_quoteinterval('7 DAY') @@ -413,11 +401,11 @@ function poco($a,$extended = false) { $sql_extra = sprintf(" and abook_id = %d and abook_hidden = 0 and abook_pending = 0 ",intval($cid)); if($system_mode) { - $r = q("SELECT count(*) as total from abook where abook_self = 1 + $r = q("SELECT count(*) as total from abook where abook_self = 1 and abook_channel in (select uid from pconfig where cat = 'system' and k = 'suggestme' and v = '1') "); } else { - $r = q("SELECT count(*) as total from abook where abook_channel = %d + $r = q("SELECT count(*) as total from abook where abook_channel = %d $sql_extra ", intval($channel_id) ); @@ -437,14 +425,14 @@ function poco($a,$extended = false) { $itemsPerPage = ((x($_GET,'count') && intval($_GET['count'])) ? intval($_GET['count']) : $totalResults); if($system_mode) { - $r = q("SELECT abook.*, xchan.* from abook left join xchan on abook_xchan = xchan_hash where abook_self = 1 - and abook_channel in (select uid from pconfig where cat = 'system' and k = 'suggestme' and v = '1') + $r = q("SELECT abook.*, xchan.* from abook left join xchan on abook_xchan = xchan_hash where abook_self = 1 + and abook_channel in (select uid from pconfig where cat = 'system' and k = 'suggestme' and v = '1') limit %d offset %d ", intval($itemsPerPage), intval($startIndex) ); } else { - $r = q("SELECT abook.*, xchan.* from abook left join xchan on abook_xchan = xchan_hash where abook_channel = %d + $r = q("SELECT abook.*, xchan.* from abook left join xchan on abook_xchan = xchan_hash where abook_channel = %d $sql_extra LIMIT %d OFFSET %d", intval($channel_id), intval($itemsPerPage), @@ -513,7 +501,7 @@ function poco($a,$extended = false) { $entry['urls'] = array(array('value' => $rr['xchan_url'], 'type' => 'profile')); $network = $rr['xchan_network']; if($rr['xchan_addr']) - $entry['urls'][] = array('value' => 'acct:' . $rr['xchan_addr'], 'type' => $network); + $entry['urls'][] = array('value' => 'acct:' . $rr['xchan_addr'], 'type' => $network); } if($fields_ret['preferredUsername']) $entry['preferredUsername'] = substr($rr['xchan_addr'],0,strpos($rr['xchan_addr'],'@')); @@ -536,7 +524,7 @@ function poco($a,$extended = false) { if($format === 'json') { header('Content-type: application/json'); echo json_encode($ret); - killme(); + killme(); } else http_status_exit(500); diff --git a/include/text.php b/include/text.php index d2ab8bc72..35a65bcfb 100644 --- a/include/text.php +++ b/include/text.php @@ -2067,7 +2067,7 @@ function get_plink($item,$conversation_mode = true) { $zidify = true; - if(array_key_exists('author',$item) && in_array($item['author']['xchan_network'], ['zot6', 'zot']) === false) + if(array_key_exists('author',$item) && $item['author']['xchan_network'] !== 'zot6') $zidify = false; if(x($item,$key)) { diff --git a/include/xchan.php b/include/xchan.php index 07fdb8b47..a32064303 100644 --- a/include/xchan.php +++ b/include/xchan.php @@ -85,13 +85,6 @@ function xchan_store($arr) { } } - if($arr['network'] === 'zot') { - if((! $arr['key']) || (! Crypto::verify($arr['guid'],base64url_decode($arr['guid_sig']),$arr['key']))) { - logger('Unable to verify signature for ' . $arr['hash']); - return false; - } - } - $columns = db_columns('xchan'); $x = []; diff --git a/include/zid.php b/include/zid.php index 0a33280ee..422683c95 100644 --- a/include/zid.php +++ b/include/zid.php @@ -14,7 +14,7 @@ function is_matrix_url($url) { if(array_key_exists($m['host'],$remembered)) return $remembered[$m['host']]; - $r = q("select hubloc_url from hubloc where hubloc_host = '%s' and hubloc_network in ('zot', 'zot6') limit 1", + $r = q("select hubloc_url from hubloc where hubloc_host = '%s' and hubloc_network = 'zot6' limit 1", dbesc($m['host']) ); if($r) { -- cgit v1.2.3