aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Lib/Libzot.php
diff options
context:
space:
mode:
Diffstat (limited to 'Zotlabs/Lib/Libzot.php')
-rw-r--r--Zotlabs/Lib/Libzot.php77
1 files changed, 45 insertions, 32 deletions
diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php
index 2c726aff4..70f013eb7 100644
--- a/Zotlabs/Lib/Libzot.php
+++ b/Zotlabs/Lib/Libzot.php
@@ -109,7 +109,7 @@ class Libzot {
$data = [
'type' => $type,
'encoding' => $encoding,
- 'sender' => $channel['channel_hash'],
+ 'sender' => $channel['channel_portable_id'],
'site_id' => self::make_xchan_hash(z_root(), get_config('system','pubkey')),
'version' => System::get_zot_revision(),
];
@@ -329,8 +329,14 @@ class Libzot {
return false;
if($channel && $record['data']['permissions']) {
- $old_read_stream_perm = their_perms_contains($channel['channel_id'],$x['hash'],'view_stream');
- set_abconfig($channel['channel_id'],$x['hash'],'system','their_perms',$record['data']['permissions']);
+ $permissions = explode(',',$record['data']['permissions']);
+ if($permissions && is_array($permissions)) {
+ $old_read_stream_perm = get_abconfig($channel['channel_id'],$x['hash'],'their_perms','view_stream');
+
+ foreach($permissions as $p) {
+ set_abconfig($channel['channel_id'],$x['hash'],'their_perms',$p,'1');
+ }
+ }
if(array_key_exists('profile',$record['data']) && array_key_exists('next_birthday',$record['data']['profile'])) {
$next_birthday = datetime_convert('UTC','UTC',$record['data']['profile']['next_birthday']);
@@ -350,7 +356,7 @@ class Libzot {
);
if($r) {
-
+logger('4');
// connection exists
// if the dob is the same as what we have stored (disregarding the year), keep the one
@@ -379,14 +385,16 @@ class Libzot {
else {
$p = Permissions::connect_perms($channel['channel_id']);
- $my_perms = Permissions::serialise($p['perms']);
+ $my_perms = $p['perms'];
$automatic = $p['automatic'];
// new connection
if($my_perms) {
- set_abconfig($channel['channel_id'],$x['hash'],'system','my_perms',$my_perms);
+ foreach($my_perms as $k => $v) {
+ set_abconfig($channel['channel_id'],$x['hash'],'my_perms',$k,$v);
+ }
}
$closeness = get_pconfig($channel['channel_id'],'system','new_abook_closeness');
@@ -409,7 +417,7 @@ class Libzot {
if($y) {
logger("New introduction received for {$channel['channel_name']}");
- $new_perms = get_all_perms($channel['channel_id'],$x['hash']);
+ $new_perms = get_all_perms($channel['channel_id'],$x['hash'],false);
// Send a clone sync packet and a permissions update if permissions have changed
@@ -425,7 +433,7 @@ class Libzot {
[
'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']
]
);
@@ -500,6 +508,7 @@ class Libzot {
$r = q("select hubloc.*, site.site_crypto from hubloc left join site on hubloc_url = site_url
where hubloc_guid = '%s' and hubloc_guid_sig = '%s'
and hubloc_url = '%s' and hubloc_url_sig = '%s'
+ and hubloc_network = 'zot6'
and hubloc_site_id = '%s' $limit",
dbesc($arr['id']),
dbesc($arr['id_sig']),
@@ -776,7 +785,7 @@ class Libzot {
// 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)
);
if($local) {
@@ -966,6 +975,7 @@ class Libzot {
}
$x = crypto_unencapsulate($x, get_config('system','prvkey'));
+
if(! is_array($x)) {
$x = json_decode($x,true);
}
@@ -996,7 +1006,7 @@ class Libzot {
dbesc($xx['recipient']),
dbesc($xx['name']),
dbesc($xx['status']),
- dbesc(datetime_convert($xx['date'])),
+ dbesc(datetime_convert('UTC','UTC',$xx['date'])),
dbesc($xx['sender'])
);
}
@@ -1129,7 +1139,7 @@ class Libzot {
if($recip_arr) {
stringify_array_elms($recip_arr,true);
$recips = implode(',',$recip_arr);
- $r = q("select channel_hash as hash from channel where channel_hash in ( " . $recips . " ) and channel_removed = 0 ");
+ $r = q("select channel_portable_id as hash from channel where channel_portable_id in ( " . $recips . " ) and channel_removed = 0 ");
}
if(! $r) {
@@ -1303,12 +1313,12 @@ class Libzot {
$r = [];
- $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['sender'],$perm)) {
- $r[] = $cc['channel_hash'];
+ $r[] = $cc['channel_portable_id'];
}
}
}
@@ -1316,7 +1326,7 @@ class Libzot {
if($include_sys) {
$sys = get_sys_channel();
if($sys)
- $r[] = $sys['channel_hash'];
+ $r[] = $sys['channel_portable_id'];
}
@@ -1332,7 +1342,7 @@ class Libzot {
if($tag['type'] === 'Mention' && (strpos($tag['href'],z_root()) !== false)) {
$address = basename($tag['href']);
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)
);
@@ -1353,7 +1363,7 @@ class Libzot {
$thread_parent = self::find_parent($msg,$act);
if($thread_parent) {
- $z = q("select channel_hash as hash from channel left join item on channel.channel_id = item.uid where ( item.thr_parent = '%s' OR item.parent_mid = '%s' ) ",
+ $z = q("select channel_portable_id as hash from channel left join item on channel.channel_id = item.uid where ( item.thr_parent = '%s' OR item.parent_mid = '%s' ) ",
dbesc($thread_parent),
dbesc($thread_parent)
);
@@ -1427,7 +1437,7 @@ class Libzot {
* access checks.
*/
- if($sender === $channel['channel_hash'] && $arr['author_xchan'] === $channel['channel_hash'] && $arr['mid'] === $arr['parent_mid']) {
+ if($sender === $channel['channel_portable_id'] && $arr['author_xchan'] === $channel['channel_portable_id'] && $arr['mid'] === $arr['parent_mid']) {
$DR->update('self delivery ignored');
$result[] = $DR->get();
continue;
@@ -1709,7 +1719,7 @@ class Libzot {
$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_hash'] || $stored['author_xchan'] === $channel['channel_portable_id'])) {
retain_item($stored['item']['parent']);
}
@@ -1809,9 +1819,9 @@ class Libzot {
}
logger('FOF Activity received: ' . print_r($arr,true), LOGGER_DATA, LOG_DEBUG);
- logger('FOF Activity recipient: ' . $channel['channel_hash'], LOGGER_DATA, LOG_DEBUG);
+ logger('FOF Activity recipient: ' . $channel['channel_portable_id'], LOGGER_DATA, LOG_DEBUG);
- $result = self::process_delivery($arr['owner_xchan'],$arr, [ $channel['channel_hash'] ],false,false,true);
+ $result = self::process_delivery($arr['owner_xchan'],$arr, [ $channel['channel_portable_id'] ],false,false,true);
if ($result) {
$ret = array_merge($ret, $result);
}
@@ -2047,7 +2057,7 @@ class Libzot {
$DR = new DReport(z_root(),$sender,$d,$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'])
);
@@ -2202,7 +2212,7 @@ class Libzot {
$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)
);
@@ -2210,7 +2220,7 @@ class Libzot {
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)
);
@@ -2246,7 +2256,7 @@ class Libzot {
static function encode_locations($channel) {
$ret = [];
- $x = self::get_hublocs($channel['channel_hash']);
+ $x = self::get_hublocs($channel['channel_portable_id']);
if($x && count($x)) {
foreach($x as $hub) {
@@ -2557,6 +2567,9 @@ class Libzot {
static function zotinfo($arr) {
+ logger('arr: ' . print_r($arr,true));
+
+
$ret = [];
$zhash = ((x($arr,'guid_hash')) ? $arr['guid_hash'] : '');
@@ -2593,13 +2606,13 @@ class Libzot {
$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)
@@ -2607,7 +2620,7 @@ class Libzot {
}
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)
@@ -2627,10 +2640,10 @@ class Libzot {
*
*/
- $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");
}
}
@@ -2749,7 +2762,7 @@ class Libzot {
];
$ret['channel_role'] = get_pconfig($e['channel_id'],'system','permissions_role','custom');
- $ret['protocols'] = [ 'zot6' ];
+ $ret['protocols'] = [ 'zot', 'zot6' ];
$ret['searchable'] = $searchable;
$ret['adult_content'] = $adult_channel;
$ret['public_forum'] = $public_forum;
@@ -2774,7 +2787,7 @@ class Libzot {
if(! $ret['follow_url'])
$ret['follow_url'] = z_root() . '/follow?f=&url=%s';
- $permissions = get_all_perms($e['channel_id'],$ztarget_hash,false);
+ $permissions = get_all_perms($e['channel_id'],$ztarget_hash,false,false);
if($ztarget_hash) {
$permissions['connected'] = false;