aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2020-01-26 19:41:52 +0000
committerMario <mario@mariovavti.com>2020-01-26 19:41:52 +0000
commit9545a81166cf52c930dfafda40d93bf93d66260d (patch)
treee63d036fac599b012316d351cfea86095f253344
parent1712eceaf95e5e57d8f5866cb1f6100a0acd28b6 (diff)
downloadvolse-hubzilla-9545a81166cf52c930dfafda40d93bf93d66260d.tar.gz
volse-hubzilla-9545a81166cf52c930dfafda40d93bf93d66260d.tar.bz2
volse-hubzilla-9545a81166cf52c930dfafda40d93bf93d66260d.zip
update create_identity() to use Lib/Connect via connect_and_sync() ported from zap
-rw-r--r--include/channel.php55
1 files changed, 50 insertions, 5 deletions
diff --git a/include/channel.php b/include/channel.php
index e7d119b1e..61603fb42 100644
--- a/include/channel.php
+++ b/include/channel.php
@@ -11,6 +11,8 @@ use Zotlabs\Daemon\Master;
use Zotlabs\Lib\System;
use Zotlabs\Render\Comanche;
use Zotlabs\Lib\Libzot;
+use Zotlabs\Lib\Connect;
+use Zotlabs\Lib\Libsync;
require_once('include/zot.php');
require_once('include/crypto.php');
@@ -346,7 +348,7 @@ function create_identity($arr) {
]
);
if(! $r)
- logger('Unable to store hub location');
+ logger('Unable to store hub location (zot)');
$r = hubloc_store_lowlevel(
[
@@ -367,7 +369,7 @@ function create_identity($arr) {
]
);
if(! $r)
- logger('Unable to store hub location');
+ logger('Unable to store hub location (zot6)');
$newuid = $ret['channel']['channel_id'];
@@ -393,6 +395,8 @@ function create_identity($arr) {
'xchan_system' => $system
]
);
+ if(! $r)
+ logger('Unable to store xchan (zot)');
$r = xchan_store_lowlevel(
[
@@ -415,6 +419,8 @@ function create_identity($arr) {
'xchan_system' => $system
]
);
+ if(! $r)
+ logger('Unable to store xchan (zot6)');
@@ -521,13 +527,22 @@ function create_identity($arr) {
$accts = get_config('system','auto_follow');
if(($accts) && (! $total_identities)) {
- require_once('include/follow.php');
if(! is_array($accts))
$accts = array($accts);
foreach($accts as $acct) {
- if(trim($acct))
- new_contact($newuid,trim($acct),$ret['channel'],false);
+ $acct = trim($acct);
+ if($acct) {
+ $f = connect_and_sync($ret['channel'], $acct);
+ if($f['success']) {
+ $can_view_stream = their_perms_contains($ret['channel']['channel_id'],$f['abook']['abook_xchan'],'view_stream');
+
+ // If we can view their stream, pull in some posts
+ if(($can_view_stream) || ($f['abook']['xchan_network'] === 'rss')) {
+ Master::Summon([ 'Onepoll',$f['abook']['abook_id'] ]);
+ }
+ }
+ }
}
}
@@ -539,6 +554,7 @@ function create_identity($arr) {
call_hooks('create_identity', $newuid);
Master::Summon(array('Directory', $ret['channel']['channel_id']));
+
}
$ret['success'] = true;
@@ -546,6 +562,35 @@ function create_identity($arr) {
}
+function connect_and_sync($channel,$address, $sub_channel = false) {
+
+ if((! $channel) || (! $address)) {
+ return false;
+ }
+
+ $f = Connect::connect($channel,$address, $sub_channel);
+ if($f['success']) {
+ $clone = [];
+ foreach($f['abook'] as $k => $v) {
+ if(strpos($k,'abook_') === 0) {
+ $clone[$k] = $v;
+ }
+ }
+ unset($clone['abook_id']);
+ unset($clone['abook_account']);
+ unset($clone['abook_channel']);
+
+ $abconfig = load_abconfig($channel['channel_id'],$clone['abook_xchan']);
+ if($abconfig) {
+ $clone['abconfig'] = $abconfig;
+ }
+
+ Libsync::build_sync_packet($channel['channel_id'], [ 'abook' => [ $clone ] ], true);
+ return $f;
+ }
+ return false;
+}
+
function change_channel_keys($channel) {
$ret = array('success' => false);