aboutsummaryrefslogtreecommitdiffstats
path: root/include/zot.php
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2012-08-09 20:31:06 -0700
committerfriendica <info@friendica.com>2012-08-09 20:31:06 -0700
commit26e29d7f885f929793b9f0720fde8843e7bf8d6d (patch)
tree1199d381ccc573aab91618bc631cdc6529ef1d86 /include/zot.php
parentf2a7fcf8220ef497c8f39f0c9ec3175757f53128 (diff)
downloadvolse-hubzilla-26e29d7f885f929793b9f0720fde8843e7bf8d6d.tar.gz
volse-hubzilla-26e29d7f885f929793b9f0720fde8843e7bf8d6d.tar.bz2
volse-hubzilla-26e29d7f885f929793b9f0720fde8843e7bf8d6d.zip
zot basic comm structure (real basic)
Diffstat (limited to 'include/zot.php')
-rw-r--r--include/zot.php50
1 files changed, 46 insertions, 4 deletions
diff --git a/include/zot.php b/include/zot.php
index f978971ea..dd5d39ef2 100644
--- a/include/zot.php
+++ b/include/zot.php
@@ -22,7 +22,7 @@ function zot_new_uid($entity_id) {
*
*/
-function zot_get_hubloc($arr,$primary) {
+function zot_get_hubloc($arr,$primary = false) {
$tmp = '';
@@ -38,7 +38,7 @@ function zot_get_hubloc($arr,$primary) {
return array();
$sql_extra = (($primary) ? " and hubloc_primary = 1 " : "" );
- return q("select * from hubloc where hubloc_zuid in ( $tmp ) $sql_extra order by hubloc_url");
+ return q("select * from hubloc where hubloc_guid in ( $tmp ) $sql_extra order by hubloc_url");
}
@@ -60,11 +60,53 @@ function zot_verify(&$item,$identity) {
function zot_notify($entity,$url) {
$x = z_post_url($url, array(
'type' => 'notify',
- 'guid' => $entity['entity_global_id'],
- 'callback' => z_root() . '/post',
+ 'guid' => $entity['entity_global_id'],
+ 'hub' => z_root(),
+ 'callback' => '/post',
'spec' => ZOT_REVISION)
);
return($x);
}
+function zot_gethub($arr) {
+
+ if((x($arr,'hub')) && (x($arr,'guid'))) {
+ $r = q("select * from hubloc
+ where hubloc_guid = '%s' and hubloc_url = '%s'
+ limit 1",
+ dbesc($arr['guid']),
+ dbesc($arr['hub'])
+ );
+ if($r && count($r))
+ return $r[0];
+ }
+ return null;
+}
+
+function zot_register_hub($arr) {
+ if((x($arr,'hub')) && (x($arr,'guid'))) {
+ $x = z_fetch_url($arr['hub'] . '/.well-known/zot-guid/' . $arr['guid']);
+ if($x['success']) {
+ $record = json_decode($x['body']);
+ if($record->guid === $arr['guid'] && $record->url === $arr['hub']) {
+ $r = q("insert into hubloc (hubloc_guid, hubloc_primary, hubloc_url,
+ hubloc_callback, hubloc_sitekey, hubloc_key)
+ values ( '%s', %d, '%s', '%s', '%s', '%s' )",
+ dbesc($arr['guid']),
+ intval($record->primary),
+ dbesc($record->url),
+ dbesc($record->callback),
+ dbesc($record->sitekey),
+ dbesc($record->key)
+ );
+
+ // return the discovery record so we can further process
+
+ if($r)
+ return $record;
+ }
+ }
+ }
+ return false;
+} \ No newline at end of file