table structure for pseudo or proxy channels (pchan)
This commit is contained in:
parent
52183f8bf8
commit
9d51318c53
@ -32,6 +32,7 @@ class Wfinger extends \Zotlabs\Web\Controller {
|
|||||||
|
|
||||||
|
|
||||||
$root_resource = false;
|
$root_resource = false;
|
||||||
|
$pchan = false;
|
||||||
|
|
||||||
if(strcasecmp(rtrim($resource,'/'),z_root()) === 0)
|
if(strcasecmp(rtrim($resource,'/'),z_root()) === 0)
|
||||||
$root_resource = true;
|
$root_resource = true;
|
||||||
@ -57,11 +58,24 @@ class Wfinger extends \Zotlabs\Web\Controller {
|
|||||||
$channel = str_replace('~','',basename($resource));
|
$channel = str_replace('~','',basename($resource));
|
||||||
}
|
}
|
||||||
|
|
||||||
$r = q("select * from channel left join xchan on channel_hash = xchan_hash
|
if(substr($channel,0,1) === '[' ) {
|
||||||
where channel_address = '%s' limit 1",
|
$channel = substr($channel,1);
|
||||||
dbesc($channel)
|
$channel = substr($channel,0,-1);
|
||||||
);
|
$pchan = true;
|
||||||
|
$r = q("select * from pchan left join xchan on pchan_hash = xchan_hash
|
||||||
|
where pchan_guid = '%s' limit 1",
|
||||||
|
dbesc($channel)
|
||||||
|
);
|
||||||
|
if($r) {
|
||||||
|
$r[0] = pchan_to_chan($r[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$r = q("select * from channel left join xchan on channel_hash = xchan_hash
|
||||||
|
where channel_address = '%s' limit 1",
|
||||||
|
dbesc($channel)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
header('Access-Control-Allow-Origin: *');
|
header('Access-Control-Allow-Origin: *');
|
||||||
@ -94,7 +108,7 @@ class Wfinger extends \Zotlabs\Web\Controller {
|
|||||||
$result['subject'] = $resource;
|
$result['subject'] = $resource;
|
||||||
|
|
||||||
$aliases = array(
|
$aliases = array(
|
||||||
z_root() . '/channel/' . $r[0]['channel_address'],
|
z_root() . (($pchan) ? '/pchan/' : '/channel/') . $r[0]['channel_address'],
|
||||||
z_root() . '/~' . $r[0]['channel_address']
|
z_root() . '/~' . $r[0]['channel_address']
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -116,53 +130,80 @@ class Wfinger extends \Zotlabs\Web\Controller {
|
|||||||
if($alias != $resource)
|
if($alias != $resource)
|
||||||
$result['aliases'][] = $alias;
|
$result['aliases'][] = $alias;
|
||||||
|
|
||||||
$result['links'] = [
|
|
||||||
|
|
||||||
[
|
|
||||||
'rel' => 'http://webfinger.net/rel/avatar',
|
|
||||||
'type' => $r[0]['xchan_photo_mimetype'],
|
|
||||||
'href' => $r[0]['xchan_photo_l']
|
|
||||||
],
|
|
||||||
|
|
||||||
[
|
|
||||||
'rel' => 'http://webfinger.net/rel/profile-page',
|
|
||||||
'href' => z_root() . '/profile/' . $r[0]['channel_address'],
|
|
||||||
],
|
|
||||||
|
|
||||||
[
|
|
||||||
'rel' => 'http://schemas.google.com/g/2010#updates-from',
|
|
||||||
'type' => 'application/atom+xml',
|
|
||||||
'href' => z_root() . '/ofeed/' . $r[0]['channel_address']
|
|
||||||
],
|
|
||||||
|
|
||||||
[
|
if($pchan) {
|
||||||
'rel' => 'http://webfinger.net/rel/blog',
|
$result['links'] = [
|
||||||
'href' => z_root() . '/channel/' . $r[0]['channel_address'],
|
|
||||||
],
|
|
||||||
|
|
||||||
[
|
[
|
||||||
'rel' => 'http://ostatus.org/schema/1.0/subscribe',
|
'rel' => 'http://webfinger.net/rel/avatar',
|
||||||
'template' => z_root() . '/follow?f=&url={uri}',
|
'type' => $r[0]['xchan_photo_mimetype'],
|
||||||
],
|
'href' => $r[0]['xchan_photo_l']
|
||||||
|
],
|
||||||
|
|
||||||
[
|
[
|
||||||
'rel' => 'http://purl.org/zot/protocol',
|
'rel' => 'http://webfinger.net/rel/profile-page',
|
||||||
'href' => z_root() . '/.well-known/zot-info' . '?address=' . $r[0]['xchan_addr'],
|
'href' => $r[0]['xchan_url'],
|
||||||
],
|
],
|
||||||
|
|
||||||
[
|
[
|
||||||
'rel' => 'http://purl.org/openwebauth/v1',
|
'rel' => 'magic-public-key',
|
||||||
'type' => 'application/x-zot+json',
|
'href' => 'data:application/magic-public-key,' . salmon_key($r[0]['channel_pubkey']),
|
||||||
'href' => z_root() . '/owa',
|
]
|
||||||
],
|
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
$result['links'] = [
|
||||||
|
|
||||||
|
[
|
||||||
|
'rel' => 'http://webfinger.net/rel/avatar',
|
||||||
|
'type' => $r[0]['xchan_photo_mimetype'],
|
||||||
|
'href' => $r[0]['xchan_photo_l']
|
||||||
|
],
|
||||||
|
|
||||||
|
[
|
||||||
|
'rel' => 'http://webfinger.net/rel/profile-page',
|
||||||
|
'href' => z_root() . '/profile/' . $r[0]['channel_address'],
|
||||||
|
],
|
||||||
|
|
||||||
|
[
|
||||||
|
'rel' => 'http://schemas.google.com/g/2010#updates-from',
|
||||||
|
'type' => 'application/atom+xml',
|
||||||
|
'href' => z_root() . '/ofeed/' . $r[0]['channel_address']
|
||||||
|
],
|
||||||
|
|
||||||
|
[
|
||||||
|
'rel' => 'http://webfinger.net/rel/blog',
|
||||||
|
'href' => z_root() . '/channel/' . $r[0]['channel_address'],
|
||||||
|
],
|
||||||
|
|
||||||
|
[
|
||||||
|
'rel' => 'http://ostatus.org/schema/1.0/subscribe',
|
||||||
|
'template' => z_root() . '/follow?f=&url={uri}',
|
||||||
|
],
|
||||||
|
|
||||||
|
[
|
||||||
|
'rel' => 'http://purl.org/zot/protocol',
|
||||||
|
'href' => z_root() . '/.well-known/zot-info' . '?address=' . $r[0]['xchan_addr'],
|
||||||
|
],
|
||||||
|
|
||||||
|
[
|
||||||
|
'rel' => 'http://purl.org/openwebauth/v1',
|
||||||
|
'type' => 'application/x-zot+json',
|
||||||
|
'href' => z_root() . '/owa',
|
||||||
|
],
|
||||||
|
|
||||||
|
|
||||||
[
|
[
|
||||||
'rel' => 'magic-public-key',
|
'rel' => 'magic-public-key',
|
||||||
'href' => 'data:application/magic-public-key,' . salmon_key($r[0]['channel_pubkey']),
|
'href' => 'data:application/magic-public-key,' . salmon_key($r[0]['channel_pubkey']),
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
}
|
||||||
|
|
||||||
if($zot) {
|
if($zot) {
|
||||||
// get a zotinfo packet and return it with webfinger
|
// get a zotinfo packet and return it with webfinger
|
||||||
$result['zot'] = zotinfo( [ 'address' => $r[0]['xchan_addr'] ]);
|
$result['zot'] = zotinfo( [ 'address' => $r[0]['xchan_addr'] ]);
|
||||||
@ -174,7 +215,7 @@ class Wfinger extends \Zotlabs\Web\Controller {
|
|||||||
killme();
|
killme();
|
||||||
}
|
}
|
||||||
|
|
||||||
$arr = [ 'channel' => $r[0], 'request' => $_REQUEST, 'result' => $result ];
|
$arr = [ 'channel' => $r[0], 'pchan' => $pchan, 'request' => $_REQUEST, 'result' => $result ];
|
||||||
call_hooks('webfinger',$arr);
|
call_hooks('webfinger',$arr);
|
||||||
|
|
||||||
|
|
||||||
|
2
boot.php
2
boot.php
@ -52,7 +52,7 @@ define ( 'PLATFORM_NAME', 'hubzilla' );
|
|||||||
define ( 'STD_VERSION', '2.9' );
|
define ( 'STD_VERSION', '2.9' );
|
||||||
define ( 'ZOT_REVISION', '1.3' );
|
define ( 'ZOT_REVISION', '1.3' );
|
||||||
|
|
||||||
define ( 'DB_UPDATE_VERSION', 1196 );
|
define ( 'DB_UPDATE_VERSION', 1197 );
|
||||||
|
|
||||||
define ( 'PROJECT_BASE', __DIR__ );
|
define ( 'PROJECT_BASE', __DIR__ );
|
||||||
|
|
||||||
|
@ -2604,3 +2604,12 @@ function anon_identity_init($reqvars) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function pchan_to_chan($pchan) {
|
||||||
|
$chan = $pchan;
|
||||||
|
$chan['channel_address'] = $pchan['pchan_guid'];
|
||||||
|
$chan['channel_hash'] = $pchan['pchan_hash'];
|
||||||
|
$chan['channel_pubkey'] = $pchan['pchan_pubkey'];
|
||||||
|
$chan['channel_prvkey'] = $pchan['pchan_prvkey'];
|
||||||
|
$chan['channel_name'] = $pchan['xchan_name'];
|
||||||
|
return $chan;
|
||||||
|
}
|
@ -900,6 +900,19 @@ CREATE TABLE IF NOT EXISTS `outq` (
|
|||||||
KEY `outq_priority` (`outq_priority`)
|
KEY `outq_priority` (`outq_priority`)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||||
|
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS pchan (
|
||||||
|
`pchan_id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||||
|
`pchan_guid` char(191) NOT NULL DEFAULT '',
|
||||||
|
`pchan_hash` char(191) NOT NULL DEFAULT '',
|
||||||
|
`pchan_pubkey` text NOT NULL,
|
||||||
|
`pchan_prvkey` text NOT NULL,
|
||||||
|
PRIMARY KEY (`pchan_id`),
|
||||||
|
KEY `pchan_guid` (`pchan_guid`),
|
||||||
|
KEY `pchan_hash` (`pchan_hash`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||||
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS `pconfig` (
|
CREATE TABLE IF NOT EXISTS `pconfig` (
|
||||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
`uid` int(11) NOT NULL DEFAULT 0 ,
|
`uid` int(11) NOT NULL DEFAULT 0 ,
|
||||||
|
@ -872,6 +872,19 @@ create index "outq_async" on outq ("outq_async");
|
|||||||
create index "outq_delivered" on outq ("outq_delivered");
|
create index "outq_delivered" on outq ("outq_delivered");
|
||||||
create index "outq_priority" on outq ("outq_priority");
|
create index "outq_priority" on outq ("outq_priority");
|
||||||
|
|
||||||
|
|
||||||
|
CREATE TABLE "pchan" (
|
||||||
|
"pchan_id" serial NOT NULL,
|
||||||
|
"pchan_guid" text NOT NULL,
|
||||||
|
"pchan_hash" text NOT NULL,
|
||||||
|
"pchan_pubkey" text NOT NULL,
|
||||||
|
"pchan_prvkey" text NOT NULL,
|
||||||
|
PRIMARY KEY ("pchan_id")
|
||||||
|
);
|
||||||
|
|
||||||
|
create index "pchan_guid" on pchan ("pchan_guid");
|
||||||
|
create index "pchan_hash" on pchan ("pchan_hash");
|
||||||
|
|
||||||
CREATE TABLE "pconfig" (
|
CREATE TABLE "pconfig" (
|
||||||
"id" serial NOT NULL,
|
"id" serial NOT NULL,
|
||||||
"uid" bigint NOT NULL DEFAULT '0',
|
"uid" bigint NOT NULL DEFAULT '0',
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
define( 'UPDATE_VERSION' , 1196 );
|
define( 'UPDATE_VERSION' , 1197 );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -3022,3 +3022,41 @@ function update_r1195() {
|
|||||||
return UPDATE_SUCCESS;
|
return UPDATE_SUCCESS;
|
||||||
return UPDATE_FAILED;
|
return UPDATE_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function update_r1196() {
|
||||||
|
|
||||||
|
if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) {
|
||||||
|
$r1 = q("CREATE TABLE \"pchan\" (
|
||||||
|
\"pchan_id\" serial NOT NULL,
|
||||||
|
\"pchan_guid\" text NOT NULL,
|
||||||
|
\"pchan_hash\" text NOT NULL,
|
||||||
|
\"pchan_pubkey\" text NOT NULL,
|
||||||
|
\"pchan_prvkey\" text NOT NULL,
|
||||||
|
PRIMARY KEY (\"pchan_id\")
|
||||||
|
)");
|
||||||
|
|
||||||
|
$r2 = q("create index \"pchan_guid\" on pchan (\"pchan_guid\")");
|
||||||
|
$r3 = q("create index \"pchan_hash\" on pchan (\"pchan_hash\");
|
||||||
|
|
||||||
|
if($r1 && $r2 && $r3) {
|
||||||
|
return UPDATE_SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$r1 = q("CREATE TABLE IF NOT EXISTS pchan (
|
||||||
|
pchan_id int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||||
|
pchan_guid char(191) NOT NULL DEFAULT '',
|
||||||
|
pchan_hash char(191) NOT NULL DEFAULT '',
|
||||||
|
pchan_pubkey text NOT NULL,
|
||||||
|
pchan_prvkey text NOT NULL,
|
||||||
|
PRIMARY KEY (pchan_id),
|
||||||
|
KEY pchan_guid (pchan_guid),
|
||||||
|
KEY pchan_hash (pchan_hash)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4");
|
||||||
|
if($r1) {
|
||||||
|
return UPDATE_SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return UPDATE_FAILED;
|
||||||
|
}
|
Reference in New Issue
Block a user