aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/channel.php85
-rw-r--r--include/connections.php64
-rw-r--r--include/event.php4
-rw-r--r--include/hubloc.php4
-rw-r--r--include/permissions.php20
-rw-r--r--include/queue_fn.php80
-rw-r--r--include/zot.php83
7 files changed, 240 insertions, 100 deletions
diff --git a/include/channel.php b/include/channel.php
index 991d4675b..25eb93cac 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');
@@ -228,12 +230,16 @@ function create_identity($arr) {
return $ret;
}
- $guid = zot_new_uid($nick);
+ $guid = Libzot::new_uid($nick);
$key = new_keypair(4096);
- $sig = base64url_encode(rsa_sign($guid,$key['prvkey']));
- $hash = make_xchan_hash($guid,$sig);
- $zhash = Libzot::make_xchan_hash($guid,$key['pubkey']);
+ // legacy zot
+ $zsig = base64url_encode(rsa_sign($guid,$key['prvkey']));
+ $zhash = make_xchan_hash($guid,$zsig);
+
+ // zot6
+ $sig = Libzot::sign($guid,$key['prvkey']);
+ $hash = Libzot::make_xchan_hash($guid,$key['pubkey']);
// Force a few things on the short term until we can provide a theme or app with choice
@@ -332,8 +338,8 @@ function create_identity($arr) {
$r = hubloc_store_lowlevel(
[
'hubloc_guid' => $guid,
- 'hubloc_guid_sig' => $sig,
- 'hubloc_hash' => $hash,
+ 'hubloc_guid_sig' => $zsig,
+ 'hubloc_hash' => $zhash,
'hubloc_addr' => channel_reddress($ret['channel']),
'hubloc_primary' => intval($primary),
'hubloc_url' => z_root(),
@@ -346,18 +352,18 @@ function create_identity($arr) {
]
);
if(! $r)
- logger('Unable to store hub location');
+ logger('Unable to store hub location (zot)');
$r = hubloc_store_lowlevel(
[
'hubloc_guid' => $guid,
- 'hubloc_guid_sig' => 'sha256.' . $sig,
- 'hubloc_hash' => $zhash,
+ 'hubloc_guid_sig' => $sig,
+ 'hubloc_hash' => $hash,
'hubloc_id_url' => channel_url($ret['channel']),
'hubloc_addr' => channel_reddress($ret['channel']),
'hubloc_primary' => intval($primary),
'hubloc_url' => z_root(),
- 'hubloc_url_sig' => 'sha256.' . base64url_encode(rsa_sign(z_root(),$ret['channel']['channel_prvkey'])),
+ 'hubloc_url_sig' => Libzot::sign(z_root(),$ret['channel']['channel_prvkey']),
'hubloc_site_id' => Libzot::make_xchan_hash(z_root(),get_config('system','pubkey')),
'hubloc_host' => App::get_hostname(),
'hubloc_callback' => z_root() . '/zot',
@@ -367,16 +373,16 @@ function create_identity($arr) {
]
);
if(! $r)
- logger('Unable to store hub location');
+ logger('Unable to store hub location (zot6)');
$newuid = $ret['channel']['channel_id'];
$r = xchan_store_lowlevel(
[
- 'xchan_hash' => $hash,
+ 'xchan_hash' => $zhash,
'xchan_guid' => $guid,
- 'xchan_guid_sig' => $sig,
+ '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}",
@@ -393,12 +399,14 @@ function create_identity($arr) {
'xchan_system' => $system
]
);
+ if(! $r)
+ logger('Unable to store xchan (zot)');
$r = xchan_store_lowlevel(
[
- 'xchan_hash' => $zhash,
+ 'xchan_hash' => $hash,
'xchan_guid' => $guid,
- 'xchan_guid_sig' => 'sha256.' . $sig,
+ 'xchan_guid_sig' => $sig,
'xchan_pubkey' => $key['pubkey'],
'xchan_photo_mimetype' => (($photo_type) ? $photo_type : 'image/png'),
'xchan_photo_l' => z_root() . "/photo/profile/l/{$newuid}",
@@ -415,6 +423,8 @@ function create_identity($arr) {
'xchan_system' => $system
]
);
+ if(! $r)
+ logger('Unable to store xchan (zot6)');
@@ -521,13 +531,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 +558,7 @@ function create_identity($arr) {
call_hooks('create_identity', $newuid);
Master::Summon(array('Directory', $ret['channel']['channel_id']));
+
}
$ret['success'] = true;
@@ -546,6 +566,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);
diff --git a/include/connections.php b/include/connections.php
index 51df18b70..c7ec163c8 100644
--- a/include/connections.php
+++ b/include/connections.php
@@ -772,3 +772,67 @@ function vcard_query(&$r) {
}
}
}
+
+function z6trans_connections() {
+
+ $r = q("SELECT DISTINCT abook.abook_xchan, hubloc.hubloc_addr, hubloc.hubloc_url, hubloc.hubloc_guid, site.site_project, site.site_version FROM abook
+ LEFT JOIN hubloc ON abook_xchan = hubloc_hash
+ LEFT JOIN site ON hubloc_url = site_url
+ WHERE abook.abook_self = 0 AND hubloc.hubloc_network = 'zot'
+ AND hubloc.hubloc_deleted = 0 AND site.site_dead = 0"
+ );
+
+ foreach($r as $rr) {
+ if(stripos($rr['site_project'], 'hubzilla') !== false && version_compare($rr['site_version'], '4.7.4', '>=')) {
+
+ $zot_xchan = $rr['abook_xchan'];
+ $guid = $rr['hubloc_guid'];
+ $hub_url = $rr['hubloc_url'];
+ $addr = $rr['hubloc_addr'];
+
+ $x = q("SELECT hubloc_hash FROM hubloc
+ WHERE hubloc_guid = '%s' AND hubloc_url = '%s' AND hubloc_network = 'zot6' AND hubloc_deleted = 0",
+ dbesc($guid),
+ dbesc($hub_url)
+ );
+
+ if(!$x) {
+ logger("z6trans_connections: zot6 hubloc for $addr not found");
+ discover_by_webbie($addr,'zot6');
+ continue;
+ }
+
+ $zot6_xchan = $x[0]['hubloc_hash'];
+
+ logger("z6trans_connections: transition $zot_xchan to $zot6_xchan");
+
+ q("START TRANSACTION");
+
+ $q1 = q("UPDATE abook set abook_xchan = '%s' WHERE abook_xchan = '%s'",
+ dbesc($zot6_xchan),
+ dbesc($zot_xchan)
+ );
+
+ $q2 = q("UPDATE abconfig set xchan = '%s' WHERE xchan = '%s'",
+ dbesc($zot6_xchan),
+ dbesc($zot_xchan)
+ );
+
+ $q3 = q("UPDATE pgrp_member set xchan = '%s' WHERE xchan = '%s'",
+ dbesc($zot6_xchan),
+ dbesc($zot_xchan)
+ );
+
+ if($q1 && $q2 && $q3) {
+ q("COMMIT");
+ logger("z6trans_connections: completed");
+ continue;
+ }
+
+ logger("z6trans_connections: failed - performing rollback");
+ q("ROLLBACK");
+
+ }
+ }
+
+}
diff --git a/include/event.php b/include/event.php
index 64e63074c..b92d2c8a9 100644
--- a/include/event.php
+++ b/include/event.php
@@ -259,9 +259,9 @@ function format_event_bbcode($ev, $utc = false) {
}
if ($utc && $ev['event-timezone'] !== 'UTC') {
- $ev['dtstart'] = datetime_convert($ev['timezone'],'UTC',$ev['dtstart'],ATOM_TIME);
+ $ev['dtstart'] = datetime_convert($ev['timezone'],'UTC',$ev['dtstart']);
if ($ev['dtend'] && ! $ev['nofinish']) {
- $ev['dtend'] = datetime_convert($ev['timezone'],'UTC',$ev['dtend'],ATOM_TIME);
+ $ev['dtend'] = datetime_convert($ev['timezone'],'UTC',$ev['dtend']);
}
$ev['timezone'] = 'UTC';
}
diff --git a/include/hubloc.php b/include/hubloc.php
index 4a1f77733..059a4dadc 100644
--- a/include/hubloc.php
+++ b/include/hubloc.php
@@ -317,7 +317,7 @@ function z6_discover() {
if ($c) {
foreach ($c as $entry) {
$q1 = q("select * from hubloc left join site on hubloc_url = site_url where hubloc_deleted = 0 and site_dead = 0 and hubloc_hash = '%s' and hubloc_url != '%s'",
- dbesc($entry['channel_hash']),
+ dbesc($entry['channel_portable_id']),
dbesc(z_root())
);
if (! $q1) {
@@ -327,7 +327,7 @@ function z6_discover() {
// does this particular server have a zot6 clone registered on our site for this channel?
foreach ($q1 as $q) {
$q2 = q("select * from hubloc left join site on hubloc_url = site_url where hubloc_deleted = 0 and site_dead = 0 and hubloc_hash = '%s' and hubloc_url = '%s'",
- dbesc($entry['channel_portable_id']),
+ dbesc($entry['channel_hash']),
dbesc($q['hubloc_url'])
);
if ($q2) {
diff --git a/include/permissions.php b/include/permissions.php
index 501b2cc77..ca8ff6e93 100644
--- a/include/permissions.php
+++ b/include/permissions.php
@@ -554,4 +554,24 @@ function site_default_perms() {
return $ret;
}
+function their_perms_contains($channel_id,$xchan_hash,$perm) {
+ $x = get_abconfig($channel_id,$xchan_hash,'system','their_perms');
+ if($x) {
+ $y = explode(',',$x);
+ if(in_array($perm,$y)) {
+ return true;
+ }
+ }
+ return false;
+}
+function my_perms_contains($channel_id,$xchan_hash,$perm) {
+ $x = get_abconfig($channel_id,$xchan_hash,'system','my_perms');
+ if($x) {
+ $y = explode(',',$x);
+ if(in_array($perm,$y)) {
+ return true;
+ }
+ }
+ return false;
+}
diff --git a/include/queue_fn.php b/include/queue_fn.php
index 865228041..b72730d2f 100644
--- a/include/queue_fn.php
+++ b/include/queue_fn.php
@@ -228,49 +228,49 @@ function queue_deliver($outq, $immediate = false) {
// normal zot delivery
- logger('deliver: dest: ' . $outq['outq_posturl'], LOGGER_DEBUG);
+ logger('deliver: dest: ' . $outq['outq_posturl'] . ' driver: ' . $outq['outq_driver'], LOGGER_DEBUG);
if($outq['outq_driver'] === 'zot6') {
- if($outq['outq_posturl'] === z_root() . '/zot') {
- // local delivery
- $zot = new Receiver(new Zot6Handler(),$outq['outq_notify']);
- $result = $zot->run(true);
- logger('returned_json: ' . json_encode($result,JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES), LOGGER_DATA);
- logger('deliver: local zot6 delivery succeeded to ' . $outq['outq_posturl']);
- Libzot::process_response($outq['outq_posturl'],[ 'success' => true, 'body' => json_encode($result) ], $outq);
- }
- else {
- logger('remote');
- $channel = null;
-
- if($outq['outq_channel']) {
- $channel = channelx_by_n($outq['outq_channel']);
- }
-
- $host_crypto = null;
- if($channel && $base) {
- $h = q("select hubloc_sitekey, site_crypto from hubloc left join site on hubloc_url = site_url where site_url = '%s' and hubloc_network = 'zot6' order by hubloc_id desc limit 1",
- dbesc($base)
- );
- if($h) {
- $host_crypto = $h[0];
- }
- }
-
- $msg = $outq['outq_notify'];
-
- $result = Libzot::zot($outq['outq_posturl'],$msg,$channel,$host_crypto);
-
- if($result['success']) {
- logger('deliver: remote zot6 delivery succeeded to ' . $outq['outq_posturl']);
- Libzot::process_response($outq['outq_posturl'],$result, $outq);
- }
- else {
- logger('deliver: remote zot6 delivery failed to ' . $outq['outq_posturl']);
- logger('deliver: remote zot6 delivery fail data: ' . print_r($result,true), LOGGER_DATA);
- update_queue_item($outq['outq_hash'],10);
- }
+ if($outq['outq_posturl'] === z_root() . '/zot') {
+ // local delivery
+ $zot = new Receiver(new Zot6Handler(),$outq['outq_notify']);
+ $result = $zot->run(true);
+ logger('returned_json: ' . json_encode($result,JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES), LOGGER_DATA);
+ logger('deliver: local zot6 delivery succeeded to ' . $outq['outq_posturl']);
+ Libzot::process_response($outq['outq_posturl'],[ 'success' => true, 'body' => json_encode($result) ], $outq);
+ }
+ else {
+ logger('remote');
+ $channel = null;
+
+ if($outq['outq_channel']) {
+ $channel = channelx_by_n($outq['outq_channel']);
+ }
+
+ $host_crypto = null;
+ if($channel && $base) {
+ $h = q("select hubloc_sitekey, site_crypto from hubloc left join site on hubloc_url = site_url where site_url = '%s' and hubloc_network = 'zot6' order by hubloc_id desc limit 1",
+ dbesc($base)
+ );
+ if($h) {
+ $host_crypto = $h[0];
+ }
+ }
+
+ $msg = $outq['outq_notify'];
+
+ $result = Libzot::zot($outq['outq_posturl'],$msg,$channel,$host_crypto);
+
+ if($result['success']) {
+ logger('deliver: remote zot6 delivery succeeded to ' . $outq['outq_posturl']);
+ Libzot::process_response($outq['outq_posturl'],$result, $outq);
+ }
+ else {
+ logger('deliver: remote zot6 delivery failed to ' . $outq['outq_posturl']);
+ logger('deliver: remote zot6 delivery fail data: ' . print_r($result,true), LOGGER_DATA);
+ update_queue_item($outq['outq_hash'],10);
+ }
}
return;
diff --git a/include/zot.php b/include/zot.php
index 5d5ac8424..8b9cb0767 100644
--- a/include/zot.php
+++ b/include/zot.php
@@ -407,8 +407,8 @@ function zot_refresh($them, $channel = null, $force = false) {
$postvars['token'] = $token;
if($channel) {
- $postvars['target'] = $channel['channel_guid'];
- $postvars['target_sig'] = $channel['channel_guid_sig'];
+ $postvars['target'] = $channel['xchan_guid'];
+ $postvars['target_sig'] = $channel['xchan_guid_sig'];
$postvars['key'] = $channel['channel_pubkey'];
}
@@ -426,7 +426,6 @@ function zot_refresh($them, $channel = null, $force = false) {
logger('zot_refresh: ' . $url, LOGGER_DATA, LOG_INFO);
-
$result = z_post_url($url . $rhs,$postvars);
if ($result['success']) {
@@ -578,7 +577,7 @@ function zot_refresh($them, $channel = null, $force = false) {
[
'type' => NOTIFY_INTRO,
'from_xchan' => $x['hash'],
- 'to_xchan' => $channel['channel_hash'],
+ 'to_xchan' => $channel['channel_portable_id'],
'link' => z_root() . '/connedit/' . $new_connection[0]['abook_id']
]
);
@@ -921,7 +920,7 @@ function import_xchan($arr, $ud_flags = UPDATE_FLAGS_UPDATED, $ud_arr = null) {
// see if this is a channel clone that's hosted locally - which we treat different from other xchans/connections
- $local = q("select channel_account_id, channel_id from channel where channel_hash = '%s' limit 1",
+ $local = q("select channel_account_id, channel_id from channel where channel_portable_id = '%s' limit 1",
dbesc($xchan_hash)
);
@@ -1299,7 +1298,7 @@ function zot_fetch($arr) {
*
* @returns array
* Suitable for logging remotely, enumerating the processing results of each message/recipient combination
- * * [0] => \e string $channel_hash
+ * * [0] => \e string $channel_portable_id
* * [1] => \e string $delivery_status
* * [2] => \e string $address
*/
@@ -1385,7 +1384,7 @@ function zot_import($arr, $sender_url) {
if($recip_arr) {
stringify_array_elms($recip_arr);
$recips = implode(',',$recip_arr);
- $r = q("select channel_hash as hash from channel where channel_hash in ( " . $recips . " )
+ $r = q("select channel_portable_id as hash from channel where channel_portable_id in ( " . $recips . " )
and channel_removed = 0 ");
}
@@ -1596,11 +1595,11 @@ function public_recips($msg) {
$r = array();
- $c = q("select channel_id, channel_hash from channel where channel_removed = 0");
+ $c = q("select channel_id, channel_portable_id from channel where channel_removed = 0");
if($c) {
foreach($c as $cc) {
if(perm_is_allowed($cc['channel_id'],$msg['notify']['sender']['hash'],$perm)) {
- $r[] = [ 'hash' => $cc['channel_hash'] ];
+ $r[] = [ 'hash' => $cc['channel_portable_id'] ];
}
}
}
@@ -1610,7 +1609,7 @@ function public_recips($msg) {
if($include_sys && array_key_exists('public_scope',$msg['message']) && $msg['message']['public_scope'] === 'public') {
$sys = get_sys_channel();
if($sys)
- $r[] = [ 'hash' => $sys['channel_hash'] ];
+ $r[] = [ 'hash' => $sys['channel_portable_id'] ];
}
// look for any public mentions on this site
@@ -1624,7 +1623,7 @@ function public_recips($msg) {
if(($tag['type'] === 'mention' || $tag['type'] === 'forum') && (strpos($tag['url'],z_root()) !== false)) {
$address = basename($tag['url']);
if($address) {
- $z = q("select channel_hash as hash from channel where channel_address = '%s'
+ $z = q("select channel_portable_id as hash from channel where channel_address = '%s'
and channel_removed = 0 limit 1",
dbesc($address)
);
@@ -1727,7 +1726,7 @@ function allowed_public_recips($msg) {
$condensed_recips[] = $rr['hash'];
$results = array();
- $r = q("select channel_hash as hash, channel_id from channel left join abook on abook_channel = channel_id where abook_xchan = '%s' and channel_removed = 0 ",
+ $r = q("select channel_portable_id as hash, channel_id from channel left join abook on abook_channel = channel_id where abook_xchan = '%s' and channel_removed = 0 ",
dbesc($hash)
);
if($r) {
@@ -1776,7 +1775,7 @@ function process_delivery($sender, $arr, $deliveries, $relay, $public = false, $
$DR = new Zotlabs\Lib\DReport(z_root(),$sender['hash'],$d['hash'],$arr['mid']);
- $channel = channelx_by_hash($d['hash']);
+ $channel = channelx_by_portid($d['hash']);
if(! $channel) {
$DR->update('recipient not found');
@@ -2076,7 +2075,7 @@ function process_delivery($sender, $arr, $deliveries, $relay, $public = false, $
$stored = (($item_result && $item_result['item']) ? $item_result['item'] : false);
if((is_array($stored)) && ($stored['id'] != $stored['parent'])
- && ($stored['author_xchan'] === $channel['channel_hash'])) {
+ && ($stored['author_xchan'] === $channel['channel_portable_id'])) {
retain_item($stored['item']['parent']);
}
@@ -2344,7 +2343,7 @@ function process_mail_delivery($sender, $arr, $deliveries) {
$DR = new Zotlabs\Lib\DReport(z_root(),$sender['hash'],$d['hash'],$arr['mid']);
- $r = q("select * from channel where channel_hash = '%s' limit 1",
+ $r = q("select * from channel where channel_portable_id = '%s' limit 1",
dbesc($d['hash'])
);
@@ -2555,7 +2554,7 @@ function check_location_move($sender_hash, $locations) {
$loc = $locations[0];
- $r = q("select * from channel where channel_hash = '%s' limit 1",
+ $r = q("select * from channel where channel_portable_id = '%s' limit 1",
dbesc($sender_hash)
);
@@ -2563,7 +2562,7 @@ function check_location_move($sender_hash, $locations) {
return;
if($loc['url'] !== z_root()) {
- $x = q("update channel set channel_moved = '%s' where channel_hash = '%s' limit 1",
+ $x = q("update channel set channel_moved = '%s' where channel_portable_id = '%s' limit 1",
dbesc($loc['url']),
dbesc($sender_hash)
);
@@ -2826,13 +2825,13 @@ function sync_locations($sender, $arr, $absolute = false) {
*
* @see zot_get_hublocs()
* @param array $channel an associative array which must contain
- * * \e string \b channel_hash the hash of the channel
+ * * \e string \b channel_portable_id the hash of the channel
* @return array an array with associative arrays
*/
function zot_encode_locations($channel) {
$ret = array();
- $x = zot_get_hublocs($channel['channel_hash']);
+ $x = zot_get_hublocs($channel['channel_portable_id']);
if($x && count($x)) {
foreach($x as $hub) {
@@ -3300,8 +3299,8 @@ function build_sync_packet($uid = 0, $packet = null, $groups_changed = false) {
if(intval($channel['channel_removed']))
return;
- $h = q("select hubloc.*, site.site_crypto from hubloc left join site on site_url = hubloc_url where hubloc_hash = '%s' and hubloc_deleted = 0",
- dbesc(($keychange) ? $packet['keychange']['old_hash'] : $channel['channel_hash'])
+ $h = q("select hubloc.*, site.site_crypto, site.site_version, site.site_project from hubloc left join site on site_url = hubloc_url where hubloc_hash = '%s' and hubloc_deleted = 0",
+ dbesc(($keychange) ? $packet['keychange']['old_hash'] : $channel['channel_portable_id'])
);
if(! $h)
@@ -3313,6 +3312,14 @@ function build_sync_packet($uid = 0, $packet = null, $groups_changed = false) {
if($x['hubloc_host'] == App::get_hostname())
continue;
+ if(stripos($x['site_project'], 'hubzilla') !== false && version_compare($x['site_version'], '4.7.3', '<=')) {
+
+ logger('Dismiss sync due to incompatible version.');
+ // logger(print_r($x,true));
+ continue;
+
+ }
+
$y = q("select site_dead from site where site_url = '%s' limit 1",
dbesc($x['hubloc_url'])
);
@@ -3325,8 +3332,9 @@ function build_sync_packet($uid = 0, $packet = null, $groups_changed = false) {
return;
$r = q("select xchan_guid, xchan_guid_sig from xchan where xchan_hash = '%s' limit 1",
- dbesc($channel['channel_hash'])
+ dbesc($channel['channel_portable_id'])
);
+
if(! $r)
return;
@@ -4192,7 +4200,7 @@ function zot_reply_message_request($data) {
$arr = $data['recipients'][0];
$recip_hash = make_xchan_hash($arr['guid'],$arr['guid_sig']);
- $c = q("select * from channel left join xchan on channel_hash = xchan_hash where channel_hash = '%s' limit 1",
+ $c = q("select * from channel left join xchan on channel_portable_id = xchan_hash where channel_portable_id = '%s' limit 1",
dbesc($recip_hash)
);
if (! $c) {
@@ -4338,21 +4346,21 @@ function zotinfo($arr) {
$r = null;
if(strlen($zhash)) {
- $r = q("select channel.*, xchan.* from channel left join xchan on channel_hash = xchan_hash
- where channel_hash = '%s' limit 1",
+ $r = q("select channel.*, xchan.* from channel left join xchan on channel_portable_id = xchan_hash
+ where channel_portable_id = '%s' limit 1",
dbesc($zhash)
);
}
elseif(strlen($zguid) && strlen($zguid_sig)) {
- $r = q("select channel.*, xchan.* from channel left join xchan on channel_hash = xchan_hash
+ $r = q("select channel.*, xchan.* from channel left join xchan on channel_portable_id = xchan_hash
where channel_guid = '%s' and channel_guid_sig = '%s' limit 1",
dbesc($zguid),
- dbesc($zguid_sig)
+ dbesc('sha256.' . $zguid_sig)
);
}
elseif(strlen($zaddr)) {
if(strpos($zaddr,'[system]') === false) { /* normal address lookup */
- $r = q("select channel.*, xchan.* from channel left join xchan on channel_hash = xchan_hash
+ $r = q("select channel.*, xchan.* from channel left join xchan on channel_portable_id = xchan_hash
where ( channel_address = '%s' or xchan_addr = '%s' ) limit 1",
dbesc($zaddr),
dbesc($zaddr)
@@ -4372,10 +4380,10 @@ function zotinfo($arr) {
*
*/
- $r = q("select channel.*, xchan.* from channel left join xchan on channel_hash = xchan_hash
+ $r = q("select channel.*, xchan.* from channel left join xchan on channel_portable_id = xchan_hash
where channel_system = 1 order by channel_id limit 1");
if(! $r) {
- $r = q("select channel.*, xchan.* from channel left join xchan on channel_hash = xchan_hash
+ $r = q("select channel.*, xchan.* from channel left join xchan on channel_portable_id = xchan_hash
where channel_removed = 0 order by channel_id limit 1");
}
}
@@ -4699,14 +4707,14 @@ function check_zotinfo($channel, $locations, &$ret) {
// for the sys channel as normal channels will be trickier.
q("delete from hubloc where hubloc_hash = '%s'",
- dbesc($channel['channel_hash'])
+ dbesc($channel['channel_portable_id'])
);
$r = hubloc_store_lowlevel(
[
'hubloc_guid' => $channel['channel_guid'],
'hubloc_guid_sig' => $channel['channel_guid_sig'],
- 'hubloc_hash' => $channel['channel_hash'],
+ 'hubloc_hash' => $channel['channel_portable_id'],
'hubloc_addr' => channel_reddress($channel),
'hubloc_network' => 'zot',
'hubloc_primary' => 1,
@@ -4761,7 +4769,7 @@ function delivery_report_is_storable($dr) {
// Is the sender one of our channels?
- $c = q("select channel_id from channel where channel_hash = '%s' limit 1",
+ $c = q("select channel_id from channel where channel_portable_id = '%s' limit 1",
dbesc($dr['sender'])
);
if(! $c)
@@ -5107,7 +5115,7 @@ function zot_reply_auth_check($data,$encrypted_packet) {
$arr = $data['recipients'][0];
$recip_hash = make_xchan_hash($arr['guid'], $arr['guid_sig']);
- $c = q("select channel_id, channel_account_id, channel_prvkey from channel where channel_hash = '%s' limit 1",
+ $c = q("select channel_id, channel_account_id, channel_prvkey from channel where channel_portable_id = '%s' limit 1",
dbesc($recip_hash)
);
if (! $c) {
@@ -5174,7 +5182,7 @@ function zot_reply_purge($sender, $recipients) {
// basically this means "unfriend"
foreach ($recipients as $recip) {
$r = q("select channel.*,xchan.* from channel
- left join xchan on channel_hash = xchan_hash
+ left join xchan on channel_portable_id = xchan_hash
where channel_guid = '%s' and channel_guid_sig = '%s' limit 1",
dbesc($recip['guid']),
dbesc($recip['guid_sig'])
@@ -5227,12 +5235,11 @@ function zot_reply_refresh($sender, $recipients) {
foreach ($recipients as $recip) {
$r = q("select channel.*,xchan.* from channel
- left join xchan on channel_hash = xchan_hash
- where channel_guid = '%s' and channel_guid_sig = '%s' limit 1",
+ left join xchan on channel_portable_id = xchan_hash
+ where xchan_guid = '%s' and xchan_guid_sig = '%s' limit 1",
dbesc($recip['guid']),
dbesc($recip['guid_sig'])
);
-
$x = zot_refresh(array(
'xchan_guid' => $sender['guid'],
'xchan_guid_sig' => $sender['guid_sig'],