aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2021-05-27 08:39:23 +0000
committerMario <mario@mariovavti.com>2021-05-27 08:39:23 +0000
commit90c9fc53385f458f39539e777ef80e0d9857d649 (patch)
tree67aaf713aed3ae6365c53bbb10b0892d05042efd /include
parent0a09f507fc6e1ad10f7bbc7097e22e9249bdcefa (diff)
downloadvolse-hubzilla-90c9fc53385f458f39539e777ef80e0d9857d649.tar.gz
volse-hubzilla-90c9fc53385f458f39539e777ef80e0d9857d649.tar.bz2
volse-hubzilla-90c9fc53385f458f39539e777ef80e0d9857d649.zip
deprecate import_xchan()
Diffstat (limited to 'include')
-rw-r--r--include/dir_fns.php25
-rw-r--r--include/follow.php325
2 files changed, 1 insertions, 349 deletions
diff --git a/include/dir_fns.php b/include/dir_fns.php
index 8326415ed..84b0e6d93 100644
--- a/include/dir_fns.php
+++ b/include/dir_fns.php
@@ -330,24 +330,12 @@ function update_directory_entry($ud) {
if ($ud['ud_addr'] && (! ($ud['ud_flags'] & UPDATE_FLAGS_DELETED))) {
$success = false;
-
- // directory migration phase 1 (Macgirvin - 29-JUNE-2019)
- // fetch zot6 info (if available) as well as historical zot info (if available)
- // Once this has been running for > 1 month on the primary directory we can deprecate the historical info and
- // modify the directory search to only return zot6 entries, and also modify this function
- // to *only* fetch the zot6 entries.
- // Otherwise we'll be showing duplicates or have a mostly empty directory for a good chunk of
- // the transition period. Directory server load will likely increase "moderately" during this transition.
- // The one month counter begins when the primary directory has upgraded to a release which uses this code.
- // Hubzilla channels running traditional zot which have not upgraded can or will be dropped from the directory or
- // "not found" at the end of the transition period as the directory will only serve zot6 entries at that time.
-
$uri = Webfinger::zot_url($ud['ud_addr']);
+
if($uri) {
$record = Zotfinger::exec($uri);
// Check the HTTP signature
-
$hsig = $record['signature'];
if($hsig && $hsig['signer'] === $uri && $hsig['header_valid'] === true && $hsig['content_valid'] === true) {
$x = Libzot::import_xchan($record['data'], 0, $ud);
@@ -356,17 +344,6 @@ function update_directory_entry($ud) {
}
}
}
- $x = \Zotlabs\Zot\Finger::run($ud['ud_addr'], '');
- if ($x['success']) {
- import_xchan($x, 0, $ud);
- $success = true;
- }
- if (! $success) {
- q("update updates set ud_last = '%s' where ud_addr = '%s'",
- dbesc(datetime_convert()),
- dbesc($ud['ud_addr'])
- );
- }
}
}
diff --git a/include/follow.php b/include/follow.php
deleted file mode 100644
index 64ae8f7f1..000000000
--- a/include/follow.php
+++ /dev/null
@@ -1,325 +0,0 @@
-<?php /** @file */
-
-
-//
-// Takes a $uid and the channel associated with the uid, and a url/handle and adds a new channel
-
-// Returns an array
-// $return['success'] boolean true if successful
-// $return['abook'] Address book entry joined with xchan if successful
-// $return['message'] error text if success is false.
-
-use Zotlabs\Lib\Crypto;
-
-require_once('include/zot.php');
-
-function new_contact($uid,$url,$channel,$interactive = false, $confirm = false) {
-
- $result = [ 'success' => false, 'message' => '' ];
-
- $my_perms = false;
- $is_zot = false;
- $protocol = '';
-
-
- if(substr($url,0,1) === '[') {
- $x = strpos($url,']');
- if($x) {
- $protocol = substr($url,1,$x-1);
- $url = substr($url,$x+1);
- }
- }
-
- $is_http = ((strpos($url,'://') !== false) ? true : false);
-
- if($is_http && substr($url,-1,1) === '/')
- $url = substr($url,0,-1);
-
- if(! allowed_url($url)) {
- $result['message'] = t('Channel is blocked on this site.');
- return $result;
- }
-
- if(! $url) {
- $result['message'] = t('Channel location missing.');
- return $result;
- }
-
-
- // check service class limits
-
- $r = q("select count(*) as total from abook where abook_channel = %d and abook_self = 0 ",
- intval($uid)
- );
- if($r)
- $total_channels = $r[0]['total'];
-
- if(! service_class_allows($uid,'total_channels',$total_channels)) {
- $result['message'] = upgrade_message();
- return $result;
- }
-
-
- $arr = array('url' => $url, 'protocol', 'channel' => array());
-
- call_hooks('follow_init', $arr);
-
- if($arr['channel']['success'])
- $ret = $arr['channel'];
- elseif((! $is_http) && ((! $protocol) || (strtolower($protocol) === 'zot')))
- $ret = Zotlabs\Zot\Finger::run($url,$channel);
-
- if($ret && is_array($ret) && $ret['success']) {
- $is_zot = true;
- $j = $ret;
- }
-
- $p = \Zotlabs\Access\Permissions::connect_perms($uid);
- $my_perms = $p['perms'];
-
- if($is_zot && $j) {
-
- logger('follow: ' . $url . ' ' . print_r($j,true), LOGGER_DEBUG);
-
-
- if(! ($j['success'] && $j['guid'])) {
- $result['message'] = t('Response from remote channel was incomplete.');
- logger('mod_follow: ' . $result['message']);
- return $result;
- }
-
- // Premium channel, set confirm before callback to avoid recursion
-
- if(array_key_exists('connect_url',$j) && (! $confirm)) {
- if($interactive) {
- goaway(zid($j['connect_url']));
- }
- else {
- $result['message'] = t('Premium channel - please visit:') . ' ' . zid($j['connect_url']);
- logger('mod_follow: ' . $result['message']);
- return $result;
- }
- }
-
-
-
- // do we have an xchan and hubloc?
- // If not, create them.
-
- $x = import_xchan($j);
-
- if(array_key_exists('deleted',$j) && intval($j['deleted'])) {
- $result['message'] = t('Channel was deleted and no longer exists.');
- return $result;
- }
-
- if(! $x['success'])
- return $x;
-
- $xchan_hash = $x['hash'];
-
- if( array_key_exists('permissions',$j) && array_key_exists('data',$j['permissions'])) {
- $permissions = Crypto::unencapsulate(array(
- 'data' => $j['permissions']['data'],
- 'alg' => $j['permissions']['alg'],
- 'key' => $j['permissions']['key'],
- 'iv' => $j['permissions']['iv']),
- $channel['channel_prvkey']);
- if($permissions)
- $permissions = json_decode($permissions,true);
- logger('decrypted permissions: ' . print_r($permissions,true), LOGGER_DATA);
- }
- else
- $permissions = $j['permissions'];
-
- if(is_array($permissions) && $permissions) {
- foreach($permissions as $k => $v) {
- set_abconfig($channel['channel_uid'],$xchan_hash,'their_perms',$k,intval($v));
- }
- }
- }
- else {
-
- $xchan_hash = '';
- $sql_options = (($protocol) ? " and xchan_network = '" . dbesc($protocol) . "' " : '');
-
-
- $r = q("select * from xchan where (xchan_addr = '%s' or xchan_url = '%s') $sql_options ",
- dbesc($url),
- dbesc($url)
- );
-
- if(! $r) {
-
- // attempt network auto-discovery
-
- $wf = discover_by_webbie($url,$protocol);
-
- if((! $wf) && ($is_http)) {
-
- // try RSS discovery
-
- $feeds = get_config('system','feed_contacts');
-
- if(($feeds) && ($protocol === '' || $protocol === 'feed' || $protocol === 'rss')) {
- $d = discover_by_url($url);
- }
- else {
- $result['message'] = t('Remote channel or protocol unavailable.');
- return $result;
- }
- }
-
- if($wf || $d) {
- $r = q("select * from xchan where xchan_hash = '%s' or xchan_url = '%s'",
- dbesc(($wf) ? $wf : $url),
- dbesc($url)
- );
- }
- }
-
- $xchan = zot_record_preferred($r,'xchan_network');
-
- // if discovery was a success we should have an xchan record in $r
-
- if($xchan) {
- $xchan_hash = $xchan['xchan_hash'];
- $their_perms = 0;
- }
- }
-
- if(! $xchan_hash) {
- $result['message'] = t('Channel discovery failed.');
- logger('follow: ' . $result['message']);
- return $result;
- }
-
- $allowed = (($is_zot || in_array($xchan['xchan_network'],['rss','zot6'])) ? 1 : 0);
-
- $x = array('channel_id' => $uid, 'follow_address' => $url, 'xchan' => $xchan, 'allowed' => $allowed, 'singleton' => 0);
-
- call_hooks('follow_allow',$x);
-
- if(! $x['allowed']) {
- $result['message'] = t('Protocol disabled.');
- return $result;
- }
-
- $singleton = intval($x['singleton']);
-
- $aid = $channel['channel_account_id'];
- $hash = $channel['channel_hash'];
- $default_group = $channel['channel_default_group'];
-
- if($hash == $xchan_hash) {
- $result['message'] = t('Cannot connect to yourself.');
- return $result;
- }
-
- if($xchan['xchan_network'] === 'rss') {
-
- // check service class feed limits
-
- $r = q("select count(*) as total from abook where abook_account = %d and abook_feed = 1 ",
- intval($aid)
- );
- if($r)
- $total_feeds = $r[0]['total'];
-
- if(! service_class_allows($uid,'total_feeds',$total_feeds)) {
- $result['message'] = upgrade_message();
- return $result;
- }
-
- // Always set these "remote" permissions for feeds since we cannot interact with them
- // to negotiate a suitable permission response
-
- set_abconfig($uid,$xchan_hash,'their_perms','view_stream',1);
- set_abconfig($uid,$xchan_hash,'their_perms','republish',1);
-
- }
-
- $profile_assign = get_pconfig($uid,'system','profile_assign','');
-
-
- $r = q("select abook_id, abook_xchan, abook_pending, abook_instance from abook
- where abook_xchan = '%s' and abook_channel = %d limit 1",
- dbesc($xchan_hash),
- intval($uid)
- );
-
- if($r) {
-
- $abook_instance = $r[0]['abook_instance'];
-
- if(($singleton) && strpos($abook_instance,z_root()) === false) {
- if($abook_instance)
- $abook_instance .= ',';
- $abook_instance .= z_root();
-
- $x = q("update abook set abook_instance = '%s', abook_not_here = 0 where abook_id = %d",
- dbesc($abook_instance),
- intval($r[0]['abook_id'])
- );
- }
-
- if(intval($r[0]['abook_pending'])) {
- $x = q("update abook set abook_pending = 0 where abook_id = %d",
- intval($r[0]['abook_id'])
- );
- }
- }
- else {
- $closeness = get_pconfig($uid,'system','new_abook_closeness',80);
-
- $r = abook_store_lowlevel(
- [
- 'abook_account' => intval($aid),
- 'abook_channel' => intval($uid),
- 'abook_closeness' => intval($closeness),
- 'abook_xchan' => $xchan_hash,
- 'abook_profile' => $profile_assign,
- 'abook_feed' => intval(($xchan['xchan_network'] === 'rss') ? 1 : 0),
- 'abook_created' => datetime_convert(),
- 'abook_updated' => datetime_convert(),
- 'abook_instance' => (($singleton) ? z_root() : '')
- ]
- );
- }
-
- if(! $r)
- logger('mod_follow: abook creation failed');
-
- if($my_perms) {
- foreach($my_perms as $k => $v) {
- set_abconfig($uid,$xchan_hash,'my_perms',$k,$v);
- }
- }
-
- $r = q("select abook.*, xchan.* from abook left join xchan on abook_xchan = xchan_hash
- where abook_xchan = '%s' and abook_channel = %d limit 1",
- dbesc($xchan_hash),
- intval($uid)
- );
-
- if($r) {
- $result['abook'] = $r[0];
- Zotlabs\Daemon\Master::Summon(array('Notifier', 'permission_create', $result['abook']['abook_id']));
- }
-
- $arr = array('channel_id' => $uid, 'channel' => $channel, 'abook' => $result['abook']);
-
- call_hooks('follow', $arr);
-
- /** If there is a default group for this channel, add this connection to it */
-
- if($default_group) {
- require_once('include/group.php');
- $g = group_rec_byhash($uid,$default_group);
- if($g)
- group_add_member($uid,'',$xchan_hash,$g['id']);
- }
-
- $result['success'] = true;
- return $result;
-}