aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Willingham <founder@kakste.com>2013-01-02 11:40:17 +0000
committerThomas Willingham <founder@kakste.com>2013-01-02 11:40:17 +0000
commit577236c372b4eaa1e93d60d7bedaecea8ef8c97f (patch)
treee9c38e309a8edcb72e25f17e751eeb6bac3feea0
parent2fd0653d6ff3c60920946f83d249c8763dcad4a8 (diff)
parent4108598133eae97e7c8a0b8e13ead4856f423cff (diff)
downloadvolse-hubzilla-577236c372b4eaa1e93d60d7bedaecea8ef8c97f.tar.gz
volse-hubzilla-577236c372b4eaa1e93d60d7bedaecea8ef8c97f.tar.bz2
volse-hubzilla-577236c372b4eaa1e93d60d7bedaecea8ef8c97f.zip
Merge remote-tracking branch 'upstream/master'
-rw-r--r--boot.php2
-rw-r--r--include/onepoll.php18
-rw-r--r--include/socgraph.php148
-rw-r--r--include/zot.php8
-rw-r--r--install/database.sql11
-rw-r--r--install/update.php16
-rw-r--r--version.inc2
7 files changed, 99 insertions, 106 deletions
diff --git a/boot.php b/boot.php
index 61b64508e..9bee6c35c 100644
--- a/boot.php
+++ b/boot.php
@@ -16,7 +16,7 @@ require_once('include/features.php');
define ( 'FRIENDICA_PLATFORM', 'Friendica Red');
define ( 'FRIENDICA_VERSION', trim(file_get_contents('version.inc')) . 'R');
define ( 'ZOT_REVISION', 1 );
-define ( 'DB_UPDATE_VERSION', 1013 );
+define ( 'DB_UPDATE_VERSION', 1014 );
define ( 'EOL', '<br />' . "\r\n" );
define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' );
diff --git a/include/onepoll.php b/include/onepoll.php
index 1d7ac226d..a2b3f7a9f 100644
--- a/include/onepoll.php
+++ b/include/onepoll.php
@@ -94,19 +94,17 @@ function onepoll_run($argv, $argc){
// set last updated timestamp
-/*
- if($contact['poco']) {
- $r = q("SELECT count(*) as total from glink
- where `cid` = %d and updated > UTC_TIMESTAMP() - INTERVAL 1 DAY",
- intval($contact['id'])
+ $r = null;
+
+ if($contact['xchan_connurl']) {
+ $r = q("SELECT xlink_id from xlink
+ where xlink_xchan = '%s' and xlink_updated > UTC_TIMESTAMP() - INTERVAL 1 DAY",
+ intval($contact['xchan_hash'])
);
}
- if(count($r)) {
- if(! $r[0]['total']) {
- poco_load($contact['id'],$importer_uid,0,$contact['poco']);
- }
+ if($r) {
+ poco_load($contact['xchan_hash'],$contact['xchan_connurl']);
}
-*/
return;
}
diff --git a/include/socgraph.php b/include/socgraph.php
index a878c1683..aa5a24e89 100644
--- a/include/socgraph.php
+++ b/include/socgraph.php
@@ -1,7 +1,6 @@
<?php
-require_once('include/datetime.php');
-
+require_once('include/zot.php');
/*
* poco_load
@@ -20,151 +19,120 @@ require_once('include/datetime.php');
-function poco_load($cid, $uid = 0,$zcid = 0,$url = null) {
+function poco_load($xchan = null,$url = null) {
$a = get_app();
- if($cid) {
- if((! $url) || (! $uid)) {
- $r = q("select `poco`, `uid` from `contact` where `id` = %d limit 1",
- intval($cid)
- );
- if(count($r)) {
- $url = $r[0]['poco'];
- $uid = $r[0]['uid'];
- }
+ if($xchan && ! $url) {
+ $r = q("select xchan_connurl from xchan where xchan_hash = %d limit 1",
+ intval($xchan)
+ );
+ if($r) {
+ $url = $r[0]['xchan_connurl'];
+ $uid = $r[0]['abook_channel'];
}
- if(! $uid)
- return;
}
if(! $url)
return;
- $url = $url . (($uid) ? '/@me/@all?fields=displayName,urls,photos' : '?fields=displayName,urls,photos') ;
- logger('poco_load: ' . $url, LOGGER_DEBUG);
+ $url = $url . '?fields=displayName,hash,urls,photos' ;
- $s = fetch_url($url);
+ logger('poco_load: ' . $url, LOGGER_DEBUG);
- logger('poco_load: returns ' . $s, LOGGER_DATA);
+ $s = z_fetch_url($url);
- logger('poco_load: return code: ' . $a->get_curl_code(), LOGGER_DEBUG);
+ logger('poco_load: returns ' . print_r($s,true), LOGGER_DATA);
- if(($a->get_curl_code() > 299) || (! $s))
+ if(! $s['success'])
return;
- $j = json_decode($s);
+ $j = json_decode($s['body'],true);
- logger('poco_load: json: ' . print_r($j,true),LOGGER_DATA);
+ logger('poco_load: ' . print_r($j,true),LOGGER_DATA);
- if(! isset($j->entry))
+ if(! x($j,'entry') && is_array($j['entry']))
return;
$total = 0;
- foreach($j->entry as $entry) {
+ foreach($j['entry'] as $entry) {
$total ++;
$profile_url = '';
$profile_photo = '';
- $connect_url = '';
+ $address = '';
$name = '';
+ $hash = '';
- $name = $entry->displayName;
+ $name = $entry['displayName'];
+ $hash = $entry['hash'];
- if(isset($entry->urls)) {
- foreach($entry->urls as $url) {
- if($url->type == 'profile') {
- $profile_url = $url->value;
+ if(x($entry,'urls') && is_array($entry['urls'])) {
+ foreach($entry['urls'] as $url) {
+ if($url['type'] == 'profile') {
+ $profile_url = $url['value'];
continue;
}
- if($url->type == 'webfinger') {
- $connect_url = str_replace('acct:' , '', $url->value);
+ if($url['type'] == 'zot') {
+ $address = str_replace('acct:' , '', $url['value']);
continue;
}
}
}
- if(isset($entry->photos)) {
- foreach($entry->photos as $photo) {
- if($photo->type == 'profile') {
- $profile_photo = $photo->value;
+ if(x($entry,'photos') && is_array($entry['photos'])) {
+ foreach($entry['photos'] as $photo) {
+ if($photo['type'] == 'profile') {
+ $profile_photo = $photo['value'];
continue;
}
}
}
- if((! $name) || (! $profile_url) || (! $profile_photo))
+ if((! $name) || (! $profile_url) || (! $profile_photo) || (! $hash) || (! $address))
continue;
- $x = q("select * from `gcontact` where `nurl` = '%s' limit 1",
- dbesc(normalise_link($profile_url))
+ $x = q("select xchan_hash from xchan where xchan_hash = '%s' limit 1",
+ dbesc($hash)
);
- if(count($x)) {
- $gcid = $x[0]['id'];
-
- if($x[0]['name'] != $name || $x[0]['photo'] != $profile_photo) {
- q("update gcontact set `name` = '%s', `photo` = '%s', `connect` = '%s', `url` = '%s'
- where `nurl` = '%s' limit 1",
- dbesc($name),
- dbesc($profile_photo),
- dbesc($connect_url),
- dbesc($profile_url),
- dbesc(normalise_link($profile_url))
- );
+ // We've never seen this person before. Import them.
+
+ if(($x !== false) && (! count($x))) {
+ if($address) {
+ $z = zot_finger($address,null);
+ if($z['success']) {
+ $j = json_decode($z['body'],true);
+ if($j)
+ import_xchan($j);
+ }
}
}
- else {
- q("insert into `gcontact` (`name`,`url`,`nurl`,`photo`,`connect`)
- values ( '%s', '%s', '%s', '%s','%s') ",
- dbesc($name),
- dbesc($profile_url),
- dbesc(normalise_link($profile_url)),
- dbesc($profile_photo),
- dbesc($connect_url)
- );
- $x = q("select * from `gcontact` where `nurl` = '%s' limit 1",
- dbesc(normalise_link($profile_url))
- );
- if(count($x))
- $gcid = $x[0]['id'];
- }
- if(! $gcid)
- return;
-
- $r = q("select * from glink where `cid` = %d and `uid` = %d and `gcid` = %d and `zcid` = %d limit 1",
- intval($cid),
- intval($uid),
- intval($gcid),
- intval($zcid)
+
+
+ $r = q("select * from xlink where xlink_xchan = '%s' and xlink_link = '%s' limit 1",
+ dbesc($xchan),
+ dbesc($hash)
);
- if(! count($r)) {
- q("insert into glink ( `cid`,`uid`,`gcid`,`zcid`, `updated`) values (%d,%d,%d,%d, '%s') ",
- intval($cid),
- intval($uid),
- intval($gcid),
- intval($zcid),
+ if(! $r) {
+ q("insert into xlink ( xlink_xchan, xlink_link, xlink_updated ) values ( '%s', '%s', '%s' ) ",
+ dbesc($xchan),
+ dbesc($hash),
dbesc(datetime_convert())
);
}
else {
- q("update glink set updated = '%s' where `cid` = %d and `uid` = %d and `gcid` = %d and zcid = %d limit 1",
+ q("update xlink set xlink_updated = '%s' where xlink_id = %d limit 1",
dbesc(datetime_convert()),
- intval($cid),
- intval($uid),
- intval($gcid),
- intval($zcid)
+ intval($r[0]['xlink_id'])
);
}
}
logger("poco_load: loaded $total entries",LOGGER_DEBUG);
- q("delete from glink where `cid` = %d and `uid` = %d and `zcid` = %d and `updated` < UTC_TIMESTAMP - INTERVAL 2 DAY",
- intval($cid),
- intval($uid),
- intval($zcid)
+ q("delete from xlink where xlink_xchan = '%s' and xlink_updated` < UTC_TIMESTAMP - INTERVAL 2 DAY",
+ dbesc($xchan)
);
-
}
diff --git a/include/zot.php b/include/zot.php
index ea2800672..46f0bd397 100644
--- a/include/zot.php
+++ b/include/zot.php
@@ -248,9 +248,11 @@ function zot_refresh($them,$channel = null) {
else
$permissions = $j['permissions'];
- foreach($permissions as $k => $v) {
- if($v) {
- $their_perms = $their_perms | intval($global_perms[$k][1]);
+ if($permissions && is_array($permissions)) {
+ foreach($permissions as $k => $v) {
+ if($v) {
+ $their_perms = $their_perms | intval($global_perms[$k][1]);
+ }
}
}
diff --git a/install/database.sql b/install/database.sql
index 6876514f2..5a17346e1 100644
--- a/install/database.sql
+++ b/install/database.sql
@@ -846,6 +846,17 @@ CREATE TABLE IF NOT EXISTS `xchan` (
KEY `xchan_connurl` (`xchan_connurl`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
+CREATE TABLE IF NOT EXISTS `xlink` (
+ `xlink_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
+ `xlink_xchan` char(255) NOT NULL DEFAULT '',
+ `xlink_link` char(255) NOT NULL DEFAULT '',
+ `xlink_updated` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
+ PRIMARY KEY (`xlink_id`),
+ KEY `xlink_xchan` ( `xlink_xchan` ),
+ KEY `xlink_link` ( `xlink_link` ),
+ KEY `xlink_updated` ( `xlink_updated` )
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
+
CREATE TABLE IF NOT EXISTS `xprof` (
`xprof_hash` char(255) NOT NULL,
`xprof_desc` char(255) NOT NULL DEFAULT '',
diff --git a/install/update.php b/install/update.php
index 614887709..549ae63ed 100644
--- a/install/update.php
+++ b/install/update.php
@@ -1,6 +1,6 @@
<?php
-define( 'UPDATE_VERSION' , 1013 );
+define( 'UPDATE_VERSION' , 1014 );
/**
*
@@ -197,3 +197,17 @@ ADD INDEX ( `xchan_connurl` )");
return UPDATE_SUCCESS;
return UPDATE_FAILED;
}
+
+function update_r1013() {
+ $r = q("CREATE TABLE if not exists `xlink` (
+`xlink_id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
+`xlink_xchan` CHAR( 255 ) NOT NULL DEFAULT '',
+`xlink_link` CHAR( 255 ) NOT NULL DEFAULT '',
+`xlink_updated` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00'
+) ENGINE = MYISAM ");
+
+ $r2 = q("alter table xlink add index ( xlink_xchan ), add index ( xlink_link ), add index ( xlink_updated ) ");
+ if($r && $r2)
+ return UPDATE_SUCCESS;
+ return UPDATE_FAILED;
+}
diff --git a/version.inc b/version.inc
index a0cec95ed..634eab4e6 100644
--- a/version.inc
+++ b/version.inc
@@ -1 +1 @@
-2012-12-31.186
+2013-01-01.187